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

Side by Side Diff: lib/src/compiler/code_generator.dart

Issue 1986693003: Provide option to suppress mirrors metadata (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Address comments Created 4 years, 7 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/runtime/dart_sdk.js ('k') | lib/src/compiler/compiler.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 'dart:collection' show HashMap, HashSet; 5 import 'dart:collection' show HashMap, HashSet;
6 import 'dart:math' show min, max; 6 import 'dart:math' show min, max;
7 7
8 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; 8 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator;
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/ast/token.dart' show Token, TokenType; 10 import 'package:analyzer/dart/ast/token.dart' show Token, TokenType;
(...skipping 1130 matching lines...) Expand 10 before | Expand all | Expand 10 after
1141 } 1141 }
1142 } 1142 }
1143 } 1143 }
1144 if (lazyStatics.isNotEmpty) { 1144 if (lazyStatics.isNotEmpty) {
1145 body.add(_emitLazyFields(classElem, lazyStatics)); 1145 body.add(_emitLazyFields(classElem, lazyStatics));
1146 } 1146 }
1147 } 1147 }
1148 1148
1149 void _emitClassMetadata(List<Annotation> metadata, JS.Expression className, 1149 void _emitClassMetadata(List<Annotation> metadata, JS.Expression className,
1150 List<JS.Statement> body) { 1150 List<JS.Statement> body) {
1151 // TODO(vsm): Make this optional per #268.
1152 // Metadata 1151 // Metadata
1153 if (metadata.isNotEmpty) { 1152 if (options.emitMetadata && metadata.isNotEmpty) {
1154 body.add(js.statement('#[dart.metadata] = () => #;', [ 1153 body.add(js.statement('#[dart.metadata] = () => #;', [
1155 className, 1154 className,
1156 new JS.ArrayInitializer( 1155 new JS.ArrayInitializer(
1157 new List<JS.Expression>.from(metadata.map(_instantiateAnnotation))) 1156 new List<JS.Expression>.from(metadata.map(_instantiateAnnotation)))
1158 ])); 1157 ]));
1159 } 1158 }
1160 } 1159 }
1161 1160
1162 /// If a concrete class implements one of our extensions, we might need to 1161 /// If a concrete class implements one of our extensions, we might need to
1163 /// add forwarders. 1162 /// add forwarders.
(...skipping 1051 matching lines...) Expand 10 before | Expand all | Expand 10 after
2215 : (p as DefaultFormalParameter).parameter.metadata; 2214 : (p as DefaultFormalParameter).parameter.metadata;
2216 2215
2217 JS.ArrayInitializer _emitTypeNames(List<DartType> types, 2216 JS.ArrayInitializer _emitTypeNames(List<DartType> types,
2218 [List<FormalParameter> parameters]) { 2217 [List<FormalParameter> parameters]) {
2219 var result = <JS.Expression>[]; 2218 var result = <JS.Expression>[];
2220 for (int i = 0; i < types.length; ++i) { 2219 for (int i = 0; i < types.length; ++i) {
2221 var metadata = 2220 var metadata =
2222 parameters != null ? _parameterMetadata(parameters[i]) : []; 2221 parameters != null ? _parameterMetadata(parameters[i]) : [];
2223 var typeName = _emitType(types[i]); 2222 var typeName = _emitType(types[i]);
2224 var value = typeName; 2223 var value = typeName;
2225 // TODO(vsm): Make this optional per #268. 2224 if (options.emitMetadata && metadata.isNotEmpty) {
2226 if (metadata.isNotEmpty) {
2227 metadata = metadata.map(_instantiateAnnotation).toList(); 2225 metadata = metadata.map(_instantiateAnnotation).toList();
2228 value = new JS.ArrayInitializer([typeName]..addAll(metadata)); 2226 value = new JS.ArrayInitializer([typeName]..addAll(metadata));
2229 } 2227 }
2230 result.add(value); 2228 result.add(value);
2231 } 2229 }
2232 return new JS.ArrayInitializer(result); 2230 return new JS.ArrayInitializer(result);
2233 } 2231 }
2234 2232
2235 JS.ObjectInitializer _emitTypeProperties(Map<String, DartType> types) { 2233 JS.ObjectInitializer _emitTypeProperties(Map<String, DartType> types) {
2236 var properties = <JS.Property>[]; 2234 var properties = <JS.Property>[];
(...skipping 2260 matching lines...) Expand 10 before | Expand all | Expand 10 after
4497 } 4495 }
4498 4496
4499 bool isLibraryPrefix(Expression node) => 4497 bool isLibraryPrefix(Expression node) =>
4500 node is SimpleIdentifier && node.staticElement is PrefixElement; 4498 node is SimpleIdentifier && node.staticElement is PrefixElement;
4501 4499
4502 LibraryElement _getLibrary(AnalysisContext c, String uri) => 4500 LibraryElement _getLibrary(AnalysisContext c, String uri) =>
4503 c.computeLibraryElement(c.sourceFactory.forUri(uri)); 4501 c.computeLibraryElement(c.sourceFactory.forUri(uri));
4504 4502
4505 bool _isDartRuntime(LibraryElement l) => 4503 bool _isDartRuntime(LibraryElement l) =>
4506 l.isInSdk && l.source.uri.toString() == 'dart:_runtime'; 4504 l.isInSdk && l.source.uri.toString() == 'dart:_runtime';
OLDNEW
« no previous file with comments | « lib/runtime/dart_sdk.js ('k') | lib/src/compiler/compiler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698