@Override public Value caseAFieldExp(AFieldExp node, Context ctxt) throws AnalysisException { BreakpointManager.getBreakpoint(node).check(node.getLocation(), ctxt); node.getField().getLocation().hit(); try { return ctxt.assistantFactory.createAFieldExpAssistant().evaluate(node, ctxt); } catch (ValueException e) { return VdmRuntimeError.abort(node.getLocation(), e); } }
VdmRuntimeError.abort(exp.getLocation(), e); return null; } catch (AnalysisException e)
public Value evaluate(AFieldExp node, Context ctxt) throws AnalysisException { Value v = node.getObject().apply(VdmRuntime.getExpressionEvaluator(), ctxt); PType objtype = null; Value r = null; if (v.isType(ObjectValue.class)) { ObjectValue ov = v.objectValue(ctxt); objtype = ov.type; r = ov.get(node.getMemberName(), node.getMemberName().getExplicit()); } else { RecordValue rv = v.recordValue(ctxt); objtype = rv.type; FieldMap fields = rv.fieldmap; r = fields.get(node.getField().getName()); } if (r == null) { VdmRuntimeError.abort(node.getLocation(), 4006, "Type " + objtype + " has no field " + node.getField().getName(), ctxt); } return r; }
LexNameToken sname = new LexNameToken(rec.getName().getModule(), node.getField().getName(), node.getLocation()); node.setType(AstFactory.newAUnknownType(node.getLocation())); return node.getType(); PType resType = results.getType(node.getLocation()); node.setType(resType); return node.getType();