remove unknown type
This commit is contained in:
@ -34,17 +34,18 @@ module Virtual
|
||||
# second, it creates MethodSource and attaches it to the method
|
||||
#
|
||||
# compile code then works with the method, but adds code tot the info
|
||||
def self.create_method( class_name , method_name , args)
|
||||
def self.create_method( class_name , return_type , method_name , args)
|
||||
raise "create_method #{class_name}.#{class_name.class}" unless class_name.is_a? Symbol
|
||||
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
|
||||
method = clazz.create_instance_method( method_name , Virtual.new_list(args))
|
||||
method.source = MethodSource.new(method)
|
||||
method.source = MethodSource.new(method , return_type)
|
||||
method
|
||||
end
|
||||
# just passing the method object in for Instructions to make decisions (later)
|
||||
def initialize method , return_type = Virtual::Unknown
|
||||
def initialize method , return_type
|
||||
# first block we have to create with .new , as new_block assumes a current
|
||||
enter = Block.new( "enter" , method ).add_code(MethodEnter.new( method ))
|
||||
@return_type = return_type
|
||||
|
@ -4,7 +4,7 @@ module Virtual
|
||||
|
||||
# Slots in the Frame are local or temporary variables in a message
|
||||
class FrameSlot < Slot
|
||||
def initialize index , type = Unknown, value = nil
|
||||
def initialize index , type , value = nil
|
||||
super(type, value)
|
||||
@index = index
|
||||
end
|
||||
|
@ -7,7 +7,7 @@ module Virtual
|
||||
# The Message has a layout as per the constant above
|
||||
|
||||
class MessageSlot < Slot
|
||||
def initialize type = Unknown , value = nil
|
||||
def initialize type , value = nil
|
||||
super(type , value )
|
||||
end
|
||||
def object_name
|
||||
@ -19,28 +19,28 @@ module Virtual
|
||||
|
||||
# Return is the return of MessageSlot
|
||||
class Return < MessageSlot
|
||||
def initialize type = Unknown, value = nil
|
||||
def initialize type , value = nil
|
||||
super( type , value )
|
||||
end
|
||||
end
|
||||
|
||||
# Self is the self in MessageSlot
|
||||
class Self < MessageSlot
|
||||
def initialize type = Unknown, value = nil
|
||||
def initialize type , value = nil
|
||||
super( type , value )
|
||||
end
|
||||
end
|
||||
|
||||
# MessageName of the current message
|
||||
class MessageName < MessageSlot
|
||||
def initialize type = Unknown, value = nil
|
||||
def initialize type , value = nil
|
||||
super( type , value )
|
||||
end
|
||||
end
|
||||
|
||||
# NewMessageName of the next message
|
||||
class ArgSlot < MessageSlot
|
||||
def initialize index , type = Unknown, value = nil
|
||||
def initialize index , type , value = nil
|
||||
@index = index
|
||||
super( type , value )
|
||||
end
|
||||
|
@ -7,7 +7,7 @@ module Virtual
|
||||
# The Message has a layout as per the constant above
|
||||
|
||||
class NewMessageSlot < Slot
|
||||
def initialize type = Unknown, value = nil
|
||||
def initialize type , value = nil
|
||||
super( type , value )
|
||||
end
|
||||
def object_name
|
||||
@ -19,28 +19,28 @@ module Virtual
|
||||
|
||||
# NewReturn is the return of NewMessageSlot
|
||||
class NewReturn < NewMessageSlot
|
||||
def initialize type = Unknown, value = nil
|
||||
def initialize type , value = nil
|
||||
super( type , value )
|
||||
end
|
||||
end
|
||||
|
||||
# NewSelf is the self of NewMessageSlot
|
||||
class NewSelf < NewMessageSlot
|
||||
def initialize type = Unknown, value = nil
|
||||
def initialize type , value = nil
|
||||
super( type , value )
|
||||
end
|
||||
end
|
||||
|
||||
# NewMessageName of the next message
|
||||
class NewMessageName < NewMessageSlot
|
||||
def initialize type = Unknown, value = nil
|
||||
def initialize type , value = nil
|
||||
super( type , value )
|
||||
end
|
||||
end
|
||||
|
||||
# NewMessageName of the next message
|
||||
class NewArgSlot < NewMessageSlot
|
||||
def initialize index , type = Unknown, value = nil
|
||||
def initialize index , type , value = nil
|
||||
@index = index
|
||||
super( type , value )
|
||||
end
|
||||
|
@ -14,7 +14,7 @@ module Virtual
|
||||
# that object
|
||||
#
|
||||
class SelfSlot < Slot
|
||||
def initialize type = Unknown, value = nil
|
||||
def initialize type , value = nil
|
||||
super
|
||||
end
|
||||
def object_name
|
||||
|
@ -7,6 +7,19 @@ module Virtual
|
||||
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
|
||||
@ -20,7 +33,4 @@ module Virtual
|
||||
attr_reader :of_class
|
||||
end
|
||||
|
||||
class Unknown < Type
|
||||
end
|
||||
|
||||
end
|
||||
|
Reference in New Issue
Block a user