diff --git a/lib/boot/boot_space.rb b/lib/boot/boot_space.rb index fe64be33..04e8a968 100644 --- a/lib/boot/boot_space.rb +++ b/lib/boot/boot_space.rb @@ -58,7 +58,7 @@ module Boot obj.add_method_definition Salama::Kernel.send(f , @context) end obj = get_or_create_class :String - [:get , :set].each do |f| + [:get , :set , :puts].each do |f| #puts "Boot String::#{f}" obj.add_method_definition Boot::String.send(f , @context) end diff --git a/lib/boot/string.rb b/lib/boot/string.rb index cc12f462..818711b4 100644 --- a/lib/boot/string.rb +++ b/lib/boot/string.rb @@ -9,6 +9,10 @@ module Boot set_function = Virtual::MethodDefinition.new(:set , [Virtual::Integer, Virtual::Integer] , Virtual::Integer ,Virtual::Integer ) return set_function end + def puts context + puts_function = Virtual::MethodDefinition.new(:puts , [] ) + return puts_function + end end extend ClassMethods end diff --git a/lib/old_boot/string.rb b/lib/old_boot/string.rb index 05f1256c..ee14a998 100644 --- a/lib/old_boot/string.rb +++ b/lib/old_boot/string.rb @@ -9,6 +9,10 @@ module Boot set_function = Virtual::Function.new(:set , Virtual::Integer ,[Virtual::Integer, Virtual::Integer] , Virtual::Integer ) return set_function end + def puts context + puts_function = Virtual::Function.new(:puts , Virtual::Integer ,[] , Virtual::Reference ) + return puts_function + end end extend ClassMethods end diff --git a/lib/trickle/send.rb b/lib/trickle/send.rb index 0b1bac84..25521726 100644 --- a/lib/trickle/send.rb +++ b/lib/trickle/send.rb @@ -15,8 +15,9 @@ module Trickle elsif( me.is_a? Virtual::ObjectConstant ) clazz = me.clazz method = clazz.get_method_definition code.name - puts "Found me a method #{method}" raise "Method not implemented #{clazz.name}.#{code.name}" unless method + call = Virtual::FunctionCall.new( method ) + block.replace(code , [call] ) else raise "unimplemented" end diff --git a/lib/virtual/block.rb b/lib/virtual/block.rb index e8f93e0f..19fd05b1 100644 --- a/lib/virtual/block.rb +++ b/lib/virtual/block.rb @@ -34,7 +34,7 @@ module Virtual end # replace a code with an array of new codes. This is what happens in passes all the time - def replace_with code , new_codes + def replace code , new_codes index = @codes.index code raise "Code not found #{code} in #{self}" unless index @codes.delete_at(index) diff --git a/lib/virtual/instruction.rb b/lib/virtual/instruction.rb index 0bc3fce6..404adf53 100644 --- a/lib/virtual/instruction.rb +++ b/lib/virtual/instruction.rb @@ -75,6 +75,13 @@ module Virtual attr_reader :name , :me , :args end + class FunctionCall < Instruction + def initialize method + @method = method + end + attr_reader :method + end + # class for Set instructions, A set is basically a mem move. # to and from are indexes into the known objects(frame,message,self and new_message), or from may be a constant class Set < Instruction diff --git a/test/virtual/hello.rb b/test/virtual/hello.rb index b856a98a..4559bc2e 100644 --- a/test/virtual/hello.rb +++ b/test/virtual/hello.rb @@ -7,9 +7,8 @@ class HelloTest < MiniTest::Test 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) # puts Sof::Writer.write(Virtual::Object.space) end