List<PDefinition> copy = new ArrayList<PDefinition>(node.getDefinitions()); for( PDefinition e : copy) if(node.getInvDef() != null && !_visitedNodes.contains(node.getInvDef())) node.getInvDef().apply(this, question); if(node.getEqDef() != null && !_visitedNodes.contains(node.getEqDef())) node.getEqDef().apply(this, question); if(node.getOrdDef() != null && !_visitedNodes.contains(node.getOrdDef())) node.getOrdDef().apply(this, question); if(node.getName() != null ) node.getName().apply(this, question); List<AFieldField> copy = new ArrayList<AFieldField>(node.getFields()); for( AFieldField e : copy)
Newquestion question) throws AnalysisException if (type.getResolved()) type.setResolved(true); type.setInfinite(false); for (AFieldField f : type.getFields()) type.setInfinite(type.getInfinite() || question.root.getInfinite()); type.apply(af.getTypeUnresolver()); throw problem; question.root.setInfinite(type.getInfinite());
@Override public PType caseARecordInvariantType(ARecordInvariantType type, String typename) throws AnalysisException { if (type.getOpaque()) { return null; } if (typename.indexOf('`') > 0) { return type.getName().getFullName().equals(typename) ? type : null; } else { // Local typenames aren't qualified with the local module name return type.getName().getName().equals(typename) ? type : null; } }
@Override public void caseARecordInvariantType(ARecordInvariantType type) throws AnalysisException { if (!type.getResolved()) { return; } else { type.setResolved(false); } for (AFieldField f : type.getFields()) { af.createPTypeAssistant().unResolve(f.getType()); } }
if (node.getRecordType().getOpaque()) AExplicitFunctionDefinition eq = recordType.getEqDef(); AExplicitFunctionDefinition ord = recordType.getOrdDef(); AExplicitFunctionDefinition inv = recordType.getInvDef(); recordType = AstFactory.newARecordInvariantType(recordType.getName().getExplicit(true), recordType.getFields()); recordType.setInvDef(inv); recordType.setEqDef(eq); recordType.setOrdDef(ord); node.setRecordType(recordType); if (node.getRecordType().getFields().size() != node.getArgs().size()) Iterator<AFieldField> fiter = node.getRecordType().getFields().iterator(); node.setArgTypes(new LinkedList<PType>()); List<PType> argTypes = node.getArgTypes(); node.setType(node.getRecordType().clone()); return question.assistantFactory.createPTypeAssistant().checkConstraint(question.constraint, node.getRecordType(), node.getLocation());
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("mk_" + type.getName() + "("); Iterator<AFieldField> fi = type.getFields().iterator(); if (fi.hasNext()) { String ftag = fi.next().getTag(); sb.append(fieldmap.get(ftag)); while (fi.hasNext()) { ftag = fi.next().getTag(); sb.append(", " + fieldmap.get(ftag)); } } sb.append(")"); return sb.toString(); }
@Override public String caseARecordInvariantType(ARecordInvariantType type) throws AnalysisException { return type.getName().toString(); }
@Override public SDeclIR caseARecordInvariantType(ARecordInvariantType node, IRInfo question) throws AnalysisException { ILexNameToken name = node.getName(); LinkedList<AFieldField> fields = node.getFields(); ARecordDeclIR record = new ARecordDeclIR(); record.setName(name.getName()); if (node.getInvDef() != null && question.getSettings().generateInvariants()) { SDeclIR invCg = node.getInvDef().apply(question.getDeclVisitor(), question); record.setInvariant(invCg); } LinkedList<AFieldDeclIR> recordFields = record.getFields(); for (AFieldField aFieldField : fields) { SDeclIR res = aFieldField.apply(question.getDeclVisitor(), question); if (res instanceof AFieldDeclIR) { AFieldDeclIR fieldDecl = (AFieldDeclIR) res; recordFields.add(fieldDecl); } else { return null; } } return record; }
public AFieldField findField(ARecordInvariantType rec, String tag) { for (AFieldField f : rec.getFields()) { if (f.getTag().equals(tag)) { return f; } } return null; }
PDefinition existing = env.findType(composeType.getName(), null); if (retype.getFields().equals(composeType.getFields())) + composeType.getName(), composeType.getLocation()); TypeChecker.detail2(composeType.getName().getName(), composeType.getLocation(), existing.getName().getName(), existing.getLocation()); + composeType.getName() + "'", composeType.getLocation()); ARecordInvariantType r2 = (ARecordInvariantType) c2; if (r1.getName().equals(r2.getName()) && !done.contains(r1.getName()) && !r1.getFields().equals(r2.getFields())) + r1.getName(), r1.getLocation()); TypeChecker.detail2(r1.getName().getName(), r1.getLocation(), r2.getName().getName(), r2.getLocation()); done.add(r1.getName());
PDefinition cdef = AstFactory.newATypeDefinition(rtype.getName(), rtype, null, null); cdef.setAccess(node.getAccess().clone()); node.getComposeDefinitions().add(cdef); rtype.getDefinitions().get(0).setAccess(node.getAccess().clone()); for (AFieldField field : rtype.getFields())
node.getRecordType().apply(this);
throws AnalysisException if (type.getInNarrower()) type.setInNarrower(true); if (type.getDefinitions().size() > 0) for (PDefinition d : type.getDefinitions()) for (AFieldField field : type.getFields()) type.setInNarrower(false); return result;
@Override public LexNameSet caseARecordInvariantType(ARecordInvariantType node, FreeVarInfo info) throws AnalysisException { if (info.env.findType(node.getName(), node.getLocation().getModule()) == null) { // Invariant values covered in TCTypeDefinition return new LexNameSet(node.getName().getExplicit(true)); } else { return new LexNameSet(); } }
@Override public PTypeList caseARecordInvariantType(ARecordInvariantType node) throws AnalysisException { if (node.getComposed()) { PTypeList types = new PTypeList(node); for (AFieldField f : node.getFields()) { types.addAll(f.getType().apply(THIS)); } return types; } else { return new PTypeList(); } } }
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); }
@Override public Integer caseARecordInvariantType(ARecordInvariantType type) throws AnalysisException { return type.getName().apply(THIS); }
private static AFieldField findField(ARecordInvariantType ty, ILexIdentifierToken id) { List<AFieldField> fields = ty.getFields(); for (AFieldField f : fields) { if (f.getTag().equals(id.getName())) { return f; } } return null; }