private PExp addPossibleType(PExp exp, PPattern node) { PType possibleType = af.createPPatternAssistant().getPossibleType(node); if (possibleType != null) { exp.setType(possibleType.clone()); } else { exp.setType(new AUnknownType()); } return exp; } }
ILexNameToken origName = af.createPPatternAssistant().getAllVariableNames(orig).get(0).clone(); PExp new_exp = args.get(0).clone(); subs.add(new Substitution(origName, new_exp));
public OperationCallObligation(ACallStm stm, SOperationDefinitionBase def, IPOContextStack ctxt, IPogAssistantFactory af) throws AnalysisException { super(stm, POType.OP_CALL, ctxt, stm.getLocation(), af); // cannot quote pre-cond so we spell it out with rewritten arguments List<Substitution> subs = new LinkedList<Substitution>(); for (int i = 0; i < stm.getArgs().size(); i++) { PPattern orig = def.getPredef().getParamPatternList().get(0).get(i); ILexNameToken origName = af.createPPatternAssistant().getAllVariableNames(orig).get(0).clone(); PExp new_exp = stm.getArgs().get(0); subs.add(new Substitution(origName, new_exp)); } PExp pre_exp = def.getPrecondition().clone(); for (Substitution sub : subs) { pre_exp = pre_exp.clone().apply(af.getVarSubVisitor(), sub); } stitch = pre_exp; valuetree.setPredicate(ctxt.getPredWithContext(pre_exp)); }
existsBindList.add(getMultipleTypeBind(atype, bname)); for (PDefinition def : assistantFactory.createPPatternAssistant().getDefinitions(param, atype, NameScope.LOCAL))
private PExp alt2Exp(ACaseAlternative alt, ACasesExp exp, IPogAssistantFactory assistantFactory) throws AnalysisException { if (assistantFactory.createPPatternAssistant().isSimple(alt.getPattern())) { AEqualsBinaryExp equalsExp = AstExpressionFactory.newAEqualsBinaryExp(exp.getExpression().clone(), patternToExp(alt.getPattern().clone())); return equalsExp; } else { PExp matching = patternToExp(alt.getPattern().clone()); AExistsExp existsExp = new AExistsExp(); ATypeMultipleBind tbind = new ATypeMultipleBind(); List<PPattern> plist = new LinkedList<PPattern>(); plist.add(alt.getPattern().clone()); tbind.setPlist(plist); tbind.setType(exp.getExpression().getType().clone()); List<PMultipleBind> bindList = new LinkedList<PMultipleBind>(); bindList.add(tbind); existsExp.setBindList(bindList); AEqualsBinaryExp equalsExp = AstExpressionFactory.newAEqualsBinaryExp(exp.getExpression().clone(), matching); existsExp.setPredicate(equalsExp); return existsExp; } }
@Override public PExp getContextNode(PExp stitch) if (assistantFactory.createPPatternAssistant().isSimple(pattern))
private PExp getCaseExp() { if (assistantFactory.createPPatternAssistant().isSimple(pattern)) { ANotUnaryExp notExp = new ANotUnaryExp(); AEqualsBinaryExp equalsExp = AstExpressionFactory.newAEqualsBinaryExp(patternToExp(pattern.clone(), assistantFactory, new UniqueNameGenerator(exp)), exp.clone()); notExp.setExp(equalsExp); return notExp; } else { ANotUnaryExp notExp = new ANotUnaryExp(); AExistsExp existsExp = new AExistsExp(); List<PMultipleBind> bindList = ContextHelper.bindListFromPattern(pattern.clone(), type.clone()); existsExp.setBindList(bindList); PExp matching = patternToExp(pattern,assistantFactory,new UniqueNameGenerator(exp)); AEqualsBinaryExp equalsExp = AstExpressionFactory.newAEqualsBinaryExp(matching, exp.clone()); existsExp.setPredicate(equalsExp); notExp.setExp(existsExp); return notExp; } }
&& assistantFactory.createPTypeAssistant().isUnion(type)) PType patternType = assistantFactory.createPPatternAssistant().getPossibleType(pattern); AUnionType ut = assistantFactory.createPTypeAssistant().getUnion(type); PTypeSet set = new PTypeSet(assistantFactory);
for (PDefinition def : assistantFactory.createPPatternAssistant().getDefinitions(p, typeIter.next(), NameScope.LOCAL))
for (PDefinition def : assistantFactory.createPPatternAssistant().getDefinitions(p, typeIter.next(), NameScope.LOCAL))
for (PDefinition def : assistantFactory.createPPatternAssistant().getDefinitions(p, typeIter.next(), NameScope.LOCAL))
&& node.getExpType() instanceof AUnionType) PType patternType = assistantFactory.createPPatternAssistant().getPossibleType(pattern); // With