Skip to content

Commit

Permalink
Address code review comments
Browse files Browse the repository at this point in the history
Add VERSION_ECMASCRIPT, which is clearer.
  • Loading branch information
gbrail committed Dec 15, 2024
1 parent 1352fc2 commit 8eb9871
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public class RhinoScriptEngine extends AbstractScriptEngine implements Compilabl
*/
public static final String OPTIMIZATION_LEVEL = "org.mozilla.javascript.optimization_level";

static final int DEFAULT_LANGUAGE_VERSION = Context.VERSION_ES6;
static final int DEFAULT_LANGUAGE_VERSION = Context.VERSION_ECMASCRIPT;
private static final int DEFAULT_OPT = 9;
private static final boolean DEFAULT_DEBUG = true;
private static final String DEFAULT_FILENAME = "eval";
Expand Down Expand Up @@ -326,7 +326,7 @@ protected boolean hasFeature(Context cx, int featureIndex) {

@Override
protected void onContextCreated(Context cx) {
cx.setLanguageVersion(Context.VERSION_ES6);
cx.setLanguageVersion(Context.VERSION_ECMASCRIPT);
cx.setOptimizationLevel(DEFAULT_OPT);
cx.setGeneratingDebug(DEFAULT_DEBUG);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public static void main(String[] args) {

main.attachTo(org.mozilla.javascript.tools.shell.Main.shellContextFactory);
try (Context cx = Context.enter()) {
cx.setLanguageVersion(Context.VERSION_ES6);
cx.setLanguageVersion(Context.VERSION_ECMASCRIPT);

Global global = org.mozilla.javascript.tools.shell.Main.getGlobal();
global.init(cx);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
public class ShellContextFactory extends ContextFactory {
private boolean strictMode;
private boolean warningAsError;
private int languageVersion = Context.VERSION_ES6;
private int languageVersion = Context.VERSION_ECMASCRIPT;
private int optimizationLevel;
private boolean generatingDebug;
private boolean allowReservedKeywords = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
public class CompilerEnvirons {
public CompilerEnvirons() {
errorReporter = DefaultErrorReporter.instance;
languageVersion = Context.VERSION_ES6;
languageVersion = Context.VERSION_ECMASCRIPT;
generateDebugInfo = true;
reservedKeywordAsIdentifier = true;
allowMemberExprAsFunctionName = false;
Expand Down
13 changes: 10 additions & 3 deletions rhino/src/main/java/org/mozilla/javascript/Context.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,22 @@ public class Context implements Closeable {
/** JavaScript 1.8 */
public static final int VERSION_1_8 = 180;

/**
* Old constant for ECMAScript 6 and after. This has been replaced with the more clearly-named
* {@link #VERSION_ECMASCRIPT}. Both constants have the same value, and this is retained for
* compatibility.
*/
public static final int VERSION_ES6 = 200;

/**
* ECMAScript 6 and after. Since around version 1.7, this has been used to denote most new
* language features.
* language features. This has the same value as {@link #VERSION_ES6}.
*
* <p>As of version 1.8, the Rhino community has no plans to continue adding new language
* versions, but instead plans to track the ECMAScript specification as it evolves and add new
* features in new versions of Rhino.
*/
public static final int VERSION_ES6 = 200;
public static final int VERSION_ECMASCRIPT = VERSION_ES6;

/**
* Controls behaviour of <code>Date.prototype.getYear()</code>. If <code>
Expand Down Expand Up @@ -407,7 +414,7 @@ protected Context(ContextFactory factory) {
throw new IllegalArgumentException("factory == null");
}
this.factory = factory;
version = VERSION_ES6;
version = VERSION_ECMASCRIPT;
optimizationLevel = codegenClass != null ? 0 : -1;
maximumInterpreterStackDepth = Integer.MAX_VALUE;
}
Expand Down

0 comments on commit 8eb9871

Please sign in to comment.