2015-10-23 13:22:55 +02:00
|
|
|
module Soml
|
2015-09-27 10:28:06 +02:00
|
|
|
Compiler.class_eval do
|
|
|
|
|
2016-03-07 10:55:28 +01:00
|
|
|
def on_FieldAccess statement
|
|
|
|
# receiver_ast , field_ast = *statement
|
|
|
|
receiver = process(statement.receiver)
|
2016-02-25 21:03:11 +01:00
|
|
|
|
2015-11-09 22:26:37 +01:00
|
|
|
clazz = Register.machine.space.get_class_by_name receiver.type
|
|
|
|
|
2016-03-07 10:55:28 +01:00
|
|
|
field_name = statement.field.name
|
2015-09-27 10:28:06 +02:00
|
|
|
|
2015-11-09 22:26:37 +01:00
|
|
|
|
2016-02-25 21:16:13 +01:00
|
|
|
index = clazz.instance_type.variable_index(field_name)
|
2015-11-09 22:26:37 +01:00
|
|
|
raise "field access, but no such field:#{field_name} for class #{clazz.name}" unless index
|
2016-02-25 21:16:13 +01:00
|
|
|
value = use_reg(clazz.instance_type.type_at(index))
|
2015-11-09 22:26:37 +01:00
|
|
|
|
|
|
|
add_code Register.get_slot(statement , receiver , index, value)
|
2015-09-27 10:28:06 +02:00
|
|
|
|
2015-09-27 11:59:50 +02:00
|
|
|
value
|
2015-09-27 10:28:06 +02:00
|
|
|
end
|
2015-11-09 22:26:37 +01:00
|
|
|
|
|
|
|
def on_receiver expression
|
|
|
|
process expression.first
|
|
|
|
end
|
2015-09-27 10:28:06 +02:00
|
|
|
end
|
|
|
|
end
|