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

Unified 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: Update comments Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart
diff --git a/pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart b/pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart
index d5bad5dbef60864dcb65d8fc50635e5cd30f4be0..d4620a1568a93d31991611960c2e9e050da4330f 100644
--- a/pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart
+++ b/pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart
@@ -147,6 +147,9 @@ abstract class IrBuilderMixin<N> {
return result;
}
+ /// `true` if an [IrBuilder] is currently set up.
+ bool get hasIrBuilder => _irBuilder != null;
+
/// The current builder.
IrBuilder get irBuilder {
assert(_irBuilder != null);
@@ -534,18 +537,23 @@ class IrBuilder {
}
/// Create a [ir.FieldDefinition] for the current [Element] using [_root] as
- /// the body.
- ir.FieldDefinition makeFieldDefinition() {
- return new ir.FieldDefinition(state.currentElement,
- state.returnContinuation,
- _root);
+ /// the body using [initializer] as the initial value.
+ ir.FieldDefinition makeFieldDefinition(ir.Primitive initializer) {
+ if (initializer == null) {
+ return new ir.FieldDefinition.withoutInitializer(state.currentElement);
+ } else {
+ buildReturn(initializer);
+ return new ir.FieldDefinition(state.currentElement,
+ state.returnContinuation,
+ _root);
+ }
}
/// Create a [ir.FunctionDefinition] for [element] using [_root] as the body.
///
/// Parameters must be created before the construction of the body using
/// [createParameter].
- ir.FunctionDefinition buildFunctionDefinition(
+ ir.FunctionDefinition makeFunctionDefinition(
List<ConstantExpression> defaults) {
FunctionElement element = state.currentElement;
if (element.isAbstract || element.isExternal) {

Powered by Google App Engine
This is Rietveld 408576698