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

Side by Side Diff: dart/sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart

Issue 15024008: Avoid syntax errors on oddly named fields. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add dart2js_native test Created 7 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | dart/tests/compiler/dart2js_native/oddly_named_fields_test.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 part of js_backend; 5 part of js_backend;
6 6
7 /** 7 /**
8 * A function element that represents a closure call. The signature is copied 8 * A function element that represents a closure call. The signature is copied
9 * from the given element. 9 * from the given element.
10 */ 10 */
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 305
306 js.if_(js('typeof fields == "function"'), [ 306 js.if_(js('typeof fields == "function"'), [
307 js('constructor = fields') 307 js('constructor = fields')
308 ], /* else */ [ 308 ], /* else */ [
309 js('var str = "function " + cls + "("'), 309 js('var str = "function " + cls + "("'),
310 js('var body = ""'), 310 js('var body = ""'),
311 311
312 js.for_('var i = 0', 'i < fields.length', 'i++', [ 312 js.for_('var i = 0', 'i < fields.length', 'i++', [
313 js.if_('i != 0', js('str += ", "')), 313 js.if_('i != 0', js('str += ", "')),
314 314
315 js('var field = fields[i]'), 315 js('var field = generateAccessor(fields[i], prototype)'),
316 js('field = generateAccessor(field, prototype)'), 316 js('var parameter = "parameter_" + field'),
317 js('str += field'), 317 js('str += parameter'),
318 js('body += ("this." + field + " = " + field + ";\\n")') 318 js('body += ("this." + field + " = " + parameter + ";\\n")')
319 ]), 319 ]),
320 320
321 js('str += (") {" + body + "}\\nreturn " + cls)'), 321 js('str += (") {" + body + "}\\nreturn " + cls)'),
322 322
323 js('constructor = new Function(str)()') 323 js('constructor = new Function(str)()')
324 ]), 324 ]),
325 325
326 js('constructor.prototype = prototype'), 326 js('constructor.prototype = prototype'),
327 js(r'constructor.builtin$cls = name'), 327 js(r'constructor.builtin$cls = name'),
328 328
(...skipping 2816 matching lines...) Expand 10 before | Expand all | Expand 10 after
3145 """; 3145 """;
3146 const String HOOKS_API_USAGE = """ 3146 const String HOOKS_API_USAGE = """
3147 // The code supports the following hooks: 3147 // The code supports the following hooks:
3148 // dartPrint(message) - if this function is defined it is called 3148 // dartPrint(message) - if this function is defined it is called
3149 // instead of the Dart [print] method. 3149 // instead of the Dart [print] method.
3150 // dartMainRunner(main) - if this function is defined, the Dart [main] 3150 // dartMainRunner(main) - if this function is defined, the Dart [main]
3151 // method will not be invoked directly. 3151 // method will not be invoked directly.
3152 // Instead, a closure that will invoke [main] is 3152 // Instead, a closure that will invoke [main] is
3153 // passed to [dartMainRunner]. 3153 // passed to [dartMainRunner].
3154 """; 3154 """;
OLDNEW
« no previous file with comments | « no previous file | dart/tests/compiler/dart2js_native/oddly_named_fields_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698