fix putstring file descriptor

This commit is contained in:
Torsten Ruger 2015-07-02 09:49:52 +03:00
parent 11997ef354
commit 3195d800e9
4 changed files with 16 additions and 13 deletions

View File

@ -14,8 +14,9 @@ module Arm
end end
def putstring int_code , codes def putstring int_code , codes
codes << ArmMachine.mov( :r0 , 1 ) # stdout == 1
codes << ArmMachine.ldr( :r1 , Register.message_reg, 4 * Register.resolve_index(:message , :receiver)) codes << ArmMachine.ldr( :r1 , Register.message_reg, 4 * Register.resolve_index(:message , :receiver))
codes << ArmMachine.add( :r1 , :r1 , 8 )
codes << ArmMachine.mov( :r0 , 1 ) # stdout == 1
codes << ArmMachine.mov( :r2 , 20 ) # String length, obvious TODO codes << ArmMachine.mov( :r2 , 20 ) # String length, obvious TODO
syscall(int_code , codes ) syscall(int_code , codes )
end end

View File

@ -12,9 +12,9 @@ module Virtual
# another abstract "marker" class (so we can check for it) # another abstract "marker" class (so we can check for it)
# derived classes are Boot/Meta Class and StringConstant # derived classes are Boot/Meta Class and StringConstant
class ObjectConstant < Constant class ObjectConstant < Constant
def type # def type
Virtual::Reference # Virtual::Reference
end # end
def clazz def clazz
raise "abstract #{self}" raise "abstract #{self}"
end end
@ -32,5 +32,5 @@ module Virtual
integer >= 0 and integer <= 255 integer >= 0 and integer <= 255
end end
end end
end end

View File

@ -15,7 +15,6 @@ module Virtual
next unless code.is_a? MessageSend next unless code.is_a? MessageSend
new_codes = [ ] new_codes = [ ]
ref = code.me ref = code.me
raise "only refs implemented #{ref.type}" unless ( ref.type.is_a? Reference)
# value known at compile time, got do something with it # value known at compile time, got do something with it
if(ref.value) if(ref.value)
me = ref.value me = ref.value
@ -27,13 +26,18 @@ module Virtual
method = me.get_class.get_instance_method(code.name) method = me.get_class.get_instance_method(code.name)
raise "Method not implemented #{me.class}.#{code.name}" unless method raise "Method not implemented #{me.class}.#{code.name}" unless method
new_codes << MethodCall.new( method ) new_codes << MethodCall.new( method )
elsif( me.is_a? Symbol )
# get the function from my class. easy peasy
method = Virtual.machine.space.get_class_by_name(:Word).get_instance_method(code.name)
raise "Method not implemented #{me.class}.#{code.name}" unless method
new_codes << MethodCall.new( method )
else else
# note: this is the current view: call internal send, even the method name says else # note: this is the current view: call internal send, even the method name says else
# but send is "special" and accesses the internal method name and resolves. # but send is "special" and accesses the internal method name and resolves.
kernel = Virtual.machine.space.get_class_by_name("Kernel") kernel = Virtual.machine.space.get_class_by_name(:Kernel)
method = kernel.get_instance_method(:__send) method = kernel.get_instance_method(:__send)
new_codes << MethodCall.new( method ) new_codes << MethodCall.new( method )
raise "unimplemented: \n#{code}" raise "unimplemented: \n#{code} \nfor #{ref.inspect}"
end end
else else
if ref.type.is_a?(Reference) and ref.type.of_class if ref.type.is_a?(Reference) and ref.type.of_class

View File

@ -24,18 +24,16 @@ HERE
check check
end end
def test_puts_string def ttest_puts_string
@string_input = <<HERE @string_input = <<HERE
putstring("Hello") putstring("Hello")
HERE HERE
check check
end end
def ttest_string_put def test_string_put
@string_input = <<HERE @string_input = <<HERE
def foo() "Hello".putstring()
"Hello".puts()
end
HERE HERE
check check
end end