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

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

Issue 2990783002: Serialize typedef parameters (including function typed ones) to Kernel and use it to resynthesize t… (Closed)
Patch Set: Test for named parameters. Created 3 years, 4 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
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 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 transformChildren(Transformer v) {} 486 transformChildren(Transformer v) {}
487 } 487 }
488 488
489 /// Declaration of a type alias. 489 /// Declaration of a type alias.
490 class Typedef extends NamedNode { 490 class Typedef extends NamedNode {
491 /// The uri of the source file that contains the declaration of this typedef. 491 /// The uri of the source file that contains the declaration of this typedef.
492 String fileUri; 492 String fileUri;
493 List<Expression> annotations = const <Expression>[]; 493 List<Expression> annotations = const <Expression>[];
494 String name; 494 String name;
495 final List<TypeParameter> typeParameters; 495 final List<TypeParameter> typeParameters;
496
497 @informative
498 int requiredParameterCount = 0;
499
500 @informative
501 List<VariableDeclaration> positionalParameters = <VariableDeclaration>[];
502
503 @informative
504 List<VariableDeclaration> namedParameters = <VariableDeclaration>[];
505
496 DartType type; 506 DartType type;
497 507
498 Typedef(this.name, this.type, 508 Typedef(this.name, this.type,
499 {Reference reference, this.fileUri, List<TypeParameter> typeParameters}) 509 {Reference reference, this.fileUri, List<TypeParameter> typeParameters})
500 : this.typeParameters = typeParameters ?? <TypeParameter>[], 510 : this.typeParameters = typeParameters ?? <TypeParameter>[],
501 super(reference) { 511 super(reference) {
502 setParents(this.typeParameters, this); 512 setParents(this.typeParameters, this);
503 } 513 }
504 514
505 Library get enclosingLibrary => parent; 515 Library get enclosingLibrary => parent;
506 516
507 accept(TreeVisitor v) { 517 accept(TreeVisitor v) {
508 return v.visitTypedef(this); 518 return v.visitTypedef(this);
509 } 519 }
510 520
521 void setParameters(
522 int requiredParameterCount,
523 List<VariableDeclaration> positionalParameters,
524 List<VariableDeclaration> namedParameters) {
525 this.requiredParameterCount = requiredParameterCount;
526 this.positionalParameters = positionalParameters;
527 this.namedParameters = namedParameters;
528 setParents(this.positionalParameters, this);
529 setParents(this.namedParameters, this);
530 }
531
511 transformChildren(Transformer v) { 532 transformChildren(Transformer v) {
512 transformList(annotations, v, this); 533 transformList(annotations, v, this);
513 transformList(typeParameters, v, this); 534 transformList(typeParameters, v, this);
535 transformList(positionalParameters, v, this);
536 transformList(namedParameters, v, this);
514 if (type != null) { 537 if (type != null) {
515 type = v.visitDartType(type); 538 type = v.visitDartType(type);
516 } 539 }
517 } 540 }
518 541
519 visitChildren(Visitor v) { 542 visitChildren(Visitor v) {
520 visitList(annotations, v); 543 visitList(annotations, v);
521 visitList(typeParameters, v); 544 visitList(typeParameters, v);
545 visitList(typeParameters, v);
546 visitList(positionalParameters, v);
547 visitList(namedParameters, v);
522 type?.accept(v); 548 type?.accept(v);
523 } 549 }
524 550
525 void addAnnotation(Expression node) { 551 void addAnnotation(Expression node) {
526 if (annotations.isEmpty) { 552 if (annotations.isEmpty) {
527 annotations = <Expression>[]; 553 annotations = <Expression>[];
528 } 554 }
529 annotations.add(node); 555 annotations.add(node);
530 node.parent = this; 556 node.parent = this;
531 } 557 }
(...skipping 4144 matching lines...) Expand 10 before | Expand all | Expand 10 after
4676 if (typedef_.canonicalName == null) { 4702 if (typedef_.canonicalName == null) {
4677 throw '$typedef_ has no canonical name'; 4703 throw '$typedef_ has no canonical name';
4678 } 4704 }
4679 return typedef_.canonicalName; 4705 return typedef_.canonicalName;
4680 } 4706 }
4681 4707
4682 /// Annotation describing information which is not part of Dart semantics; in 4708 /// Annotation describing information which is not part of Dart semantics; in
4683 /// other words, if this information (or any information it refers to) changes, 4709 /// other words, if this information (or any information it refers to) changes,
4684 /// static analysis and runtime behavior of the library are unaffected. 4710 /// static analysis and runtime behavior of the library are unaffected.
4685 const informative = null; 4711 const informative = null;
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/fasta/kernel/kernel_function_type_builder.dart ('k') | pkg/kernel/lib/binary/ast_from_binary.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698