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

Unified Diff: pkg/compiler/lib/src/common/backend_api.dart

Issue 1408043002: Move native and js interop properties from the element model to the JS backend (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments. Created 5 years, 2 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 | « no previous file | pkg/compiler/lib/src/common/codegen.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/common/backend_api.dart
diff --git a/pkg/compiler/lib/src/common/backend_api.dart b/pkg/compiler/lib/src/common/backend_api.dart
index 4638207bd74dd3a902467352bdffb6a646a8b58c..c091aefb3c6f7e69a56b44127e8ac3434a601657 100644
--- a/pkg/compiler/lib/src/common/backend_api.dart
+++ b/pkg/compiler/lib/src/common/backend_api.dart
@@ -43,7 +43,8 @@ import '../library_loader.dart' show
LibraryLoader,
LoadedLibraries;
import '../native/native.dart' as native show
- NativeEnqueuer;
+ NativeEnqueuer,
+ maybeEnableNative;
import '../patch_parser.dart' show
checkNativeAnnotation, checkJsInteropAnnotation;
import '../resolution/tree_elements.dart' show
@@ -259,6 +260,20 @@ abstract class Backend {
/// backend has specialized handling for the element.
bool isForeign(Element element) => false;
+ /// Returns `true` if [element] is a native element, that is, that the
+ /// corresponding entity already exists in the target language.
+ bool isNative(Element element) => false;
+
+ /// Returns `true` if [element] is implemented via typed JavaScript interop.
+ // TODO(johnniwinther): Move this to [JavaScriptBackend].
+ bool isJsInterop(Element element) => false;
+
+ /// Returns `true` if the `native` pseudo keyword is supported for [library].
+ bool canLibraryUseNative(LibraryElement library) {
+ // TODO(johnniwinther): Move this to [JavaScriptBackend].
+ return native.maybeEnableNative(compiler, library);
+ }
+
/// Processes [element] for resolution and returns the [FunctionElement] that
/// defines the implementation of [element].
FunctionElement resolveExternalFunction(FunctionElement element) => element;
@@ -286,7 +301,8 @@ abstract class Backend {
/// This method is called immediately after the [library] and its parts have
/// been scanned.
Future onLibraryScanned(LibraryElement library, LibraryLoader loader) {
- if (library.canUseNative) {
+ // TODO(johnniwinther): Move this to [JavaScriptBackend].
+ if (canLibraryUseNative(library)) {
library.forEachLocalMember((Element element) {
if (element.isClass) {
checkNativeAnnotation(compiler, element);
@@ -296,7 +312,7 @@ abstract class Backend {
checkJsInteropAnnotation(compiler, library);
library.forEachLocalMember((Element element) {
checkJsInteropAnnotation(compiler, element);
- if (element.isClass && element.isJsInterop) {
+ if (element.isClass && isJsInterop(element)) {
ClassElement classElement = element;
classElement.forEachMember((_, memberElement) {
checkJsInteropAnnotation(compiler, memberElement);
« no previous file with comments | « no previous file | pkg/compiler/lib/src/common/codegen.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698