mirror of
https://github.com/bendtherules/ask262.git
synced 2026-08-18 13:21:55 +00:00
feat: add startTrace/stopTrace to control mark capture
Implemented a capture flag in `Ask262Debug` to enable/disable marking. - Added `_captureEnabled` property and related logic in `mark()`. - Introduced `startTrace()` and `stopTrace()` methods to toggle capture. - Updated verification script to start tracing, run tests, stop tracing, and assert that the `Array.prototype.every` section is captured and marked important.
This commit is contained in:
@@ -29,6 +29,9 @@ class Ask262Debug {
|
||||
/** Whether to mark new entries as important */
|
||||
private _important = false;
|
||||
|
||||
/** Whether capture is enabled (controlled by startTrace/stopTrace) */
|
||||
private _captureEnabled = false;
|
||||
|
||||
/** Map from deduplication key to index in marks array */
|
||||
private _markIndex = new Map<string, number>();
|
||||
|
||||
@@ -47,11 +50,16 @@ class Ask262Debug {
|
||||
* Records a mark for spec section entry during execution.
|
||||
* Deduplicates based on (sectionIds, file, line) combination.
|
||||
* If duplicate found, merges important flags (OR logic).
|
||||
* Only captures if tracing is enabled (via startTrace()).
|
||||
* @param sectionIds - Array of ECMAScript spec section IDs
|
||||
* @param file - Relative file path from engine262/src/
|
||||
* @param line - Line number in source file (1-indexed)
|
||||
*/
|
||||
mark(sectionIds: string[], file: string, line: number) {
|
||||
if (!this._captureEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
const key = this._makeKey(sectionIds, file, line);
|
||||
const existingIndex = this._markIndex.get(key);
|
||||
|
||||
@@ -75,6 +83,22 @@ class Ask262Debug {
|
||||
this.marks.push(newMark);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables capture of marks during execution.
|
||||
* Marks will be recorded until stopTrace() is called.
|
||||
*/
|
||||
startTrace() {
|
||||
this._captureEnabled = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables capture of marks during execution.
|
||||
* Marks will be ignored until startTrace() is called again.
|
||||
*/
|
||||
stopTrace() {
|
||||
this._captureEnabled = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks subsequent mark() calls as important.
|
||||
* Used to annotate interesting execution phases.
|
||||
|
||||
Reference in New Issue
Block a user