several larger changes came together, bit of cleaning too

- all code must be in functions (which must be in classes).
— changes a fair few tests
— also changes api, as method is not recursive, not passed around
- all state in instance vars in compiler (no accessors)
- class is another such variable, surely more coming
all green again
This commit is contained in:
Torsten Ruger
2015-10-06 00:27:13 +03:00
parent 3d36fd1746
commit f4a4ccb98e
37 changed files with 302 additions and 205 deletions

View File

@ -4,7 +4,7 @@ module Bosl
def on_call expression
name , arguments , receiver = *expression
name = name.to_a.first
raise "not inside method " unless @method
if receiver
me = process( receiver.to_a.first )
else
@ -12,9 +12,9 @@ module Bosl
end
## need two step process, compile and save to frame
# then move from frame to new message
method.source.add_code Virtual::NewMessage.new
method.source.add_code Virtual::Set.new( me , Virtual::NewSelf.new(me.type))
method.source.add_code Virtual::Set.new( name.to_sym , Virtual::NewMessageName.new(:int))
@method.source.add_code Virtual::NewMessage.new
@method.source.add_code Virtual::Set.new( me , Virtual::NewSelf.new(me.type))
@method.source.add_code Virtual::Set.new( name.to_sym , Virtual::NewMessageName.new(:int))
compiled_args = []
arguments.to_a.each_with_index do |arg , i|
#compile in the running method, ie before passing control
@ -24,7 +24,7 @@ module Bosl
# so the next free is +1
to = Virtual::NewArgSlot.new(i + 1 ,val.type , val)
# (doing this immediately, not after the loop, so if it's a return it won't get overwritten)
method.source.add_code Virtual::Set.new( val , to )
@method.source.add_code Virtual::Set.new( val , to )
compiled_args << to
end
#method.source.add_code Virtual::MessageSend.new(name , me , compiled_args) #and pass control
@ -41,7 +41,7 @@ module Bosl
elsif( me.is_a? Fixnum )
name = :plus if name == :+
method = Virtual.machine.space.get_class_by_name(:Integer).get_instance_method(name)
#puts Virtual.machine.space.get_class_by_name(:Integer).method_names.to_a
puts Virtual.machine.space.get_class_by_name(:Integer).method_names.to_a
raise "Method not implemented Integer.#{name}" unless method
@method.source.add_code Virtual::MethodCall.new( method )
else