Example #1
0
	def ret_proc(self, ret_value):
		vm_trace.print_info("Thread", "Procedure Returned (return value = {0})".format(ret_value))
		self.frame_stack.pop()
		if len(self.frame_stack) <= 0:
			self.halt()
		else:
			self.current_frame().push_eval_stack_value(ret_value)
Example #2
0
 def run(self):
     # Only supports single-threading at this time
     vm_trace.print_info("Domain", "Running Domain...")
     try:
         while self.threads[0].is_running:
             self.threads[0].step()
     except vm_exception.VMException as e:
         # Handle VM Exception
         vm_trace.print_error(e.error_class, e.error_type, e.error_subtype, e.error_info)
     finally:
         vm_trace.print_info("Domain", "Finished Running Domain...")
Example #3
0
File: vm.py Project: bstockus/vm
codes = [	20, 3,
			58,
			61,
			2,
			2,
			2,
			2,
			20, 0,
			56, 0,
			20, 1,
			56, 1,
			20, 2,
			56, 2,
			20, 4,
			56, 3,
			20, 5,
			56, 4,
			10		# HALT
		]

token_types = 	{
					vm_values.TokenValue("sys","obj") : vm_blocks.Type(5,5)
				}

proc = vm_blocks.Proc(0, 5, consts, codes)
domain = vm_domain.Domain(token_types)
domain.spawn_thread(proc)
domain.run()

vm_trace.print_info('Domain', "Tokens Map = {0}".format(domain.tokens_map))
vm_trace.print_info('Domain', "Pool = {0}".format(domain.pool.blocks))
Example #4
0
	def halt(self):
		vm_trace.print_info("Thread", "Thread Halted.")
		self.is_running = False
Example #5
0
	def call_proc(self, proc, params):
		vm_trace.print_info("Thread", "Procedure Called (params = {0}, consts = {1})".format(params, proc.consts))
		self.frame_stack.append(vm_frame.Frame(self, proc, params))