OLD | NEW |
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 library fasta.procedure_builder; | 5 library fasta.procedure_builder; |
6 | 6 |
7 // Note: we're deliberately using AsyncMarker and ProcedureKind from kernel | 7 // Note: we're deliberately using AsyncMarker and ProcedureKind from kernel |
8 // outside the kernel-specific builders. This is simpler than creating | 8 // outside the kernel-specific builders. This is simpler than creating |
9 // additional enums. | 9 // additional enums. |
10 import 'package:kernel/ast.dart' show | 10 import 'package:kernel/ast.dart' show AsyncMarker, ProcedureKind; |
11 AsyncMarker, | |
12 ProcedureKind; | |
13 | 11 |
14 import 'builder.dart' show | 12 import 'builder.dart' |
15 Builder, | 13 show |
16 FormalParameterBuilder, | 14 Builder, |
17 LibraryBuilder, | 15 FormalParameterBuilder, |
18 MemberBuilder, | 16 LibraryBuilder, |
19 MetadataBuilder, | 17 MemberBuilder, |
20 TypeBuilder, | 18 MetadataBuilder, |
21 TypeVariableBuilder; | 19 TypeBuilder, |
| 20 TypeVariableBuilder; |
22 | 21 |
23 import 'scope.dart' show | 22 import 'scope.dart' show Scope; |
24 Scope; | |
25 | 23 |
26 abstract class ProcedureBuilder<T extends TypeBuilder> extends MemberBuilder { | 24 abstract class ProcedureBuilder<T extends TypeBuilder> extends MemberBuilder { |
27 final List<MetadataBuilder> metadata; | 25 final List<MetadataBuilder> metadata; |
28 | 26 |
29 final int modifiers; | 27 final int modifiers; |
30 | 28 |
31 final T returnType; | 29 final T returnType; |
32 | 30 |
33 final String name; | 31 final String name; |
34 | 32 |
35 final List<TypeVariableBuilder> typeVariables; | 33 final List<TypeVariableBuilder> typeVariables; |
36 | 34 |
37 final List<FormalParameterBuilder> formals; | 35 final List<FormalParameterBuilder> formals; |
38 | 36 |
39 ProcedureBuilder(this.metadata, this.modifiers, this.returnType, this.name, | 37 ProcedureBuilder( |
40 this.typeVariables, this.formals, LibraryBuilder compilationUnit, | 38 this.metadata, |
| 39 this.modifiers, |
| 40 this.returnType, |
| 41 this.name, |
| 42 this.typeVariables, |
| 43 this.formals, |
| 44 LibraryBuilder compilationUnit, |
41 int charOffset) | 45 int charOffset) |
42 : super(compilationUnit, charOffset); | 46 : super(compilationUnit, charOffset); |
43 | 47 |
44 AsyncMarker get asyncModifier; | 48 AsyncMarker get asyncModifier; |
45 | 49 |
46 ProcedureKind get kind; | 50 ProcedureKind get kind; |
47 | 51 |
48 bool get isConstructor => false; | 52 bool get isConstructor => false; |
49 | 53 |
50 bool get isRegularMethod => identical(ProcedureKind.Method, kind); | 54 bool get isRegularMethod => identical(ProcedureKind.Method, kind); |
(...skipping 26 matching lines...) Expand all Loading... |
77 /// to support generic methods. | 81 /// to support generic methods. |
78 Scope computeTypeParameterScope(Scope parent) { | 82 Scope computeTypeParameterScope(Scope parent) { |
79 if (typeVariables == null) return parent; | 83 if (typeVariables == null) return parent; |
80 Map<String, Builder> local = <String, Builder>{}; | 84 Map<String, Builder> local = <String, Builder>{}; |
81 for (TypeVariableBuilder variable in typeVariables) { | 85 for (TypeVariableBuilder variable in typeVariables) { |
82 local[variable.name] = variable; | 86 local[variable.name] = variable; |
83 } | 87 } |
84 return new Scope(local, parent, isModifiable: false); | 88 return new Scope(local, parent, isModifiable: false); |
85 } | 89 } |
86 } | 90 } |
OLD | NEW |