rename blocks do_add to be the same as sunctions add_code to blur the difference
This commit is contained in:
parent
43a2649635
commit
17904d8e02
@ -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
|
||||
|
@ -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
|
||||
|
@ -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}"
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user