Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add external mapShim/debug modules (#33712)
* Add external mapShim/debug modules

* rename test file
  • Loading branch information
rbuckton committed Oct 7, 2019
1 parent 154793a commit 01b3d41
Show file tree
Hide file tree
Showing 21 changed files with 1,736 additions and 878 deletions.
14 changes: 12 additions & 2 deletions Gulpfile.js
Expand Up @@ -90,8 +90,18 @@ const localize = async () => {
}
};

const buildShims = () => buildProject("src/shims");
const cleanShims = () => cleanProject("src/shims");
cleanTasks.push(cleanShims);

const buildDebugTools = () => buildProject("src/debug");
const cleanDebugTools = () => cleanProject("src/debug");
cleanTasks.push(cleanDebugTools);

const buildShimsAndTools = parallel(buildShims, buildDebugTools);

// Pre-build steps when targeting the LKG compiler
const lkgPreBuild = parallel(generateLibs, series(buildScripts, generateDiagnostics));
const lkgPreBuild = parallel(generateLibs, series(buildScripts, generateDiagnostics, buildShimsAndTools));

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

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

// Pre-build steps to use based on supplied options.
const preBuild = cmdLineOptions.lkg ? lkgPreBuild : localPreBuild;
Expand Down
25 changes: 17 additions & 8 deletions src/compiler/binder.ts
Expand Up @@ -161,7 +161,12 @@ namespace ts {
IsObjectLiteralOrClassExpressionMethod = 1 << 7,
}

let flowNodeCreated: <T extends FlowNode>(node: T) => T = identity;
function initFlowNode<T extends FlowNode>(node: T) {
Debug.attachFlowNodeDebugInfo(node);
return node;
}

let flowNodeCreated: <T extends FlowNode>(node: T) => T = initFlowNode;

const binder = createBinder();

Expand Down Expand Up @@ -238,6 +243,10 @@ namespace ts {

Symbol = objectAllocator.getSymbolConstructor();

// Attach debugging information if necessary
Debug.attachFlowNodeDebugInfo(unreachableFlow);
Debug.attachFlowNodeDebugInfo(reportedUnreachableFlow);

if (!file.locals) {
bind(file);
file.symbolCount = symbolCount;
Expand Down Expand Up @@ -626,7 +635,7 @@ namespace ts {
// A non-async, non-generator IIFE is considered part of the containing control flow. Return statements behave
// similarly to break statements that exit to a label just past the statement body.
if (!isIIFE) {
currentFlow = { flags: FlowFlags.Start };
currentFlow = initFlowNode({ flags: FlowFlags.Start });
if (containerFlags & (ContainerFlags.IsFunctionExpression | ContainerFlags.IsObjectLiteralOrClassExpressionMethod)) {
currentFlow.node = <FunctionExpression | ArrowFunction | MethodDeclaration>node;
}
Expand All @@ -638,7 +647,7 @@ namespace ts {
currentContinueTarget = undefined;
activeLabels = undefined;
hasExplicitReturn = false;
flowNodeCreated = identity;
flowNodeCreated = initFlowNode;
bindChildren(node);
// Reset all reachability check related flags on node (for incremental scenarios)
node.flags &= ~NodeFlags.ReachabilityAndEmitFlags;
Expand Down Expand Up @@ -919,11 +928,11 @@ namespace ts {
}

function createBranchLabel(): FlowLabel {
return { flags: FlowFlags.BranchLabel, antecedents: undefined };
return initFlowNode({ flags: FlowFlags.BranchLabel, antecedents: undefined });
}

function createLoopLabel(): FlowLabel {
return { flags: FlowFlags.LoopLabel, antecedents: undefined };
return initFlowNode({ flags: FlowFlags.LoopLabel, antecedents: undefined });
}

function setFlowNodeReferenced(flow: FlowNode) {
Expand Down Expand Up @@ -1193,7 +1202,7 @@ namespace ts {
// as possible antecedents of the start of the `catch` or `finally` blocks.
// Don't bother intercepting the call if there's no finally or catch block that needs the information
if (node.catchClause || node.finallyBlock) {
flowNodeCreated = node => (tryPriors.push(node), node);
flowNodeCreated = node => (tryPriors.push(node), initFlowNode(node));
}
bind(node.tryBlock);
flowNodeCreated = oldFlowNodeCreated;
Expand Down Expand Up @@ -1262,7 +1271,7 @@ namespace ts {
//
// extra edges that we inject allows to control this behavior
// 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.
const preFinallyFlow: PreFinallyFlow = { flags: FlowFlags.PreFinally, antecedent: preFinallyPrior, lock: {} };
const preFinallyFlow: PreFinallyFlow = initFlowNode({ flags: FlowFlags.PreFinally, antecedent: preFinallyPrior, lock: {} });
addAntecedent(preFinallyLabel, preFinallyFlow);

currentFlow = finishFlowLabel(preFinallyLabel);
Expand Down Expand Up @@ -1983,7 +1992,7 @@ namespace ts {
const host = getJSDocHost(typeAlias);
container = findAncestor(host.parent, n => !!(getContainerFlags(n) & ContainerFlags.IsContainer)) || file;
blockScopeContainer = getEnclosingBlockScopeContainer(host) || file;
currentFlow = { flags: FlowFlags.Start };
currentFlow = initFlowNode({ flags: FlowFlags.Start });
parent = typeAlias;
bind(typeAlias.typeExpression);
const declName = getNameOfDeclaration(typeAlias);
Expand Down

0 comments on commit 01b3d41

Please sign in to comment.