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

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

Issue 2060183002: Serialize metadata (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comment. Created 4 years, 6 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) 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 /// Analysis to determine how to generate code for typed JavaScript interop. 5 /// Analysis to determine how to generate code for typed JavaScript interop.
6 library compiler.src.js_backend.js_interop_analysis; 6 library compiler.src.js_backend.js_interop_analysis;
7 7
8 import '../common.dart';
8 import '../constants/values.dart' 9 import '../constants/values.dart'
9 show ConstantValue, ConstructedConstantValue, StringConstantValue; 10 show ConstantValue, ConstructedConstantValue, StringConstantValue;
10 import '../diagnostics/messages.dart' show MessageKind; 11 import '../diagnostics/messages.dart' show MessageKind;
11 import '../elements/elements.dart' 12 import '../elements/elements.dart'
12 show 13 show
13 ClassElement, 14 ClassElement,
14 Element, 15 Element,
15 FieldElement, 16 FieldElement,
16 FunctionElement, 17 FunctionElement,
17 LibraryElement, 18 LibraryElement,
(...skipping 29 matching lines...) Expand all
47 .forEach(processJsInteropAnnotationsInLibrary); 48 .forEach(processJsInteropAnnotationsInLibrary);
48 } 49 }
49 } 50 }
50 51
51 void onCodegenStart() { 52 void onCodegenStart() {
52 _inCodegen = true; 53 _inCodegen = true;
53 } 54 }
54 55
55 void processJsInteropAnnotation(Element e) { 56 void processJsInteropAnnotation(Element e) {
56 for (MetadataAnnotation annotation in e.implementation.metadata) { 57 for (MetadataAnnotation annotation in e.implementation.metadata) {
58 // TODO(johnniwinther): Avoid processing unresolved elements.
59 if (annotation.constant == null) continue;
57 ConstantValue constant = 60 ConstantValue constant =
58 backend.compiler.constants.getConstantValue(annotation.constant); 61 backend.compiler.constants.getConstantValue(annotation.constant);
59 if (constant == null || constant is! ConstructedConstantValue) continue; 62 if (constant == null || constant is! ConstructedConstantValue) continue;
60 ConstructedConstantValue constructedConstant = constant; 63 ConstructedConstantValue constructedConstant = constant;
61 if (constructedConstant.type.element == helpers.jsAnnotationClass) { 64 if (constructedConstant.type.element == helpers.jsAnnotationClass) {
62 ConstantValue value = constructedConstant.fields[nameField]; 65 ConstantValue value = constructedConstant.fields[nameField];
63 if (value.isString) { 66 if (value.isString) {
64 StringConstantValue stringValue = value; 67 StringConstantValue stringValue = value;
65 backend.nativeData 68 backend.nativeData
66 .setJsInteropName(e, stringValue.primitiveValue.slowToString()); 69 .setJsInteropName(e, stringValue.primitiveValue.slowToString());
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 var name = backend.namer.invocationName(selector); 179 var name = backend.namer.invocationName(selector);
177 statements.add(js.statement( 180 statements.add(js.statement(
178 'Function.prototype.# = function(#) { return this(#) }', 181 'Function.prototype.# = function(#) { return this(#) }',
179 [name, parameters, parameters])); 182 [name, parameters, parameters]));
180 } 183 }
181 }); 184 });
182 }); 185 });
183 return new jsAst.Block(statements); 186 return new jsAst.Block(statements);
184 } 187 }
185 } 188 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_backend/constant_handler_javascript.dart ('k') | pkg/compiler/lib/src/js_backend/namer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698