OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library closureToClassMapper; | 5 library closureToClassMapper; |
6 | 6 |
7 import "elements/elements.dart"; | 7 import "elements/elements.dart"; |
8 import "dart2jslib.dart"; | 8 import "dart2jslib.dart"; |
9 import "tree/tree.dart"; | 9 import "tree/tree.dart"; |
10 import "util/util.dart"; | 10 import "util/util.dart"; |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 } | 364 } |
365 | 365 |
366 visitNewExpression(NewExpression node) { | 366 visitNewExpression(NewExpression node) { |
367 DartType type = elements.getType(node); | 367 DartType type = elements.getType(node); |
368 | 368 |
369 bool hasTypeVariable(DartType type) { | 369 bool hasTypeVariable(DartType type) { |
370 if (type is TypeVariableType) { | 370 if (type is TypeVariableType) { |
371 return true; | 371 return true; |
372 } else if (type is InterfaceType) { | 372 } else if (type is InterfaceType) { |
373 InterfaceType ifcType = type; | 373 InterfaceType ifcType = type; |
374 for (DartType argument in ifcType.arguments) { | 374 for (DartType argument in ifcType.typeArguments) { |
375 if (hasTypeVariable(argument)) { | 375 if (hasTypeVariable(argument)) { |
376 return true; | 376 return true; |
377 } | 377 } |
378 } | 378 } |
379 } | 379 } |
380 return false; | 380 return false; |
381 } | 381 } |
382 | 382 |
383 void analyzeTypeVariables(DartType type) { | 383 void analyzeTypeVariables(DartType type) { |
384 if (type is TypeVariableType) { | 384 if (type is TypeVariableType) { |
385 useLocal(type.element); | 385 useLocal(type.element); |
386 } else if (type is InterfaceType) { | 386 } else if (type is InterfaceType) { |
387 InterfaceType ifcType = type; | 387 InterfaceType ifcType = type; |
388 for (DartType argument in ifcType.arguments) { | 388 for (DartType argument in ifcType.typeArguments) { |
389 analyzeTypeVariables(argument); | 389 analyzeTypeVariables(argument); |
390 } | 390 } |
391 } | 391 } |
392 } | 392 } |
393 if (outermostElement.isMember() && | 393 if (outermostElement.isMember() && |
394 compiler.world.needsRti(outermostElement.getEnclosingClass())) { | 394 compiler.world.needsRti(outermostElement.getEnclosingClass())) { |
395 if (outermostElement.isInstanceMember() | 395 if (outermostElement.isInstanceMember() |
396 || outermostElement.isGenerativeConstructor()) { | 396 || outermostElement.isGenerativeConstructor()) { |
397 if (hasTypeVariable(type)) useLocal(closureData.thisElement); | 397 if (hasTypeVariable(type)) useLocal(closureData.thisElement); |
398 } else if (outermostElement.isFactoryConstructor()) { | 398 } else if (outermostElement.isFactoryConstructor()) { |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
615 } | 615 } |
616 | 616 |
617 visitTryStatement(TryStatement node) { | 617 visitTryStatement(TryStatement node) { |
618 // TODO(ngeoffray): implement finer grain state. | 618 // TODO(ngeoffray): implement finer grain state. |
619 bool oldInTryStatement = inTryStatement; | 619 bool oldInTryStatement = inTryStatement; |
620 inTryStatement = true; | 620 inTryStatement = true; |
621 node.visitChildren(this); | 621 node.visitChildren(this); |
622 inTryStatement = oldInTryStatement; | 622 inTryStatement = oldInTryStatement; |
623 } | 623 } |
624 } | 624 } |
OLD | NEW |