@Override public PStm caseADurationStm(ADurationStm stm, Integer lineno) throws AnalysisException { return stm.getStatement().apply(THIS, lineno); }
@Override public PExp caseADurationStm(ADurationStm stm, Integer lineno) throws AnalysisException { return stm.getStatement().apply(THIS, lineno); }
/** * Called by the {@link ADurationStm} node from {@link ADurationStm#apply(IAnalysis)}. * @param node the calling {@link ADurationStm} node */ public void caseADurationStm(ADurationStm node, Q question) throws AnalysisException { _visitedNodes.add(node); inADurationStm(node, question); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { node.getType().apply(this, question); } if(node.getDuration() != null && !_visitedNodes.contains(node.getDuration())) { node.getDuration().apply(this, question); } if(node.getStatement() != null && !_visitedNodes.contains(node.getStatement())) { node.getStatement().apply(this, question); } outADurationStm(node, question); }
/** * Called by the {@link ADurationStm} node from {@link ADurationStm#apply(IAnalysis)}. * @param node the calling {@link ADurationStm} node */ public void caseADurationStm(ADurationStm node) throws AnalysisException { _visitedNodes.add(node); inADurationStm(node); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { node.getType().apply(this); } if(node.getDuration() != null && !_visitedNodes.contains(node.getDuration())) { node.getDuration().apply(this); } if(node.getStatement() != null && !_visitedNodes.contains(node.getStatement())) { node.getStatement().apply(this); } outADurationStm(node); }
/** * Called by the {@link ADurationStm} node from {@link ADurationStm#apply(IPOFAnalysis)}. * @param node the calling {@link ADurationStm} node */ public void caseADurationStm(ADurationStm node) throws AnalysisException { _visitedNodes.add(node); inADurationStm(node); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { node.getType().apply(this); } if(node.getDuration() != null && !_visitedNodes.contains(node.getDuration())) { node.getDuration().apply(this); } if(node.getStatement() != null && !_visitedNodes.contains(node.getStatement())) { node.getStatement().apply(this); } outADurationStm(node); }
@Override public LexNameSet caseADurationStm(ADurationStm node, FreeVarInfo info) throws AnalysisException { LexNameSet names = node.getDuration().apply(this, info); names.addAll(node.getStatement().apply(this, info)); return names; }
/** * Called by the {@link ADurationStm} node from {@link ADurationStm#apply(IAnalysis)}. * @param node the calling {@link ADurationStm} node */ public A caseADurationStm(ADurationStm node, Q question) throws AnalysisException { _visitedNodes.add(node); A retVal = createNewReturnValue(node, question); mergeReturns(retVal,inADurationStm(node, question)); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { mergeReturns(retVal,node.getType().apply(this, question)); } if(node.getDuration() != null && !_visitedNodes.contains(node.getDuration())) { mergeReturns(retVal,node.getDuration().apply(this, question)); } if(node.getStatement() != null && !_visitedNodes.contains(node.getStatement())) { mergeReturns(retVal,node.getStatement().apply(this, question)); } mergeReturns(retVal,outADurationStm(node, question)); return retVal; }
/** * Called by the {@link ADurationStm} node from {@link ADurationStm#apply(IAnalysis)}. * @param node the calling {@link ADurationStm} node */ public A caseADurationStm(ADurationStm node) throws AnalysisException { _visitedNodes.add(node); A retVal = createNewReturnValue(node); mergeReturns(retVal,inADurationStm(node)); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { mergeReturns(retVal,node.getType().apply(this)); } if(node.getDuration() != null && !_visitedNodes.contains(node.getDuration())) { mergeReturns(retVal,node.getDuration().apply(this)); } if(node.getStatement() != null && !_visitedNodes.contains(node.getStatement())) { mergeReturns(retVal,node.getStatement().apply(this)); } mergeReturns(retVal,outADurationStm(node)); return retVal; }
@Override public SStmIR caseADurationStm(ADurationStm node, IRInfo question) throws AnalysisException { PExp duration = node.getDuration(); PStm stm = node.getStatement(); SExpIR durationCg = duration.apply(question.getExpVisitor(), question); SStmIR stmCg = stm.apply(question.getStmVisitor(), question); ADurationStmIR durStm = new ADurationStmIR(); durStm.setDuration(durationCg); durStm.setStm(stmCg); ; return durStm; }
@Override public Value caseADurationStm(ADurationStm node, Context ctxt) throws AnalysisException { node.getLocation().hit(); node.getDuration().getLocation().hit(); ISchedulableThread me = BasicSchedulableThread.getThread(Thread.currentThread()); if (me.inOuterTimestep()) { // Already in a timed step, so ignore nesting return node.getStatement().apply(VdmRuntime.getStatementEvaluator(), ctxt); } else { // We disable the swapping and time (RT) as duration evaluation should be "free". long step; try { ctxt.threadState.setAtomic(true); step = node.getDuration().apply(VdmRuntime.getStatementEvaluator(), ctxt).natValue(ctxt); } finally { ctxt.threadState.setAtomic(false); } me.inOuterTimestep(true); Value rv = node.getStatement().apply(VdmRuntime.getStatementEvaluator(), ctxt); me.inOuterTimestep(false); me.duration(step, ctxt, node.getLocation()); return rv; } }
@Override public PType caseADurationStm(ADurationStm node, TypeCheckInfo question) throws AnalysisException { PDefinition encl = question.env.getEnclosingDefinition(); if (encl != null && encl.getAccess().getPure()) { TypeCheckerErrors.report(3346, "Cannot use duration in pure operations", node.getLocation(), node); } Environment newEnv = new FlatEnvironment(question.assistantFactory, question.env, true); TypeCheckInfo functional = question.newInfo(newEnv); PType argType = node.getDuration().apply(THIS, functional); if (!question.assistantFactory.getTypeComparator().compatible(AstFactory.newANatNumericBasicType(node.getLocation()), argType)) { TypeCheckerErrors.report(3281, "Arguments to duration must be a nat", node.getLocation(), node); TypeCheckerErrors.detail("Actual", argType); } return node.getStatement().apply(THIS, question); }