/** * Called by the {@link AForPatternBindStm} node from {@link AForPatternBindStm#apply(IAnalysis)}. * @param node the calling {@link AForPatternBindStm} node */ public void caseAForPatternBindStm(AForPatternBindStm node, Q question) throws AnalysisException { _visitedNodes.add(node); inAForPatternBindStm(node, question); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { node.getType().apply(this, question); } if(node.getPatternBind() != null && !_visitedNodes.contains(node.getPatternBind())) { node.getPatternBind().apply(this, question); } if(node.getExp() != null && !_visitedNodes.contains(node.getExp())) { node.getExp().apply(this, question); } if(node.getStatement() != null && !_visitedNodes.contains(node.getStatement())) { node.getStatement().apply(this, question); } if(node.getSeqType() != null && !_visitedNodes.contains(node.getSeqType())) { node.getSeqType().apply(this, question); } outAForPatternBindStm(node, question); }
/** * Creates a new complete constructor {@code AForPatternBindStm} 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 patternBind_ the {@link ADefPatternBind} node for the {@code patternBind} child of this {@link AForPatternBindStm} node * @param reverse_ the {@link Boolean} node for the {@code reverse} child of this {@link AForPatternBindStm} node * @param exp_ the {@link PExp} node for the {@code exp} child of this {@link AForPatternBindStm} node * @param statement_ the {@link PStm} node for the {@code statement} child of this {@link AForPatternBindStm} node * @param seqType_ the {@link SSeqType} <b>graph</a> node for the {@code seqType} child of this {@link AForPatternBindStm} node. * <i>The parent of this {@code seqType } will not be changed by adding it to this node.</i> */ public AForPatternBindStm(ILexLocation location_, PType type_, ADefPatternBind patternBind_, Boolean reverse_, PExp exp_, PStm statement_, SSeqType seqType_) { super(location_,type_); this.setPatternBind(patternBind_); this.setReverse(reverse_); this.setExp(exp_); this.setStatement(statement_); this.setSeqType(seqType_); }
@Override public PExp caseAForPatternBindStm(AForPatternBindStm stm, Integer lineno) throws AnalysisException { PExp found = af.createPExpAssistant().findExpression(stm.getExp(), lineno); if (found != null) { return found; } return stm.getStatement().apply(THIS, lineno); }
PPattern pattern = node.getPatternBind().getPattern(); pattern = node.getPatternBind().getBind().getPattern(); PExp exp = node.getExp(); PStm stm = node.getStatement(); Boolean reverse = node.getReverse();
@Override public PType caseAForPatternBindStm(AForPatternBindStm node, TypeCheckInfo question) throws AnalysisException { PType stype = node.getExp().apply(THIS, new TypeCheckInfo(question.assistantFactory, question.env, question.scope)); Environment local = question.env; if (question.assistantFactory.createPTypeAssistant().isSeq(stype)) { node.setSeqType(question.assistantFactory.createPTypeAssistant().getSeq(stype)); node.getPatternBind().apply(THIS, new TypeCheckInfo(question.assistantFactory, question.env, question.scope)); List<PDefinition> defs = getDefinitions(node.getPatternBind()); question.assistantFactory.createPDefinitionListAssistant().typeCheck(defs, THIS, new TypeCheckInfo(question.assistantFactory, question.env, question.scope)); local = new FlatCheckedEnvironment(question.assistantFactory, defs, question.env, question.scope); } else { TypeCheckerErrors.report(3223, "Expecting sequence type after 'in'", node.getLocation(), node); } PType rt = node.getStatement().apply(THIS, new TypeCheckInfo(question.assistantFactory, local, question.scope)); local.unusedCheck(); node.setType(rt); return rt; }
@Override public void caseAForPatternBindStm(AForPatternBindStm node) throws AnalysisException { if (!proceed(node)) { return; } if (node.getExp() != null) { node.getExp().apply(this); } openScope(node.getPatternBind().getPattern(), node.getPatternBind().getDefs(), node.getStatement()); node.getStatement().apply(this); for (PDefinition def : node.getPatternBind().getDefs()) { removeLocalDefFromScope(def); } }
@Override public PTypeSet caseAForPatternBindStm(AForPatternBindStm statement) throws AnalysisException { return statement.getStatement().apply(THIS); }
@Override public LexNameSet caseAForPatternBindStm(AForPatternBindStm node, FreeVarInfo info) throws AnalysisException { return node.getExp().apply(this, info); }
if (parent != null) type = ((AForPatternBindStm) parent).getSeqType().getSeqof(); } else if ((parent = node.getAncestor(ATrapStm.class)) != null)
BreakpointManager.getBreakpoint(node).check(node.getLocation(), ctxt); ValueList values = node.getExp().apply(VdmRuntime.getStatementEvaluator(), ctxt).seqValue(ctxt); if (node.getReverse()) if (node.getPatternBind().getPattern() != null) Context evalContext = new Context(ctxt.assistantFactory, node.getLocation(), "for pattern", ctxt); evalContext.putList(ctxt.assistantFactory.createPPatternAssistant().getNamedValues(node.getPatternBind().getPattern(), val, ctxt)); Value rv = node.getStatement().apply(VdmRuntime.getStatementEvaluator(), evalContext); else if (node.getPatternBind().getBind() instanceof ASetBind) ASetBind setbind = (ASetBind) node.getPatternBind().getBind(); ValueSet set = setbind.getSet().apply(VdmRuntime.getStatementEvaluator(), ctxt).setValue(ctxt); VdmRuntimeError.abort(node.getLocation(), 4039, "Set bind does not contain value " + val, ctxt); Context evalContext = new Context(ctxt.assistantFactory, node.getLocation(), "for set bind", ctxt); evalContext.putList(ctxt.assistantFactory.createPPatternAssistant().getNamedValues(setbind.getPattern(), val, ctxt)); Value rv = node.getStatement().apply(VdmRuntime.getStatementEvaluator(), evalContext); else if (node.getPatternBind().getBind() instanceof ASeqBind) ASeqBind seqbind = (ASeqBind) node.getPatternBind().getBind(); ValueList seq = seqbind.getSeq().apply(VdmRuntime.getStatementEvaluator(), ctxt).seqValue(ctxt);
IProofObligationList list = node.getExp().apply(rootVisitor, question); if (node.getPatternBind().getPattern() != null) else if (node.getPatternBind().getBind() instanceof ATypeBind) else if (node.getPatternBind().getBind() instanceof ASetBind) ASetBind bind = (ASetBind) node.getPatternBind().getBind(); list.addAll(bind.getSet().apply(rootVisitor, question)); question.push(new POForAllContext(bind, node.getExp())); list.add(new SetMembershipObligation(bind.getPattern(), bind.getSet(), question, aF)); question.pop(); else if (node.getPatternBind().getBind() instanceof ASeqBind) ASeqBind bind = (ASeqBind) node.getPatternBind().getBind(); list.addAll(bind.getSeq().apply(rootVisitor, question)); question.push(new POForAllContext(bind, node.getExp())); list.add(new SeqMembershipObligation(bind.getPattern(), bind.getSeq(), question, aF)); question.pop(); list.addAll(node.getStatement().apply(mainVisitor, question)); return list;
@Override public PStm caseAForPatternBindStm(AForPatternBindStm stm, Integer lineno) throws AnalysisException { PStm found = findStatementBaseCase(stm, lineno); if (found != null) { return found; } return stm.getStatement().apply(THIS, lineno);// PStmAssistantInterpreter.findStatement(stm.getStatement(), // lineno); }
/** * Called by the {@link AForPatternBindStm} node from {@link AForPatternBindStm#apply(IAnalysis)}. * @param node the calling {@link AForPatternBindStm} node */ public void caseAForPatternBindStm(AForPatternBindStm node) throws AnalysisException { _visitedNodes.add(node); inAForPatternBindStm(node); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { node.getType().apply(this); } if(node.getPatternBind() != null && !_visitedNodes.contains(node.getPatternBind())) { node.getPatternBind().apply(this); } if(node.getExp() != null && !_visitedNodes.contains(node.getExp())) { node.getExp().apply(this); } if(node.getStatement() != null && !_visitedNodes.contains(node.getStatement())) { node.getStatement().apply(this); } if(node.getSeqType() != null && !_visitedNodes.contains(node.getSeqType())) { node.getSeqType().apply(this); } outAForPatternBindStm(node); }
/** * Called by the {@link AForPatternBindStm} node from {@link AForPatternBindStm#apply(IPOFAnalysis)}. * @param node the calling {@link AForPatternBindStm} node */ public void caseAForPatternBindStm(AForPatternBindStm node) throws AnalysisException { _visitedNodes.add(node); inAForPatternBindStm(node); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { node.getType().apply(this); } if(node.getPatternBind() != null && !_visitedNodes.contains(node.getPatternBind())) { node.getPatternBind().apply(this); } if(node.getExp() != null && !_visitedNodes.contains(node.getExp())) { node.getExp().apply(this); } if(node.getStatement() != null && !_visitedNodes.contains(node.getStatement())) { node.getStatement().apply(this); } if(node.getSeqType() != null && !_visitedNodes.contains(node.getSeqType())) { node.getSeqType().apply(this); } outAForPatternBindStm(node); }
mergeReturns(retVal,inAForPatternBindStm(node, question)); if(node.getType() != null && !_visitedNodes.contains(node.getType())) mergeReturns(retVal,node.getType().apply(this, question)); if(node.getPatternBind() != null && !_visitedNodes.contains(node.getPatternBind())) mergeReturns(retVal,node.getPatternBind().apply(this, question)); if(node.getExp() != null && !_visitedNodes.contains(node.getExp())) mergeReturns(retVal,node.getExp().apply(this, question)); if(node.getStatement() != null && !_visitedNodes.contains(node.getStatement())) mergeReturns(retVal,node.getStatement().apply(this, question)); if(node.getSeqType() != null && !_visitedNodes.contains(node.getSeqType())) mergeReturns(retVal,node.getSeqType().apply(this, question));
mergeReturns(retVal,inAForPatternBindStm(node)); if(node.getType() != null && !_visitedNodes.contains(node.getType())) mergeReturns(retVal,node.getType().apply(this)); if(node.getPatternBind() != null && !_visitedNodes.contains(node.getPatternBind())) mergeReturns(retVal,node.getPatternBind().apply(this)); if(node.getExp() != null && !_visitedNodes.contains(node.getExp())) mergeReturns(retVal,node.getExp().apply(this)); if(node.getStatement() != null && !_visitedNodes.contains(node.getStatement())) mergeReturns(retVal,node.getStatement().apply(this)); if(node.getSeqType() != null && !_visitedNodes.contains(node.getSeqType())) mergeReturns(retVal,node.getSeqType().apply(this));