mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 23:58:20 +00:00
Add scope field to {} nodes
Since we need to add variables, we need to know which scope to add them to. Add this information to the {} node, which is what creates a new scope. An alternative would be to scan for any variable or label declaration within the braces and use that or create a new one if none, which is more expensive and may waste symbol tables.
This commit is contained in:
parent
3542824d51
commit
76f483fc11
3 changed files with 32 additions and 14 deletions
|
@ -124,7 +124,9 @@ class lastpass(object):
|
|||
# function (must be the result of optimization).
|
||||
# Insert dummy IF(1){...} statement covering the whole function
|
||||
# (if it returs a value, insert a return statement too).
|
||||
child[0] = nr(nt='{}', t=None, ch=[
|
||||
scope = len(self.symtab)
|
||||
self.symtab.append({})
|
||||
child[0] = nr(nt='{}', t=None, scope=scope, ch=[
|
||||
nr(nt='IF', t=None, ch=[
|
||||
nr(nt='CONST', t='integer', value=1, SEF=True),
|
||||
child[0]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue