1
+ /*! *****************************************************************************
2
+ Copyright (c) Microsoft Corporation. All rights reserved.
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4
+ this file except in compliance with the License. You may obtain a copy of the
5
+ License at http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
8
+ KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
9
+ WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
10
+ MERCHANTABLITY OR NON-INFRINGEMENT.
11
+
12
+ See the Apache Version 2.0 License for specific language governing permissions
13
+ and limitations under the License.
14
+ ***************************************************************************** */
15
+
1
16
var TypeScript;
2
17
(function (TypeScript) {
3
18
TypeScript.DiagnosticCode = {
@@ -28413,6 +28428,7 @@ var TypeScript;
28413
28428
this.thisClassNode = null;
28414
28429
this.thisRoleNode = null;
28415
28430
this.thisFunctionNode = null;
28431
+ this.thisDCIContextNode = null;
28416
28432
this.moduleName = "";
28417
28433
this.emitState = new EmitState();
28418
28434
this.indenter = new Indenter();
@@ -28799,69 +28815,74 @@ var TypeScript;
28799
28815
var binExpTarget, operand1, operand2, dciContext, isCallToRoleMethod = false, isCallToSelf = false, roleName;
28800
28816
28801
28817
if (this.thisFunctionNode && target instanceof TypeScript.BinaryExpression) {
28802
- if (this.thisFunctionNode.isDCIContext) {
28803
- dciContext = this.thisFunctionNode;
28804
- }
28805
-
28806
- var declStack = this.declStack;
28807
- for (var i = 0; i < declStack.length; i++) {
28808
- if (declStack[i] instanceof TypeScript.PullFunctionExpressionDecl) {
28809
- var funcDecl = declStack[i].ast;
28810
- if (funcDecl.isDCIContext) {
28811
- dciContext = funcDecl;
28812
- break;
28813
- }
28814
- }
28815
- }
28816
-
28817
- if (dciContext) {
28818
+ if (this.thisDCIContextNode) {
28819
+ dciContext = this.thisDCIContextNode;
28818
28820
binExpTarget = target;
28819
28821
operand1 = binExpTarget.operand1;
28820
28822
operand2 = binExpTarget.operand2;
28821
28823
28822
28824
if (this.thisRoleNode) {
28823
- if (this.thisRoleNode && operand1 instanceof TypeScript.ThisExpression) {
28825
+ if (this.thisRoleNode && ( operand1 instanceof TypeScript.ThisExpression || operand1.actualText == 'self') ) {
28824
28826
roleName = this.thisRoleNode.name.actualText;
28825
28827
isCallToSelf = true;
28826
28828
}
28827
28829
}
28828
28830
28829
- if (!isCallToSelf) {
28831
+ if (!roleName)
28830
28832
roleName = operand1.actualText;
28831
- if (roleName in dciContext.roleDeclarations) {
28832
- var methodName = operand2.actualText;
28833
- var roleDecl = dciContext.roleDeclarations[roleName] ;
28834
- roleDecl.members.members.forEach(function (member) {
28835
- if ((member).name.actualText == methodName ) {
28836
- isCallToRoleMethod = true;
28837
- return false ;
28838
- }
28839
- });
28840
- }
28833
+
28834
+ if (roleName && roleName in dciContext.roleDeclarations) {
28835
+ var methodName = operand2.actualText ;
28836
+ var roleDecl = dciContext.roleDeclarations[roleName];
28837
+ roleDecl.members.members.forEach(function (member ) {
28838
+ if ((member).name.actualText == methodName) {
28839
+ isCallToRoleMethod = true ;
28840
+ return false;
28841
+ }
28842
+ });
28841
28843
}
28842
28844
}
28843
28845
}
28844
28846
28845
28847
if (isCallToRoleMethod || isCallToSelf) {
28848
+ var isCallToThis = false;
28846
28849
if (isCallToSelf) {
28847
- this.writeToOutput("__dci_internal__.callMethodOnSelf");
28850
+ if (operand1 instanceof TypeScript.ThisExpression) {
28851
+ isCallToThis = true;
28852
+
28853
+ this.writeToOutput("__dci_internal__.callMethodOnSelf");
28854
+
28855
+ this.writeToOutput("(__context, this, '" + roleName + "'");
28856
+ this.writeToOutput(", '" + operand2.actualText + "'");
28848
28857
28849
- this.writeToOutput("(__context, this, '" + roleName + "'");
28850
- this.writeToOutput(", '" + operand2.actualText + "'");
28858
+ if (args && args.members.length)
28859
+ this.writeToOutput(", ");
28860
+ } else {
28861
+ if (isCallToRoleMethod) {
28862
+ this.writeToOutput("__context.__$" + roleName + "." + operand2.actualText + ".");
28863
+ this.writeToOutput("call(__context." + roleName);
28864
+
28865
+ if (args && args.members.length)
28866
+ this.writeToOutput(", ");
28867
+ } else {
28868
+ this.writeToOutput("__context." + roleName + "." + operand2.actualText + "(");
28869
+ }
28870
+ }
28851
28871
} else {
28852
28872
this.writeToOutput("__context.__$" + roleName + "." + operand2.actualText + ".");
28853
28873
this.writeToOutput("call(__context." + roleName);
28874
+
28875
+ if (args && args.members.length)
28876
+ this.writeToOutput(", ");
28854
28877
}
28855
- if (args && args.members.length)
28856
- this.writeToOutput(", ");
28857
28878
28858
28879
this.recordSourceMappingStart(args);
28859
28880
28860
28881
if (args && args.members.length) {
28861
- if (isCallToSelf )
28882
+ if (isCallToThis )
28862
28883
this.writeToOutput("[");
28863
28884
this.emitCommaSeparatedList(args);
28864
- if (isCallToSelf )
28885
+ if (isCallToThis )
28865
28886
this.writeToOutput("]");
28866
28887
}
28867
28888
} else {
@@ -28959,8 +28980,6 @@ var TypeScript;
28959
28980
}
28960
28981
this.writeLineToOutput(") {");
28961
28982
28962
- funcDecl.isDCIContext = (Object.keys(funcDecl.roleDeclarations).length > 0);
28963
-
28964
28983
if (funcDecl.isDCIContext) {
28965
28984
this.indenter.increaseIndent();
28966
28985
this.writeLineToOutput("var __context = this;");
@@ -29402,6 +29421,12 @@ var TypeScript;
29402
29421
var tempFnc = this.thisFunctionNode;
29403
29422
this.thisFunctionNode = funcDecl;
29404
29423
29424
+ funcDecl.isDCIContext = (Object.keys(funcDecl.roleDeclarations).length > 0);
29425
+ if (funcDecl.isDCIContext) {
29426
+ var tmpDCIContext = this.thisDCIContextNode;
29427
+ this.thisDCIContextNode = funcDecl;
29428
+ }
29429
+
29405
29430
if (funcDecl.isConstructor) {
29406
29431
temp = this.setContainer(4 /* Constructor */);
29407
29432
} else {
@@ -29417,6 +29442,10 @@ var TypeScript;
29417
29442
this.setContainer(temp);
29418
29443
this.thisFunctionNode = tempFnc;
29419
29444
29445
+ if (funcDecl.isDCIContext) {
29446
+ this.thisDCIContextNode = tmpDCIContext;
29447
+ }
29448
+
29420
29449
if (!TypeScript.hasFlag(funcDecl.getFunctionFlags(), 128 /* Signature */)) {
29421
29450
var pullFunctionDecl = this.semanticInfoChain.getDeclForAST(funcDecl, this.document.fileName);
29422
29451
if (TypeScript.hasFlag(funcDecl.getFunctionFlags(), 16 /* Static */)) {
@@ -40193,11 +40222,11 @@ var TypeScript;
40193
40222
40194
40223
nameSymbol = this.resolveNameSymbol(nameSymbol, context);
40195
40224
40196
- if (!nameSymbol && !lhsType.isPrimitive() && this.cachedObjectInterfaceType()) {
40197
- nameSymbol = this.getMemberSymbol(rhsName, TypeScript.PullElementKind.SomeValue, this.cachedObjectInterfaceType());
40198
- }
40199
-
40200
40225
if (!nameSymbol) {
40226
+ if (!lhsType.isPrimitive() && this.cachedObjectInterfaceType()) {
40227
+ nameSymbol = this.getMemberSymbol(rhsName, TypeScript.PullElementKind.SomeValue, this.cachedObjectInterfaceType());
40228
+ }
40229
+
40201
40230
if (lhs.kind != TypeScript.PullElementKind.Role) {
40202
40231
context.postError(this.unitPath, dottedNameAST.operand2.minChar, dottedNameAST.operand2.getLength(), TypeScript.DiagnosticCode.The_property_0_does_not_exist_on_value_of_type_1, [(dottedNameAST.operand2).actualText, lhsType.toString(enclosingDecl ? enclosingDecl.getSymbol() : null)], enclosingDecl);
40203
40232
}
@@ -53610,8 +53639,11 @@ var TypeScript;
53610
53639
};
53611
53640
53612
53641
Identifier.prototype.emit = function (emitter) {
53613
- if (emitter.thisFunctionNode && emitter.thisFunctionNode.isDCIContext) {
53614
- if (this.actualText in emitter.thisFunctionNode.roleDeclarations) {
53642
+ if (emitter.thisDCIContextNode) {
53643
+ if (emitter.thisRoleNode && this.actualText == 'self') {
53644
+ emitter.writeToOutput("__context." + emitter.thisRoleNode.name.actualText);
53645
+ return;
53646
+ } else if (this.actualText in emitter.thisDCIContextNode.roleDeclarations) {
53615
53647
emitter.writeToOutput("__context.");
53616
53648
}
53617
53649
}
@@ -54525,6 +54557,8 @@ var TypeScript;
54525
54557
_super.call(this, name, typeParameters, extendsList, implementsList, members);
54526
54558
this.endingToken = endingToken;
54527
54559
this.constructorDecl = null;
54560
+ this.isDCIContext = false;
54561
+ this.roleDeclarations = {};
54528
54562
}
54529
54563
ClassDeclaration.prototype.nodeType = function () {
54530
54564
return 14 /* ClassDeclaration */;
@@ -54644,9 +54678,6 @@ var TypeScript;
54644
54678
var operand1 = (this.expression).operand1;
54645
54679
var operand2 = (this.expression).operand2;
54646
54680
54647
- if (!emitter.thisFunctionNode.isDCIContext) {
54648
- emitter.writeToOutput("__context.");
54649
- }
54650
54681
operand1.emit(emitter);
54651
54682
emitter.writeToOutput(" = ");
54652
54683
@@ -57038,4 +57069,3 @@ var TypeScript;
57038
57069
57039
57070
var batch = new TypeScript.BatchCompiler(IO);
57040
57071
batch.batchCompile();
57041
- //# sourceMappingURL=file:////www/node_modules/typescript-dci/built/local/tsc.js.map
0 commit comments