introduces compile time type (ct_type)

to determine whether we can call directly
This commit is contained in:
Torsten Ruger
2017-04-19 20:59:13 +03:00
parent d2fba19b95
commit 3e282c083d
8 changed files with 130 additions and 12 deletions

View File

@ -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

View File

@ -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