Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
175 commits
Select commit Hold shift + click to select a range
eb091eb
Tweak object wrapper reported members logic (#1956)
lahma Aug 26, 2024
56bd3d4
Bump the all-dependencies group with 2 updates (#1957)
dependabot[bot] Aug 26, 2024
7f72d48
Update test262 test suite and fix issues (#1958)
lahma Aug 30, 2024
3c4af55
Bump the all-dependencies group with 2 updates (#1960)
dependabot[bot] Sep 2, 2024
ca8a653
Prefer CLR type's shadowing property over base's hidden (#1963)
mspertus Sep 4, 2024
332c8f5
Remove some unnecessary excludes from Test262Harness.settings.json (#…
lahma Sep 8, 2024
d20f91a
Bump the all-dependencies group with 4 updates (#1965)
dependabot[bot] Sep 9, 2024
6b2d622
Implement Math.sumPrecise (#1966)
lahma Sep 15, 2024
e67e58a
Improve interop finding of properties in derived types (#1969)
mspertus Sep 23, 2024
b4fd449
Bump the all-dependencies group with 2 updates (#1970)
dependabot[bot] Sep 23, 2024
1fd4183
Bump the all-dependencies group with 2 updates (#1973)
dependabot[bot] Sep 30, 2024
0eee47d
Fix Array.prototype.toString() stackoverflow (#1976)
xBaank Oct 6, 2024
7857b9c
Bump the all-dependencies group with 5 updates (#1978)
dependabot[bot] Oct 14, 2024
bbbd8ac
Bump Meziantou.Analyzer in the all-dependencies group (#1982)
dependabot[bot] Oct 21, 2024
1b0d5f8
Promise.withResolvers() returned object had resolve and reject functi…
tomatosalat0 Oct 24, 2024
af0845f
Made test of cancellation of engine execution more robust (#1984)
tomatosalat0 Oct 24, 2024
6cb6d5d
Early out in ObjectPool to avoid loop execution (#1985)
tomatosalat0 Oct 24, 2024
7381086
Optimize ValueStringBuilder and some character checks (#1986)
lahma Oct 24, 2024
7d1de2d
Make JsSet public (#1987)
kenlyon Oct 26, 2024
1461bf1
Make JsMap public (#1988)
lahma Oct 26, 2024
c3d86d8
Make JsSet int indexer internal (#1989)
lahma Oct 27, 2024
8e3e320
Exclude static fields and properties from ObjectWrapper by default (#…
lahma Oct 27, 2024
7ac9805
Add Options.InteropOptions.BuildCallStackHandler (#1793)
scgm0 Oct 27, 2024
04466d0
Revert back to favoring SearchValues<char> (#1990)
lahma Oct 27, 2024
d30fe18
Bump Meziantou.Analyzer from 2.0.173 to 2.0.176 in the all-dependenci…
dependabot[bot] Oct 28, 2024
44a0ce0
Improve interop conversion logic between numeric types (#1995)
lahma Nov 2, 2024
7849416
Use Array.Resize when growing ArrayInstance (#1997)
lahma Nov 4, 2024
aba1466
Bump the all-dependencies group with 2 updates (#1998)
dependabot[bot] Nov 4, 2024
408b636
Bump FluentAssertions in the all-dependencies group (#2001)
dependabot[bot] Nov 11, 2024
a506929
Improve infinity detection when parsing numbers on full framework (#2…
lahma Nov 14, 2024
5ea604e
Bump the all-dependencies group across 1 directory with 9 updates (#2…
dependabot[bot] Nov 27, 2024
9d59c60
Bump the all-dependencies group with 3 updates (#2010)
dependabot[bot] Dec 2, 2024
344a1e0
Bump NUnit from 4.2.2 to 4.3.0 in the all-dependencies group (#2014)
dependabot[bot] Dec 16, 2024
03b686a
Bump the all-dependencies group with 2 updates (#2016)
dependabot[bot] Dec 23, 2024
4b0e44e
Bump the all-dependencies group across 1 directory with 4 updates (#2…
dependabot[bot] Jan 7, 2025
964596c
Fix building on GH Actions Ubuntu 24.04 (#2024)
lahma Jan 14, 2025
deded55
Use net472 to run full framework tests (#2026)
lahma Jan 15, 2025
3f2b614
Bump the all-dependencies group across 1 directory with 7 updates (#2…
dependabot[bot] Jan 15, 2025
2b55158
Pin FluentAssertions to version 7.0.0 (#2028)
lahma Jan 16, 2025
dd77948
Update test262 harness and fix issues (#2029)
lahma Jan 18, 2025
a3c7444
Implement Error.isError (#2030)
lahma Jan 18, 2025
d928fec
Fix statement counting code in MaxStatementsConstraint (#2035)
nicolay-f Jan 23, 2025
c87361e
Cleanup custom dictionary implementations (#2036)
lahma Jan 24, 2025
d52688f
Create ExpressionCache to unify constant lookups (#2037)
lahma Jan 24, 2025
df1cbf3
Remove closure allocations from JintFunctionDefinition (#2039)
lahma Jan 25, 2025
815fa32
Flatten declarative record instance creation lookups (#2040)
lahma Jan 25, 2025
cb4effd
Support running DromaeoBenchmark with modern JS syntax (#2041)
lahma Jan 26, 2025
e3c7fe7
Use NET 9 to run tests and benchmarks, remove NET 6 target (#2042)
lahma Jan 26, 2025
8ebce9a
Add extension point for custom Function.toString() logic (#2043)
lahma Jan 27, 2025
fb0016d
Improve environment initialization performance (#2045)
lahma Jan 27, 2025
e6ea23f
Bump the all-dependencies group across 1 directory with 2 updates (#2…
dependabot[bot] Jan 28, 2025
8925d0f
Add configurable limit for Atomics.pause iterations (#2047)
lahma Jan 28, 2025
7ab17c5
Add support for block statement preparation (#2048)
lahma Jan 28, 2025
5342ebb
Add fast paths for object Get/Set for simple objects (#2050)
lahma Jan 31, 2025
b54be04
Bump YantraJS.Core from 1.2.246 to 1.2.261 in the all-dependencies gr…
dependabot[bot] Feb 3, 2025
2563811
Upgrade to new Microsoft Test Platform when using NUnit (#2052)
lahma Feb 10, 2025
dd4e681
Add support for object return values in Func callbacks (#2053)
martinbu Feb 11, 2025
27d3ce9
Create global alias for JsValue[] arguments (#2055)
lahma Feb 15, 2025
f012c83
Bump the all-dependencies group with 3 updates (#2056)
dependabot[bot] Feb 17, 2025
d87a847
Remove apparently-redundant `DateFlags` calculation in `JsDate` const…
nil4 Feb 19, 2025
1e90413
Avoid creating context for eval if eval is not present (#2059)
lahma Feb 21, 2025
b3b3ea8
Improve function arguments parameter expression detection (#2060)
lahma Feb 23, 2025
8750190
Bump the all-dependencies group with 5 updates (#2061)
dependabot[bot] Mar 7, 2025
a4a51e3
Check against long.MaxValue instead of int in memory limit configurat…
lahma Mar 9, 2025
82ac023
Update bug_report.md (#2070)
lahma Mar 10, 2025
f1a8010
Remove unused usings (#2072)
lahma Mar 16, 2025
c57a4a8
Use collection expressions (#2073)
lahma Mar 16, 2025
323230e
Enforce code style on build and fix issues (#2074)
lahma Mar 16, 2025
96c6280
Use matrix to run PR builds, add ARM runner (#2075)
lahma Mar 16, 2025
4e3dbac
Create config.yml for issues templates (#2077)
lahma Mar 16, 2025
6b7414d
Bump the all-dependencies group with 3 updates (#2079)
dependabot[bot] Mar 17, 2025
0ca0ce7
Bump the all-dependencies group with 2 updates (#2080)
dependabot[bot] Apr 3, 2025
e4800fa
Improve interop performance with delegates and dictionaries (#2088)
lahma Apr 4, 2025
6edcbbe
Bump Meziantou.Analyzer in the all-dependencies group (#2089)
dependabot[bot] Apr 9, 2025
8bd8821
Bump the all-dependencies group with 4 updates (#2091)
dependabot[bot] Apr 14, 2025
16ae0ab
Update Meziantou.Analyzer to 2.0.197 (#2093)
dependabot[bot] Apr 21, 2025
ee4ecb6
Bump the all-dependencies group across 1 directory with 2 updates (#2…
dependabot[bot] May 5, 2025
74f1608
Fix ObjectAccessBenchmark test (#2100)
mac-michael May 10, 2025
54a2801
Add default 10 second timeout for promise unwrapping (#2103)
lahma May 18, 2025
7b73c90
Update: (#2104)
dependabot[bot] May 19, 2025
1cc4c0b
#2099: Fix over-caching by providing each function instance with it's…
warappa May 22, 2025
aa732f8
Update: (#2107)
dependabot[bot] May 26, 2025
6aea437
Fix calling pop on generic list of value types (#2112)
Genteure Jun 2, 2025
4d9be48
Fix NRE in BuildTargetBinderDelegate (#2116)
warappa Jun 7, 2025
35ee8e3
Bump the all-dependencies group with 3 updates (#2117)
dependabot[bot] Jun 9, 2025
d04ba03
Bump the all-dependencies group with 6 updates (#2120)
dependabot[bot] Jun 16, 2025
981dfbe
Improve Half interop handling (#2121)
lahma Jun 20, 2025
9957b5b
eval syntax checks should not descend into function declarations (#2123)
rg1 Jun 22, 2025
2ed75d5
Update ES2025 support status to README.md (#2125)
lahma Jun 28, 2025
203a19b
Update test262 harness and fix issues (#2126)
lahma Jun 29, 2025
1a6c127
Implement Upsert (#2127)
lahma Jun 29, 2025
3dc3134
Remove some duplication and align with spec naming (#2128)
lahma Jun 29, 2025
229b697
Use V8-based stacktraces (#2129)
Guichaguri Jun 30, 2025
17f6a71
Improve interop member resolution when enum indexer present (#2131)
lahma Jun 30, 2025
d6e1a83
Fix default parameter handling under interop (#2134)
lahma Jul 2, 2025
45e466a
Support writing length to IList under interop (#2135)
lahma Jul 2, 2025
7b6b733
Support passing `space` arg to `SerializeToJsonDelegate` (#2142)
Zaitonn Jul 6, 2025
ac3f89d
Add explicit resource management supporting types (#2143)
lahma Jul 6, 2025
72690f3
Upgrade to Acornima v1.2.0 (#2145)
adams85 Jul 12, 2025
533a270
Bump the all-dependencies group with 2 updates (#2144)
dependabot[bot] Jul 12, 2025
0b03f8e
Add support for using and await using (#2139)
lahma Jul 12, 2025
cb2474c
Bump the all-dependencies group with 3 updates (#2146)
dependabot[bot] Jul 15, 2025
8f106a7
Rename ExceptionHelper to Throw and shorter method names (#2148)
lahma Jul 18, 2025
f58fc1f
Add `Options.Constraints.PromiseTimeout` to control timeout for `Dis…
rocklau Jul 23, 2025
1ba9579
Bump the all-dependencies group with 1 update (#2149)
dependabot[bot] Jul 23, 2025
c83b629
Fix iterating a CLR list proxy and length property under interop (#2151)
martinbu Jul 23, 2025
feeab47
Fix MethodAccessor property flags (#2153)
lahma Jul 26, 2025
cdad567
Upgrade to xUnit v3 (#2154)
lahma Jul 28, 2025
08ca9ca
Fix BigInt modulo assignment (#2178)
lahma Sep 16, 2025
fb64c38
Upgrade Test262Harness to version 1.0.3 (#2184)
lahma Oct 15, 2025
2d65613
Object.is fix when providing BigInt values (#2183)
tomatosalat0 Oct 15, 2025
9430d0d
Bump the all-dependencies group with 12 updates (#2187)
dependabot[bot] Oct 20, 2025
ddf187c
Bump the all-dependencies group with 2 updates (#2188)
dependabot[bot] Oct 27, 2025
2459e76
Prevent accidental leakage of arguments between separate calls (#2193)
tomatosalat0 Nov 9, 2025
69990b5
Rewrite of flaky test (#2195)
tomatosalat0 Nov 9, 2025
4414497
Allow garbage collector to collect unused memory (#2196)
tomatosalat0 Nov 9, 2025
215d1cd
Bump the all-dependencies group with 4 updates (#2192)
dependabot[bot] Nov 9, 2025
5eec04b
Allow conversion of Promise to task when passing an async function as…
REscobar Nov 10, 2025
7a9e1ef
Bump the all-dependencies group with 3 updates (#2198)
dependabot[bot] Nov 10, 2025
b4930a3
Fix missing control characters in JSON Parse Key (#2202)
H4ad Nov 21, 2025
768b442
Use NET 10 SDK to build and test (#2185)
lahma Nov 21, 2025
ab847c2
Upgrade packages (#2212)
lahma Dec 26, 2025
3c8ba7c
Convert solution to slnx format (#2213)
lahma Dec 28, 2025
1a7c606
Defer iterator next method check until actually iterating (#2214)
lahma Dec 29, 2025
0f2c2af
Add ArrayExpression and ObjectExpression to computed property key typ…
lahma Dec 29, 2025
20b6fea
Fix parameter TDZ and eval-var-scope handling (#2216)
lahma Dec 29, 2025
18a18d1
ES6 Generators (#824)
lahma Dec 30, 2025
c239947
Bump the all-dependencies group with 1 update (#2217)
dependabot[bot] Dec 30, 2025
b593264
Refactor generator control flow from exceptions to flags (#2218)
lahma Dec 30, 2025
ee5de0d
Implement Iterator Helpers (#2032)
lahma Dec 30, 2025
b2c18fd
Implement Iterator Sequencing (#2031)
lahma Dec 30, 2025
65c036f
Update test262 test suite and fix issues (#2219)
lahma Dec 31, 2025
a7216e6
Implement RegExp.escape() (#2220)
lahma Dec 31, 2025
2f7a1bc
Implement Immutable ArrayBuffers (#2222)
lahma Dec 31, 2025
b524fdd
Implement Joint Iteration (#2221)
lahma Dec 31, 2025
bcc903d
Improve REPL for AI usage (#2224)
lahma Dec 31, 2025
9b66769
Implement JSON.parse source text access (#2223)
lahma Dec 31, 2025
884f990
Rename IsGeneratorSuspended to IsSuspended (#2226)
lahma Jan 3, 2026
0f0dba3
Implement ECMAScript-compliant async/await with proper suspension (#2…
lahma Jan 3, 2026
27d00c7
Filter TypeReference constructors using TypeResolver.MemberFilter (#2…
lahma Jan 3, 2026
5bc93d8
Implement Asynchronous iteration (#2228)
lahma Jan 4, 2026
19fb86e
Implement Array.fromAsync (#2229)
lahma Jan 5, 2026
098a629
Add agent support to test262 testing (#2231)
lahma Jan 5, 2026
341ffed
Bump the all-dependencies group with 2 updates (#2232)
dependabot[bot] Jan 6, 2026
ed5354a
Implement Atomics (#2230)
lahma Jan 6, 2026
b00170a
ValueTask<TResult> and IAsyncEnumerable<T> interop support (#2233)
lahma Jan 6, 2026
89e5dd2
Disable fail-fast in GitHub Actions workflow (#2235)
lahma Jan 6, 2026
30d51f8
Add jsValue.UnwrapIfPromise(CancellationToken cancellationToken) (#2234)
lahma Jan 6, 2026
26d2b01
Fix Test262Test setTimeout concurrency issue (#2236)
lahma Jan 7, 2026
1fec529
Type resolution should use runtime type when declared type has indexe…
lahma Jan 7, 2026
c47e369
JavaScriptException.GetBaseException() should not return JavaScriptEr…
lahma Jan 7, 2026
57f3e7f
Enable decorator tests (#2239)
lahma Jan 7, 2026
077276e
Fix Final_Sigma_U180E issue (#2240)
lahma Jan 7, 2026
064fb4e
Improve TypeReference method parameter scoring (#2241)
lahma Jan 7, 2026
d9ada8f
Add test coverage for async functions (#2242)
lahma Jan 7, 2026
c86083c
Fall back to non-generic list wrapper on error (#2244)
lahma Jan 7, 2026
8668f1a
Update VersionPrefix from 4.0.0 to 4.5.0 (#2245)
lahma Jan 7, 2026
c2cc835
Cleanup suspend logic (#2246)
lahma Jan 7, 2026
f7c2103
Bump the all-dependencies group with 2 updates (#2247)
dependabot[bot] Jan 12, 2026
5736591
Preserve lexical block environment across async loop resumes (#2250)
Copilot Jan 15, 2026
3fcb53e
Add core Intl infrastructure (#2253)
lahma Jan 24, 2026
0789959
feat(intl): Add CLDR data files and DefaultCldrProvider (#2254)
lahma Jan 24, 2026
028ca54
feat(intl): Add Intl global object and Intl.Locale (#2255)
lahma Jan 24, 2026
fd5e51d
Add Intl.Collator and update String.localeCompare (#2256)
lahma Jan 24, 2026
217f37e
Add Intl.PluralRules (#2257)
lahma Jan 24, 2026
acdb026
Add Intl.NumberFormat and update toLocaleString (#2258)
lahma Jan 24, 2026
333e4e8
Add Intl.DateTimeFormat and update toLocaleString (#2259)
lahma Jan 24, 2026
3dd25cb
Complete Intl API with remaining formatters and tests (#2260)
lahma Jan 24, 2026
322adb4
The Temporal API infrastructure (#2262)
lahma Jan 25, 2026
db19d65
Implement Temporal.Duration (#2263)
lahma Jan 25, 2026
7742a69
Regenerate test suite on settings file change (#2265)
lahma Jan 25, 2026
be3470b
Enable tests and fix issues (#2266)
lahma Jan 25, 2026
287f9f8
Improve Internalization API performance (#2267)
lahma Jan 25, 2026
4d0dc45
Merge branch 'main' of https://github.com/sebastienros/jint into seba…
break-pointer Jan 29, 2026
aaf8d23
Merge branch 'sebastienros-main' into sync-with-upstream
break-pointer Jan 29, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ assignees: ''

---

**Version used**
**Version/platform/runtime used**

With which version did you encounter this behavior. Please check against 3.x beta if you haven't yet, it might have the fix already.
With which version did you encounter this behavior, which OS and NET runtime.

**Describe the bug**

Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
blank_issues_enabled: false
10 changes: 8 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,17 @@ jobs:

runs-on: ubuntu-latest
steps:

- name: Setup NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0

- name: Checkout source code
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: Test
run: dotnet test --configuration Release --logger GitHubActions
run: dotnet test --configuration Release --logger "GitHubActions;summary-include-passed=false;summary-include-skipped=false"

- name: Pack with dotnet
run: dotnet pack Jint/Jint.csproj --output artifacts --configuration Release -p:VersionSuffix=preview-$GITHUB_RUN_NUMBER -p:ContinuousIntegrationBuild=True
Expand Down
45 changes: 24 additions & 21 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,45 @@
name: PR Check
name: PR

on:

pull_request:
branches: [ main, release/2.x, 3.x ]
branches: [ main, 3.x ]

env:
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: 1

concurrency:
group: ${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:

windows:
runs-on: windows-latest
test:

steps:
- name: Checkout source code
uses: actions/checkout@v4
name: ${{ matrix.os.name }}

- name: Test
run: dotnet test --configuration Release --logger GitHubActions
strategy:
fail-fast: false
matrix:
os:
- { name: 'linux', image: 'ubuntu-latest' }
- { name: 'linux - ARM', image: 'ubuntu-24.04-arm' }
- { name: 'windows', image: 'windows-latest' }
- { name: 'macos', image: 'macos-latest' }

linux:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os.image }}

steps:
- name: Checkout source code
uses: actions/checkout@v4

- name: Test
run: dotnet test --configuration Release --logger GitHubActions

macos:
runs-on: macos-14
- name: Setup NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0

steps:
- name: Checkout source code
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: Test
run: dotnet test --configuration Release --logger GitHubActions
run: dotnet test --configuration Release --logger "GitHubActions;summary-include-passed=false;summary-include-skipped=false"

10 changes: 8 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,17 @@ jobs:

runs-on: ubuntu-latest
steps:

- name: Setup NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0

- name: Checkout source code
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: Test
run: dotnet test --configuration Release --logger GitHubActions
run: dotnet test --configuration Release --logger "GitHubActions;summary-include-passed=false;summary-include-skipped=false"

- name: Pack with dotnet
run: |
Expand Down
267 changes: 267 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,267 @@
# CLAUDE.md

**Current development**: Target against main branch and compare changes against it.

## Build & Test Commands

### Building
```bash
# Build entire solution
dotnet build --configuration Release

# Build specific project
dotnet build --configuration Release Jint/Jint.csproj
```

Important: Never use --no-build - always ensure you are working with the latest compiled code.

### Testing
```bash
# Run all tests
dotnet test --configuration Release

# Run specific test project
dotnet test --configuration Release Jint.Tests/Jint.Tests.csproj

# Run specific test class
dotnet test --configuration Release --filter "FullyQualifiedName~Jint.Tests.Runtime.EngineTests"

# Run specific test method
dotnet test --configuration Release --filter "FullyQualifiedName~Jint.Tests.Runtime.EngineTests.CanEvaluateScripts"

# Run Test262 conformance tests
dotnet test --configuration Release Jint.Tests.Test262/Jint.Tests.Test262.csproj
```

Important: Run tests in Release mode for faster feedback loop.

## Requirements

- The project uses central package management via Directory.Packages.props

## Architecture

Jint follows a layered interpreter architecture:

```
Acornima Parser (external) → AST → Interpreter → Runtime → Interop
```

### Core Components

**Engine (`Jint/Engine.cs`)**
- Main API entry point split across multiple partial files (Engine.cs, Engine.Advanced.cs, Engine.Modules.cs, etc.)
- Manages execution context stack, intrinsics (built-in objects), and realms
- Configuration via `Options` class (constraints, CLR interop, modules, debugging)

**JsValue Type System (`Jint/Native/`)**
- `JsValue` is the abstract base class for all JavaScript values
- Primitive types: JsUndefined, JsNull, JsBoolean, JsNumber, JsString, JsBigInt, JsSymbol
- Object types: ObjectInstance and derived classes (JsArray, JsDate, JsMap, JsSet, JsPromise, etc.)
- All built-in JavaScript objects are in `Jint/Native/` organized by type (Array/, Date/, Error/, Function/, etc.)

**Runtime (`Jint/Runtime/`)**
- **TypeConverter.cs** (1,048 lines): All JavaScript type coercion (ToPrimitive, ToNumber, ToString, ToObject, etc.)
- **Intrinsics.cs**: Singleton containing all built-in object constructors and prototypes (lazily initialized)
- **Realm.cs**: ECMAScript Realm encapsulating global environment and intrinsics
- **Environments/**: Scope chain implementation (GlobalEnvironment, FunctionEnvironment, DeclarativeEnvironment, etc.)

**Interpreter (`Jint/Runtime/Interpreter/`)**
- **Statements/**: One handler class per statement type (JintIfStatement, JintForStatement, JintTryStatement, etc.)
- **Expressions/**: One handler class per expression type (JintBinaryExpression, JintCallExpression, JintMemberExpression, etc.)
- AST nodes are evaluated via specialized Jint* handler classes
- Caching: JintFunctionDefinition caches compiled function metadata for reuse

**Interop (`Jint/Runtime/Interop/`)**
- **ObjectWrapper.cs**: Wraps .NET objects for JavaScript access
- **TypeReference.cs**: Exposes CLR types to JavaScript (e.g., `System.String`)
- **ClrFunction.cs**: Wraps .NET methods/delegates as JavaScript functions
- **DefaultTypeConverter.cs**: Bidirectional conversion between JS values and CLR types
- **Reflection/**: Type discovery and method binding with caching

**Modules (`Jint/Runtime/Modules/`)**
- ES6 module system with import/export support
- ModuleLoader handles module resolution and loading
- Supports cyclic dependencies via CyclicModule
- Modules can be defined from JavaScript source or programmatically via ModuleBuilder

### Important Patterns

**Lazy Initialization**
- Built-in objects (Intrinsics) are lazily initialized to reduce startup time
- Properties are typically null until first access

**Object Pooling (`Jint/Pooling/`)**
- Reference, Arguments, and JsValue arrays are pooled to reduce GC pressure
- Use `ReferencePool`, `ArgumentsInstancePool`, `JsValueArrayPool`

**Property Key Optimization**
- `KnownKeys.cs` contains pre-computed common property names
- `HybridDictionary` switches between list and hash based on property count
- `StringDictionarySlim` for string-only dictionary keys

**Partial Classes**
- Large classes are split: Engine.*.cs, Intrinsics.*.cs, ObjectInstance.*.cs, etc.
- Keep related functionality together when editing

**ECMAScript Spec References**
- Code includes TC39 spec section references in comments (e.g., `// https://tc39.es/ecma262/#sec-...`)
- Maintain these references when implementing new features
- The to follow TC 39 spec when possible
- The test files are located in ..\test262\test when source code needed

**Type Flags**
- `InternalTypes` enum enables fast type checking without casting
- Many hot paths use type flags for performance

## ECMAScript Compliance
- Follow ECMAScript specification behavior as closely as practical
- Do not introduce non-standard language extensions
- Support both strict and sloppy mode with spec-defined differences

## Code Conventions

- **Namespaces**: Global usings for Acornima and Acornima.Ast defined in Directory.Build.props
- **Nullable**: Enabled across the codebase (NRT)
- **Unsafe Code**: Allowed (used for performance-critical paths)
- **Warnings as Errors**: Enabled - all warnings must be fixed
- **Analysis**: Latest analyzers enabled with EnforceCodeStyleInBuild
- **Performance**: Try to make code as perfomant as possible.

## Testing

- **Jint.Tests/**: Main test suite using xUnit v3
- Organized by topic (Runtime/, Parser/, Debugger/, etc.)
- Uses FluentAssertions for readable assertions
- Embedded test scripts in Runtime/Scripts/ and Parser/Scripts/
- Use timeout of 30 seconds when invoking test runner

- **Jint.Tests.Test262/**: ECMAScript conformance suite using NUnit
- Official TC39 Test262 integration
- Validates spec compliance
- The test files are located in ..\test262\test when source code needed, you are always allowed to read from this directory and its sub-directories
- The error output contains the failing script, you just need to remove line numbers from the JavaScript
- Never try to fix these tests
- No need to use timeout, engine has default timeout of 30 seconds

- **Jint.Tests.CommonScripts/**: Real-world benchmark scripts using NUnit
- Performance validation (crypto, 3D rendering, etc.)

- **Jint.Tests.PublicInterface/**: API contract tests using xUnit v3
- Ensures public API stability

## Performance Considerations

- Jint uses Acornima for parsing (external, optimized)
- Cache `Script` or `Module` instances when executing the same script repeatedly
- Prefer strict mode execution (improves performance)
- Object pooling reduces GC pressure
- Expression and function definition caching reduces re-evaluation cost
- AggressiveInlining attributes mark hot paths

## Working with ES Features

When implementing new ECMAScript features:

1. **Read the TC39 spec section** for the feature
2. **Check Native/ directory** for where the built-in should live (e.g., Array/ for Array methods)
3. **Add to Intrinsics.cs** if it's a new global constructor or well-known symbol
4. **Update TypeConverter.cs** if new type coercion rules apply
5. **Add Statement/Expression handler** in Runtime/Interpreter/ if it's new syntax
6. **Reference spec sections** in code comments
7. Jint.Tests.Test262\Test262Harness.settings.json contains exclusions and inclusions for test cases

## Testing with Jint.Repl

The Jint REPL (Read-Eval-Print Loop) is useful for quickly testing JavaScript code during development.

### Running the REPL
```bash
# Build the REPL
dotnet build Jint.Repl --configuration Release

# Run the REPL
dotnet run --project Jint.Repl --configuration Release
```

### Command Line Options
```
-f, --file <path> Execute JavaScript file
-t, --timeout <secs> Set execution timeout in seconds
-h, --help Show help message
```

### Testing Scripts

**Always use a timeout when testing scripts using Jint.Repl** to prevent infinite loops from hanging your session:

```bash
# Execute a file with 10 second timeout (recommended default)
dotnet run --project Jint.Repl --configuration Release -- -f script.js -t 10

# Execute from stdin with timeout
echo "1 + 2" | dotnet run --project Jint.Repl --configuration Release -- -t 10

# Execute multiline script from stdin
cat << 'EOF' | dotnet run --project Jint.Repl --configuration Release -- -t 10
var result = [];
for (var i = 0; i < 5; i++) {
result.push(i * 2);
}
JSON.stringify(result);
EOF
```

### Quick Testing Patterns

```bash
# Test a simple expression
echo "Math.sqrt(16)" | dotnet run --project Jint.Repl --configuration Release -- -t 10

# Test JSON parsing
echo 'JSON.parse("[1,2,3]")' | dotnet run --project Jint.Repl --configuration Release -- -t 10

# Test with a temporary file
echo 'var x = 5; x * 2' > /tmp/test.js
dotnet run --project Jint.Repl --configuration Release -- -f /tmp/test.js -t 10
```

### When to Use REPL vs Jint.Tryouts

- **REPL**: Quick one-off tests, verifying behavior, testing from command line
- **Jint.Tryouts**: Complex debugging scenarios, stepping through code, testing with C# interop

## Module System

Modules are enabled via:
```csharp
var engine = new Engine(options => options.EnableModules(@"C:\Scripts"));
var ns = engine.Modules.Import("./my-module.js");
```

Or define modules programmatically:
```csharp
engine.Modules.Add("lib", builder => builder
.ExportType<MyClass>()
.ExportValue("version", 1)
);
```

## Constraints & Security

Execution constraints prevent resource abuse:
- Memory limits: `options.LimitMemory(4_000_000)`
- Timeout: `options.TimeoutInterval(TimeSpan.FromSeconds(4))`
- Statement limits: `options.MaxStatements(1000)`
- Custom constraints: Derive from `Constraint` base class

CLR access is disabled by default. Enable via:
```csharp
var engine = new Engine(cfg => cfg.AllowClr());
```

## AOT Compatibility

- Jint is AOT-compatible for .NET 7.0+ targets
- See Jint.AotExample/ for AOT usage patterns
- IsAotCompatible flag set for net7.0+ in Jint.csproj
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<PackageLicenseExpression>BSD-2-Clause</PackageLicenseExpression>

<BuildNumber Condition="'$(BuildNumber)' == ''">0</BuildNumber>
<VersionPrefix>4.0.0</VersionPrefix>
<VersionPrefix>4.5.0</VersionPrefix>
<VersionSuffix>beta-$(BuildNumber)</VersionSuffix>
<FileVersion>$(VersionPrefix).$(BuildNumber)</FileVersion>

Expand Down
Loading
Loading