OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 dart_tree_printer; | 5 library dart_tree_printer; |
6 | 6 |
7 import '../constants/values.dart' as values; | 7 import '../constants/values.dart' as values; |
8 import '../dart_types.dart' as types; | 8 import '../dart_types.dart' as types; |
9 import '../dart2jslib.dart' as dart2js; | 9 import '../diagnostics/invariant.dart' show |
| 10 invariant; |
10 import '../elements/elements.dart' as elements; | 11 import '../elements/elements.dart' as elements; |
11 import '../resolution/resolution.dart' show | 12 import '../resolution/resolution.dart' show |
12 TreeElementMapping; | 13 TreeElementMapping; |
13 import '../tree/tree.dart' as tree; | 14 import '../tree/tree.dart' as tree; |
14 import '../scanner/scannerlib.dart'; | 15 import '../scanner/scannerlib.dart'; |
15 import '../util/util.dart'; | 16 import '../util/util.dart'; |
16 import 'backend_ast_nodes.dart'; | 17 import 'backend_ast_nodes.dart'; |
17 import 'backend_ast_emitter.dart' show TypeGenerator; | 18 import 'backend_ast_emitter.dart' show TypeGenerator; |
18 | 19 |
19 /// Translates the backend AST to Dart frontend AST. | 20 /// Translates the backend AST to Dart frontend AST. |
(...skipping 1124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1144 typeAnnotations, null, ','); | 1145 typeAnnotations, null, ','); |
1145 } | 1146 } |
1146 } | 1147 } |
1147 | 1148 |
1148 /// Creates a [tree.NamedMixinApplication] node for [cls]. | 1149 /// Creates a [tree.NamedMixinApplication] node for [cls]. |
1149 // TODO(johnniwinther): Unify creation of mixin lists between | 1150 // TODO(johnniwinther): Unify creation of mixin lists between |
1150 // [NamedMixinApplicationElement] and [ClassElement]. | 1151 // [NamedMixinApplicationElement] and [ClassElement]. |
1151 tree.NamedMixinApplication makeNamedMixinApplication( | 1152 tree.NamedMixinApplication makeNamedMixinApplication( |
1152 elements.MixinApplicationElement cls) { | 1153 elements.MixinApplicationElement cls) { |
1153 | 1154 |
1154 assert(dart2js.invariant(cls, !cls.isUnnamedMixinApplication, | 1155 assert(invariant(cls, !cls.isUnnamedMixinApplication, |
1155 message: "Cannot create ClassNode for unnamed mixin application " | 1156 message: "Cannot create ClassNode for unnamed mixin application " |
1156 "$cls.")); | 1157 "$cls.")); |
1157 tree.Modifiers modifiers = makeModifiers(isAbstract: cls.isAbstract); | 1158 tree.Modifiers modifiers = makeModifiers(isAbstract: cls.isAbstract); |
1158 tree.Identifier name = makeIdentifier(cls.name); | 1159 tree.Identifier name = makeIdentifier(cls.name); |
1159 tree.NodeList typeParameters = makeTypeParameters(cls.typeVariables); | 1160 tree.NodeList typeParameters = makeTypeParameters(cls.typeVariables); |
1160 | 1161 |
1161 Set<types.DartType> mixinTypes = new Set<types.DartType>(); | 1162 Set<types.DartType> mixinTypes = new Set<types.DartType>(); |
1162 Link<tree.Node> mixins = const Link<tree.Node>(); | 1163 Link<tree.Node> mixins = const Link<tree.Node>(); |
1163 | 1164 |
1164 void addMixin(types.DartType mixinType) { | 1165 void addMixin(types.DartType mixinType) { |
(...skipping 26 matching lines...) Expand all Loading... |
1191 tree.Enum makeEnum(elements.EnumClassElement cls) { | 1192 tree.Enum makeEnum(elements.EnumClassElement cls) { |
1192 return new tree.Enum( | 1193 return new tree.Enum( |
1193 enumToken, | 1194 enumToken, |
1194 makeIdentifier(cls.name), | 1195 makeIdentifier(cls.name), |
1195 makeList(',', cls.enumValues.map((e) => makeIdentifier(e.name)), | 1196 makeList(',', cls.enumValues.map((e) => makeIdentifier(e.name)), |
1196 open: openBrace, close: closeBrace)); | 1197 open: openBrace, close: closeBrace)); |
1197 } | 1198 } |
1198 | 1199 |
1199 /// Creates a [tree.ClassNode] node for [cls]. | 1200 /// Creates a [tree.ClassNode] node for [cls]. |
1200 tree.ClassNode makeClassNode(elements.ClassElement cls) { | 1201 tree.ClassNode makeClassNode(elements.ClassElement cls) { |
1201 assert(dart2js.invariant(cls, !cls.isUnnamedMixinApplication, | 1202 assert(invariant(cls, !cls.isUnnamedMixinApplication, |
1202 message: "Cannot create ClassNode for unnamed mixin application " | 1203 message: "Cannot create ClassNode for unnamed mixin application " |
1203 "$cls.")); | 1204 "$cls.")); |
1204 tree.Modifiers modifiers = makeModifiers(isAbstract: cls.isAbstract); | 1205 tree.Modifiers modifiers = makeModifiers(isAbstract: cls.isAbstract); |
1205 tree.Identifier name = makeIdentifier(cls.name); | 1206 tree.Identifier name = makeIdentifier(cls.name); |
1206 tree.NodeList typeParameters = makeTypeParameters(cls.typeVariables); | 1207 tree.NodeList typeParameters = makeTypeParameters(cls.typeVariables); |
1207 tree.Node supernode; | 1208 tree.Node supernode; |
1208 types.InterfaceType supertype = cls.supertype; | 1209 types.InterfaceType supertype = cls.supertype; |
1209 Set<types.DartType> mixinTypes = new Set<types.DartType>(); | 1210 Set<types.DartType> mixinTypes = new Set<types.DartType>(); |
1210 Link<tree.Node> mixins = const Link<tree.Node>(); | 1211 Link<tree.Node> mixins = const Link<tree.Node>(); |
1211 | 1212 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1333 printStringChunk(chunk.previous), | 1334 printStringChunk(chunk.previous), |
1334 node); | 1335 node); |
1335 } else { | 1336 } else { |
1336 return node; | 1337 return node; |
1337 } | 1338 } |
1338 } | 1339 } |
1339 return printStringChunk(output.chunk); | 1340 return printStringChunk(output.chunk); |
1340 } | 1341 } |
1341 | 1342 |
1342 } | 1343 } |
OLD | NEW |