Skip to content

Commit 3879d0a

Browse files
committed
Merge branch 'master' of https://github.com/Microsoft/TypeScript into typeParameterFixing
2 parents f14abfe + a301ee3 commit 3879d0a

File tree

7 files changed

+124
-58
lines changed

7 files changed

+124
-58
lines changed

src/compiler/binder.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -322,13 +322,14 @@ module ts {
322322
}
323323
else {
324324
bindDeclaration(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes, /*isBlockScopeContainer*/ true);
325-
if (state === ModuleInstanceState.ConstEnumOnly) {
326-
// mark value module as module that contains only enums
327-
node.symbol.constEnumOnlyModule = true;
325+
let currentModuleIsConstEnumOnly = state === ModuleInstanceState.ConstEnumOnly;
326+
if (node.symbol.constEnumOnlyModule === undefined) {
327+
// non-merged case - use the current state
328+
node.symbol.constEnumOnlyModule = currentModuleIsConstEnumOnly;
328329
}
329-
else if (node.symbol.constEnumOnlyModule) {
330-
// const only value module was merged with instantiated module - reset flag
331-
node.symbol.constEnumOnlyModule = false;
330+
else {
331+
// merged case: module is const enum only if all its pieces are non-instantiated or const enum
332+
node.symbol.constEnumOnlyModule = node.symbol.constEnumOnlyModule && currentModuleIsConstEnumOnly;
332333
}
333334
}
334335
}

src/compiler/emitter.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5310,14 +5310,6 @@ module ts {
53105310
}
53115311
}
53125312

