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

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

Issue 2975203002: Revert "dart2ks-kernel: constant types and constant lists with type parameters" (Closed)
Patch Set: Created 3 years, 5 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 | « no previous file | pkg/compiler/lib/src/js_backend/namer.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) 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 '../common_elements.dart'; 6 import '../common_elements.dart';
7 import '../constants/values.dart'; 7 import '../constants/values.dart';
8 import '../elements/elements.dart'; 8 import '../elements/elements.dart';
9 import '../elements/types.dart' show DartType, InterfaceType, TypeVariableType; 9 import '../elements/types.dart' show TypeVariableType;
10 import '../elements/entities.dart'; 10 import '../elements/entities.dart';
11 import '../elements/resolution_types.dart'; 11 import '../elements/resolution_types.dart';
12 import '../io/code_output.dart'; 12 import '../io/code_output.dart';
13 import '../js/js.dart' as jsAst; 13 import '../js/js.dart' as jsAst;
14 import '../js/js.dart' show js; 14 import '../js/js.dart' show js;
15 import '../js_emitter/code_emitter_task.dart'; 15 import '../js_emitter/code_emitter_task.dart';
16 import '../options.dart'; 16 import '../options.dart';
17 import '../universe/world_builder.dart'; 17 import '../universe/world_builder.dart';
18 import 'constant_system_javascript.dart'; 18 import 'constant_system_javascript.dart';
19 import 'js_backend.dart'; 19 import 'js_backend.dart';
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 267
268 if (_rtiNeed.classNeedsRtiField(classElement)) { 268 if (_rtiNeed.classNeedsRtiField(classElement)) {
269 arguments.add(_reifiedTypeArguments(constant.type)); 269 arguments.add(_reifiedTypeArguments(constant.type));
270 } 270 }
271 271
272 jsAst.Expression constructor = _emitter.constructorAccess(classElement); 272 jsAst.Expression constructor = _emitter.constructorAccess(classElement);
273 jsAst.Expression value = new jsAst.New(constructor, arguments); 273 jsAst.Expression value = new jsAst.New(constructor, arguments);
274 return value; 274 return value;
275 } 275 }
276 276
277 jsAst.PropertyAccess getHelperProperty(FunctionEntity helper) { 277 jsAst.PropertyAccess getHelperProperty(MethodElement helper) {
278 return _emitter.staticFunctionAccess(helper); 278 return _emitter.staticFunctionAccess(helper);
279 } 279 }
280 280
281 @override 281 @override
282 jsAst.Expression visitType(TypeConstantValue constant, [_]) { 282 jsAst.Expression visitType(TypeConstantValue constant, [_]) {
283 DartType type = constant.representedType; 283 ResolutionDartType type = constant.representedType;
284 jsAst.Name typeName = _namer.runtimeTypeName(type.element); 284 jsAst.Name typeName = _namer.runtimeTypeName(type.element);
285 return new jsAst.Call(getHelperProperty(_commonElements.createRuntimeType), 285 return new jsAst.Call(getHelperProperty(_commonElements.createRuntimeType),
286 [js.quoteName(typeName)]); 286 [js.quoteName(typeName)]);
287 } 287 }
288 288
289 @override 289 @override
290 jsAst.Expression visitInterceptor(InterceptorConstantValue constant, [_]) { 290 jsAst.Expression visitInterceptor(InterceptorConstantValue constant, [_]) {
291 ClassEntity interceptorClass = constant.cls; 291 ClassEntity interceptorClass = constant.cls;
292 return _task.interceptorPrototypeAccess(interceptorClass); 292 return _task.interceptorPrototypeAccess(interceptorClass);
293 } 293 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 } 326 }
327 jsAst.New instantiation = new jsAst.New(constructor, fields); 327 jsAst.New instantiation = new jsAst.New(constructor, fields);
328 return instantiation; 328 return instantiation;
329 } 329 }
330 330
331 String stripComments(String rawJavaScript) { 331 String stripComments(String rawJavaScript) {
332 return rawJavaScript.replaceAll(COMMENT_RE, ''); 332 return rawJavaScript.replaceAll(COMMENT_RE, '');
333 } 333 }
334 334
335 jsAst.Expression maybeAddTypeArguments( 335 jsAst.Expression maybeAddTypeArguments(
336 InterfaceType type, jsAst.Expression value) { 336 ResolutionInterfaceType type, jsAst.Expression value) {
337 if (type is InterfaceType && 337 if (type is ResolutionInterfaceType &&
338 !type.treatAsRaw && 338 !type.treatAsRaw &&
339 _rtiNeed.classNeedsRti(type.element)) { 339 _rtiNeed.classNeedsRti(type.element)) {
340 return new jsAst.Call( 340 return new jsAst.Call(
341 getHelperProperty(_commonElements.setRuntimeTypeInfo), 341 getHelperProperty(_commonElements.setRuntimeTypeInfo),
342 [value, _reifiedTypeArguments(type)]); 342 [value, _reifiedTypeArguments(type)]);
343 } 343 }
344 return value; 344 return value;
345 } 345 }
346 346
347 jsAst.Expression _reifiedTypeArguments(InterfaceType type) { 347 jsAst.Expression _reifiedTypeArguments(ResolutionInterfaceType type) {
348 jsAst.Expression unexpected(TypeVariableType variable) { 348 jsAst.Expression unexpected(TypeVariableType _variable) {
349 ResolutionTypeVariableType variable = _variable;
349 throw new SpannableAssertionFailure( 350 throw new SpannableAssertionFailure(
350 NO_LOCATION_SPANNABLE, 351 NO_LOCATION_SPANNABLE,
351 "Unexpected type variable '${variable.getStringAsDeclared(null)}'" 352 "Unexpected type variable '${variable.getStringAsDeclared(null)}'"
352 " in constant type '${type.getStringAsDeclared(null)}'"); 353 " in constant type '${type.getStringAsDeclared(null)}'");
353 } 354 }
354 355
355 List<jsAst.Expression> arguments = <jsAst.Expression>[]; 356 List<jsAst.Expression> arguments = <jsAst.Expression>[];
356 for (DartType argument in type.typeArguments) { 357 for (ResolutionDartType argument in type.typeArguments) {
357 arguments.add( 358 arguments.add(
358 _rtiEncoder.getTypeRepresentation(_emitter, argument, unexpected)); 359 _rtiEncoder.getTypeRepresentation(_emitter, argument, unexpected));
359 } 360 }
360 return new jsAst.ArrayInitializer(arguments); 361 return new jsAst.ArrayInitializer(arguments);
361 } 362 }
362 363
363 @override 364 @override
364 jsAst.Expression visitDeferred(DeferredConstantValue constant, [_]) { 365 jsAst.Expression visitDeferred(DeferredConstantValue constant, [_]) {
365 return constantReferenceGenerator(constant.referenced); 366 return constantReferenceGenerator(constant.referenced);
366 } 367 }
367 } 368 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_backend/namer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698