(string) source knockoffs

This commit is contained in:
Torsten Ruger 2015-10-28 21:39:59 +02:00
parent c426f4a6d5
commit e6743c7216
3 changed files with 11 additions and 11 deletions

View File

@ -15,10 +15,10 @@ module Register
end
end
def self.issue_call caller , callee
def self.issue_call compiler , callee
# move the current new_message to message
caller.source.add_code RegisterTransfer.new(caller, Register.new_message_reg , Register.message_reg )
compiler.add_code RegisterTransfer.new("__call__", Register.new_message_reg , Register.message_reg )
# do the register call
caller.source.add_code FunctionCall.new( caller , callee )
compiler.add_code FunctionCall.new( "__call__" , callee )
end
end

View File

@ -30,11 +30,11 @@ module Register
methods = []
@space.classes.values.each do |c|
c.instance_methods.each do |f|
methods << f.source
methods << f
end
end
methods.each do |method|
instruction = method.method.instructions
instruction = method.instructions
while instruction.next
nekst = instruction.next
t = translator.translate(nekst) # returning nil means no replace
@ -72,7 +72,7 @@ module Register
syntax = @parser.parse_with_debug(bytes)
parts = Parser::Transform.new.apply(syntax)
#puts parts.inspect
Soml::Compiler.compile( parts )
Soml.compile( parts )
end
end

View File

@ -9,12 +9,12 @@ module Soml
reset_regs
#move the new message (that we need to populate to make a call) to std register
new_message = Register.resolve_to_register(:new_message)
add_code Register.get_slot(@method, :message , :next_message , new_message )
add_code Register.get_slot(statement, :message , :next_message , new_message )
if receiver
me = process( receiver.first )
else
me = use_reg @method.for_class.name
add_code Register.get_slot(@method, :message , :receiver , me )
add_code Register.get_slot(statement, :message , :receiver , me )
end
if(me.type == :Class)
clazz = me.value.meta
@ -40,7 +40,7 @@ module Soml
val = process( arg)
raise "Not register #{val}" unless val.is_a?(Register::RegisterValue)
# which we load int the new_message at the argument's index (the one comes from c index)
set = Register.set_slot( statement , val , :new_message , Parfait::Message.get_indexed(i+1))
set = Register.set_slot( arg , val , :new_message , Parfait::Message.get_indexed(i+1))
add_code set
end
@ -49,11 +49,11 @@ module Soml
method = clazz.get_instance_method(name)
#puts Register.machine.space.get_class_by_name(:Integer).method_names.to_a
raise "Method not implemented #{me.type}.#{name}" unless method
Register.issue_call( @method , method )
Register.issue_call( self , method )
ret = use_reg( :Integer )
# the effect of the method is that the NewMessage Return slot will be filled, return it
# but move it into a register too
add_code Register.get_slot(@method, :message , :return_value , ret )
add_code Register.get_slot(statement, :message , :return_value , ret )
ret
end
end