add FunctionCall instruction and the missing puts (stub)
This commit is contained in:
parent
e19b7be111
commit
91ce05364a
@ -58,7 +58,7 @@ module Boot
|
|||||||
obj.add_method_definition Salama::Kernel.send(f , @context)
|
obj.add_method_definition Salama::Kernel.send(f , @context)
|
||||||
end
|
end
|
||||||
obj = get_or_create_class :String
|
obj = get_or_create_class :String
|
||||||
[:get , :set].each do |f|
|
[:get , :set , :puts].each do |f|
|
||||||
#puts "Boot String::#{f}"
|
#puts "Boot String::#{f}"
|
||||||
obj.add_method_definition Boot::String.send(f , @context)
|
obj.add_method_definition Boot::String.send(f , @context)
|
||||||
end
|
end
|
||||||
|
@ -9,6 +9,10 @@ module Boot
|
|||||||
set_function = Virtual::MethodDefinition.new(:set , [Virtual::Integer, Virtual::Integer] , Virtual::Integer ,Virtual::Integer )
|
set_function = Virtual::MethodDefinition.new(:set , [Virtual::Integer, Virtual::Integer] , Virtual::Integer ,Virtual::Integer )
|
||||||
return set_function
|
return set_function
|
||||||
end
|
end
|
||||||
|
def puts context
|
||||||
|
puts_function = Virtual::MethodDefinition.new(:puts , [] )
|
||||||
|
return puts_function
|
||||||
|
end
|
||||||
end
|
end
|
||||||
extend ClassMethods
|
extend ClassMethods
|
||||||
end
|
end
|
||||||
|
@ -9,6 +9,10 @@ module Boot
|
|||||||
set_function = Virtual::Function.new(:set , Virtual::Integer ,[Virtual::Integer, Virtual::Integer] , Virtual::Integer )
|
set_function = Virtual::Function.new(:set , Virtual::Integer ,[Virtual::Integer, Virtual::Integer] , Virtual::Integer )
|
||||||
return set_function
|
return set_function
|
||||||
end
|
end
|
||||||
|
def puts context
|
||||||
|
puts_function = Virtual::Function.new(:puts , Virtual::Integer ,[] , Virtual::Reference )
|
||||||
|
return puts_function
|
||||||
|
end
|
||||||
end
|
end
|
||||||
extend ClassMethods
|
extend ClassMethods
|
||||||
end
|
end
|
||||||
|
@ -15,8 +15,9 @@ module Trickle
|
|||||||
elsif( me.is_a? Virtual::ObjectConstant )
|
elsif( me.is_a? Virtual::ObjectConstant )
|
||||||
clazz = me.clazz
|
clazz = me.clazz
|
||||||
method = clazz.get_method_definition code.name
|
method = clazz.get_method_definition code.name
|
||||||
puts "Found me a method #{method}"
|
|
||||||
raise "Method not implemented #{clazz.name}.#{code.name}" unless method
|
raise "Method not implemented #{clazz.name}.#{code.name}" unless method
|
||||||
|
call = Virtual::FunctionCall.new( method )
|
||||||
|
block.replace(code , [call] )
|
||||||
else
|
else
|
||||||
raise "unimplemented"
|
raise "unimplemented"
|
||||||
end
|
end
|
||||||
|
@ -34,7 +34,7 @@ module Virtual
|
|||||||
end
|
end
|
||||||
|
|
||||||
# replace a code with an array of new codes. This is what happens in passes all the time
|
# 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
|
index = @codes.index code
|
||||||
raise "Code not found #{code} in #{self}" unless index
|
raise "Code not found #{code} in #{self}" unless index
|
||||||
@codes.delete_at(index)
|
@codes.delete_at(index)
|
||||||
|
@ -75,6 +75,13 @@ module Virtual
|
|||||||
attr_reader :name , :me , :args
|
attr_reader :name , :me , :args
|
||||||
end
|
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.
|
# 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
|
# to and from are indexes into the known objects(frame,message,self and new_message), or from may be a constant
|
||||||
class Set < Instruction
|
class Set < Instruction
|
||||||
|
@ -7,9 +7,8 @@ class HelloTest < MiniTest::Test
|
|||||||
machine = Virtual::Machine.boot
|
machine = Virtual::Machine.boot
|
||||||
expressions = machine.compile_main @string_input
|
expressions = machine.compile_main @string_input
|
||||||
puts ""
|
puts ""
|
||||||
puts Sof::Writer.write(expressions)
|
|
||||||
Virtual::Object.space.run_passes
|
Virtual::Object.space.run_passes
|
||||||
puts ""
|
puts Sof::Writer.write(expressions)
|
||||||
# puts Sof::Writer.write(Virtual::Object.space)
|
# puts Sof::Writer.write(Virtual::Object.space)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user