-
Notifications
You must be signed in to change notification settings - Fork 23
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
Consider adding IfElseStatement for if-then-else, separating from IfStatement for if-then #33
Comments
Anything that simplifies streaming bytecode compilation is a good idea. So I'm for this. |
How about having a “variant” byte after the node type (defaulting to
|
having another variant for IfStatement with empty-then-clause sounds interesting. Then, about variant byte, if we can (or should?) throw error if the subtree violates the variant's structure, I think it's almost the same thing as adding dedicated interfaces for each, and just using dedicated interface should be simpler (we don't need extra byte for each node). If the variant is just a hint and the tree may violate the hint, it won't so much simplify bytecode compilation. |
I agree that the hint doesn't look useful to me. It takes more space, adds one more possible hint violation/syntax error, and I don't feel that it would improve anything. The empty-then-clause is an interesting question. How would we use the information? |
currently we're not emitting different bytecode for empty-then-clause case, |
Note that the format I'm currently experimenting doesn't care all that much about having more than 128 nodes. We only get an observable compression impact if we have more than 128 instances of Expression or more than 128 instances of Statement, etc. in a single file. |
(moved from binast/binjs-ref#131)
Background
IfStatement
has optionalalternate
statement, and the existence of thealternate
is unknown until we start parsing it, that means, it's unknown when generating branch opcode or generating bytecode forconsequent
So, with current
IfStatement
interface, we should modify the branch's kind (source note) when it turns out that there'salternate
.It would be better that kind of information is known at the beginning.
Solution
Separate
IfStatement
intoIfStatement
withoutalternate
, andIfElseStatement
withalternate
Pros
alternate
becomes smaller in .binjs fileCons
(With multipart encoding, increasing interfaces may result in the number of tuple index exceeding 127, which results in 2-bytes data inside [TREE])
Consideration
The text was updated successfully, but these errors were encountered: