Skip to content

Commit 804ede2

Browse files
committed
Merge branch 'master' into test262RunnerUpdates
2 parents d970af4 + 06bb947 commit 804ede2

66 files changed

Lines changed: 1026 additions & 183 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Jakefile

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// This file contains the build logic for the public repo
22

33
var fs = require("fs");
4+
var os = require("os");
45
var path = require("path");
56
var child_process = require("child_process");
67

@@ -148,7 +149,7 @@ var compilerFilename = "tsc.js";
148149
* @param useBuiltCompiler: true to use the built compiler, false to use the LKG
149150
* @param noOutFile: true to compile without using --out
150151
*/
151-
function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOutFile, generateDeclarations) {
152+
function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOutFile, generateDeclarations, callback) {
152153
file(outFile, prereqs, function() {
153154
var dir = useBuiltCompiler ? builtLocalDirectory : LKGDirectory;
154155
var options = "-removeComments --module commonjs -noImplicitAny ";
@@ -180,6 +181,11 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOu
180181
prependFile(prefixes[i], outFile);
181182
}
182183
}
184+
185+
if (callback) {
186+
callback();
187+
}
188+
183189
complete();
184190
});
185191
ex.addListener("error", function() {
@@ -224,7 +230,7 @@ compileFile(processDiagnosticMessagesJs,
224230
[processDiagnosticMessagesTs],
225231
[processDiagnosticMessagesTs],
226232
[],
227-
false);
233+
/*useBuiltCompiler*/ false);
228234

229235
// The generated diagnostics map; built for the compiler and for the 'generate-diagnostics' task
230236
file(diagnosticInfoMapTs, [processDiagnosticMessagesJs, diagnosticMessagesJson], function () {
@@ -244,7 +250,6 @@ file(diagnosticInfoMapTs, [processDiagnosticMessagesJs, diagnosticMessagesJson],
244250
ex.run();
245251
}, {async: true})
246252

247-
248253
desc("Generates a diagnostic file in TypeScript based on an input JSON file");
249254
task("generate-diagnostics", [diagnosticInfoMapTs])
250255

@@ -255,13 +260,24 @@ compileFile(tscFile, compilerSources, [builtLocalDirectory, copyright].concat(co
255260

256261
var servicesFile = path.join(builtLocalDirectory, "typescriptServices.js");
257262
var servicesDefinitionsFile = path.join(builtLocalDirectory, "typescriptServices.d.ts");
258-
compileFile(servicesFile, servicesSources, [builtLocalDirectory, copyright].concat(servicesSources), [copyright], /*useBuiltCompiler:*/ true, /*noOutFile:*/ false, /*generateDeclarations:*/ true);
263+
264+
compileFile(servicesFile,
265+
servicesSources,
266+
[builtLocalDirectory, copyright].concat(servicesSources),
267+
[copyright],
268+
/*useBuiltCompiler*/ true,
269+
/*noOutFile*/ false,
270+
/*generateDeclarations*/ true,
271+
/*callback*/ fixDeclarationFile);
272+
273+
function fixDeclarationFile() {
274+
fs.appendFileSync(servicesDefinitionsFile, os.EOL + "export = ts;")
275+
}
259276

260277
// Local target to build the compiler and services
261278
desc("Builds the full compiler and services");
262279
task("local", ["generate-diagnostics", "lib", tscFile, servicesFile]);
263280

264-
265281
// Local target to build the compiler and services
266282
desc("Sets release mode flag");
267283
task("release", function() {
@@ -278,7 +294,6 @@ task("clean", function() {
278294
jake.rmRf(builtDirectory);
279295
});
280296

281-
282297
// Generate Markdown spec
283298
var word2mdJs = path.join(scriptsDirectory, "word2md.js");
284299
var word2mdTs = path.join(scriptsDirectory, "word2md.ts");
@@ -292,7 +307,7 @@ compileFile(word2mdJs,
292307
[word2mdTs],
293308
[word2mdTs],
294309
[],
295-
false);
310+
/*useBuiltCompiler*/ false);
296311

297312
// The generated spec.md; built for the 'generate-spec' task
298313
file(specMd, [word2mdJs, specWord], function () {
@@ -444,7 +459,7 @@ task("generate-code-coverage", ["tests", builtLocalDirectory], function () {
444459
// Browser tests
445460
var nodeServerOutFile = 'tests/webTestServer.js'
446461
var nodeServerInFile = 'tests/webTestServer.ts'
447-
compileFile(nodeServerOutFile, [nodeServerInFile], [builtLocalDirectory, tscFile], [], true, true);
462+
compileFile(nodeServerOutFile, [nodeServerInFile], [builtLocalDirectory, tscFile], [], /*useBuiltCompiler:*/ true, /*noOutFile*/ true);
448463

449464
desc("Runs browserify on run.js to produce a file suitable for running tests in the browser");
450465
task("browserify", ["tests", builtLocalDirectory, nodeServerOutFile], function() {
@@ -525,7 +540,7 @@ task("baseline-accept-test262", function() {
525540
// Webhost
526541
var webhostPath = "tests/webhost/webtsc.ts";
527542
var webhostJsPath = "tests/webhost/webtsc.js";
528-
compileFile(webhostJsPath, [webhostPath], [tscFile, webhostPath].concat(libraryTargets), [], true);
543+
compileFile(webhostJsPath, [webhostPath], [tscFile, webhostPath].concat(libraryTargets), [], /*useBuiltCompiler*/true);
529544

530545
desc("Builds the tsc web host");
531546
task("webhost", [webhostJsPath], function() {
@@ -535,7 +550,7 @@ task("webhost", [webhostJsPath], function() {
535550
// Perf compiler
536551
var perftscPath = "tests/perftsc.ts";
537552
var perftscJsPath = "built/local/perftsc.js";
538-
compileFile(perftscJsPath, [perftscPath], [tscFile, perftscPath, "tests/perfsys.ts"].concat(libraryTargets), [], true);
553+
compileFile(perftscJsPath, [perftscPath], [tscFile, perftscPath, "tests/perfsys.ts"].concat(libraryTargets), [], /*useBuiltCompiler*/ true);
539554
desc("Builds augmented version of the compiler for perf tests");
540555
task("perftsc", [perftscJsPath]);
541556

@@ -559,7 +574,7 @@ file(loggedIOJsPath, [builtLocalDirectory, loggedIOpath], function() {
559574

560575
var instrumenterPath = harnessDirectory + 'instrumenter.ts';
561576
var instrumenterJsPath = builtLocalDirectory + 'instrumenter.js';
562-
compileFile(instrumenterJsPath, [instrumenterPath], [tscFile, instrumenterPath], [], true);
577+
compileFile(instrumenterJsPath, [instrumenterPath], [tscFile, instrumenterPath], [], /*useBuiltCompiler*/ true);
563578

564579
desc("Builds an instrumented tsc.js");
565580
task('tsc-instrumented', [loggedIOJsPath, instrumenterJsPath, tscFile], function() {

src/compiler/checker.ts

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ module ts {
8585
getDiagnostics,
8686
getDeclarationDiagnostics,
8787
getGlobalDiagnostics,
88-
checkProgram,
8988
getParentOfSymbol,
9089
getNarrowedTypeOfSymbol,
9190
getDeclaredTypeOfSymbol,
@@ -546,14 +545,18 @@ module ts {
546545
return moduleName.substr(0, 2) === "./" || moduleName.substr(0, 3) === "../" || moduleName.substr(0, 2) === ".\\" || moduleName.substr(0, 3) === "..\\";
547546
}
548547

549-
function resolveExternalModuleName(location: Node, moduleExpression: Expression): Symbol {
550-
if (moduleExpression.kind !== SyntaxKind.StringLiteral) {
548+
function resolveExternalModuleName(location: Node, moduleReferenceExpression: Expression): Symbol {
549+
if (moduleReferenceExpression.kind !== SyntaxKind.StringLiteral) {
551550
return;
552551
}
553552

554-
var moduleLiteral = <LiteralExpression>moduleExpression;
553+
var moduleReferenceLiteral = <LiteralExpression>moduleReferenceExpression;
555554
var searchPath = getDirectoryPath(getSourceFile(location).filename);
556-
var moduleName = moduleLiteral.text;
555+
556+
// Module names are escaped in our symbol table. However, string literal values aren't.
557+
// Escape the name in the "require(...)" clause to ensure we find the right symbol.
558+
var moduleName = escapeIdentifier(moduleReferenceLiteral.text);
559+
557560
if (!moduleName) return;
558561
var isRelative = isExternalModuleNameRelative(moduleName);
559562
if (!isRelative) {
@@ -574,10 +577,10 @@ module ts {
574577
if (sourceFile.symbol) {
575578
return getResolvedExportSymbol(sourceFile.symbol);
576579
}
577-
error(moduleLiteral, Diagnostics.File_0_is_not_an_external_module, sourceFile.filename);
580+
error(moduleReferenceLiteral, Diagnostics.File_0_is_not_an_external_module, sourceFile.filename);
578581
return;
579582
}
580-
error(moduleLiteral, Diagnostics.Cannot_find_external_module_0, moduleName);
583+
error(moduleReferenceLiteral, Diagnostics.Cannot_find_external_module_0, moduleName);
581584
}
582585

583586
function getResolvedExportSymbol(moduleSymbol: Symbol): Symbol {
@@ -8653,10 +8656,6 @@ module ts {
86538656
}
86548657
}
86558658

8656-
function checkProgram() {
8657-
forEach(program.getSourceFiles(), checkSourceFile);
8658-
}
8659-
86608659
function getSortedDiagnostics(): Diagnostic[]{
86618660
Debug.assert(fullTypeCheck, "diagnostics are available only in the full typecheck mode");
86628661

@@ -8669,12 +8668,11 @@ module ts {
86698668
}
86708669

86718670
function getDiagnostics(sourceFile?: SourceFile): Diagnostic[]{
8672-
86738671
if (sourceFile) {
86748672
checkSourceFile(sourceFile);
86758673
return filter(getSortedDiagnostics(), d => d.file === sourceFile);
86768674
}
8677-
checkProgram();
8675+
forEach(program.getSourceFiles(), checkSourceFile);
86788676
return getSortedDiagnostics();
86798677
}
86808678

@@ -9024,7 +9022,7 @@ module ts {
90249022
// This is necessary as an identifier in short-hand property assignment can contains two meaning:
90259023
// property name and property value.
90269024
if (location && location.kind === SyntaxKind.ShorthandPropertyAssignment) {
9027-
return resolveEntityName(location, (<ShortHandPropertyDeclaration>location).name, SymbolFlags.Value);
9025+
return resolveEntityName(location, (<ShorthandPropertyDeclaration>location).name, SymbolFlags.Value);
90289026
}
90299027
return undefined;
90309028
}
@@ -9192,9 +9190,9 @@ module ts {
91929190
return isImportResolvedToValue(getSymbolOfNode(node));
91939191
}
91949192

9195-
function hasSemanticErrors() {
9193+
function hasSemanticErrors(sourceFile?: SourceFile) {
91969194
// Return true if there is any semantic error in a file or globally
9197-
return getDiagnostics().length > 0 || getGlobalDiagnostics().length > 0;
9195+
return getDiagnostics(sourceFile).length > 0 || getGlobalDiagnostics().length > 0;
91989196
}
91999197

92009198
function isEmitBlocked(sourceFile?: SourceFile): boolean {
@@ -9312,7 +9310,6 @@ module ts {
93129310

93139311
function invokeEmitter(targetSourceFile?: SourceFile) {
93149312
var resolver = createResolver();
9315-
checkProgram();
93169313
return emitFiles(resolver, targetSourceFile);
93179314
}
93189315

0 commit comments

Comments
 (0)