-
-
Notifications
You must be signed in to change notification settings - Fork 560
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve AOT usage scenarios with metadata (#1764)
* create AOT example project * set REPL for AOT publish * extract reflection related helpers from TypeConverter to InteropHelper
- Loading branch information
Showing
34 changed files
with
595 additions
and
406 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<IsPackable>false</IsPackable> | ||
<PublishAot>true</PublishAot> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Jint\Jint.csproj" /> | ||
<TrimmerRootAssembly Include="Jint" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using Jint; | ||
|
||
var engine = new Engine(cfg => cfg | ||
.AllowClr() | ||
); | ||
|
||
engine.SetValue("company", new Company()); | ||
|
||
Console.WriteLine($"Company's name: {engine.Evaluate("company.name")}"); | ||
Console.WriteLine($"Company's field: {engine.Evaluate("company.field")}"); | ||
Console.WriteLine($"Company's indexer: {engine.Evaluate("company[42]")}"); | ||
Console.WriteLine($"Company's greeting: {engine.Evaluate("company.sayHello('Mary')")}"); | ||
|
||
|
||
public class Company | ||
{ | ||
public string Field = "public field value"; | ||
public string Name => "Jint"; | ||
public string SayHello(string name) => $"Hello {name}!"; | ||
public int this[int index] => index; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
namespace Jint.Runtime; | ||
|
||
[Flags] | ||
internal enum InternalTypes | ||
{ | ||
// should not be used, used for empty match | ||
Empty = 0, | ||
|
||
Undefined = 1, | ||
Null = 2, | ||
|
||
// primitive types range start | ||
Boolean = 4, | ||
String = 8, | ||
Number = 16, | ||
Integer = 32, | ||
Symbol = 64, | ||
BigInt = 128, | ||
|
||
// primitive types range end | ||
Object = 256, | ||
|
||
PrivateName = 512, | ||
|
||
// internal usage | ||
ObjectEnvironmentRecord = 1024, | ||
RequiresCloning = 2048, | ||
Module = 4096, | ||
|
||
// the object doesn't override important GetOwnProperty etc which change behavior | ||
PlainObject = 8192, | ||
// our native array | ||
Array = 16384, | ||
|
||
Primitive = Boolean | String | Number | Integer | BigInt | Symbol, | ||
InternalFlags = ObjectEnvironmentRecord | RequiresCloning | PlainObject | Array | Module | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.