public RecordValue(ARecordInvariantType type, NameValuePairList mapvalues, Context ctxt) { this.type = type; this.invariant = null; this.fieldmap = new FieldMap(); this.equality = null; this.ordering = null; for (NameValuePair nvp : mapvalues) { AFieldField f = ctxt.assistantFactory.createARecordInvariantTypeAssistant().findField(type, nvp.name.getName()); this.fieldmap.add(nvp.name.getName(), nvp.value, !f.getEqualityAbstraction()); } }
public RecordValue(ARecordInvariantType type, ValueList values, Context ctxt) throws AnalysisException { this.type = type; this.fieldmap = new FieldMap(); this.invariant = ctxt.assistantFactory.createSInvariantTypeAssistant().getInvariant(type, ctxt); this.equality = ctxt.assistantFactory.createSInvariantTypeAssistant().getEquality(type, ctxt); this.ordering = ctxt.assistantFactory.createSInvariantTypeAssistant().getOrder(type, ctxt); if (values.size() != type.getFields().size()) { abort(4078, "Wrong number of fields for " + type.getName(), ctxt); } Iterator<AFieldField> fi = type.getFields().iterator(); for (Value v : values) { AFieldField f = fi.next(); fieldmap.add(f.getTag(), v.convertTo(f.getType(), ctxt), !f.getEqualityAbstraction()); } checkInvariant(ctxt); }
public RecordValue(ARecordInvariantType type, FieldMap mapvalues, Context ctxt) throws AnalysisException { this.type = type; this.fieldmap = new FieldMap(); this.invariant = ctxt.assistantFactory.createSInvariantTypeAssistant().getInvariant(type, ctxt); this.equality = ctxt.assistantFactory.createSInvariantTypeAssistant().getEquality(type, ctxt); this.ordering = ctxt.assistantFactory.createSInvariantTypeAssistant().getOrder(type, ctxt); if (mapvalues.size() != type.getFields().size()) { abort(4080, "Wrong number of fields for " + type.getName(), ctxt); } Iterator<AFieldField> fi = type.getFields().iterator(); while (fi.hasNext()) { AFieldField f = fi.next(); Value v = mapvalues.get(f.getTag()); if (v == null) { abort(4081, "Field not defined: " + f.getTag(), ctxt); } fieldmap.add(f.getTag(), v.convertTo(f.getType(), ctxt), !f.getEqualityAbstraction()); } checkInvariant(ctxt); }
@Override public Value caseAMuExp(AMuExp node, Context ctxt) throws AnalysisException { BreakpointManager.getBreakpoint(node).check(node.getLocation(), ctxt); try { RecordValue r = node.getRecord().apply(VdmRuntime.getExpressionEvaluator(), ctxt).recordValue(ctxt); FieldMap fields = new FieldMap(r.fieldmap); for (ARecordModifier rm : node.getModifiers()) { AFieldField f = ctxt.assistantFactory.createARecordInvariantTypeAssistant().findField(r.type, rm.getTag().getName()); if (f == null) { VdmRuntimeError.abort(node.getLocation(), 4023, "Mu type conflict? No field tag " + rm.getTag().getName(), ctxt); } else { fields.add(rm.getTag().getName(), rm.getValue().apply(VdmRuntime.getExpressionEvaluator(), ctxt), !f.getEqualityAbstraction()); } } return new RecordValue(r.type, fields, ctxt); } catch (ValueException e) { return VdmRuntimeError.abort(node.getLocation(), e); } }