Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f2de450

Browse filesBrowse files
committed
Extract emit-specific properties into EmitNode
1 parent b7d1d11 commit f2de450
Copy full SHA for f2de450

16 files changed

+492-500Lines changed: 492 additions & 500 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/compiler/binder.ts‎

Copy file name to clipboardExpand all lines: src/compiler/binder.ts
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2592,7 +2592,7 @@ namespace ts {
25922592
}
25932593

25942594
// Currently, we only support generators that were originally async function bodies.
2595-
if (asteriskToken && node.emitFlags & NodeEmitFlags.AsyncFunctionBody) {
2595+
if (asteriskToken && getEmitFlags(node) & EmitFlags.AsyncFunctionBody) {
25962596
transformFlags |= TransformFlags.AssertGenerator;
25972597
}
25982598

@@ -2667,7 +2667,7 @@ namespace ts {
26672667
// down-level generator.
26682668
// Currently we do not support transforming any other generator fucntions
26692669
// down level.
2670-
if (asteriskToken && node.emitFlags & NodeEmitFlags.AsyncFunctionBody) {
2670+
if (asteriskToken && getEmitFlags(node) & EmitFlags.AsyncFunctionBody) {
26712671
transformFlags |= TransformFlags.AssertGenerator;
26722672
}
26732673
}
@@ -2698,7 +2698,7 @@ namespace ts {
26982698
// down-level generator.
26992699
// Currently we do not support transforming any other generator fucntions
27002700
// down level.
2701-
if (asteriskToken && node.emitFlags & NodeEmitFlags.AsyncFunctionBody) {
2701+
if (asteriskToken && getEmitFlags(node) & EmitFlags.AsyncFunctionBody) {
27022702
transformFlags |= TransformFlags.AssertGenerator;
27032703
}
27042704

Collapse file

‎src/compiler/comments.ts‎

Copy file name to clipboardExpand all lines: src/compiler/comments.ts
+10-10Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ namespace ts {
4141
}
4242

4343
if (node) {
44-
const { pos, end } = node.commentRange || node;
45-
const emitFlags = node.emitFlags;
44+
const { pos, end } = getCommentRange(node);
45+
const emitFlags = getEmitFlags(node);
4646
if ((pos < 0 && end < 0) || (pos === end)) {
4747
// Both pos and end are synthesized, so just emit the node without comments.
48-
if (emitFlags & NodeEmitFlags.NoNestedComments) {
48+
if (emitFlags & EmitFlags.NoNestedComments) {
4949
disableCommentsAndEmit(node, emitCallback);
5050
}
5151
else {
@@ -58,8 +58,8 @@ namespace ts {
5858
}
5959

6060
const isEmittedNode = node.kind !== SyntaxKind.NotEmittedStatement;
61-
const skipLeadingComments = pos < 0 || (emitFlags & NodeEmitFlags.NoLeadingComments) !== 0;
62-
const skipTrailingComments = end < 0 || (emitFlags & NodeEmitFlags.NoTrailingComments) !== 0;
61+
const skipLeadingComments = pos < 0 || (emitFlags & EmitFlags.NoLeadingComments) !== 0;
62+
const skipTrailingComments = end < 0 || (emitFlags & EmitFlags.NoTrailingComments) !== 0;
6363

6464
// Emit leading comments if the position is not synthesized and the node
6565
// has not opted out from emitting leading comments.
@@ -90,7 +90,7 @@ namespace ts {
9090
performance.measure("commentTime", "preEmitNodeWithComment");
9191
}
9292

93-
if (emitFlags & NodeEmitFlags.NoNestedComments) {
93+
if (emitFlags & EmitFlags.NoNestedComments) {
9494
disableCommentsAndEmit(node, emitCallback);
9595
}
9696
else {
@@ -125,9 +125,9 @@ namespace ts {
125125
}
126126

127127
const { pos, end } = detachedRange;
128-
const emitFlags = node.emitFlags;
129-
const skipLeadingComments = pos < 0 || (emitFlags & NodeEmitFlags.NoLeadingComments) !== 0;
130-
const skipTrailingComments = disabled || end < 0 || (emitFlags & NodeEmitFlags.NoTrailingComments) !== 0;
128+
const emitFlags = getEmitFlags(node);
129+
const skipLeadingComments = pos < 0 || (emitFlags & EmitFlags.NoLeadingComments) !== 0;
130+
const skipTrailingComments = disabled || end < 0 || (emitFlags & EmitFlags.NoTrailingComments) !== 0;
131131

132132
if (!skipLeadingComments) {
133133
emitDetachedCommentsAndUpdateCommentsInfo(detachedRange);
@@ -137,7 +137,7 @@ namespace ts {
137137
performance.measure("commentTime", "preEmitBodyWithDetachedComments");
138138
}
139139

140-
if (emitFlags & NodeEmitFlags.NoNestedComments) {
140+
if (emitFlags & EmitFlags.NoNestedComments) {
141141
disableCommentsAndEmit(node, emitCallback);
142142
}
143143
else {
Collapse file

‎src/compiler/core.ts‎

Copy file name to clipboardExpand all lines: src/compiler/core.ts
+66-1Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,72 @@ namespace ts {
824824
};
825825
}
826826

827+
/**
828+
* High-order function, creates a function that executes a function composition.
829+
* For example, `chain(a, b)` is the equivalent of `x => ((a', b') => y => b'(a'(y)))(a(x), b(x))`
830+
*
831+
* @param args The functions to chain.
832+
*/
833+
export function chain<T, U>(...args: ((t: T) => (u: U) => U)[]): (t: T) => (u: U) => U;
834+
export function chain<T, U>(a: (t: T) => (u: U) => U, b: (t: T) => (u: U) => U, c: (t: T) => (u: U) => U, d: (t: T) => (u: U) => U, e: (t: T) => (u: U) => U): (t: T) => (u: U) => U {
835+
if (e) {
836+
const args: ((t: T) => (u: U) => U)[] = [];
837+
for (let i = 0; i < arguments.length; i++) {
838+
args[i] = arguments[i];
839+
}
840+
841+
return t => compose(...map(args, f => f(t)));
842+
}
843+
else if (d) {
844+
return t => compose(a(t), b(t), c(t), d(t));
845+
}
846+
else if (c) {
847+
return t => compose(a(t), b(t), c(t));
848+
}
849+
else if (b) {
850+
return t => compose(a(t), b(t));
851+
}
852+
else if (a) {
853+
return t => compose(a(t));
854+
}
855+
else {
856+
return t => u => u;
857+
}
858+
}
859+
860+
/**
861+
* High-order function, composes functions. Note that functions are composed inside-out;
862+
* for example, `compose(a, b)` is the equivalent of `x => b(a(x))`.
863+
*
864+
* @param args The functions to compose.
865+
*/
866+
export function compose<T>(...args: ((t: T) => T)[]): (t: T) => T;
867+
export function compose<T>(a: (t: T) => T, b: (t: T) => T, c: (t: T) => T, d: (t: T) => T, e: (t: T) => T): (t: T) => T {
868+
if (e) {
869+
const args: ((t: T) => T)[] = [];
870+
for (let i = 0; i < arguments.length; i++) {
871+
args[i] = arguments[i];
872+
}
873+
874+
return t => reduceLeft<(t: T) => T, T>(args, (u, f) => f(u), t);
875+
}
876+
else if (d) {
877+
return t => d(c(b(a(t))));
878+
}
879+
else if (c) {
880+
return t => c(b(a(t)));
881+
}
882+
else if (b) {
883+
return t => b(a(t));
884+
}
885+
else if (a) {
886+
return t => a(t);
887+
}
888+
else {
889+
return t => t;
890+
}
891+
}
892+
827893
function formatStringFromArgs(text: string, args: { [index: number]: any; }, baseIndex?: number): string {
828894
baseIndex = baseIndex || 0;
829895

@@ -1715,7 +1781,6 @@ namespace ts {
17151781
this.transformFlags = TransformFlags.None;
17161782
this.parent = undefined;
17171783
this.original = undefined;
1718-
this.transformId = 0;
17191784
}
17201785

17211786
export let objectAllocator: ObjectAllocator = {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.