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
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.add( :r1 , :r1 , 8 )
codes << ArmMachine.mov( :r0 , 1 ) # stdout == 1
codes << ArmMachine.mov( :r2 , 20 ) # String length, obvious TODO
syscall(int_code , codes )
end

View File

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

View File

@ -15,7 +15,6 @@ module Virtual
next unless code.is_a? MessageSend
new_codes = [ ]
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
if(ref.value)
me = ref.value
@ -27,13 +26,18 @@ module Virtual
method = me.get_class.get_instance_method(code.name)
raise "Method not implemented #{me.class}.#{code.name}" unless 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
# 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.
kernel = Virtual.machine.space.get_class_by_name("Kernel")
kernel = Virtual.machine.space.get_class_by_name(:Kernel)
method = kernel.get_instance_method(:__send)
new_codes << MethodCall.new( method )
raise "unimplemented: \n#{code}"
raise "unimplemented: \n#{code} \nfor #{ref.inspect}"
end
else
if ref.type.is_a?(Reference) and ref.type.of_class

View File

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