def add_instance_primitive(self, value, warn_if_not_existing): if self.add_instance_invokable(value) and warn_if_not_existing: from som.vm.universe import std_print, std_println std_print("Warning: Primitive " + value.get_signature().get_embedded_string()) std_println(" is not in class definition for class " + self.get_name().get_embedded_string())
def print_stack_trace(self, bytecode_index): # Print a stack trace starting in this frame from som.vm.universe import std_print, std_println std_print(self.get_method().get_holder().get_name().get_string()) std_println(" %d @ %s" % (bytecode_index, self.get_method().get_signature().get_string())) if self.has_previous_frame(): self.get_previous_frame().print_stack_trace()
def print_stack_trace(self, bytecode_index): # Print a stack trace starting in this frame from som.vm.universe import std_print, std_println std_print(self.get_method().get_holder().get_name().get_string()) std_println( " %d @ %s" % (bytecode_index, self.get_method().get_signature().get_string())) if self.has_previous_frame(): self.get_previous_frame().print_stack_trace()
def start(self): from som.vm.universe import std_println, error_println counter = 0 it = self._universe.nilObject std_println("SOM Shell. Type \"quit\" to exit.\n") # Create a fake bootstrap frame current_frame = self._interpreter.new_frame(None, self._bootstrap_method, None) while True: try: # Read a statement from the keyboard stmt = raw_input("---> ") if stmt == "quit" or stmt == "": return elif stmt == "\n": continue # Generate a temporary class with a run method stmt = ("Shell_Class_" + str(counter) + " = ( run: it = ( | tmp | tmp := (" + stmt + " ). 'it = ' print. ^tmp println ) )") counter += 1 # Compile and load the newly generated class my_class = self._universe.load_shell_class(stmt) # If success if my_class: current_frame.reset_stack_pointer() # Create and push a new instance of our class on the stack my_object = self._universe.new_instance(my_class) current_frame.push(my_object) # Push the old value of "it" on the stack current_frame.push(it) # Lookup the run: method initialize = my_class.lookup_invokable( self._universe.symbol_for("run:")) # Invoke the run method initialize.invoke(current_frame, self._interpreter) # Save the result of the run method it = current_frame.pop() except Exception as e: if not we_are_translated(): # this cannot be done in rpython import traceback traceback.print_exc() error_println("Caught exception: %s" % e)
def start(self): from som.vm.universe import std_println, error_println counter = 0 it = nilObject std_println("SOM Shell. Type \"quit\" to exit.\n") while True: try: # Read a statement from the keyboard stmt = raw_input("---> ") if stmt == "quit" or stmt == "": return elif stmt == "\n": continue # Generate a temporary class with a run method stmt = ("Shell_Class_" + str(counter) + " = ( run: it = ( | tmp | tmp := (" + stmt + " ). 'it = ' print. ^tmp println ) )") counter += 1 # Compile and load the newly generated class my_class = self._universe.load_shell_class(stmt) # If success if my_class: # Create and push a new instance of our class on the stack my_object = self._universe.new_instance(my_class) # Lookup the run: method initialize = my_class.lookup_invokable( self._universe.symbol_for("run:")) # Invoke the run method it = initialize.invoke(my_object, [it], False) except Exception as e: if not we_are_translated(): # this cannot be done in rpython import traceback traceback.print_exc() error_println("Caught exception: %s" % e)
def _print_newline(ivkbl, rcvr, args, meta_level): std_println() return rcvr
def _print_newline(ivkbl, frame, interpreter): std_println()
def add_instance_primitive(self, value, display_warning): if self.add_instance_invokable(value) and display_warning: from som.vm.universe import std_print, std_println std_print("Warning: Primitive " + value.get_signature().get_string()) std_println(" is not in class definition for class " + self.get_name().get_string())
def _print_newline(ivkbl, rcvr, args): std_println() return rcvr