2017-01-14 19:28:44 +02:00
|
|
|
module Vm
|
2016-12-09 14:04:06 +02:00
|
|
|
module FieldAccess
|
2015-09-27 11:28:06 +03:00
|
|
|
|
2016-03-07 11:55:28 +02:00
|
|
|
def on_FieldAccess statement
|
|
|
|
# receiver_ast , field_ast = *statement
|
|
|
|
receiver = process(statement.receiver)
|
2016-02-25 12:03:11 -08:00
|
|
|
|
2016-12-14 13:24:42 +02:00
|
|
|
type = receiver.type
|
|
|
|
if(type.is_a?(Symbol))
|
2016-12-30 14:10:49 +02:00
|
|
|
type = Parfait.object_space.get_class_by_name(type).instance_type
|
2016-12-14 13:24:42 +02:00
|
|
|
end
|
2016-03-07 11:55:28 +02:00
|
|
|
field_name = statement.field.name
|
2016-12-14 13:24:42 +02:00
|
|
|
|
|
|
|
index = type.variable_index(field_name)
|
|
|
|
raise "no such field:#{field_name} for class #{type.inspect}" unless index
|
|
|
|
value = use_reg(type.type_at(index))
|
2015-11-09 23:26:37 +02:00
|
|
|
|
2016-12-28 20:37:54 +02:00
|
|
|
add_slot_to_reg(statement , receiver , index, value)
|
2015-09-27 11:28:06 +03:00
|
|
|
|
2015-09-27 12:59:50 +03:00
|
|
|
value
|
2015-09-27 11:28:06 +03:00
|
|
|
end
|
2015-11-09 23:26:37 +02:00
|
|
|
|
|
|
|
def on_receiver expression
|
|
|
|
process expression.first
|
|
|
|
end
|
2015-09-27 11:28:06 +03:00
|
|
|
end
|
|
|
|
end
|