/** * Called by the {@link ASameBaseClassExp} node from {@link ASameBaseClassExp#apply(IAnalysis)}. * @param node the calling {@link ASameBaseClassExp} node */ public void caseASameBaseClassExp(ASameBaseClassExp node, Q question) throws AnalysisException { _visitedNodes.add(node); inASameBaseClassExp(node, question); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { node.getType().apply(this, question); } if(node.getLeft() != null && !_visitedNodes.contains(node.getLeft())) { node.getLeft().apply(this, question); } if(node.getRight() != null && !_visitedNodes.contains(node.getRight())) { node.getRight().apply(this, question); } outASameBaseClassExp(node, question); }
public static ASameBaseClassExp newASameBaseClassExp(ILexLocation start, List<PExp> args) { ASameBaseClassExp result = new ASameBaseClassExp(); initExpression(result, start); result.setLeft(args.get(0)); result.setRight(args.get(1)); return result; }
/** * Returns a deep clone of this {@link ASameBaseClassExp} node. * @return a deep clone of this {@link ASameBaseClassExp} node */ public ASameBaseClassExp clone() { return new ASameBaseClassExp( _type, _location, cloneNode(_left), cloneNode(_right) ); }
@Override public PType caseASameBaseClassExp(ASameBaseClassExp node, TypeCheckInfo question) throws AnalysisException { PExp left = node.getLeft(); PExp right = node.getRight(); question.qualifiers = null; PType lt = left.apply(THIS, question.newConstraint(null)); if (!question.assistantFactory.createPTypeAssistant().isClass(lt, question.env)) { TypeCheckerErrors.report(3266, "Argument is not an object", left.getLocation(), left); } question.qualifiers = null; PType rt = right.apply(THIS, question.newConstraint(null)); if (!question.assistantFactory.createPTypeAssistant().isClass(rt, question.env)) { TypeCheckerErrors.report(3266, "Argument is not an object", right.getLocation(), right); } node.setType(AstFactory.newABooleanBasicType(node.getLocation())); return question.assistantFactory.createPTypeAssistant().checkConstraint(question.constraint, node.getType(), node.getLocation()); }
@Override public Value caseASameBaseClassExp(ASameBaseClassExp node, Context ctxt) throws AnalysisException { BreakpointManager.getBreakpoint(node).check(node.getLocation(), ctxt); try { Value l = node.getLeft().apply(VdmRuntime.getExpressionEvaluator(), ctxt); Value r = node.getRight().apply(VdmRuntime.getExpressionEvaluator(), ctxt); if (!l.isType(ObjectValue.class) || !r.isType(ObjectValue.class)) { return new BooleanValue(false); } ObjectValue lv = l.objectValue(ctxt); ObjectValue rv = r.objectValue(ctxt); PTypeList lbases = lv.getBaseTypes(); PTypeList rbases = rv.getBaseTypes(); for (PType ltype : lbases) { if (rbases.contains(ltype)) { return new BooleanValue(true); } } return new BooleanValue(false); } catch (ValueException e) { return VdmRuntimeError.abort(node.getLocation(), e); } }
@Override public PExp caseASameBaseClassExp(ASameBaseClassExp exp, Integer lineno) throws AnalysisException { PExp found = findExpressionBaseCase(exp, lineno); if (found != null) { return found; } found = exp.getLeft().apply(THIS, lineno); if (found != null) { return found; } found = exp.getRight().apply(THIS, lineno); if (found != null) { return found; } return null; }
/** * Called by the {@link ASameBaseClassExp} node from {@link ASameBaseClassExp#apply(IAnalysis)}. * @param node the calling {@link ASameBaseClassExp} node */ public void caseASameBaseClassExp(ASameBaseClassExp node) throws AnalysisException { _visitedNodes.add(node); inASameBaseClassExp(node); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { node.getType().apply(this); } if(node.getLeft() != null && !_visitedNodes.contains(node.getLeft())) { node.getLeft().apply(this); } if(node.getRight() != null && !_visitedNodes.contains(node.getRight())) { node.getRight().apply(this); } outASameBaseClassExp(node); }
@Override public IProofObligationList caseASameBaseClassExp(ASameBaseClassExp node, IPOContextStack question) throws AnalysisException { IProofObligationList obligations = new ProofObligationList(); obligations.addAll(node.getLeft().apply(mainVisitor, question)); obligations.addAll(node.getRight().apply(mainVisitor, question)); return obligations; }
/** * Creates a deep clone of this {@link ASameBaseClassExp} 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 ASameBaseClassExp} node */ public ASameBaseClassExp clone(Map<INode,INode> oldToNewMap) { ASameBaseClassExp node = new ASameBaseClassExp( _type, _location, cloneNode(_left, oldToNewMap), cloneNode(_right, oldToNewMap) ); oldToNewMap.put(this, node); return node; }
/** * Called by the {@link ASameBaseClassExp} node from {@link ASameBaseClassExp#apply(IPOFAnalysis)}. * @param node the calling {@link ASameBaseClassExp} node */ public void caseASameBaseClassExp(ASameBaseClassExp node) throws AnalysisException { _visitedNodes.add(node); inASameBaseClassExp(node); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { node.getType().apply(this); } if(node.getLeft() != null && !_visitedNodes.contains(node.getLeft())) { node.getLeft().apply(this); } if(node.getRight() != null && !_visitedNodes.contains(node.getRight())) { node.getRight().apply(this); } outASameBaseClassExp(node); }
/** * Called by the {@link ASameBaseClassExp} node from {@link ASameBaseClassExp#apply(IAnalysis)}. * @param node the calling {@link ASameBaseClassExp} node */ public A caseASameBaseClassExp(ASameBaseClassExp node) throws AnalysisException { _visitedNodes.add(node); A retVal = createNewReturnValue(node); mergeReturns(retVal,inASameBaseClassExp(node)); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { mergeReturns(retVal,node.getType().apply(this)); } if(node.getLeft() != null && !_visitedNodes.contains(node.getLeft())) { mergeReturns(retVal,node.getLeft().apply(this)); } if(node.getRight() != null && !_visitedNodes.contains(node.getRight())) { mergeReturns(retVal,node.getRight().apply(this)); } mergeReturns(retVal,outASameBaseClassExp(node)); return retVal; }
@Override public SExpIR caseASameBaseClassExp(ASameBaseClassExp node, IRInfo question) throws AnalysisException { PExp left = node.getLeft(); PExp right = node.getRight(); SExpIR leftCg = left.apply(question.getExpVisitor(), question); SExpIR rightCg = right.apply(question.getExpVisitor(), question); ASameBaseClassExpIR sameBaseClassExp = new ASameBaseClassExpIR(); sameBaseClassExp.setLeft(leftCg); sameBaseClassExp.setRight(rightCg); return sameBaseClassExp; }
/** * Called by the {@link ASameBaseClassExp} node from {@link ASameBaseClassExp#apply(IAnalysis)}. * @param node the calling {@link ASameBaseClassExp} node */ public A caseASameBaseClassExp(ASameBaseClassExp node, Q question) throws AnalysisException { _visitedNodes.add(node); A retVal = createNewReturnValue(node, question); mergeReturns(retVal,inASameBaseClassExp(node, question)); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { mergeReturns(retVal,node.getType().apply(this, question)); } if(node.getLeft() != null && !_visitedNodes.contains(node.getLeft())) { mergeReturns(retVal,node.getLeft().apply(this, question)); } if(node.getRight() != null && !_visitedNodes.contains(node.getRight())) { mergeReturns(retVal,node.getRight().apply(this, question)); } mergeReturns(retVal,outASameBaseClassExp(node, question)); return retVal; }