/** * Called by the {@link ASameClassExp} node from {@link ASameClassExp#apply(IAnalysis)}. * @param node the calling {@link ASameClassExp} node */ public void caseASameClassExp(ASameClassExp node) throws AnalysisException { _visitedNodes.add(node); inASameClassExp(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); } outASameClassExp(node); }
public static ASameClassExp newASameClassExp(ILexLocation start, List<PExp> args) { ASameClassExp result = new ASameClassExp(); initExpression(result, start); result.setLeft(args.get(0)); result.setRight(args.get(1)); return result; }
/** * Returns a deep clone of this {@link ASameClassExp} node. * @return a deep clone of this {@link ASameClassExp} node */ public ASameClassExp clone() { return new ASameClassExp( _type, _location, cloneNode(_left), cloneNode(_right) ); }
@Override public PType caseASameClassExp(ASameClassExp 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 caseASameClassExp(ASameClassExp 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); return new BooleanValue(lv.type.equals(rv.type)); } catch (ValueException e) { return VdmRuntimeError.abort(node.getLocation(), e); } }
/** * Called by the {@link ASameClassExp} node from {@link ASameClassExp#apply(IAnalysis)}. * @param node the calling {@link ASameClassExp} node */ public void caseASameClassExp(ASameClassExp node, Q question) throws AnalysisException { _visitedNodes.add(node); inASameClassExp(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); } outASameClassExp(node, question); }
@Override public PExp caseASameClassExp(ASameClassExp 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; }
/** * Creates a deep clone of this {@link ASameClassExp} 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 ASameClassExp} node */ public ASameClassExp clone(Map<INode,INode> oldToNewMap) { ASameClassExp node = new ASameClassExp( _type, _location, cloneNode(_left, oldToNewMap), cloneNode(_right, oldToNewMap) ); oldToNewMap.put(this, node); return node; }
/** * Called by the {@link ASameClassExp} node from {@link ASameClassExp#apply(IPOFAnalysis)}. * @param node the calling {@link ASameClassExp} node */ public void caseASameClassExp(ASameClassExp node) throws AnalysisException { _visitedNodes.add(node); inASameClassExp(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); } outASameClassExp(node); }
/** * Called by the {@link ASameClassExp} node from {@link ASameClassExp#apply(IAnalysis)}. * @param node the calling {@link ASameClassExp} node */ public A caseASameClassExp(ASameClassExp node) throws AnalysisException { _visitedNodes.add(node); A retVal = createNewReturnValue(node); mergeReturns(retVal,inASameClassExp(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,outASameClassExp(node)); return retVal; }
@Override public SExpIR caseASameClassExp(ASameClassExp 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); ASameClassExpIR sameBaseClassExp = new ASameClassExpIR(); sameBaseClassExp.setLeft(leftCg); sameBaseClassExp.setRight(rightCg); return sameBaseClassExp; } }
/** * Called by the {@link ASameClassExp} node from {@link ASameClassExp#apply(IAnalysis)}. * @param node the calling {@link ASameClassExp} node */ public A caseASameClassExp(ASameClassExp node, Q question) throws AnalysisException { _visitedNodes.add(node); A retVal = createNewReturnValue(node, question); mergeReturns(retVal,inASameClassExp(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,outASameClassExp(node, question)); return retVal; }