putstring unfolds length
which means sys call doesn’t need to and also interpreter sometimes gets a symbol length
This commit is contained in:
parent
f92ea36fe5
commit
303b7eb1f8
@ -128,14 +128,13 @@ module Arm
|
||||
end
|
||||
|
||||
def putstring int_code
|
||||
codes = ArmMachine.ldr( :r2 , :r1 , 8 ) # String length
|
||||
codes.append ArmMachine.add( :r1 , :r1 , 12 ) # adjust for object header
|
||||
codes = ArmMachine.add( :r1 , :r1 , 12 ) # adjust for object header
|
||||
codes.append ArmMachine.mov( :r0 , 1 ) # write to stdout == 1
|
||||
syscall(int_code , codes )
|
||||
end
|
||||
|
||||
def exit int_code
|
||||
codes = Register::Label.new(nil , "exit")
|
||||
codes = ArmMachine.ldr( :r0 , :r0 , arm_index(Register.resolve_index(:Message , :return_value)) )
|
||||
syscall int_code , codes
|
||||
end
|
||||
|
||||
|
@ -121,7 +121,15 @@ module Interpreter
|
||||
else
|
||||
index = get_register(@instruction.index)
|
||||
end
|
||||
value = object.get_internal( index )
|
||||
if object.is_a?(Symbol)
|
||||
if( index == 2 )
|
||||
value = object.to_s.length
|
||||
else
|
||||
raise "Unsupported action, must convert symbol to word:#{object}"
|
||||
end
|
||||
else
|
||||
value = object.get_internal( index )
|
||||
end
|
||||
#value = value.object_id unless value.is_a? Fixnum
|
||||
set_register( @instruction.register , value )
|
||||
true
|
||||
|
@ -5,6 +5,9 @@ module Register
|
||||
def putstring context
|
||||
compiler = Soml::Compiler.new.create_method(:Word , :putstring ).init_method
|
||||
compiler.add_code Register.get_slot( "putstring" , :message , :receiver , :new_message )
|
||||
index = Parfait::Word.get_length_index
|
||||
reg = RegisterValue.new(:r2 , :Integer)
|
||||
compiler.add_code Register.get_slot( "putstring" , :new_message , index , reg )
|
||||
Kernel.emit_syscall( compiler , :putstring )
|
||||
compiler.method
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user