@Override public PType caseATypeDefinition(ATypeDefinition node) throws AnalysisException { return ((ATypeDefinition) node).getInvType(); }
@Override public boolean mustHandleNameToken(ILexNameToken nameToken) { if (this.getNames().contains(nameToken.getName())) { PDefinitionAssistantTC defAssistant = irInfo.getTcFactory().createPDefinitionAssistant(); TypeAssistantIR typeAssistantCg = irInfo.getAssistantManager().getTypeAssistant(); PDefinition def = typeAssistantCg.getTypeDef(nameToken, defAssistant); if (def instanceof ATypeDefinition) { ATypeDefinition typeDef = (ATypeDefinition) def; return typeDef.getInvType() == null; } return def != null; } else if (isModuleViolation(nameToken)) { return true; } return false; }
public SatisfiabilityObligation(ATypeDefinition node, IPOContextStack ctxt, IPogAssistantFactory af) throws AnalysisException { super(node, POType.TYPE_INV_SAT, ctxt, node.getLocation(), af); AExistsExp exists_exp = new AExistsExp(); exists_exp.setType(new ABooleanBasicType()); ATypeMultipleBind tmb = new ATypeMultipleBind(); List<PPattern> pats = new LinkedList<PPattern>(); pats.add(node.getInvPattern().clone()); tmb.setPlist(pats); tmb.setType(node.getInvType().clone()); List<PMultipleBind> binds = new LinkedList<PMultipleBind>(); binds.add(tmb); exists_exp.setBindList(binds); exists_exp.setPredicate(node.getInvExpression().clone()); stitch = exists_exp; valuetree.setPredicate(ctxt.getPredWithContext(exists_exp)); }
private PTypeList getPTypes(ATypeDefinition typedef) { PTypeList ptypes = new PTypeList(); if (typedef.getInvType() instanceof ARecordInvariantType) { // Records are inv_R: R +> bool AUnresolvedType uType= AstFactory.newAUnresolvedType(typedef.getName().clone()); ptypes.add(uType.clone()); ptypes.add(uType.clone()); } else { // Named types are inv_T: x +> bool, for T = x ANamedInvariantType nt = (ANamedInvariantType) typedef.getInvType(); ptypes.add(nt.getType().clone()); ptypes.add(nt.getType().clone()); } return ptypes; }
public AExplicitFunctionDefinition getInvDefinition(ATypeDefinition d) { ILexLocation loc = d.getInvPattern().getLocation(); List<PPattern> params = new Vector<PPattern>(); params.add(d.getInvPattern().clone()); List<List<PPattern>> parameters = new Vector<List<PPattern>>(); parameters.add(params); PTypeList ptypes = new PTypeList(); if (d.getInvType() instanceof ARecordInvariantType) { // Records are inv_R: R +> bool ptypes.add(AstFactory.newAUnresolvedType(d.getName().clone())); } else { // Named types are inv_T: x +> bool, for T = x ANamedInvariantType nt = (ANamedInvariantType) d.getInvType(); ptypes.add(nt.getType().clone()); } AFunctionType ftype = AstFactory.newAFunctionType(loc, false, ptypes, AstFactory.newABooleanBasicType(loc)); AExplicitFunctionDefinition def = AstFactory.newAExplicitFunctionDefinition(d.getName().getInvName(loc), NameScope.GLOBAL, null, ftype, parameters, d.getInvExpression(), null, null, true, null); def.setAccess(d.getAccess().clone()); // Same as type's def.setClassDefinition(d.getClassDefinition()); return def; }
if(node.getInvType() != null && !_visitedNodes.contains(node.getInvType())) node.getInvType().apply(this);
if(node.getInvType() != null && !_visitedNodes.contains(node.getInvType())) node.getInvType().apply(this, question);
if(node.getInvType() != null && !_visitedNodes.contains(node.getInvType())) node.getInvType().apply(this);
node.getInvType().setInvDef(node.getInvdef()); } else node.getInvType().setOrdDef(node.getOrdRelation().getRelDef()); setMinMax(node.getOrdRelation(),node); node.getInvType().setEqDef(node.getEqRelation().getRelDef()); if (node.getInvType() instanceof ANamedInvariantType) ANamedInvariantType ntype = (ANamedInvariantType) node.getInvType(); node.getComposeDefinitions().clear();
AFunctionType ftype = AstFactory.newAFunctionType(loc.clone(), false, ptypes, typeDef.getInvType().clone()); AExplicitFunctionDefinition maxD = AstFactory.newAExplicitFunctionDefinition(typeDef.getName().getMaxName(loc), NameScope.GLOBAL, null, ftype, parameters, maxBody, null, null, true, null); ftype = AstFactory.newAFunctionType(loc.clone(), false, ptypes, typeDef.getInvType().clone());
if(node.getInvType() != null && !_visitedNodes.contains(node.getInvType())) mergeReturns(retVal,node.getInvType().apply(this, question));
if(node.getInvType() != null && !_visitedNodes.contains(node.getInvType())) mergeReturns(retVal,node.getInvType().apply(this));
node.setInvType((SInvariantType) af.createPTypeAssistant().typeResolve((SInvariantType) node.getInvType(), node, question.rootVisitor, question.question)); node.setType(node.getInvType()); node.setType(node.getInvType()); af.createPTypeAssistant().unResolve(node.getInvType()); throw e;