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
|
def main_start context
|
||||||
entry = Vm::Block.new("main_entry",nil,nil)
|
entry = Vm::Block.new("main_entry",nil,nil)
|
||||||
entry.do_add mov( :fp , 0 )
|
entry.add_code mov( :fp , 0 )
|
||||||
entry.do_add call( context.function )
|
entry.add_code call( context.function )
|
||||||
entry
|
entry
|
||||||
end
|
end
|
||||||
def main_exit context
|
def main_exit context
|
||||||
@ -44,11 +44,11 @@ module Arm
|
|||||||
exit
|
exit
|
||||||
end
|
end
|
||||||
def function_entry block, f_name
|
def function_entry block, f_name
|
||||||
block.do_add push( [:lr] )
|
block.add_code push( [:lr] )
|
||||||
block
|
block
|
||||||
end
|
end
|
||||||
def function_exit entry , f_name
|
def function_exit entry , f_name
|
||||||
entry.do_add pop( [:pc] )
|
entry.add_code pop( [:pc] )
|
||||||
entry
|
entry
|
||||||
end
|
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
|
# 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) )
|
sys = Vm::Integer.new( Vm::RegisterReference.new(:r7) )
|
||||||
ret = Vm::Integer.new( Vm::RegisterReference.new(RETURN_REG) )
|
ret = Vm::Integer.new( Vm::RegisterReference.new(RETURN_REG) )
|
||||||
block.do_add mov( sys , num )
|
block.add_code mov( sys , num )
|
||||||
block.do_add swi( 0 )
|
block.add_code swi( 0 )
|
||||||
#todo should write type into r1 according to syscall
|
#todo should write type into r1 according to syscall
|
||||||
ret
|
ret
|
||||||
end
|
end
|
||||||
|
@ -39,7 +39,7 @@ module Boot
|
|||||||
return get_function
|
return get_function
|
||||||
end
|
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 )
|
set_function = Vm::Function.new(:_set_instance_variable , Vm::Integer , [ Vm::Integer , Vm::Integer] , Vm::Integer )
|
||||||
me = set_function.receiver
|
me = set_function.receiver
|
||||||
var_name = set_function.args.first
|
var_name = set_function.args.first
|
||||||
|
@ -41,7 +41,7 @@ module Vm
|
|||||||
ret
|
ret
|
||||||
end
|
end
|
||||||
|
|
||||||
def do_add kode
|
def add_code kode
|
||||||
kode.assigns.each { |a| (@assigns << a) unless @assigns.include?(a) }
|
kode.assigns.each { |a| (@assigns << a) unless @assigns.include?(a) }
|
||||||
kode.uses.each { |use| (@uses << use) unless (@assigns.include?(use) or @uses.include?(use)) }
|
kode.uses.each { |use| (@uses << use) unless (@assigns.include?(use) or @uses.include?(use)) }
|
||||||
#puts "IN ADD #{name}#{uses}"
|
#puts "IN ADD #{name}#{uses}"
|
||||||
|
@ -140,7 +140,7 @@ module Vm
|
|||||||
def add_code(kode)
|
def add_code(kode)
|
||||||
raise "alarm #{kode}" if kode.is_a? Word
|
raise "alarm #{kode}" if kode.is_a? Word
|
||||||
raise "alarm #{kode.class} #{kode}" unless kode.is_a? Code
|
raise "alarm #{kode.class} #{kode}" unless kode.is_a? Code
|
||||||
@insert_at.do_add kode
|
@insert_at.add_code kode
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
module Vm
|
module Vm
|
||||||
class Reference < Word
|
class Reference < Word
|
||||||
# needs to be here as Word's constructor is private (to make it abstract)
|
# needs to be here as Word's constructor is private (to make it abstract)
|
||||||
def initialize reg
|
def initialize reg , clazz = nil
|
||||||
super
|
super(reg)
|
||||||
|
@clazz = clazz
|
||||||
end
|
end
|
||||||
|
attr_accessor :clazz
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user