@Override public void caseAForIndexStm(AForIndexStm node) throws AnalysisException { if (!proceed(node)) { return; } if (node.getFrom() != null) { node.getFrom().apply(this); } if (node.getTo() != null) { node.getTo().apply(this); } if (node.getBy() != null) { node.getBy().apply(this); } ILexNameToken var = node.getVar(); openLoop(var, null, node.getStatement()); node.getStatement().apply(this); localDefsInScope.remove(var); }
@Override public PTypeSet caseAForIndexStm(AForIndexStm statement) throws AnalysisException { return statement.getStatement().apply(THIS); }
@Override public PStm caseAForIndexStm(AForIndexStm 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); }
inAForIndexStm(node); if(node.getType() != null && !_visitedNodes.contains(node.getType())) node.getType().apply(this); if(node.getVar() != null ) node.getVar().apply(this); if(node.getFrom() != null && !_visitedNodes.contains(node.getFrom())) node.getFrom().apply(this); if(node.getTo() != null && !_visitedNodes.contains(node.getTo())) node.getTo().apply(this); if(node.getBy() != null && !_visitedNodes.contains(node.getBy())) node.getBy().apply(this); if(node.getStatement() != null && !_visitedNodes.contains(node.getStatement())) node.getStatement().apply(this);
inAForIndexStm(node); if(node.getType() != null && !_visitedNodes.contains(node.getType())) node.getType().apply(this); if(node.getVar() != null ) node.getVar().apply(this); if(node.getFrom() != null && !_visitedNodes.contains(node.getFrom())) node.getFrom().apply(this); if(node.getTo() != null && !_visitedNodes.contains(node.getTo())) node.getTo().apply(this); if(node.getBy() != null && !_visitedNodes.contains(node.getBy())) node.getBy().apply(this); if(node.getStatement() != null && !_visitedNodes.contains(node.getStatement())) node.getStatement().apply(this);
inAForIndexStm(node, question); if(node.getType() != null && !_visitedNodes.contains(node.getType())) node.getType().apply(this, question); if(node.getVar() != null ) node.getVar().apply(this, question); if(node.getFrom() != null && !_visitedNodes.contains(node.getFrom())) node.getFrom().apply(this, question); if(node.getTo() != null && !_visitedNodes.contains(node.getTo())) node.getTo().apply(this, question); if(node.getBy() != null && !_visitedNodes.contains(node.getBy())) node.getBy().apply(this, question); if(node.getStatement() != null && !_visitedNodes.contains(node.getStatement())) node.getStatement().apply(this, question);
mergeReturns(retVal,inAForIndexStm(node)); if(node.getType() != null && !_visitedNodes.contains(node.getType())) mergeReturns(retVal,node.getType().apply(this)); if(node.getVar() != null ) mergeReturns(retVal,node.getVar().apply(this)); if(node.getFrom() != null && !_visitedNodes.contains(node.getFrom())) mergeReturns(retVal,node.getFrom().apply(this)); if(node.getTo() != null && !_visitedNodes.contains(node.getTo())) mergeReturns(retVal,node.getTo().apply(this)); if(node.getBy() != null && !_visitedNodes.contains(node.getBy())) mergeReturns(retVal,node.getBy().apply(this)); if(node.getStatement() != null && !_visitedNodes.contains(node.getStatement())) mergeReturns(retVal,node.getStatement().apply(this));
mergeReturns(retVal,inAForIndexStm(node, question)); if(node.getType() != null && !_visitedNodes.contains(node.getType())) mergeReturns(retVal,node.getType().apply(this, question)); if(node.getVar() != null ) mergeReturns(retVal,node.getVar().apply(this, question)); if(node.getFrom() != null && !_visitedNodes.contains(node.getFrom())) mergeReturns(retVal,node.getFrom().apply(this, question)); if(node.getTo() != null && !_visitedNodes.contains(node.getTo())) mergeReturns(retVal,node.getTo().apply(this, question)); if(node.getBy() != null && !_visitedNodes.contains(node.getBy())) mergeReturns(retVal,node.getBy().apply(this, question)); if(node.getStatement() != null && !_visitedNodes.contains(node.getStatement())) mergeReturns(retVal,node.getStatement().apply(this, question));
@Override public PExp caseAForIndexStm(AForIndexStm stm, Integer lineno) throws AnalysisException { PExp found = af.createPExpAssistant().findExpression(stm.getFrom(), lineno); if (found != null) { return found; } found = stm.getTo().apply(THIS, lineno); if (found != null) { return found; } found = af.createPExpAssistant().findExpression(stm.getBy(), lineno); if (found != null) { return found; } return stm.getStatement().apply(THIS, lineno); }
@Override public PType caseAForIndexStm(AForIndexStm node, TypeCheckInfo question) throws AnalysisException { PType ft = node.getFrom().apply(THIS, question); PType tt = node.getTo().apply(THIS, question); if (!question.assistantFactory.createPTypeAssistant().isNumeric(ft)) { TypeCheckerErrors.report(3220, "From type is not numeric", node.getLocation(), node); } if (!question.assistantFactory.createPTypeAssistant().isNumeric(tt)) { TypeCheckerErrors.report(3221, "To type is not numeric", node.getLocation(), node); } if (node.getBy() != null) { PType bt = node.getBy().apply(THIS, question); if (!question.assistantFactory.createPTypeAssistant().isNumeric(bt)) { TypeCheckerErrors.report(3222, "By type is not numeric", node.getLocation(), node); } } PDefinition vardef = AstFactory.newALocalDefinition(node.getVar().getLocation(), node.getVar(), NameScope.LOCAL, ft); Environment local = new FlatCheckedEnvironment(question.assistantFactory, vardef, question.env, question.scope); PType rt = node.getStatement().apply(THIS, new TypeCheckInfo(question.assistantFactory, local, question.scope)); local.unusedCheck(); node.setType(rt); return rt; }
@Override public IProofObligationList caseAForIndexStm(AForIndexStm node, IPOContextStack question) throws AnalysisException { try { IProofObligationList obligations = node.getFrom().apply(rootVisitor, question); obligations.addAll(node.getTo().apply(rootVisitor, question)); if (node.getBy() != null) { obligations.addAll(node.getBy().apply(rootVisitor, question)); } question.push(new POScopeContext()); obligations.addAll(node.getStatement().apply(mainVisitor, question)); question.pop(); return obligations; } catch (Exception e) { throw new POException(node, e.getMessage()); } }
throws AnalysisException BreakpointManager.getBreakpoint(node).check(node.getLocation(), ctxt); long fval = node.getFrom().apply(VdmRuntime.getStatementEvaluator(), ctxt).intValue(ctxt); long tval = node.getTo().apply(VdmRuntime.getStatementEvaluator(), ctxt).intValue(ctxt); long bval = node.getBy() == null ? 1 : node.getBy().apply(VdmRuntime.getStatementEvaluator(), ctxt).intValue(ctxt); VdmRuntimeError.abort(node.getLocation(), 4038, "Loop, from " + fval + " to " + tval + " by " + bval + " will never terminate", ctxt); && value >= tval; value += bval) Context evalContext = new Context(ctxt.assistantFactory, node.getLocation(), "for index", ctxt); evalContext.put(node.getVar(), new IntegerValue(value)); Value rv = node.getStatement().apply(VdmRuntime.getStatementEvaluator(), evalContext); VdmRuntimeError.abort(node.getLocation(), e);
@Override public SStmIR caseAForIndexStm(AForIndexStm node, IRInfo question) throws AnalysisException { ILexNameToken var = node.getVar(); PExp from = node.getFrom(); PExp to = node.getTo(); PExp by = node.getBy(); PStm stm = node.getStatement(); String varCg = var.getName(); SExpIR fromCg = from.apply(question.getExpVisitor(), question); SExpIR toCg = to.apply(question.getExpVisitor(), question); SExpIR byCg = by != null ? by.apply(question.getExpVisitor(), question) : null; SStmIR bodyCg = stm.apply(question.getStmVisitor(), question); AForIndexStmIR forStm = new AForIndexStmIR(); forStm.setVar(varCg); forStm.setFrom(fromCg); forStm.setTo(toCg); forStm.setBy(byCg); forStm.setBody(bodyCg); return forStm; }