Adds a prototype implementation of the bind ('::') operator

This commit is contained in:
Ron Buckton 2015-07-08 17:04:45 -07:00
Родитель aaf0f78553
Коммит 8521632d1c
14 изменённых файлов: 636 добавлений и 31 удалений

Просмотреть файл

@ -158,6 +158,7 @@ namespace ts {
let emitParam = false;
let emitAwaiter = false;
let emitGenerator = false;
let emitBind = false;
let resolutionTargets: Object[] = [];
let resolutionResults: boolean[] = [];
@ -6178,14 +6179,14 @@ namespace ts {
if (needToCaptureLexicalThis) {
captureLexicalThis(node, container);
}
if (isClassLike(container.parent)) {
let symbol = getSymbolOfNode(container.parent);
return container.flags & NodeFlags.Static ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol);
}
return anyType;
}
function isInConstructorArgumentInitializer(node: Node, constructorDecl: Node): boolean {
for (let n = node; n && n !== constructorDecl; n = n.parent) {
if (n.kind === SyntaxKind.Parameter) {
@ -8765,6 +8766,33 @@ namespace ts {
function checkTaggedTemplateExpression(node: TaggedTemplateExpression): Type {
return getReturnTypeOfSignature(getResolvedSignature(node));
}
function checkBindExpression(node: BindExpression): Type {
emitBind = true;
if (!node.baseExpression
&& node.targetExpression.kind !== SyntaxKind.PropertyAccessExpression
&& node.targetExpression.kind !== SyntaxKind.ElementAccessExpression) {
error(node, Diagnostics.The_target_of_a_bind_expression_without_a_left_hand_side_must_be_a_property_or_element_access);
return unknownType;
}
let baseType = node.baseExpression ? checkExpression(node.baseExpression) : undefined;
let targetType = checkExpression(node.targetExpression);
let apparentType = getApparentType(targetType);
if (apparentType === unknownType) {
return unknownType;
}
let callSignatures = getSignaturesOfType(apparentType, SignatureKind.Call);
let constructSignatures = getSignaturesOfType(apparentType, SignatureKind.Construct);
if (!isTypeAny(targetType) && callSignatures.length === 0 && constructSignatures.length === 0) {
error(node, Diagnostics.Cannot_bind_an_expression_whose_type_lacks_a_call_or_construct_signature);
return unknownType;
}
return targetType;
}
function checkAssertion(node: AssertionExpression) {
let exprType = checkExpression(node.expression);
@ -9813,6 +9841,8 @@ namespace ts {
case SyntaxKind.CallExpression:
case SyntaxKind.NewExpression:
return checkCallExpression(<CallExpression>node);
case SyntaxKind.BindExpression:
return checkBindExpression(<BindExpression>node);
case SyntaxKind.TaggedTemplateExpression:
return checkTaggedTemplateExpression(<TaggedTemplateExpression>node);
case SyntaxKind.ParenthesizedExpression:
@ -13235,6 +13265,7 @@ namespace ts {
case SyntaxKind.ConditionalExpression:
case SyntaxKind.SpreadElementExpression:
case SyntaxKind.YieldExpression:
case SyntaxKind.BindExpression:
case SyntaxKind.Block:
case SyntaxKind.ModuleBlock:
case SyntaxKind.VariableStatement:
@ -13298,6 +13329,9 @@ namespace ts {
emitExtends = false;
emitDecorate = false;
emitParam = false;
emitAwaiter = false;
emitGenerator = false;
emitBind = false;
potentialThisCollisions.length = 0;
forEach(node.statements, checkSourceElement);
@ -13331,6 +13365,10 @@ namespace ts {
if (emitGenerator || (emitAwaiter && languageVersion < ScriptTarget.ES6)) {
links.flags |= NodeCheckFlags.EmitGenerator;
}
if (emitBind) {
links.flags |= NodeCheckFlags.EmitBind;
}
links.flags |= NodeCheckFlags.TypeChecked;
}

Просмотреть файл

@ -414,6 +414,8 @@ namespace ts {
The_arguments_object_cannot_be_referenced_in_an_async_arrow_function_Consider_using_a_standard_async_function_expression: { code: 2522, category: DiagnosticCategory.Error, key: "The 'arguments' object cannot be referenced in an async arrow function. Consider using a standard async function expression." },
yield_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2523, category: DiagnosticCategory.Error, key: "'yield' expressions cannot be used in a parameter initializer." },
await_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2524, category: DiagnosticCategory.Error, key: "'await' expressions cannot be used in a parameter initializer." },
Cannot_bind_an_expression_whose_type_lacks_a_call_or_construct_signature: { code: 2525, category: DiagnosticCategory.Error, key: "Cannot bind an expression whose type lacks a call or construct signature." },
The_target_of_a_bind_expression_without_a_left_hand_side_must_be_a_property_or_element_access: { code: 2526, category: DiagnosticCategory.Error, key: "The target of a bind expression without a left-hand side must be a property or element access." },
JSX_element_attributes_type_0_must_be_an_object_type: { code: 2600, category: DiagnosticCategory.Error, key: "JSX element attributes type '{0}' must be an object type." },
The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: DiagnosticCategory.Error, key: "The return type of a JSX element constructor must return an object type." },
JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: { code: 2602, category: DiagnosticCategory.Error, key: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." },

Просмотреть файл

@ -1645,6 +1645,14 @@
"category": "Error",
"code": 2524
},
"Cannot bind an expression whose type lacks a call or construct signature.": {
"category": "Error",
"code": 2525
},
"The target of a bind expression without a left-hand side must be a property or element access.": {
"category": "Error",
"code": 2526
},
"JSX element attributes type '{0}' must be an object type.": {
"category": "Error",
"code": 2600

Просмотреть файл

@ -23,6 +23,13 @@ var __extends = (this && this.__extends) || function (d, b) {
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};`;
// emit output for the __bind helper function
const bindHelper = `
var __bind = (this && this.__bind) || function (b, t) {
var d;
return d = function() { return b.apply(t, arguments); }, d.prototype = b.prototype, d;
};`;
// emit output for the __decorate helper function
const decorateHelper = `
@ -147,6 +154,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
let decorateEmitted = false;
let paramEmitted = false;
let awaiterEmitted = false;
let bindEmitted = false;
let tempFlags = 0;
let tempVariables: Identifier[];
let tempParameters: Identifier[];
@ -1442,6 +1450,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
case SyntaxKind.WhileStatement:
case SyntaxKind.WithStatement:
case SyntaxKind.YieldExpression:
case SyntaxKind.BindExpression:
return true;
case SyntaxKind.BindingElement:
case SyntaxKind.EnumMember:
@ -2156,22 +2165,32 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
}
function emitCallExpression(node: CallExpression) {
if (languageVersion < ScriptTarget.ES6 && hasSpreadElement(node.arguments)) {
let expression = node.expression;
if (expression.kind === SyntaxKind.BindExpression) {
if ((<BindExpression>expression).baseExpression !== undefined) {
emitBindExpression(<BindExpression>expression, node.arguments);
return;
}
else {
expression = (<BindExpression>expression).targetExpression;
}
}
else if (languageVersion < ScriptTarget.ES6 && hasSpreadElement(node.arguments)) {
emitCallWithSpread(node);
return;
}
let superCall = false;
if (node.expression.kind === SyntaxKind.SuperKeyword) {
emitSuper(node.expression);
if (expression.kind === SyntaxKind.SuperKeyword) {
emitSuper(expression);
superCall = true;
}
else {
emit(node.expression);
superCall = node.expression.kind === SyntaxKind.PropertyAccessExpression && (<PropertyAccessExpression>node.expression).expression.kind === SyntaxKind.SuperKeyword;
emit(expression);
superCall = expression.kind === SyntaxKind.PropertyAccessExpression && (<PropertyAccessExpression>expression).expression.kind === SyntaxKind.SuperKeyword;
}
if (superCall && languageVersion < ScriptTarget.ES6) {
write(".call(");
emitThis(node.expression);
emitThis(expression);
if (node.arguments.length) {
write(", ");
emitCommaList(node.arguments);
@ -2236,6 +2255,108 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
emitDownlevelTaggedTemplate(node);
}
}
function createCallCall(expression: Expression, thisArgument: Expression, _arguments: NodeArray<Expression>) {
let callIdentifier = <Identifier>createSynthesizedNode(SyntaxKind.Identifier);
callIdentifier.text = "call";
let callExpr = createCallExpression(
createPropertyAccessExpression(expression, callIdentifier),
[thisArgument, ..._arguments]);
return callExpr;
}
function createBindCall(expression: Expression, thisArgument: Expression) {
if (languageVersion < ScriptTarget.ES5) {
let bindIdentifier = <Identifier>createSynthesizedNode(SyntaxKind.Identifier);
bindIdentifier.text = "__bind";
let callExpr = createCallExpression(
bindIdentifier,
[parenthesizeForAccess(expression), thisArgument]);
return callExpr;
}
else {
let bindIdentifier = <Identifier>createSynthesizedNode(SyntaxKind.Identifier);
bindIdentifier.text = "bind";
let callExpr = createCallExpression(
createPropertyAccessExpression(expression, bindIdentifier),
[thisArgument]);
return callExpr;
}
}
function createCallExpression(expression: Expression, _arguments: Expression[]) {
let callExpr = <CallExpression>createSynthesizedNode(SyntaxKind.CallExpression);
callExpr.expression = parenthesizeForAccess(expression);
callExpr.arguments = <NodeArray<Expression>>createSynthesizedNodeArray();
for (let argument of _arguments) {
callExpr.arguments.push(argument);
}
return callExpr;
}
function createAssignmentExpression(left: Expression, right: Expression): BinaryExpression {
let assignExpression = <BinaryExpression>createSynthesizedNode(SyntaxKind.BinaryExpression);
assignExpression.left = left;
assignExpression.operatorToken = createSynthesizedNode(SyntaxKind.EqualsToken);
assignExpression.right = right;
return assignExpression;
}
function createCommaExpression(left: Expression, right: Expression): BinaryExpression {
let commaExpression = <BinaryExpression>createSynthesizedNode(SyntaxKind.BinaryExpression);
commaExpression.left = left;
commaExpression.operatorToken = createSynthesizedNode(SyntaxKind.CommaToken);
commaExpression.right = right;
return commaExpression;
}
function emitBindExpression(node: BindExpression, _arguments?: NodeArray<Expression>): void {
let { baseExpression, targetExpression } = node;
let boundExpression: Expression;
let thisArgument: Expression;
if (baseExpression) {
let tempVariable = createAndRecordTempVariable(TempFlags.Auto);
boundExpression = createCommaExpression(
createAssignmentExpression(tempVariable, baseExpression),
targetExpression
);
thisArgument = tempVariable;
}
else if (targetExpression.kind === SyntaxKind.PropertyAccessExpression) {
let tempVariable = createAndRecordTempVariable(TempFlags.Auto);
let { expression, name } = <PropertyAccessExpression>targetExpression;
boundExpression = createPropertyAccessExpression(
createAssignmentExpression(tempVariable, expression),
name
);
thisArgument = tempVariable;
}
else if (targetExpression.kind === SyntaxKind.ElementAccessExpression) {
let tempVariable = createAndRecordTempVariable(TempFlags.Auto);
let { expression, argumentExpression } = <ElementAccessExpression>targetExpression;
boundExpression = createElementAccessExpression(
createAssignmentExpression(tempVariable, expression),
argumentExpression
);
thisArgument = tempVariable;
}
else {
emit(targetExpression);
return;
}
let callExpression = _arguments
? createCallCall(boundExpression, thisArgument, _arguments)
: createBindCall(boundExpression, thisArgument);
emit(callExpression);
}
function emitParenExpression(node: ParenthesizedExpression) {
// If the node is synthesized, it means the emitter put the parentheses there,
@ -6232,6 +6353,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
writeLines(extendsHelper);
extendsEmitted = true;
}
if ((languageVersion < ScriptTarget.ES5) && (!bindEmitted && resolver.getNodeCheckFlags(node) & NodeCheckFlags.EmitBind)) {
writeLines(bindHelper);
bindEmitted = true;
}
if (!decorateEmitted && resolver.getNodeCheckFlags(node) & NodeCheckFlags.EmitDecorate) {
writeLines(decorateHelper);
@ -6416,6 +6542,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
return emitNewExpression(<NewExpression>node);
case SyntaxKind.TaggedTemplateExpression:
return emitTaggedTemplateExpression(<TaggedTemplateExpression>node);
case SyntaxKind.BindExpression:
return emitBindExpression(<BindExpression>node);
case SyntaxKind.TypeAssertionExpression:
return emit((<TypeAssertion>node).expression);
case SyntaxKind.AsExpression:

Просмотреть файл

@ -168,6 +168,9 @@ namespace ts {
case SyntaxKind.AsExpression:
return visitNode(cbNode, (<AsExpression>node).expression) ||
visitNode(cbNode, (<AsExpression>node).type);
case SyntaxKind.BindExpression:
return visitNode(cbNode, (<BindExpression>node).baseExpression) ||
visitNode(cbNode, (<BindExpression>node).targetExpression);
case SyntaxKind.ConditionalExpression:
return visitNode(cbNode, (<ConditionalExpression>node).condition) ||
visitNode(cbNode, (<ConditionalExpression>node).questionToken) ||
@ -2526,6 +2529,7 @@ namespace ts {
case SyntaxKind.MinusToken:
case SyntaxKind.TildeToken:
case SyntaxKind.ExclamationToken:
case SyntaxKind.ColonColonToken:
case SyntaxKind.DeleteKeyword:
case SyntaxKind.TypeOfKeyword:
case SyntaxKind.VoidKeyword:
@ -3232,15 +3236,25 @@ namespace ts {
// the last two CallExpression productions. Or we have a MemberExpression which either
// completes the LeftHandSideExpression, or starts the beginning of the first four
// CallExpression productions.
let expression = token === SyntaxKind.SuperKeyword
? parseSuperExpression()
: parseMemberExpressionOrHigher();
let expression =
token === SyntaxKind.ColonColonToken ? parseBindExpressionRest(/*baseExpression*/ undefined) :
token === SyntaxKind.SuperKeyword ? parseSuperExpression() :
parseMemberExpressionOrHigher();
// Now, we *may* be complete. However, we might have consumed the start of a
// CallExpression. As such, we need to consume the rest of it here to be complete.
return parseCallExpressionRest(expression);
}
function parseBindExpressionRest(baseExpression: LeftHandSideExpression) {
let fullStart = baseExpression ? baseExpression.pos : scanner.getStartPos();
let node = <BindExpression>createNode(SyntaxKind.BindExpression, fullStart);
node.baseExpression = baseExpression;
nextToken();
node.targetExpression = parseMemberExpressionOrHigher();
return finishNode(node);
}
function parseMemberExpressionOrHigher(): MemberExpression {
// Note: to make our lives simpler, we decompose the the NewExpression productions and
// place ObjectCreationExpression and FunctionExpression into PrimaryExpression.
@ -3506,7 +3520,7 @@ namespace ts {
expression = finishNode(tagExpression);
continue;
}
return <MemberExpression>expression;
}
}
@ -3538,6 +3552,10 @@ namespace ts {
expression = finishNode(callExpr);
continue;
}
else if (token === SyntaxKind.ColonColonToken) {
expression = parseBindExpressionRest(expression);
continue;
}
return expression;
}

Просмотреть файл

@ -149,6 +149,7 @@ namespace ts {
"||": SyntaxKind.BarBarToken,
"?": SyntaxKind.QuestionToken,
":": SyntaxKind.ColonToken,
"::": SyntaxKind.ColonColonToken,
"=": SyntaxKind.EqualsToken,
"+=": SyntaxKind.PlusEqualsToken,
"-=": SyntaxKind.MinusEqualsToken,
@ -1292,6 +1293,9 @@ namespace ts {
tokenValue = "" + scanNumber();
return token = SyntaxKind.NumericLiteral;
case CharacterCodes.colon:
if (text.charCodeAt(pos + 1) === CharacterCodes.colon) {
return pos += 2, token = SyntaxKind.ColonColonToken;
}
return pos++, token = SyntaxKind.ColonToken;
case CharacterCodes.semicolon:
return pos++, token = SyntaxKind.SemicolonToken;

Просмотреть файл

@ -76,6 +76,7 @@ namespace ts {
BarBarToken,
QuestionToken,
ColonToken,
ColonColonToken,
AtToken,
// Assignments
EqualsToken,
@ -224,6 +225,7 @@ namespace ts {
OmittedExpression,
ExpressionWithTypeArguments,
AsExpression,
BindExpression,
// Misc
TemplateSpan,
@ -852,6 +854,11 @@ namespace ts {
}
export type AssertionExpression = TypeAssertion | AsExpression;
export interface BindExpression extends LeftHandSideExpression {
baseExpression?: LeftHandSideExpression;
targetExpression?: MemberExpression;
}
/// A JSX expression of the form <TagName attrs>...</TagName>
export interface JsxElement extends PrimaryExpression {
@ -1689,16 +1696,17 @@ namespace ts {
EmitParam = 0x00000020, // Emit __param helper for decorators
EmitAwaiter = 0x00000040, // Emit __awaiter
EmitGenerator = 0x00000080, // Emit __generator
SuperInstance = 0x00000100, // Instance 'super' reference
SuperStatic = 0x00000200, // Static 'super' reference
ContextChecked = 0x00000400, // Contextual types have been assigned
LexicalArguments = 0x00000800,
CaptureArguments = 0x00001000, // Lexical 'arguments' used in body (for async functions)
EmitBind = 0x00000100, // Emit __bind
SuperInstance = 0x00000200, // Instance 'super' reference
SuperStatic = 0x00000400, // Static 'super' reference
ContextChecked = 0x00000800, // Contextual types have been assigned
LexicalArguments = 0x00001000,
CaptureArguments = 0x00002000, // Lexical 'arguments' used in body (for async functions)
// Values for enum members have been computed, and any errors have been reported for them.
EnumValuesComputed = 0x00002000,
BlockScopedBindingInLoop = 0x00004000,
LexicalModuleMergesWithClass= 0x00008000, // Instantiated lexical module declaration is merged with a previous class declaration.
EnumValuesComputed = 0x00004000,
BlockScopedBindingInLoop = 0x00008000,
LexicalModuleMergesWithClass= 0x00010000, // Instantiated lexical module declaration is merged with a previous class declaration.
}
/* @internal */

Просмотреть файл

@ -863,6 +863,7 @@ namespace ts {
case SyntaxKind.ElementAccessExpression:
case SyntaxKind.CallExpression:
case SyntaxKind.NewExpression:
case SyntaxKind.BindExpression:
case SyntaxKind.TaggedTemplateExpression:
case SyntaxKind.AsExpression:
case SyntaxKind.TypeAssertionExpression:
@ -1916,6 +1917,7 @@ namespace ts {
case SyntaxKind.ElementAccessExpression:
case SyntaxKind.NewExpression:
case SyntaxKind.CallExpression:
case SyntaxKind.BindExpression:
case SyntaxKind.JsxElement:
case SyntaxKind.JsxSelfClosingElement:
case SyntaxKind.TaggedTemplateExpression:

Просмотреть файл

@ -46,6 +46,10 @@ namespace ts.formatting {
public NoSpaceAfterOpenBracket: Rule;
public NoSpaceBeforeCloseBracket: Rule;
public NoSpaceAfterCloseBracket: Rule;
// No space for bind
public NoSpaceBeforeColonColon: Rule;
public NoSpaceAfterColonColon: Rule;
// Insert a space after { and before } in single-line contexts, but remove space from empty object literals {}.
public SpaceAfterOpenBrace: Rule;
@ -238,6 +242,10 @@ namespace ts.formatting {
this.NoSpaceAfterOpenBracket = new Rule(RuleDescriptor.create3(SyntaxKind.OpenBracketToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
this.NoSpaceBeforeCloseBracket = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CloseBracketToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
this.NoSpaceAfterCloseBracket = new Rule(RuleDescriptor.create3(SyntaxKind.CloseBracketToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext), RuleAction.Delete));
// No space for bind
this.NoSpaceBeforeColonColon = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.ColonColonToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
this.NoSpaceAfterColonColon = new Rule(RuleDescriptor.create3(SyntaxKind.ColonColonToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
// Place a space before open brace in a function declaration
this.FunctionOpenBraceLeftTokenRange = Shared.TokenRange.AnyIncludingMultilineComments;
@ -358,6 +366,7 @@ namespace ts.formatting {
this.NoSpaceBeforeColon, this.SpaceAfterColon, this.NoSpaceBeforeQuestionMark, this.SpaceAfterQuestionMarkInConditionalOperator,
this.NoSpaceAfterQuestionMark,
this.NoSpaceBeforeDot, this.NoSpaceAfterDot,
this.NoSpaceBeforeColonColon, this.NoSpaceAfterColonColon,
this.NoSpaceAfterUnaryPrefixOperator,
this.NoSpaceAfterUnaryPreincrementOperator, this.NoSpaceAfterUnaryPredecrementOperator,
this.NoSpaceBeforeUnaryPostincrementOperator, this.NoSpaceBeforeUnaryPostdecrementOperator,

Просмотреть файл

@ -75,26 +75,26 @@ function delint(sourceFile) {
delintNode(sourceFile);
function delintNode(node) {
switch (node.kind) {
case 196 /* ForStatement */:
case 197 /* ForInStatement */:
case 195 /* WhileStatement */:
case 194 /* DoStatement */:
if (node.statement.kind !== 189 /* Block */) {
case 198 /* ForStatement */:
case 199 /* ForInStatement */:
case 197 /* WhileStatement */:
case 196 /* DoStatement */:
if (node.statement.kind !== 191 /* Block */) {
report(node, "A looping statement's contents should be wrapped in a block body.");
}
break;
case 193 /* IfStatement */:
case 195 /* IfStatement */:
var ifStatement = node;
if (ifStatement.thenStatement.kind !== 189 /* Block */) {
if (ifStatement.thenStatement.kind !== 191 /* Block */) {
report(ifStatement.thenStatement, "An if statement's contents should be wrapped in a block body.");
}
if (ifStatement.elseStatement &&
ifStatement.elseStatement.kind !== 189 /* Block */ &&
ifStatement.elseStatement.kind !== 193 /* IfStatement */) {
ifStatement.elseStatement.kind !== 191 /* Block */ &&
ifStatement.elseStatement.kind !== 195 /* IfStatement */) {
report(ifStatement.elseStatement, "An else statement's contents should be wrapped in a block body.");
}
break;
case 178 /* BinaryExpression */:
case 179 /* BinaryExpression */:
var op = node.operatorToken.kind;
if (op === 29 /* EqualsEqualsToken */ || op == 30 /* ExclamationEqualsToken */) {
report(node, "Use '===' and '!=='.");

Просмотреть файл

@ -0,0 +1,46 @@
//// [bindOperator1.ts]
declare var a: { b(): number; c(): { b(): boolean; }; };
declare function b(): string;
declare class C { b(): boolean; }
let z = a::b;
let y = a::b();
let x = a::a.b;
let w = a::a.b();
let v = a::a["b"];
let u = a::a["b"]();
let t = a.b::b;
let s = a.b::b();
let r = a["b"]::b;
let q = a["b"]::b();
let p = ::a.b;
let o = ::a.b();
let n = ::a["b"];
let m = ::a["b"]();
let l = a.c()::b;
let k = a.c()::b();
let j = a.c()::a.b;
let i = a.c()::a.b();
let h = a.c()::new C().b;
//// [bindOperator1.js]
var z = (_a = a, b).bind(_a);
var y = (_b = a, b).call(_b);
var x = (_c = a, a.b).bind(_c);
var w = (_d = a, a.b).call(_d);
var v = (_e = a, a["b"]).bind(_e);
var u = (_f = a, a["b"]).call(_f);
var t = (_g = a.b, b).bind(_g);
var s = (_h = a.b, b).call(_h);
var r = (_j = a["b"], b).bind(_j);
var q = (_k = a["b"], b).call(_k);
var p = (_l = a).b.bind(_l);
var o = a.b();
var n = (_m = a)["b"].bind(_m);
var m = a["b"]();
var l = (_o = a.c(), b).bind(_o);
var k = (_p = a.c(), b).call(_p);
var j = (_q = a.c(), a.b).bind(_q);
var i = (_r = a.c(), a.b).call(_r);
var h = (_s = a.c(), new C().b).bind(_s);
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;

Просмотреть файл

@ -0,0 +1,139 @@
=== tests/cases/conformance/expressions/bindOperator/bindOperator1.ts ===
declare var a: { b(): number; c(): { b(): boolean; }; };
>a : Symbol(a, Decl(bindOperator1.ts, 0, 11))
>b : Symbol(b, Decl(bindOperator1.ts, 0, 16))
>c : Symbol(c, Decl(bindOperator1.ts, 0, 29))
>b : Symbol(b, Decl(bindOperator1.ts, 0, 36))
declare function b(): string;
>b : Symbol(b, Decl(bindOperator1.ts, 0, 56))
declare class C { b(): boolean; }
>C : Symbol(C, Decl(bindOperator1.ts, 1, 29))
>b : Symbol(b, Decl(bindOperator1.ts, 2, 17))
let z = a::b;
>z : Symbol(z, Decl(bindOperator1.ts, 4, 3))
>a : Symbol(a, Decl(bindOperator1.ts, 0, 11))
>b : Symbol(b, Decl(bindOperator1.ts, 0, 56))
let y = a::b();
>y : Symbol(y, Decl(bindOperator1.ts, 5, 3))
>a : Symbol(a, Decl(bindOperator1.ts, 0, 11))
>b : Symbol(b, Decl(bindOperator1.ts, 0, 56))
let x = a::a.b;
>x : Symbol(x, Decl(bindOperator1.ts, 6, 3))
>a : Symbol(a, Decl(bindOperator1.ts, 0, 11))
>a.b : Symbol(b, Decl(bindOperator1.ts, 0, 16))
>a : Symbol(a, Decl(bindOperator1.ts, 0, 11))
>b : Symbol(b, Decl(bindOperator1.ts, 0, 16))
let w = a::a.b();
>w : Symbol(w, Decl(bindOperator1.ts, 7, 3))
>a : Symbol(a, Decl(bindOperator1.ts, 0, 11))
>a.b : Symbol(b, Decl(bindOperator1.ts, 0, 16))
>a : Symbol(a, Decl(bindOperator1.ts, 0, 11))
>b : Symbol(b, Decl(bindOperator1.ts, 0, 16))
let v = a::a["b"];
>v : Symbol(v, Decl(bindOperator1.ts, 8, 3))
>a : Symbol(a, Decl(bindOperator1.ts, 0, 11))
>a : Symbol(a, Decl(bindOperator1.ts, 0, 11))
>"b" : Symbol(b, Decl(bindOperator1.ts, 0, 16))
let u = a::a["b"]();
>u : Symbol(u, Decl(bindOperator1.ts, 9, 3))
>a : Symbol(a, Decl(bindOperator1.ts, 0, 11))
>a : Symbol(a, Decl(bindOperator1.ts, 0, 11))
>"b" : Symbol(b, Decl(bindOperator1.ts, 0, 16))
let t = a.b::b;
>t : Symbol(t, Decl(bindOperator1.ts, 10, 3))
>a.b : Symbol(b, Decl(bindOperator1.ts, 0, 16))
>a : Symbol(a, Decl(bindOperator1.ts, 0, 11))
>b : Symbol(b, Decl(bindOperator1.ts, 0, 16))
>b : Symbol(b, Decl(bindOperator1.ts, 0, 56))
let s = a.b::b();
>s : Symbol(s, Decl(bindOperator1.ts, 11, 3))
>a.b : Symbol(b, Decl(bindOperator1.ts, 0, 16))
>a : Symbol(a, Decl(bindOperator1.ts, 0, 11))
>b : Symbol(b, Decl(bindOperator1.ts, 0, 16))
>b : Symbol(b, Decl(bindOperator1.ts, 0, 56))
let r = a["b"]::b;
>r : Symbol(r, Decl(bindOperator1.ts, 12, 3))
>a : Symbol(a, Decl(bindOperator1.ts, 0, 11))
>"b" : Symbol(b, Decl(bindOperator1.ts, 0, 16))
>b : Symbol(b, Decl(bindOperator1.ts, 0, 56))
let q = a["b"]::b();
>q : Symbol(q, Decl(bindOperator1.ts, 13, 3))
>a : Symbol(a, Decl(bindOperator1.ts, 0, 11))
>"b" : Symbol(b, Decl(bindOperator1.ts, 0, 16))
>b : Symbol(b, Decl(bindOperator1.ts, 0, 56))
let p = ::a.b;
>p : Symbol(p, Decl(bindOperator1.ts, 14, 3))
>a.b : Symbol(b, Decl(bindOperator1.ts, 0, 16))
>a : Symbol(a, Decl(bindOperator1.ts, 0, 11))
>b : Symbol(b, Decl(bindOperator1.ts, 0, 16))
let o = ::a.b();
>o : Symbol(o, Decl(bindOperator1.ts, 15, 3))
>a.b : Symbol(b, Decl(bindOperator1.ts, 0, 16))
>a : Symbol(a, Decl(bindOperator1.ts, 0, 11))
>b : Symbol(b, Decl(bindOperator1.ts, 0, 16))
let n = ::a["b"];
>n : Symbol(n, Decl(bindOperator1.ts, 16, 3))
>a : Symbol(a, Decl(bindOperator1.ts, 0, 11))
>"b" : Symbol(b, Decl(bindOperator1.ts, 0, 16))
let m = ::a["b"]();
>m : Symbol(m, Decl(bindOperator1.ts, 17, 3))
>a : Symbol(a, Decl(bindOperator1.ts, 0, 11))
>"b" : Symbol(b, Decl(bindOperator1.ts, 0, 16))
let l = a.c()::b;
>l : Symbol(l, Decl(bindOperator1.ts, 18, 3))
>a.c : Symbol(c, Decl(bindOperator1.ts, 0, 29))
>a : Symbol(a, Decl(bindOperator1.ts, 0, 11))
>c : Symbol(c, Decl(bindOperator1.ts, 0, 29))
>b : Symbol(b, Decl(bindOperator1.ts, 0, 56))
let k = a.c()::b();
>k : Symbol(k, Decl(bindOperator1.ts, 19, 3))
>a.c : Symbol(c, Decl(bindOperator1.ts, 0, 29))
>a : Symbol(a, Decl(bindOperator1.ts, 0, 11))
>c : Symbol(c, Decl(bindOperator1.ts, 0, 29))
>b : Symbol(b, Decl(bindOperator1.ts, 0, 56))
let j = a.c()::a.b;
>j : Symbol(j, Decl(bindOperator1.ts, 20, 3))
>a.c : Symbol(c, Decl(bindOperator1.ts, 0, 29))
>a : Symbol(a, Decl(bindOperator1.ts, 0, 11))
>c : Symbol(c, Decl(bindOperator1.ts, 0, 29))
>a.b : Symbol(b, Decl(bindOperator1.ts, 0, 16))
>a : Symbol(a, Decl(bindOperator1.ts, 0, 11))
>b : Symbol(b, Decl(bindOperator1.ts, 0, 16))
let i = a.c()::a.b();
>i : Symbol(i, Decl(bindOperator1.ts, 21, 3))
>a.c : Symbol(c, Decl(bindOperator1.ts, 0, 29))
>a : Symbol(a, Decl(bindOperator1.ts, 0, 11))
>c : Symbol(c, Decl(bindOperator1.ts, 0, 29))
>a.b : Symbol(b, Decl(bindOperator1.ts, 0, 16))
>a : Symbol(a, Decl(bindOperator1.ts, 0, 11))
>b : Symbol(b, Decl(bindOperator1.ts, 0, 16))
let h = a.c()::new C().b;
>h : Symbol(h, Decl(bindOperator1.ts, 22, 3))
>a.c : Symbol(c, Decl(bindOperator1.ts, 0, 29))
>a : Symbol(a, Decl(bindOperator1.ts, 0, 11))
>c : Symbol(c, Decl(bindOperator1.ts, 0, 29))
>new C().b : Symbol(C.b, Decl(bindOperator1.ts, 2, 17))
>C : Symbol(C, Decl(bindOperator1.ts, 1, 29))
>b : Symbol(C.b, Decl(bindOperator1.ts, 2, 17))

Просмотреть файл

@ -0,0 +1,179 @@
=== tests/cases/conformance/expressions/bindOperator/bindOperator1.ts ===
declare var a: { b(): number; c(): { b(): boolean; }; };
>a : { b(): number; c(): { b(): boolean; }; }
>b : () => number
>c : () => { b(): boolean; }
>b : () => boolean
declare function b(): string;
>b : () => string
declare class C { b(): boolean; }
>C : C
>b : () => boolean
let z = a::b;
>z : () => string
>a::b : () => string
>a : { b(): number; c(): { b(): boolean; }; }
>b : () => string
let y = a::b();
>y : string
>a::b() : string
>a::b : () => string
>a : { b(): number; c(): { b(): boolean; }; }
>b : () => string
let x = a::a.b;
>x : () => number
>a::a.b : () => number
>a : { b(): number; c(): { b(): boolean; }; }
>a.b : () => number
>a : { b(): number; c(): { b(): boolean; }; }
>b : () => number
let w = a::a.b();
>w : number
>a::a.b() : number
>a::a.b : () => number
>a : { b(): number; c(): { b(): boolean; }; }
>a.b : () => number
>a : { b(): number; c(): { b(): boolean; }; }
>b : () => number
let v = a::a["b"];
>v : () => number
>a::a["b"] : () => number
>a : { b(): number; c(): { b(): boolean; }; }
>a["b"] : () => number
>a : { b(): number; c(): { b(): boolean; }; }
>"b" : string
let u = a::a["b"]();
>u : number
>a::a["b"]() : number
>a::a["b"] : () => number
>a : { b(): number; c(): { b(): boolean; }; }
>a["b"] : () => number
>a : { b(): number; c(): { b(): boolean; }; }
>"b" : string
let t = a.b::b;
>t : () => string
>a.b::b : () => string
>a.b : () => number
>a : { b(): number; c(): { b(): boolean; }; }
>b : () => number
>b : () => string
let s = a.b::b();
>s : string
>a.b::b() : string
>a.b::b : () => string
>a.b : () => number
>a : { b(): number; c(): { b(): boolean; }; }
>b : () => number
>b : () => string
let r = a["b"]::b;
>r : () => string
>a["b"]::b : () => string
>a["b"] : () => number
>a : { b(): number; c(): { b(): boolean; }; }
>"b" : string
>b : () => string
let q = a["b"]::b();
>q : string
>a["b"]::b() : string
>a["b"]::b : () => string
>a["b"] : () => number
>a : { b(): number; c(): { b(): boolean; }; }
>"b" : string
>b : () => string
let p = ::a.b;
>p : () => number
>::a.b : () => number
>a.b : () => number
>a : { b(): number; c(): { b(): boolean; }; }
>b : () => number
let o = ::a.b();
>o : number
>::a.b() : number
>::a.b : () => number
>a.b : () => number
>a : { b(): number; c(): { b(): boolean; }; }
>b : () => number
let n = ::a["b"];
>n : () => number
>::a["b"] : () => number
>a["b"] : () => number
>a : { b(): number; c(): { b(): boolean; }; }
>"b" : string
let m = ::a["b"]();
>m : number
>::a["b"]() : number
>::a["b"] : () => number
>a["b"] : () => number
>a : { b(): number; c(): { b(): boolean; }; }
>"b" : string
let l = a.c()::b;
>l : () => string
>a.c()::b : () => string
>a.c() : { b(): boolean; }
>a.c : () => { b(): boolean; }
>a : { b(): number; c(): { b(): boolean; }; }
>c : () => { b(): boolean; }
>b : () => string
let k = a.c()::b();
>k : string
>a.c()::b() : string
>a.c()::b : () => string
>a.c() : { b(): boolean; }
>a.c : () => { b(): boolean; }
>a : { b(): number; c(): { b(): boolean; }; }
>c : () => { b(): boolean; }
>b : () => string
let j = a.c()::a.b;
>j : () => number
>a.c()::a.b : () => number
>a.c() : { b(): boolean; }
>a.c : () => { b(): boolean; }
>a : { b(): number; c(): { b(): boolean; }; }
>c : () => { b(): boolean; }
>a.b : () => number
>a : { b(): number; c(): { b(): boolean; }; }
>b : () => number
let i = a.c()::a.b();
>i : number
>a.c()::a.b() : number
>a.c()::a.b : () => number
>a.c() : { b(): boolean; }
>a.c : () => { b(): boolean; }
>a : { b(): number; c(): { b(): boolean; }; }
>c : () => { b(): boolean; }
>a.b : () => number
>a : { b(): number; c(): { b(): boolean; }; }
>b : () => number
let h = a.c()::new C().b;
>h : () => boolean
>a.c()::new C().b : () => boolean
>a.c() : { b(): boolean; }
>a.c : () => { b(): boolean; }
>a : { b(): number; c(): { b(): boolean; }; }
>c : () => { b(): boolean; }
>new C().b : () => boolean
>new C() : C
>C : typeof C
>b : () => boolean

Просмотреть файл

@ -0,0 +1,24 @@
// @target: es5
declare var a: { b(): number; c(): { b(): boolean; }; };
declare function b(): string;
declare class C { b(): boolean; }
let z = a::b;
let y = a::b();
let x = a::a.b;
let w = a::a.b();
let v = a::a["b"];
let u = a::a["b"]();
let t = a.b::b;
let s = a.b::b();
let r = a["b"]::b;
let q = a["b"]::b();
let p = ::a.b;
let o = ::a.b();
let n = ::a["b"];
let m = ::a["b"]();
let l = a.c()::b;
let k = a.c()::b();
let j = a.c()::a.b;
let i = a.c()::a.b();
let h = a.c()::new C().b;