Beispiel #1
0
 @JRubyMethod(name = "_id2ref", required = 1, module = true, visibility = Visibility.PRIVATE)
 public static IRubyObject id2ref(IRubyObject recv, IRubyObject id) {
   Ruby runtime = id.getRuntime();
   if (!(id instanceof RubyFixnum)) {
     throw recv.getRuntime().newTypeError(id, recv.getRuntime().getFixnum());
   }
   RubyFixnum idFixnum = (RubyFixnum) id;
   long longId = idFixnum.getLongValue();
   if (longId == 0) {
     return runtime.getFalse();
   } else if (longId == 2) {
     return runtime.getTrue();
   } else if (longId == 4) {
     return runtime.getNil();
   } else if (longId % 2 != 0) {
     // odd
     return runtime.newFixnum((longId - 1) / 2);
   } else {
     if (runtime.isObjectSpaceEnabled()) {
       IRubyObject object = runtime.getObjectSpace().id2ref(longId);
       if (object == null) {
         return runtime.getNil();
       }
       return object;
     } else {
       runtime
           .getWarnings()
           .warn("ObjectSpace is disabled; _id2ref only supports immediates, pass -X+O to enable");
       return runtime.getNil();
     }
   }
 }
Beispiel #2
0
  private static IRubyObject callCmpMethod(
      ThreadContext context, IRubyObject recv, IRubyObject other, IRubyObject returnValueOnError) {
    Ruby runtime = context.runtime;

    if (recv == other) return runtime.getTrue();

    try {
      IRubyObject result = invokedynamic(context, recv, OP_CMP, other);

      // This is only to prevent throwing exceptions by cmperr - it has poor performance
      if (result.isNil()) {
        return returnValueOnError;
      }

      return RubyBoolean.newBoolean(runtime, cmpint(context, result, recv, other) == 0);
    } catch (RaiseException e) {
      if (e.getException().kind_of_p(context, runtime.getStandardError()).isTrue()) {
        // clear error info resulting from failure to compare (JRUBY-3292)
        context.setErrorInfo(runtime.getNil());
        return returnValueOnError;
      } else {
        throw e;
      }
    }
  }
Beispiel #3
0
 @JRubyMethod(name = "even?")
 public RubyBoolean even_p(ThreadContext context) {
   Ruby runtime = context.getRuntime();
   if (callMethod(context, "%", RubyFixnum.two(runtime)) == RubyFixnum.zero(runtime)) {
     return runtime.getTrue();
   }
   return runtime.getFalse();
 }
Beispiel #4
0
 @JRubyMethod(name = "odd?")
 public RubyBoolean odd_p(ThreadContext context) {
   Ruby runtime = context.runtime;
   if (callMethod(context, "%", RubyFixnum.two(runtime)) != RubyFixnum.zero(runtime)) {
     return runtime.getTrue();
   }
   return runtime.getFalse();
 }
Beispiel #5
0
 @JRubyMethod(
     name = {"include?", "member?"},
     frame = true,
     compat = CompatVersion.RUBY1_9)
 public IRubyObject include_p19(ThreadContext context, IRubyObject obj) {
   Ruby runtime = context.getRuntime();
   if (begin instanceof RubyNumeric
       || end instanceof RubyNumeric
       || !TypeConverter.convertToTypeWithCheck(begin, runtime.getInteger(), "to_int").isNil()
       || !TypeConverter.convertToTypeWithCheck(end, runtime.getInteger(), "to_int").isNil()) {
     if (rangeLe(context, begin, obj) != null) {
       if (isExclusive) {
         if (rangeLt(context, obj, end) != null) return runtime.getTrue();
       } else {
         if (rangeLe(context, obj, end) != null) return runtime.getTrue();
       }
     }
     return runtime.getFalse();
   } else if (begin instanceof RubyString
       && end instanceof RubyString
       && ((RubyString) begin).getByteList().realSize == 1
       && ((RubyString) end).getByteList().realSize == 1) {
     if (obj.isNil()) return runtime.getFalse();
     if (obj instanceof RubyString) {
       ByteList Vbytes = ((RubyString) obj).getByteList();
       if (Vbytes.realSize != 1) return runtime.getFalse();
       int v = Vbytes.bytes[Vbytes.begin] & 0xff;
       ByteList Bbytes = ((RubyString) begin).getByteList();
       int b = Bbytes.bytes[Bbytes.begin] & 0xff;
       ByteList Ebytes = ((RubyString) end).getByteList();
       int e = Ebytes.bytes[Ebytes.begin] & 0xff;
       if (Encoding.isAscii(v) && Encoding.isAscii(b) && Encoding.isAscii(e)) {
         if ((b <= v && v < e) || (!isExclusive && v == e)) return runtime.getTrue();
         return runtime.getFalse();
       }
     }
   }
   return RuntimeHelpers.invokeSuper(context, this, obj, Block.NULL_BLOCK);
 }
