コード例 #1
0
 def is_local_not_def(self, symbols, cmd, cmds):
     # only continue if the variable is not defined locally
     ret = 1
     ret, v = variables.next_cmd(ret, cmds)
     if not variables.is_defined(v, symbols[SYM_LOCAL]):
         return ret
     else:
         return len(cmds) + 1
コード例 #2
0
    def sto_l(self, symbols, cmd, cmds):
        # stores the value on the top of the stack into the local variable named by the next token
        ret = 1
        ret, v = variables.next_cmd(ret, cmds)
        a = variables.top(symbols, 1)
        variables.put(v, a, symbols[SYM_LOCAL])

        return ret
コード例 #3
0
 def is_global_not_def(self, symbols, cmd, cmds):
     # only continue if the variable is not defined globally
     ret = 1
     ret, v = variables.next_cmd(ret, cmds)
     with symbols[SYM_GLOBAL][0]:  # lock the globals while we do this
         if not variables.is_defined(v, symbols[SYM_GLOBAL][1]):
             return ret
         else:
             return len(cmds) + 1
コード例 #4
0
    def rcl_l(self, symbols, cmd, cmds):
        # recalls a local variable (not overly useful, but avoids ambiguity)
        ret = 1
        ret, v = variables.next_cmd(ret, cmds)
        a = variables.get(v, symbols[SYM_LOCAL], None,
                          param_convs._any)  # as an integer
        variables.push(symbols, a)

        return ret
コード例 #5
0
    def rcl(self, symbols, cmd, cmds):
        # recalls a variable.  Try local first, then global
        ret = 1
        ret, v = variables.next_cmd(ret, cmds)
        with symbols[SYM_GLOBAL][0]:  # lock the globals while we do this
            a = variables.get(v, symbols[SYM_LOCAL], symbols[SYM_GLOBAL][1],
                              param_convs._any)  # as an integer
        variables.push(symbols, a)

        return ret
コード例 #6
0
 def is_def(self, symbols, cmd, cmds):
     # only continue if the variable is defined (locally or globally is OK)
     ret = 1
     ret, v = variables.next_cmd(ret, cmds)
     with symbols[SYM_GLOBAL][0]:  # lock the globals while we do this
         if variables.is_defined(
                 v, symbols[SYM_GLOBAL][1]) or variables.is_defined(
                     v, symbols[SYM_LOCAL]):
             return ret
         else:
             return len(cmds) + 1
コード例 #7
0
    def rcl_g(self, symbols, cmd, cmds):
        # recalls a global variable (useful if you define an identical local var)
        ret = 1
        ret, v = variables.next_cmd(ret, cmds)
        with symbols[SYM_GLOBAL][0]:  # lock the globals while we do this
            a = variables.get(
                v, None, symbols[SYM_GLOBAL][1], param_convs._any
            )  # grab the value from the global vars as an integer
        variables.push(symbols, a)  # and push onto the stack

        return ret
コード例 #8
0
    def sto_g(self, symbols, cmd, cmds):
        # stores the value on the top of the stack into the global variable named by the next token
        ret = 1
        ret, v = variables.next_cmd(ret,
                                    cmds)  # what's the name of the variable?
        a = variables.top(symbols,
                          1)  # will be stored from the top of the stack
        with symbols[SYM_GLOBAL][0]:  # lock the globals
            variables.put(v, a, symbols[SYM_GLOBAL][1])  # and store it there

        return ret
コード例 #9
0
    def sto(self, symbols, cmd, cmds):
        # stores the value in local var if it exists, otherwise global var.  If neither, creates local
        ret = 1
        ret, v = variables.next_cmd(ret,
                                    cmds)  # what's the name of the variable?
        a = variables.top(symbols,
                          1)  # will be stored from the top of the stack

        variables.Auto_store(v, a, symbols)  # "auto store" the value

        return ret