post
poster: Thetawaves
description: Scope
language: plain text
[download]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# this is the scope stack
ScopeStack = []
# current scope dictionary, default is global scope
# esp-ebp-offset is a virtual variable to keep track of the stack.
CurrentScope = {"esp-ebp-offset":0}

# Loop the statement function with control
def FuncBlock():
    global ScopeStack
    global CurrentScope
    
    # push the current scope onto the scope stack
    ScopeStack.append(CurrentScope)
    
    # initialize the current scope from the global variable dictionary
    CurrentScope = ScopeStack[0].copy()

    Match('{')
    StmEnd = GetRandIdent()
    primed = False
    while IsAlpha(Look):
        statementtype = Statement(StmEnd, primed)
        if statementtype == "IF":
            primed = True
        elif statementtype == "ELSE":
            StmEnd = GetRandIdent()
            
    Match('}')
    
    CurrentScope = ScopeStack.pop()