Repository navigation
Conversation
| @@ -0,0 +1,5 @@ | |||
| const arr = [1, 2]; | |||
| const a = arr[0], b = arr[1]; | |||
| const x = [3, 4][0], y = [3, 4][1]; | |||
There was a problem hiding this comment.
Would love to hear some suggestion how to implement a "dummy" variable to avoid the double invocation
There was a problem hiding this comment.
We typically compile the Statements directly, i.e. not trying to "transpile" on the parser level, so we not only get a 1:1 roundtrip when serializing the AST again, but also do not have to deal with temporary AST nodes like the one that would be necessary here. Here, the compiler would typically implement a compileDestructuringAssignment method directly compiling to Binaryen IR, which may then use a temporary Wasm local.
There was a problem hiding this comment.
Make sense. From what I hear I need to set the NodeKind to DESTRUCTED_VARIABLE. And then handle it in compileStatement() switch?
There was a problem hiding this comment.
Or add a flag to the statement and keep the type to VARIABLE
|
@dcodeIO May I ask for your help with passing a test here. The same |
| var localCallableVarDeclaration: VariableDeclaration | undefined; | ||
| var localCallableIdentifier: IdentifierExpression | undefined; |
There was a problem hiding this comment.
AssemblyScript doesn't support undefined. Only null. And due to compiler support self-bootstrapping you should never use undefined even in compiler's codebase.
Update from mastte
|
@MaxGraey @dcodeIO took me a while to get the tests to pass (needed to rebase - I guess the tests runs agains master merge not my current branch dah...). I know you asked to use a local I can revert back to use a local // part of "compileElementAccessExpression()" method in compilers.ts
let thisArg = this.compileExpressionMaybeCached(targetExpression, thisType, destructingKey); // Try to hit a cache resultWhere The only issues is that I got an error from the optimization test because "the Binaryen IR tree is not flat". |
# Conflicts: # src/compiler.ts # tests/compiler/array-destructuring.optimized.wat # tests/compiler/array-destructuring.ts
|
This PR has been automatically marked as stale because it has not had recent activity. It will be closed in one week if no further activity occurs. Thank you for your contributions! |
|
This PR has been automatically closed due to lack of recent activity, but feel free to reopen it as long as you merge in the main branch afterwards. |
Per #1473, Im stated to implement destructuring assignment.
At this step, I will implement the array destructuring.
Please feel free to comment on the progress.