Skip to content

Commit 15b05e6

Browse files
author
Yui T
committed
Merge branch 'master' into emitArrowFunctionES6
2 parents f219a2d + 9289cfb commit 15b05e6

File tree

324 files changed

+7401
-635
lines changed

Some content is hidden

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

324 files changed

+7401
-635
lines changed

scripts/bisect-test.ts

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/// <reference path="..\src\harness\external\node.d.ts" />
2+
3+
import cp = require('child_process');
4+
import fs = require('fs');
5+
6+
// Slice off 'node bisect-test.js' from the commandline args
7+
var args = process.argv.slice(2);
8+
9+
function tsc(tscArgs: string, onExit: (exitCode: number) => void) {
10+
var tsc = cp.exec('node built/local/tsc.js ' + tscArgs,() => void 0);
11+
tsc.on('close', tscExitCode => {
12+
onExit(tscExitCode);
13+
});
14+
}
15+
16+
var jake = cp.exec('jake clean local', () => void 0);
17+
jake.on('close', jakeExitCode => {
18+
if (jakeExitCode === 0) {
19+
// See what we're being asked to do
20+
if (args[1] === 'compiles' || args[1] === '!compiles') {
21+
tsc(args[0], tscExitCode => {
22+
if ((tscExitCode === 0) === (args[1] === 'compiles')) {
23+
console.log('Good');
24+
process.exit(0); // Good
25+
} else {
26+
console.log('Bad');
27+
process.exit(1); // Bad
28+
}
29+
});
30+
} else if (args[1] === 'emits' || args[1] === '!emits') {
31+
tsc(args[0], tscExitCode => {
32+
fs.readFile(args[2], 'utf-8', (err, data) => {
33+
var doesContains = data.indexOf(args[3]) >= 0;
34+
if (doesContains === (args[1] === 'emits')) {
35+
console.log('Good');
36+
process.exit(0); // Good
37+
} else {
38+
console.log('Bad');
39+
process.exit(1); // Bad
40+
}
41+
});
42+
});
43+
} else {
44+
console.log('Unknown command line arguments.');
45+
console.log('Usage (compile errors): git bisect run scripts\bisect.js "foo.ts --module amd" compiles');
46+
console.log('Usage (emit check): git bisect run scripts\bisect.js bar.ts emits bar.js "_this = this"');
47+
// Aborts the 'git bisect run' process
48+
process.exit(-1);
49+
}
50+
} else {
51+
// Compiler build failed; skip this commit
52+
console.log('Skip');
53+
process.exit(125); // bisect skip
54+
}
55+
});
56+

scripts/bisect.cmd

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
echo off
2+
IF NOT EXIST scripts\bisect.cmd GOTO :wrongdir
3+
IF "%1" == "" GOTO :usage
4+
IF "%1" == "GO" GOTO :run
5+
GOTO :copy
6+
7+
:usage
8+
echo Usage: bisect GoodCommit BadCommit test.ts compiles
9+
echo Usage: bisect GoodCommit BadCommit test.ts emits test.js "var x = 3"
10+
GOTO :eof
11+
12+
:copy
13+
copy scripts\bisect.cmd scripts\bisect-fresh.cmd
14+
scripts\bisect-fresh GO %*
15+
GOTO :eof
16+
17+
:run
18+
call jake local
19+
node built/local/tsc.js scripts/bisect-test.ts --module commonjs
20+
git bisect start %2 %3
21+
git bisect run node scripts/bisect-test.js %4 %5 %6 %7
22+
del scripts\bisect-test.js
23+
del scripts\bisect-fresh.cmd
24+
GOTO :eof
25+
26+
:wrongdir
27+
@echo Run this file from the repo folder, not the scripts folder
28+
GOTO :eof
29+
30+
:eof

src/compiler/binder.ts

