-
Notifications
You must be signed in to change notification settings - Fork 155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Static arrays, bug fixes and improvements #148
Conversation
- Enable memory.dataSize
I think it would be better if we avoid overloading Say that at first I think I need a fixed size array for some purpose, but later change my mind, and deep down in my refactored code I have a Or even simpler: I just mix up the two while writing the code. It happens! If we have two function names instead, for example |
- Function calls are not allowed in global initializers
- Update dataSize to dataSize() so that it cannot be called outside a function
@JobLeonard I hear you, but I don't agree this will lead to negative trade-offs. I been thinking about it for a while, so it took me a bit to respond. The reason why To illustrate type ArrayLike = { 0: i32, 1: i32 };
const x: ArrayLike = <some-pointer-value>;
sizeof(x); // The type of x is known to be "ArrayLike" and its size is 2 * sizeof(i32)
const y: i32[] = [1, 2]; // hidden static struct type here, same keys as "ArrayLike"
sizeof(y); // The type of x is known and it's size is 2 * sizeof(i32) So the behavior is equivalent to existing sizeof rules, but because the type is not a symbol the only way to get the correct sizeof result is to reference This behavior has a side-effect where functions sharing this reference are required to pass in the length of the static data section manually to other functions to make it useful. Here is an example in action |
That is the healthier attitude to internet discussions, I'm grateful you gave it some thought! :) I don't think we're quite reasoning about the same thing though? Your line of thought: does My line of thought: does overloading a keyword make it more or less likely that bugs appear due to this overloading? Your reasoning is sound, but the examples I gave have nothing to do with it, and everything to do with how people rewrite their code. Of course, it still comes down to a decision which trade-off matters more even then. |
Wait, why are some of these |
Oh hey, good catch! The grammar rules were too permissive and allowed for non-array types in the declarations. Simple enough to fix in #150 |
Quality of life improvements and bug fixes
New Features
Implements static arrays as opaque types, when defined on a global scope:
These arrays are not possible to define inside a function call, so they are statics. This is a pretty decent metod of witing Data section entries into a binary, which was pretty difficult to do before.
Fixes
walt-cli
should be using peerDeps for compiler/linkerwalt-cli
compiler api update to work withwalt-compiler@0.10.0+
walt-cli
did not use working directorywalt-compiler
did not handle escape sequences correctlywalt-cli
add additional testsAdditions
Will implement #79
memory.dataSize()
memory.grow()
memory.size()