2015-10-23 13:22:55 +02:00
|
|
|
module Soml
|
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-18 16:20:19 +02:00
|
|
|
value = use_reg(@clazz.name) #TODO incorrect, this is the self, but should be the type of variable at index
|
2015-10-23 13:08:12 +02:00
|
|
|
add_code Register.get_slot(statement , :message , :receiver , value )
|
2015-10-18 16:20:19 +02:00
|
|
|
# reuse the register for next move
|
|
|
|
move = Register.get_slot(statement, value , index , value )
|
2015-10-23 13:08:12 +02:00
|
|
|
add_code move
|
2015-10-13 15:42:53 +02:00
|
|
|
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
|