/** * Called by the {@link APlusNumericBinaryExp} node from {@link APlusNumericBinaryExp#apply(IAnalysis)}. * @param node the calling {@link APlusNumericBinaryExp} node */ public void caseAPlusNumericBinaryExp(APlusNumericBinaryExp node) throws AnalysisException { _visitedNodes.add(node); inAPlusNumericBinaryExp(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.getOp() != null ) { node.getOp().apply(this); } if(node.getRight() != null && !_visitedNodes.contains(node.getRight())) { node.getRight().apply(this); } outAPlusNumericBinaryExp(node); }
/** * Returns a deep clone of this {@link APlusNumericBinaryExp} node. * @return a deep clone of this {@link APlusNumericBinaryExp} node */ public APlusNumericBinaryExp clone() { return new APlusNumericBinaryExp( _type, _location, cloneNode(_left), cloneNode(_op), cloneNode(_right) ); }
SNumericBasicType ln = question.assistantFactory.createPTypeAssistant().getNumeric(node.getLeft().getType()); SNumericBasicType rn = question.assistantFactory.createPTypeAssistant().getNumeric(node.getRight().getType()); node.setType(ln); return ln; } else if (rn instanceof ARealNumericBasicType) node.setType(rn); return rn; } else if (ln instanceof AIntNumericBasicType) node.setType(ln); return ln; } else if (rn instanceof AIntNumericBasicType) node.setType(rn); return rn; } else if (ln instanceof ANatNumericBasicType && rn instanceof ANatNumericBasicType) node.setType(ln); return ln; } else node.setType(AstFactory.newANatOneNumericBasicType(ln.getLocation())); return node.getType();
@Override public String caseAPlusNumericBinaryExp(APlusNumericBinaryExp node, IndentTracker question) throws AnalysisException { String l = node.getLeft().apply(THIS, question); String r = node.getRight().apply(THIS, question); String op = mytable.getPLUS(); StringBuilder sb = new StringBuilder(); sb.append(l); sb.append(space); sb.append(op); sb.append(space); sb.append(r); return Utilities.wrap(sb.toString()); }
@Override public Value caseAPlusNumericBinaryExp(APlusNumericBinaryExp node, Context ctxt) throws AnalysisException { // breakpoint.check(location, ctxt); node.getLocation().hit(); // Mark as covered try { Value l = node.getLeft().apply(VdmRuntime.getExpressionEvaluator(), ctxt); Value r = node.getRight().apply(VdmRuntime.getExpressionEvaluator(), ctxt); if (NumericValue.areIntegers(l, r)) { long lv = l.intValue(ctxt); long rv = r.intValue(ctxt); long sum = addExact(lv, rv, ctxt); return NumericValue.valueOf(sum, ctxt); } else { double lv = l.realValue(ctxt); double rv = r.realValue(ctxt); return NumericValue.valueOf(lv + rv, ctxt); } } catch (ValueException e) { return VdmRuntimeError.abort(node.getLocation(), e); } }
public static APlusNumericBinaryExp newAPlusNumericBinaryExp(PExp left, LexToken op, PExp right) { APlusNumericBinaryExp result = new APlusNumericBinaryExp(); initExpressionBinary(result, left, op, right); return result; }
public static APlusNumericBinaryExp newAPlusNumericBinaryExp(PExp left, PExp right) { APlusNumericBinaryExp result = new APlusNumericBinaryExp(); ILexToken op = new LexToken(null, VDMToken.PLUS); initExpressionBinary(result, left, op, right); return result; }
/** * Called by the {@link APlusNumericBinaryExp} node from {@link APlusNumericBinaryExp#apply(IAnalysis)}. * @param node the calling {@link APlusNumericBinaryExp} node */ public void caseAPlusNumericBinaryExp(APlusNumericBinaryExp node, Q question) throws AnalysisException { _visitedNodes.add(node); inAPlusNumericBinaryExp(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.getOp() != null ) { node.getOp().apply(this, question); } if(node.getRight() != null && !_visitedNodes.contains(node.getRight())) { node.getRight().apply(this, question); } outAPlusNumericBinaryExp(node, question); }
/** * Creates a deep clone of this {@link APlusNumericBinaryExp} 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 APlusNumericBinaryExp} node */ public APlusNumericBinaryExp clone(Map<INode,INode> oldToNewMap) { APlusNumericBinaryExp node = new APlusNumericBinaryExp( _type, _location, cloneNode(_left, oldToNewMap), cloneNode(_op, oldToNewMap), cloneNode(_right, oldToNewMap) ); oldToNewMap.put(this, node); return node; }
/** * Called by the {@link APlusNumericBinaryExp} node from {@link APlusNumericBinaryExp#apply(IPOFAnalysis)}. * @param node the calling {@link APlusNumericBinaryExp} node */ public void caseAPlusNumericBinaryExp(APlusNumericBinaryExp node) throws AnalysisException { _visitedNodes.add(node); inAPlusNumericBinaryExp(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.getOp() != null ) { node.getOp().apply(this); } if(node.getRight() != null && !_visitedNodes.contains(node.getRight())) { node.getRight().apply(this); } outAPlusNumericBinaryExp(node); }
/** * Called by the {@link APlusNumericBinaryExp} node from {@link APlusNumericBinaryExp#apply(IAnalysis)}. * @param node the calling {@link APlusNumericBinaryExp} node */ public A caseAPlusNumericBinaryExp(APlusNumericBinaryExp node) throws AnalysisException { _visitedNodes.add(node); A retVal = createNewReturnValue(node); mergeReturns(retVal,inAPlusNumericBinaryExp(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.getOp() != null ) { mergeReturns(retVal,node.getOp().apply(this)); } if(node.getRight() != null && !_visitedNodes.contains(node.getRight())) { mergeReturns(retVal,node.getRight().apply(this)); } mergeReturns(retVal,outAPlusNumericBinaryExp(node)); return retVal; }
/** * Called by the {@link APlusNumericBinaryExp} node from {@link APlusNumericBinaryExp#apply(IAnalysis)}. * @param node the calling {@link APlusNumericBinaryExp} node */ public A caseAPlusNumericBinaryExp(APlusNumericBinaryExp node, Q question) throws AnalysisException { _visitedNodes.add(node); A retVal = createNewReturnValue(node, question); mergeReturns(retVal,inAPlusNumericBinaryExp(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.getOp() != null ) { mergeReturns(retVal,node.getOp().apply(this, question)); } if(node.getRight() != null && !_visitedNodes.contains(node.getRight())) { mergeReturns(retVal,node.getRight().apply(this, question)); } mergeReturns(retVal,outAPlusNumericBinaryExp(node, question)); return retVal; }