(string) source knockoffs
This commit is contained in:
parent
c426f4a6d5
commit
e6743c7216
@ -15,10 +15,10 @@ module Register
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.issue_call caller , callee
|
def self.issue_call compiler , callee
|
||||||
# move the current new_message to message
|
# 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
|
# do the register call
|
||||||
caller.source.add_code FunctionCall.new( caller , callee )
|
compiler.add_code FunctionCall.new( "__call__" , callee )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -30,11 +30,11 @@ module Register
|
|||||||
methods = []
|
methods = []
|
||||||
@space.classes.values.each do |c|
|
@space.classes.values.each do |c|
|
||||||
c.instance_methods.each do |f|
|
c.instance_methods.each do |f|
|
||||||
methods << f.source
|
methods << f
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
methods.each do |method|
|
methods.each do |method|
|
||||||
instruction = method.method.instructions
|
instruction = method.instructions
|
||||||
while instruction.next
|
while instruction.next
|
||||||
nekst = instruction.next
|
nekst = instruction.next
|
||||||
t = translator.translate(nekst) # returning nil means no replace
|
t = translator.translate(nekst) # returning nil means no replace
|
||||||
@ -72,7 +72,7 @@ module Register
|
|||||||
syntax = @parser.parse_with_debug(bytes)
|
syntax = @parser.parse_with_debug(bytes)
|
||||||
parts = Parser::Transform.new.apply(syntax)
|
parts = Parser::Transform.new.apply(syntax)
|
||||||
#puts parts.inspect
|
#puts parts.inspect
|
||||||
Soml::Compiler.compile( parts )
|
Soml.compile( parts )
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -9,12 +9,12 @@ module Soml
|
|||||||
reset_regs
|
reset_regs
|
||||||
#move the new message (that we need to populate to make a call) to std register
|
#move the new message (that we need to populate to make a call) to std register
|
||||||
new_message = Register.resolve_to_register(:new_message)
|
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
|
if receiver
|
||||||
me = process( receiver.first )
|
me = process( receiver.first )
|
||||||
else
|
else
|
||||||
me = use_reg @method.for_class.name
|
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
|
end
|
||||||
if(me.type == :Class)
|
if(me.type == :Class)
|
||||||
clazz = me.value.meta
|
clazz = me.value.meta
|
||||||
@ -40,7 +40,7 @@ module Soml
|
|||||||
val = process( arg)
|
val = process( arg)
|
||||||
raise "Not register #{val}" unless val.is_a?(Register::RegisterValue)
|
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)
|
# 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
|
add_code set
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -49,11 +49,11 @@ module Soml
|
|||||||
method = clazz.get_instance_method(name)
|
method = clazz.get_instance_method(name)
|
||||||
#puts Register.machine.space.get_class_by_name(:Integer).method_names.to_a
|
#puts Register.machine.space.get_class_by_name(:Integer).method_names.to_a
|
||||||
raise "Method not implemented #{me.type}.#{name}" unless method
|
raise "Method not implemented #{me.type}.#{name}" unless method
|
||||||
Register.issue_call( @method , method )
|
Register.issue_call( self , method )
|
||||||
ret = use_reg( :Integer )
|
ret = use_reg( :Integer )
|
||||||
# the effect of the method is that the NewMessage Return slot will be filled, return it
|
# the effect of the method is that the NewMessage Return slot will be filled, return it
|
||||||
# but move it into a register too
|
# 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
|
ret
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user