예제 #1
0
 def run(self, vm: VM):
     key = pop_value(vm)
     dict = pop(vm)
     if key in dict.value:
         push(vm, dict.value[key][1])
     else:
         push(vm, NullNode(None))
예제 #2
0
 def run(self, vm: VM):
     quote_false = pop(vm)
     quote_true = pop(vm)
     is_true = pop_value(vm)
     if is_true:
         vm.run_ast(quote_true.ast)
     else:
         vm.run_ast(quote_false.ast)
예제 #3
0
 def run(self, vm: VM):
     key = pop_value(vm)
     dict = pop(vm)
     value = NullNode(None)
     if key in dict.value:
         value = dict.value.pop(key)[1]
     push(vm, dict)
     push(vm, value)
예제 #4
0
 def run(self, vm: VM):
   parameters = []
   python_function = pop(vm)
   count_of_parameters = pop_value(vm)
   for _ in range(0,count_of_parameters):
     parameters.append(vm.stack.pop().value)
   parameters = parameters[::-1]
   result = python_function(*parameters)
   vm.stack.append(create_node(result))
예제 #5
0
 def run(self, vm: VM):
     quote = pop(vm)
     sequence = pop(vm)
     filtered = ArrayNode()
     for entry in sequence:
         run_node(vm, entry)
         vm.run_ast(quote.ast)
         result = pop_value(vm)
         if result:
             filtered.append(entry)
     push(vm, filtered)
예제 #6
0
 def run(self, vm: VM):
     value = pop_value(vm)
     push(vm, BooleanNode(not value, None))
예제 #7
0
 def run(self, vm: VM):
   python_code = pop_value(vm)
   result = create_node(eval(python_code))
   push(vm, result)
예제 #8
0
 def run(self, vm: VM):
   module_name = pop_value(vm)
   result = import_module(module_name)
   push(vm, result)
예제 #9
0
 def run(self, vm: VM):
   key = pop_value(vm)
   python_module = pop(vm)
   result = getattr(python_module, key)
   push(vm, result)
예제 #10
0
 def run(self, vm: VM):
   value1 = pop_value(vm)
   value2 = pop_value(vm)
   value = create_node(value2 / value1)
   push(vm, value)
예제 #11
0
 def run(self, vm: VM):
   value = create_node(pop_value(vm) * pop_value(vm))
   push(vm, value)
예제 #12
0
 def run(self, vm: VM):
     quote = pop(vm)
     is_true = pop_value(vm)
     if is_true:
         vm.run_ast(quote.ast)
예제 #13
0
 def run(self, vm: VM):
     quote = pop(vm)
     count = pop_value(vm)
     for _ in range(0, count):
         vm.run_ast(quote.ast)
예제 #14
0
 def run(self, vm: VM):
     key = pop_value(vm)
     dict = pop(vm)
     push(vm, BooleanNode(key in dict.value, None))
예제 #15
0
 def run(self, vm: VM):
     push(vm, StringNode(str(pop_value(vm)), None))