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

Side by Side Diff: lib/src/codegen/js_interop.dart

Issue 1680263002: Support for dart:typed_data (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Address comments, rebase Created 4 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 | « lib/src/codegen/js_codegen.dart ('k') | lib/src/codegen/module_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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 import 'package:analyzer/src/generated/ast.dart'; 5 import 'package:analyzer/src/generated/ast.dart';
6 import 'package:analyzer/src/generated/element.dart'; 6 import 'package:analyzer/src/generated/element.dart';
7 import 'package:analyzer/src/generated/constant.dart'; 7 import 'package:analyzer/src/generated/constant.dart';
8 8
9 bool _isJsLibType(String expectedName, Element e) => 9 bool _isJsLibType(String expectedName, Element e) =>
10 e?.name == expectedName && _isJsLib(e.library); 10 e?.name == expectedName && _isJsLib(e.library);
(...skipping 17 matching lines...) Expand all
28 28
29 /// Whether [i] is a `spread` invocation (to be used on function arguments 29 /// Whether [i] is a `spread` invocation (to be used on function arguments
30 /// to have them compiled as `...` spread args in ES6 outputs). 30 /// to have them compiled as `...` spread args in ES6 outputs).
31 bool isJsSpreadInvocation(MethodInvocation i) => 31 bool isJsSpreadInvocation(MethodInvocation i) =>
32 _isJsLibType('spread', i.methodName?.bestElement); 32 _isJsLibType('spread', i.methodName?.bestElement);
33 33
34 // TODO(jmesserly): Move JsPeerInterface to package:js (see issue #135). 34 // TODO(jmesserly): Move JsPeerInterface to package:js (see issue #135).
35 bool isJSAnnotation(DartObjectImpl value) => 35 bool isJSAnnotation(DartObjectImpl value) =>
36 _isJsLibType('JS', value.type.element); 36 _isJsLibType('JS', value.type.element);
37 37
38 bool _isBuiltinAnnotation(
39 DartObjectImpl value, String libraryName, String annotationName) {
40 var e = value?.type?.element;
41 if (e?.name != annotationName) return false;
42 var uri = e.source.uri;
43 var path = uri.pathSegments[0];
44 return uri.scheme == 'dart' && path == libraryName;
45 }
46
38 /// Whether [value] is a `@JSExportName` (internal annotation used in SDK 47 /// Whether [value] is a `@JSExportName` (internal annotation used in SDK
39 /// instead of `@JS` from `package:js`). 48 /// instead of `@JS` from `package:js`).
40 bool isJSExportNameAnnotation(DartObjectImpl value) { 49 bool isJSExportNameAnnotation(DartObjectImpl value) =>
41 var e = value?.type?.element; 50 _isBuiltinAnnotation(value, '_foreign_helper', 'JSExportName');
42 if (e?.name != 'JSExportName') return false; 51
43 var uri = e.source.uri; 52 bool isJsName(DartObjectImpl value) =>
44 return uri.scheme == 'dart' && uri.path == '_foreign_helper'; 53 _isBuiltinAnnotation(value, '_js_helper', 'JSName');
45 }
46 54
47 bool isJsPeerInterface(DartObjectImpl value) => 55 bool isJsPeerInterface(DartObjectImpl value) =>
48 value.type.name == 'JsPeerInterface'; 56 _isBuiltinAnnotation(value, '_js_helper', 'JsPeerInterface');
57
58 bool isNativeAnnotation(DartObjectImpl value) =>
59 _isBuiltinAnnotation(value, '_js_helper', 'Native');
OLDNEW
« no previous file with comments | « lib/src/codegen/js_codegen.dart ('k') | lib/src/codegen/module_builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698