Index: runtime/vm/parser.cc |
diff --git a/runtime/vm/parser.cc b/runtime/vm/parser.cc |
index aacdda0b953f57214f7e030b9cbe1fc9a98f3a52..58567f1325fb24c3f78977fc951bf5e250e9f20b 100644 |
--- a/runtime/vm/parser.cc |
+++ b/runtime/vm/parser.cc |
@@ -756,6 +756,9 @@ void Parser::ParseFunction(ParsedFunction* parsed_function) { |
case RawFunction::kConstImplicitGetter: |
node_sequence = parser.ParseStaticConstGetter(func); |
break; |
+ case RawFunction::kMethodExtractor: |
+ node_sequence = parser.ParseMethodExtractor(func); |
+ break; |
default: |
UNREACHABLE(); |
} |
@@ -984,6 +987,37 @@ SequenceNode* Parser::ParseInstanceSetter(const Function& func) { |
} |
+SequenceNode* Parser::ParseMethodExtractor(const Function& func) { |
+ TRACE_PARSER("ParseMethodExtractor"); |
+ ParamList params; |
+ |
+ // func.token_pos() points to the name of the field. |
Ivan Posva
2013/01/17 08:03:20
I don't think this comment is correct. The token_p
Vyacheslav Egorov (Google)
2013/01/17 12:46:38
Indeed it is not. token_pos is 0 actually.
|
+ intptr_t ident_pos = func.token_pos(); |
+ ASSERT(current_class().raw() == func.Owner()); |
+ params.AddReceiver(ReceiverType(ident_pos)); |
+ ASSERT(func.num_fixed_parameters() == 1); // receiver. |
+ ASSERT(!func.HasOptionalParameters()); |
+ |
+ // Build local scope for function and populate with the formal parameters. |
+ OpenFunctionBlock(func); |
+ AddFormalParamsToScope(¶ms, current_block_->scope); |
+ |
+ // Receiver is local 0. |
+ LocalVariable* receiver = current_block_->scope->VariableAt(0); |
+ LoadLocalNode* load_receiver = new LoadLocalNode(ident_pos, receiver); |
+ |
+ ClosureNode* closure = new ClosureNode( |
+ ident_pos, |
+ Function::ZoneHandle(func.extracted_method_closure()), |
+ load_receiver, |
+ NULL); |
+ |
+ ReturnNode* return_node = new ReturnNode(ident_pos, closure); |
+ current_block_->statements->Add(return_node); |
+ return CloseBlock(); |
+} |
+ |
+ |
void Parser::SkipBlock() { |
ASSERT(CurrentToken() == Token::kLBRACE); |
GrowableArray<Token::Kind> token_stack(8); |