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

Side by Side Diff: pkg/fasta/lib/src/builder/procedure_builder.dart

Issue 2629063005: Fasta builders. (Closed)
Patch Set: Address review comments. Created 3 years, 11 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/fasta/lib/src/builder/prefix_builder.dart ('k') | pkg/fasta/lib/src/builder/scope.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library fasta.procedure_builder;
6
7 // Note: we're deliberately using AsyncMarker and ProcedureKind from kernel
8 // outside the kernel-specific builders. This is simpler than creating
9 // additional enums.
10 import 'package:kernel/ast.dart' show
11 AsyncMarker,
12 ProcedureKind;
13
14 import 'builder.dart' show
15 Builder,
16 FormalParameterBuilder,
17 MemberBuilder,
18 MetadataBuilder,
19 TypeBuilder,
20 TypeVariableBuilder;
21
22 import 'scope.dart' show
23 Scope;
24
25 abstract class ProcedureBuilder<T extends TypeBuilder> extends MemberBuilder {
26 final List<MetadataBuilder> metadata;
27
28 final int modifiers;
29
30 final T returnType;
31
32 final String name;
33
34 final List<TypeVariableBuilder> typeVariables;
35
36 final List<FormalParameterBuilder> formals;
37
38 ProcedureBuilder(this.metadata, this.modifiers, this.returnType, this.name,
39 this.typeVariables, this.formals);
40
41 AsyncMarker get asyncModifier;
42
43 ProcedureKind get kind;
44
45 bool get isConstructor => false;
46
47 bool get isRegularMethod => identical(ProcedureKind.Method, kind);
48
49 bool get isGetter => identical(ProcedureKind.Getter, kind);
50
51 bool get isSetter => identical(ProcedureKind.Setter, kind);
52
53 bool get isOperator => identical(ProcedureKind.Operator, kind);
54
55 bool get isFactory => identical(ProcedureKind.Factory, kind);
56
57 void set body(statement);
58
59 /// This is the formal parameter scope as specified in the Dart Programming
60 /// Language Specifiction, 4th ed, section 9.2.
61 Scope computeFormalParameterScope(Scope parent) {
62 if (formals == null) return parent;
63 Map<String, Builder> local = <String, Builder>{};
64 for (FormalParameterBuilder formal in formals) {
65 if (!formal.hasThis) {
66 local[formal.name] = formal;
67 }
68 }
69 return new Scope(local, parent, isModifiable: false);
70 }
71
72 /// This scope doesn't correspond to any scope specified in the Dart
73 /// Programming Language Specifiction, 4th ed. It's an unspecified extension
74 /// to support generic methods.
75 Scope computeTypeParameterScope(Scope parent) {
76 if (typeVariables == null) return parent;
77 Map<String, Builder> local = <String, Builder>{};
78 for (TypeVariableBuilder variable in typeVariables) {
79 local[variable.name] = variable;
80 }
81 return new Scope(local, parent, isModifiable: false);
82 }
83 }
OLDNEW
« no previous file with comments | « pkg/fasta/lib/src/builder/prefix_builder.dart ('k') | pkg/fasta/lib/src/builder/scope.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698