Chromium Code Reviews| Index: pkg/compiler/lib/src/kernel/native_basic_data.dart |
| diff --git a/pkg/compiler/lib/src/kernel/native_basic_data.dart b/pkg/compiler/lib/src/kernel/native_basic_data.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..4c350a97b84c9baa7fa790bcc4f6211282e60aed |
| --- /dev/null |
| +++ b/pkg/compiler/lib/src/kernel/native_basic_data.dart |
| @@ -0,0 +1,39 @@ |
| +// Copyright (c) 2017, 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. |
| + |
| +part of dart2js.kernel.world_builder; |
| + |
| +/// Computes that NativeBasicData for the libraries in [worldBuilder]. |
| +// TODO(johnnniwinther): Move this to the AnnotationProcessor when it has been |
| +// committed. |
| +NativeBasicData computeNativeBasicData(KernelWorldBuilder worldBuilder) { |
| + NativeBasicDataBuilderImpl builder = new NativeBasicDataBuilderImpl(); |
| + ElementEnvironment elementEnvironment = worldBuilder.elementEnvironment; |
| + for (LibraryEntity library in elementEnvironment.libraries) { |
| + /// TODO(johnniwinther): Reuse `JavaScriptBackend.canLibraryUseNative` |
| + /// instead. |
| + if (library.canonicalUri.scheme == 'dart') { |
| + elementEnvironment.forEachClass(library, (ClassEntity cls) { |
| + String annotationName; |
| + for (ConstantExpression annotation |
| + in worldBuilder._getClassMetadata(cls)) { |
|
Siggi Cherem (dart-lang)
2017/04/19 16:05:22
I might be missing sometheing, but isn't this a ty
Johnni Winther
2017/04/20 08:05:25
_getClassMetadata expects a KClass but uses _class
|
| + ConstantValue value = |
| + worldBuilder.constantEnvironment.getConstantValue(annotation); |
|
Siggi Cherem (dart-lang)
2017/04/19 16:05:22
ah - this might answer part of my question from my
Johnni Winther
2017/04/20 08:05:25
We need the KernelWorldBuilder from the get-go. Th
|
| + String name = readAnnotationName( |
| + cls, value, worldBuilder.commonElements.nativeAnnotationClass); |
| + if (annotationName == null) { |
| + annotationName = name; |
| + } else if (name != null) { |
| + throw new SpannableAssertionFailure( |
| + cls, 'Too many name annotations.'); |
| + } |
| + } |
| + if (annotationName != null) { |
| + builder.setNativeClassTagInfo(cls, annotationName); |
| + } |
| + }); |
| + } |
| + } |
| + return builder.close(worldBuilder.elementEnvironment); |
|
Siggi Cherem (dart-lang)
2017/04/19 16:05:22
use directly the local elementEnvironment
Johnni Winther
2017/04/20 08:05:25
Done.
|
| +} |