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

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

Issue 2260353002: Remove use of JS templates in reified type information (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 4 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 '../common.dart'; 5 import '../common.dart';
6 import '../compiler.dart' show Compiler; 6 import '../compiler.dart' show Compiler;
7 import '../constants/values.dart'; 7 import '../constants/values.dart';
8 import '../dart_types.dart'; 8 import '../dart_types.dart';
9 import '../elements/elements.dart'; 9 import '../elements/elements.dart';
10 import '../io/code_output.dart'; 10 import '../io/code_output.dart';
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 313
314 String stripComments(String rawJavaScript) { 314 String stripComments(String rawJavaScript) {
315 return rawJavaScript.replaceAll(COMMENT_RE, ''); 315 return rawJavaScript.replaceAll(COMMENT_RE, '');
316 } 316 }
317 317
318 jsAst.Expression maybeAddTypeArguments( 318 jsAst.Expression maybeAddTypeArguments(
319 InterfaceType type, jsAst.Expression value) { 319 InterfaceType type, jsAst.Expression value) {
320 if (type is InterfaceType && 320 if (type is InterfaceType &&
321 !type.treatAsRaw && 321 !type.treatAsRaw &&
322 backend.classNeedsRti(type.element)) { 322 backend.classNeedsRti(type.element)) {
323 InterfaceType interface = type;
324 RuntimeTypesEncoder rtiEncoder = backend.rtiEncoder;
325 Iterable<jsAst.Expression> arguments = interface.typeArguments.map(
326 (DartType type) =>
327 rtiEncoder.getTypeRepresentationWithPlaceholders(type, (_) {}));
328 jsAst.Expression argumentList =
329 new jsAst.ArrayInitializer(arguments.toList());
330 return new jsAst.Call( 323 return new jsAst.Call(
331 getHelperProperty(backend.helpers.setRuntimeTypeInfo), 324 getHelperProperty(backend.helpers.setRuntimeTypeInfo),
332 [value, argumentList]); 325 [value, _reifiedTypeArguments(type)]);
333 } 326 }
334 return value; 327 return value;
335 } 328 }
336 329
330 jsAst.Expression _reifiedTypeArguments(InterfaceType type) {
331 jsAst.Expression unexpected(TypeVariableType variable) {
332 reporter.internalError(
333 NO_LOCATION_SPANNABLE,
334 "Unexpected type variable '${variable.getStringAsDeclared(null)}'"
335 " in constant type '${type.getStringAsDeclared(null)}'");
336 return null;
337 }
338 List<jsAst.Expression> arguments = <jsAst.Expression>[];
339 RuntimeTypesEncoder rtiEncoder = backend.rtiEncoder;
340 for (DartType argument in type.typeArguments) {
341 arguments.add(rtiEncoder.getTypeRepresentation(argument, unexpected));
342 }
343 return new jsAst.ArrayInitializer(arguments);
344 }
345
337 @override 346 @override
338 jsAst.Expression visitDeferred(DeferredConstantValue constant, [_]) { 347 jsAst.Expression visitDeferred(DeferredConstantValue constant, [_]) {
339 return constantReferenceGenerator(constant.referenced); 348 return constantReferenceGenerator(constant.referenced);
340 } 349 }
341 } 350 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_backend/runtime_types.dart » ('j') | pkg/compiler/lib/src/js_backend/runtime_types.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698