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

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

Issue 2072223002: Enforce use of the forEachInstanceField ordering for constructed constants. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Remove tab 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 Element element = constant.type.element; 288 ClassElement 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 = constant.fields.values 296 List<jsAst.Expression> fields = <jsAst.Expression>[];
297 .map(constantReferenceGenerator) 297 element.forEachInstanceField((_, FieldElement field) {
298 .toList(growable: false); 298 fields.add(constantReferenceGenerator(constant.fields[field]));
299 }, includeSuperAndInjectedMembers: true);
299 jsAst.New instantiation = new jsAst.New(constructor, fields); 300 jsAst.New instantiation = new jsAst.New(constructor, fields);
300 return maybeAddTypeArguments(constant.type, instantiation); 301 return maybeAddTypeArguments(constant.type, instantiation);
301 } 302 }
302 303
303 String stripComments(String rawJavaScript) { 304 String stripComments(String rawJavaScript) {
304 return rawJavaScript.replaceAll(COMMENT_RE, ''); 305 return rawJavaScript.replaceAll(COMMENT_RE, '');
305 } 306 }
306 307
307 jsAst.Expression maybeAddTypeArguments( 308 jsAst.Expression maybeAddTypeArguments(
308 InterfaceType type, jsAst.Expression value) { 309 InterfaceType type, jsAst.Expression value) {
(...skipping 12 matching lines...) Expand all
321 [value, argumentList]); 322 [value, argumentList]);
322 } 323 }
323 return value; 324 return value;
324 } 325 }
325 326
326 @override 327 @override
327 jsAst.Expression visitDeferred(DeferredConstantValue constant, [_]) { 328 jsAst.Expression visitDeferred(DeferredConstantValue constant, [_]) {
328 return constantReferenceGenerator(constant.referenced); 329 return constantReferenceGenerator(constant.referenced);
329 } 330 }
330 } 331 }
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