move type to phial and add type to reg_ref

This commit is contained in:
Torsten Ruger
2015-10-10 19:14:27 +03:00
parent cb306c09f0
commit dd3381e38b
15 changed files with 65 additions and 54 deletions

View File

@ -37,7 +37,7 @@ module Virtual
raise "create_method #{method_name}.#{method_name.class}" unless method_name.is_a? Symbol
clazz = Virtual.machine.space.get_class_by_name class_name
raise "No such class #{class_name}" unless clazz
return_type = Virtual::Type.from_sym return_type
return_type = Phisol::Type.from_sym return_type
arguments = []
args.each_with_index do | arg , index |
unless arg.is_a? Parfait::Variable

View File

@ -1,36 +0,0 @@
module Virtual
# Integer and (Object) References are the main derived classes, but float will come.
class Type
def == other
return false unless other.class == self.class
return true
end
# map from a type sym (currently :int/:ref) to a class of subtype of Type
# TODO needs to be made extensible in a defined way.
def self.from_sym type
case type
when :int
Virtual::Integer
when :ref
Virtual::Reference
else
raise "No type maps to:#{type}"
end
end
end
class Integer < Type
end
class Reference < Type
# possibly unknown value, but known class (as in methods)
def initialize clazz = nil
@of_class = clazz
end
attr_reader :of_class
end
end