@next-core/cook 2.4.1 → 2.4.3
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/dist/cjs/AnalysisContext.js.map +1 -1
- package/dist/cjs/cook.js +14 -2
- package/dist/cjs/cook.js.map +1 -1
- package/dist/cjs/precook.js +16 -3
- package/dist/cjs/precook.js.map +1 -1
- package/dist/esm/AnalysisContext.js.map +1 -1
- package/dist/esm/cook.js +12 -2
- package/dist/esm/cook.js.map +1 -1
- package/dist/esm/precook.js +16 -3
- package/dist/esm/precook.js.map +1 -1
- package/dist/types/AnalysisContext.d.ts +1 -0
- package/dist/types/cook.d.ts +3 -0
- package/dist/types/precook.d.ts +2 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnalysisContext.js","names":["AnalysisContext","VariableEnvironment","LexicalEnvironment","exports","AnalysisEnvironment","OuterEnv","bindingSet","Set","constructor","outer","HasBinding","name","has","CreateBinding","add"],"sources":["../../src/AnalysisContext.ts"],"sourcesContent":["import {\n ArrowFunctionExpression,\n Expression,\n FunctionDeclaration,\n FunctionExpression,\n Statement,\n} from \"@babel/types\";\n\n// https://tc39.es/ecma262/#sec-execution-contexts\nexport class AnalysisContext {\n VariableEnvironment?: AnalysisEnvironment;\n LexicalEnvironment?: AnalysisEnvironment;\n}\n\n// https://tc39.es/ecma262/#sec-environment-records\nexport class AnalysisEnvironment {\n readonly OuterEnv: AnalysisEnvironment | null | undefined;\n private readonly bindingSet = new Set<string>();\n\n constructor(outer: AnalysisEnvironment | null | undefined) {\n this.OuterEnv = outer;\n }\n\n HasBinding(name: string): boolean {\n return this.bindingSet.has(name);\n }\n\n CreateBinding(name: string): void {\n this.bindingSet.add(name);\n }\n}\n\nexport interface AnalysisFunctionObject {\n Function: FunctionDeclaration | FunctionExpression | ArrowFunctionExpression;\n FormalParameters: FunctionDeclaration[\"params\"];\n ECMAScriptCode: Statement[] | Expression;\n Environment?: AnalysisEnvironment;\n}\n"],"mappings":";;;;;;AAQA;AACO,MAAMA,eAAe,CAAC;EAC3BC,mBAAmB;EACnBC,kBAAkB;AACpB;;AAEA;AAAAC,OAAA,CAAAH,eAAA,GAAAA,eAAA;AACO,MAAMI,mBAAmB,CAAC;EACtBC,QAAQ;EACAC,UAAU,GAAG,IAAIC,GAAG,CAAS,CAAC;EAE/CC,WAAWA,CAACC,KAA6C,EAAE;IACzD,IAAI,CAACJ,QAAQ,GAAGI,KAAK;EACvB;EAEAC,UAAUA,CAACC,IAAY,EAAW;IAChC,OAAO,IAAI,CAACL,UAAU,CAACM,GAAG,CAACD,IAAI,CAAC;EAClC;EAEAE,aAAaA,CAACF,IAAY,EAAQ;IAChC,IAAI,CAACL,UAAU,CAACQ,GAAG,CAACH,IAAI,CAAC;EAC3B;AACF;AAACR,OAAA,CAAAC,mBAAA,GAAAA,mBAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"AnalysisContext.js","names":["AnalysisContext","VariableEnvironment","LexicalEnvironment","exports","AnalysisEnvironment","OuterEnv","bindingSet","Set","constructor","outer","HasBinding","name","has","CreateBinding","add"],"sources":["../../src/AnalysisContext.ts"],"sourcesContent":["import {\n ArrowFunctionExpression,\n Expression,\n FunctionDeclaration,\n FunctionExpression,\n Statement,\n} from \"@babel/types\";\n\n// https://tc39.es/ecma262/#sec-execution-contexts\nexport class AnalysisContext {\n VariableEnvironment?: AnalysisEnvironment;\n LexicalEnvironment?: AnalysisEnvironment;\n}\n\n// https://tc39.es/ecma262/#sec-environment-records\nexport class AnalysisEnvironment {\n readonly OuterEnv: AnalysisEnvironment | null | undefined;\n private readonly bindingSet = new Set<string>();\n\n constructor(outer: AnalysisEnvironment | null | undefined) {\n this.OuterEnv = outer;\n }\n\n HasBinding(name: string): boolean {\n return this.bindingSet.has(name);\n }\n\n CreateBinding(name: string): void {\n this.bindingSet.add(name);\n }\n}\n\nexport interface AnalysisFunctionObject {\n Function: FunctionDeclaration | FunctionExpression | ArrowFunctionExpression;\n FormalParameters: FunctionDeclaration[\"params\"];\n ECMAScriptCode: Statement[] | Expression;\n Environment?: AnalysisEnvironment;\n ThisMode: \"LEXICAL\" | \"STRICT\";\n}\n"],"mappings":";;;;;;AAQA;AACO,MAAMA,eAAe,CAAC;EAC3BC,mBAAmB;EACnBC,kBAAkB;AACpB;;AAEA;AAAAC,OAAA,CAAAH,eAAA,GAAAA,eAAA;AACO,MAAMI,mBAAmB,CAAC;EACtBC,QAAQ;EACAC,UAAU,GAAG,IAAIC,GAAG,CAAS,CAAC;EAE/CC,WAAWA,CAACC,KAA6C,EAAE;IACzD,IAAI,CAACJ,QAAQ,GAAGI,KAAK;EACvB;EAEAC,UAAUA,CAACC,IAAY,EAAW;IAChC,OAAO,IAAI,CAACL,UAAU,CAACM,GAAG,CAACD,IAAI,CAAC;EAClC;EAEAE,aAAaA,CAACF,IAAY,EAAQ;IAChC,IAAI,CAACL,UAAU,CAACQ,GAAG,CAACH,IAAI,CAAC;EAC3B;AACF;AAACR,OAAA,CAAAC,mBAAA,GAAAA,mBAAA","ignoreList":[]}
|
package/dist/cjs/cook.js
CHANGED
|
@@ -3,11 +3,21 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.__dev_only_clearGlobalExecutionContextStack = __dev_only_clearGlobalExecutionContextStack;
|
|
7
|
+
exports.__dev_only_getGlobalExecutionContextStack = __dev_only_getGlobalExecutionContextStack;
|
|
6
8
|
exports.cook = cook;
|
|
7
9
|
var _contextFree = require("./context-free.js");
|
|
8
10
|
var _ExecutionContext = require("./ExecutionContext.js");
|
|
9
11
|
var _sanitize = require("./sanitize.js");
|
|
10
12
|
var _traverse = require("./traverse.js");
|
|
13
|
+
const globalExecutionContextStack = [];
|
|
14
|
+
function __dev_only_clearGlobalExecutionContextStack() {
|
|
15
|
+
globalExecutionContextStack.length = 0;
|
|
16
|
+
}
|
|
17
|
+
function __dev_only_getGlobalExecutionContextStack() {
|
|
18
|
+
return globalExecutionContextStack;
|
|
19
|
+
}
|
|
20
|
+
|
|
11
21
|
/** For next-core internal usage only. */
|
|
12
22
|
function cook(rootAst, codeSource, {
|
|
13
23
|
rules,
|
|
@@ -442,7 +452,7 @@ function cook(rootAst, codeSource, {
|
|
|
442
452
|
}
|
|
443
453
|
} else if (declarator.id.type === "Identifier") {
|
|
444
454
|
currentNode = declarator.init;
|
|
445
|
-
if (debug) yield;
|
|
455
|
+
if (debug && currentNode.type !== "CallExpression" && currentNode.type !== "TaggedTemplateExpression") yield;
|
|
446
456
|
const bindingId = declarator.id.name;
|
|
447
457
|
const lhs = ResolveBinding(bindingId);
|
|
448
458
|
let value;
|
|
@@ -455,7 +465,7 @@ function cook(rootAst, codeSource, {
|
|
|
455
465
|
result = node.kind === "var" ? (0, _contextFree.PutValue)(lhs, value) : (0, _contextFree.InitializeReferencedBinding)(lhs, value);
|
|
456
466
|
} else {
|
|
457
467
|
currentNode = declarator.init;
|
|
458
|
-
if (debug) yield;
|
|
468
|
+
if (debug && currentNode.type !== "CallExpression" && currentNode.type !== "TaggedTemplateExpression") yield;
|
|
459
469
|
const rhs = yield* Evaluate(declarator.init);
|
|
460
470
|
const rval = (0, _contextFree.GetValue)(rhs);
|
|
461
471
|
result = yield* BindingInitialization(declarator.id, rval, node.kind === "var" ? undefined : getRunningContext().LexicalEnvironment);
|
|
@@ -1063,6 +1073,7 @@ function cook(rootAst, codeSource, {
|
|
|
1063
1073
|
};
|
|
1064
1074
|
}
|
|
1065
1075
|
executionContextStack.pop();
|
|
1076
|
+
globalExecutionContextStack.pop();
|
|
1066
1077
|
if (result.Type === "return") {
|
|
1067
1078
|
return result.Value;
|
|
1068
1079
|
}
|
|
@@ -1077,6 +1088,7 @@ function cook(rootAst, codeSource, {
|
|
|
1077
1088
|
calleeContext.VariableEnvironment = localEnv;
|
|
1078
1089
|
calleeContext.LexicalEnvironment = localEnv;
|
|
1079
1090
|
executionContextStack.push(calleeContext);
|
|
1091
|
+
globalExecutionContextStack.push(calleeContext);
|
|
1080
1092
|
return calleeContext;
|
|
1081
1093
|
}
|
|
1082
1094
|
function OrdinaryCallBindThis(F, calleeContext, thisArgument) {
|