Beispiel #6
0
        public void marshalTo(Ruby runtime, Object obj, RubyClass type, MarshalStream marshalStream)
            throws IOException {
          RubyRange range = (RubyRange) obj;

          marshalStream.registerLinkTarget(range);
          List<Variable<IRubyObject>> attrs = range.getVariableList();

          attrs.add(new VariableEntry<IRubyObject>("begin", range.begin));
          attrs.add(new VariableEntry<IRubyObject>("end", range.end));
          attrs.add(
              new VariableEntry<IRubyObject>(
                  "excl", range.isExclusive ? runtime.getTrue() : runtime.getFalse()));

          marshalStream.dumpVariables(attrs);
        }
Beispiel #7
0
  public static void createGlobals(ThreadContext context, Ruby runtime) {
    runtime.defineGlobalConstant("TOPLEVEL_BINDING", runtime.newBinding());

    runtime.defineGlobalConstant("TRUE", runtime.getTrue());
    runtime.defineGlobalConstant("FALSE", runtime.getFalse());
    runtime.defineGlobalConstant("NIL", runtime.getNil());

    // define ARGV and $* for this runtime
    RubyArray argvArray = runtime.newArray();
    String[] argv = runtime.getInstanceConfig().getArgv();
    for (int i = 0; i < argv.length; i++) {
      argvArray.append(RubyString.newStringShared(runtime, argv[i].getBytes()));
    }
    runtime.defineGlobalConstant("ARGV", argvArray);
    runtime.getGlobalVariables().defineReadonly("$*", new ValueAccessor(argvArray));

    IAccessor d =
        new ValueAccessor(runtime.newString(runtime.getInstanceConfig().displayedFileName()));
    runtime.getGlobalVariables().define("$PROGRAM_NAME", d);
    runtime.getGlobalVariables().define("$0", d);

    // Version information:
    IRubyObject version = null;
    IRubyObject patchlevel = null;
    IRubyObject release = runtime.newString(Constants.COMPILE_DATE).freeze(context);
    IRubyObject platform = runtime.newString(Constants.PLATFORM).freeze(context);
    IRubyObject engine = runtime.newString(Constants.ENGINE).freeze(context);

    switch (runtime.getInstanceConfig().getCompatVersion()) {
      case RUBY1_8:
        version = runtime.newString(Constants.RUBY_VERSION).freeze(context);
        patchlevel = runtime.newFixnum(Constants.RUBY_PATCHLEVEL).freeze(context);
        break;
      case RUBY1_9:
        version = runtime.newString(Constants.RUBY1_9_VERSION).freeze(context);
        patchlevel = runtime.newFixnum(Constants.RUBY1_9_PATCHLEVEL).freeze(context);
        break;
    }
    runtime.defineGlobalConstant("RUBY_VERSION", version);
    runtime.defineGlobalConstant("RUBY_PATCHLEVEL", patchlevel);
    runtime.defineGlobalConstant("RUBY_RELEASE_DATE", release);
    runtime.defineGlobalConstant("RUBY_PLATFORM", platform);
    runtime.defineGlobalConstant("RUBY_ENGINE", engine);

    IRubyObject description =
        runtime.newString(runtime.getInstanceConfig().getVersionString()).freeze(context);
    runtime.defineGlobalConstant("RUBY_DESCRIPTION", description);

    IRubyObject copyright =
        runtime.newString(runtime.getInstanceConfig().getCopyrightString()).freeze(context);
    runtime.defineGlobalConstant("RUBY_COPYRIGHT", copyright);

    runtime.defineGlobalConstant("VERSION", version);
    runtime.defineGlobalConstant("RELEASE_DATE", release);
    runtime.defineGlobalConstant("PLATFORM", platform);

    IRubyObject jrubyVersion = runtime.newString(Constants.VERSION).freeze(context);
    IRubyObject jrubyRevision = runtime.newString(Constants.REVISION).freeze(context);
    runtime.defineGlobalConstant("JRUBY_VERSION", jrubyVersion);
    runtime.defineGlobalConstant("JRUBY_REVISION", jrubyRevision);

    if (runtime.is1_9()) {
      // needs to be a fixnum, but our revision is a sha1 hash from git
      runtime.defineGlobalConstant("RUBY_REVISION", runtime.newFixnum(Constants.RUBY1_9_REVISION));
    }

    GlobalVariable kcodeGV = new KCodeGlobalVariable(runtime, "$KCODE", runtime.newString("NONE"));
    runtime.defineVariable(kcodeGV);
    runtime.defineVariable(new GlobalVariable.Copy(runtime, "$-K", kcodeGV));
    IRubyObject defaultRS =
        runtime.newString(runtime.getInstanceConfig().getRecordSeparator()).freeze(context);
    GlobalVariable rs = new StringGlobalVariable(runtime, "$/", defaultRS);
    runtime.defineVariable(rs);
    runtime.setRecordSeparatorVar(rs);
    runtime.getGlobalVariables().setDefaultSeparator(defaultRS);
    runtime.defineVariable(new StringGlobalVariable(runtime, "$\\", runtime.getNil()));
    runtime.defineVariable(new StringGlobalVariable(runtime, "$,", runtime.getNil()));

    runtime.defineVariable(new LineNumberGlobalVariable(runtime, "$."));
    runtime.defineVariable(new LastlineGlobalVariable(runtime, "$_"));
    runtime.defineVariable(new LastExitStatusVariable(runtime, "$?"));

    runtime.defineVariable(new ErrorInfoGlobalVariable(runtime, "$!", runtime.getNil()));
    runtime.defineVariable(new NonEffectiveGlobalVariable(runtime, "$=", runtime.getFalse()));

    if (runtime.getInstanceConfig().getInputFieldSeparator() == null) {
      runtime.defineVariable(new GlobalVariable(runtime, "$;", runtime.getNil()));
    } else {
      runtime.defineVariable(
          new GlobalVariable(
              runtime,
              "$;",
              RubyRegexp.newRegexp(
                  runtime, runtime.getInstanceConfig().getInputFieldSeparator(), 0)));
    }

    Boolean verbose = runtime.getInstanceConfig().getVerbose();
    IRubyObject verboseValue = null;
    if (verbose == null) {
      verboseValue = runtime.getNil();
    } else if (verbose == Boolean.TRUE) {
      verboseValue = runtime.getTrue();
    } else {
      verboseValue = runtime.getFalse();
    }
    runtime.defineVariable(new VerboseGlobalVariable(runtime, "$VERBOSE", verboseValue));

    IRubyObject debug = runtime.newBoolean(runtime.getInstanceConfig().isDebug());
    runtime.defineVariable(new DebugGlobalVariable(runtime, "$DEBUG", debug));
    runtime.defineVariable(new DebugGlobalVariable(runtime, "$-d", debug));

    runtime.defineVariable(new SafeGlobalVariable(runtime, "$SAFE"));

    runtime.defineVariable(new BacktraceGlobalVariable(runtime, "$@"));

    IRubyObject stdin = new RubyIO(runtime, STDIO.IN);
    IRubyObject stdout = new RubyIO(runtime, STDIO.OUT);
    IRubyObject stderr = new RubyIO(runtime, STDIO.ERR);

    runtime.defineVariable(new InputGlobalVariable(runtime, "$stdin", stdin));

    runtime.defineVariable(new OutputGlobalVariable(runtime, "$stdout", stdout));
    runtime.getGlobalVariables().alias("$>", "$stdout");
    runtime.getGlobalVariables().alias("$defout", "$stdout");

    runtime.defineVariable(new OutputGlobalVariable(runtime, "$stderr", stderr));
    runtime.getGlobalVariables().alias("$deferr", "$stderr");

    runtime.defineGlobalConstant("STDIN", stdin);
    runtime.defineGlobalConstant("STDOUT", stdout);
    runtime.defineGlobalConstant("STDERR", stderr);

    runtime.defineVariable(new LoadedFeatures(runtime, "$\""));
    runtime.defineVariable(new LoadedFeatures(runtime, "$LOADED_FEATURES"));

    runtime.defineVariable(new LoadPath(runtime, "$:"));
    runtime.defineVariable(new LoadPath(runtime, "$-I"));
    runtime.defineVariable(new LoadPath(runtime, "$LOAD_PATH"));

    runtime.defineVariable(new MatchMatchGlobalVariable(runtime, "$&"));
    runtime.defineVariable(new PreMatchGlobalVariable(runtime, "$`"));
    runtime.defineVariable(new PostMatchGlobalVariable(runtime, "$'"));
    runtime.defineVariable(new LastMatchGlobalVariable(runtime, "$+"));
    runtime.defineVariable(new BackRefGlobalVariable(runtime, "$~"));

    // On platforms without a c-library accessable through JNA, getpid will return hashCode
    // as $$ used to. Using $$ to kill processes could take down many runtimes, but by basing
    // $$ on getpid() where available, we have the same semantics as MRI.
    runtime.getGlobalVariables().defineReadonly("$$", new PidAccessor(runtime));

    // after defn of $stderr as the call may produce warnings
    defineGlobalEnvConstants(runtime);

    // Fixme: Do we need the check or does Main.java not call this...they should consolidate
    if (runtime.getGlobalVariables().get("$*").isNil()) {
      runtime.getGlobalVariables().defineReadonly("$*", new ValueAccessor(runtime.newArray()));
    }

    runtime
        .getGlobalVariables()
        .defineReadonly(
            "$-p",
            new ValueAccessor(runtime.newBoolean(runtime.getInstanceConfig().isAssumePrinting())));
    runtime
        .getGlobalVariables()
        .defineReadonly(
            "$-a", new ValueAccessor(runtime.newBoolean(runtime.getInstanceConfig().isSplit())));
    runtime
        .getGlobalVariables()
        .defineReadonly(
            "$-l",
            new ValueAccessor(runtime.newBoolean(runtime.getInstanceConfig().isProcessLineEnds())));

    // ARGF, $< object
    RubyArgsFile.initArgsFile(runtime);
  }
