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

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

Issue 2319863002: Revert "dart2js: Pass type information to constructor rather than add later." (Closed)
Patch Set: Created 4 years, 3 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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 if ((className == JavaScriptMapConstant.DART_STRING_CLASS && 244 if ((className == JavaScriptMapConstant.DART_STRING_CLASS &&
245 emittedArgumentCount != 3) || 245 emittedArgumentCount != 3) ||
246 (className == JavaScriptMapConstant.DART_PROTO_CLASS && 246 (className == JavaScriptMapConstant.DART_PROTO_CLASS &&
247 emittedArgumentCount != 4) || 247 emittedArgumentCount != 4) ||
248 (className == JavaScriptMapConstant.DART_GENERAL_CLASS && 248 (className == JavaScriptMapConstant.DART_GENERAL_CLASS &&
249 emittedArgumentCount != 1)) { 249 emittedArgumentCount != 1)) {
250 reporter.internalError(classElement, 250 reporter.internalError(classElement,
251 "Compiler and ${className} disagree on number of fields."); 251 "Compiler and ${className} disagree on number of fields.");
252 } 252 }
253 253
254 if (backend.classNeedsRtiField(classElement)) {
255 arguments.add(_reifiedTypeArguments(constant.type));
256 }
257
258 jsAst.Expression constructor = 254 jsAst.Expression constructor =
259 backend.emitter.constructorAccess(classElement); 255 backend.emitter.constructorAccess(classElement);
260 jsAst.Expression value = new jsAst.New(constructor, arguments); 256 jsAst.Expression value = new jsAst.New(constructor, arguments);
261 return value; 257 return maybeAddTypeArguments(constant.type, value);
262 } 258 }
263 259
264 JavaScriptBackend get backend => compiler.backend; 260 JavaScriptBackend get backend => compiler.backend;
265 261
266 jsAst.PropertyAccess getHelperProperty(Element helper) { 262 jsAst.PropertyAccess getHelperProperty(Element helper) {
267 return backend.emitter.staticFunctionAccess(helper); 263 return backend.emitter.staticFunctionAccess(helper);
268 } 264 }
269 265
270 @override 266 @override
271 jsAst.Expression visitType(TypeConstantValue constant, [_]) { 267 jsAst.Expression visitType(TypeConstantValue constant, [_]) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 StringConstantValue str = constant.fields.values.single; 300 StringConstantValue str = constant.fields.values.single;
305 String value = str.primitiveValue.slowToString(); 301 String value = str.primitiveValue.slowToString();
306 return new jsAst.LiteralExpression(stripComments(value)); 302 return new jsAst.LiteralExpression(stripComments(value));
307 } 303 }
308 jsAst.Expression constructor = 304 jsAst.Expression constructor =
309 backend.emitter.constructorAccess(constant.type.element); 305 backend.emitter.constructorAccess(constant.type.element);
310 List<jsAst.Expression> fields = <jsAst.Expression>[]; 306 List<jsAst.Expression> fields = <jsAst.Expression>[];
311 element.forEachInstanceField((_, FieldElement field) { 307 element.forEachInstanceField((_, FieldElement field) {
312 fields.add(constantReferenceGenerator(constant.fields[field])); 308 fields.add(constantReferenceGenerator(constant.fields[field]));
313 }, includeSuperAndInjectedMembers: true); 309 }, includeSuperAndInjectedMembers: true);
314 if (backend.classNeedsRtiField(constant.type.element)) {
315 fields.add(_reifiedTypeArguments(constant.type));
316 }
317 jsAst.New instantiation = new jsAst.New(constructor, fields); 310 jsAst.New instantiation = new jsAst.New(constructor, fields);
318 return maybeAddTypeArguments(constant.type, instantiation); 311 return maybeAddTypeArguments(constant.type, instantiation);
319 } 312 }
320 313
321 String stripComments(String rawJavaScript) { 314 String stripComments(String rawJavaScript) {
322 return rawJavaScript.replaceAll(COMMENT_RE, ''); 315 return rawJavaScript.replaceAll(COMMENT_RE, '');
323 } 316 }
324 317
325 jsAst.Expression maybeAddTypeArguments( 318 jsAst.Expression maybeAddTypeArguments(
326 InterfaceType type, jsAst.Expression value) { 319 InterfaceType type, jsAst.Expression value) {
(...skipping 22 matching lines...) Expand all
349 arguments.add(rtiEncoder.getTypeRepresentation(argument, unexpected)); 342 arguments.add(rtiEncoder.getTypeRepresentation(argument, unexpected));
350 } 343 }
351 return new jsAst.ArrayInitializer(arguments); 344 return new jsAst.ArrayInitializer(arguments);
352 } 345 }
353 346
354 @override 347 @override
355 jsAst.Expression visitDeferred(DeferredConstantValue constant, [_]) { 348 jsAst.Expression visitDeferred(DeferredConstantValue constant, [_]) {
356 return constantReferenceGenerator(constant.referenced); 349 return constantReferenceGenerator(constant.referenced);
357 } 350 }
358 } 351 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_backend/backend.dart ('k') | pkg/compiler/lib/src/js_emitter/class_stub_generator.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698