Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Microsoft/TypeScript into…
Browse files Browse the repository at this point in the history
… typeParameterFixing
  • Loading branch information
JsonFreeman committed Mar 17, 2015
2 parents f14abfe + a301ee3 commit 3879d0a
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 58 deletions.
13 changes: 7 additions & 6 deletions src/compiler/binder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,13 +322,14 @@ module ts {
}
else {
bindDeclaration(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes, /*isBlockScopeContainer*/ true);
if (state === ModuleInstanceState.ConstEnumOnly) {
// mark value module as module that contains only enums
node.symbol.constEnumOnlyModule = true;
let currentModuleIsConstEnumOnly = state === ModuleInstanceState.ConstEnumOnly;
if (node.symbol.constEnumOnlyModule === undefined) {
// non-merged case - use the current state
node.symbol.constEnumOnlyModule = currentModuleIsConstEnumOnly;
}
else if (node.symbol.constEnumOnlyModule) {
// const only value module was merged with instantiated module - reset flag
node.symbol.constEnumOnlyModule = false;
else {
// merged case: module is const enum only if all its pieces are non-instantiated or const enum
node.symbol.constEnumOnlyModule = node.symbol.constEnumOnlyModule && currentModuleIsConstEnumOnly;
}
}
}
Expand Down
8 changes: 0 additions & 8 deletions src/compiler/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5310,14 +5310,6 @@ module ts {
}
}

function getFirstExportAssignment(sourceFile: SourceFile) {
return forEach(sourceFile.statements, node => {
if (node.kind === SyntaxKind.ExportAssignment) {
return <ExportAssignment>node;
}
});
}

