Skip to content

Commit 01b3d41

Browse files
authored
Add external mapShim/debug modules (microsoft#33712)
* Add external mapShim/debug modules * rename test file
1 parent 154793a commit 01b3d41

21 files changed

+1736
-878
lines changed

Gulpfile.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,18 @@ const localize = async () => {
9090
}
9191
};
9292

93+
const buildShims = () => buildProject("src/shims");
94+
const cleanShims = () => cleanProject("src/shims");
95+
cleanTasks.push(cleanShims);
96+
97+
const buildDebugTools = () => buildProject("src/debug");
98+
const cleanDebugTools = () => cleanProject("src/debug");
99+
cleanTasks.push(cleanDebugTools);
100+
101+
const buildShimsAndTools = parallel(buildShims, buildDebugTools);
102+
93103
// Pre-build steps when targeting the LKG compiler
94-
const lkgPreBuild = parallel(generateLibs, series(buildScripts, generateDiagnostics));
104+
const lkgPreBuild = parallel(generateLibs, series(buildScripts, generateDiagnostics, buildShimsAndTools));
95105

96106
const buildTsc = () => buildProject("src/tsc");
97107
task("tsc", series(lkgPreBuild, buildTsc));
@@ -107,7 +117,7 @@ task("watch-tsc", series(lkgPreBuild, parallel(watchLib, watchDiagnostics, watch
107117
task("watch-tsc").description = "Watch for changes and rebuild the command-line compiler only.";
108118

109119
// Pre-build steps when targeting the built/local compiler.
110-
const localPreBuild = parallel(generateLibs, series(buildScripts, generateDiagnostics, buildTsc));
120+
const localPreBuild = parallel(generateLibs, series(buildScripts, generateDiagnostics, buildShimsAndTools, buildTsc));
111121

112122
// Pre-build steps to use based on supplied options.
113123
const preBuild = cmdLineOptions.lkg ? lkgPreBuild : localPreBuild;

src/compiler/binder.ts

+17-8
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,12 @@ namespace ts {
161161
IsObjectLiteralOrClassExpressionMethod = 1 << 7,
162162
}
163163

164-
let flowNodeCreated: <T extends FlowNode>(node: T) => T = identity;
164+
function initFlowNode<T extends FlowNode>(node: T) {
165+
Debug.attachFlowNodeDebugInfo(node);
166+
return node;
167+
}
168+
169+
let flowNodeCreated: <T extends FlowNode>(node: T) => T = initFlowNode;
165170

166171
const binder = createBinder();
167172

@@ -238,6 +243,10 @@ namespace ts {
238243

239244
Symbol = objectAllocator.getSymbolConstructor();
240245

246+
// Attach debugging information if necessary
247+
Debug.attachFlowNodeDebugInfo(unreachableFlow);
248+
Debug.attachFlowNodeDebugInfo(reportedUnreachableFlow);
249+
241250
if (!file.locals) {
242251
bind(file);
243252
file.symbolCount = symbolCount;
@@ -626,7 +635,7 @@ namespace ts {
626635
// A non-async, non-generator IIFE is considered part of the containing control flow. Return statements behave
627636
// similarly to break statements that exit to a label just past the statement body.
628637
if (!isIIFE) {
629-
currentFlow = { flags: FlowFlags.Start };
638+
currentFlow = initFlowNode({ flags: FlowFlags.Start });
630639
if (containerFlags & (ContainerFlags.IsFunctionExpression | ContainerFlags.IsObjectLiteralOrClassExpressionMethod)) {
631640
currentFlow.node = <FunctionExpression | ArrowFunction | MethodDeclaration>node;
632641
}
@@ -638,7 +647,7 @@ namespace ts {
638647
currentContinueTarget = undefined;
639648
activeLabels = undefined;
640649
hasExplicitReturn = false;
641-
flowNodeCreated = identity;
650+
flowNodeCreated = initFlowNode;
642651
bindChildren(node);
643652
// Reset all reachability check related flags on node (for incremental scenarios)
644653
node.flags &= ~NodeFlags.ReachabilityAndEmitFlags;
@@ -919,11 +928,11 @@ namespace ts {
919928
}
920929

921930
function createBranchLabel(): FlowLabel {
922-
return { flags: FlowFlags.BranchLabel, antecedents: undefined };
931+
return initFlowNode({ flags: FlowFlags.BranchLabel, antecedents: undefined });
923932
}
924933

925934
function createLoopLabel(): FlowLabel {
926-
return { flags: FlowFlags.LoopLabel, antecedents: undefined };
935+
return initFlowNode({ flags: FlowFlags.LoopLabel, antecedents: undefined });
927936
}
928937

929938
function setFlowNodeReferenced(flow: FlowNode) {
@@ -1193,7 +1202,7 @@ namespace ts {
11931202
// as possible antecedents of the start of the `catch` or `finally` blocks.
11941203
// Don't bother intercepting the call if there's no finally or catch block that needs the information
11951204
if (node.catchClause || node.finallyBlock) {
1196-
flowNodeCreated = node => (tryPriors.push(node), node);
1205+
flowNodeCreated = node => (tryPriors.push(node), initFlowNode(node));
11971206
}
11981207
bind(node.tryBlock);
11991208
flowNodeCreated = oldFlowNodeCreated;
@@ -1262,7 +1271,7 @@ namespace ts {
12621271
//
12631272
// extra edges that we inject allows to control this behavior
12641273
// if when walking the flow we step on post-finally edge - we can mark matching pre-finally edge as locked so it will be skipped.
1265-
const preFinallyFlow: PreFinallyFlow = { flags: FlowFlags.PreFinally, antecedent: preFinallyPrior, lock: {} };
1274+
const preFinallyFlow: PreFinallyFlow = initFlowNode({ flags: FlowFlags.PreFinally, antecedent: preFinallyPrior, lock: {} });
12661275
addAntecedent(preFinallyLabel, preFinallyFlow);
12671276

12681277
currentFlow = finishFlowLabel(preFinallyLabel);
@@ -1983,7 +1992,7 @@ namespace ts {
19831992
const host = getJSDocHost(typeAlias);
19841993
container = findAncestor(host.parent, n => !!(getContainerFlags(n) & ContainerFlags.IsContainer)) || file;
19851994
blockScopeContainer = getEnclosingBlockScopeContainer(host) || file;
1986-
currentFlow = { flags: FlowFlags.Start };
1995+
currentFlow = initFlowNode({ flags: FlowFlags.Start });
19871996
parent = typeAlias;
19881997
bind(typeAlias.typeExpression);
19891998
const declName = getNameOfDeclaration(typeAlias);

0 commit comments

Comments
 (0)