def new_block(self, method, context_frame, arguments): # Allocate a new block and set its class to be the block class result = Block(self._nilObject, method, context_frame) result.set_class(self._get_block_class(arguments)) # Return the freshly allocated block return result
def _get_block_class(self, number_of_arguments = None): if not number_of_arguments: # Get the generic block class return self._blockClass # Compute the name of the block class with the given number of # arguments name = self.symbol_for("Block" + str(number_of_arguments)) # Lookup the specific block class in the dictionary of globals and # return it if self.has_global(name): return self.get_global(name) # Get the block class for blocks with the given number of arguments result = self._load_class(name, None) # Add the appropriate value primitive to the block class result.add_instance_primitive(Block.get_evaluation_primitive(number_of_arguments, self)) # Insert the block class into the dictionary of globals self.set_global(name, result) # Return the loaded block class return result
def _get_block_class(self, number_of_arguments=None): if not number_of_arguments: # Get the generic block class return self._blockClass # Compute the name of the block class with the given number of # arguments name = self.symbol_for("Block" + str(number_of_arguments)) # Lookup the specific block class in the dictionary of globals and # return it if self.has_global(name): return self.get_global(name) # Get the block class for blocks with the given number of arguments result = self._load_class(name, None) # Add the appropriate value primitive to the block class result.add_instance_primitive( Block.get_evaluation_primitive(number_of_arguments, self)) # Insert the block class into the dictionary of globals self.set_global(name, result) # Return the loaded block class return result
def new_block(method, context_frame): return Block(method, context_frame)
def new_block(method, context_values): return Block(method, context_values)
def setUp(self): self.method = 0 self.context = 0 self.block = Block(Object(None), )