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

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

Issue 12294028: Fix warnings spotted by dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 10 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
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 1332 matching lines...) Expand 10 before | Expand all | Expand 10 after
1343 /* Do nothing. */ 1343 /* Do nothing. */
1344 } 1344 }
1345 1345
1346 void emitClassFields(ClassElement classElement, 1346 void emitClassFields(ClassElement classElement,
1347 ClassBuilder builder, 1347 ClassBuilder builder,
1348 { String superClass: "", 1348 { String superClass: "",
1349 bool classIsNative: false}) { 1349 bool classIsNative: false}) {
1350 bool isFirstField = true; 1350 bool isFirstField = true;
1351 StringBuffer buffer = new StringBuffer(); 1351 StringBuffer buffer = new StringBuffer();
1352 if (!classIsNative) { 1352 if (!classIsNative) {
1353 buffer.add('$superClass;'); 1353 buffer.write('$superClass;');
1354 } 1354 }
1355 visitClassFields(classElement, (Element member, 1355 visitClassFields(classElement, (Element member,
1356 String name, 1356 String name,
1357 String accessorName, 1357 String accessorName,
1358 bool needsGetter, 1358 bool needsGetter,
1359 bool needsSetter, 1359 bool needsSetter,
1360 bool needsCheckedSetter) { 1360 bool needsCheckedSetter) {
1361 // Ignore needsCheckedSetter - that is handled below. 1361 // Ignore needsCheckedSetter - that is handled below.
1362 bool needsAccessor = (needsGetter || needsSetter); 1362 bool needsAccessor = (needsGetter || needsSetter);
1363 // We need to output the fields for non-native classes so we can auto- 1363 // We need to output the fields for non-native classes so we can auto-
1364 // generate the constructor. For native classes there are no 1364 // generate the constructor. For native classes there are no
1365 // constructors, so we don't need the fields unless we are generating 1365 // constructors, so we don't need the fields unless we are generating
1366 // accessors at runtime. 1366 // accessors at runtime.
1367 if (!classIsNative || needsAccessor) { 1367 if (!classIsNative || needsAccessor) {
1368 // Emit correct commas. 1368 // Emit correct commas.
1369 if (isFirstField) { 1369 if (isFirstField) {
1370 isFirstField = false; 1370 isFirstField = false;
1371 } else { 1371 } else {
1372 buffer.add(','); 1372 buffer.write(',');
1373 } 1373 }
1374 int flag = 0; 1374 int flag = 0;
1375 if (!needsAccessor) { 1375 if (!needsAccessor) {
1376 // Emit field for constructor generation. 1376 // Emit field for constructor generation.
1377 assert(!classIsNative); 1377 assert(!classIsNative);
1378 buffer.add(name); 1378 buffer.write(name);
1379 } else { 1379 } else {
1380 // Emit (possibly renaming) field name so we can add accessors at 1380 // Emit (possibly renaming) field name so we can add accessors at
1381 // runtime. 1381 // runtime.
1382 buffer.add(accessorName); 1382 buffer.write(accessorName);
1383 if (name != accessorName) { 1383 if (name != accessorName) {
1384 buffer.add(':$name'); 1384 buffer.write(':$name');
1385 // Only the native classes can have renaming accessors. 1385 // Only the native classes can have renaming accessors.
1386 assert(classIsNative); 1386 assert(classIsNative);
1387 flag = RENAMING_FLAG; 1387 flag = RENAMING_FLAG;
1388 } 1388 }
1389 } 1389 }
1390 if (needsGetter && needsSetter) { 1390 if (needsGetter && needsSetter) {
1391 buffer.addCharCode(GETTER_SETTER_CODE + flag); 1391 buffer.writeCharCode(GETTER_SETTER_CODE + flag);
1392 } else if (needsGetter) { 1392 } else if (needsGetter) {
1393 buffer.addCharCode(GETTER_CODE + flag); 1393 buffer.writeCharCode(GETTER_CODE + flag);
1394 } else if (needsSetter) { 1394 } else if (needsSetter) {
1395 buffer.addCharCode(SETTER_CODE + flag); 1395 buffer.writeCharCode(SETTER_CODE + flag);
1396 } 1396 }
1397 } 1397 }
1398 }); 1398 });
1399 1399
1400 String compactClassData = buffer.toString(); 1400 String compactClassData = buffer.toString();
1401 if (compactClassData.length > 0) { 1401 if (compactClassData.length > 0) {
1402 builder.addProperty('', js.string(compactClassData)); 1402 builder.addProperty('', js.string(compactClassData));
1403 } 1403 }
1404 } 1404 }
1405 1405
(...skipping 1270 matching lines...) Expand 10 before | Expand all | Expand 10 after
2676 """; 2676 """;
2677 const String HOOKS_API_USAGE = """ 2677 const String HOOKS_API_USAGE = """
2678 // The code supports the following hooks: 2678 // The code supports the following hooks:
2679 // dartPrint(message) - if this function is defined it is called 2679 // dartPrint(message) - if this function is defined it is called
2680 // instead of the Dart [print] method. 2680 // instead of the Dart [print] method.
2681 // dartMainRunner(main) - if this function is defined, the Dart [main] 2681 // dartMainRunner(main) - if this function is defined, the Dart [main]
2682 // method will not be invoked directly. 2682 // method will not be invoked directly.
2683 // Instead, a closure that will invoke [main] is 2683 // Instead, a closure that will invoke [main] is
2684 // passed to [dartMainRunner]. 2684 // passed to [dartMainRunner].
2685 """; 2685 """;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698