function sortAMDModules(amdModules: {name: string; path: string}[]) {
// AMD modules with declared variable names go first
return amdModules.sort((moduleA, moduleB) => {
Expand Down
46 changes: 26 additions & 20 deletions src/compiler/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
/// <reference path="emitter.ts" />

module ts {
/* @internal */ export let programTime = 0;
/* @internal */ export let emitTime = 0;
/* @internal */ export let ioReadTime = 0;
/* @internal */ export let ioWriteTime = 0;

/** The version of the TypeScript compiler release */
export let version = "1.5.0.0";
Expand Down Expand Up @@ -36,33 +38,34 @@ module ts {
}
text = "";
}

return text !== undefined ? createSourceFile(fileName, text, languageVersion) : undefined;
}

function writeFile(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void) {
function directoryExists(directoryPath: string): boolean {
if (hasProperty(existingDirectories, directoryPath)) {
return true;
}
if (sys.directoryExists(directoryPath)) {
existingDirectories[directoryPath] = true;
return true;
}
return false;
function directoryExists(directoryPath: string): boolean {
if (hasProperty(existingDirectories, directoryPath)) {
return true;
}
if (sys.directoryExists(directoryPath)) {
existingDirectories[directoryPath] = true;
return true;
}
return false;
}

function ensureDirectoriesExist(directoryPath: string) {
if (directoryPath.length > getRootLength(directoryPath) && !directoryExists(directoryPath)) {
let parentDirectory = getDirectoryPath(directoryPath);
ensureDirectoriesExist(parentDirectory);
sys.createDirectory(directoryPath);
}
function ensureDirectoriesExist(directoryPath: string) {
if (directoryPath.length > getRootLength(directoryPath) && !directoryExists(directoryPath)) {
let parentDirectory = getDirectoryPath(directoryPath);
ensureDirectoriesExist(parentDirectory);
sys.createDirectory(directoryPath);
}
}

function writeFile(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void) {
try {
var start = new Date().getTime();
ensureDirectoriesExist(getDirectoryPath(normalizePath(fileName)));
sys.writeFile(fileName, data, writeByteOrderMark);
ioWriteTime += new Date().getTime() - start;
}
catch (e) {
if (onError) {
Expand Down Expand Up @@ -120,16 +123,19 @@ module ts {
let diagnostics = createDiagnosticCollection();
let seenNoDefaultLib = options.noLib;
let commonSourceDirectory: string;
host = host || createCompilerHost(options);
let diagnosticsProducingTypeChecker: TypeChecker;
let noDiagnosticsTypeChecker: TypeChecker;

let start = new Date().getTime();

host = host || createCompilerHost(options);
forEach(rootNames, name => processRootFile(name, false));
if (!seenNoDefaultLib) {
processRootFile(host.getDefaultLibFileName(options), true);
}
verifyCompilerOptions();

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

program = {
getSourceFile: getSourceFile,
Expand Down
39 changes: 15 additions & 24 deletions src/compiler/tsc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,22 +320,16 @@ module ts {
}

function compile(fileNames: string[], compilerOptions: CompilerOptions, compilerHost: CompilerHost) {
ts.ioReadTime = 0;
ts.parseTime = 0;
ts.bindTime = 0;
ts.checkTime = 0;
ts.emitTime = 0;

var start = new Date().getTime();
ioReadTime = 0;
ioWriteTime = 0;
programTime = 0;
bindTime = 0;
checkTime = 0;
emitTime = 0;

var program = createProgram(fileNames, compilerOptions, compilerHost);
var programTime = new Date().getTime() - start;

var exitStatus = compileProgram();

var end = new Date().getTime() - start;
var compileTime = end - programTime;

if (compilerOptions.listFiles) {
forEach(program.getSourceFiles(), file => {
sys.write(file.fileName + sys.newLine);
Expand All @@ -356,19 +350,16 @@ module ts {
}

// Individual component times.
// Note: we output 'programTime' as parseTime to match the tsc 1.3 behavior. tsc 1.3
// measured parse time along with read IO as a single counter. We preserve that
// behavior so we can accurately compare times. For actual parse times (in isolation)
// is reported below.
// Note: To match the behavior of previous versions of the compiler, the reported parse time includes
// I/O read time and processing time for triple-slash references and module imports, and the reported
// emit time includes I/O write time. We preserve this behavior so we can accurately compare times.
reportTimeStatistic("I/O read", ioReadTime);
reportTimeStatistic("I/O write", ioWriteTime);
reportTimeStatistic("Parse time", programTime);
reportTimeStatistic("Bind time", ts.bindTime);
reportTimeStatistic("Check time", ts.checkTime);
reportTimeStatistic("Emit time", ts.emitTime);

reportTimeStatistic("Parse time w/o IO", ts.parseTime);
reportTimeStatistic("IO read", ts.ioReadTime);
reportTimeStatistic("Compile time", compileTime);
reportTimeStatistic("Total time", end);
reportTimeStatistic("Bind time", bindTime);
reportTimeStatistic("Check time", checkTime);
reportTimeStatistic("Emit time", emitTime);
reportTimeStatistic("Total time", programTime + bindTime + checkTime + emitTime);
}

return { program, exitStatus };
Expand Down
26 changes: 26 additions & 0 deletions tests/baselines/reference/constEnumOnlyModuleMerging.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//// [constEnumOnlyModuleMerging.ts]
module Outer {
export var x = 1;
}

module Outer {
export const enum A { X }
}

module B {
import O = Outer;
var x = O.A.X;
var y = O.x;
}

//// [constEnumOnlyModuleMerging.js]
var Outer;
(function (Outer) {
Outer.x = 1;
})(Outer || (Outer = {}));
var B;
(function (B) {
var O = Outer;
var x = 0 /* X */;
var y = O.x;
})(B || (B = {}));
37 changes: 37 additions & 0 deletions tests/baselines/reference/constEnumOnlyModuleMerging.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
=== tests/cases/compiler/constEnumOnlyModuleMerging.ts ===
module Outer {
>Outer : typeof Outer

export var x = 1;
>x : number
}

module Outer {
>Outer : typeof Outer

export const enum A { X }
>A : A
>X : A
}

module B {
>B : typeof B

import O = Outer;
>O : typeof O
>Outer : typeof O

var x = O.A.X;
>x : O.A
>O.A.X : O.A
>O.A : typeof O.A
>O : typeof O
>A : typeof O.A
>X : O.A

var y = O.x;
>y : number
>O.x : number
>O : typeof O
>x : number
}
13 changes: 13 additions & 0 deletions tests/cases/compiler/constEnumOnlyModuleMerging.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module Outer {
export var x = 1;
}

module Outer {
export const enum A { X }
}

module B {
import O = Outer;
var x = O.A.X;
var y = O.x;
}

0 comments on commit 3879d0a

Please sign in to comment.