Package org.jruby

Examples of org.jruby.RubyString$TR


            // skip this one, probably no 'ls' (windows)
        }
    }
    public void testUsesRubyEnvPathToRunShellPrograms() {
        RubyHash env = (RubyHash) runtime.getObject().fastGetConstant("ENV");
        RubyString path = runtime.newString("PATH");
        RubyString utilPath = runtime.newString(System.getProperty("jruby.home") + "/test/org/jruby/util");
        ThreadContext context = runtime.getCurrentContext();
        env.op_aset(context, path,
                env.op_aref(context, path).convertToString()
                .op_plus(context, runtime.newString(File.pathSeparator)).convertToString()
                .op_plus(context, utilPath));
View Full Code Here


        runtime = Ruby.newInstance();
        target = new ObjectSpace();
    }

    public void testIdentities() {
        RubyString o1 = runtime.newString("hey");
        RubyString o2 = runtime.newString("ho");

        long id1 = target.createAndRegisterObjectId(o1);
        long id2 = target.createAndRegisterObjectId(o2);

        assertEquals("id of normal objects must be even", 0, id1 % 2);
View Full Code Here

    /**
     * JRUBY-5646: RubyString.newUnicodeString in 1.9 mode produces ASCII-8BIT
     */
    public void testNewUnicodeString() throws Exception {
        RubyString str = RubyString.newUnicodeString(runtime, "hello");
        assertEquals(UTF8Encoding.INSTANCE, str.getByteList().getEncoding());
    }
View Full Code Here

   
    @Override
    public IRubyObject interpret(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
        if (getOnce() && onceRegexp != null) return onceRegexp;

        RubyString string = (RubyString) super.interpret(runtime, context, self, aBlock);
        RubyRegexp regexp = RubyRegexp.newDRegexp(runtime, string, options);
       
        if (getOnce() && onceRegexp == null) onceRegexp = regexp;

        return regexp;
View Full Code Here

        return new BacktickString(newPieces);
    }

    @Override
    public Object retrieve(InterpreterContext interp) {
        RubyString newString = interp.getRuntime().newString();

        for (Operand p: pieces) {
            newString.append((IRubyObject) p.retrieve(interp));
        }
       
        return ((IRubyObject) interp.getSelf()).callMethod(interp.getContext(), "`", newString);
    }
View Full Code Here

        byte[] bytes = getZeroTerminatedByteArray(address);
        if (bytes.length == 0) {
            return RubyString.newEmptyString(runtime);
        }

        RubyString s = RubyString.newStringNoCopy(runtime, bytes);
        s.setTaint(true);
        return s;
    }
View Full Code Here

        evalScope.getStaticScope().determineModule();

        Frame lastFrame = context.preEvalWithBinding(binding);
        try {
            // Binding provided for scope, use it
            RubyString source = src.convertToString();
            Node node = runtime.parseEval(source.getByteList(), binding.getFile(), evalScope, binding.getLine());

            return INTERPRET_EVAL(runtime, context, binding.getFile(), binding.getLine(), node, binding.getMethod(), self, binding.getFrame().getBlock());
        } catch (JumpException.BreakJump bj) {
            throw runtime.newLocalJumpError(RubyLocalJumpError.Reason.BREAK, (IRubyObject)bj.getValue(), "unexpected break");
        } catch (JumpException.RedoJump rj) {
View Full Code Here

        Ruby runtime = src.getRuntime();
        String savedFile = context.getFile();
        int savedLine = context.getLine();

        // no binding, just eval in "current" frame (caller's frame)
        RubyString source = src.convertToString();
       
        DynamicScope evalScope = context.getCurrentScope().getEvalScope();
        evalScope.getStaticScope().determineModule();
       
        try {
            Node node = runtime.parseEval(source.getByteList(), file, evalScope, lineNumber);

            return INTERPRET_EVAL(runtime, context, file, lineNumber, node, "(eval)", self, Block.NULL_BLOCK);
        } catch (JumpException.BreakJump bj) {
            throw runtime.newLocalJumpError(RubyLocalJumpError.Reason.BREAK, (IRubyObject)bj.getValue(), "unexpected break");
        } catch (StackOverflowError soe) {
View Full Code Here

   
    private static void addRubyKeyValuePair(Ruby runtime, Map map, String key, String value, Encoding encoding) {
        ByteList keyBytes = new ByteList(key.getBytes(), encoding);
        ByteList valueBytes = new ByteList(value.getBytes(), encoding);
       
        RubyString keyString = runtime.newString(keyBytes);
        RubyString valueString = runtime.newString(valueBytes);
       
        keyString.setFrozen(true);
        valueString.setFrozen(true);

        map.put(keyString, valueString);
    }
View Full Code Here

     * throw SecurityError.
     * @param runtime
     * @param value
     */
    public static final void checkStringSafety(Ruby runtime, IRubyObject value) {
        RubyString s = value.asString();
        if (runtime.getSafeLevel() > 0 && s.isTaint()) {
            throw runtime.newSecurityError("Unsafe string parameter");
        }
        ByteList bl = s.getByteList();
        final byte[] array = bl.getUnsafeBytes();
        final int end = bl.length();
        for (int i = bl.begin(); i < end; ++i) {
            if (array[i] == (byte) 0) {
                throw runtime.newSecurityError("string contains null byte");
View Full Code Here

TOP

Related Classes of org.jruby.RubyString$TR

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.