/** * Called by the {@link ATrapStm} node from {@link ATrapStm#apply(IAnalysis)}. * @param node the calling {@link ATrapStm} node */ public void caseATrapStm(ATrapStm node) throws AnalysisException { _visitedNodes.add(node); inATrapStm(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.getWith() != null && !_visitedNodes.contains(node.getWith())) { node.getWith().apply(this); } if(node.getBody() != null && !_visitedNodes.contains(node.getBody())) { node.getBody().apply(this); } outATrapStm(node); }
public static ATrapStm newATrapStm(ILexLocation token, ADefPatternBind patternBind, PStm with, PStm body) { ATrapStm result = new ATrapStm(); initStatement(result, token); result.setPatternBind(patternBind); result.setWith(with); result.setBody(body); return result; }
@Override public PExp caseATrapStm(ATrapStm stm, Integer lineno) throws AnalysisException { PExp found = stm.getBody().apply(THIS, lineno);// PStmAssistantInterpreter.findExpression(stm.getBody(), // lineno); if (found != null) { return found; } return stm.getWith().apply(THIS, lineno);// PStmAssistantInterpreter.findExpression(stm.getWith(), lineno); }
@Override public PType caseATrapStm(ATrapStm node, TypeCheckInfo question) throws AnalysisException { PTypeSet rtypes = new PTypeSet(question.assistantFactory); PStm body = node.getBody(); PType bt = body.apply(THIS, question); rtypes.add(bt); PTypeSet extype = exitCheck(body, question); PType ptype = null; if (extype.isEmpty()) { TypeCheckerErrors.report(3241, "Body of trap statement does not throw exceptions", node.getLocation(), node); ptype = AstFactory.newAUnknownType(body.getLocation()); } else { ptype = extype.getType(body.getLocation()); } node.setType(ptype); node.getPatternBind().apply(THIS, question); // TODO: PatternBind stuff List<PDefinition> defs = getDefinitions(node.getPatternBind()); question.assistantFactory.createPDefinitionListAssistant().typeCheck(defs, THIS, question); Environment local = new FlatCheckedEnvironment(question.assistantFactory, defs, question.env, question.scope); rtypes.add(node.getWith().apply(THIS, new TypeCheckInfo(question.assistantFactory, local, question.scope, question.qualifiers))); node.setType(rtypes.getType(node.getLocation())); return node.getType(); }
@Override public void caseATrapStm(ATrapStm node) throws AnalysisException { if (!proceed(node)) { return; } if (node.getBody() != null) { node.getBody().apply(this); } openScope(node.getPatternBind().getPattern(), node.getPatternBind().getDefs(), node.getWith()); if (node.getWith() != null) { node.getWith().apply(this); } for (PDefinition def : node.getPatternBind().getDefs()) { removeLocalDefFromScope(def); } }
BreakpointManager.getBreakpoint(node).check(node.getLocation(), ctxt); Value rv = null; rv = node.getBody().apply(VdmRuntime.getStatementEvaluator(), ctxt); } catch (ExitException e) if (node.getPatternBind().getPattern() != null) Context evalContext = new Context(ctxt.assistantFactory, node.getLocation(), "trap pattern", ctxt); evalContext.putList(ctxt.assistantFactory.createPPatternAssistant().getNamedValues(node.getPatternBind().getPattern(), exval, ctxt)); rv = node.getWith().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); Context evalContext = new Context(ctxt.assistantFactory, node.getLocation(), "trap set", ctxt); evalContext.putList(ctxt.assistantFactory.createPPatternAssistant().getNamedValues(setbind.getPattern(), exval, ctxt)); rv = node.getWith().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); Context evalContext = new Context(ctxt.assistantFactory, node.getLocation(), "trap seq", ctxt); evalContext.putList(ctxt.assistantFactory.createPPatternAssistant().getNamedValues(seqbind.getPattern(), exval, ctxt)); rv = node.getWith().apply(VdmRuntime.getStatementEvaluator(), evalContext);
@Override public LexNameSet caseATrapStm(ATrapStm node, FreeVarInfo info) throws AnalysisException { return node.getBody().apply(this, info); }
} else if ((parent = node.getAncestor(ATrapStm.class)) != null) type = ((ATrapStm) parent).getType(); } else if ((parent = node.getAncestor(ATixeStmtAlternative.class)) != null)
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)); list.add(new SetMembershipObligation(bind.getPattern(), bind.getSet(), question, aF)); else if (node.getPatternBind().getBind() instanceof ASeqBind) ASeqBind bind = (ASeqBind) node.getPatternBind().getBind(); list.addAll(bind.getSeq().apply(rootVisitor, question)); list.add(new SeqMembershipObligation(bind.getPattern(), bind.getSeq(), question, aF)); list.addAll(node.getWith().apply(rootVisitor, question)); list.addAll(node.getBody().apply(rootVisitor, question)); return list; } catch (Exception e)
@Override public PStm caseATrapStm(ATrapStm stm, Integer lineno) throws AnalysisException { PStm found = findStatementBaseCase(stm, lineno); if (found != null) { return found; } found = stm.getBody().apply(THIS, lineno);// PStmAssistantInterpreter.findStatement(stm.getBody(), lineno); if (found != null) { return found; } return stm.getWith().apply(THIS, lineno);// PStmAssistantInterpreter.findStatement(stm.getWith(), lineno); }
/** * Creates a deep clone of this {@link ATrapStm} node while putting all * old node-new node relations in the map {@code oldToNewMap}. * @param oldToNewMap the map filled with the old node-new node relation * @return a deep clone of this {@link ATrapStm} node */ public ATrapStm clone(Map<INode,INode> oldToNewMap) { ATrapStm node = new ATrapStm( _location, _type, cloneNode(_patternBind, oldToNewMap), cloneNode(_with, oldToNewMap), cloneNode(_body, oldToNewMap) ); oldToNewMap.put(this, node); return node; }
/** * Called by the {@link ATrapStm} node from {@link ATrapStm#apply(IAnalysis)}. * @param node the calling {@link ATrapStm} node */ public void caseATrapStm(ATrapStm node, Q question) throws AnalysisException { _visitedNodes.add(node); inATrapStm(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.getWith() != null && !_visitedNodes.contains(node.getWith())) { node.getWith().apply(this, question); } if(node.getBody() != null && !_visitedNodes.contains(node.getBody())) { node.getBody().apply(this, question); } outATrapStm(node, question); }
/** * Called by the {@link ATrapStm} node from {@link ATrapStm#apply(IPOFAnalysis)}. * @param node the calling {@link ATrapStm} node */ public void caseATrapStm(ATrapStm node) throws AnalysisException { _visitedNodes.add(node); inATrapStm(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.getWith() != null && !_visitedNodes.contains(node.getWith())) { node.getWith().apply(this); } if(node.getBody() != null && !_visitedNodes.contains(node.getBody())) { node.getBody().apply(this); } outATrapStm(node); }
/** * Called by the {@link ATrapStm} node from {@link ATrapStm#apply(IAnalysis)}. * @param node the calling {@link ATrapStm} node */ public A caseATrapStm(ATrapStm node, Q question) throws AnalysisException { _visitedNodes.add(node); A retVal = createNewReturnValue(node, question); mergeReturns(retVal,inATrapStm(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.getWith() != null && !_visitedNodes.contains(node.getWith())) { mergeReturns(retVal,node.getWith().apply(this, question)); } if(node.getBody() != null && !_visitedNodes.contains(node.getBody())) { mergeReturns(retVal,node.getBody().apply(this, question)); } mergeReturns(retVal,outATrapStm(node, question)); return retVal; }
/** * Called by the {@link ATrapStm} node from {@link ATrapStm#apply(IAnalysis)}. * @param node the calling {@link ATrapStm} node */ public A caseATrapStm(ATrapStm node) throws AnalysisException { _visitedNodes.add(node); A retVal = createNewReturnValue(node); mergeReturns(retVal,inATrapStm(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.getWith() != null && !_visitedNodes.contains(node.getWith())) { mergeReturns(retVal,node.getWith().apply(this)); } if(node.getBody() != null && !_visitedNodes.contains(node.getBody())) { mergeReturns(retVal,node.getBody().apply(this)); } mergeReturns(retVal,outATrapStm(node)); return retVal; }