5313-
function getFirstExportAssignment(sourceFile: SourceFile) {
5314-
return forEach(sourceFile.statements, node => {
5315-
if (node.kind === SyntaxKind.ExportAssignment) {
5316-
return <ExportAssignment>node;
5317-
}
5318-
});
5319-
}
5320-
53215313
function sortAMDModules(amdModules: {name: string; path: string}[]) {
53225314
// AMD modules with declared variable names go first
53235315
return amdModules.sort((moduleA, moduleB) => {

src/compiler/program.ts

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
/// <reference path="emitter.ts" />
33

44
module ts {
5+
/* @internal */ export let programTime = 0;
56
/* @internal */ export let emitTime = 0;
67
/* @internal */ export let ioReadTime = 0;
8+
/* @internal */ export let ioWriteTime = 0;
79

810
/** The version of the TypeScript compiler release */
911
export let version = "1.5.0.0";
@@ -36,33 +38,34 @@ module ts {
3638
}
3739
text = "";
3840
}
39-
4041
return text !== undefined ? createSourceFile(fileName, text, languageVersion) : undefined;
4142
}
4243

43-
function writeFile(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void) {
44-
function directoryExists(directoryPath: string): boolean {
45-
if (hasProperty(existingDirectories, directoryPath)) {
46-
return true;
47-
}
48-
if (sys.directoryExists(directoryPath)) {
49-
existingDirectories[directoryPath] = true;
50-
return true;
51-
}
52-
return false;
44+
function directoryExists(directoryPath: string): boolean {
45+
if (hasProperty(existingDirectories, directoryPath)) {
46+
return true;
5347
}
48+
if (sys.directoryExists(directoryPath)) {
49+
existingDirectories[directoryPath] = true;
50+
return true;
51+
}
52+
return false;
53+
}
5454

55-
function ensureDirectoriesExist(directoryPath: string) {
56-
if (directoryPath.length > getRootLength(directoryPath) && !directoryExists(directoryPath)) {
57-
let parentDirectory = getDirectoryPath(directoryPath);
58-
ensureDirectoriesExist(parentDirectory);
59-
sys.createDirectory(directoryPath);
60-
}
55+
function ensureDirectoriesExist(directoryPath: string) {
56+
if (directoryPath.length > getRootLength(directoryPath) && !directoryExists(directoryPath)) {
57+
let parentDirectory = getDirectoryPath(directoryPath);
58+
ensureDirectoriesExist(parentDirectory);
59+
sys.createDirectory(directoryPath);
6160
}
61+
}
6262

63+
function writeFile(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void) {
6364
try {
65+
var start = new Date().getTime();
6466
ensureDirectoriesExist(getDirectoryPath(normalizePath(fileName)));
6567
sys.writeFile(fileName, data, writeByteOrderMark);
68+
ioWriteTime += new Date().getTime() - start;
6669
}
6770
catch (e) {
6871
if (onError) {
@@ -120,16 +123,19 @@ module ts {
120123
let diagnostics = createDiagnosticCollection();
121124
let seenNoDefaultLib = options.noLib;
122125
let commonSourceDirectory: string;
123-
host = host || createCompilerHost(options);
126+
let diagnosticsProducingTypeChecker: TypeChecker;
127+
let noDiagnosticsTypeChecker: TypeChecker;
124128

129+
let start = new Date().getTime();
130+
131+
host = host || createCompilerHost(options);
125132
forEach(rootNames, name => processRootFile(name, false));
126133
if (!seenNoDefaultLib) {
127134
processRootFile(host.getDefaultLibFileName(options), true);
128135
}
129136
verifyCompilerOptions();
130137

131-
let diagnosticsProducingTypeChecker: TypeChecker;
132-
let noDiagnosticsTypeChecker: TypeChecker;
138+
programTime += new Date().getTime() - start;
133139

134140
program = {
135141
getSourceFile: getSourceFile,

src/compiler/tsc.ts

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -320,22 +320,16 @@ module ts {
320320
}
321321

322322
function compile(fileNames: string[], compilerOptions: CompilerOptions, compilerHost: CompilerHost) {
323-
ts.ioReadTime = 0;
324-
ts.parseTime = 0;
325-
ts.bindTime = 0;
326-
ts.checkTime = 0;
327-
ts.emitTime = 0;
328-
329-
var start = new Date().getTime();
323+
ioReadTime = 0;
324+
ioWriteTime = 0;
325+
programTime = 0;
326+
bindTime = 0;
327+
checkTime = 0;
328+
emitTime = 0;
330329

331330
var program = createProgram(fileNames, compilerOptions, compilerHost);
332-
var programTime = new Date().getTime() - start;
333-
334331
var exitStatus = compileProgram();
335332

336-
var end = new Date().getTime() - start;
337-
var compileTime = end - programTime;
338-
339333
if (compilerOptions.listFiles) {
340334
forEach(program.getSourceFiles(), file => {
341335
sys.write(file.fileName + sys.newLine);
@@ -356,19 +350,16 @@ module ts {
356350
}
357351

358352
// Individual component times.
359-
// Note: we output 'programTime' as parseTime to match the tsc 1.3 behavior. tsc 1.3
360-
// measured parse time along with read IO as a single counter. We preserve that
361-
// behavior so we can accurately compare times. For actual parse times (in isolation)
362-
// is reported below.
353+
// Note: To match the behavior of previous versions of the compiler, the reported parse time includes
354+
// I/O read time and processing time for triple-slash references and module imports, and the reported
355+
// emit time includes I/O write time. We preserve this behavior so we can accurately compare times.
356+
reportTimeStatistic("I/O read", ioReadTime);
357+
reportTimeStatistic("I/O write", ioWriteTime);
363358
reportTimeStatistic("Parse time", programTime);
364-
reportTimeStatistic("Bind time", ts.bindTime);
365-
reportTimeStatistic("Check time", ts.checkTime);
366-
reportTimeStatistic("Emit time", ts.emitTime);
367-
368-
reportTimeStatistic("Parse time w/o IO", ts.parseTime);
369-
reportTimeStatistic("IO read", ts.ioReadTime);
370-
reportTimeStatistic("Compile time", compileTime);
371-
reportTimeStatistic("Total time", end);
359+
reportTimeStatistic("Bind time", bindTime);
360+
reportTimeStatistic("Check time", checkTime);
361+
reportTimeStatistic("Emit time", emitTime);
362+
reportTimeStatistic("Total time", programTime + bindTime + checkTime + emitTime);
372363
}
373364

374365
return { program, exitStatus };
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//// [constEnumOnlyModuleMerging.ts]
2+
module Outer {
3+
export var x = 1;
4+
}
5+
6+
module Outer {
7+
export const enum A { X }
8+
}
9+
10+
module B {
11+
import O = Outer;
12+
var x = O.A.X;
13+
var y = O.x;
14+
}
15+
16+
//// [constEnumOnlyModuleMerging.js]
17+
var Outer;
18+
(function (Outer) {
19+
Outer.x = 1;
20+
})(Outer || (Outer = {}));
21+
var B;
22+
(function (B) {
23+
var O = Outer;
24+
var x = 0 /* X */;
25+
var y = O.x;
26+
})(B || (B = {}));
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
=== tests/cases/compiler/constEnumOnlyModuleMerging.ts ===
2+
module Outer {
3+
>Outer : typeof Outer
4+
5+
export var x = 1;
6+
>x : number
7+
}
8+
9+
module Outer {
10+
>Outer : typeof Outer
11+
12+
export const enum A { X }
13+
>A : A
14+
>X : A
15+
}
16+
17+
module B {
18+
>B : typeof B
19+
20+
import O = Outer;
21+
>O : typeof O
22+
>Outer : typeof O
23+
24+
var x = O.A.X;
25+
>x : O.A
26+
>O.A.X : O.A
27+
>O.A : typeof O.A
28+
>O : typeof O
29+
>A : typeof O.A
30+
>X : O.A
31+
32+
var y = O.x;
33+
>y : number
34+
>O.x : number
35+
>O : typeof O
36+
>x : number
37+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module Outer {
2+
export var x = 1;
3+
}
4+
5+
module Outer {
6+
export const enum A { X }
7+
}
8+
9+
module B {
10+
import O = Outer;
11+
var x = O.A.X;
12+
var y = O.x;
13+
}

0 commit comments

Comments
 (0)