Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
internal/planner: Insert general ref head objects starting from the l…
…eaves, not root. (#6401) This way the object insert operations can return a new object instance. Before, the object construction for a rule like p[a][b] := ... would look like this: *ir.BlockStmt BlockStmt (1 blocks) *ir.Block Block (3 statements) *ir.BlockStmt BlockStmt (1 blocks) *ir.Block Block (2 statements) *ir.DotStmt &{Source:{Value:Local<2>} Key:{Value:Local<10>} Target:Local<14>} *ir.BreakStmt &{Index:1} *ir.MakeObjectStmt &{Target:Local<14>} *ir.ObjectInsertOnceStmt &{Key:{Value:Local<10>} Value:{Value:Local<14>} Object:Local<2>} *ir.ObjectInsertOnceStmt &{Key:{Value:Local<11>} Value:{Value:Local<13>} Object:Local<14>} Now, it'll look like *ir.BlockStmt BlockStmt (1 blocks) *ir.Block Block (2 statements) *ir.BlockStmt BlockStmt (1 blocks) *ir.Block Block (2 statements) *ir.DotStmt &{Source:{Value:Local<2>} Key:{Value:Local<10>} Target:Local<14>} *ir.BreakStmt &{Index:1} *ir.MakeObjectStmt &{Target:Local<14>} *ir.ObjectInsertOnceStmt &{Key:{Value:Local<11>} Value:{Value:Local<13>} Object:Local<14>} *ir.ObjectInsertStmt &{Key:{Value:Local<10>} Value:{Value:Local<14>} Object:Local<2>} so the object in Local<14> is built first, and the added to object Local<2>. Signed-off-by: Stephan Renatus <stephan@styra.com> Co-authored-by: Teemu Koponen <koponen@styra.com>
- Loading branch information