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

Side by Side Diff: pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart

Issue 762213002: Support top-level field declaration and assignment in analyzer2dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 6 years 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 library dart2js.ir_builder; 5 library dart2js.ir_builder;
6 6
7 import '../constants/expressions.dart'; 7 import '../constants/expressions.dart';
8 import '../constants/values.dart' show PrimitiveConstantValue; 8 import '../constants/values.dart' show PrimitiveConstantValue;
9 import '../dart_backend/dart_backend.dart' show DartBackend; 9 import '../dart_backend/dart_backend.dart' show DartBackend;
10 import '../dart_types.dart'; 10 import '../dart_types.dart';
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 * such as `foo(){ }`. 527 * such as `foo(){ }`.
528 */ 528 */
529 void _ensureReturn() { 529 void _ensureReturn() {
530 if (!isOpen) return; 530 if (!isOpen) return;
531 ir.Constant constant = buildNullLiteral(); 531 ir.Constant constant = buildNullLiteral();
532 add(new ir.InvokeContinuation(state.returnContinuation, [constant])); 532 add(new ir.InvokeContinuation(state.returnContinuation, [constant]));
533 _current = null; 533 _current = null;
534 } 534 }
535 535
536 /// Create a [ir.FieldDefinition] for the current [Element] using [_root] as 536 /// Create a [ir.FieldDefinition] for the current [Element] using [_root] as
537 /// the body. 537 /// the body using [initializer] as the initial value.
538 ir.FieldDefinition makeFieldDefinition() { 538 ir.FieldDefinition makeFieldDefinition(ir.Primitive initializer) {
539 return new ir.FieldDefinition(state.currentElement, 539 if (initializer == null) {
540 state.returnContinuation, 540 return new ir.FieldDefinition.withoutInitializer(state.currentElement);
541 _root); 541 } else {
542 buildReturn(initializer);
543 return new ir.FieldDefinition(state.currentElement,
544 state.returnContinuation,
545 _root);
546 }
542 } 547 }
543 548
544 /// Create a [ir.FunctionDefinition] for [element] using [_root] as the body. 549 /// Create a [ir.FunctionDefinition] for [element] using [_root] as the body.
545 /// 550 ///
546 /// Parameters must be created before the construction of the body using 551 /// Parameters must be created before the construction of the body using
547 /// [createParameter]. 552 /// [createParameter].
548 ir.FunctionDefinition buildFunctionDefinition( 553 ir.FunctionDefinition makeFunctionDefinition(
549 List<ConstantExpression> defaults) { 554 List<ConstantExpression> defaults) {
550 FunctionElement element = state.currentElement; 555 FunctionElement element = state.currentElement;
551 if (element.isAbstract || element.isExternal) { 556 if (element.isAbstract || element.isExternal) {
552 assert(invariant(element, _root == null, 557 assert(invariant(element, _root == null,
553 message: "Non-empty body for abstract method $element: $_root")); 558 message: "Non-empty body for abstract method $element: $_root"));
554 assert(invariant(element, state.localConstants.isEmpty, 559 assert(invariant(element, state.localConstants.isEmpty,
555 message: "Local constants for abstract method $element: " 560 message: "Local constants for abstract method $element: "
556 "${state.localConstants}")); 561 "${state.localConstants}"));
557 return new ir.FunctionDefinition.abstract( 562 return new ir.FunctionDefinition.abstract(
558 element, _parameters, defaults); 563 element, _parameters, defaults);
(...skipping 903 matching lines...) Expand 10 before | Expand all | Expand 10 after
1462 index = 0; 1467 index = 0;
1463 for (int i = 0; i < environment.length; ++i) { 1468 for (int i = 0; i < environment.length; ++i) {
1464 if (common[i] == null) { 1469 if (common[i] == null) {
1465 environment.index2value[i] = parameters[index++]; 1470 environment.index2value[i] = parameters[index++];
1466 } 1471 }
1467 } 1472 }
1468 1473
1469 return join; 1474 return join;
1470 } 1475 }
1471 } 1476 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/constant_propagation.dart ('k') | pkg/compiler/lib/src/cps_ir/cps_ir_builder_visitor.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698