use factory functions consistently to create instructions
This commit is contained in:
@ -133,11 +133,11 @@ module Typed
|
||||
def init_method
|
||||
source = "_init_method"
|
||||
name = "#{method.for_type.name}.#{method.name}"
|
||||
@method.instructions = Register::Label.new(source, name)
|
||||
@method.instructions = Register.label(source, name)
|
||||
@current = enter = method.instructions
|
||||
add_code Register::Label.new( source, "return #{name}")
|
||||
add_code Register.label( source, "return #{name}")
|
||||
#load the return address into pc, affecting return. (other cpus have commands for this, but not arm)
|
||||
add_code Register::FunctionReturn.new( source , Register.message_reg , Register.resolve_to_index(:message , :return_address) )
|
||||
add_code Register.function_return( source , Register.message_reg , Register.resolve_to_index(:message , :return_address) )
|
||||
@current = enter
|
||||
self
|
||||
end
|
||||
|
@ -21,7 +21,7 @@ module Typed
|
||||
reset_regs
|
||||
process(statement.condition)
|
||||
branch_class = Object.const_get "Register::Is#{statement.branch_type.capitalize}"
|
||||
true_block = Register::Label.new(statement, "if_true")
|
||||
true_block = Register.label(statement, "if_true")
|
||||
add_code branch_class.new( statement.condition , true_block )
|
||||
return true_block
|
||||
end
|
||||
@ -33,7 +33,7 @@ module Typed
|
||||
def compile_if_false( statement )
|
||||
reset_regs
|
||||
process(statement.if_false) if statement.if_false.statements
|
||||
merge = Register::Label.new(statement , "if_merge")
|
||||
merge = Register.label(statement , "if_merge")
|
||||
add_code Register::Branch.new(statement.if_false, merge )
|
||||
merge
|
||||
end
|
||||
|
@ -22,13 +22,13 @@ module Typed
|
||||
private
|
||||
|
||||
def compile_while_preamble( statement )
|
||||
condition_label = Register::Label.new(statement.condition , "condition_label")
|
||||
condition_label = Register.label(statement.condition , "condition_label")
|
||||
# unconditionally branch to the condition upon entering the loop
|
||||
add_code Register::Branch.new(statement.condition , condition_label)
|
||||
condition_label
|
||||
end
|
||||
def compile_while_body( statement )
|
||||
start = Register::Label.new(statement , "while_start" )
|
||||
start = Register.label(statement , "while_start" )
|
||||
add_code start
|
||||
reset_regs
|
||||
process(statement.statements)
|
||||
|
Reference in New Issue
Block a user