mostly finish index resolve in slot_definition
alas, it reveals error, types may not be set correctly
This commit is contained in:
parent
be79388cc5
commit
e7b878a353
@ -8,7 +8,7 @@ module Mom
|
||||
#
|
||||
# The Slot on the left hand side is always a SlotDefinition.
|
||||
# The only known object (*) for the left side is the current message, which is a bit like
|
||||
# the oo version of a PC (program Counter)
|
||||
# the oo version of a Stack (Stack Register, Frame Pointer, ..)
|
||||
# (* off course all class objects are global, and so they are allowed too)
|
||||
#
|
||||
# A maybe not immediately obvious corrolar of this design is the total absence of
|
||||
@ -39,9 +39,14 @@ module Mom
|
||||
when Constant
|
||||
const = Risc.load_constant(self, @right , right)
|
||||
when Symbol
|
||||
const = Risc::SlotToReg.new( self , Risc.message_reg ,
|
||||
const = Risc::SlotToReg.new( self , Risc.resolve_to_register(@right.known_object) ,
|
||||
Risc.resolve_to_index(:message , @right.slots[0]), right)
|
||||
puts "more slots #{@right.slots}" if @right.slots.length > 1
|
||||
if @right.slots.length > 1
|
||||
# desctructively replace the existing value to be loaded if more slots
|
||||
index = resolve_to_index(@right.slots[0] , @right.slots[1] ,compiler)
|
||||
const << Risc::SlotToReg.new( self , right ,index, right)
|
||||
raise "more slots not implemented #{@right.slots}" if @right.slots.length > 2
|
||||
end
|
||||
else
|
||||
raise "We have a #{@right} #{@right.known_object}"
|
||||
end
|
||||
@ -61,6 +66,21 @@ module Mom
|
||||
return const
|
||||
end
|
||||
|
||||
def resolve_to_index(object , variable_name ,compiler)
|
||||
case object
|
||||
when :frame
|
||||
type = compiler.method.frame
|
||||
when :arguments
|
||||
type = compiler.method.arguments
|
||||
when :receiver
|
||||
type = compiler.method.for_type
|
||||
else
|
||||
raise "Not implemented/found object #{object}"
|
||||
end
|
||||
index = type.variable_index(variable_name)
|
||||
raise "Index not found for #{variable_name} in #{object} of type #{type}" unless index
|
||||
return index
|
||||
end
|
||||
end
|
||||
|
||||
class SlotDefinition
|
||||
|
@ -13,7 +13,7 @@
|
||||
# Instructions derive from class Instruction and form a linked list
|
||||
# - binary: The binary (jumpable) code that the instructions get assembled into
|
||||
# - arguments: A type object describing the arguments (name+types) to be passed
|
||||
# - locals: A type object describing the local variables that the method has
|
||||
# - frame: A type object describing the local variables that the method has
|
||||
# - for_type: The Type the Method is for
|
||||
|
||||
|
||||
|
@ -107,7 +107,7 @@ module Vool
|
||||
def build_method_cache_update(in_method)
|
||||
receiver = StringConstant.new(@name)
|
||||
resolve = SendStatement.new(:resolve_method , receiver , [SelfExpression.new])
|
||||
move_method = Mom::SlotLoad.new([@dynamic.cache_entry, :cached_method] , [:message ,:receiver , :return])
|
||||
move_method = Mom::SlotLoad.new([@dynamic.cache_entry, :cached_method] , [:message , :return_value])
|
||||
resolve.to_mom(in_method) << move_method
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user