2015-10-07 14:22:47 +02:00
|
|
|
module Phisol
|
2015-09-27 10:28:06 +02:00
|
|
|
Compiler.class_eval do
|
|
|
|
|
|
|
|
def on_field_access expression
|
2015-09-27 11:59:50 +02:00
|
|
|
#puts expression.inspect
|
2015-09-27 10:28:06 +02:00
|
|
|
receiver_ast , field_ast = *expression
|
|
|
|
receiver = receiver_ast.first_from(:name)
|
|
|
|
field_name = field_ast.first_from(:name)
|
|
|
|
|
|
|
|
case receiver
|
|
|
|
when :self
|
2015-10-05 23:27:13 +02:00
|
|
|
index = @clazz.object_layout.variable_index(field_name)
|
|
|
|
raise "field access, but no such field:#{field_name} for class #{@clazz.name}" unless index
|
2015-09-27 11:59:50 +02:00
|
|
|
value = Virtual::Return.new(:int)
|
2015-10-07 09:04:00 +02:00
|
|
|
@method.source.add_code Virtual::Set.new( Virtual::SelfsSlot.new(index, :int ) , value )
|
2015-09-27 10:28:06 +02:00
|
|
|
when :message
|
|
|
|
#message Slot
|
|
|
|
raise "message not yet"
|
|
|
|
else
|
|
|
|
#arg / frame Slot
|
|
|
|
raise "frame not implemented"
|
|
|
|
end
|
|
|
|
|
2015-09-27 11:59:50 +02:00
|
|
|
value
|
2015-09-27 10:28:06 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|