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

Side by Side Diff: pkg/kernel/lib/ast.dart

Issue 2893803003: Add metadata annotations to library definitions. (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « pkg/kernel/binary.md ('k') | pkg/kernel/lib/binary/ast_from_binary.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 /// ERROR HANDLING 6 /// ERROR HANDLING
7 /// ----------------------------------------------------------------------- 7 /// -----------------------------------------------------------------------
8 /// 8 ///
9 /// As a rule of thumb, errors that can be detected statically are handled by 9 /// As a rule of thumb, errors that can be detected statically are handled by
10 /// the frontend, typically by translating the erroneous code into a 'throw' or 10 /// the frontend, typically by translating the erroneous code into a 'throw' or
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 /// 257 ///
258 /// Classes of an external library are loaded at one of the [ClassLevel]s 258 /// Classes of an external library are loaded at one of the [ClassLevel]s
259 /// other than [ClassLevel.Body]. Members in an external library have no 259 /// other than [ClassLevel.Body]. Members in an external library have no
260 /// body, but have their typed interface present. 260 /// body, but have their typed interface present.
261 /// 261 ///
262 /// If the libary is non-external, then its classes are at [ClassLevel.Body] 262 /// If the libary is non-external, then its classes are at [ClassLevel.Body]
263 /// and all members are loaded. 263 /// and all members are loaded.
264 bool isExternal; 264 bool isExternal;
265 265
266 String name; 266 String name;
267 final List<Expression> annotations;
267 final List<LibraryDependency> dependencies; 268 final List<LibraryDependency> dependencies;
268 final List<Typedef> typedefs; 269 final List<Typedef> typedefs;
269 final List<Class> classes; 270 final List<Class> classes;
270 final List<Procedure> procedures; 271 final List<Procedure> procedures;
271 final List<Field> fields; 272 final List<Field> fields;
272 273
273 Library(this.importUri, 274 Library(this.importUri,
274 {this.name, 275 {this.name,
275 this.isExternal: false, 276 this.isExternal: false,
277 List<Expression> annotations,
276 List<LibraryDependency> dependencies, 278 List<LibraryDependency> dependencies,
277 List<Typedef> typedefs, 279 List<Typedef> typedefs,
278 List<Class> classes, 280 List<Class> classes,
279 List<Procedure> procedures, 281 List<Procedure> procedures,
280 List<Field> fields, 282 List<Field> fields,
281 this.fileUri, 283 this.fileUri,
282 Reference reference}) 284 Reference reference})
283 : this.dependencies = dependencies ?? <LibraryDependency>[], 285 : this.annotations = annotations ?? <Expression>[],
286 this.dependencies = dependencies ?? <LibraryDependency>[],
284 this.typedefs = typedefs ?? <Typedef>[], 287 this.typedefs = typedefs ?? <Typedef>[],
285 this.classes = classes ?? <Class>[], 288 this.classes = classes ?? <Class>[],
286 this.procedures = procedures ?? <Procedure>[], 289 this.procedures = procedures ?? <Procedure>[],
287 this.fields = fields ?? <Field>[], 290 this.fields = fields ?? <Field>[],
288 super(reference) { 291 super(reference) {
289 setParents(this.dependencies, this); 292 setParents(this.dependencies, this);
290 setParents(this.typedefs, this); 293 setParents(this.typedefs, this);
291 setParents(this.classes, this); 294 setParents(this.classes, this);
292 setParents(this.procedures, this); 295 setParents(this.procedures, this);
293 setParents(this.fields, this); 296 setParents(this.fields, this);
(...skipping 20 matching lines...) Expand all
314 void addClass(Class class_) { 317 void addClass(Class class_) {
315 class_.parent = this; 318 class_.parent = this;
316 classes.add(class_); 319 classes.add(class_);
317 } 320 }
318 321
319 void addTypedef(Typedef typedef_) { 322 void addTypedef(Typedef typedef_) {
320 typedef_.parent = this; 323 typedef_.parent = this;
321 typedefs.add(typedef_); 324 typedefs.add(typedef_);
322 } 325 }
323 326
327 void addAnnotation(Expression node) {
328 node.parent = this;
329 annotations.add(node);
330 }
331
324 void computeCanonicalNames() { 332 void computeCanonicalNames() {
325 assert(canonicalName != null); 333 assert(canonicalName != null);
326 for (var typedef_ in typedefs) { 334 for (var typedef_ in typedefs) {
327 canonicalName.getChildFromTypedef(typedef_).bindTo(typedef_.reference); 335 canonicalName.getChildFromTypedef(typedef_).bindTo(typedef_.reference);
328 } 336 }
329 for (var field in fields) { 337 for (var field in fields) {
330 canonicalName.getChildFromMember(field).bindTo(field.reference); 338 canonicalName.getChildFromMember(field).bindTo(field.reference);
331 } 339 }
332 for (var member in procedures) { 340 for (var member in procedures) {
333 canonicalName.getChildFromMember(member).bindTo(member.reference); 341 canonicalName.getChildFromMember(member).bindTo(member.reference);
(...skipping 4262 matching lines...) Expand 10 before | Expand all | Expand 10 after
4596 /// typedef has not been assigned a canonical name yet. 4604 /// typedef has not been assigned a canonical name yet.
4597 /// 4605 ///
4598 /// Returns `null` if the typedef is `null`. 4606 /// Returns `null` if the typedef is `null`.
4599 CanonicalName getCanonicalNameOfTypedef(Typedef typedef_) { 4607 CanonicalName getCanonicalNameOfTypedef(Typedef typedef_) {
4600 if (typedef_ == null) return null; 4608 if (typedef_ == null) return null;
4601 if (typedef_.canonicalName == null) { 4609 if (typedef_.canonicalName == null) {
4602 throw '$typedef_ has no canonical name'; 4610 throw '$typedef_ has no canonical name';
4603 } 4611 }
4604 return typedef_.canonicalName; 4612 return typedef_.canonicalName;
4605 } 4613 }
OLDNEW
« no previous file with comments | « pkg/kernel/binary.md ('k') | pkg/kernel/lib/binary/ast_from_binary.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698