2015-10-07 14:22:47 +02:00
|
|
|
module Phisol
|
2015-09-27 10:28:06 +02:00
|
|
|
Compiler.class_eval do
|
|
|
|
|
2015-10-09 16:51:14 +02:00
|
|
|
def on_field_access statement
|
|
|
|
#puts statement.inspect
|
|
|
|
receiver_ast , field_ast = *statement
|
2015-09-27 10:28:06 +02:00
|
|
|
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-10-13 15:42:53 +02:00
|
|
|
value = use_reg(:int) #TODO, need types in layout
|
|
|
|
move = Register.get_slot(statement, :self , index , value )
|
|
|
|
@method.source.add_code move
|
|
|
|
return 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
|