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

Side by Side Diff: pkg/compiler/lib/src/js_backend/native_data.dart

Issue 2680823002: Extract InterceptorData from JavaScriptBackend. (Closed)
Patch Set: Updated cf. comments 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
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 js_backend.native_data; 5 library js_backend.native_data;
6 6
7 import '../common.dart'; 7 import '../common.dart';
8 import '../elements/elements.dart' 8 import '../elements/elements.dart'
9 show ClassElement, Element, FieldElement, FunctionElement, MemberElement; 9 show ClassElement, Element, FieldElement, FunctionElement, MemberElement;
10 import '../elements/entities.dart'; 10 import '../elements/entities.dart';
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 /// JavaScriptInterop mechanism which is allowed for user libraries. 124 /// JavaScriptInterop mechanism which is allowed for user libraries.
125 bool isNative(Element element) { 125 bool isNative(Element element) {
126 if (isJsInterop(element)) return true; 126 if (isJsInterop(element)) return true;
127 if (element.isClass) { 127 if (element.isClass) {
128 return nativeClassTagInfo.containsKey(element.declaration); 128 return nativeClassTagInfo.containsKey(element.declaration);
129 } else { 129 } else {
130 return nativeMemberName.containsKey(element.declaration); 130 return nativeMemberName.containsKey(element.declaration);
131 } 131 }
132 } 132 }
133 133
134 /// Returns `true` if [element] or any of its superclasses is native.
135 bool isNativeOrExtendsNative(ClassElement element) {
136 if (element == null) return false;
137 if (isNative(element) || isJsInterop(element)) {
138 return true;
139 }
140 assert(element.isResolved);
141 return isNativeOrExtendsNative(element.superclass);
142 }
143
134 /// Sets the native [name] for the member [element]. This name is used for 144 /// Sets the native [name] for the member [element]. This name is used for
135 /// [element] in the generated JavaScript. 145 /// [element] in the generated JavaScript.
136 void setNativeMemberName(MemberElement element, String name) { 146 void setNativeMemberName(MemberElement element, String name) {
137 // TODO(johnniwinther): Avoid setting this more than once. The enqueuer 147 // TODO(johnniwinther): Avoid setting this more than once. The enqueuer
138 // might enqueue [element] several times (before processing it) and computes 148 // might enqueue [element] several times (before processing it) and computes
139 // name on each call to `internalAddToWorkList`. 149 // name on each call to `internalAddToWorkList`.
140 assert(invariant( 150 assert(invariant(
141 element, 151 element,
142 nativeMemberName[element.declaration] == null || 152 nativeMemberName[element.declaration] == null ||
143 nativeMemberName[element.declaration] == name, 153 nativeMemberName[element.declaration] == name,
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 } 236 }
227 237
228 /// Apply JS$ escaping scheme to convert possible escaped Dart names into 238 /// Apply JS$ escaping scheme to convert possible escaped Dart names into
229 /// JS names. 239 /// JS names.
230 String getUnescapedJSInteropName(String name) { 240 String getUnescapedJSInteropName(String name) {
231 return name.startsWith(_jsInteropEscapePrefix) 241 return name.startsWith(_jsInteropEscapePrefix)
232 ? name.substring(_jsInteropEscapePrefix.length) 242 ? name.substring(_jsInteropEscapePrefix.length)
233 : name; 243 : name;
234 } 244 }
235 } 245 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_backend/namer.dart ('k') | pkg/compiler/lib/src/js_emitter/class_stub_generator.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698