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

Side by Side Diff: lib/compiler/implementation/emitter.dart

Issue 10388069: Don't emit dangling comma in object literal. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix typo and more cosmetic changes. Created 8 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 | « frog/tests/leg/class_codegen2_test.dart ('k') | no next file » | 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 /** 5 /**
6 * A function element that represents a closure call. The signature is copied 6 * A function element that represents a closure call. The signature is copied
7 * from the given element. 7 * from the given element.
8 */ 8 */
9 class ClosureInvocationElement extends FunctionElement { 9 class ClosureInvocationElement extends FunctionElement {
10 ClosureInvocationElement(SourceString name, 10 ClosureInvocationElement(SourceString name,
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 // If a class is not instantiated then we add the field just so we can 459 // If a class is not instantiated then we add the field just so we can
460 // generate the field getter/setter dynamically. Since this is only 460 // generate the field getter/setter dynamically. Since this is only
461 // allowed on fields that are in [classElement] we don't need to visit 461 // allowed on fields that are in [classElement] we don't need to visit
462 // superclasses for non-instantiated classes. 462 // superclasses for non-instantiated classes.
463 classElement.forEachInstanceField(addField, 463 classElement.forEachInstanceField(addField,
464 includeBackendMembers: true, 464 includeBackendMembers: true,
465 includeSuperMembers: isInstantiated); 465 includeSuperMembers: isInstantiated);
466 } 466 }
467 467
468 void emitInstanceMembers(ClassElement classElement, StringBuffer buffer) { 468 void emitInstanceMembers(ClassElement classElement, StringBuffer buffer) {
469 bool isFirst = true;
469 void defineInstanceMember(String name, String value) { 470 void defineInstanceMember(String name, String value) {
470 buffer.add(' $name: $value,\n'); 471 if (!isFirst) buffer.add(',');
472 isFirst = false;
473 buffer.add('\n');
474 buffer.add(' $name: $value');
471 } 475 }
472 476
473 classElement.forEachMember(includeBackendMembers: true, 477 classElement.forEachMember(includeBackendMembers: true,
474 f: (ClassElement enclosing, Element member) { 478 f: (ClassElement enclosing, Element member) {
475 if (member.isInstanceMember()) { 479 if (member.isInstanceMember()) {
476 // All getters and setters for non-native classes are generated 480 // All getters and setters for non-native classes are generated
477 // dynamically. 481 // dynamically.
478 bool needGettersAndSetters = false; 482 bool needGettersAndSetters = false;
479 addInstanceMember(member, needGettersAndSetters, defineInstanceMember); 483 addInstanceMember(member, needGettersAndSetters, defineInstanceMember);
480 } 484 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 String className = namer.getName(classElement); 518 String className = namer.getName(classElement);
515 ClassElement superclass = classElement.superclass; 519 ClassElement superclass = classElement.superclass;
516 String superName = ""; 520 String superName = "";
517 if (superclass !== null) { 521 if (superclass !== null) {
518 superName = namer.getName(superclass); 522 superName = namer.getName(superclass);
519 } 523 }
520 String constructorName = namer.safeName(classElement.name.slowToString()); 524 String constructorName = namer.safeName(classElement.name.slowToString());
521 525
522 buffer.add('$defineClassName("$className", "$superName", ['); 526 buffer.add('$defineClassName("$className", "$superName", [');
523 emitClassFields(classElement, buffer); 527 emitClassFields(classElement, buffer);
524 buffer.add('], {\n'); 528 buffer.add('], {');
525 emitInstanceMembers(classElement, buffer); 529 emitInstanceMembers(classElement, buffer);
526 buffer.add('});\n\n'); 530 buffer.add('\n});\n\n');
527 } 531 }
528 532
529 void generateTypeTests(ClassElement cls, 533 void generateTypeTests(ClassElement cls,
530 void generateTypeTest(ClassElement element)) { 534 void generateTypeTest(ClassElement element)) {
531 if (compiler.universe.isChecks.contains(cls)) { 535 if (compiler.universe.isChecks.contains(cls)) {
532 generateTypeTest(cls); 536 generateTypeTest(cls);
533 } 537 }
534 generateInterfacesIsTests(cls, generateTypeTest, new Set<Element>()); 538 generateInterfacesIsTests(cls, generateTypeTest, new Set<Element>());
535 } 539 }
536 540
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
980 mainBuffer.add('function init() {\n'); 984 mainBuffer.add('function init() {\n');
981 mainBuffer.add(' $isolateProperties = {};\n'); 985 mainBuffer.add(' $isolateProperties = {};\n');
982 addDefineClassAndFinishClassFunctionsIfNecessary(mainBuffer); 986 addDefineClassAndFinishClassFunctionsIfNecessary(mainBuffer);
983 emitFinishIsolateConstructor(mainBuffer); 987 emitFinishIsolateConstructor(mainBuffer);
984 mainBuffer.add('}\n'); 988 mainBuffer.add('}\n');
985 compiler.assembledCode = mainBuffer.toString(); 989 compiler.assembledCode = mainBuffer.toString();
986 }); 990 });
987 return compiler.assembledCode; 991 return compiler.assembledCode;
988 } 992 }
989 } 993 }
OLDNEW
« no previous file with comments | « frog/tests/leg/class_codegen2_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698