add label generation to builder
This commit is contained in:
parent
6958fc31ab
commit
695ae5ad99
@ -20,12 +20,15 @@ module Risc
|
||||
return @names[name] if @names.has_key?(name)
|
||||
if name == :message
|
||||
reg = Risc.message_reg
|
||||
reg.builder = self
|
||||
elsif name.to_s.index("label")
|
||||
reg = Risc.label( name.to_s , "#{name}_#{object_id}")
|
||||
else
|
||||
type = Risc.resolve_type(name , @compiler) #checking
|
||||
reg = @compiler.use_reg( type.object_class.name )
|
||||
reg.builder = self
|
||||
end
|
||||
@names[name] = reg
|
||||
reg.builder = self
|
||||
reg
|
||||
end
|
||||
|
||||
|
@ -58,10 +58,6 @@ module Risc
|
||||
compiler = compiler_for(:Word, :resolve_method , {:value => :Type} )
|
||||
source = "resolve_method "
|
||||
|
||||
while_start = Risc.label( source , source + "while_start_#{object_id}")
|
||||
exit_label = Risc.label( source , source + "exit_label_#{object_id}")
|
||||
false_label = Risc.label( source , source + "fal_label_#{object_id}")
|
||||
|
||||
compiler.build do
|
||||
word << message[ :receiver ]
|
||||
|
||||
@ -69,7 +65,7 @@ module Risc
|
||||
type << type[2]
|
||||
type << type[:type]
|
||||
typed_method << type[:methods]
|
||||
add while_start
|
||||
add while_start_label
|
||||
space << Parfait.object_space
|
||||
space << space[:nil_object]
|
||||
|
||||
@ -87,7 +83,7 @@ module Risc
|
||||
|
||||
add false_label
|
||||
typed_method << typed_method[:next_method]
|
||||
add Risc::Branch.new(source + "back to while", while_start)
|
||||
add Risc::Branch.new(source + "back to while", while_start_label)
|
||||
|
||||
add exit_label
|
||||
end
|
||||
|
@ -64,5 +64,15 @@ module Risc
|
||||
assert_equal RegToSlot , built.class
|
||||
assert_equal :r0 , built.array.symbol
|
||||
end
|
||||
def test_label
|
||||
label = @builder.exit_label
|
||||
assert_equal Label , label.class
|
||||
assert label.name.index("exit")
|
||||
end
|
||||
def test_two_label
|
||||
label1 = @builder.exit_label
|
||||
label2 = @builder.exit_label
|
||||
assert_equal label1 , label2
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user