Beispiel #8
0
 public static RubyBoolean newBoolean(Ruby runtime, boolean value) {
   return value ? runtime.getTrue() : runtime.getFalse();
 }
Beispiel #9
0
 /**
  * Returns the status of the global ``abort on exception'' condition. The default is false. When
  * set to true, will cause all threads to abort (the process will exit(0)) if an exception is
  * raised in any thread. See also Thread.abort_on_exception= .
  */
 @JRubyMethod(name = "abort_on_exception", meta = true)
 public static RubyBoolean abort_on_exception_x(IRubyObject recv) {
   Ruby runtime = recv.getRuntime();
   return runtime.isGlobalAbortOnExceptionEnabled() ? runtime.getTrue() : runtime.getFalse();
 }
Beispiel #10
0
  public static void createGlobals(ThreadContext context, Ruby runtime) {
    GlobalVariables globals = runtime.getGlobalVariables();

    runtime.defineGlobalConstant("TOPLEVEL_BINDING", runtime.newBinding());

    runtime.defineGlobalConstant("TRUE", runtime.getTrue());
    runtime.defineGlobalConstant("FALSE", runtime.getFalse());
    runtime.defineGlobalConstant("NIL", runtime.getNil());

    initARGV(runtime);

    IAccessor d =
        new ValueAccessor(runtime.newString(runtime.getInstanceConfig().displayedFileName()));
    globals.define("$PROGRAM_NAME", d, GLOBAL);
    globals.define("$0", d, GLOBAL);

    // Version information:
    IRubyObject version = null;
    IRubyObject patchlevel = null;
    IRubyObject release = runtime.newString(Constants.COMPILE_DATE).freeze(context);
    IRubyObject platform = runtime.newString(Constants.PLATFORM).freeze(context);
    IRubyObject engine = runtime.newString(Constants.ENGINE).freeze(context);

    version = runtime.newString(Constants.RUBY_VERSION).freeze(context);
    patchlevel = runtime.newFixnum(Constants.RUBY_PATCHLEVEL);
    runtime.defineGlobalConstant("RUBY_VERSION", version);
    runtime.defineGlobalConstant("RUBY_PATCHLEVEL", patchlevel);
    runtime.defineGlobalConstant("RUBY_RELEASE_DATE", release);
    runtime.defineGlobalConstant("RUBY_PLATFORM", platform);

    IRubyObject description = runtime.newString(OutputStrings.getVersionString()).freeze(context);
    runtime.defineGlobalConstant("RUBY_DESCRIPTION", description);

    IRubyObject copyright = runtime.newString(OutputStrings.getCopyrightString()).freeze(context);
    runtime.defineGlobalConstant("RUBY_COPYRIGHT", copyright);

    runtime.defineGlobalConstant("RELEASE_DATE", release);
    runtime.defineGlobalConstant("PLATFORM", platform);

    IRubyObject jrubyVersion = runtime.newString(Constants.VERSION).freeze(context);
    IRubyObject jrubyRevision = runtime.newString(Constants.REVISION).freeze(context);
    runtime.defineGlobalConstant("JRUBY_VERSION", jrubyVersion);
    runtime.defineGlobalConstant("JRUBY_REVISION", jrubyRevision);

    // needs to be a fixnum, but our revision is a sha1 hash from git
    runtime.defineGlobalConstant("RUBY_REVISION", runtime.newFixnum(Constants.RUBY_REVISION));
    runtime.defineGlobalConstant("RUBY_ENGINE", engine);
    runtime.defineGlobalConstant("RUBY_ENGINE_VERSION", jrubyVersion);

    RubyInstanceConfig.Verbosity verbosity = runtime.getInstanceConfig().getVerbosity();
    runtime.defineVariable(new WarningGlobalVariable(runtime, "$-W", verbosity), GLOBAL);

    final GlobalVariable kcodeGV;
    kcodeGV = new NonEffectiveGlobalVariable(runtime, "$KCODE", runtime.getNil());

    runtime.defineVariable(kcodeGV, GLOBAL);
    runtime.defineVariable(new GlobalVariable.Copy(runtime, "$-K", kcodeGV), GLOBAL);
    IRubyObject defaultRS =
        runtime.newString(runtime.getInstanceConfig().getRecordSeparator()).freeze(context);
    GlobalVariable rs = new StringGlobalVariable(runtime, "$/", defaultRS);
    runtime.defineVariable(rs, GLOBAL);
    runtime.setRecordSeparatorVar(rs);
    globals.setDefaultSeparator(defaultRS);
    runtime.defineVariable(new StringGlobalVariable(runtime, "$\\", runtime.getNil()), GLOBAL);
    runtime.defineVariable(new StringGlobalVariable(runtime, "$,", runtime.getNil()), GLOBAL);

    runtime.defineVariable(new LineNumberGlobalVariable(runtime, "$."), GLOBAL);
    runtime.defineVariable(new LastlineGlobalVariable(runtime, "$_"), FRAME);
    runtime.defineVariable(new LastExitStatusVariable(runtime, "$?"), THREAD);

    runtime.defineVariable(new ErrorInfoGlobalVariable(runtime, "$!", runtime.getNil()), THREAD);
    runtime.defineVariable(
        new NonEffectiveGlobalVariable(runtime, "$=", runtime.getFalse()), GLOBAL);

    if (runtime.getInstanceConfig().getInputFieldSeparator() == null) {
      runtime.defineVariable(new GlobalVariable(runtime, "$;", runtime.getNil()), GLOBAL);
    } else {
      runtime.defineVariable(
          new GlobalVariable(
              runtime,
              "$;",
              RubyRegexp.newRegexp(
                  runtime,
                  runtime.getInstanceConfig().getInputFieldSeparator(),
                  new RegexpOptions())),
          GLOBAL);
    }

    RubyInstanceConfig.Verbosity verbose = runtime.getInstanceConfig().getVerbosity();
    IRubyObject verboseValue = null;
    if (verbose == RubyInstanceConfig.Verbosity.NIL) {
      verboseValue = runtime.getNil();
    } else if (verbose == RubyInstanceConfig.Verbosity.TRUE) {
      verboseValue = runtime.getTrue();
    } else {
      verboseValue = runtime.getFalse();
    }
    runtime.defineVariable(new VerboseGlobalVariable(runtime, "$VERBOSE", verboseValue), GLOBAL);
    runtime.defineVariable(new VerboseGlobalVariable(runtime, "$-v", verboseValue), GLOBAL);
    runtime.defineVariable(new VerboseGlobalVariable(runtime, "$-w", verboseValue), GLOBAL);

    IRubyObject debug = runtime.newBoolean(runtime.getInstanceConfig().isDebug());
    runtime.defineVariable(new DebugGlobalVariable(runtime, "$DEBUG", debug), GLOBAL);
    runtime.defineVariable(new DebugGlobalVariable(runtime, "$-d", debug), GLOBAL);

    runtime.defineVariable(new SafeGlobalVariable(runtime, "$SAFE"), THREAD);

    runtime.defineVariable(new BacktraceGlobalVariable(runtime, "$@"), THREAD);

    IRubyObject stdin =
        RubyIO.prepStdio(
            runtime,
            runtime.getIn(),
            prepareStdioChannel(runtime, STDIO.IN, runtime.getIn()),
            OpenFile.READABLE,
            runtime.getIO(),
            "<STDIN>");
    IRubyObject stdout =
        RubyIO.prepStdio(
            runtime,
            runtime.getOut(),
            prepareStdioChannel(runtime, STDIO.OUT, runtime.getOut()),
            OpenFile.WRITABLE,
            runtime.getIO(),
            "<STDOUT>");
    IRubyObject stderr =
        RubyIO.prepStdio(
            runtime,
            runtime.getErr(),
            prepareStdioChannel(runtime, STDIO.ERR, runtime.getErr()),
            OpenFile.WRITABLE | OpenFile.SYNC,
            runtime.getIO(),
            "<STDERR>");

    runtime.defineVariable(new InputGlobalVariable(runtime, "$stdin", stdin), GLOBAL);
    runtime.defineVariable(new OutputGlobalVariable(runtime, "$stdout", stdout), GLOBAL);
    globals.alias("$>", "$stdout");
    runtime.defineVariable(new OutputGlobalVariable(runtime, "$stderr", stderr), GLOBAL);

    runtime.defineGlobalConstant("STDIN", stdin);
    runtime.defineGlobalConstant("STDOUT", stdout);
    runtime.defineGlobalConstant("STDERR", stderr);

    runtime.defineVariable(new LoadedFeatures(runtime, "$\""), GLOBAL);
    runtime.defineVariable(new LoadedFeatures(runtime, "$LOADED_FEATURES"), GLOBAL);

    runtime.defineVariable(new LoadPath(runtime, "$:"), GLOBAL);
    runtime.defineVariable(new LoadPath(runtime, "$-I"), GLOBAL);
    runtime.defineVariable(new LoadPath(runtime, "$LOAD_PATH"), GLOBAL);

    runtime.defineVariable(new MatchMatchGlobalVariable(runtime, "$&"), FRAME);
    runtime.defineVariable(new PreMatchGlobalVariable(runtime, "$`"), FRAME);
    runtime.defineVariable(new PostMatchGlobalVariable(runtime, "$'"), FRAME);
    runtime.defineVariable(new LastMatchGlobalVariable(runtime, "$+"), FRAME);
    runtime.defineVariable(new BackRefGlobalVariable(runtime, "$~"), FRAME);

    // On platforms without a c-library accessable through JNA, getpid will return hashCode
    // as $$ used to. Using $$ to kill processes could take down many runtimes, but by basing
    // $$ on getpid() where available, we have the same semantics as MRI.
    globals.defineReadonly("$$", new PidAccessor(runtime), GLOBAL);

    // after defn of $stderr as the call may produce warnings
    defineGlobalEnvConstants(runtime);

    // Fixme: Do we need the check or does Main.java not call this...they should consolidate
    if (globals.get("$*").isNil()) {
      globals.defineReadonly("$*", new ValueAccessor(runtime.newArray()), GLOBAL);
    }

    globals.defineReadonly(
        "$-p",
        new ValueAccessor(runtime.newBoolean(runtime.getInstanceConfig().isAssumePrinting())),
        GLOBAL);
    globals.defineReadonly(
        "$-a",
        new ValueAccessor(runtime.newBoolean(runtime.getInstanceConfig().isSplit())),
        GLOBAL);
    globals.defineReadonly(
        "$-l",
        new ValueAccessor(runtime.newBoolean(runtime.getInstanceConfig().isProcessLineEnds())),
        GLOBAL);

    // ARGF, $< object
    RubyArgsFile.initArgsFile(runtime);

    globals.alias("$-0", "$/");

    // Define aliases originally in the "English.rb" stdlib
    globals.alias("$ERROR_INFO", "$!");
    globals.alias("$ERROR_POSITION", "$@");
    globals.alias("$FS", "$;");
    globals.alias("$FIELD_SEPARATOR", "$;");
    globals.alias("$OFS", "$,");
    globals.alias("$OUTPUT_FIELD_SEPARATOR", "$,");
    globals.alias("$RS", "$/");
    globals.alias("$INPUT_RECORD_SEPARATOR", "$/");
    globals.alias("$ORS", "$\\");
    globals.alias("$OUTPUT_RECORD_SEPARATOR", "$\\");
    globals.alias("$NR", "$.");
    globals.alias("$INPUT_LINE_NUMBER", "$.");
    globals.alias("$LAST_READ_LINE", "$_");
    globals.alias("$DEFAULT_OUTPUT", "$>");
    globals.alias("$DEFAULT_INPUT", "$<");
    globals.alias("$PID", "$$");
    globals.alias("$PROCESS_ID", "$$");
    globals.alias("$CHILD_STATUS", "$?");
    globals.alias("$LAST_MATCH_INFO", "$~");
    globals.alias("$IGNORECASE", "$=");
    globals.alias("$ARGV", "$*");
    globals.alias("$MATCH", "$&");
    globals.alias("$PREMATCH", "$`");
    globals.alias("$POSTMATCH", "$'");
    globals.alias("$LAST_PAREN_MATCH", "$+");
  }