From ef60b4738c2336398d2c9a20a4d52bb956577e89 Mon Sep 17 00:00:00 2001 From: Akash Kava <39438041+ackava@users.noreply.github.com> Date: Sun, 3 Nov 2024 14:19:35 +0530 Subject: [PATCH] Added global this for eval --- YantraJS.Core/Core/JSContext.cs | 9 +- YantraJS.Core/YantraJS.Core.csproj | 158 ++++++++++++++--------------- 2 files changed, 82 insertions(+), 85 deletions(-) diff --git a/YantraJS.Core/Core/JSContext.cs b/YantraJS.Core/Core/JSContext.cs index bbb31491..ea2cf19b 100644 --- a/YantraJS.Core/Core/JSContext.cs +++ b/YantraJS.Core/Core/JSContext.cs @@ -692,21 +692,18 @@ internal ConcurrentDictionary PendingPromises /// public JSValue Eval(string code, string codeFilePath = null, JSValue @this = null) { + @this ??= this; if (Debugger == null) { var fx = CoreScript.Compile(code, codeFilePath, codeCache: CodeCache); - return @this == null - ? fx(in Arguments.Empty) - : fx(new Arguments(@this)); + return fx(new Arguments(@this)); } try { var f = CoreScript.Compile(code, codeFilePath, codeCache: CodeCache); Debugger.ScriptParsed(this.ID, code, codeFilePath); - return @this == null - ? f(in Arguments.Empty) - : f(new Arguments(@this)); + return f(new Arguments(@this)); } catch (Exception ex) { this.ReportError(ex); diff --git a/YantraJS.Core/YantraJS.Core.csproj b/YantraJS.Core/YantraJS.Core.csproj index 874635da..fb2eb00f 100644 --- a/YantraJS.Core/YantraJS.Core.csproj +++ b/YantraJS.Core/YantraJS.Core.csproj @@ -1,79 +1,79 @@ - - - - netstandard2.0;netstandard2.1 - YantraJS.Core - YantraJS.Core - yantra,yantrajs,javascript,c#,standard,core,framework,.net - JavaScript Engine Core for .NET Standard - http://yantrajs.com/ - https://github.com/yantrajs/yantra - true - 1.0.1 - latest - $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb - Apache-2.0 - true - snupkg - True - embedded - true - - - - true - Generated - - - - - - - - - - - - - - - - - all - runtime; build; native; contentfiles; analyzers - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - all - runtime; build; native; contentfiles; analyzers - - - - - - - - - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Microsoft.Build.Tasks.v4.0.dll - - - - + + + + netstandard2.0;netstandard2.1 + YantraJS.Core + YantraJS.Core + yantra,yantrajs,javascript,c#,standard,core,framework,.net + JavaScript Engine Core for .NET Standard + http://yantrajs.com/ + https://github.com/yantrajs/yantra + true + 1.0.1 + latest + $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb + Apache-2.0 + true + snupkg + True + embedded + true + + + + true + Generated + + + + + + + + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + all + runtime; build; native; contentfiles; analyzers + + + + + + + + + + + C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Microsoft.Build.Tasks.v4.0.dll + + + +