Skip to content

Commit

Permalink
Correct static field naming
Browse files Browse the repository at this point in the history
  • Loading branch information
adams85 committed Mar 30, 2024
1 parent 1639545 commit 25b2087
Show file tree
Hide file tree
Showing 13 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion Jint.Benchmark/EngineComparisonBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class EngineComparisonBenchmark
[GlobalSetup]
public void Setup()
{
var javaScriptParser = new Parser(Engine.s_defaultParserOptions);
var javaScriptParser = new Parser(Engine.BaseParserOptions);
foreach (var fileName in _files.Keys.ToList())
{
var script = File.ReadAllText($"Scripts/{fileName}.js");
Expand Down
2 changes: 1 addition & 1 deletion Jint.Benchmark/EngineConstructionBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class EngineConstructionBenchmark
[GlobalSetup]
public void GlobalSetup()
{
var parser = new Parser(Engine.s_defaultParserOptions);
var parser = new Parser(Engine.BaseParserOptions);
_program = parser.ParseScript("([].length + ''.length)");
_simple = parser.ParseScript("1");
new Engine().Evaluate(_program);
Expand Down
14 changes: 7 additions & 7 deletions Jint.Tests/Runtime/EngineTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1298,8 +1298,8 @@ public void ShouldExecuteDromaeoBase64()
public void ShouldExecuteKnockoutWithoutErrorWhetherTolerantOrIntolerant()
{
var content = GetEmbeddedFile("knockout-3.4.0.js");
_engine.Execute(content, Engine.s_defaultParserOptions with { Tolerant = true });
_engine.Execute(content, Engine.s_defaultParserOptions with { Tolerant = false });
_engine.Execute(content, Engine.BaseParserOptions with { Tolerant = true });
_engine.Execute(content, Engine.BaseParserOptions with { Tolerant = false });
}

[Fact]
Expand All @@ -1316,7 +1316,7 @@ public void ShouldNotAllowDuplicateProtoProperty()
{
var code = "if({ __proto__: [], __proto__:[] } instanceof Array) {}";

Exception ex = Assert.Throws<SyntaxErrorException>(() => _engine.Execute(code, Engine.s_defaultParserOptions with { Tolerant = false }));
Exception ex = Assert.Throws<SyntaxErrorException>(() => _engine.Execute(code, Engine.BaseParserOptions with { Tolerant = false }));
Assert.Contains("Duplicate __proto__ fields are not allowed in object literals", ex.Message);

ex = Assert.Throws<JavaScriptException>(() => _engine.Execute($"eval('{code}')"));
Expand Down Expand Up @@ -2946,7 +2946,7 @@ public void ExecuteWithSourceShouldTriggerBeforeEvaluateEvent()
public void ExecuteWithParserOptionsShouldTriggerBeforeEvaluateEvent()
{
TestBeforeEvaluateEvent(
(engine, code) => engine.Execute(code, Engine.s_defaultParserOptions),
(engine, code) => engine.Execute(code, Engine.BaseParserOptions),
expectedSource: "<anonymous>"
);
}
Expand All @@ -2955,7 +2955,7 @@ public void ExecuteWithParserOptionsShouldTriggerBeforeEvaluateEvent()
public void ExecuteWithSourceAndParserOptionsShouldTriggerBeforeEvaluateEvent()
{
TestBeforeEvaluateEvent(
(engine, code) => engine.Execute(code, "mysource", Engine.s_defaultParserOptions),
(engine, code) => engine.Execute(code, "mysource", Engine.BaseParserOptions),
expectedSource: "mysource"
);
}
Expand All @@ -2982,7 +2982,7 @@ public void EvaluateWithSourceShouldTriggerBeforeEvaluateEvent()
public void EvaluateWithParserOptionsShouldTriggerBeforeEvaluateEvent()
{
TestBeforeEvaluateEvent(
(engine, code) => engine.Evaluate(code, Engine.s_defaultParserOptions),
(engine, code) => engine.Evaluate(code, Engine.BaseParserOptions),
expectedSource: "<anonymous>"
);
}
Expand All @@ -2991,7 +2991,7 @@ public void EvaluateWithParserOptionsShouldTriggerBeforeEvaluateEvent()
public void EvaluateWithSourceAndParserOptionsShouldTriggerBeforeEvaluateEvent()
{
TestBeforeEvaluateEvent(
(engine, code) => engine.Evaluate(code, "mysource", Engine.s_defaultParserOptions),
(engine, code) => engine.Evaluate(code, "mysource", Engine.BaseParserOptions),
expectedSource: "mysource"
);
}
Expand Down
4 changes: 2 additions & 2 deletions Jint.Tests/Runtime/ErrorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ public void StackTraceCollectedForImmediatelyInvokedFunctionExpression()
return item;
})(getItem);";

var parserOptions = Engine.s_defaultParserOptions with
var parserOptions = Engine.BaseParserOptions with
{
Tolerant = true
};
Expand Down Expand Up @@ -385,7 +385,7 @@ public void CallStackWorksWithRecursiveCalls()
{
static ParserOptions CreateParserOptions()
{
return Engine.s_defaultParserOptions with
return Engine.BaseParserOptions with
{
Tolerant = true
};
Expand Down
10 changes: 2 additions & 8 deletions Jint/Engine.Ast.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ namespace Jint;

public partial class Engine
{
internal static readonly ParserOptions s_defaultParserOptions = ParserOptions.Default with
{
EcmaVersion = EcmaVersion.Experimental,
RegExpParseMode = RegExpParseMode.AdaptToInterpreted,
};

/// <summary>
/// Prepares a script for the engine that includes static analysis data to speed up execution during run-time.
/// </summary>
Expand All @@ -28,7 +22,7 @@ public partial class Engine
public static Script PrepareScript(string script, string? source = null, bool strict = false)
{
var astAnalyzer = new AstAnalyzer(new ScriptPreparationOptions());
var options = s_defaultParserOptions with
var options = BaseParserOptions with
{
AllowReturnOutsideFunction = true,
OnNode = astAnalyzer.NodeVisitor
Expand All @@ -46,7 +40,7 @@ public static Script PrepareScript(string script, string? source = null, bool st
public static Module PrepareModule(string script, string? source = null)
{
var astAnalyzer = new AstAnalyzer(new ScriptPreparationOptions());
var options = s_defaultParserOptions with
var options = BaseParserOptions with
{
OnNode = astAnalyzer.NodeVisitor
};
Expand Down
8 changes: 7 additions & 1 deletion Jint/Engine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ namespace Jint
[DebuggerTypeProxy(typeof(EngineDebugView))]
public sealed partial class Engine : IDisposable
{
internal static readonly ParserOptions BaseParserOptions = ParserOptions.Default with
{
EcmaVersion = EcmaVersion.Experimental,
RegExpParseMode = RegExpParseMode.AdaptToInterpreted,
};

private static readonly Options _defaultEngineOptions = new();

private readonly ParserOptions _defaultParserOptions;
Expand Down Expand Up @@ -146,7 +152,7 @@ private Engine(Options? options, Action<Engine, Options>? configure)
CallStack = new JintCallStack(Options.Constraints.MaxRecursionDepth >= 0);
_stackGuard = new StackGuard(this);

_defaultParserOptions = s_defaultParserOptions with
_defaultParserOptions = BaseParserOptions with
{
AllowReturnOutsideFunction = true,
RegexTimeout = Options.Constraints.RegexTimeout
Expand Down
2 changes: 1 addition & 1 deletion Jint/Native/Function/ClassDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ internal sealed class ClassDefinition

static ClassDefinition()
{
var parser = new Parser(Engine.s_defaultParserOptions);
var parser = new Parser(Engine.BaseParserOptions);

// generate missing constructor AST only once
static MethodDefinition CreateConstructorMethodDefinition(Parser parser, string source)
Expand Down
2 changes: 1 addition & 1 deletion Jint/Native/Function/EvalFunction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public sealed class EvalFunction : Function
{
private static readonly JsString _functionName = new("eval");

private static readonly ParserOptions _parserOptions = Engine.s_defaultParserOptions with
private static readonly ParserOptions _parserOptions = Engine.BaseParserOptions with
{
AllowNewTargetOutsideFunction = true,
AllowSuperOutsideMethod = true,
Expand Down
2 changes: 1 addition & 1 deletion Jint/Native/Function/FunctionInstance.Dynamic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ internal Function CreateDynamicFunction(
}
}

Parser parser = new Parser(Engine.s_defaultParserOptions with
Parser parser = new Parser(Engine.BaseParserOptions with
{
RegexTimeout = _engine.Options.Constraints.RegexTimeout
});
Expand Down
2 changes: 1 addition & 1 deletion Jint/Native/ShadowRealm/ShadowRealm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public sealed class ShadowRealm : ObjectInstance

internal ShadowRealm(Engine engine, ExecutionContext executionContext, Realm shadowRealm) : base(engine)
{
_parser = new(Engine.s_defaultParserOptions with
_parser = new(Engine.BaseParserOptions with
{
RegexTimeout = engine.Options.Constraints.RegexTimeout
});
Expand Down
2 changes: 1 addition & 1 deletion Jint/Runtime/Debugger/DebugHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public JsValue Evaluate(Script script)
/// <inheritdoc cref="Evaluate(Script)" />
public JsValue Evaluate(string source, ParserOptions? options = null)
{
options ??= Engine.s_defaultParserOptions;
options ??= Engine.BaseParserOptions;
var parser = new Parser(options);
try
{
Expand Down
2 changes: 1 addition & 1 deletion Jint/Runtime/Modules/ModuleBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ internal ModuleBuilder(Engine engine, string specifier)
{
_engine = engine;
_specifier = specifier;
_options = Engine.s_defaultParserOptions with
_options = Engine.BaseParserOptions with
{
RegexTimeout = engine.Options.Constraints.RegexTimeout
};
Expand Down
2 changes: 1 addition & 1 deletion Jint/Runtime/Modules/ModuleFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static Module BuildSourceTextModule(Engine engine, ResolvedSpecifier reso
Acornima.Ast.Module module;
try
{
module = new Parser(Engine.s_defaultParserOptions).ParseModule(code, source);
module = new Parser(Engine.BaseParserOptions).ParseModule(code, source);
}
catch (ParseErrorException ex)
{
Expand Down

0 comments on commit 25b2087

Please sign in to comment.