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

Side by Side Diff: dart/sdk/lib/_internal/dartdoc/lib/src/json_serializer.dart

Issue 23455028: Mirrors overhaul. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Merged with r29550. Created 7 years, 1 month 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) 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 /** 5 /**
6 * Simple library to serialize acyclic Dart types to JSON. 6 * Simple library to serialize acyclic Dart types to JSON.
7 * This library is not intended for broad consumption and should be replaced 7 * This library is not intended for broad consumption and should be replaced
8 * with a more generic Dart serialization library when one is available. 8 * with a more generic Dart serialization library when one is available.
9 */ 9 */
10 library json_serializer; 10 library json_serializer;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 // immediately. 55 // immediately.
56 for(String memberName in members) { 56 for(String memberName in members) {
57 var result = mirror.getField(new Symbol(memberName)); 57 var result = mirror.getField(new Symbol(memberName));
58 _serialize(memberName, result.reflectee, printer); 58 _serialize(memberName, result.reflectee, printer);
59 } 59 }
60 printer.endObject(); 60 printer.endObject();
61 } 61 }
62 62
63 void determineAllMembers(ClassMirror classMirror, 63 void determineAllMembers(ClassMirror classMirror,
64 List<String> members) { 64 List<String> members) {
65 for(Symbol getterName in classMirror.getters.keys) { 65 for (var mirror in classMirror.declarations.values) {
66 if (!members.contains(MirrorSystem.getName(getterName))) { 66 if (mirror is VariableMirror ||
67 members.add(MirrorSystem.getName(getterName)); 67 (mirror is MethodMirror && mirror.isGetter)) {
68 } 68 if (!members.contains(MirrorSystem.getName(mirror.simpleName))) {
69 } 69 members.add(MirrorSystem.getName(mirror.simpleName));
70 for(Symbol fieldName in classMirror.variables.keys) { 70 }
71 if (!members.contains(MirrorSystem.getName(fieldName))) {
72 members.add(MirrorSystem.getName(fieldName));
73 } 71 }
74 } 72 }
75 if (classMirror.superclass != null && 73 if (classMirror.superclass != null &&
76 74
77 // TODO(ahe): What is this test for? Consider removing it, 75 // TODO(ahe): What is this test for? Consider removing it,
78 // dart2js will issue an error if there is a cycle in superclass 76 // dart2js will issue an error if there is a cycle in superclass
79 // hierarchy. 77 // hierarchy.
80 classMirror.superclass.qualifiedName != classMirror.qualifiedName && 78 classMirror.superclass.qualifiedName != classMirror.qualifiedName &&
81 79
82 MirrorSystem.getName(classMirror.superclass.qualifiedName) != 80 MirrorSystem.getName(classMirror.superclass.qualifiedName) !=
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 needsEscape = true; 248 needsEscape = true;
251 codeUnits.add(JsonPrinter.BACKSLASH); 249 codeUnits.add(JsonPrinter.BACKSLASH);
252 codeUnits.add(codeUnit); 250 codeUnits.add(codeUnit);
253 } else { 251 } else {
254 codeUnits.add(codeUnit); 252 codeUnits.add(codeUnit);
255 } 253 }
256 } 254 }
257 sb.write(needsEscape ? new String.fromCharCodes(codeUnits) : s); 255 sb.write(needsEscape ? new String.fromCharCodes(codeUnits) : s);
258 } 256 }
259 } 257 }
OLDNEW
« no previous file with comments | « dart/sdk/lib/_internal/compiler/implementation/mirrors/mirrors.dart ('k') | dart/sdk/lib/_internal/lib/js_mirrors.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698