inACallStm(node); if(node.getType() != null && !_visitedNodes.contains(node.getType())) node.getType().apply(this); if(node.getName() != null ) node.getName().apply(this); List<PExp> copy = new ArrayList<PExp>(node.getArgs()); for( PExp e : copy) if(node.getRootdef() != null && !_visitedNodes.contains(node.getRootdef())) node.getRootdef().apply(this);
@Override public PTypeSet caseACallStm(ACallStm statement) throws AnalysisException { // TODO We don't know what an operation call will raise return new PTypeSet(AstFactory.newAUnknownType(statement.getLocation()), af); }
/** * Creates a new complete constructor {@code ACallStm} node with the given nodes as children. * @deprecated This method should not be used, use AstFactory instead. * The basic child nodes are removed from their previous parents. * @param name_ the {@link ILexNameToken} node for the {@code name} child of this {@link ACallStm} node * @param args_ the {@link NodeList} node for the {@code args} child of this {@link ACallStm} node * @param rootdef_ the {@link PDefinition} <b>graph</a> node for the {@code rootdef} child of this {@link ACallStm} node. * <i>The parent of this {@code rootdef } will not be changed by adding it to this node.</i> */ public ACallStm(ILexLocation location_, PType type_, ILexNameToken name_, List<? extends PExp> args_, PDefinition rootdef_) { super(location_,type_); this.setName(name_); this.setArgs(args_); this.setRootdef(rootdef_); }
List<PType> atypes = getArgTypes(node.getArgs(), THIS, question); node.getName().setTypeQualifier(atypes); PDefinition opdef = question.env.findName(node.getName(), question.scope); node.setRootdef(opdef); TypeCheckerErrors.report(3213, "Operation " + node.getName() + " is not in scope", node.getLocation(), node); question.env.listAlternatives(node.getName()); node.setType(AstFactory.newAUnknownType(node.getLocation())); return node.getType(); if (question.env.isVDMPP() && node.getName().getExplicit()) TypeCheckerErrors.report(3324, "Operation " + node.getName() + " is not static", node.getLocation(), node); node.setType(AstFactory.newAUnknownType(node.getLocation())); return node.getType(); TypeCheckerErrors.report(3337, "Cannot call a constructor from here", node.getLocation(), node); node.setType(AstFactory.newAUnknownType(node.getLocation())); return node.getType(); TypeCheckerErrors.report(3214, "Cannot call " + node.getName() + " from static context", node.getLocation(), node); node.setType(AstFactory.newAUnknownType(node.getLocation())); return node.getType();
breakpoint.check(node.getLocation(), ctxt); boolean endstop = breakpoint.catchReturn(ctxt); Value v = ctxt.lookup(node.getName()).deref(); ValueList argValues = new ValueList(); for (PExp arg : node.getArgs()) Value rv = op.eval(node.getLocation(), argValues, ctxt); ValueList argValues = new ValueList(); for (PExp arg : node.getArgs()) Value rv = fn.eval(node.getLocation(), argValues, ctxt); return VdmRuntimeError.abort(node.getLocation(), e);
@Override public SOperationDefinitionBase caseACallStm(ACallStm node) throws AnalysisException { return node.getRootdef().apply(this); }
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)); }
@Override public PExp caseACallStm(ACallStm stm, Integer lineno) throws AnalysisException { return af.createPExpAssistant().findExpression(stm.getArgs(), lineno); }
@Override public IProofObligationList caseACallStm(ACallStm node, IPOContextStack question) throws AnalysisException { try { IProofObligationList obligations = new ProofObligationList(); for (PExp exp : node.getArgs()) { obligations.addAll(exp.apply(rootVisitor, question)); } // stick possible op post_condition in the context SOperationDefinitionBase calledOp = node.apply(new GetOpCallVisitor()); if (calledOp != null) { if (calledOp.getPrecondition() != null) { obligations.add(new OperationCallObligation(node, calledOp, question, aF)); } question.push(new OpPostConditionContext(calledOp.getPostdef(), node, calledOp, aF, question)); } return obligations; } catch (Exception e) { throw new POException(node, e.getMessage()); } }
sb.append(cs.getName().getName()); sep = "; "; } else if (stmt instanceof ACallObjectStm)
private String getInitName(APlainCallStmIR node) { if (node.getSourceNode() != null && node.getSourceNode().getVdmNode() != null) { INode vdmNode = node.getSourceNode().getVdmNode(); if (vdmNode instanceof ACallStm) { ACallStm c = (ACallStm) vdmNode; PDefinition rootDef = c.getRootdef(); while (rootDef instanceof AInheritedDefinition) { rootDef = ((AInheritedDefinition) rootDef).getSuperdef(); } if (rootDef instanceof AExplicitOperationDefinition) { AExplicitOperationDefinition op = (AExplicitOperationDefinition) rootDef; if (op.getIsConstructor()) { return getObjectInitializerCall(op); } } } } return null; }
public OpPostConditionContext(AExplicitFunctionDefinition postDef, ACallStm stm, SOperationDefinitionBase calledOp, IPogAssistantFactory af, IPOContextStack ctxt) { super(ctxt); this.gen = ctxt.getGenerator(); this.subs = new LinkedList<Substitution>(); this.forall_exp = getChangedVarsExp(postDef, calledOp); PExp inv = buildInvExp(calledOp, af); this.pred = spellCondition(postDef, af, stm.getArgs(), inv); this.visitor = af.getVarSubVisitor(); }
inACallStm(node, question); if(node.getType() != null && !_visitedNodes.contains(node.getType())) node.getType().apply(this, question); if(node.getName() != null ) node.getName().apply(this, question); List<PExp> copy = new ArrayList<PExp>(node.getArgs()); for( PExp e : copy) if(node.getRootdef() != null && !_visitedNodes.contains(node.getRootdef())) node.getRootdef().apply(this, question);
PDefinition def = callStm.getRootdef();
public void checkArgTypes(ACallStm node, PType type, List<PType> ptypes, List<PType> atypes, TypeCheckInfo question) { if (ptypes.size() != atypes.size()) { TypeCheckerErrors.report(3216, "Expecting " + ptypes.size() + " arguments", node.getLocation(), node); } else { int i = 0; for (PType atype : atypes) { PType ptype = ptypes.get(i++); if (!question.assistantFactory.getTypeComparator().compatible(ptype, atype)) { TypeCheckerErrors.report(3217, "Unexpected type for argument " + i, node.getLocation(), type); TypeCheckerErrors.detail2("Expected", ptype, "Actual", atype); } } } }
inACallStm(node); if(node.getType() != null && !_visitedNodes.contains(node.getType())) node.getType().apply(this); if(node.getName() != null ) node.getName().apply(this); List<PExp> copy = new ArrayList<PExp>(node.getArgs()); for( PExp e : copy) if(node.getRootdef() != null && !_visitedNodes.contains(node.getRootdef())) node.getRootdef().apply(this);
if (callStm.getRootdef() instanceof SOperationDefinition) SOperationDefinition op = (SOperationDefinition) callStm.getRootdef(); } else if (callStm.getRootdef() instanceof SFunctionDefinition) SFunctionDefinition func = (SFunctionDefinition) callStm.getRootdef();
mergeReturns(retVal,inACallStm(node)); if(node.getType() != null && !_visitedNodes.contains(node.getType())) mergeReturns(retVal,node.getType().apply(this)); if(node.getName() != null ) mergeReturns(retVal,node.getName().apply(this)); List<PExp> copy = new ArrayList<PExp>(node.getArgs()); for( PExp e : copy) if(node.getRootdef() != null && !_visitedNodes.contains(node.getRootdef())) mergeReturns(retVal,node.getRootdef().apply(this));