Ejemplo n.º 1
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
Ejemplo n.º 2
0
    def view(self, symbols, cmd, cmds):
        # view the top of the stack (typically where results are)
        ret = 1
        print('Top of stack = ', variables.top(
            symbols,
            1))  # we're going to peek at the top of the stack without popping

        return ret
Ejemplo n.º 3
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
Ejemplo n.º 4
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
Ejemplo n.º 5
0
 def x_le_y(self, symbols, cmd, cmds):
     # only continue if the top value <= the second value on the stack
     if variables.top(symbols, 1) <= variables.top(symbols, 2):
         return 1
     else:
         return len(cmds) + 1
Ejemplo n.º 6
0
 def x_ne_y(self, symbols, cmd, cmds):
     # only continues eval if the two top values are not equal
     if variables.top(symbols, 1) != variables.top(symbols, 2):
         return 1
     else:
         return len(cmds) + 1
Ejemplo n.º 7
0
 def x_ne_zero(self, symbols, cmd, cmds):
     # only continues eval if the top of the stack is not 0
     if variables.top(symbols, 1) != 0:
         return 1
     else:
         return len(cmds) + 1
Ejemplo n.º 8
0
    def dup(self, symbols, cmd, cmds):
        # duplicates the value on the top of the stack
        ret = 1
        variables.push(symbols, variables.top(symbols, 1))

        return ret