/** * 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); }
/** * 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); }
@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); } }
/** * 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; }
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));
/** * 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; }
if (node.getPatternBind().getPattern() != null) 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); else if (node.getPatternBind().getBind() instanceof ASeqBind) ASeqBind seqbind = (ASeqBind) node.getPatternBind().getBind(); ValueList seq = seqbind.getSeq().apply(VdmRuntime.getStatementEvaluator(), ctxt).seqValue(ctxt); ATypeBind typebind = (ATypeBind) node.getPatternBind().getBind(); Value converted = exval.convertTo(typebind.getType(), ctxt); Context evalContext = new Context(ctxt.assistantFactory, node.getLocation(), "trap type", ctxt);
@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(); }