@Override public IRubyObject interpret(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) { if (oldName.equals("$_") || oldName.equals("$LAST_READ_LINE") || oldName.equals("$~") || oldName.equals("$`") || oldName.equals("$'") || oldName.equals("$+") || oldName.equals("$LAST_MATCH_INFO") || oldName.equals("$PREMATCH") || oldName.equals("$POSTMATCH") || oldName.equals("$LAST_PAREN_MATCH")) { runtime.getWarnings().warn(oldName + " is treated specially in JRuby and should not be aliased"); } runtime.getGlobalVariables().alias(newName, oldName); return runtime.getNil(); } }
@Override public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, Block block) { String newNameString = newName.retrieve(context, self, currDynScope, temp).toString(); String oldNameString = oldName.retrieve(context, self, currDynScope, temp).toString(); context.runtime.getGlobalVariables().alias(newNameString, oldNameString); return null; }
@Override public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, Block block) { String newNameString = newName.retrieve(context, self, currDynScope, temp).toString(); String oldNameString = oldName.retrieve(context, self, currDynScope, temp).toString(); context.runtime.getGlobalVariables().alias(newNameString, oldNameString); return null; }
@Override public IRubyObject interpret(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) { if (oldName.equals("$_") || oldName.equals("$LAST_READ_LINE") || oldName.equals("$~") || oldName.equals("$`") || oldName.equals("$'") || oldName.equals("$+") || oldName.equals("$LAST_MATCH_INFO") || oldName.equals("$PREMATCH") || oldName.equals("$POSTMATCH") || oldName.equals("$LAST_PAREN_MATCH")) { runtime.getWarnings().warn(oldName + " is treated specially in JRuby and should not be aliased"); } runtime.getGlobalVariables().alias(newName, oldName); return runtime.getNil(); } }
@Override public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) { String newNameString = getNewName().retrieve(context, self, currScope, currDynScope, temp).toString(); String oldNameString = getOldName().retrieve(context, self, currScope, currDynScope, temp).toString(); context.runtime.getGlobalVariables().alias(newNameString, oldNameString); return null; }
@Override public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) { String newNameString = getNewName().retrieve(context, self, currScope, currDynScope, temp).toString(); String oldNameString = getOldName().retrieve(context, self, currScope, currDynScope, temp).toString(); context.runtime.getGlobalVariables().alias(newNameString, oldNameString); return null; }
private static void setStdOut(ScriptingContainer container, Writer writer) { if (writer == null) { return; } Map map = container.getAttributeMap(); if (map.containsKey(AttributeName.WRITER)) { Writer old = (Writer) map.get(AttributeName.WRITER); if (old == writer) { return; } } map.put(AttributeName.WRITER, writer); Ruby runtime = container.getProvider().getRuntime(); RubyIO io = getRubyIO(runtime, writer); runtime.defineVariable(new OutputGlobalVariable(runtime, "$stdout", io), GlobalVariable.Scope.GLOBAL); runtime.getObject().storeConstant("STDOUT", io); runtime.getGlobalVariables().alias("$>", "$stdout"); runtime.getGlobalVariables().alias("$defout", "$stdout"); }
private static void setStdOut(ScriptingContainer container, Writer writer) { if (writer == null) { return; } Map map = container.getAttributeMap(); if (map.containsKey(AttributeName.WRITER)) { Writer old = (Writer) map.get(AttributeName.WRITER); if (old == writer) { return; } } map.put(AttributeName.WRITER, writer); Ruby runtime = container.getProvider().getRuntime(); RubyIO io = getRubyIO(runtime, writer); runtime.defineVariable(new OutputGlobalVariable(runtime, "$stdout", io), GlobalVariable.Scope.GLOBAL); runtime.getObject().storeConstant("STDOUT", io); runtime.getGlobalVariables().alias("$>", "$stdout"); runtime.getGlobalVariables().alias("$defout", "$stdout"); }
private static void setErrorWriter(ScriptingContainer container, Writer writer) throws IOException, BadDescriptorException { if (writer == null) { return; } Map map = container.getAttributeMap(); if (map.containsKey(AttributeName.ERROR_WRITER)) { Writer old = (Writer) map.get(AttributeName.ERROR_WRITER); if (old == writer) { return; } } map.put(AttributeName.ERROR_WRITER, writer); Ruby runtime = container.getProvider().getRuntime(); RubyIO io = getRubyIO(runtime, writer); runtime.defineVariable(new OutputGlobalVariable(runtime, "$stderr", io), GlobalVariable.Scope. GLOBAL); runtime.getObject().storeConstant("STDERR", io); runtime.getGlobalVariables().alias("$deferr", "$stderr"); }
private void setOutputStream(PrintStream pstream) { if (pstream == null) { return; } Ruby runtime = provider.getRuntime(); RubyIO io = new RubyIO(runtime, pstream); io.getOpenFile().setSync(true); runtime.defineVariable(new OutputGlobalVariable(runtime, "$stdout", io), GlobalVariable.Scope.GLOBAL); runtime.getObject().storeConstant("STDOUT", io); runtime.getGlobalVariables().alias("$>", "$stdout"); runtime.getGlobalVariables().alias("$defout", "$stdout"); }
private static void setStdErr(ScriptingContainer container, Writer writer) { if (writer == null) { return; } Map map = container.getAttributeMap(); if (map.containsKey(AttributeName.ERROR_WRITER)) { Writer old = (Writer) map.get(AttributeName.ERROR_WRITER); if (old == writer) { return; } } map.put(AttributeName.ERROR_WRITER, writer); Ruby runtime = container.getProvider().getRuntime(); RubyIO io = getRubyIO(runtime, writer); runtime.defineVariable(new OutputGlobalVariable(runtime, "$stderr", io), GlobalVariable.Scope.GLOBAL); runtime.getObject().storeConstant("STDERR", io); runtime.getGlobalVariables().alias("$deferr", "$stderr"); }
private void setOutputStream(PrintStream pstream) { if (pstream == null) { return; } Ruby runtime = provider.getRuntime(); RubyIO io = new RubyIO(runtime, pstream); io.getOpenFile().setSync(true); runtime.defineVariable(new OutputGlobalVariable(runtime, "$stdout", io), GlobalVariable.Scope.GLOBAL); runtime.getObject().storeConstant("STDOUT", io); runtime.getGlobalVariables().alias("$>", "$stdout"); runtime.getGlobalVariables().alias("$defout", "$stdout"); }
private static void setStdErr(ScriptingContainer container, Writer writer) { if (writer == null) { return; } Map map = container.getAttributeMap(); if (map.containsKey(AttributeName.ERROR_WRITER)) { Writer old = (Writer) map.get(AttributeName.ERROR_WRITER); if (old == writer) { return; } } map.put(AttributeName.ERROR_WRITER, writer); Ruby runtime = container.getProvider().getRuntime(); RubyIO io = getRubyIO(runtime, writer); runtime.defineVariable(new OutputGlobalVariable(runtime, "$stderr", io), GlobalVariable.Scope.GLOBAL); runtime.getObject().storeConstant("STDERR", io); runtime.getGlobalVariables().alias("$deferr", "$stderr"); }
private static void setErrorWriter(ScriptingContainer container, Writer writer) throws IOException, BadDescriptorException { if (writer == null) { return; } Map map = container.getAttributeMap(); if (map.containsKey(AttributeName.ERROR_WRITER)) { Writer old = (Writer) map.get(AttributeName.ERROR_WRITER); if (old == writer) { return; } } map.put(AttributeName.ERROR_WRITER, writer); Ruby runtime = container.getProvider().getRuntime(); RubyIO io = getRubyIO(runtime, writer); runtime.defineVariable(new OutputGlobalVariable(runtime, "$stderr", io), GlobalVariable.Scope. GLOBAL); runtime.getObject().storeConstant("STDERR", io); runtime.getGlobalVariables().alias("$deferr", "$stderr"); }
private void setOutputStream(PrintStream pstream) { if (pstream == null) { return; } Ruby runtime = provider.getRuntime(); RubyIO io = new RubyIO(runtime, pstream); io.getOpenFile().getMainStream().setSync(true); runtime.defineVariable(new OutputGlobalVariable(runtime, "$stdout", io), GlobalVariable.Scope.GLOBAL); runtime.getObject().storeConstant("STDOUT", io); runtime.getGlobalVariables().alias("$>", "$stdout"); runtime.getGlobalVariables().alias("$defout", "$stdout"); }
private void setOutputStream(PrintStream pstream) { if (pstream == null) { return; } Ruby runtime = provider.getRuntime(); RubyIO io = new RubyIO(runtime, pstream); io.getOpenFile().getMainStream().setSync(true); runtime.defineVariable(new OutputGlobalVariable(runtime, "$stdout", io), GlobalVariable.Scope.GLOBAL); runtime.getObject().storeConstant("STDOUT", io); runtime.getGlobalVariables().alias("$>", "$stdout"); runtime.getGlobalVariables().alias("$defout", "$stdout"); }
private void setErrorStream(PrintStream error) { if (error == null) { return; } Ruby runtime = provider.getRuntime(); RubyIO io = new RubyIO(runtime, error); io.getOpenFile().setSync(true); runtime.defineVariable(new OutputGlobalVariable(runtime, "$stderr", io), GlobalVariable.Scope.GLOBAL); runtime.getObject().storeConstant("STDERR", io); runtime.getGlobalVariables().alias("$deferr", "$stderr"); }
private void setErrorStream(PrintStream error) { if (error == null) { return; } Ruby runtime = provider.getRuntime(); RubyIO io = new RubyIO(runtime, error); io.getOpenFile().setSync(true); runtime.defineVariable(new OutputGlobalVariable(runtime, "$stderr", io), GlobalVariable.Scope.GLOBAL); runtime.getObject().storeConstant("STDERR", io); runtime.getGlobalVariables().alias("$deferr", "$stderr"); }
private void setErrorStream(PrintStream error) { if (error == null) { return; } Ruby runtime = provider.getRuntime(); RubyIO io = new RubyIO(runtime, error); io.getOpenFile().getMainStream().setSync(true); runtime.defineVariable(new OutputGlobalVariable(runtime, "$stderr", io), GlobalVariable.Scope.GLOBAL); runtime.getObject().storeConstant("STDERR", io); runtime.getGlobalVariables().alias("$deferr", "$stderr"); }
private void setErrorStream(PrintStream error) { if (error == null) { return; } Ruby runtime = provider.getRuntime(); RubyIO io = new RubyIO(runtime, error); io.getOpenFile().getMainStream().setSync(true); runtime.defineVariable(new OutputGlobalVariable(runtime, "$stderr", io), GlobalVariable.Scope.GLOBAL); runtime.getObject().storeConstant("STDERR", io); runtime.getGlobalVariables().alias("$deferr", "$stderr"); }