-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor!: overhaul interpreter (#3)
* feat: use ESTree for the AST types * feat: implement all update, unary, logical and assignment operators * chore: update remaining nodes * chore: update examples and tests * chore: remove trailing spaces * feat: add support for arrow functions * chore: update readme and bump deps
- Loading branch information
Showing
47 changed files
with
2,086 additions
and
1,327 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
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 |
---|---|---|
@@ -1,17 +1,14 @@ | ||
import * as ESTree from 'estree'; | ||
|
||
declare module 'acorn' { | ||
export function parse(s: string, o: Options): ESTree.Program; | ||
type ExtendNode<T> = { | ||
[K in keyof T]: T[K] extends object ? ExtendNode<T[K]> : T[K]; | ||
} & (T extends ESTree.Node | ||
? { | ||
start: number; | ||
end: number; | ||
} | ||
: unknown); | ||
|
||
// fix type of Comment property 'type' | ||
export type AcornComment = Omit<Comment, 'type'> & { | ||
type: 'Line' | 'Block'; | ||
}; | ||
} | ||
|
||
declare module 'estree' { | ||
interface BaseNodeWithoutComments { | ||
start: number; | ||
end: number; | ||
} | ||
export function parse(s: string, o: Options): ExtendNode<ESTree.Program>; | ||
} |
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,10 @@ | ||
import fs from 'fs'; | ||
import Jinter from '../dist'; | ||
|
||
const code = fs.readFileSync('./test-code.js').toString(); | ||
|
||
const jinter = new Jinter(code); | ||
jinter.scope.set('ntoken', 'vPIcacaohWtfY_'); | ||
const result = jinter.interpret(); | ||
|
||
console.info('Transformed sig:', result); |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.