Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 5d6b60fac77c
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 4f96f3556c9b
Choose a head ref
  • 5 commits
  • 31 files changed
  • 1 contributor

Commits on Dec 2, 2016

  1. Copy the full SHA
    ee0b534 View commit details
  2. Copy the full SHA
    dc380c4 View commit details
  3. Copy the full SHA
    2432ff4 View commit details
  4. Copy the full SHA
    9da1532 View commit details
  5. Copy the full SHA
    4f96f35 View commit details
Showing with 692 additions and 384 deletions.
  1. +2 −2 core/src/main/java/org/jruby/Main.java
  2. +2 −2 core/src/main/java/org/jruby/lexer/yacc/RubyLexer.java
  3. +1 −4 core/src/main/java/org/jruby/parser/ParserSupport.java
  4. +0 −93 core/src/main/java/org/jruby/util/cli/Options.java
  5. +20 −6 tool/truffle/generate-options.rb
  6. +93 −2 tool/truffle/options.yml
  7. +4 −2 truffle/src/main/java/org/jruby/truffle/Main.java
  8. +0 −183 truffle/src/main/java/org/jruby/truffle/Options.java
  9. +6 −10 truffle/src/main/java/org/jruby/truffle/RubyContext.java
  10. +2 −3 truffle/src/main/java/org/jruby/truffle/RubyEngine.java
  11. +1 −1 truffle/src/main/java/org/jruby/truffle/builtins/CoreMethodNodeManager.java
  12. +9 −6 truffle/src/main/java/org/jruby/truffle/core/CoreMethods.java
  13. +1 −1 truffle/src/main/java/org/jruby/truffle/core/encoding/EncodingNodes.java
  14. +4 −3 truffle/src/main/java/org/jruby/truffle/core/thread/ThreadManager.java
  15. +3 −2 truffle/src/main/java/org/jruby/truffle/language/LazyRubyRootNode.java
  16. +3 −1 truffle/src/main/java/org/jruby/truffle/language/PerformanceWarnings.java
  17. +1 −1 truffle/src/main/java/org/jruby/truffle/language/TruffleBootNodes.java
  18. +1 −1 truffle/src/main/java/org/jruby/truffle/language/backtrace/BacktraceFormatter.java
  19. +3 −1 truffle/src/main/java/org/jruby/truffle/language/globals/GlobalVariableStorage.java
  20. +5 −5 truffle/src/main/java/org/jruby/truffle/language/methods/ExceptionTranslatingNode.java
  21. +6 −5 truffle/src/main/java/org/jruby/truffle/language/objects/shared/SharedObjects.java
  22. +5 −3 truffle/src/main/java/org/jruby/truffle/options/BooleanOptionDescription.java
  23. +41 −0 truffle/src/main/java/org/jruby/truffle/options/IntegerOptionDescription.java
  24. +0 −29 truffle/src/main/java/org/jruby/truffle/options/NewOptions.java
  25. +181 −0 truffle/src/main/java/org/jruby/truffle/options/Options.java
  26. +31 −10 truffle/src/main/java/org/jruby/truffle/options/OptionsBuilder.java
  27. +228 −0 truffle/src/main/java/org/jruby/truffle/options/OptionsCatalog.java
  28. +3 −3 truffle/src/main/java/org/jruby/truffle/options/StringArrayOptionDescription.java
  29. +31 −0 truffle/src/main/java/org/jruby/truffle/options/StringOptionDescription.java
  30. +2 −2 truffle/src/main/java/org/jruby/truffle/parser/lexer/RubyLexer.java
  31. +3 −3 truffle/src/main/java/org/jruby/truffle/parser/parser/ParserSupport.java
4 changes: 2 additions & 2 deletions core/src/main/java/org/jruby/Main.java
Original file line number Diff line number Diff line change
@@ -658,14 +658,14 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl
}

