Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: pkg/compiler/lib/src/dart_backend/backend_ast_to_frontend_ast.dart

Issue 878843003: Support enums in dart2dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 '../dart2jslib.dart' as dart2js;
10 import '../elements/elements.dart' as elements; 10 import '../elements/elements.dart' as elements;
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 final Token catchToken = makeIdToken('catch'); 132 final Token catchToken = makeIdToken('catch');
133 final Token onToken = makeIdToken('on'); 133 final Token onToken = makeIdToken('on');
134 final Token finallyToken = makeIdToken('finally'); 134 final Token finallyToken = makeIdToken('finally');
135 final Token getToken = makeIdToken('get'); 135 final Token getToken = makeIdToken('get');
136 final Token setToken = makeIdToken('set'); 136 final Token setToken = makeIdToken('set');
137 final Token classToken = makeIdToken('class'); 137 final Token classToken = makeIdToken('class');
138 final Token extendsToken = makeIdToken('extends'); 138 final Token extendsToken = makeIdToken('extends');
139 final Token withToken = makeIdToken('with'); 139 final Token withToken = makeIdToken('with');
140 final Token implementsToken = makeIdToken('implements'); 140 final Token implementsToken = makeIdToken('implements');
141 final Token typedefToken = makeIdToken('typedef'); 141 final Token typedefToken = makeIdToken('typedef');
142 final Token enumToken = makeIdToken('enum');
142 143
143 static tree.Identifier makeIdentifier(String name) { 144 static tree.Identifier makeIdentifier(String name) {
144 return new tree.Identifier( 145 return new tree.Identifier(
145 new StringToken.fromString(IDENTIFIER_INFO, name, -1)); 146 new StringToken.fromString(IDENTIFIER_INFO, name, -1));
146 } 147 }
147 148
148 static tree.Operator makeOperator(String name) { 149 static tree.Operator makeOperator(String name) {
149 return new tree.Operator( 150 return new tree.Operator(
150 new StringToken.fromString(IDENTIFIER_INFO, name, -1)); 151 new StringToken.fromString(IDENTIFIER_INFO, name, -1));
151 } 152 }
(...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after
1053 if (exp.element == null) return makeEmptyModifiers(); 1054 if (exp.element == null) return makeEmptyModifiers();
1054 return makeModifiers(isExternal: exp.element.isExternal, 1055 return makeModifiers(isExternal: exp.element.isExternal,
1055 isStatic: exp.element.isStatic, 1056 isStatic: exp.element.isStatic,
1056 isFactory: exp.element.isFactoryConstructor, 1057 isFactory: exp.element.isFactoryConstructor,
1057 isConst: exp.element.isConst); 1058 isConst: exp.element.isConst);
1058 } 1059 }
1059 1060
1060 tree.Node makeNodeForClassElement(elements.ClassElement cls) { 1061 tree.Node makeNodeForClassElement(elements.ClassElement cls) {
1061 if (cls.isMixinApplication) { 1062 if (cls.isMixinApplication) {
1062 return makeNamedMixinApplication(cls); 1063 return makeNamedMixinApplication(cls);
1064 } else if (cls.isEnumClass) {
1065 return makeEnum(cls);
1063 } else { 1066 } else {
1064 return makeClassNode(cls); 1067 return makeClassNode(cls);
1065 } 1068 }
1066 } 1069 }
1067 1070
1068 tree.Typedef makeTypedef(elements.TypedefElement typdef) { 1071 tree.Typedef makeTypedef(elements.TypedefElement typdef) {
1069 types.FunctionType functionType = typdef.alias; 1072 types.FunctionType functionType = typdef.alias;
1070 final tree.TypeAnnotation returnType = 1073 final tree.TypeAnnotation returnType =
1071 makeType(TypeGenerator.createType(functionType.returnType)); 1074 makeType(TypeGenerator.createType(functionType.returnType));
1072 1075
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
1174 superclass, new tree.NodeList(null, mixins, null, ',')); 1177 superclass, new tree.NodeList(null, mixins, null, ','));
1175 1178
1176 tree.NodeList interfaces = makeInterfaces( 1179 tree.NodeList interfaces = makeInterfaces(
1177 cls.interfaces, mixinTypes, forNamedMixinApplication: true); 1180 cls.interfaces, mixinTypes, forNamedMixinApplication: true);
1178 1181
1179 return new tree.NamedMixinApplication( 1182 return new tree.NamedMixinApplication(
1180 name, typeParameters, modifiers, supernode, 1183 name, typeParameters, modifiers, supernode,
1181 interfaces, classToken, semicolon); 1184 interfaces, classToken, semicolon);
1182 } 1185 }
1183 1186
1187 tree.Enum makeEnum(elements.EnumClassElement cls) {
1188 return new tree.Enum(
1189 enumToken,
1190 makeIdentifier(cls.name),
1191 makeList(',', cls.enumValues.map((e) => makeIdentifier(e.name)),
1192 open: openBrace, close: closeBrace));
1193 }
1194
1184 /// Creates a [tree.ClassNode] node for [cls]. 1195 /// Creates a [tree.ClassNode] node for [cls].
1185 tree.ClassNode makeClassNode(elements.ClassElement cls) { 1196 tree.ClassNode makeClassNode(elements.ClassElement cls) {
1186 assert(dart2js.invariant(cls, !cls.isUnnamedMixinApplication, 1197 assert(dart2js.invariant(cls, !cls.isUnnamedMixinApplication,
1187 message: "Cannot create ClassNode for unnamed mixin application " 1198 message: "Cannot create ClassNode for unnamed mixin application "
1188 "$cls.")); 1199 "$cls."));
1189 tree.Modifiers modifiers = makeModifiers(isAbstract: cls.isAbstract); 1200 tree.Modifiers modifiers = makeModifiers(isAbstract: cls.isAbstract);
1190 tree.Identifier name = makeIdentifier(cls.name); 1201 tree.Identifier name = makeIdentifier(cls.name);
1191 tree.NodeList typeParameters = makeTypeParameters(cls.typeVariables); 1202 tree.NodeList typeParameters = makeTypeParameters(cls.typeVariables);
1192 tree.Node supernode; 1203 tree.Node supernode;
1193 types.InterfaceType supertype = cls.supertype; 1204 types.InterfaceType supertype = cls.supertype;
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1319 printStringChunk(chunk.previous), 1330 printStringChunk(chunk.previous),
1320 node); 1331 node);
1321 } else { 1332 } else {
1322 return node; 1333 return node;
1323 } 1334 }
1324 } 1335 }
1325 return printStringChunk(output.chunk); 1336 return printStringChunk(output.chunk);
1326 } 1337 }
1327 1338
1328 } 1339 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/dart_backend/backend.dart ('k') | pkg/compiler/lib/src/dart_backend/outputter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698