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

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

Issue 2697523002: Add accessor for getting target-specific constructor. (Closed)
Patch Set: Created 3 years, 10 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 | « no previous file | pkg/front_end/lib/src/fasta/kernel/body_builder.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 library fasta.library_builder; 5 library fasta.library_builder;
6 6
7 import '../combinator.dart' show 7 import '../combinator.dart' show
8 Combinator; 8 Combinator;
9 9
10 import '../errors.dart' show 10 import '../errors.dart' show
11 InputError; 11 InputError,
12 internalError;
12 13
13 import '../export.dart' show 14 import '../export.dart' show
14 Export; 15 Export;
15 16
16 import '../loader.dart' show 17 import '../loader.dart' show
17 Loader; 18 Loader;
18 19
19 import 'builder.dart' show 20 import 'builder.dart' show
20 Builder, 21 Builder,
21 ClassBuilder, 22 ClassBuilder,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 65
65 bool addToExportScope(String name, Builder member); 66 bool addToExportScope(String name, Builder member);
66 67
67 void addToScope(String name, Builder member); 68 void addToScope(String name, Builder member);
68 69
69 InvalidTypeBuilder buildAmbiguousBuilder( 70 InvalidTypeBuilder buildAmbiguousBuilder(
70 String name, Builder builder, Builder other, int charOffset); 71 String name, Builder builder, Builder other, int charOffset);
71 72
72 int finishStaticInvocations() => 0; 73 int finishStaticInvocations() => 0;
73 74
75 /// Looks up [constructorName] in the class named [className]. It's an error
76 /// if no such class is exported by this library, or if the class doesn't
77 /// have a matching constructor (or factory).
78 ///
79 /// If [constructorName] is null or the empty string, it's assumed to be an
80 /// unnamed constructor.
81 Builder getConstructor(String className,
82 {String constructorName, bool isPrivate: false}) {
83 constructorName ??= "";
84 Builder cls = (isPrivate ? members : exports)[className];
85 if (cls is ClassBuilder) {
86 // TODO(ahe): This code is similar to code in `handleNewExpression` in
87 // `body_builder.dart`, try to share it.
88 Builder constructor = cls.findConstructorOrFactory(constructorName);
89 if (constructor == null) {
90 // Fall-through to internal error below.
91 } else if (constructor.isConstructor) {
92 if (!cls.isAbstract) {
93 return constructor;
94 }
95 } else if (constructor.isFactory) {
96 return constructor;
97 }
98 }
99 throw internalError("Internal error: No constructor named"
100 " '$className::$constructorName' in '$uri'.");
101 }
102
74 int finishTypeVariables(ClassBuilder object) => 0; 103 int finishTypeVariables(ClassBuilder object) => 0;
75 } 104 }
OLDNEW
« no previous file with comments | « no previous file | pkg/front_end/lib/src/fasta/kernel/body_builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698