public static ARealLiteralExp newARealLiteralExp(LexRealToken value) { ARealLiteralExp result = new ARealLiteralExp(); initExpression(result, value.location); result.setValue(value); return result; }
/** * Returns a deep clone of this {@link ARealLiteralExp} node. * @return a deep clone of this {@link ARealLiteralExp} node */ public ARealLiteralExp clone() { return new ARealLiteralExp( _type, _location, cloneNode(_value) ); }
/** * Called by the {@link ARealLiteralExp} node from {@link ARealLiteralExp#apply(IAnalysis)}. * @param node the calling {@link ARealLiteralExp} node */ public void caseARealLiteralExp(ARealLiteralExp node) throws AnalysisException { _visitedNodes.add(node); inARealLiteralExp(node); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { node.getType().apply(this); } if(node.getValue() != null ) { node.getValue().apply(this); } outARealLiteralExp(node); }
@Override public PType caseARealLiteralExp(ARealLiteralExp node, TypeCheckInfo question) { ILexRealToken value = node.getValue(); if (Math.round(value.getValue()) == value.getValue()) { if (value.getValue() < 0) { node.setType(AstFactory.newAIntNumericBasicType(node.getLocation())); } else if (value.getValue() == 0) { node.setType(AstFactory.newANatNumericBasicType(node.getLocation())); } else { node.setType(AstFactory.newANatOneNumericBasicType(node.getLocation())); } } else { node.setType(AstFactory.newARationalNumericBasicType(node.getLocation())); } return question.assistantFactory.createPTypeAssistant().checkConstraint(question.constraint, node.getType(), node.getLocation()); }
@Override public Value caseARealLiteralExp(ARealLiteralExp node, Context ctxt) throws AnalysisException { BreakpointManager.getBreakpoint(node).check(node.getLocation(), ctxt); try { return NumericValue.valueOf(node.getValue().getValue(), ctxt); } catch (ValueException e) { return VdmRuntimeError.abort(node.getLocation(), e); } }
@Override public String caseARealLiteralExp(ARealLiteralExp node, IndentTracker question) throws AnalysisException { return Double.toString(node.getValue().getValue()); }
/** * Creates a new tree field only constructor {@code ARealLiteralExp TAG=realLiteral} node with the given nodes as children. * @deprecated This method should not be used, use AstFactory instead. * The basic child nodes are removed from their previous parents. * @param value_ the {@link ILexRealToken} node for the {@code value} child of this {@link ARealLiteralExp} node */ public ARealLiteralExp(ILexLocation location_, ILexRealToken value_) { super(null,location_); this.setValue(value_); }
/** * Called by the {@link ARealLiteralExp} node from {@link ARealLiteralExp#apply(IPOFAnalysis)}. * @param node the calling {@link ARealLiteralExp} node */ public void caseARealLiteralExp(ARealLiteralExp node) throws AnalysisException { _visitedNodes.add(node); inARealLiteralExp(node); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { node.getType().apply(this); } if(node.getValue() != null ) { node.getValue().apply(this); } outARealLiteralExp(node); }
private boolean neverZero(PExp exp) { if (exp instanceof AIntLiteralExp) { AIntLiteralExp il_Exp = (AIntLiteralExp) exp; if (il_Exp.getValue().getValue() != 0) { return true; } } if (exp instanceof ARealLiteralExp) { ARealLiteralExp rl_Exp = (ARealLiteralExp) exp; if (rl_Exp.getValue().getValue() != 0) { return true; } } return false; }
/** * Creates a new complete constructor {@code ARealLiteralExp} node with the given nodes as children. * @deprecated This method should not be used, use AstFactory instead. * The basic child nodes are removed from their previous parents. * @param value_ the {@link ILexRealToken} node for the {@code value} child of this {@link ARealLiteralExp} node */ public ARealLiteralExp(PType type_, ILexLocation location_, ILexRealToken value_) { super(type_,location_); this.setValue(value_); }
/** * Called by the {@link ARealLiteralExp} node from {@link ARealLiteralExp#apply(IAnalysis)}. * @param node the calling {@link ARealLiteralExp} node */ public void caseARealLiteralExp(ARealLiteralExp node, Q question) throws AnalysisException { _visitedNodes.add(node); inARealLiteralExp(node, question); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { node.getType().apply(this, question); } if(node.getValue() != null ) { node.getValue().apply(this, question); } outARealLiteralExp(node, question); }
speed = frequencyExp.getValue().getValue();
public PExp caseARealPattern(ARealPattern node) throws AnalysisException { ARealLiteralExp exp = new ARealLiteralExp(); exp.setValue(node.getValue().clone()); addPossibleType(exp, node); return exp; }
/** * Creates a deep clone of this {@link ARealLiteralExp} 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 ARealLiteralExp} node */ public ARealLiteralExp clone(Map<INode,INode> oldToNewMap) { ARealLiteralExp node = new ARealLiteralExp( _type, _location, cloneNode(_value, oldToNewMap) ); oldToNewMap.put(this, node); return node; }
/** * Called by the {@link ARealLiteralExp} node from {@link ARealLiteralExp#apply(IAnalysis)}. * @param node the calling {@link ARealLiteralExp} node */ public A caseARealLiteralExp(ARealLiteralExp node, Q question) throws AnalysisException { _visitedNodes.add(node); A retVal = createNewReturnValue(node, question); mergeReturns(retVal,inARealLiteralExp(node, question)); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { mergeReturns(retVal,node.getType().apply(this, question)); } if(node.getValue() != null ) { mergeReturns(retVal,node.getValue().apply(this, question)); } mergeReturns(retVal,outARealLiteralExp(node, question)); return retVal; }
/** * Called by the {@link ARealLiteralExp} node from {@link ARealLiteralExp#apply(IAnalysis)}. * @param node the calling {@link ARealLiteralExp} node */ public A caseARealLiteralExp(ARealLiteralExp node) throws AnalysisException { _visitedNodes.add(node); A retVal = createNewReturnValue(node); mergeReturns(retVal,inARealLiteralExp(node)); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { mergeReturns(retVal,node.getType().apply(this)); } if(node.getValue() != null ) { mergeReturns(retVal,node.getValue().apply(this)); } mergeReturns(retVal,outARealLiteralExp(node)); return retVal; }
@Override public SExpIR caseARealLiteralExp(ARealLiteralExp node, IRInfo question) throws AnalysisException { PType type = node.getType(); double value = node.getValue().getValue(); STypeIR typeCg = type.apply(question.getTypeVisitor(), question); ARealLiteralExpIR realLitCg = new ARealLiteralExpIR(); realLitCg.setType(typeCg); realLitCg.setValue(value); return realLitCg; }