| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 import 'dart:collection' show HashSet, HashMap, SplayTreeSet; | 5 import 'dart:collection' show HashSet, HashMap, SplayTreeSet; |
| 6 | 6 |
| 7 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; | 7 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; |
| 8 import 'package:analyzer/dart/ast/token.dart'; | 8 import 'package:analyzer/dart/ast/token.dart'; |
| 9 import 'package:analyzer/src/generated/ast.dart' hide ConstantEvaluator; | 9 import 'package:analyzer/dart/element/element.dart'; |
| 10 import 'package:analyzer/dart/element/visitor.dart'; |
| 11 import 'package:analyzer/dart/element/type.dart'; |
| 12 import 'package:analyzer/dart/ast/ast.dart' hide ConstantEvaluator; |
| 10 import 'package:analyzer/src/generated/constant.dart'; | 13 import 'package:analyzer/src/generated/constant.dart'; |
| 11 import 'package:analyzer/src/generated/element.dart'; | 14 //TODO(leafp): Remove deprecated dependency |
| 15 //ignore: DEPRECATED_MEMBER_USE |
| 16 import 'package:analyzer/src/generated/element.dart' |
| 17 show DynamicElementImpl, DynamicTypeImpl, LocalVariableElementImpl; |
| 12 import 'package:analyzer/src/generated/engine.dart' show AnalysisContext; | 18 import 'package:analyzer/src/generated/engine.dart' show AnalysisContext; |
| 13 import 'package:analyzer/src/generated/resolver.dart' show TypeProvider; | 19 import 'package:analyzer/src/generated/resolver.dart' show TypeProvider; |
| 14 import 'package:analyzer/src/dart/ast/token.dart' | 20 import 'package:analyzer/src/dart/ast/token.dart' |
| 15 show StringToken, Token, TokenType; | 21 show StringToken, Token, TokenType; |
| 16 import 'package:analyzer/src/generated/type_system.dart' | 22 import 'package:analyzer/src/generated/type_system.dart' |
| 17 show StrongTypeSystemImpl; | 23 show StrongTypeSystemImpl; |
| 18 | 24 |
| 19 import 'ast_builder.dart' show AstBuilder; | 25 import 'ast_builder.dart' show AstBuilder; |
| 20 import 'reify_coercions.dart' show CoercionReifier, Tuple2; | 26 import 'reify_coercions.dart' show CoercionReifier, Tuple2; |
| 21 | 27 |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 var type = element.type; | 496 var type = element.type; |
| 491 var name = js.string(type.name); | 497 var name = js.string(type.name); |
| 492 var id = new JS.Identifier(type.name); | 498 var id = new JS.Identifier(type.name); |
| 493 | 499 |
| 494 // Generate a class per section 13 of the spec. | 500 // Generate a class per section 13 of the spec. |
| 495 // TODO(vsm): Generate any accompanying metadata | 501 // TODO(vsm): Generate any accompanying metadata |
| 496 | 502 |
| 497 // Create constructor and initialize index | 503 // Create constructor and initialize index |
| 498 var constructor = new JS.Method( | 504 var constructor = new JS.Method( |
| 499 name, js.call('function(index) { this.index = index; }') as JS.Fun); | 505 name, js.call('function(index) { this.index = index; }') as JS.Fun); |
| 500 var fields = new List<ConstFieldElementImpl>.from( | 506 var fields = new List<FieldElement>.from( |
| 501 element.fields.where((f) => f.type == type)); | 507 element.fields.where((f) => f.type == type)); |
| 502 | 508 |
| 503 // Create toString() method | 509 // Create toString() method |
| 504 var properties = new List<JS.Property>(); | 510 var properties = new List<JS.Property>(); |
| 505 for (var i = 0; i < fields.length; ++i) { | 511 for (var i = 0; i < fields.length; ++i) { |
| 506 properties.add(new JS.Property( | 512 properties.add(new JS.Property( |
| 507 js.number(i), js.string('${type.name}.${fields[i].name}'))); | 513 js.number(i), js.string('${type.name}.${fields[i].name}'))); |
| 508 } | 514 } |
| 509 var nameMap = new JS.ObjectInitializer(properties, multiline: true); | 515 var nameMap = new JS.ObjectInitializer(properties, multiline: true); |
| 510 var toStringF = new JS.Method(js.string('toString'), | 516 var toStringF = new JS.Method(js.string('toString'), |
| (...skipping 1214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1725 } | 1731 } |
| 1726 | 1732 |
| 1727 // Get the original declaring element. If we had a property accessor, this | 1733 // Get the original declaring element. If we had a property accessor, this |
| 1728 // indirects back to a (possibly synthetic) field. | 1734 // indirects back to a (possibly synthetic) field. |
| 1729 var element = accessor; | 1735 var element = accessor; |
| 1730 if (accessor is PropertyAccessorElement) element = accessor.variable; | 1736 if (accessor is PropertyAccessorElement) element = accessor.variable; |
| 1731 | 1737 |
| 1732 _loader.declareBeforeUse(element); | 1738 _loader.declareBeforeUse(element); |
| 1733 | 1739 |
| 1734 // type literal | 1740 // type literal |
| 1735 if (element is ClassElement || | 1741 if (element is TypeDefiningElement) { |
| 1736 element is DynamicElementImpl || | |
| 1737 element is FunctionTypeAliasElement) { | |
| 1738 return _emitTypeName( | 1742 return _emitTypeName( |
| 1739 fillDynamicTypeArgs((element as dynamic).type, types)); | 1743 fillDynamicTypeArgs((element as dynamic).type, types)); |
| 1740 } | 1744 } |
| 1741 | 1745 |
| 1742 // library member | 1746 // library member |
| 1743 if (element.enclosingElement is CompilationUnitElement) { | 1747 if (element.enclosingElement is CompilationUnitElement) { |
| 1744 return _emitTopLevelName(element); | 1748 return _emitTopLevelName(element); |
| 1745 } | 1749 } |
| 1746 | 1750 |
| 1747 var name = element.name; | 1751 var name = element.name; |
| (...skipping 2085 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3833 | 3837 |
| 3834 /// A special kind of element created by the compiler, signifying a temporary | 3838 /// A special kind of element created by the compiler, signifying a temporary |
| 3835 /// variable. These objects use instance equality, and should be shared | 3839 /// variable. These objects use instance equality, and should be shared |
| 3836 /// everywhere in the tree where they are treated as the same variable. | 3840 /// everywhere in the tree where they are treated as the same variable. |
| 3837 class TemporaryVariableElement extends LocalVariableElementImpl { | 3841 class TemporaryVariableElement extends LocalVariableElementImpl { |
| 3838 TemporaryVariableElement.forNode(Identifier name) : super.forNode(name); | 3842 TemporaryVariableElement.forNode(Identifier name) : super.forNode(name); |
| 3839 | 3843 |
| 3840 int get hashCode => identityHashCode(this); | 3844 int get hashCode => identityHashCode(this); |
| 3841 bool operator ==(Object other) => identical(this, other); | 3845 bool operator ==(Object other) => identical(this, other); |
| 3842 } | 3846 } |
| OLD | NEW |