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

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

Issue 2080183002: Revert "Enforce use of the forEachInstanceField ordering for constructed constants." (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: 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) 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 part of js_backend; 5 part of js_backend;
6 6
7 typedef jsAst.Expression _ConstantReferenceGenerator(ConstantValue constant); 7 typedef jsAst.Expression _ConstantReferenceGenerator(ConstantValue constant);
8 8
9 typedef jsAst.Expression _ConstantListGenerator(jsAst.Expression array); 9 typedef jsAst.Expression _ConstantListGenerator(jsAst.Expression array);
10 10
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 return constant.payload; 278 return constant.payload;
279 default: 279 default:
280 reporter.internalError(NO_LOCATION_SPANNABLE, 280 reporter.internalError(NO_LOCATION_SPANNABLE,
281 "Unexpected DummyConstantKind ${constant.kind}"); 281 "Unexpected DummyConstantKind ${constant.kind}");
282 return null; 282 return null;
283 } 283 }
284 } 284 }
285 285
286 @override 286 @override
287 jsAst.Expression visitConstructed(ConstructedConstantValue constant, [_]) { 287 jsAst.Expression visitConstructed(ConstructedConstantValue constant, [_]) {
288 ClassElement element = constant.type.element; 288 Element element = constant.type.element;
289 if (backend.isForeign(element) && element.name == 'JS_CONST') { 289 if (backend.isForeign(element) && element.name == 'JS_CONST') {
290 StringConstantValue str = constant.fields.values.single; 290 StringConstantValue str = constant.fields.values.single;
291 String value = str.primitiveValue.slowToString(); 291 String value = str.primitiveValue.slowToString();
292 return new jsAst.LiteralExpression(stripComments(value)); 292 return new jsAst.LiteralExpression(stripComments(value));
293 } 293 }
294 jsAst.Expression constructor = 294 jsAst.Expression constructor =
295 backend.emitter.constructorAccess(constant.type.element); 295 backend.emitter.constructorAccess(constant.type.element);
296 List<jsAst.Expression> fields = <jsAst.Expression>[]; 296 List<jsAst.Expression> fields = constant.fields.values
297 element.forEachInstanceField((_, FieldElement field) { 297 .map(constantReferenceGenerator)
298 fields.add(constantReferenceGenerator(constant.fields[field])); 298 .toList(growable: false);
299 });
300 jsAst.New instantiation = new jsAst.New(constructor, fields); 299 jsAst.New instantiation = new jsAst.New(constructor, fields);
301 return maybeAddTypeArguments(constant.type, instantiation); 300 return maybeAddTypeArguments(constant.type, instantiation);
302 } 301 }
303 302
304 String stripComments(String rawJavaScript) { 303 String stripComments(String rawJavaScript) {
305 return rawJavaScript.replaceAll(COMMENT_RE, ''); 304 return rawJavaScript.replaceAll(COMMENT_RE, '');
306 } 305 }
307 306
308 jsAst.Expression maybeAddTypeArguments( 307 jsAst.Expression maybeAddTypeArguments(
309 InterfaceType type, jsAst.Expression value) { 308 InterfaceType type, jsAst.Expression value) {
(...skipping 12 matching lines...) Expand all
322 [value, argumentList]); 321 [value, argumentList]);
323 } 322 }
324 return value; 323 return value;
325 } 324 }
326 325
327 @override 326 @override
328 jsAst.Expression visitDeferred(DeferredConstantValue constant, [_]) { 327 jsAst.Expression visitDeferred(DeferredConstantValue constant, [_]) {
329 return constantReferenceGenerator(constant.referenced); 328 return constantReferenceGenerator(constant.referenced);
330 } 329 }
331 } 330 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/constants/values.dart ('k') | pkg/compiler/lib/src/js_backend/constant_handler_javascript.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698