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

Side by Side Diff: pkg/compiler/lib/src/kernel/native_basic_data.dart

Issue 2824423002: Compute NativeBasicData for KernelWorldBuilder (Closed)
Patch Set: Put computeNativeBasicData into KernelAnnotationProcessor. Created 3 years, 8 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
(Empty)
1 // Copyright (c) 2017, 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 part of dart2js.kernel.world_builder;
6
7 /// Computes that NativeBasicData for the libraries in [worldBuilder].
8 // TODO(johnnniwinther): Move this to the AnnotationProcessor when it has been
Siggi Cherem (dart-lang) 2017/04/21 16:29:39 update TODO? I'm guessing this function will entir
Johnni Winther 2017/04/24 06:50:06 Done.
9 // committed.
10 NativeBasicData computeNativeBasicData(KernelWorldBuilder worldBuilder) {
11 NativeBasicDataBuilderImpl builder = new NativeBasicDataBuilderImpl();
12 ElementEnvironment elementEnvironment = worldBuilder.elementEnvironment;
13 for (LibraryEntity library in elementEnvironment.libraries) {
14 /// TODO(johnniwinther): Reuse `JavaScriptBackend.canLibraryUseNative`
15 /// instead.
16 if (library.canonicalUri.scheme == 'dart') {
17 new KernelAnnotationProcessor(worldBuilder)
18 .extractNativeAnnotations(library, builder);
19 }
20 }
21 return builder.close(elementEnvironment);
22 }
23
24 class KernelAnnotationProcessor implements AnnotationProcessor {
25 final KernelWorldBuilder worldBuilder;
26
27 KernelAnnotationProcessor(this.worldBuilder);
28
29 void extractNativeAnnotations(
30 LibraryEntity library, NativeBasicDataBuilder nativeBasicDataBuilder) {
31 ElementEnvironment elementEnvironment = worldBuilder.elementEnvironment;
32 CommonElements commonElements = worldBuilder.commonElements;
33
34 elementEnvironment.forEachClass(library, (ClassEntity cls) {
35 String annotationName;
36 for (ConstantExpression annotation
37 in worldBuilder._getClassMetadata(cls)) {
Siggi Cherem (dart-lang) 2017/04/21 16:29:39 add TODO: - make getClassMetadata public (with ou
Johnni Winther 2017/04/24 06:50:06 Done.
38 ConstantValue value =
39 worldBuilder.constantEnvironment.getConstantValue(annotation);
40 String name = readAnnotationName(
41 cls, value, commonElements.nativeAnnotationClass);
42 if (annotationName == null) {
43 annotationName = name;
44 } else if (name != null) {
45 throw new SpannableAssertionFailure(
46 cls, 'Too many name annotations.');
47 }
48 }
49 if (annotationName != null) {
50 nativeBasicDataBuilder.setNativeClassTagInfo(cls, annotationName);
51 }
52 });
53 }
54
55 void extractJsInteropAnnotations(
56 LibraryEntity library, NativeBasicDataBuilder nativeBasicDataBuilder) {
57 throw new UnimplementedError(
58 'KernelAnnotationProcessor.extractJsInteropAnnotations');
59 }
60 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/kernel/element_adapter.dart ('k') | pkg/compiler/lib/src/kernel/world_builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698