rename for_type to self_type
and split a base class off TypedMethod
This commit is contained in:
@ -70,7 +70,7 @@ module Vool
|
||||
@my_type = type
|
||||
end
|
||||
def slot_definition(compiler)
|
||||
@my_type = compiler.method.for_type
|
||||
@my_type = compiler.method.self_type
|
||||
Mom::SlotDefinition.new(:message , [:receiver])
|
||||
end
|
||||
def ct_type
|
||||
|
@ -8,13 +8,21 @@ module Vool
|
||||
@clazz = clazz
|
||||
end
|
||||
|
||||
def to_mom( compiler )
|
||||
# raise "should not be called (call create_objects)"
|
||||
end
|
||||
# because of normalization (of send), slot_definition is called first,
|
||||
# to assign the block to a variable.
|
||||
#
|
||||
# This means we do the compiler here (rather than to_mom, which is in
|
||||
# fact never called)
|
||||
def slot_definition(compiler)
|
||||
@parfait_block = to_parfait(compiler)
|
||||
compiler.add_constant(@parfait_block)
|
||||
return Mom::SlotDefinition.new(Mom::IntegerConstant.new(1) , [])
|
||||
end
|
||||
|
||||
def to_mom( compiler )
|
||||
# raise "should not be called "
|
||||
end
|
||||
|
||||
def each(&block)
|
||||
block.call(self)
|
||||
@body.each(&block)
|
||||
@ -24,9 +32,10 @@ module Vool
|
||||
BlockStatement.new( @args , @body.normalize)
|
||||
end
|
||||
|
||||
def create_objects(clazz)
|
||||
end
|
||||
private
|
||||
def to_parfait(compiler)
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
@ -24,10 +24,9 @@ module Vool
|
||||
|
||||
def to_mom( _ )
|
||||
create_class_object
|
||||
method_compilers = []
|
||||
body.statements.each do |node|
|
||||
method_compilers = body.statements.collect do |node|
|
||||
raise "Only methods for now #{node}" unless node.is_a?(MethodStatement)
|
||||
method_compilers << node.to_mom(@clazz)
|
||||
node.to_mom(@clazz)
|
||||
end
|
||||
Mom::MomCompiler.new(method_compilers)
|
||||
end
|
||||
|
@ -72,8 +72,7 @@ module Vool
|
||||
# - Setting up the next message, with receiver, arguments, and (importantly) return address
|
||||
# - a CachedCall , or a SimpleCall, depending on wether the receiver type can be determined
|
||||
def to_mom( compiler )
|
||||
@parfait_block = self.block.to_mom(compiler) if self.block
|
||||
@receiver = SelfExpression.new(compiler.method.for_type) if @receiver.is_a?(SelfExpression)
|
||||
@receiver = SelfExpression.new(compiler.method.self_type) if @receiver.is_a?(SelfExpression)
|
||||
if(@receiver.ct_type)
|
||||
simple_call(compiler)
|
||||
else
|
||||
|
@ -39,10 +39,6 @@ module Vool
|
||||
flat
|
||||
end
|
||||
|
||||
def create_objects
|
||||
@statements.each{ |s| s.create_objects }
|
||||
end
|
||||
|
||||
def each(&block)
|
||||
block.call(self)
|
||||
@statements.each{|a| a.each(&block)}
|
||||
|
@ -48,7 +48,7 @@ module Vool
|
||||
# - a SimpleCall,
|
||||
def to_mom( compiler )
|
||||
@parfait_block = @block.to_mom(compiler) if @block
|
||||
@receiver = SelfExpression.new(compiler.for_type) if @receiver.is_a?(SelfExpression)
|
||||
@receiver = SelfExpression.new(compiler.self_type) if @receiver.is_a?(SelfExpression)
|
||||
if(@receiver.ct_type)
|
||||
simple_call(compiler)
|
||||
else
|
||||
|
Reference in New Issue
Block a user