introduces compile time type (ct_type)
to determine whether we can call directly
This commit is contained in:
@ -4,18 +4,33 @@ module Vool
|
||||
def initialize(value)
|
||||
@value = value
|
||||
end
|
||||
def ct_type
|
||||
Parfait.object_space.get_class_by_name(:Integer).instance_type
|
||||
end
|
||||
end
|
||||
class FloatStatement < Statement
|
||||
attr_reader :value
|
||||
def initialize(value)
|
||||
@value = value
|
||||
end
|
||||
def ct_type
|
||||
true
|
||||
end
|
||||
end
|
||||
class TrueStatement < Statement
|
||||
def ct_type
|
||||
Parfait.object_space.get_class_by_name(:True).instance_type
|
||||
end
|
||||
end
|
||||
class FalseStatement < Statement
|
||||
def ct_type
|
||||
Parfait.object_space.get_class_by_name(:False).instance_type
|
||||
end
|
||||
end
|
||||
class NilStatement < Statement
|
||||
def ct_type
|
||||
Parfait.object_space.get_class_by_name(:Nil).instance_type
|
||||
end
|
||||
end
|
||||
class SelfStatement < Statement
|
||||
end
|
||||
@ -26,7 +41,13 @@ module Vool
|
||||
def initialize(value)
|
||||
@value = value
|
||||
end
|
||||
def ct_type
|
||||
Parfait.object_space.get_class_by_name(:Word).instance_type
|
||||
end
|
||||
end
|
||||
class SymbolStatement < StringStatement
|
||||
def ct_type
|
||||
Parfait.object_space.get_class_by_name(:Word).instance_type
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -41,24 +41,21 @@ module Vool
|
||||
pops = [Mom::SlotConstant.new([:message , :next_message , :receiver] , @receiver) ]
|
||||
@arguments.each_with_index do |arg , index|
|
||||
arg_target = [:message , :next_message , :arguments]
|
||||
pops << Mom::SlotConstant.new( arg_target << index , arg)
|
||||
pops << Mom::SlotConstant.new( arg_target + [index] , arg)
|
||||
end
|
||||
pops
|
||||
end
|
||||
|
||||
def call_instruction
|
||||
if(receiver_type)
|
||||
if(@receiver.ct_type)
|
||||
simple_call
|
||||
else
|
||||
cached_call
|
||||
end
|
||||
end
|
||||
|
||||
def receiver_type
|
||||
Parfait.object_space.get_class_by_name(:Integer).instance_type
|
||||
end
|
||||
def simple_call
|
||||
type = receiver_type
|
||||
type = @receiver.ct_type
|
||||
method = type.get_method(@name)
|
||||
[Mom::SimpleCall.new( method) ]
|
||||
end
|
||||
|
Reference in New Issue
Block a user