diff --git a/lib/ast/call_site_expression.rb b/lib/ast/call_site_expression.rb index a108ffe0..6b6fc15d 100644 --- a/lib/ast/call_site_expression.rb +++ b/lib/ast/call_site_expression.rb @@ -8,11 +8,13 @@ module Ast me = receiver.compile( method, message ) method.add_code Virtual::Set.new(Virtual::NewSelf.new(me.type), me) method.add_code Virtual::Set.new(Virtual::NewName.new(), name) + compiled_args = [] args.each_with_index do |arg , i| val = arg.compile( method, message) #compile in the running method, ie before passing control + compiled_args << val method.add_code Virtual::Set.new(Virtual::NewMessageSlot.new(i ,val.type ) , val ) end - method.add_code Virtual::MessageSend.new(name) #and pass control + method.add_code Virtual::MessageSend.new(name , me , compiled_args) #and pass control Virtual::Return.new( method.return_type ) end diff --git a/lib/boot/boot_memory.rb b/lib/boot/boot_memory.rb deleted file mode 100644 index e69de29b..00000000 diff --git a/lib/trickle/send.rb b/lib/trickle/send.rb index d1052fba..d69dd644 100644 --- a/lib/trickle/send.rb +++ b/lib/trickle/send.rb @@ -6,7 +6,10 @@ module Trickle def run block block.codes.dup.each do |code| next unless code.is_a? MessageSend - + if( code.me.type == Virtual::Reference) + + next + end end end end diff --git a/lib/virtual/constants.rb b/lib/virtual/constants.rb index f36183fd..8b5df53e 100644 --- a/lib/virtual/constants.rb +++ b/lib/virtual/constants.rb @@ -12,6 +12,9 @@ module Virtual # another abstract "marker" class (so we can check for it) # derived classes are Boot/Meta Class and StringConstant class ObjectConstant < Constant + def type + Virtual::Reference + end end class IntegerConstant < Constant @@ -34,9 +37,6 @@ module Virtual @string = str end attr_reader :string - def type - Virtual::Reference - end def result= value class_for(MoveInstruction).new(value , self , :opcode => :mov) end diff --git a/lib/virtual/instruction.rb b/lib/virtual/instruction.rb index b18799df..0bc3fce6 100644 --- a/lib/virtual/instruction.rb +++ b/lib/virtual/instruction.rb @@ -67,11 +67,12 @@ module Virtual end class MessageSend < Instruction - def initialize name , args = [] + def initialize name , me , args = [] @name = name.to_sym + @me = me @args = args end - attr_reader :name , :args + attr_reader :name , :me , :args end # class for Set instructions, A set is basically a mem move. diff --git a/test/virtual/hello.rb b/test/virtual/hello.rb new file mode 100644 index 00000000..e3bc3f13 --- /dev/null +++ b/test/virtual/hello.rb @@ -0,0 +1,34 @@ +require_relative "virtual_helper" + +class HelloTest < MiniTest::Test + include VirtualHelper + + def check + machine = Virtual::Machine.boot + expressions = machine.compile_main @string_input + puts "" + puts Sof::Writer.write(expressions) + Virtual::Object.space.run_passes + puts "" + puts Sof::Writer.write(expressions) + end + + def test_simplest_function + @string_input = <