@ibyar/expressions 0.8.3 → 0.8.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -3
- package/api/abstract.d.ts +6 -2
- package/api/abstract.js +15 -8
- package/api/abstract.js.map +1 -1
- package/api/class/class.d.ts +15 -18
- package/api/class/class.js +49 -61
- package/api/class/class.js.map +1 -1
- package/api/class/decorator.d.ts +2 -2
- package/api/class/decorator.js +6 -6
- package/api/class/decorator.js.map +1 -1
- package/api/computing/call.d.ts +2 -2
- package/api/computing/call.js +8 -8
- package/api/computing/call.js.map +1 -1
- package/api/computing/debugger.d.ts +1 -2
- package/api/computing/debugger.js +2 -3
- package/api/computing/debugger.js.map +1 -1
- package/api/computing/new.d.ts +2 -2
- package/api/computing/new.js +7 -7
- package/api/computing/new.js.map +1 -1
- package/api/computing/rest.d.ts +2 -2
- package/api/computing/rest.js +6 -6
- package/api/computing/rest.js.map +1 -1
- package/api/computing/return.d.ts +2 -2
- package/api/computing/return.js +6 -6
- package/api/computing/return.js.map +1 -1
- package/api/computing/spread.d.ts +2 -2
- package/api/computing/spread.js +6 -6
- package/api/computing/spread.js.map +1 -1
- package/api/computing/throw.d.ts +4 -4
- package/api/computing/throw.js +18 -18
- package/api/computing/throw.js.map +1 -1
- package/api/computing/yield.d.ts +2 -2
- package/api/computing/yield.js +7 -7
- package/api/computing/yield.js.map +1 -1
- package/api/definition/array.d.ts +3 -3
- package/api/definition/array.js +14 -14
- package/api/definition/array.js.map +1 -1
- package/api/definition/bind.d.ts +2 -2
- package/api/definition/bind.js +9 -9
- package/api/definition/bind.js.map +1 -1
- package/api/definition/comment.d.ts +3 -3
- package/api/definition/comment.js +6 -6
- package/api/definition/comment.js.map +1 -1
- package/api/definition/function.d.ts +17 -16
- package/api/definition/function.js +60 -55
- package/api/definition/function.js.map +1 -1
- package/api/definition/member.d.ts +2 -2
- package/api/definition/member.js +13 -9
- package/api/definition/member.js.map +1 -1
- package/api/definition/object.d.ts +4 -4
- package/api/definition/object.js +22 -22
- package/api/definition/object.js.map +1 -1
- package/api/definition/statement.d.ts +2 -2
- package/api/definition/statement.js +6 -6
- package/api/definition/statement.js.map +1 -1
- package/api/definition/values.d.ts +15 -37
- package/api/definition/values.js +49 -74
- package/api/definition/values.js.map +1 -1
- package/api/expression.d.ts +42 -8
- package/api/expression.js.map +1 -1
- package/api/index.d.ts +1 -0
- package/api/index.js +1 -0
- package/api/index.js.map +1 -1
- package/api/module/common.d.ts +3 -3
- package/api/module/common.js +9 -9
- package/api/module/common.js.map +1 -1
- package/api/module/export.d.ts +5 -5
- package/api/module/export.js +30 -29
- package/api/module/export.js.map +1 -1
- package/api/module/import.d.ts +4 -4
- package/api/module/import.js +24 -23
- package/api/module/import.js.map +1 -1
- package/api/operators/assignment.d.ts +3 -3
- package/api/operators/assignment.js +5 -5
- package/api/operators/assignment.js.map +1 -1
- package/api/operators/await.d.ts +3 -3
- package/api/operators/await.js +7 -7
- package/api/operators/await.js.map +1 -1
- package/api/operators/binary.d.ts +1 -1
- package/api/operators/binary.js +1 -1
- package/api/operators/binary.js.map +1 -1
- package/api/operators/chaining.d.ts +2 -2
- package/api/operators/chaining.js +6 -6
- package/api/operators/chaining.js.map +1 -1
- package/api/operators/comma.d.ts +2 -2
- package/api/operators/comma.js +6 -6
- package/api/operators/comma.js.map +1 -1
- package/api/operators/grouping.d.ts +2 -2
- package/api/operators/grouping.js +6 -6
- package/api/operators/grouping.js.map +1 -1
- package/api/operators/logical.d.ts +1 -1
- package/api/operators/logical.js +1 -1
- package/api/operators/logical.js.map +1 -1
- package/api/operators/pipeline.d.ts +3 -3
- package/api/operators/pipeline.js +8 -8
- package/api/operators/pipeline.js.map +1 -1
- package/api/operators/ternary.d.ts +2 -2
- package/api/operators/ternary.js +8 -8
- package/api/operators/ternary.js.map +1 -1
- package/api/operators/types.d.ts +1 -1
- package/api/operators/unary.d.ts +3 -3
- package/api/operators/unary.js +7 -7
- package/api/operators/unary.js.map +1 -1
- package/api/operators/update.d.ts +3 -3
- package/api/operators/update.js +8 -8
- package/api/operators/update.js.map +1 -1
- package/api/program.d.ts +3 -3
- package/api/program.js +7 -7
- package/api/program.js.map +1 -1
- package/api/statement/control/block.d.ts +2 -2
- package/api/statement/control/block.js +6 -6
- package/api/statement/control/block.js.map +1 -1
- package/api/statement/control/empty.d.ts +2 -3
- package/api/statement/control/empty.js +6 -7
- package/api/statement/control/empty.js.map +1 -1
- package/api/statement/control/if.d.ts +2 -2
- package/api/statement/control/if.js +8 -8
- package/api/statement/control/if.js.map +1 -1
- package/api/statement/control/switch.d.ts +4 -6
- package/api/statement/control/switch.js +19 -20
- package/api/statement/control/switch.js.map +1 -1
- package/api/statement/control/terminate.d.ts +4 -4
- package/api/statement/control/terminate.js +11 -15
- package/api/statement/control/terminate.js.map +1 -1
- package/api/statement/control/with.d.ts +21 -0
- package/api/statement/control/with.js +67 -0
- package/api/statement/control/with.js.map +1 -0
- package/api/statement/declarations/declares.d.ts +4 -4
- package/api/statement/declarations/declares.js +14 -14
- package/api/statement/declarations/declares.js.map +1 -1
- package/api/statement/iterations/for.d.ts +7 -7
- package/api/statement/iterations/for.js +35 -35
- package/api/statement/iterations/for.js.map +1 -1
- package/api/statement/iterations/while.d.ts +3 -3
- package/api/statement/iterations/while.js +14 -14
- package/api/statement/iterations/while.js.map +1 -1
- package/package.json +14 -4
- package/scope/finalizer.d.ts +1 -1
- package/scope/pool.d.ts +1 -1
- package/scope/proxy.d.ts +1 -1
- package/scope/proxy.js +1 -0
- package/scope/proxy.js.map +1 -1
- package/scope/scope.d.ts +2 -2
- package/scope/scope.js +13 -16
- package/scope/scope.js.map +1 -1
- package/scope/stack.js +23 -23
- package/scope/stack.js.map +1 -1
- package/v8/enums.d.ts +4 -2
- package/v8/enums.js.map +1 -1
- package/v8/factory.d.ts +148 -0
- package/v8/factory.js +499 -0
- package/v8/factory.js.map +1 -0
- package/v8/inline.d.ts +49 -49
- package/v8/inline.js +317 -307
- package/v8/inline.js.map +1 -1
- package/v8/node.d.ts +141 -0
- package/v8/node.js +2 -0
- package/v8/node.js.map +1 -0
- package/v8/nodes.d.ts +0 -14
- package/v8/nodes.js +1 -152
- package/v8/nodes.js.map +1 -1
- package/v8/parser.d.ts +21 -18
- package/v8/parser.js +97 -84
- package/v8/parser.js.map +1 -1
- package/v8/stream.d.ts +2 -1
- package/v8/stream.js +221 -311
- package/v8/stream.js.map +1 -1
- package/v8/token.d.ts +3 -1
- package/v8/token.js +7 -5
- package/v8/token.js.map +1 -1
- package/visit/visitor.d.ts +1 -1
package/v8/factory.d.ts
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { AccessorProperty, ClassBody, ClassDeclaration, ClassExpression, MetaProperty, MethodDefinition, MethodDefinitionKind, PrivateIdentifier, PropertyDefinition, StaticBlock, Super } from '../api/class/class.js';
|
|
2
|
+
import { Decorator } from '../api/class/decorator.js';
|
|
3
|
+
import { CallExpression } from '../api/computing/call.js';
|
|
4
|
+
import { DebuggerStatement } from '../api/computing/debugger.js';
|
|
5
|
+
import { NewExpression } from '../api/computing/new.js';
|
|
6
|
+
import { RestElement } from '../api/computing/rest.js';
|
|
7
|
+
import { ReturnStatement } from '../api/computing/return.js';
|
|
8
|
+
import { SpreadElement } from '../api/computing/spread.js';
|
|
9
|
+
import { CatchClauseNode, ThrowStatement, TryCatchNode } from '../api/computing/throw.js';
|
|
10
|
+
import { YieldExpression } from '../api/computing/yield.js';
|
|
11
|
+
import { ArrayExpression, ArrayPattern } from '../api/definition/array.js';
|
|
12
|
+
import { BindExpression } from '../api/definition/bind.js';
|
|
13
|
+
import { ArrowFunctionExpression, AssignmentPattern, FunctionDeclaration, FunctionExpression } from '../api/definition/function.js';
|
|
14
|
+
import { MemberExpression } from '../api/definition/member.js';
|
|
15
|
+
import { ObjectExpression, ObjectPattern, Property } from '../api/definition/object.js';
|
|
16
|
+
import { Identifier, Literal, TaggedTemplateExpression, TemplateLiteral, ThisExpression } from '../api/definition/values.js';
|
|
17
|
+
import { DeclarationExpression, ExpressionNode, SourceLocation } from '../api/expression.js';
|
|
18
|
+
import { ImportAttribute } from '../api/module/common.js';
|
|
19
|
+
import { ExportAllDeclaration, ExportDefaultDeclaration, ExportNamedDeclaration, ExportSpecifier } from '../api/module/export.js';
|
|
20
|
+
import { ImportDeclaration, ImportDefaultSpecifier, ImportExpression, ImportNamespaceSpecifier, ImportSpecifier } from '../api/module/import.js';
|
|
21
|
+
import { AssignmentExpression, AssignmentOperator } from '../api/operators/assignment.js';
|
|
22
|
+
import { AwaitExpression } from '../api/operators/await.js';
|
|
23
|
+
import { BinaryExpression, BinaryOperator } from '../api/operators/binary.js';
|
|
24
|
+
import { ChainExpression } from '../api/operators/chaining.js';
|
|
25
|
+
import { SequenceExpression } from '../api/operators/comma.js';
|
|
26
|
+
import { GroupingExpression } from '../api/operators/grouping.js';
|
|
27
|
+
import { LogicalExpression, LogicalOperator } from '../api/operators/logical.js';
|
|
28
|
+
import { PipelineExpression } from '../api/operators/pipeline.js';
|
|
29
|
+
import { ConditionalExpression } from '../api/operators/ternary.js';
|
|
30
|
+
import { UnaryExpression, UnaryOperator } from '../api/operators/unary.js';
|
|
31
|
+
import { UpdateExpression, UpdateOperator } from '../api/operators/update.js';
|
|
32
|
+
import { Program, ProgramSourceType } from '../api/program.js';
|
|
33
|
+
import { BlockStatement } from '../api/statement/control/block.js';
|
|
34
|
+
import { EmptyStatement } from '../api/statement/control/empty.js';
|
|
35
|
+
import { IfStatement } from '../api/statement/control/if.js';
|
|
36
|
+
import { DefaultExpression, SwitchCase, SwitchStatement } from '../api/statement/control/switch.js';
|
|
37
|
+
import { BreakStatement, ContinueStatement, LabeledStatement } from '../api/statement/control/terminate.js';
|
|
38
|
+
import { WithStatement } from '../api/statement/control/with.js';
|
|
39
|
+
import { VariableDeclarationNode, VariableDeclarator } from '../api/statement/declarations/declares.js';
|
|
40
|
+
import { ForAwaitOfNode, ForDeclaration, ForInNode, ForNode, ForOfNode } from '../api/statement/iterations/for.js';
|
|
41
|
+
import { DoWhileNode, WhileNode } from '../api/statement/iterations/while.js';
|
|
42
|
+
import type { NodeFactory, SourcePositionFactory } from './node.js';
|
|
43
|
+
export declare class ExpressionNodeSourcePosition implements SourcePositionFactory {
|
|
44
|
+
private source;
|
|
45
|
+
private newLineRegex;
|
|
46
|
+
constructor(source: string);
|
|
47
|
+
private getLineNumber;
|
|
48
|
+
private getColumnNumber;
|
|
49
|
+
createSourcePosition(range?: [number, number]): SourceLocation | undefined;
|
|
50
|
+
}
|
|
51
|
+
export declare class ExpressionNodeFactory implements NodeFactory {
|
|
52
|
+
private rangeFactory?;
|
|
53
|
+
constructor(rangeFactory?: SourcePositionFactory | undefined);
|
|
54
|
+
createDebuggerStatement(range?: [number, number]): DebuggerStatement;
|
|
55
|
+
createSuper(range?: [number, number]): Super;
|
|
56
|
+
createThis(range?: [number, number]): ThisExpression;
|
|
57
|
+
createNull(range?: [number, number]): Literal<null>;
|
|
58
|
+
createTrue(range?: [number, number]): Literal<true>;
|
|
59
|
+
createFalse(range?: [number, number]): Literal<false>;
|
|
60
|
+
createVoidZero(argument: ExpressionNode, range?: [number, number]): UnaryExpression;
|
|
61
|
+
createEmptyStatement(range?: [number, number]): EmptyStatement;
|
|
62
|
+
createExpressionStatement(list: ExpressionNode[], range?: [number, number]): ExpressionNode;
|
|
63
|
+
createCatchClause(block: BlockStatement, identifier?: ExpressionNode, range?: [number, number]): CatchClauseNode;
|
|
64
|
+
createTryStatement(tryBlock: BlockStatement, catchBlock?: ExpressionNode, finallyBlock?: ExpressionNode, range?: [number, number]): TryCatchNode;
|
|
65
|
+
createThrowStatement(exception: ExpressionNode, range?: [number, number]): ThrowStatement;
|
|
66
|
+
createBlock(statements: ExpressionNode[], range?: [number, number]): BlockStatement;
|
|
67
|
+
createIfStatement(condition: ExpressionNode, thenStatement: ExpressionNode, elseStatement?: ExpressionNode, range?: [number, number]): IfStatement;
|
|
68
|
+
createDoStatement(condition: ExpressionNode, body: ExpressionNode, range?: [number, number] | undefined): DoWhileNode;
|
|
69
|
+
createClassDeclaration(body: ClassBody, decorators: Decorator[], id: Identifier, superClass?: ExpressionNode, range?: [number, number]): ClassDeclaration;
|
|
70
|
+
createFunctionDeclaration(formals: DeclarationExpression[], bodyBlock: BlockStatement, isAsync: boolean, isGenerator: boolean, name: Identifier, range?: [number, number]): FunctionDeclaration;
|
|
71
|
+
createFunctionExpression(formals: DeclarationExpression[], bodyBlock: BlockStatement, isAsync: boolean, isGenerator: boolean, range?: [number, number]): FunctionExpression;
|
|
72
|
+
createWhileStatement(condition: ExpressionNode, body: ExpressionNode, range?: [number, number] | undefined): WhileNode;
|
|
73
|
+
createSwitchStatement(tag: ExpressionNode, cases: SwitchCase[], range?: [number, number] | undefined): SwitchStatement;
|
|
74
|
+
createCaseBlock(test: ExpressionNode, block: BlockStatement, range?: [number, number] | undefined): SwitchCase;
|
|
75
|
+
createDefaultClause(block: BlockStatement, range?: [number, number] | undefined): DefaultExpression;
|
|
76
|
+
createWithStatement(object: ExpressionNode, body: ExpressionNode, range?: [number, number]): WithStatement;
|
|
77
|
+
createForStatement(body: ExpressionNode, initializer: ExpressionNode, cond: ExpressionNode, next: ExpressionNode, range?: [number, number] | undefined): ForNode;
|
|
78
|
+
createForOfStatement(initializer: ForDeclaration, enumerable: ExpressionNode, body: ExpressionNode, range?: [number, number] | undefined): ForOfNode;
|
|
79
|
+
createForAwaitOfStatement(left: ForDeclaration, right: ExpressionNode, body: ExpressionNode, range?: [number, number] | undefined): ForAwaitOfNode;
|
|
80
|
+
createForInStatement(initializer: ForDeclaration, enumerable: ExpressionNode, body: ExpressionNode, range?: [number, number]): ForInNode;
|
|
81
|
+
createVariableDeclaration(id: DeclarationExpression, init?: ExpressionNode, range?: [number, number]): VariableDeclarator;
|
|
82
|
+
createVariableStatement(variables: VariableDeclarator[], kind: 'let' | 'var' | 'const', range?: [number, number]): VariableDeclarationNode;
|
|
83
|
+
createContinueStatement(label?: Identifier, range?: [number, number]): ContinueStatement;
|
|
84
|
+
createBreakStatement(label?: Identifier, range?: [number, number]): BreakStatement;
|
|
85
|
+
createReturnStatement(argument?: ExpressionNode, range?: [number, number]): ReturnStatement;
|
|
86
|
+
createLabeledStatement(expression: Identifier, result: ExpressionNode, range?: [number, number]): LabeledStatement;
|
|
87
|
+
createAssignmentPattern(left: DeclarationExpression, right: ExpressionNode, range?: [number, number]): AssignmentPattern;
|
|
88
|
+
createSpreadElement(argument: ExpressionNode, range?: [number, number]): SpreadElement;
|
|
89
|
+
createCommaListExpression(expressions: ExpressionNode[], range?: [number, number] | undefined): SequenceExpression;
|
|
90
|
+
createTemplateExpression(quasis: string[], expressions: ExpressionNode[], range?: [number, number]): TemplateLiteral;
|
|
91
|
+
createTaggedTemplateExpression(tag: ExpressionNode, quasis: string[], expressions: ExpressionNode[], range?: [number, number]): TaggedTemplateExpression;
|
|
92
|
+
createNewExpression(className: ExpressionNode, parameters?: ExpressionNode[], range?: [number, number]): NewExpression;
|
|
93
|
+
createObjectBindingPattern(properties: (Property | RestElement)[], range?: [number, number] | undefined): ObjectPattern;
|
|
94
|
+
createObjectLiteralExpression(properties: Property[], range?: [number, number]): ObjectExpression;
|
|
95
|
+
createArrayBindingPattern(elements: (DeclarationExpression | null)[], range?: [number, number]): ArrayPattern;
|
|
96
|
+
createArrayLiteralExpression(elements: (ExpressionNode | SpreadElement | null)[], range?: [number, number]): ArrayExpression;
|
|
97
|
+
createAssignment(operator: AssignmentOperator, left: ExpressionNode, right: ExpressionNode, range?: [number, number]): AssignmentExpression;
|
|
98
|
+
createRestElement(argument: DeclarationExpression, range?: [number, number]): RestElement;
|
|
99
|
+
createArrowFunction(params: DeclarationExpression[], body: ExpressionNode | ExpressionNode[], expression: boolean, async: boolean, range?: [number, number]): ArrowFunctionExpression;
|
|
100
|
+
createPropertyDeclaration(key: ExpressionNode, value: DeclarationExpression | ExpressionNode, kind: 'init' | 'get' | 'set', method: boolean, shorthand: boolean, computed: boolean, range?: [number, number]): Property;
|
|
101
|
+
createIdentifier(name: string, range?: [number, number]): Identifier;
|
|
102
|
+
createPropertyAssignment(object: ExpressionNode, property: ExpressionNode, computed: boolean, optional?: boolean, range?: [number, number]): MemberExpression;
|
|
103
|
+
createPipelineExpression(left: ExpressionNode, right: ExpressionNode, params?: (ExpressionNode | '?' | '...?')[], range?: [number, number]): PipelineExpression;
|
|
104
|
+
createCallExpression(callee: ExpressionNode, params: ExpressionNode[], optional?: boolean, range?: [number, number]): CallExpression;
|
|
105
|
+
createBindExpression(object: ExpressionNode, property: ExpressionNode, computed: boolean, optional?: boolean, range?: [number, number]): BindExpression;
|
|
106
|
+
createChainExpression(expression: ExpressionNode, range?: [number, number]): ChainExpression;
|
|
107
|
+
createLogicalExpression(operator: LogicalOperator, left: ExpressionNode, right: ExpressionNode, range?: [number, number]): LogicalExpression;
|
|
108
|
+
createConditionalExpression(test: ExpressionNode, alternate: ExpressionNode, consequent: ExpressionNode, range?: [number, number]): ConditionalExpression;
|
|
109
|
+
createYieldExpression(delegate: boolean, argument?: ExpressionNode, range?: [number, number]): YieldExpression;
|
|
110
|
+
createMetaProperty(meta: Identifier, property: Identifier, range?: [number, number]): MetaProperty;
|
|
111
|
+
createProgram(sourceType: ProgramSourceType, body: ExpressionNode[], range?: [number, number]): Program;
|
|
112
|
+
createClassExpression(body: ClassBody, decorators: Decorator[], id?: Identifier, superClass?: ExpressionNode, range?: [number, number]): ClassExpression;
|
|
113
|
+
createClassStaticBlockDeclaration(body: ExpressionNode[], range?: [number, number]): StaticBlock;
|
|
114
|
+
createMethodSignature(kind: MethodDefinitionKind, key: ExpressionNode | PrivateIdentifier, value: FunctionExpression, decorators: Decorator[], computed: boolean, isStatic: boolean, range?: [number, number]): MethodDefinition;
|
|
115
|
+
createPropertySignature(key: ExpressionNode | PrivateIdentifier, decorators: Decorator[], computed: boolean, isStatic: boolean, value?: ExpressionNode, range?: [number, number]): PropertyDefinition;
|
|
116
|
+
createClassBody(body: (MethodDefinition | PropertyDefinition | AccessorProperty | StaticBlock)[], range?: [number, number]): ClassBody;
|
|
117
|
+
createNamespaceExportDeclaration(specifiers: ExportSpecifier[], declaration?: DeclarationExpression, source?: Literal<string>, assertions?: ImportAttribute[], range?: [number, number]): ExportNamedDeclaration;
|
|
118
|
+
createExportSpecifier(local: Identifier, exported: Identifier, range?: [number, number]): ExportSpecifier;
|
|
119
|
+
createImportSpecifier(local: Identifier, imported: Identifier, range?: [number, number]): ImportSpecifier;
|
|
120
|
+
createImportDeclaration(source: Literal<string>, specifiers?: (ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier)[], assertions?: ImportAttribute[], range?: [number, number]): ImportDeclaration;
|
|
121
|
+
createImportNamespaceSpecifier(local: Identifier, range?: [number, number]): ImportNamespaceSpecifier;
|
|
122
|
+
createImportDefaultSpecifier(local: Identifier, range?: [number, number]): ImportDefaultSpecifier;
|
|
123
|
+
createImportExpression(source: Literal<string>, attributes?: ExpressionNode, range?: [number, number]): ImportExpression;
|
|
124
|
+
createAssertEntry(key: Identifier | Literal<string>, value: Literal<string>, range?: [number, number]): ImportAttribute;
|
|
125
|
+
createExportDefault(declaration: FunctionDeclaration | ClassDeclaration | ExpressionNode, range?: [number, number]): ExportDefaultDeclaration;
|
|
126
|
+
createExportAllDeclaration(source: Literal<string>, exported?: Identifier, assertions?: ImportAttribute[], range?: [number, number]): ExportAllDeclaration;
|
|
127
|
+
createInfixExpression(op: AssignmentOperator | LogicalOperator | BinaryOperator, left: ExpressionNode, right: ExpressionNode, range?: [number, number]): AssignmentExpression | LogicalExpression | BinaryExpression;
|
|
128
|
+
createUnaryExpression(operator: UpdateOperator | UnaryOperator | 'await', expression: ExpressionNode, range?: [number, number]): UpdateExpression | UnaryExpression | AwaitExpression;
|
|
129
|
+
createUpdateExpression(operator: UpdateOperator, argument: ExpressionNode, prefix: boolean, range?: [number, number]): UpdateExpression;
|
|
130
|
+
createAwaitExpression(argument: ExpressionNode, range?: [number, number]): AwaitExpression;
|
|
131
|
+
isIdentifier(node?: ExpressionNode): node is Identifier;
|
|
132
|
+
isObjectExpression(node?: ExpressionNode): node is ObjectExpression;
|
|
133
|
+
isArrayExpression(node?: ExpressionNode): node is ArrayExpression;
|
|
134
|
+
isObjectPattern(node?: ExpressionNode): node is ObjectPattern;
|
|
135
|
+
isArrayPattern(node?: ExpressionNode): node is ArrayPattern;
|
|
136
|
+
isAssignmentPattern(node?: ExpressionNode): node is AssignmentPattern;
|
|
137
|
+
isPattern(node?: ExpressionNode): boolean;
|
|
138
|
+
canBePattern(node?: ExpressionNode): node is (ObjectExpression | ArrayExpression);
|
|
139
|
+
isProperty(node?: ExpressionNode): node is Property;
|
|
140
|
+
isMemberExpression(node?: ExpressionNode): node is MemberExpression;
|
|
141
|
+
isPropertyOrMemberExpression(node?: ExpressionNode): node is (Property | MemberExpression);
|
|
142
|
+
isEmptyStatement(node: ExpressionNode): node is EmptyStatement;
|
|
143
|
+
isSequenceExpression(node: ExpressionNode): node is SequenceExpression;
|
|
144
|
+
isSuper(node: ExpressionNode): node is Super;
|
|
145
|
+
isAssignmentExpression(node: ExpressionNode): node is AssignmentExpression;
|
|
146
|
+
isGroupingExpression(node: ExpressionNode): node is GroupingExpression;
|
|
147
|
+
isSpreadElement(node: ExpressionNode): node is SpreadElement;
|
|
148
|
+
}
|
package/v8/factory.js
ADDED
|
@@ -0,0 +1,499 @@
|
|
|
1
|
+
import { ClassBody, ClassDeclaration, ClassExpression, MetaProperty, MethodDefinition, PropertyDefinition, StaticBlock, Super } from '../api/class/class.js';
|
|
2
|
+
import { CallExpression } from '../api/computing/call.js';
|
|
3
|
+
import { DebuggerStatement } from '../api/computing/debugger.js';
|
|
4
|
+
import { NewExpression } from '../api/computing/new.js';
|
|
5
|
+
import { RestElement } from '../api/computing/rest.js';
|
|
6
|
+
import { ReturnStatement } from '../api/computing/return.js';
|
|
7
|
+
import { SpreadElement } from '../api/computing/spread.js';
|
|
8
|
+
import { CatchClauseNode, ThrowStatement, TryCatchNode } from '../api/computing/throw.js';
|
|
9
|
+
import { YieldExpression } from '../api/computing/yield.js';
|
|
10
|
+
import { ArrayExpression, ArrayPattern } from '../api/definition/array.js';
|
|
11
|
+
import { BindExpression } from '../api/definition/bind.js';
|
|
12
|
+
import { ArrowFunctionExpression, AssignmentPattern, FunctionDeclaration, FunctionExpression } from '../api/definition/function.js';
|
|
13
|
+
import { MemberExpression } from '../api/definition/member.js';
|
|
14
|
+
import { ObjectExpression, ObjectPattern, Property } from '../api/definition/object.js';
|
|
15
|
+
import { ExpressionStatement } from '../api/definition/statement.js';
|
|
16
|
+
import { Identifier, Literal, TaggedTemplateExpression, TemplateLiteral, ThisExpression } from '../api/definition/values.js';
|
|
17
|
+
import { ImportAttribute } from '../api/module/common.js';
|
|
18
|
+
import { ExportAllDeclaration, ExportDefaultDeclaration, ExportNamedDeclaration, ExportSpecifier } from '../api/module/export.js';
|
|
19
|
+
import { ImportDeclaration, ImportDefaultSpecifier, ImportExpression, ImportNamespaceSpecifier, ImportSpecifier } from '../api/module/import.js';
|
|
20
|
+
import { AssignmentExpression } from '../api/operators/assignment.js';
|
|
21
|
+
import { AwaitExpression } from '../api/operators/await.js';
|
|
22
|
+
import { BinaryExpression } from '../api/operators/binary.js';
|
|
23
|
+
import { ChainExpression } from '../api/operators/chaining.js';
|
|
24
|
+
import { SequenceExpression } from '../api/operators/comma.js';
|
|
25
|
+
import { GroupingExpression } from '../api/operators/grouping.js';
|
|
26
|
+
import { LogicalExpression } from '../api/operators/logical.js';
|
|
27
|
+
import { PipelineExpression } from '../api/operators/pipeline.js';
|
|
28
|
+
import { ConditionalExpression } from '../api/operators/ternary.js';
|
|
29
|
+
import { UnaryExpression } from '../api/operators/unary.js';
|
|
30
|
+
import { UpdateExpression } from '../api/operators/update.js';
|
|
31
|
+
import { Program } from '../api/program.js';
|
|
32
|
+
import { BlockStatement } from '../api/statement/control/block.js';
|
|
33
|
+
import { EmptyStatement } from '../api/statement/control/empty.js';
|
|
34
|
+
import { IfStatement } from '../api/statement/control/if.js';
|
|
35
|
+
import { DefaultExpression, SwitchCase, SwitchStatement } from '../api/statement/control/switch.js';
|
|
36
|
+
import { BreakStatement, ContinueStatement, LabeledStatement } from '../api/statement/control/terminate.js';
|
|
37
|
+
import { WithStatement } from '../api/statement/control/with.js';
|
|
38
|
+
import { VariableDeclarationNode, VariableDeclarator } from '../api/statement/declarations/declares.js';
|
|
39
|
+
import { ForAwaitOfNode, ForInNode, ForNode, ForOfNode } from '../api/statement/iterations/for.js';
|
|
40
|
+
import { DoWhileNode, WhileNode } from '../api/statement/iterations/while.js';
|
|
41
|
+
export class ExpressionNodeSourcePosition {
|
|
42
|
+
constructor(source) {
|
|
43
|
+
this.source = source;
|
|
44
|
+
this.newLineRegex = new RegExp('\n', 'g');
|
|
45
|
+
}
|
|
46
|
+
getLineNumber(index, defaultValue) {
|
|
47
|
+
return this.source.substring(0, index).match(this.newLineRegex)?.length ?? defaultValue;
|
|
48
|
+
}
|
|
49
|
+
getColumnNumber(index) {
|
|
50
|
+
const end = this.source.lastIndexOf('\n', index);
|
|
51
|
+
if (end === -1) {
|
|
52
|
+
return index;
|
|
53
|
+
}
|
|
54
|
+
return index - end - 1;
|
|
55
|
+
}
|
|
56
|
+
createSourcePosition(range) {
|
|
57
|
+
if (!range || !this.source) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const startLine = this.getLineNumber(range[0], 1);
|
|
61
|
+
const endLine = this.getLineNumber(range[1], startLine);
|
|
62
|
+
const startColumn = this.getColumnNumber(range[0]);
|
|
63
|
+
const endColumn = this.getColumnNumber(range[1]);
|
|
64
|
+
return {
|
|
65
|
+
start: { line: startLine, column: startColumn },
|
|
66
|
+
end: { line: endLine, column: endColumn },
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
export class ExpressionNodeFactory {
|
|
71
|
+
constructor(rangeFactory) {
|
|
72
|
+
this.rangeFactory = rangeFactory;
|
|
73
|
+
}
|
|
74
|
+
createDebuggerStatement(range) {
|
|
75
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
76
|
+
return new DebuggerStatement(range, loc);
|
|
77
|
+
}
|
|
78
|
+
createSuper(range) {
|
|
79
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
80
|
+
return new Super(range, loc);
|
|
81
|
+
}
|
|
82
|
+
createThis(range) {
|
|
83
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
84
|
+
return new ThisExpression(range, loc);
|
|
85
|
+
}
|
|
86
|
+
createNull(range) {
|
|
87
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
88
|
+
return new Literal(null, undefined, undefined, undefined, range, loc);
|
|
89
|
+
}
|
|
90
|
+
createTrue(range) {
|
|
91
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
92
|
+
return new Literal(true, undefined, undefined, undefined, range, loc);
|
|
93
|
+
}
|
|
94
|
+
createFalse(range) {
|
|
95
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
96
|
+
return new Literal(false, undefined, undefined, undefined, range, loc);
|
|
97
|
+
}
|
|
98
|
+
createVoidZero(argument, range) {
|
|
99
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
100
|
+
return new UnaryExpression('void', argument, range, loc);
|
|
101
|
+
}
|
|
102
|
+
createEmptyStatement(range) {
|
|
103
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
104
|
+
return new EmptyStatement(range, loc);
|
|
105
|
+
}
|
|
106
|
+
createExpressionStatement(list, range) {
|
|
107
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
108
|
+
return new ExpressionStatement(list, range, loc);
|
|
109
|
+
}
|
|
110
|
+
createCatchClause(block, identifier, range) {
|
|
111
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
112
|
+
return new CatchClauseNode(block, identifier, range, loc);
|
|
113
|
+
}
|
|
114
|
+
createTryStatement(tryBlock, catchBlock, finallyBlock, range) {
|
|
115
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
116
|
+
return new TryCatchNode(tryBlock, catchBlock, finallyBlock, range, loc);
|
|
117
|
+
}
|
|
118
|
+
createThrowStatement(exception, range) {
|
|
119
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
120
|
+
return new ThrowStatement(exception, range, loc);
|
|
121
|
+
}
|
|
122
|
+
createBlock(statements, range) {
|
|
123
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
124
|
+
return new BlockStatement(statements, range, loc);
|
|
125
|
+
}
|
|
126
|
+
createIfStatement(condition, thenStatement, elseStatement, range) {
|
|
127
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
128
|
+
return new IfStatement(condition, thenStatement, elseStatement, range, loc);
|
|
129
|
+
}
|
|
130
|
+
createDoStatement(condition, body, range) {
|
|
131
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
132
|
+
return new DoWhileNode(condition, body, range, loc);
|
|
133
|
+
}
|
|
134
|
+
createClassDeclaration(body, decorators, id, superClass, range) {
|
|
135
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
136
|
+
return new ClassDeclaration(body, decorators, id, superClass, range, loc);
|
|
137
|
+
}
|
|
138
|
+
createFunctionDeclaration(formals, bodyBlock, isAsync, isGenerator, name, range) {
|
|
139
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
140
|
+
return new FunctionDeclaration(formals, bodyBlock, isAsync, isGenerator, name, range, loc);
|
|
141
|
+
}
|
|
142
|
+
createFunctionExpression(formals, bodyBlock, isAsync, isGenerator, range) {
|
|
143
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
144
|
+
return new FunctionExpression(formals, bodyBlock, isAsync, isGenerator, undefined, range, loc);
|
|
145
|
+
}
|
|
146
|
+
createWhileStatement(condition, body, range) {
|
|
147
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
148
|
+
return new WhileNode(condition, body, range, loc);
|
|
149
|
+
}
|
|
150
|
+
createSwitchStatement(tag, cases, range) {
|
|
151
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
152
|
+
return new SwitchStatement(tag, cases, range, loc);
|
|
153
|
+
}
|
|
154
|
+
createCaseBlock(test, block, range) {
|
|
155
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
156
|
+
return new SwitchCase(test, block, range, loc);
|
|
157
|
+
}
|
|
158
|
+
createDefaultClause(block, range) {
|
|
159
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
160
|
+
return new DefaultExpression(block, range, loc);
|
|
161
|
+
}
|
|
162
|
+
createWithStatement(object, body, range) {
|
|
163
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
164
|
+
return new WithStatement(object, body, range, loc);
|
|
165
|
+
}
|
|
166
|
+
createForStatement(body, initializer, cond, next, range) {
|
|
167
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
168
|
+
return new ForNode(body, initializer, cond, next, range, loc);
|
|
169
|
+
}
|
|
170
|
+
createForOfStatement(initializer, enumerable, body, range) {
|
|
171
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
172
|
+
return new ForOfNode(initializer, enumerable, body, range, loc);
|
|
173
|
+
}
|
|
174
|
+
createForAwaitOfStatement(left, right, body, range) {
|
|
175
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
176
|
+
return new ForAwaitOfNode(left, right, body, range, loc);
|
|
177
|
+
}
|
|
178
|
+
createForInStatement(initializer, enumerable, body, range) {
|
|
179
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
180
|
+
return new ForInNode(initializer, enumerable, body, range, loc);
|
|
181
|
+
}
|
|
182
|
+
createVariableDeclaration(id, init, range) {
|
|
183
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
184
|
+
return new VariableDeclarator(id, init, range, loc);
|
|
185
|
+
}
|
|
186
|
+
createVariableStatement(variables, kind, range) {
|
|
187
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
188
|
+
return new VariableDeclarationNode(variables, kind, range, loc);
|
|
189
|
+
}
|
|
190
|
+
createContinueStatement(label, range) {
|
|
191
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
192
|
+
return new ContinueStatement(label, range, loc);
|
|
193
|
+
}
|
|
194
|
+
createBreakStatement(label, range) {
|
|
195
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
196
|
+
return new BreakStatement(label, range, loc);
|
|
197
|
+
}
|
|
198
|
+
createReturnStatement(argument, range) {
|
|
199
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
200
|
+
return new ReturnStatement(argument, range, loc);
|
|
201
|
+
}
|
|
202
|
+
createLabeledStatement(expression, result, range) {
|
|
203
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
204
|
+
return new LabeledStatement(expression, result, range, loc);
|
|
205
|
+
}
|
|
206
|
+
createAssignmentPattern(left, right, range) {
|
|
207
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
208
|
+
return new AssignmentPattern(left, right, range, loc);
|
|
209
|
+
}
|
|
210
|
+
createSpreadElement(argument, range) {
|
|
211
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
212
|
+
return new SpreadElement(argument, range, loc);
|
|
213
|
+
}
|
|
214
|
+
createCommaListExpression(expressions, range) {
|
|
215
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
216
|
+
return new SequenceExpression(expressions, range, loc);
|
|
217
|
+
}
|
|
218
|
+
createTemplateExpression(quasis, expressions, range) {
|
|
219
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
220
|
+
return new TemplateLiteral(quasis, expressions, range, loc);
|
|
221
|
+
}
|
|
222
|
+
createTaggedTemplateExpression(tag, quasis, expressions, range) {
|
|
223
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
224
|
+
return new TaggedTemplateExpression(tag, quasis, expressions, range, loc);
|
|
225
|
+
}
|
|
226
|
+
createNewExpression(className, parameters, range) {
|
|
227
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
228
|
+
return new NewExpression(className, parameters, range, loc);
|
|
229
|
+
}
|
|
230
|
+
createObjectBindingPattern(properties, range) {
|
|
231
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
232
|
+
return new ObjectPattern(properties, range, loc);
|
|
233
|
+
}
|
|
234
|
+
createObjectLiteralExpression(properties, range) {
|
|
235
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
236
|
+
return new ObjectExpression(properties, range, loc);
|
|
237
|
+
}
|
|
238
|
+
createArrayBindingPattern(elements, range) {
|
|
239
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
240
|
+
return new ArrayPattern(elements, range, loc);
|
|
241
|
+
}
|
|
242
|
+
createArrayLiteralExpression(elements, range) {
|
|
243
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
244
|
+
return new ArrayExpression(elements, range, loc);
|
|
245
|
+
}
|
|
246
|
+
createAssignment(operator, left, right, range) {
|
|
247
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
248
|
+
return new AssignmentExpression(operator, left, right, range, loc);
|
|
249
|
+
}
|
|
250
|
+
createRestElement(argument, range) {
|
|
251
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
252
|
+
return new RestElement(argument, range, loc);
|
|
253
|
+
}
|
|
254
|
+
createArrowFunction(params, body, expression, async, range) {
|
|
255
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
256
|
+
return new ArrowFunctionExpression(params, body, expression, async, range, loc);
|
|
257
|
+
}
|
|
258
|
+
createPropertyDeclaration(key, value, kind, method, shorthand, computed, range) {
|
|
259
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
260
|
+
return new Property(key, value, kind, method, shorthand, computed, range, loc);
|
|
261
|
+
}
|
|
262
|
+
createIdentifier(name, range) {
|
|
263
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
264
|
+
return new Identifier(name, range, loc);
|
|
265
|
+
}
|
|
266
|
+
createPropertyAssignment(object, property, computed, optional, range) {
|
|
267
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
268
|
+
return new MemberExpression(object, property, computed, optional, range, loc);
|
|
269
|
+
}
|
|
270
|
+
createPipelineExpression(left, right, params, range) {
|
|
271
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
272
|
+
return new PipelineExpression(left, right, params, range, loc);
|
|
273
|
+
}
|
|
274
|
+
createCallExpression(callee, params, optional, range) {
|
|
275
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
276
|
+
return new CallExpression(callee, params, optional, range, loc);
|
|
277
|
+
}
|
|
278
|
+
createBindExpression(object, property, computed, optional, range) {
|
|
279
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
280
|
+
return new BindExpression(object, property, computed, optional, range, loc);
|
|
281
|
+
}
|
|
282
|
+
createChainExpression(expression, range) {
|
|
283
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
284
|
+
return new ChainExpression(expression, range, loc);
|
|
285
|
+
}
|
|
286
|
+
createLogicalExpression(operator, left, right, range) {
|
|
287
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
288
|
+
return new LogicalExpression(operator, left, right, range, loc);
|
|
289
|
+
}
|
|
290
|
+
createConditionalExpression(test, alternate, consequent, range) {
|
|
291
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
292
|
+
return new ConditionalExpression(test, alternate, consequent, range, loc);
|
|
293
|
+
}
|
|
294
|
+
createYieldExpression(delegate, argument, range) {
|
|
295
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
296
|
+
return new YieldExpression(delegate, argument, range, loc);
|
|
297
|
+
}
|
|
298
|
+
createMetaProperty(meta, property, range) {
|
|
299
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
300
|
+
return new MetaProperty(meta, property, range, loc);
|
|
301
|
+
}
|
|
302
|
+
createProgram(sourceType, body, range) {
|
|
303
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
304
|
+
return new Program(sourceType, body, range, loc);
|
|
305
|
+
}
|
|
306
|
+
createClassExpression(body, decorators, id, superClass, range) {
|
|
307
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
308
|
+
return new ClassExpression(body, decorators, id, superClass, range, loc);
|
|
309
|
+
}
|
|
310
|
+
createClassStaticBlockDeclaration(body, range) {
|
|
311
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
312
|
+
return new StaticBlock(body, range, loc);
|
|
313
|
+
}
|
|
314
|
+
createMethodSignature(kind, key, value, decorators, computed, isStatic, range) {
|
|
315
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
316
|
+
return new MethodDefinition(kind, key, value, decorators, computed, isStatic, range, loc);
|
|
317
|
+
}
|
|
318
|
+
createPropertySignature(key, decorators, computed, isStatic, value, range) {
|
|
319
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
320
|
+
return new PropertyDefinition(key, decorators, computed, isStatic, value, range, loc);
|
|
321
|
+
}
|
|
322
|
+
createClassBody(body, range) {
|
|
323
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
324
|
+
return new ClassBody(body, range, loc);
|
|
325
|
+
}
|
|
326
|
+
createNamespaceExportDeclaration(specifiers, declaration, source, assertions, range) {
|
|
327
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
328
|
+
return new ExportNamedDeclaration(specifiers, declaration, source, assertions, range, loc);
|
|
329
|
+
}
|
|
330
|
+
createExportSpecifier(local, exported, range) {
|
|
331
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
332
|
+
return new ExportSpecifier(local, exported, range, loc);
|
|
333
|
+
}
|
|
334
|
+
createImportSpecifier(local, imported, range) {
|
|
335
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
336
|
+
return new ImportSpecifier(local, imported, range, loc);
|
|
337
|
+
}
|
|
338
|
+
createImportDeclaration(source, specifiers, assertions, range) {
|
|
339
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
340
|
+
return new ImportDeclaration(source, specifiers, assertions, range, loc);
|
|
341
|
+
}
|
|
342
|
+
createImportNamespaceSpecifier(local, range) {
|
|
343
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
344
|
+
return new ImportNamespaceSpecifier(local, range, loc);
|
|
345
|
+
}
|
|
346
|
+
createImportDefaultSpecifier(local, range) {
|
|
347
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
348
|
+
return new ImportDefaultSpecifier(local, range, loc);
|
|
349
|
+
}
|
|
350
|
+
createImportExpression(source, attributes, range) {
|
|
351
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
352
|
+
return new ImportExpression(source, attributes, range, loc);
|
|
353
|
+
}
|
|
354
|
+
createAssertEntry(key, value, range) {
|
|
355
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
356
|
+
return new ImportAttribute(key, value, range, loc);
|
|
357
|
+
}
|
|
358
|
+
createExportDefault(declaration, range) {
|
|
359
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
360
|
+
return new ExportDefaultDeclaration(declaration, range, loc);
|
|
361
|
+
}
|
|
362
|
+
createExportAllDeclaration(source, exported, assertions, range) {
|
|
363
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
364
|
+
return new ExportAllDeclaration(source, exported, assertions, range, loc);
|
|
365
|
+
}
|
|
366
|
+
createInfixExpression(op, left, right, range) {
|
|
367
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
368
|
+
switch (op) {
|
|
369
|
+
case '=':
|
|
370
|
+
case '+=':
|
|
371
|
+
case '-=':
|
|
372
|
+
case '**=':
|
|
373
|
+
case '/=':
|
|
374
|
+
case '%=':
|
|
375
|
+
case '<<=':
|
|
376
|
+
case '>>=':
|
|
377
|
+
case '>>>=':
|
|
378
|
+
case '&=':
|
|
379
|
+
case '^=':
|
|
380
|
+
case '|=':
|
|
381
|
+
case '&&=':
|
|
382
|
+
case '||=':
|
|
383
|
+
case '??=':
|
|
384
|
+
return new AssignmentExpression(op, left, right, range, loc);
|
|
385
|
+
case '&&':
|
|
386
|
+
case '||':
|
|
387
|
+
case '??':
|
|
388
|
+
return new LogicalExpression(op, left, right, range, loc);
|
|
389
|
+
case '**':
|
|
390
|
+
case '*':
|
|
391
|
+
case '/':
|
|
392
|
+
case '%':
|
|
393
|
+
case '+':
|
|
394
|
+
case '-':
|
|
395
|
+
case '<':
|
|
396
|
+
case '<=':
|
|
397
|
+
case '>':
|
|
398
|
+
case '>=':
|
|
399
|
+
case 'in':
|
|
400
|
+
case 'instanceof':
|
|
401
|
+
case '==':
|
|
402
|
+
case '!=':
|
|
403
|
+
case '===':
|
|
404
|
+
case '!==':
|
|
405
|
+
case '<<':
|
|
406
|
+
case '>>':
|
|
407
|
+
case '>>>':
|
|
408
|
+
case '&':
|
|
409
|
+
case '^':
|
|
410
|
+
case '|':
|
|
411
|
+
case '>?':
|
|
412
|
+
case '<?':
|
|
413
|
+
case '<=>':
|
|
414
|
+
return new BinaryExpression(op, left, right, range, loc);
|
|
415
|
+
default:
|
|
416
|
+
throw new Error(`Not Supported Operator: ${op}`);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
createUnaryExpression(operator, expression, range) {
|
|
420
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
421
|
+
switch (operator) {
|
|
422
|
+
case '++':
|
|
423
|
+
case '--':
|
|
424
|
+
return new UpdateExpression(operator, expression, true);
|
|
425
|
+
case '+':
|
|
426
|
+
case '-':
|
|
427
|
+
case '!':
|
|
428
|
+
case '~':
|
|
429
|
+
case 'typeof':
|
|
430
|
+
case 'void':
|
|
431
|
+
case 'delete':
|
|
432
|
+
return new UnaryExpression(operator, expression);
|
|
433
|
+
case 'await':
|
|
434
|
+
return new AwaitExpression(expression);
|
|
435
|
+
default:
|
|
436
|
+
throw new Error(`${operator} is not prefix operator`);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
createUpdateExpression(operator, argument, prefix, range) {
|
|
440
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
441
|
+
return new UpdateExpression(operator, argument, prefix, range, loc);
|
|
442
|
+
}
|
|
443
|
+
createAwaitExpression(argument, range) {
|
|
444
|
+
const loc = this.rangeFactory?.createSourcePosition(range);
|
|
445
|
+
return new AwaitExpression(argument, range, loc);
|
|
446
|
+
}
|
|
447
|
+
isIdentifier(node) {
|
|
448
|
+
return node instanceof Identifier || node?.type === 'Identifier';
|
|
449
|
+
}
|
|
450
|
+
isObjectExpression(node) {
|
|
451
|
+
return node instanceof ObjectExpression || node?.type === 'ObjectExpression';
|
|
452
|
+
}
|
|
453
|
+
isArrayExpression(node) {
|
|
454
|
+
return node instanceof ArrayExpression || node?.type === 'ArrayExpression';
|
|
455
|
+
}
|
|
456
|
+
isObjectPattern(node) {
|
|
457
|
+
return node instanceof ObjectPattern || node?.type === 'ObjectPattern';
|
|
458
|
+
}
|
|
459
|
+
isArrayPattern(node) {
|
|
460
|
+
return node instanceof ArrayPattern || node?.type === 'ArrayPattern';
|
|
461
|
+
}
|
|
462
|
+
isAssignmentPattern(node) {
|
|
463
|
+
return node instanceof AssignmentPattern || node?.type === 'AssignmentPattern';
|
|
464
|
+
}
|
|
465
|
+
isPattern(node) {
|
|
466
|
+
return this.isObjectPattern(node) || this.isArrayPattern(node) || this.isAssignmentPattern(node);
|
|
467
|
+
}
|
|
468
|
+
canBePattern(node) {
|
|
469
|
+
return this.isObjectExpression(node) || this.isArrayExpression(node);
|
|
470
|
+
}
|
|
471
|
+
isProperty(node) {
|
|
472
|
+
return node instanceof Property || node?.type === 'Property';
|
|
473
|
+
}
|
|
474
|
+
isMemberExpression(node) {
|
|
475
|
+
return node instanceof MemberExpression || node?.type === 'MemberExpression';
|
|
476
|
+
}
|
|
477
|
+
isPropertyOrMemberExpression(node) {
|
|
478
|
+
return this.isProperty(node) || this.isMemberExpression(node);
|
|
479
|
+
}
|
|
480
|
+
isEmptyStatement(node) {
|
|
481
|
+
return node instanceof EmptyStatement || node?.type === 'EmptyStatement';
|
|
482
|
+
}
|
|
483
|
+
isSequenceExpression(node) {
|
|
484
|
+
return node instanceof SequenceExpression || node?.type === 'SequenceExpression';
|
|
485
|
+
}
|
|
486
|
+
isSuper(node) {
|
|
487
|
+
return node instanceof Super || node?.type === 'Super';
|
|
488
|
+
}
|
|
489
|
+
isAssignmentExpression(node) {
|
|
490
|
+
return node instanceof AssignmentExpression || node?.type === 'AssignmentExpression';
|
|
491
|
+
}
|
|
492
|
+
isGroupingExpression(node) {
|
|
493
|
+
return node instanceof GroupingExpression || node?.type === 'GroupingExpression';
|
|
494
|
+
}
|
|
495
|
+
isSpreadElement(node) {
|
|
496
|
+
return node instanceof SpreadElement || node?.type === 'SpreadElement';
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
//# sourceMappingURL=factory.js.map
|