Skip to content

Commit

Permalink
Added global this for eval
Browse files Browse the repository at this point in the history
  • Loading branch information
ackava committed Nov 3, 2024
1 parent f6a9d47 commit ef60b47
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 85 deletions.
9 changes: 3 additions & 6 deletions YantraJS.Core/Core/JSContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -692,21 +692,18 @@ internal ConcurrentDictionary<long, JSPromise> PendingPromises
/// <returns></returns>
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);
Expand Down
158 changes: 79 additions & 79 deletions YantraJS.Core/YantraJS.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,79 +1,79 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
<AssemblyName>YantraJS.Core</AssemblyName>
<PackageId>YantraJS.Core</PackageId>
<PackageTags>yantra,yantrajs,javascript,c#,standard,core,framework,.net</PackageTags>
<Description>JavaScript Engine Core for .NET Standard</Description>
<PackageProjectUrl>http://yantrajs.com/</PackageProjectUrl>
<RepositoryUrl>https://github.com/yantrajs/yantra</RepositoryUrl>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Version>1.0.1</Version>
<LangVersion>latest</LangVersion>
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<EmbedAllSources>True</EmbedAllSources>
<DebugType>embedded</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>

<PropertyGroup>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<CompilerGeneratedFilesOutputPath>Generated</CompilerGeneratedFilesOutputPath>
</PropertyGroup>
<Target Name="AddSourceGeneratedFiles" AfterTargets="CoreCompile">
<ItemGroup>
<Compile Include="Generated\**" />
</ItemGroup>
</Target>
<Target Name="RemoveSourceGeneratedFiles" BeforeTargets="CoreCompile">
<ItemGroup>
<Compile Remove="Generated\**" />
</ItemGroup>
</Target>

<!-- <ItemGroup>
<Compile Include="..\esprima-dotnet\src\Esprima\*.cs">
<Link>Esprima\%(RecursiveDir)%(FileName)%(Extension)</Link>
</Compile>
<Compile Include="..\esprima-dotnet\src\Esprima\Ast\*.cs">
<Link>Esprima\Ast\%(RecursiveDir)%(FileName)%(Extension)</Link>
</Compile>
<Compile Include="..\esprima-dotnet\src\Esprima\Utils\*.cs">
<Link>Esprima\Utils\%(RecursiveDir)%(FileName)%(Extension)</Link>
</Compile>
</ItemGroup> -->

<ItemGroup>
<PackageReference Include="ErrorProne.NET.Structs" Version="0.3.0-beta.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="System.Text.Json" Version="8.0.5" />
<PackageReference Include="System.Reflection.Emit.Lightweight" Version="4.7.0" />
<PackageReference Include="System.Runtime" Version="4.3.1" />
<PackageReference Include="Nerdbank.GitVersioning" Version="3.6.143">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\YantraJS.ExpressionCompiler\YantraJS.ExpressionCompiler.csproj" />
<ProjectReference Include="..\YantraJS.JSClassGenerator\YantraJS.JSClassGenerator.csproj" ReferenceOutputAssembly="false" OutputItemType="Analyzer" />
</ItemGroup>

<ItemGroup>
<Reference Include="Microsoft.Build.Tasks.v4.0">
<HintPath>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Microsoft.Build.Tasks.v4.0.dll</HintPath>
</Reference>
</ItemGroup>

</Project>
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
<AssemblyName>YantraJS.Core</AssemblyName>
<PackageId>YantraJS.Core</PackageId>
<PackageTags>yantra,yantrajs,javascript,c#,standard,core,framework,.net</PackageTags>
<Description>JavaScript Engine Core for .NET Standard</Description>
<PackageProjectUrl>http://yantrajs.com/</PackageProjectUrl>
<RepositoryUrl>https://github.com/yantrajs/yantra</RepositoryUrl>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Version>1.0.1</Version>
<LangVersion>latest</LangVersion>
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<EmbedAllSources>True</EmbedAllSources>
<DebugType>embedded</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>

<PropertyGroup>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<CompilerGeneratedFilesOutputPath>Generated</CompilerGeneratedFilesOutputPath>
</PropertyGroup>
<Target Name="AddSourceGeneratedFiles" AfterTargets="CoreCompile">
<ItemGroup>
<Compile Include="Generated\**" />
</ItemGroup>
</Target>
<Target Name="RemoveSourceGeneratedFiles" BeforeTargets="CoreCompile">
<ItemGroup>
<Compile Remove="Generated\**" />
</ItemGroup>
</Target>

<!-- <ItemGroup>
<Compile Include="..\esprima-dotnet\src\Esprima\*.cs">
<Link>Esprima\%(RecursiveDir)%(FileName)%(Extension)</Link>
</Compile>
<Compile Include="..\esprima-dotnet\src\Esprima\Ast\*.cs">
<Link>Esprima\Ast\%(RecursiveDir)%(FileName)%(Extension)</Link>
</Compile>
<Compile Include="..\esprima-dotnet\src\Esprima\Utils\*.cs">
<Link>Esprima\Utils\%(RecursiveDir)%(FileName)%(Extension)</Link>
</Compile>
</ItemGroup> -->

<ItemGroup>
<PackageReference Include="ErrorProne.NET.Structs" Version="0.3.0-beta.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="System.Text.Json" Version="8.0.5" />
<PackageReference Include="System.Reflection.Emit.Lightweight" Version="4.7.0" />
<PackageReference Include="System.Runtime" Version="4.3.1" />
<PackageReference Include="Nerdbank.GitVersioning" Version="3.6.143">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\YantraJS.ExpressionCompiler\YantraJS.ExpressionCompiler.csproj" />
<ProjectReference Include="..\YantraJS.JSClassGenerator\YantraJS.JSClassGenerator.csproj" ReferenceOutputAssembly="false" OutputItemType="Analyzer" />
</ItemGroup>

<ItemGroup>
<Reference Include="Microsoft.Build.Tasks.v4.0">
<HintPath>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Microsoft.Build.Tasks.v4.0.dll</HintPath>
</Reference>
</ItemGroup>

</Project>

0 comments on commit ef60b47

Please sign in to comment.