Package org.jruby

Examples of org.jruby.RubyFixnum


        return value;
    }
   
    @JRubyMethod(backtrace = true)
    public IRubyObject at(ThreadContext context, IRubyObject indexObj) {
        RubyFixnum lengthF = getJavaArray().length();
        RubyInteger indexI = indexObj.convertToInteger();
       
        if (indexI.getLongValue() < 0) {
            indexI = RubyFixnum.newFixnum(context.getRuntime(), indexI.getLongValue() + lengthF.getLongValue());
        }
        long index = indexI.getLongValue();
       
        if (index >= 0 && index < lengthF.getLongValue()) {
            return JavaUtil.java_to_ruby(context.getRuntime(), getJavaArray().aref(indexI));
        } else {
            return context.getRuntime().getNil();
        }
    }
View Full Code Here


                return;
            case ClassIndex.FALSE:
                write('F');
                return;
            case ClassIndex.FIXNUM: {
                RubyFixnum fixnum = (RubyFixnum)value;

                if (isMarshalFixnum(fixnum)) {
                    write('i');
                    writeInt((int) fixnum.getLongValue());
                    return;
                }
                // FIXME: inefficient; constructing a bignum just for dumping?
                value = RubyBignum.newBignum(value.getRuntime(), fixnum.getLongValue());

                // fall through
            }
            case ClassIndex.BIGNUM:
                write('l');
View Full Code Here

        if (symbol == null) return symbols[index] = runtime.newSymbol(name);
        return symbol;
    }

    public final RubyFixnum getFixnum(Ruby runtime, int index, int value) {
        RubyFixnum fixnum = fixnums[index];
        if (fixnum == null) return fixnums[index] = RubyFixnum.newFixnum(runtime, value);
        return fixnum;
    }
View Full Code Here

        if (fixnum == null) return fixnums[index] = RubyFixnum.newFixnum(runtime, value);
        return fixnum;
    }

    public final RubyFixnum getFixnum(Ruby runtime, int index, long value) {
        RubyFixnum fixnum = fixnums[index];
        if (fixnum == null) return fixnums[index] = RubyFixnum.newFixnum(runtime, value);
        return fixnum;
    }
View Full Code Here

    public void testExit() throws Exception {
        verifyExit(RubyFixnum.zero(runtime),   "true");
        verifyExit(RubyFixnum.one(runtime),    "false");
        verifyExit(RubyFixnum.one(runtime),    "");
        verifyExit(new RubyFixnum(runtime, 7), "7");
    }
View Full Code Here

    }
   
    public static void benchFixnumFib(int n) {
        long start = System.currentTimeMillis();
        ThreadContext context = ruby.getCurrentContext();
        RubyFixnum result = boxedFib(context, RubyFixnum.newFixnum(ruby, n));
        System.out.println("Took " + (System.currentTimeMillis() - start) + "ms for boxedFib(" + n + ") = " + result);
    }
View Full Code Here

                return;
            case ClassIndex.FALSE:
                write('F');
                return;
            case ClassIndex.FIXNUM: {
                RubyFixnum fixnum = (RubyFixnum)value;

                if (isMarshalFixnum(fixnum)) {
                    write('i');
                    writeInt((int) fixnum.getLongValue());
                    return;
                }
                // FIXME: inefficient; constructing a bignum just for dumping?
                value = RubyBignum.newBignum(value.getRuntime(), fixnum.getLongValue());

                // fall through
            }
            case ClassIndex.BIGNUM:
                write('l');
View Full Code Here

        userCommon(value, null);
    }

    private void userCommon(IRubyObject value, DynamicMethod method) throws IOException {
        registerLinkTarget(value);
        RubyFixnum depthLimitFixnum = runtime.newFixnum(depthLimit);

        IRubyObject dumpResult;
        if (method != null) {
            dumpResult = method.call(runtime.getCurrentContext(), value, value.getMetaClass(), "_dump", depthLimitFixnum);
        } else {
View Full Code Here

   *
   * @see de.yaams.maker.helper.gui.form.FormList#getNewElement()
   */
  @Override
  protected IRubyObject getNewElement() {
    RubyFixnum r = RubyFixnum.one(RGSSProjectHelper.getInterpreter(project).getRuntime());
    return r;
  }
View Full Code Here

   * @param value
   *            = long, int or string
   */
  public static void setNum(Object holder, Object index, Object value) {

    setObj(holder, index, new RubyFixnum(getRunTime(holder, index), Long.valueOf(value.toString())));
  }
View Full Code Here

TOP

Related Classes of org.jruby.RubyFixnum

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.