From 57782d3d47bcb52af0006ac75e75f3b3609b1d31 Mon Sep 17 00:00:00 2001 From: Matt Valentine-House Date: Thu, 30 Nov 2023 11:05:26 +0000 Subject: Store depth offset inside the scope node. Instead of incrementing the depth using call by reference as we're recursing up the stack we could instead store an offset for each known scope where we know the depth is going to represented differently in the Prism ast. --- prism_compile.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'prism_compile.h') diff --git a/prism_compile.h b/prism_compile.h index d307807b84..2d64811e69 100644 --- a/prism_compile.h +++ b/prism_compile.h @@ -13,6 +13,11 @@ typedef struct pm_scope_node { ID *constants; st_table *index_lookup_table; + + // Some locals are defined at higher scopes than they are used. We can use + // this offset to control which parent scopes local table we should be + // referencing from the current scope. + unsigned int local_depth_offset; } pm_scope_node_t; void pm_scope_node_init(const pm_node_t *node, pm_scope_node_t *scope, pm_scope_node_t *previous, pm_parser_t *parser); -- cgit v1.2.3