Skip to content

Commit

Permalink
[Truffle] Simplify the main program entry point.
Browse files Browse the repository at this point in the history
As part of our start-up we would initialize global variables in the JRuby runtime. However, the Truffle backend keeps track of those global variables already and we never need to fetch them from the other runtime.
  • Loading branch information
nirvdrum committed Oct 14, 2016
1 parent 64cb1a9 commit 239bcc6
Showing 1 changed file with 0 additions and 16 deletions.
16 changes: 0 additions & 16 deletions truffle/src/main/java/org/jruby/truffle/Main.java
Expand Up @@ -34,22 +34,6 @@ public static void main(String[] args) {
config.setCompileMode(RubyInstanceConfig.CompileMode.TRUFFLE);

if (in != null) {
// Global variables
IAccessor programName = new ValueAccessor(runtime.newString(filename));
runtime.getGlobalVariables().define("$PROGRAM_NAME", programName, GlobalVariable.Scope.GLOBAL);
runtime.getGlobalVariables().define("$0", programName, GlobalVariable.Scope.GLOBAL);

for (Map.Entry<String, String> entry : config.getOptionGlobals().entrySet()) {
final IRubyObject varvalue;
if (entry.getValue() != null) {
varvalue = runtime.newString(entry.getValue());
} else {
varvalue = runtime.getTrue();
}

runtime.getGlobalVariables().set("$" + entry.getKey(), varvalue);
}

int exitCode = runtime.getTruffleContext().execute(filename);
System.exit(exitCode);
}
Expand Down

0 comments on commit 239bcc6

Please sign in to comment.