Index: runtime/vm/scopes.cc |
=================================================================== |
--- runtime/vm/scopes.cc (revision 14713) |
+++ runtime/vm/scopes.cc (working copy) |
@@ -460,7 +460,12 @@ |
context_scope.SetTokenIndexAt(captured_idx, variable->token_pos()); |
context_scope.SetNameAt(captured_idx, variable->name()); |
context_scope.SetIsFinalAt(captured_idx, variable->is_final()); |
- context_scope.SetTypeAt(captured_idx, variable->type()); |
+ context_scope.SetIsConstAt(captured_idx, variable->IsConst()); |
+ if (variable->IsConst()) { |
+ context_scope.SetConstValueAt(captured_idx, *variable->ConstValue()); |
+ } else { |
+ context_scope.SetTypeAt(captured_idx, variable->type()); |
+ } |
context_scope.SetContextIndexAt(captured_idx, variable->index()); |
// Adjust the context level relative to the current context level, |
// since the context of the current scope will be at level 0 when |
@@ -482,10 +487,18 @@ |
LocalScope* outer_scope = new LocalScope(NULL, -1, 0); |
// Add all variables as aliases to the outer scope. |
for (int i = 0; i < context_scope.num_variables(); i++) { |
- LocalVariable* variable = |
- new LocalVariable(context_scope.TokenIndexAt(i), |
- String::ZoneHandle(context_scope.NameAt(i)), |
- AbstractType::ZoneHandle(context_scope.TypeAt(i))); |
+ LocalVariable* variable; |
+ if (context_scope.IsConstAt(i)) { |
+ variable = new LocalVariable(context_scope.TokenIndexAt(i), |
+ String::ZoneHandle(context_scope.NameAt(i)), |
+ AbstractType::ZoneHandle(Type::DynamicType())); |
+ variable->SetConstValue( |
+ Instance::ZoneHandle(context_scope.ConstValueAt(i))); |
+ } else { |
+ variable = new LocalVariable(context_scope.TokenIndexAt(i), |
+ String::ZoneHandle(context_scope.NameAt(i)), |
+ AbstractType::ZoneHandle(context_scope.TypeAt(i))); |
+ } |
variable->set_is_captured(); |
variable->set_index(context_scope.ContextIndexAt(i)); |
if (context_scope.IsFinalAt(i)) { |
@@ -516,6 +529,7 @@ |
context_scope.SetTokenIndexAt(0, func.token_pos()); |
context_scope.SetNameAt(0, name); |
context_scope.SetIsFinalAt(0, true); |
+ context_scope.SetIsConstAt(0, false); |
const AbstractType& type = AbstractType::Handle(func.ParameterTypeAt(0)); |
context_scope.SetTypeAt(0, type); |
context_scope.SetContextIndexAt(0, 0); |