public static void printTruffleTimeMetric(String id) {
if (Options.TRUFFLE_METRICS_TIME.load()) {
if (Boolean.getBoolean("jruby.truffle.metrics.time")) {
final long millis = System.currentTimeMillis();
System.err.printf("%s %d.%03d%n", id, millis / 1000, millis % 1000);
}
}

private static void printTruffleMemoryMetric() {
if (Options.TRUFFLE_METRICS_MEMORY_USED_ON_EXIT.load()) {
if (Boolean.getBoolean("jruby.truffle.metrics.memory_used_on_exit")) {
for (int n = 0; n < 10; n++) {
System.gc();
}
4 changes: 2 additions & 2 deletions core/src/main/java/org/jruby/lexer/yacc/RubyLexer.java
Original file line number Diff line number Diff line change
@@ -655,7 +655,7 @@ private int hereDocumentIdentifier() throws IOException {
}

private boolean arg_ambiguous() {
if (warnings.isVerbose() && Options.PARSER_WARN_AMBIGUOUS_ARGUMENTS.load() && !ParserSupport.skipTruffleRubiniusWarnings(this)) {
if (warnings.isVerbose() && Options.PARSER_WARN_AMBIGUOUS_ARGUMENTS.load()) {
warnings.warning(ID.AMBIGUOUS_ARGUMENT, getPosition(), "Ambiguous first argument; make sure.");
}
return true;
@@ -1976,7 +1976,7 @@ private int star(boolean spaceSeen) throws IOException {
default:
pushback(c);
if (isSpaceArg(c, spaceSeen)) {
if (warnings.isVerbose() && Options.PARSER_WARN_ARGUMENT_PREFIX.load() && !ParserSupport.skipTruffleRubiniusWarnings(this))
if (warnings.isVerbose() && Options.PARSER_WARN_ARGUMENT_PREFIX.load())
warnings.warning(ID.ARGUMENT_AS_PREFIX, getPosition(), "`*' interpreted as argument prefix");
c = Tokens.tSTAR;
} else if (isBEG()) {
5 changes: 1 addition & 4 deletions core/src/main/java/org/jruby/parser/ParserSupport.java
Original file line number Diff line number Diff line change
@@ -1219,7 +1219,7 @@ public String shadowing_lvar(String name) {
if (current.exists(name) >= 0) yyerror("duplicated argument name");

if (current.isBlockScope() && warnings.isVerbose() && current.isDefined(name) >= 0 &&
Options.PARSER_WARN_LOCAL_SHADOWING.load() && !ParserSupport.skipTruffleRubiniusWarnings(lexer)) {
Options.PARSER_WARN_LOCAL_SHADOWING.load()) {
warnings.warning(ID.STATEMENT_NOT_REACHED, lexer.getPosition(), "shadowing outer local variable - " + name);
}

@@ -1478,7 +1478,4 @@ public String internalId() {
return "";
}

public static boolean skipTruffleRubiniusWarnings(RubyLexer lexer) {
return lexer.getFile().startsWith(Options.TRUFFLE_CORE_LOAD_PATH.load());
}
}
93 changes: 0 additions & 93 deletions core/src/main/java/org/jruby/util/cli/Options.java
Original file line number Diff line number Diff line change
@@ -227,99 +227,6 @@ public class Options {
public static final Option<Boolean> CLI_STRIP_HEADER = bool(CLI, "cli.strip.header", false, "Strip text before shebang in script. Same as -x.");
public static final Option<Boolean> CLI_LOAD_GEMFILE = bool(CLI, "cli.load.gemfile", false, "Load a bundler Gemfile in cwd before running. Same as -G.");

public static final Option<Boolean> TRUFFLE_PLATFORM_SAFE = bool(TRUFFLE, "truffle.platform.safe", true, "Default value for the safety of all operations.");
public static final Option<Boolean> TRUFFLE_PLATFORM_SAFE_LOAD = bool(TRUFFLE, "truffle.platform.safe.load", TRUFFLE_PLATFORM_SAFE.load(), "Treat loading, requiring and autoloading as safe.");
public static final Option<Boolean> TRUFFLE_PLATFORM_SAFE_IO = bool(TRUFFLE, "truffle.platform.safe.io", TRUFFLE_PLATFORM_SAFE.load(), "Treat any methods that deal with IO as safe.");
public static final Option<Boolean> TRUFFLE_PLATFORM_SAFE_MEMORY = bool(TRUFFLE, "truffle.platform.safe.memory", TRUFFLE_PLATFORM_SAFE.load(), "Treat any methods that deal with unmanaged memory as safe.");
public static final Option<Boolean> TRUFFLE_PLATFORM_SAFE_THREADS = bool(TRUFFLE, "truffle.platform.safe.threads", TRUFFLE_PLATFORM_SAFE.load(), "Treat any methods that deal with threads as safe.");
public static final Option<Boolean> TRUFFLE_PLATFORM_SAFE_PROCESSES = bool(TRUFFLE, "truffle.platform.safe.processes", TRUFFLE_PLATFORM_SAFE.load(), "Treat any methods that deal with processes as safe.");
public static final Option<Boolean> TRUFFLE_PLATFORM_SAFE_SIGNALS = bool(TRUFFLE, "truffle.platform.safe.siganls", TRUFFLE_PLATFORM_SAFE.load(), "Treat any methods that deal with signals as safe.");
public static final Option<Boolean> TRUFFLE_PLATFORM_SAFE_EXIT = bool(TRUFFLE, "truffle.platform.safe.exit", TRUFFLE_PLATFORM_SAFE.load(), "Treat #exit! (hard exiting the VM) as safe.");
public static final Option<Boolean> TRUFFLE_PLATFORM_SAFE_AT_EXIT = bool(TRUFFLE, "truffle.platform.safe.at_exit", TRUFFLE_PLATFORM_SAFE.load(), "Treat #at_exit as safe.");
public static final Option<Boolean> TRUFFLE_PLATFORM_SAFE_PUTS = bool(TRUFFLE, "truffle.platform.safe_puts", true, "Treat Truffle.safe_puts as safe.");
public static final Option<Boolean> TRUFFLE_PLATFORM_USE_JAVA = bool(TRUFFLE, "truffle.platform.use_java", false, "Use a pure-Java platform, so no native POSIX.");

public static final Option<Boolean> TRUFFLE_COVERAGE_GLOBAL = bool(TRUFFLE, "truffle.coverage.global", false, "Run coverage for all code and print results on exit.");
public static final Option<Boolean> TRUFFLE_INLINE_JS = bool(TRUFFLE, "truffle.inline_js", false, "Allow inline JavaScript.");

public static final Option<String> TRUFFLE_CORE_LOAD_PATH = string(TRUFFLE, "truffle.core.load_path", "truffle:/jruby-truffle", "Location to load the Truffle core library from.");
public static final Option<Boolean> TRUFFLE_CORE_PARALLEL_LOAD = bool(TRUFFLE, "truffle.core.parallel_load", false, "Load the Truffle core library in parallel.");

public static final Option<Integer> TRUFFLE_ARRAY_UNINITIALIZED_SIZE = integer(TRUFFLE, "truffle.array.uninitialized_size", 32, "How large an Array to allocate when we have no other information to go on.");
public static final Option<Integer> TRUFFLE_ARRAY_SMALL = integer(TRUFFLE, "truffle.array.small", 3, "Maximum size of an Array to consider small for optimisations.");
public static final Option<Integer> TRUFFLE_HASH_PACKED_ARRAY_MAX = integer(TRUFFLE, "truffle.hash.packed_array.max", 3, "Maximum size of a Hash to consider using the packed array storage strategy for.");

public static final Option<Boolean> TRUFFLE_ROPE_LAZY_SUBSTRINGS = bool(TRUFFLE, "truffle.rope.lazy_substrings", true, "Indicates whether a substring operation on a rope should be performed lazily.");
public static final Option<Boolean> TRUFFLE_ROPE_PRINT_INTERN_STATS = bool(TRUFFLE, "truffle.rope.print_intern_stats", false, "Print interned rope stats at application exit.");

public static final Option<Integer> TRUFFLE_GLOBAL_VARIABLE_MAX_INVALIDATIONS = integer(TRUFFLE, "truffle.global_variable.max_invalidations", 10,
"Maximum number of times a global variable can be changed to be considered constant.");

public static final Option<Integer> TRUFFLE_DEFAULT_CACHE = integer(TRUFFLE, "truffle.default_cache", 8, "Default size for caches.");

public static final Option<Integer> TRUFFLE_METHOD_LOOKUP_CACHE = integer(TRUFFLE, "truffle.method_lookup.cache", TRUFFLE_DEFAULT_CACHE.load(), "Method lookup cache size.");
public static final Option<Integer> TRUFFLE_DISPATCH_CACHE = integer(TRUFFLE, "truffle.dispatch.cache", TRUFFLE_DEFAULT_CACHE.load(), "Dispatch (various forms of method call) cache size.");
public static final Option<Integer> TRUFFLE_YIELD_CACHE = integer(TRUFFLE, "truffle.yield.cache", TRUFFLE_DEFAULT_CACHE.load(), "Yield cache size.");
public static final Option<Integer> TRUFFLE_METHOD_TO_PROC_CACHE = integer(TRUFFLE, "truffle.to_proc.cache", TRUFFLE_DEFAULT_CACHE.load(), "Method#to_proc cache size.");
public static final Option<Integer> TRUFFLE_IS_A_CACHE = integer(TRUFFLE, "truffle.is_a.cache", TRUFFLE_DEFAULT_CACHE.load(), "Kernel#is_a? and #kind_of? cache size.");
public static final Option<Integer> TRUFFLE_BIND_CACHE = integer(TRUFFLE, "truffle.bind.cache", TRUFFLE_DEFAULT_CACHE.load(), "Cache size of test for being able to bind a method to a module.");
public static final Option<Integer> TRUFFLE_CONSTANT_CACHE = integer(TRUFFLE, "truffle.constant.cache", TRUFFLE_DEFAULT_CACHE.load(), "Constant cache size.");
public static final Option<Integer> TRUFFLE_INSTANCE_VARIABLE_CACHE = integer(TRUFFLE, "truffle.instance_variable.cache", TRUFFLE_DEFAULT_CACHE.load(), "Instance variable cache size.");
public static final Option<Integer> TRUFFLE_BINDING_LOCAL_VARIABLE_CACHE = integer(TRUFFLE, "truffle.binding_local_variable.cache", TRUFFLE_DEFAULT_CACHE.load(), "Binding#local_variable_get/set cache size.");
public static final Option<Integer> TRUFFLE_SYMBOL_TO_PROC_CACHE = integer(TRUFFLE, "truffle.symbol_to_proc.cache", TRUFFLE_DEFAULT_CACHE.load(), "Symbol#to_proc cache size.");
public static final Option<Integer> TRUFFLE_ALLOCATE_CLASS_CACHE = integer(TRUFFLE, "truffle.allocate_class.cache", TRUFFLE_DEFAULT_CACHE.load(), "Allocation size class cache size.");
public static final Option<Integer> TRUFFLE_PACK_CACHE = integer(TRUFFLE, "truffle.pack.cache", TRUFFLE_DEFAULT_CACHE.load(), "Array#pack cache size.");
public static final Option<Integer> TRUFFLE_UNPACK_CACHE = integer(TRUFFLE, "truffle.unpack.cache", TRUFFLE_DEFAULT_CACHE.load(), "String#unpack cache size.");
public static final Option<Integer> TRUFFLE_EVAL_CACHE = integer(TRUFFLE, "truffle.eval.cache", TRUFFLE_DEFAULT_CACHE.load(), "eval cache size.");
public static final Option<Integer> TRUFFLE_CLASS_CACHE = integer(TRUFFLE, "truffle.class.cache", TRUFFLE_DEFAULT_CACHE.load(), ".class and .metaclass cache size.");
public static final Option<Integer> TRUFFLE_ENCODING_COMPATIBLE_QUERY_CACHE = integer(TRUFFLE, "truffle.encoding_compatible_query.cache", TRUFFLE_DEFAULT_CACHE.load(), "Encoding.compatible? cache size.");
public static final Option<Integer> TRUFFLE_ENCODING_LOADED_CLASSES_CACHE = integer(TRUFFLE, "truffle.encoding_loaded_classes.cache", TRUFFLE_DEFAULT_CACHE.load(), "Cache size of encoding operations based on anticipated number of total active encodings.");
public static final Option<Integer> TRUFFLE_THREAD_CACHE = integer(TRUFFLE, "truffle.thread.cache", TRUFFLE_DEFAULT_CACHE.load(), "Cache size of operations that depend on a particular thread.");
public static final Option<Integer> TRUFFLE_ROPE_CLASS_CACHE = integer(TRUFFLE, "truffle.rope_class.cache", 6, "Cache size for rope operations that depend on a concrete rope implementation to avoid virtual calls.");
public static final Option<Integer> TRUFFLE_INTEROP_CONVERT_CACHE = integer(TRUFFLE, "truffle.interop.convert.cache", TRUFFLE_DEFAULT_CACHE.load(), "Cache size for converting values for interop.");
public static final Option<Integer> TRUFFLE_INTEROP_EXECUTE_CACHE = integer(TRUFFLE, "truffle.interop.execute.cache", TRUFFLE_DEFAULT_CACHE.load(), "Cache size for interop EXECUTE messages.");
public static final Option<Integer> TRUFFLE_INTEROP_READ_CACHE = integer(TRUFFLE, "truffle.interop.read.cache", TRUFFLE_DEFAULT_CACHE.load(), "Cache size for interop READ messages.");
public static final Option<Integer> TRUFFLE_INTEROP_WRITE_CACHE = integer(TRUFFLE, "truffle.interop.write.cache", TRUFFLE_DEFAULT_CACHE.load(), "Cache size for interop WRITE messages.");
public static final Option<Integer> TRUFFLE_INTEROP_INVOKE_CACHE = integer(TRUFFLE, "truffle.interop.invoke.cache", TRUFFLE_DEFAULT_CACHE.load(), "Cache size for interop INVOKE messages.");

public static final Option<Boolean> TRUFFLE_CLONE_DEFAULT = bool(TRUFFLE, "truffle.clone.default", true, "Default option for cloning.");
public static final Option<Boolean> TRUFFLE_INLINE_DEFAULT = bool(TRUFFLE, "truffle.inline.default", true, "Default option for inlining.");
public static final Option<Boolean> TRUFFLE_CORE_ALWAYS_CLONE = bool(TRUFFLE, "truffle.core.always_clone", TRUFFLE_CLONE_DEFAULT.load(), "Always clone built-in core methods.");
public static final Option<Boolean> TRUFFLE_INLINE_NEEDS_CALLER_FRAME = bool(TRUFFLE, "truffle.inline_needs_caller_frame", TRUFFLE_INLINE_DEFAULT.load(), "Inline methods that need their caller frame.");
public static final Option<Boolean> TRUFFLE_YIELD_ALWAYS_CLONE = bool(TRUFFLE, "truffle.yield.always_clone", TRUFFLE_CLONE_DEFAULT.load(), "Always clone yields.");
public static final Option<Boolean> TRUFFLE_YIELD_ALWAYS_INLINE = bool(TRUFFLE, "truffle.yield.always_inline", TRUFFLE_INLINE_DEFAULT.load(), "Always inline yields.");
public static final Option<Boolean> TRUFFLE_METHODMISSING_ALWAYS_CLONE = bool(TRUFFLE, "truffle.method_missing.always_clone", TRUFFLE_CLONE_DEFAULT.load(), "Always clone #method_missing.");
public static final Option<Boolean> TRUFFLE_METHODMISSING_ALWAYS_INLINE = bool(TRUFFLE, "truffle.method_missing.always_inline", TRUFFLE_INLINE_DEFAULT.load(), "Always inline #method_missing.");

public static final Option<Integer> TRUFFLE_PACK_UNROLL_LIMIT = integer(TRUFFLE, "truffle.pack.unroll", 4, "If a pack or unpack expression has a loop less than this many iterations, unroll it.");
public static final Option<Integer> TRUFFLE_PACK_RECOVER_LOOP_MIN = integer(TRUFFLE, "truffle.pack.recover", 32, "If a pack or unpack expression is longer than this, attempt to recover loops.");

public static final Option<Integer> TRUFFLE_INSTRUMENTATION_SERVER_PORT = integer(TRUFFLE, "truffle.instrumentation_server_port", 0, "Port number to run an HTTP server on that provides instrumentation services");
public static final Option<Boolean> TRUFFLE_EXCEPTIONS_STORE_JAVA = bool(TRUFFLE, "truffle.exceptions.store_java", false, "Store the Java exception with the Ruby backtrace");
//public static final Option<Boolean> TRUFFLE_EXCEPTIONS_PRINT_JAVA = bool(TRUFFLE, "truffle.exceptions.print_java", false, "Print Java exceptions at the point of translating them to Ruby exceptions.");
public static final Option<Boolean> TRUFFLE_EXCEPTIONS_PRINT_UNCAUGHT_JAVA = bool(TRUFFLE, "truffle.exceptions.print_uncaught_java", false, "Print uncaught Java exceptions at the point of translating them to Ruby exceptions.");
public static final Option<Boolean> TRUFFLE_BACKTRACES_HIDE_CORE_FILES = bool(TRUFFLE, "truffle.backtraces.hide_core_files", true, "Hide core source files in backtraces, like MRI does.");
public static final Option<Boolean> TRUFFLE_BACKTRACES_INTERLEAVE_JAVA = bool(TRUFFLE, "truffle.backtraces.interleave_java", false, "Interleave Java stacktraces into the Ruby backtrace.");
public static final Option<Integer> TRUFFLE_BACKTRACES_LIMIT = integer(TRUFFLE, "truffle.backtraces.limit", 9999, "Limit the size of Ruby backtraces.");
public static final Option<Boolean> TRUFFLE_BACKTRACES_OMIT_UNUSED = bool(TRUFFLE, "truffle.backtraces.omit_unused", true, "Omit backtraces that should be unused as they have pure rescue expressions.");
public static final Option<Boolean> TRUFFLE_BASICOPS_INLINE = bool(TRUFFLE, "truffle.basic_ops.inline", true, "Inline basic operations (like Fixnum operators) in the AST without a call.");

public static final Option<Boolean> TRUFFLE_METRICS_TIME = bool(TRUFFLE, "truffle.metrics.time", false, "Print the time at various stages of VM operation.");
public static final Option<Boolean> TRUFFLE_METRICS_MEMORY_USED_ON_EXIT = bool(TRUFFLE, "truffle.metrics.memory_used_on_exit", false, "Print the size of heap memory in use on exit.");
public static final Option<Boolean> TRUFFLE_CALL_GRAPH = bool(TRUFFLE, "truffle.callgraph", false, "Maintain a call graph.");
public static final Option<String> TRUFFLE_CALL_GRAPH_WRITE = string(TRUFFLE, "truffle.callgraph.write", "File to write the call garph to on exit.");
public static final Option<Boolean> TRUFFLE_CHAOS = bool(TRUFFLE, "truffle.chaos", false, "Randomly modify the representation of objects.");

public static final Option<Boolean> TRUFFLE_GRAAL_WARNING_UNLESS = bool(TRUFFLE, "truffle.graal.warn_unless", true, "Warn unless the JVM has the Graal compiler.");
public static final Option<Boolean> TRUFFLE_PERF_WARNING = bool(TRUFFLE, "truffle.perf.warn", false, "Warn when using a fature which is not optimized yet.");

public static final Option<Boolean> TRUFFLE_SHARED_OBJECTS_ENABLED = bool(TRUFFLE, "truffle.shared.objects", true, "Enable shared objects.");
public static final Option<Boolean> TRUFFLE_SHARED_OBJECTS_DEBUG = bool(TRUFFLE, "truffle.shared.objects.debug", false, "Print information about shared objects.");
public static final Option<Boolean> TRUFFLE_SHARED_OBJECTS_FORCE = bool(TRUFFLE, "truffle.shared.objects.force", false, "Force sharing of objects roots at startup.");
public static final Option<Boolean> TRUFFLE_SHARED_OBJECTS_SHARE_ALL = bool(TRUFFLE, "truffle.shared.objects.share_all", false, "Consider all objects as shared.");

public static final Option<Boolean> TRUFFLE_CEXTS_LOG_LOAD = bool(TRUFFLE, "truffle.cexts.log.load", false, "Log loading of cexts.");

public static String dump() {
return "# JRuby configuration options with current values\n" +
Option.formatValues(_loadedOptions);
26 changes: 20 additions & 6 deletions tool/truffle/generate-options.rb
Original file line number Diff line number Diff line change
@@ -20,25 +20,39 @@
type = 'boolean'
type_cons = 'BooleanOptionDescription'
default = default.to_s
null_default = false
when 'integer'
type = 'int'
type_cons = 'IntegerOptionDescription'
default = default.to_s
null_default = 0
when 'string'
type = 'String'
type_cons = 'StringOptionDescription'
default = default.nil? ? 'null' : "\"#{default.to_s}\""
null_default = 'null'
when 'string-array'
type = 'String[]'
type_cons = 'StringArrayOptionDescription'
default = "new String[]{#{default.map(&:inspect).join(', ')}}"
null_default = 'null'
else
raise type
raise type.to_s
end

OpenStruct.new(
:constant => constant,
:name => name,
:type => type,
:default => default,
:reference_default => /[A-Z]/.match(default[0]),
:null_default => null_default,
:description => description,
:type_cons => type_cons
)
end

File.write('truffle/src/main/java/org/jruby/truffle/options/NewOptions.java', ERB.new(<<JAVA).result)
File.write('truffle/src/main/java/org/jruby/truffle/options/Options.java', ERB.new(<<JAVA).result)
/*
* Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved. This
* code is released under a tri EPL/GPL/LGPL license. You can use it,
@@ -57,12 +71,12 @@
import javax.annotation.Generated;
@Generated("tool/truffle/generate-options.rb")
public class NewOptions {
public class Options {
<% options.each do |o| %><% if o.type.end_with?('[]') %>@CompilationFinal(dimensions=1) <% end %>public final <%= o.type %> <%= o.constant %>;
<% end %>
NewOptions(OptionsBuilder builder) {
<% options.each do |o| %> <%= o.constant %> = builder.getOrDefault(OptionsCatalog.<%= o.constant %>);
Options(OptionsBuilder builder) {
<% options.each do |o| %> <%= o.constant %> = builder.getOrDefault(OptionsCatalog.<%= o.constant %><%= o.reference_default ? ', ' + o.default : '' %>);
<% end %>}
}
@@ -87,7 +101,7 @@
@Generated("tool/truffle/generate-options.rb")
public class OptionsCatalog {
<% options.each do |o| %>public static final OptionDescription <%= o.constant %> = new <%= o.type_cons %>("<%= o.name %>", "<%= o.description %>", <%= o.default %>);
<% options.each do |o| %>public static final OptionDescription <%= o.constant %> = new <%= o.type_cons %>("<%= o.name %>", "<%= o.description %>", <%= o.reference_default ? o.null_default : o.default %>);
<% end %>
public static OptionDescription fromName(String name) {
switch (name) {
Loading