Skip to content

Commit

Permalink
Showing 2 changed files with 42 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved. This
* code is released under a tri EPL/GPL/LGPL license. You can use it,
* redistribute it and/or modify it under the terms of the:
*
* Eclipse Public License version 1.0
* GNU General Public License version 2
* GNU Lesser General Public License version 2.1
*/
package org.jruby.truffle.nodes.literal;

import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.runtime.RubyContext;

import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.NodeCost;
import com.oracle.truffle.api.nodes.NodeInfo;
import com.oracle.truffle.api.source.SourceSection;

@NodeInfo(cost = NodeCost.NONE)
public class FloatLiteralNode extends RubyNode {

private final double value;

public FloatLiteralNode(RubyContext context, SourceSection sourceSection, double value) {
super(context, sourceSection);
this.value = value;
}

@Override
public double executeDouble(VirtualFrame frame) {
return value;
}

@Override
public Object execute(VirtualFrame frame) {
return executeDouble(frame);
}

}
Original file line number Diff line number Diff line change
@@ -34,16 +34,7 @@
import org.jruby.truffle.nodes.constants.ReadConstantWithLexicalScopeNode;
import org.jruby.truffle.nodes.constants.ReadLiteralConstantNode;
import org.jruby.truffle.nodes.constants.WriteConstantNode;
import org.jruby.truffle.nodes.control.AndNode;
import org.jruby.truffle.nodes.control.BreakNode;
import org.jruby.truffle.nodes.control.*;
import org.jruby.truffle.nodes.control.IfNode;
import org.jruby.truffle.nodes.control.NextNode;
import org.jruby.truffle.nodes.control.OrNode;
import org.jruby.truffle.nodes.control.RedoNode;
import org.jruby.truffle.nodes.control.RetryNode;
import org.jruby.truffle.nodes.control.ReturnNode;
import org.jruby.truffle.nodes.control.WhileNode;
import org.jruby.truffle.nodes.core.*;
import org.jruby.truffle.nodes.core.ModuleNodesFactory.AliasMethodNodeFactory;
import org.jruby.truffle.nodes.core.ModuleNodesFactory.UndefMethodNodeFactory;
@@ -58,17 +49,15 @@
import org.jruby.truffle.nodes.defined.DefinedNode;
import org.jruby.truffle.nodes.defined.DefinedWrapperNode;
import org.jruby.truffle.nodes.dispatch.RubyCallNode;
import org.jruby.truffle.nodes.exceptions.EnsureNode;
import org.jruby.truffle.nodes.exceptions.*;
import org.jruby.truffle.nodes.exceptions.RescueNode;
import org.jruby.truffle.nodes.globals.*;
import org.jruby.truffle.nodes.literal.BooleanLiteralNode;
import org.jruby.truffle.nodes.literal.FloatLiteralNode;
import org.jruby.truffle.nodes.literal.LiteralNode;
import org.jruby.truffle.nodes.literal.StringLiteralNode;
import org.jruby.truffle.nodes.locals.*;
import org.jruby.truffle.nodes.methods.*;
import org.jruby.truffle.nodes.objects.*;
import org.jruby.truffle.nodes.objects.SelfNode;
import org.jruby.truffle.nodes.rubinius.RubiniusLastStringReadNode;
import org.jruby.truffle.nodes.rubinius.RubiniusPrimitiveConstructor;
import org.jruby.truffle.nodes.rubinius.RubiniusSingleBlockArgNode;
@@ -1250,7 +1239,7 @@ protected FlipFlopStateNode createFlipFlopState(SourceSection sourceSection, int

@Override
public RubyNode visitFloatNode(org.jruby.ast.FloatNode node) {
final RubyNode ret = new LiteralNode(context, translate(node.getPosition()), node.getValue());
final RubyNode ret = new FloatLiteralNode(context, translate(node.getPosition()), node.getValue());
return addNewlineIfNeeded(node, ret);
}

0 comments on commit db93d9e

Please sign in to comment.