public static void setErrorInfo(Ruby runtime, IRubyObject error) { runtime.getGlobalVariables().set("$!", error); }
@Override public IRubyObject assign(Ruby runtime, ThreadContext context, IRubyObject self, IRubyObject value, Block block, boolean checkArity) { runtime.getGlobalVariables().set(name, value); return runtime.getNil(); } }
/** * Injects a global value to a parsed Ruby script. This method is * invoked during EvalUnit#run() is executed. */ @Override public void inject() { synchronized (receiver.getRuntime()) { String varname = (name.startsWith("$") ? name : "$" + name); receiver.getRuntime().getGlobalVariables().set(varname.intern(), irubyObject); } }
/** * Injects a global value to a parsed Ruby script. This method is * invoked during EvalUnit#run() is executed. */ @Override public void inject() { synchronized (getRuntime()) { String gName = (name.startsWith("$") ? name : "$" + name); getRuntime().getGlobalVariables().set( gName.intern(), irubyObject ); } }
/** * Injects a global value to a parsed Ruby script. This method is * invoked during EvalUnit#run() is executed. */ @Override public void inject() { synchronized (getRuntime()) { String gName = (name.startsWith("$") ? name : "$" + name); getRuntime().getGlobalVariables().set( gName.intern(), irubyObject ); } }
/** * Injects a global value to a parsed Ruby script. This method is * invoked during EvalUnit#run() is executed. */ @Override public void inject() { synchronized (receiver.getRuntime()) { String varname = (name.startsWith("$") ? name : "$" + name); receiver.getRuntime().getGlobalVariables().set(varname.intern(), irubyObject); } }
@Override public IRubyObject assign(Ruby runtime, ThreadContext context, IRubyObject self, IRubyObject value, Block block, boolean checkArity) { runtime.getGlobalVariables().set(name, value); return runtime.getNil(); } }
@Override public IRubyObject interpret(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) { IRubyObject result = getValueNode().interpret(runtime,context, self, aBlock); runtime.getGlobalVariables().set(name, result); return result; }
@Override public void undeclareBean(BSFDeclaredBean bean) throws BSFException { runtime.getGlobalVariables().set(GlobalVariable.variableName(bean.name), runtime.getNil()); }
@Override public IRubyObject interpret(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) { IRubyObject result = getValueNode().interpret(runtime,context, self, aBlock); runtime.getGlobalVariables().set(name, result); return result; }
private static IRubyObject rbThrowInternal(ThreadContext context, IRubyObject tag, IRubyObject arg) { final Ruby runtime = context.runtime; runtime.getGlobalVariables().set("$!", context.nil); RubyContinuation.Continuation continuation = context.getActiveCatch(tag); if (continuation != null) { continuation.args = arg == null ? IRubyObject.NULL_ARRAY : new IRubyObject[] { arg }; throw continuation; } // No catch active for this throw IRubyObject value = arg == null ? context.nil : arg; throw uncaughtThrow(runtime, tag, value, RubyString.newStringShared(runtime, uncaught_throw_p)); }
private static IRubyObject rbThrowInternal(ThreadContext context, IRubyObject tag, IRubyObject arg) { final Ruby runtime = context.runtime; runtime.getGlobalVariables().set("$!", context.nil); RubyContinuation.Continuation continuation = context.getActiveCatch(tag); if (continuation != null) { continuation.args = arg == null ? IRubyObject.NULL_ARRAY : new IRubyObject[] { arg }; throw continuation; } // No catch active for this throw IRubyObject value = arg == null ? context.nil : arg; throw uncaughtThrow(runtime, tag, value, RubyString.newStringShared(runtime, uncaught_throw_p)); }
@Override public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, Block block) { GlobalVariable target = (GlobalVariable)getTarget(); IRubyObject value = (IRubyObject) getValue().retrieve(context, self, currDynScope, temp); context.runtime.getGlobalVariables().set(target.getName(), value); return null; }
@Override public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, Block block) { GlobalVariable target = (GlobalVariable)getTarget(); IRubyObject value = (IRubyObject) getValue().retrieve(context, self, currDynScope, temp); context.runtime.getGlobalVariables().set(target.getName(), value); return null; }
@Override public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) { GlobalVariable target = getTarget(); IRubyObject value = (IRubyObject) getValue().retrieve(context, self, currScope, currDynScope, temp); context.runtime.getGlobalVariables().set(target.getId(), value); return null; }
@Override public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) { GlobalVariable target = getTarget(); IRubyObject value = (IRubyObject) getValue().retrieve(context, self, currScope, currDynScope, temp); context.runtime.getGlobalVariables().set(target.getId(), value); return null; }
private void inplaceEdit(ThreadContext context, String filename, String extension) throws RaiseException { File file = new File(filename); FileStat stat = runtime.getPosix().stat(filename); if (extension.length() > 0) { file.renameTo(new File(filename + extension)); } else { file.delete(); } createNewFile(file); runtime.getPosix().chmod(filename, stat.mode()); runtime.getPosix().chown(filename, stat.uid(), stat.gid()); runtime.getGlobalVariables().set("$stdout", (RubyIO) RubyFile.open(context, runtime.getFile(), new IRubyObject[]{runtime.newString(filename), runtime.newString("w")}, Block.NULL_BLOCK)); }
@JRubyMethod(name = {"exists?", "exist?"}, meta = true, compat = RUBY1_9) public static IRubyObject exist(ThreadContext context, IRubyObject recv, IRubyObject arg) { // Capture previous exception if any. IRubyObject exception = context.runtime.getGlobalVariables().get("$!"); try { return context.runtime.newFileStat(RubyFile.get_path(context, arg).asJavaString(), false).directory_p(); } catch (Exception e) { // Restore $! context.runtime.getGlobalVariables().set("$!", exception); return context.runtime.newBoolean(false); } }
@JRubyMethod(name = {"exists?", "exist?"}, meta = true, compat = RUBY1_9) public static IRubyObject exist(ThreadContext context, IRubyObject recv, IRubyObject arg) { // Capture previous exception if any. IRubyObject exception = context.runtime.getGlobalVariables().get("$!"); try { return context.runtime.newFileStat(RubyFile.get_path(context, arg).asJavaString(), false).directory_p(); } catch (Exception e) { // Restore $! context.runtime.getGlobalVariables().set("$!", exception); return context.runtime.newBoolean(false); } }
@JRubyMethod(name = {"unlink", "delete"}) public IRubyObject unlink(ThreadContext context) { IRubyObject oldExc = context.runtime.getGlobalVariables().get("$!"); // Save $! try { return context.runtime.getDir().callMethod(context, "unlink", getPath()); } catch (RaiseException ex) { if (!context.runtime.getErrno().getClass("ENOTDIR").isInstance(ex.getException())) { throw ex; } context.runtime.getGlobalVariables().set("$!", oldExc); // Restore $! return context.runtime.getFile().callMethod(context, "unlink", getPath()); } }