Exemplo n.º 1
0
 def exp(self, op, quad):
     '''Evaluates expression using ops table'''
     mode_params = utils.mode_params
     op1 = memory.get(quad[2], mode_params)
     if (quad[3]):  # If operation is binary
         op2 = memory.get(quad[3], mode_params)
         value = ops[op](op1, op2)
     else:  # If operation is unary
         value = ops[op](op1)
     memory.set(quad[4], value, mode_params)
Exemplo n.º 2
0
 def ver(self, quad):
     '''Verifies if index is inbounds'''
     func = utils.func_stack[len(utils.func_stack) - 1]
     var_name = quad[4] + '-' + str(memory.get(quad[2]))
     if (var_name not in memory.func_dir[func]['vars']
             and var_name not in memory.func_dir['global']['vars']):
         err('Out of bounds!', var_name)
Exemplo n.º 3
0
 def test_get_use_non_existent_var_exp_none(self):
     self.assertIsNotNone(not memory.get("not_existent_var"))
Exemplo n.º 4
0
 def test_get_use_server_config_exp_success(self):
     self.assertIsNotNone(memory.get("server_config"))
Exemplo n.º 5
0
def addLiteral(key, port, val):
    inst = memory.get(key)
    inst.addLiteral(port, val)
Exemplo n.º 6
0
def addDestination(srcKey, srcPort, dstKey, dstPort):
    inst = memory.get(srcKey)
    inst.addDestination(srcPort, dstKey, dstPort)
Exemplo n.º 7
0
 def param(self, quad):
     '''Set param to function'''
     val = memory.get(quad[2], True)
     memory.set(quad[4], val)
Exemplo n.º 8
0
 def gotof(self, quad):
     '''Evalates an expression to see if it is false it makes a jump'''
     value = memory.get(quad[2])
     if (not value):
         self.pos = quad[4] - 2
Exemplo n.º 9
0
 def equal(self, quad):
     '''Assigns value of an expression to a variable'''
     value = memory.get(quad[2])
     memory.set(quad[4], value)
Exemplo n.º 10
0
 def eprint(self, quad):
     '''Prints to terminal and IDE output'''
     value = str(memory.get(quad[4])).upper()
     for char in value:
         if char in emoji_letters:
             self.output.write(emoji_letters[char] + '\n')
Exemplo n.º 11
0
 def print(self, quad):
     '''Prints to terminal and IDE output'''
     value = memory.get(quad[4])
     self.output.write(str(value) + '\n')
     print(value)
Exemplo n.º 12
0
 def ret(self, quad):
     '''Sets the return value to the global variable that stores returns'''
     func = utils.func_stack[len(utils.func_stack) - 1]
     val = memory.get(quad[2])
     memory.set(quad[4], val)
     self.pos = memory.func_dir[func]['end'] - 2