type now means class name

update reader (with new type definition)
remove type class (now symbol)
update all types to class name symbols
This commit is contained in:
Torsten Ruger
2015-10-14 16:16:03 +03:00
parent d8a5dc147b
commit 1141ed9c99
16 changed files with 72 additions and 121 deletions

View File

@ -19,26 +19,26 @@ module Phisol
end
def on_true statement
reg = use_reg :ref
reg = use_reg :Boolean
@method.source.add_code Register::LoadConstant.new( statement, true , reg )
return reg
end
def on_false statement
reg = use_reg :ref
reg = use_reg :Boolean
@method.source.add_code Register::LoadConstant.new( statement, false , reg )
return reg
end
def on_nil statement
reg = use_reg :ref
reg = use_reg :NilClass
@method.source.add_code Register::LoadConstant.new( statement, nil , reg )
return reg
end
def on_string statement
value = statement.first.to_sym
reg = use_reg :ref
reg = use_reg :Word
@method.source.constants << value
@method.source.add_code Register::LoadConstant.new( statement, value , reg )
return reg

View File

@ -9,12 +9,7 @@ module Phisol
if receiver
me = process( receiver.to_a.first )
else
if @method.for_class.name == :Integer
type = :int
else
type = :ref
end
me = Register.self_reg type
me = Register.self_reg @method.for_class.name
end
#move the new message (that we need to populate to make a call) to std register
new_message = Register.resolve_to_register(:new_message)
@ -22,7 +17,7 @@ module Phisol
# move our receiver there
@method.source.add_code Register.set_slot( statement , me , :new_message , :receiver)
# load method name and set to new message (for exceptions/debug)
name_tmp = use_reg(:ref)
name_tmp = use_reg(:Word)
@method.source.add_code Register::LoadConstant.new(statement, name , name_tmp)
@method.source.add_code Register.set_slot( statement , name_tmp , :new_message , :name)
# next arguments. reset tmp regs for each and load result into new_message
@ -56,17 +51,12 @@ module Phisol
raise "unimplemented: \n#{code} \nfor #{ref.inspect}"
end
else
if( me.type.is_a? Phisol::Integer)
name = :plus if name == :+
method = Virtual.machine.space.get_class_by_name(:Integer).get_instance_method(name)
puts Virtual.machine.space.get_class_by_name(:Integer).method_names.to_a
raise "Method not implemented Integer.#{name}" unless method
@method.source.add_code Virtual::MethodCall.new( method )
else
method = @clazz.get_instance_method(name)
raise "Method not implemented #{@clazz.name}.#{name}" unless method
@method.source.add_code Virtual::MethodCall.new( method )
end
clazz = Virtual.machine.space.get_class_by_name(me.type)
raise "No such class #{me.type}" unless clazz
method = clazz.get_instance_method(name)
puts Virtual.machine.space.get_class_by_name(:Integer).method_names.to_a
raise "Method not implemented Integer.#{name}" unless method
@method.source.add_code Virtual::MethodCall.new( method )
end
raise "Method not implemented #{me.value}.#{name}" unless method
ret = use_reg( method.source.return_type )

View File

@ -7,7 +7,7 @@ module Phisol
# whichever way this goes the result is stored in the return slot (as all compiles)
def on_name statement
name = statement.to_a.first
return Virtual::Self.new( Phisol::Reference.new(@clazz)) if name == :self
return Virtual::Self.new( @clazz) if name == :self
# either an argument, so it's stored in message
if( index = @method.has_arg(name))
type = @method.arguments[index].type