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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/fasta/lib/src/builder/procedure_builder.dart
diff --git a/pkg/fasta/lib/src/builder/procedure_builder.dart b/pkg/fasta/lib/src/builder/procedure_builder.dart
new file mode 100644
index 0000000000000000000000000000000000000000..fb4409225ba97b14cbc08f8a4b50f9729a8d1222
--- /dev/null
+++ b/pkg/fasta/lib/src/builder/procedure_builder.dart
@@ -0,0 +1,83 @@
+// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library fasta.procedure_builder;
+
+// Note: we're deliberately using AsyncMarker and ProcedureKind from kernel
+// outside the kernel-specific builders. This is simpler than creating
+// additional enums.
+import 'package:kernel/ast.dart' show
+ AsyncMarker,
+ ProcedureKind;
+
+import 'builder.dart' show
+ Builder,
+ FormalParameterBuilder,
+ MemberBuilder,
+ MetadataBuilder,
+ TypeBuilder,
+ TypeVariableBuilder;
+
+import 'scope.dart' show
+ Scope;
+
+abstract class ProcedureBuilder<T extends TypeBuilder> extends MemberBuilder {
+ final List<MetadataBuilder> metadata;
+
+ final int modifiers;
+
+ final T returnType;
+
+ final String name;
+
+ final List<TypeVariableBuilder> typeVariables;
+
+ final List<FormalParameterBuilder> formals;
+
+ ProcedureBuilder(this.metadata, this.modifiers, this.returnType, this.name,
+ this.typeVariables, this.formals);
+
+ AsyncMarker get asyncModifier;
+
+ ProcedureKind get kind;
+
+ bool get isConstructor => false;
+
+ bool get isRegularMethod => identical(ProcedureKind.Method, kind);
+
+ bool get isGetter => identical(ProcedureKind.Getter, kind);
+
+ bool get isSetter => identical(ProcedureKind.Setter, kind);
+
+ bool get isOperator => identical(ProcedureKind.Operator, kind);
+
+ bool get isFactory => identical(ProcedureKind.Factory, kind);
+
+ void set body(statement);
+
+ /// This is the formal parameter scope as specified in the Dart Programming
+ /// Language Specifiction, 4th ed, section 9.2.
+ Scope computeFormalParameterScope(Scope parent) {
+ if (formals == null) return parent;
+ Map<String, Builder> local = <String, Builder>{};
+ for (FormalParameterBuilder formal in formals) {
+ if (!formal.hasThis) {
+ local[formal.name] = formal;
+ }
+ }
+ return new Scope(local, parent, isModifiable: false);
+ }
+
+ /// This scope doesn't correspond to any scope specified in the Dart
+ /// Programming Language Specifiction, 4th ed. It's an unspecified extension
+ /// to support generic methods.
+ Scope computeTypeParameterScope(Scope parent) {
+ if (typeVariables == null) return parent;
+ Map<String, Builder> local = <String, Builder>{};
+ for (TypeVariableBuilder variable in typeVariables) {
+ local[variable.name] = variable;
+ }
+ return new Scope(local, parent, isModifiable: false);
+ }
+}
« 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