| Index: runtime/vm/parser.cc
|
| ===================================================================
|
| --- runtime/vm/parser.cc (revision 25920)
|
| +++ runtime/vm/parser.cc (working copy)
|
| @@ -757,15 +757,27 @@
|
| SequenceNode* node_sequence = NULL;
|
| Array& default_parameter_values = Array::ZoneHandle(isolate, Array::null());
|
| switch (func.kind()) {
|
| - case RawFunction::kRegularFunction:
|
| + case RawFunction::kRegularFunction: {
|
| + }
|
| case RawFunction::kClosureFunction:
|
| case RawFunction::kGetterFunction:
|
| case RawFunction::kSetterFunction:
|
| - case RawFunction::kConstructor:
|
| + case RawFunction::kConstructor: {
|
| + const Class& owner = Class::Handle(func.Owner());
|
| + const String& name = String::Handle(func.name());
|
| + if (owner.IsSignatureClass() && name.Equals("==")) {
|
| + node_sequence = parser.ParseClosureEqualsFunction(func);
|
| + break;
|
| + }
|
| + if (owner.IsSignatureClass() && name.Equals("get:hashCode")) {
|
| + node_sequence = parser.ParseClosureHashCodeFunction(func);
|
| + break;
|
| + }
|
| // The call to a redirecting factory is redirected.
|
| ASSERT(!func.IsRedirectingFactory());
|
| node_sequence = parser.ParseFunc(func, default_parameter_values);
|
| break;
|
| + }
|
| case RawFunction::kImplicitGetter:
|
| ASSERT(!func.is_static());
|
| node_sequence = parser.ParseInstanceGetter(func);
|
| @@ -1117,6 +1129,103 @@
|
| }
|
|
|
|
|
| +static const String& PrivateCoreLibName(const String& str) {
|
| + const Library& core_lib = Library::Handle(Library::CoreLibrary());
|
| + const String& private_name = String::ZoneHandle(core_lib.PrivateName(str));
|
| + return private_name;
|
| +}
|
| +
|
| +
|
| +SequenceNode* Parser::ParseClosureEqualsFunction(const Function& func) {
|
| + TRACE_PARSER("ParseClosureEqualsFunction");
|
| + ParamList params;
|
| +
|
| + const intptr_t token_pos = func.token_pos();
|
| + ASSERT(func.token_pos() == 0);
|
| + ASSERT(current_class().raw() == func.Owner());
|
| + params.AddReceiver(ReceiverType(), token_pos);
|
| + params.AddFinalParameter(
|
| + token_pos,
|
| + &String::ZoneHandle(Symbols::New("other")),
|
| + &Type::ZoneHandle(Type::DynamicType()));
|
| + ASSERT(func.num_fixed_parameters() == 2); // Receiver, other.
|
| + 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(token_pos, receiver);
|
| +
|
| + // Other is local 1.
|
| + LocalVariable* other = current_block_->scope->VariableAt(1);
|
| + LoadLocalNode* load_other = new LoadLocalNode(token_pos, other);
|
| +
|
| + ArgumentListNode* arguments = new ArgumentListNode(token_pos);
|
| + arguments->Add(load_receiver);
|
| + arguments->Add(load_other);
|
| +
|
| + const Function& compare_func = Function::ZoneHandle(Resolver::ResolveStatic(
|
| + Library::Handle(Library::CoreLibrary()),
|
| + String::Handle(),
|
| + PrivateCoreLibName(Symbols::ClosureCompareFunction()),
|
| + arguments->length(),
|
| + arguments->names(),
|
| + Resolver::kIsQualified,
|
| + NULL));
|
| + ASSERT(!compare_func.IsNull());
|
| +
|
| + StaticCallNode* call = new StaticCallNode(token_pos, compare_func, arguments);
|
| +
|
| + ReturnNode* return_node = new ReturnNode(token_pos, call);
|
| + current_block_->statements->Add(return_node);
|
| + return CloseBlock();
|
| +}
|
| +
|
| +
|
| +SequenceNode* Parser::ParseClosureHashCodeFunction(const Function& func) {
|
| + TRACE_PARSER("ParseClosureHashCodeFunction");
|
| + ParamList params;
|
| +
|
| + const intptr_t token_pos = func.token_pos();
|
| + ASSERT(func.token_pos() == 0);
|
| + ASSERT(current_class().raw() == func.Owner());
|
| + params.AddReceiver(ReceiverType(), token_pos);
|
| + ASSERT(func.num_fixed_parameters() == 1); // Receiver, other.
|
| + 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(token_pos, receiver);
|
| +
|
| + ArgumentListNode* arguments = new ArgumentListNode(token_pos);
|
| + arguments->Add(load_receiver);
|
| +
|
| + const Function& hash_code_func = Function::ZoneHandle(Resolver::ResolveStatic(
|
| + Library::Handle(Library::CoreLibrary()),
|
| + String::Handle(),
|
| + PrivateCoreLibName(Symbols::ClosureHashCodeFunction()),
|
| + arguments->length(),
|
| + arguments->names(),
|
| + Resolver::kIsQualified,
|
| + NULL));
|
| + ASSERT(!hash_code_func.IsNull());
|
| +
|
| + StaticCallNode* call =
|
| + new StaticCallNode(token_pos, hash_code_func, arguments);
|
| +
|
| + ReturnNode* return_node = new ReturnNode(token_pos, call);
|
| + current_block_->statements->Add(return_node);
|
| + return CloseBlock();
|
| +}
|
| +
|
| +
|
| void Parser::BuildDispatcherScope(const Function& func,
|
| const ArgumentsDescriptor& desc,
|
| Array& default_values) {
|
| @@ -1615,13 +1724,6 @@
|
| }
|
|
|
|
|
| -static const String& PrivateCoreLibName(const String& str) {
|
| - const Library& core_lib = Library::Handle(Library::CoreLibrary());
|
| - const String& private_name = String::ZoneHandle(core_lib.PrivateName(str));
|
| - return private_name;
|
| -}
|
| -
|
| -
|
| StaticCallNode* Parser::BuildInvocationMirrorAllocation(
|
| intptr_t call_pos,
|
| const String& function_name,
|
|
|