private RubyObject getReceiverObject(Object receiver) { if (receiver == null || !(receiver instanceof IRubyObject)) return (RubyObject)provider.getRuntime().getTopSelf(); else if (receiver instanceof RubyObject) return (RubyObject)receiver; else return (RubyObject)((IRubyObject)receiver).getRuntime().getTopSelf(); }
private RubyObject getReceiverObject(Object receiver) { if (receiver == null || !(receiver instanceof IRubyObject)) return (RubyObject)provider.getRuntime().getTopSelf(); else if (receiver instanceof RubyObject) return (RubyObject)receiver; else return (RubyObject)((IRubyObject)receiver).getRuntime().getTopSelf(); }
private RubyObject getReceiverObject(Object receiver) { Ruby runtime = container.getProvider().getRuntime(); if (receiver == null || !(receiver instanceof IRubyObject)) { return (RubyObject)runtime.getTopSelf(); } else if (receiver instanceof RubyObject) return (RubyObject)receiver; else return (RubyObject)((IRubyObject)receiver).getRuntime().getTopSelf(); }
private RubyObject getReceiverObject(Object receiver) { Ruby runtime = container.getProvider().getRuntime(); if (receiver == null || !(receiver instanceof IRubyObject)) { return (RubyObject)runtime.getTopSelf(); } else if (receiver instanceof RubyObject) return (RubyObject)receiver; else return (RubyObject)((IRubyObject)receiver).getRuntime().getTopSelf(); }
private RubyObject getReceiverObject(Object receiver) { Ruby runtime = container.getProvider().getRuntime(); if (receiver == null || !(receiver instanceof IRubyObject)) { return (RubyObject)runtime.getTopSelf(); } else if (receiver instanceof RubyObject) return (RubyObject)receiver; else return (RubyObject)((IRubyObject)receiver).getRuntime().getTopSelf(); }
private RubyObject getReceiverObject(Object receiver) { Ruby runtime = container.getProvider().getRuntime(); if (receiver == null || !(receiver instanceof IRubyObject)) { return (RubyObject)runtime.getTopSelf(); } else if (receiver instanceof RubyObject) return (RubyObject)receiver; else return (RubyObject)((IRubyObject)receiver).getRuntime().getTopSelf(); }
/** * Returns the value in BiVariable type to which the specified key is mapped, * or {@code null} if this map contains no mapping for the key. * * @param key is the key whose associated BiVariable object is to be returned * @return the BiVariable type object to which the specified key is mapped, or * {@code null} if this map contains no mapping for the key */ @Deprecated public BiVariable getVariable(String key) { return getVariable((RubyObject)provider.getRuntime().getTopSelf(), key); }
/** * This is used for the "gets" loop, and we bypass 'load' to use an * already-prepared, already-pushed scope for the script body. */ public IRubyObject runScriptBody(Script script) { return script.__file__(getCurrentContext(), getTopSelf(), Block.NULL_BLOCK); }
public void loadScript(Script script, boolean wrap) { IRubyObject self = getTopSelf(); ThreadContext context = getCurrentContext(); try { script.load(context, self, wrap); } catch (JumpException.ReturnJump rj) { return; } }
/** * Removes the mapping for a key from this map if it is present in a top level. * * <p>Returns the value to which this map previously associated the key, * or <tt>null</tt> if the map contained no mapping for the key. * @param key the key whose mapping is to be removed from the map * @return the previous value associated with <tt>key</tt>, or * <tt>null</tt> if there was no mapping for <tt>key</tt>. */ public V remove(Object key) { return removeFrom(provider.getRuntime().getTopSelf(), key); }
public IRubyObject create(Ruby runtime, org.yecht.Node n, Data.Str ds) throws java.io.UnsupportedEncodingException { IRubyObject year = runtime.newFixnum(Integer.parseInt(new String(ds.ptr.buffer, 0, 4, "ISO-8859-1"))); IRubyObject mon = runtime.newFixnum(Integer.parseInt(new String(ds.ptr.buffer, 5, 2, "ISO-8859-1"))); IRubyObject day = runtime.newFixnum(Integer.parseInt(new String(ds.ptr.buffer, 8, 2, "ISO-8859-1"))); RubyKernel.require(runtime.getTopSelf(), runtime.newString("date"), Block.NULL_BLOCK); return runtime.getClass("Date").callMethod(runtime.getCurrentContext(), "new", new IRubyObject[] {year, mon, day}); } });
public IRubyObject runScript(Script script, boolean wrap) { ThreadContext context = getCurrentContext(); try { return script.load(context, getTopSelf(), wrap); } catch (JumpException.ReturnJump rj) { return (IRubyObject) rj.getValue(); } }
public IRubyObject runScript(Script script, boolean wrap) { ThreadContext context = getCurrentContext(); try { return script.load(context, getTopSelf(), wrap); } catch (JumpException.ReturnJump rj) { return (IRubyObject) rj.getValue(); } }
/** * Retrieves instance variables from Ruby after the evaluation. * * @param runtime Ruby runtime * @param receiver receiver object returned when a script is evaluated. * @param vars map to save retrieved instance variables. */ public static void retrieve(RubyObject receiver, BiVariableMap vars) { if (vars.isLazy()) return; updateInstanceVar(receiver, vars); updateInstanceVar((RubyObject)receiver.getRuntime().getTopSelf(), vars); }
/** * Retrieves instance variables from Ruby after the evaluation. * * @param runtime Ruby runtime * @param receiver receiver object returned when a script is evaluated. * @param vars map to save retrieved instance variables. */ public static void retrieve(RubyObject receiver, BiVariableMap vars) { if (vars.isLazy()) return; updateInstanceVar(receiver, vars); updateInstanceVar((RubyObject)receiver.getRuntime().getTopSelf(), vars); }
public IRubyObject runInterpreter(ThreadContext context, Node rootNode, IRubyObject self) { assert rootNode != null : "scriptNode is not null"; try { if (getInstanceConfig().getCompileMode() == CompileMode.OFFIR) { return Interpreter.interpret(this, rootNode, self); } else { return ASTInterpreter.INTERPRET_ROOT(this, context, rootNode, getTopSelf(), Block.NULL_BLOCK); } } catch (JumpException.ReturnJump rj) { return (IRubyObject) rj.getValue(); } }
public IRubyObject getInstanceVariable(IRubyObject obj, String variableName) { BiVariableMap map = container.getVarMap(); synchronized (map) { if (map.containsKey(variableName)) { BiVariable bv = map.getVariable((RubyObject)container.getProvider().getRuntime().getTopSelf(), variableName); return bv.getRubyObject(); } } return null; }
public static void preLoadCommon(ThreadContext context, StaticScope staticScope, boolean wrap) { RubyModule objectClass = context.runtime.getObject(); if (wrap) { objectClass = RubyModule.newModule(context.runtime); } staticScope.setModule(objectClass); DynamicScope scope = DynamicScope.newDynamicScope(staticScope); // Each root node has a top-level scope that we need to push context.preScopedBody(scope); context.preNodeEval(context.runtime.getTopSelf()); }
public IRubyObject getInstanceVariable(IRubyObject obj, String variableName) { BiVariableMap map = container.getVarMap(); synchronized (map) { if (map.containsKey(variableName)) { BiVariable bv = map.getVariable((RubyObject)container.getProvider().getRuntime().getTopSelf(), variableName); return bv.getRubyObject(); } } return null; }
public static void preLoadCommon(ThreadContext context, StaticScope staticScope, boolean wrap) { RubyModule objectClass = context.runtime.getObject(); if (wrap) { objectClass = RubyModule.newModule(context.runtime); } staticScope.setModule(objectClass); DynamicScope scope = DynamicScope.newDynamicScope(staticScope); // Each root node has a top-level scope that we need to push context.preScopedBody(scope); context.preNodeEval(context.runtime.getTopSelf()); }