/** * Returns a deep clone of this {@link ARealLiteralExpIR} node. * @return a deep clone of this {@link ARealLiteralExpIR} node */ public ARealLiteralExpIR clone() { return new ARealLiteralExpIR( _sourceNode, _tag, _metaData, cloneNode(_type), _value ); }
/** * Creates a deep clone of this {@link ARealLiteralExpIR} 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 ARealLiteralExpIR} node */ public ARealLiteralExpIR clone(Map<INode,INode> oldToNewMap) { ARealLiteralExpIR node = new ARealLiteralExpIR( _sourceNode, _tag, _metaData, cloneNode(_type, oldToNewMap), _value ); oldToNewMap.put(this, node); return node; }
public ARealLiteralExpIR consRealLiteral(double value) { ARealLiteralExpIR realLiteral = new ARealLiteralExpIR(); realLiteral.setType(new ARealNumericBasicTypeIR()); realLiteral.setValue(value); return realLiteral; }
@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; }
@Override public void caseADivideNumericBinaryExpIR(ADivideNumericBinaryExpIR node) throws AnalysisException { SExpIR leftExp = node.getLeft(); leftExp.apply(this); SExpIR rightExp = node.getRight(); rightExp.apply(this); if (info.getExpAssistant().isIntegerType(leftExp) && info.getExpAssistant().isIntegerType(rightExp)) { ARealLiteralExpIR one = new ARealLiteralExpIR(); ARealNumericBasicTypeIR realTypeCg = new ARealNumericBasicTypeIR(); realTypeCg.setSourceNode(new SourceNode(new ARealNumericBasicType())); one.setType(realTypeCg); one.setValue(1.0); ATimesNumericBinaryExpIR neutralMul = new ATimesNumericBinaryExpIR(); neutralMul.setType(realTypeCg.clone()); neutralMul.setLeft(one); neutralMul.setRight(leftExp); node.setLeft(info.getExpAssistant().isolateExpression(neutralMul)); } } }