1 31 package org.jruby.ast; 32 33 import java.util.List ; 34 import org.jruby.Ruby; 35 import org.jruby.RubyFixnum; 36 37 import org.jruby.ast.types.ILiteralNode; 38 import org.jruby.ast.visitor.NodeVisitor; 39 import org.jruby.evaluator.Instruction; 40 import org.jruby.lexer.yacc.ISourcePosition; 41 42 46 public class FixnumNode extends Node implements ILiteralNode { 47 static final long serialVersionUID = 2236565825959274729L; 48 49 private long value; 50 private RubyFixnum fixnum; 51 52 public FixnumNode(ISourcePosition position, long value) { 53 super(position, NodeTypes.FIXNUMNODE); 54 this.value = value; 55 } 56 57 public Instruction accept(NodeVisitor iVisitor) { 58 return iVisitor.visitFixnumNode(this); 59 } 60 61 65 public long getValue() { 66 return value; 67 } 68 69 public void setValue(long value) { 70 if (fixnum != null) { 72 fixnum = null; 73 } 74 this.value = value; 75 } 76 77 public RubyFixnum getFixnum(Ruby runtime) { 78 if (fixnum == null) { 79 return fixnum = RubyFixnum.newFixnum(runtime, value); 80 } 81 return fixnum; 82 } 83 84 public List childNodes() { 85 return EMPTY_LIST; 86 } 87 88 } 89 | Popular Tags |