Skip to content

Commit 21a9338

Browse files
committed
WIP
1 parent 49b812b commit 21a9338

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/compiler/binder.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ namespace ts {
125125
// state used for emit helpers
126126
let emitFlags: NodeFlags;
127127

128+
let clonedNodeMarker = 0;
129+
128130
// If this file is an external module, then it is automatically in strict-mode according to
129131
// ES6. If it is not an external module, then we'll determine if it is in strict mode or
130132
// not depending on if we see "use strict" in certain places or if we hit a class/namespace
@@ -150,6 +152,7 @@ namespace ts {
150152
classifiableNames = createMap<string>();
151153
symbolCount = 0;
152154
skipTransformFlagAggregation = isDeclarationFile(file);
155+
clonedNodeMarker = 0;
153156

154157
Symbol = objectAllocator.getSymbolConstructor();
155158

@@ -775,6 +778,21 @@ namespace ts {
775778
}
776779
}
777780

781+
function markClonableFlowNodes<T extends FlowNode>(flowNode: T): T {
782+
if (clonedNodeMarker !== 0) {
783+
flowNode.flags |= clonedNodeMarker << 22;
784+
}
785+
return flowNode;
786+
}
787+
788+
function getFlowNodeMarker(flowNode: FlowNode): number {
789+
return flowNode.flags >> 22;
790+
}
791+
792+
function resetFlowNodeMarker(flowNode: FlowNode): void {
793+
flowNode.flags &=
794+
}
795+
778796
function createFlowCondition(flags: FlowFlags, antecedent: FlowNode, expression: Expression): FlowNode {
779797
if (antecedent.flags & FlowFlags.Unreachable) {
780798
return antecedent;

src/compiler/types.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2055,7 +2055,9 @@ namespace ts {
20552055
Referenced = 1 << 9, // Referenced as antecedent once
20562056
Shared = 1 << 10, // Referenced as antecedent more than once
20572057
Label = BranchLabel | LoopLabel,
2058-
Condition = TrueCondition | FalseCondition
2058+
Condition = TrueCondition | FalseCondition,
2059+
2060+
// range from 22-29 bits is reserved for marking flow nodes that should be cloned during binding
20592061
}
20602062

20612063
export interface FlowNode {

0 commit comments

Comments
 (0)