+25-19
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ module ts {
99

1010
export function getModuleInstanceState(node: Node): ModuleInstanceState {
1111
// A module is uninstantiated if it contains only
12-
// 1. interface declarations
13-
if (node.kind === SyntaxKind.InterfaceDeclaration) {
12+
// 1. interface declarations, type alias declarations
13+
if (node.kind === SyntaxKind.InterfaceDeclaration || node.kind === SyntaxKind.TypeAliasDeclaration) {
1414
return ModuleInstanceState.NonInstantiated;
1515
}
1616
// 2. const enum declarations don't make module instantiated
@@ -50,12 +50,13 @@ module ts {
5050
}
5151

5252
/**
53-
* Returns false if any of the following are true:
54-
* 1. declaration has no name
55-
* 2. declaration has a literal name (not computed)
56-
* 3. declaration has a computed property name that is a known symbol
53+
* A declaration has a dynamic name if both of the following are true:
54+
* 1. The declaration has a computed property name
55+
* 2. The computed name is *not* expressed as Symbol.<name>, where name
56+
* is a property of the Symbol constructor that denotes a built in
57+
* Symbol.
5758
*/
58-
export function hasComputedNameButNotSymbol(declaration: Declaration): boolean {
59+
export function hasDynamicName(declaration: Declaration): boolean {
5960
return declaration.name && declaration.name.kind === SyntaxKind.ComputedPropertyName;
6061
}
6162

@@ -96,7 +97,7 @@ module ts {
9697
if (node.kind === SyntaxKind.ModuleDeclaration && node.name.kind === SyntaxKind.StringLiteral) {
9798
return '"' + (<LiteralExpression>node.name).text + '"';
9899
}
99-
Debug.assert(!hasComputedNameButNotSymbol(node));
100+
Debug.assert(!hasDynamicName(node));
100101
return (<Identifier | LiteralExpression>node.name).text;
101102
}
102103
switch (node.kind) {
@@ -118,11 +119,7 @@ module ts {
118119
}
119120

120121
function declareSymbol(symbols: SymbolTable, parent: Symbol, node: Declaration, includes: SymbolFlags, excludes: SymbolFlags): Symbol {
121-
// Nodes with computed property names will not get symbols, because the type checker
122-
// does not make properties for them.
123-
if (hasComputedNameButNotSymbol(node)) {
124-
return undefined;
125-
}
122+
Debug.assert(!hasDynamicName(node));
126123

127124
var name = getDeclarationName(node);
128125
if (name !== undefined) {
@@ -395,14 +392,14 @@ module ts {
395392
break;
396393
case SyntaxKind.PropertyDeclaration:
397394
case SyntaxKind.PropertySignature:
398-
bindDeclaration(<Declaration>node, SymbolFlags.Property | ((<PropertyDeclaration>node).questionToken ? SymbolFlags.Optional : 0), SymbolFlags.PropertyExcludes, /*isBlockScopeContainer*/ false);
395+
bindPropertyOrMethodOrAccessor(<Declaration>node, SymbolFlags.Property | ((<PropertyDeclaration>node).questionToken ? SymbolFlags.Optional : 0), SymbolFlags.PropertyExcludes, /*isBlockScopeContainer*/ false);
399396
break;
400397
case SyntaxKind.PropertyAssignment:
401398
case SyntaxKind.ShorthandPropertyAssignment:
402-
bindDeclaration(<Declaration>node, SymbolFlags.Property, SymbolFlags.PropertyExcludes, /*isBlockScopeContainer*/ false);
399+
bindPropertyOrMethodOrAccessor(<Declaration>node, SymbolFlags.Property, SymbolFlags.PropertyExcludes, /*isBlockScopeContainer*/ false);
403400
break;
404401
case SyntaxKind.EnumMember:
405-
bindDeclaration(<Declaration>node, SymbolFlags.EnumMember, SymbolFlags.EnumMemberExcludes, /*isBlockScopeContainer*/ false);
402+
bindPropertyOrMethodOrAccessor(<Declaration>node, SymbolFlags.EnumMember, SymbolFlags.EnumMemberExcludes, /*isBlockScopeContainer*/ false);
406403
break;
407404
case SyntaxKind.CallSignature:
408405
case SyntaxKind.ConstructSignature:
@@ -415,7 +412,7 @@ module ts {
415412
// as other properties in the object literal. So we use SymbolFlags.PropertyExcludes
416413
// so that it will conflict with any other object literal members with the same
417414
// name.
418-
bindDeclaration(<Declaration>node, SymbolFlags.Method | ((<MethodDeclaration>node).questionToken ? SymbolFlags.Optional : 0),
415+
bindPropertyOrMethodOrAccessor(<Declaration>node, SymbolFlags.Method | ((<MethodDeclaration>node).questionToken ? SymbolFlags.Optional : 0),
419416
isObjectLiteralMethod(node) ? SymbolFlags.PropertyExcludes : SymbolFlags.MethodExcludes, /*isBlockScopeContainer*/ true);
420417
break;
421418
case SyntaxKind.FunctionDeclaration:
@@ -425,10 +422,10 @@ module ts {
425422
bindDeclaration(<Declaration>node, SymbolFlags.Constructor, /*symbolExcludes:*/ 0, /*isBlockScopeContainer:*/ true);
426423
break;
427424
case SyntaxKind.GetAccessor:
428-
bindDeclaration(<Declaration>node, SymbolFlags.GetAccessor, SymbolFlags.GetAccessorExcludes, /*isBlockScopeContainer*/ true);
425+
bindPropertyOrMethodOrAccessor(<Declaration>node, SymbolFlags.GetAccessor, SymbolFlags.GetAccessorExcludes, /*isBlockScopeContainer*/ true);
429426
break;
430427
case SyntaxKind.SetAccessor:
431-
bindDeclaration(<Declaration>node, SymbolFlags.SetAccessor, SymbolFlags.SetAccessorExcludes, /*isBlockScopeContainer*/ true);
428+
bindPropertyOrMethodOrAccessor(<Declaration>node, SymbolFlags.SetAccessor, SymbolFlags.SetAccessorExcludes, /*isBlockScopeContainer*/ true);
432429
break;
433430

434431
case SyntaxKind.FunctionType:
@@ -510,5 +507,14 @@ module ts {
510507
declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, SymbolFlags.Property, SymbolFlags.PropertyExcludes);
511508
}
512509
}
510+
511+
function bindPropertyOrMethodOrAccessor(node: Declaration, symbolKind: SymbolFlags, symbolExcludes: SymbolFlags, isBlockScopeContainer: boolean) {
512+
if (hasDynamicName(node)) {
513+
bindAnonymousDeclaration(node, symbolKind, "__computed", isBlockScopeContainer);
514+
}
515+
else {
516+
bindDeclaration(node, symbolKind, symbolExcludes, isBlockScopeContainer);
517+
}
518+
}
513519
}
514520
}

0 commit comments

Comments
 (0)