diff --git a/lib/arm/arm_machine.rb b/lib/arm/arm_machine.rb index 224d34dc..d8e5deea 100644 --- a/lib/arm/arm_machine.rb +++ b/lib/arm/arm_machine.rb @@ -34,8 +34,8 @@ module Arm def main_start context entry = Vm::Block.new("main_entry",nil,nil) - entry.do_add mov( :fp , 0 ) - entry.do_add call( context.function ) + entry.add_code mov( :fp , 0 ) + entry.add_code call( context.function ) entry end def main_exit context @@ -44,11 +44,11 @@ module Arm exit end def function_entry block, f_name - block.do_add push( [:lr] ) + block.add_code push( [:lr] ) block end def function_exit entry , f_name - entry.do_add pop( [:pc] ) + entry.add_code pop( [:pc] ) entry end @@ -93,8 +93,8 @@ module Arm # This is very arm specific, syscall number is passed in r7, other arguments like a c call ie 0 and up sys = Vm::Integer.new( Vm::RegisterReference.new(:r7) ) ret = Vm::Integer.new( Vm::RegisterReference.new(RETURN_REG) ) - block.do_add mov( sys , num ) - block.do_add swi( 0 ) + block.add_code mov( sys , num ) + block.add_code swi( 0 ) #todo should write type into r1 according to syscall ret end diff --git a/lib/boot/object.rb b/lib/boot/object.rb index 439c4398..90e8bd15 100644 --- a/lib/boot/object.rb +++ b/lib/boot/object.rb @@ -39,7 +39,7 @@ module Boot return get_function end - def _set_instance_variable(context , name , value) + def _set_instance_variable(context , name = Vm::Integer , value = Vm::Integer ) set_function = Vm::Function.new(:_set_instance_variable , Vm::Integer , [ Vm::Integer , Vm::Integer] , Vm::Integer ) me = set_function.receiver var_name = set_function.args.first diff --git a/lib/vm/block.rb b/lib/vm/block.rb index b9add585..e38eb0b9 100644 --- a/lib/vm/block.rb +++ b/lib/vm/block.rb @@ -41,7 +41,7 @@ module Vm ret end - def do_add kode + def add_code kode kode.assigns.each { |a| (@assigns << a) unless @assigns.include?(a) } kode.uses.each { |use| (@uses << use) unless (@assigns.include?(use) or @uses.include?(use)) } #puts "IN ADD #{name}#{uses}" diff --git a/lib/vm/function.rb b/lib/vm/function.rb index a328debf..cfa375ea 100644 --- a/lib/vm/function.rb +++ b/lib/vm/function.rb @@ -140,7 +140,7 @@ module Vm def add_code(kode) raise "alarm #{kode}" if kode.is_a? Word raise "alarm #{kode.class} #{kode}" unless kode.is_a? Code - @insert_at.do_add kode + @insert_at.add_code kode self end diff --git a/lib/vm/values/reference.rb b/lib/vm/values/reference.rb index a2c86772..35069e31 100644 --- a/lib/vm/values/reference.rb +++ b/lib/vm/values/reference.rb @@ -1,9 +1,11 @@ module Vm class Reference < Word # needs to be here as Word's constructor is private (to make it abstract) - def initialize reg - super + def initialize reg , clazz = nil + super(reg) + @clazz = clazz end + attr_accessor :clazz end end