Chromium Code Reviews| Index: runtime/vm/parser.cc |
| =================================================================== |
| --- runtime/vm/parser.cc (revision 10362) |
| +++ runtime/vm/parser.cc (working copy) |
| @@ -1192,22 +1192,6 @@ |
| } |
| -static RawFunction* ResolveDynamicFunction(const Class& cls, |
| - const String& name) { |
| - Function& func = Function::Handle(cls.LookupDynamicFunction(name)); |
| - if (func.IsNull()) { |
| - Class& super_cls = Class::Handle(cls.SuperClass()); |
| - while (!super_cls.IsNull()) { |
| - func = super_cls.LookupDynamicFunction(name); |
| - if (!func.IsNull()) { |
| - return func.raw(); |
| - } |
| - super_cls = super_cls.SuperClass(); |
| - } |
| - } |
| - return func.raw(); |
| -} |
| - |
| // Resolve and return the dynamic function of the given name in the superclass. |
| // If it is not found, return noSuchMethod and set is_no_such_method to true. |
| RawFunction* Parser::GetSuperFunction(intptr_t token_pos, |
| @@ -1220,10 +1204,11 @@ |
| } |
| Function& super_func = |
| - Function::Handle(ResolveDynamicFunction(super_class, name)); |
| + Function::Handle(Resolver::ResolveDynamicAnyParams(super_class, name)); |
| if (super_func.IsNull()) { |
| const String& no_such_method_name = String::Handle(Symbols::NoSuchMethod()); |
| - super_func = ResolveDynamicFunction(super_class, no_such_method_name); |
| + super_func = |
| + Resolver::ResolveDynamicAnyParams(super_class, no_such_method_name); |
| ASSERT(!super_func.IsNull()); |
| *is_no_such_method = true; |
| } else { |
| @@ -1436,7 +1421,7 @@ |
| AstNode* Parser::ParseSuperFieldAccess(const String& field_name) { |
| TRACE_PARSER("ParseSuperFieldAccess"); |
| const intptr_t field_pos = TokenPos(); |
| - const Class& super_class = Class::Handle(current_class().SuperClass()); |
| + const Class& super_class = Class::ZoneHandle(current_class().SuperClass()); |
|
srdjan
2012/08/08 16:44:34
Why ZoneHandle, does the 'super_class' handle esca
hausner
2012/08/08 17:42:02
Yes, it is used in the static getter node in line
|
| if (super_class.IsNull()) { |
| ErrorMsg("class '%s' does not have a superclass", |
| String::Handle(current_class().Name()).ToCString()); |
| @@ -1446,14 +1431,14 @@ |
| const String& getter_name = |
| String::ZoneHandle(Field::GetterName(field_name)); |
| const Function& super_getter = Function::ZoneHandle( |
| - ResolveDynamicFunction(super_class, getter_name)); |
| + Resolver::ResolveDynamicAnyParams(super_class, getter_name)); |
| if (super_getter.IsNull()) { |
| // Check if this is an access to an implicit closure using 'super'. |
| // If a function exists of the specified field_name then try |
| // accessing it as a getter, at runtime we will handle this by |
| // creating an implicit closure of the function and returning it. |
| const Function& super_function = Function::ZoneHandle( |
| - ResolveDynamicFunction(super_class, field_name)); |
| + Resolver::ResolveDynamicAnyParams(super_class, field_name)); |
| if (super_function.IsNull()) { |
| ErrorMsg(field_pos, "field or getter '%s' not found in superclass", |
| field_name.ToCString()); |
| @@ -1462,37 +1447,9 @@ |
| field_pos, |
| implicit_argument); |
| } |
| - // All dynamic getters take one argument and no named arguments. |
| - ASSERT(super_getter.AreValidArgumentCounts(1, 0, NULL)); |
| - ArgumentListNode* getter_arguments = new ArgumentListNode(field_pos); |
| - getter_arguments->Add(implicit_argument); |
| - AstNode* super_field = |
| - new StaticCallNode(field_pos, super_getter, getter_arguments); |
| - if (Token::IsAssignmentOperator(CurrentToken())) { |
| - const String& setter_name = |
| - String::ZoneHandle(Field::SetterName(field_name)); |
| - const Function& super_setter = Function::ZoneHandle( |
| - ResolveDynamicFunction(super_class, setter_name)); |
| - if (super_setter.IsNull()) { |
| - ErrorMsg(field_pos, |
| - "field '%s' not assignable in superclass", |
| - field_name.ToCString()); |
| - } |
| - // All dynamic setters take two arguments and no named arguments. |
| - ASSERT(super_setter.AreValidArgumentCounts(2, 0, NULL)); |
| - |
| - Token::Kind assignment_op = CurrentToken(); |
| - ConsumeToken(); |
| - AstNode* value = ParseExpr(kAllowConst, kConsumeCascades); |
| - value = ExpandAssignableOp(field_pos, assignment_op, super_field, value); |
| - |
| - ArgumentListNode* setter_arguments = new ArgumentListNode(field_pos); |
| - setter_arguments->Add(implicit_argument); |
| - setter_arguments->Add(value); |
| - super_field = new StaticCallNode(field_pos, super_setter, setter_arguments); |
| - } |
| - return super_field; |
| + return new StaticGetterNode( |
| + field_pos, implicit_argument, true, super_class, field_name); |
| } |
| @@ -6707,6 +6664,7 @@ |
| EnsureExpressionTemp(); |
| closure = new StaticGetterNode(call_pos, |
| NULL, |
| + false, |
|
srdjan
2012/08/08 16:44:34
add comment what false means.
hausner
2012/08/08 17:42:02
I don't think that makes the program more readable
|
| Class::ZoneHandle(cls.raw()), |
| func_name); |
| return new ClosureCallNode(call_pos, closure, arguments); |
| @@ -6816,6 +6774,7 @@ |
| // exist, and error will be reported by the code generator. |
| access = new StaticGetterNode(call_pos, |
| NULL, |
| + false, |
|
srdjan
2012/08/08 16:44:34
ditto
|
| Class::ZoneHandle(cls.raw()), |
| String::ZoneHandle(field_name.raw())); |
| } else { |
| @@ -6855,6 +6814,7 @@ |
| ASSERT(func.kind() != RawFunction::kConstImplicitGetter); |
| access = new StaticGetterNode(call_pos, |
| NULL, |
| + false, |
|
srdjan
2012/08/08 16:44:34
ditto
|
| Class::ZoneHandle(cls.raw()), |
| field_name); |
| } |
| @@ -7255,6 +7215,7 @@ |
| // The implicit static getter will throw the exception if necessary. |
| return new StaticGetterNode(TokenPos(), |
| NULL, |
| + false, |
|
srdjan
2012/08/08 16:44:34
ditto
|
| Class::ZoneHandle(field.owner()), |
| String::ZoneHandle(field.name())); |
| } |
| @@ -7306,6 +7267,7 @@ |
| } else { |
| return new StaticGetterNode(TokenPos(), |
| NULL, |
| + false, |
|
srdjan
2012/08/08 16:44:34
ditto
|
| Class::ZoneHandle(field.owner()), |
| String::ZoneHandle(field.name())); |
| } |
| @@ -7429,7 +7391,9 @@ |
| } else if (func.IsStaticFunction()) { |
| if (node != NULL) { |
| ASSERT(AbstractType::Handle(func.result_type()).IsResolved()); |
| - // The static getter may be changed later into an instance setter. |
| + // The static getter may later be changed into a dynamically |
| + // resolved instance setter if no static setter can |
| + // be found. |
| AstNode* receiver = NULL; |
| const bool kTestOnly = true; |
| ASSERT(!current_function().IsInFactoryScope()); |
| @@ -7439,6 +7403,7 @@ |
| } |
| *node = new StaticGetterNode(ident_pos, |
| receiver, |
| + false, |
|
srdjan
2012/08/08 16:44:34
ditto and all other places.
|
| Class::ZoneHandle(isolate, cls.raw()), |
| ident); |
| } |
| @@ -7466,6 +7431,7 @@ |
| // when we try to invoke the getter. |
| *node = new StaticGetterNode(ident_pos, |
| NULL, |
| + false, |
| Class::ZoneHandle(isolate, cls.raw()), |
| ident); |
| } |
| @@ -7538,6 +7504,7 @@ |
| ASSERT(AbstractType::Handle(func.result_type()).IsResolved()); |
| return new StaticGetterNode(qual_ident.ident_pos, |
| NULL, |
| + false, |
| Class::ZoneHandle(func.owner()), |
| *qual_ident.ident); |
| } |