| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/parser.h" | 5 #include "vm/parser.h" |
| 6 | 6 |
| 7 #include "vm/bigint_operations.h" | 7 #include "vm/bigint_operations.h" |
| 8 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/compiler_stats.h" | 10 #include "vm/compiler_stats.h" |
| (...skipping 1174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1185 | 1185 |
| 1186 void Parser::CheckFunctionIsCallable(intptr_t token_pos, | 1186 void Parser::CheckFunctionIsCallable(intptr_t token_pos, |
| 1187 const Function& function) { | 1187 const Function& function) { |
| 1188 if (Class::Handle(function.owner()).is_interface()) { | 1188 if (Class::Handle(function.owner()).is_interface()) { |
| 1189 ErrorMsg(token_pos, "cannot call function of interface '%s'", | 1189 ErrorMsg(token_pos, "cannot call function of interface '%s'", |
| 1190 function.ToFullyQualifiedCString()); | 1190 function.ToFullyQualifiedCString()); |
| 1191 } | 1191 } |
| 1192 } | 1192 } |
| 1193 | 1193 |
| 1194 | 1194 |
| 1195 static RawFunction* ResolveDynamicFunction(const Class& cls, | |
| 1196 const String& name) { | |
| 1197 Function& func = Function::Handle(cls.LookupDynamicFunction(name)); | |
| 1198 if (func.IsNull()) { | |
| 1199 Class& super_cls = Class::Handle(cls.SuperClass()); | |
| 1200 while (!super_cls.IsNull()) { | |
| 1201 func = super_cls.LookupDynamicFunction(name); | |
| 1202 if (!func.IsNull()) { | |
| 1203 return func.raw(); | |
| 1204 } | |
| 1205 super_cls = super_cls.SuperClass(); | |
| 1206 } | |
| 1207 } | |
| 1208 return func.raw(); | |
| 1209 } | |
| 1210 | |
| 1211 // Resolve and return the dynamic function of the given name in the superclass. | 1195 // Resolve and return the dynamic function of the given name in the superclass. |
| 1212 // If it is not found, return noSuchMethod and set is_no_such_method to true. | 1196 // If it is not found, return noSuchMethod and set is_no_such_method to true. |
| 1213 RawFunction* Parser::GetSuperFunction(intptr_t token_pos, | 1197 RawFunction* Parser::GetSuperFunction(intptr_t token_pos, |
| 1214 const String& name, | 1198 const String& name, |
| 1215 bool* is_no_such_method) { | 1199 bool* is_no_such_method) { |
| 1216 const Class& super_class = Class::Handle(current_class().SuperClass()); | 1200 const Class& super_class = Class::Handle(current_class().SuperClass()); |
| 1217 if (super_class.IsNull()) { | 1201 if (super_class.IsNull()) { |
| 1218 ErrorMsg(token_pos, "class '%s' does not have a superclass", | 1202 ErrorMsg(token_pos, "class '%s' does not have a superclass", |
| 1219 String::Handle(current_class().Name()).ToCString()); | 1203 String::Handle(current_class().Name()).ToCString()); |
| 1220 } | 1204 } |
| 1221 | 1205 |
| 1222 Function& super_func = | 1206 Function& super_func = |
| 1223 Function::Handle(ResolveDynamicFunction(super_class, name)); | 1207 Function::Handle(Resolver::ResolveDynamicAnyArgs(super_class, name)); |
| 1224 if (super_func.IsNull()) { | 1208 if (super_func.IsNull()) { |
| 1225 const String& no_such_method_name = String::Handle(Symbols::NoSuchMethod()); | 1209 const String& no_such_method_name = String::Handle(Symbols::NoSuchMethod()); |
| 1226 super_func = ResolveDynamicFunction(super_class, no_such_method_name); | 1210 super_func = |
| 1211 Resolver::ResolveDynamicAnyArgs(super_class, no_such_method_name); |
| 1227 ASSERT(!super_func.IsNull()); | 1212 ASSERT(!super_func.IsNull()); |
| 1228 *is_no_such_method = true; | 1213 *is_no_such_method = true; |
| 1229 } else { | 1214 } else { |
| 1230 *is_no_such_method = false; | 1215 *is_no_such_method = false; |
| 1231 } | 1216 } |
| 1232 CheckFunctionIsCallable(token_pos, super_func); | 1217 CheckFunctionIsCallable(token_pos, super_func); |
| 1233 return super_func.raw(); | 1218 return super_func.raw(); |
| 1234 } | 1219 } |
| 1235 | 1220 |
| 1236 | 1221 |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1429 } | 1414 } |
| 1430 } | 1415 } |
| 1431 } | 1416 } |
| 1432 return new ClosureNode(token_pos, implicit_closure_function, receiver, NULL); | 1417 return new ClosureNode(token_pos, implicit_closure_function, receiver, NULL); |
| 1433 } | 1418 } |
| 1434 | 1419 |
| 1435 | 1420 |
| 1436 AstNode* Parser::ParseSuperFieldAccess(const String& field_name) { | 1421 AstNode* Parser::ParseSuperFieldAccess(const String& field_name) { |
| 1437 TRACE_PARSER("ParseSuperFieldAccess"); | 1422 TRACE_PARSER("ParseSuperFieldAccess"); |
| 1438 const intptr_t field_pos = TokenPos(); | 1423 const intptr_t field_pos = TokenPos(); |
| 1439 const Class& super_class = Class::Handle(current_class().SuperClass()); | 1424 const Class& super_class = Class::ZoneHandle(current_class().SuperClass()); |
| 1440 if (super_class.IsNull()) { | 1425 if (super_class.IsNull()) { |
| 1441 ErrorMsg("class '%s' does not have a superclass", | 1426 ErrorMsg("class '%s' does not have a superclass", |
| 1442 String::Handle(current_class().Name()).ToCString()); | 1427 String::Handle(current_class().Name()).ToCString()); |
| 1443 } | 1428 } |
| 1444 AstNode* implicit_argument = LoadReceiver(field_pos); | 1429 AstNode* implicit_argument = LoadReceiver(field_pos); |
| 1445 | 1430 |
| 1446 const String& getter_name = | 1431 const String& getter_name = |
| 1447 String::ZoneHandle(Field::GetterName(field_name)); | 1432 String::ZoneHandle(Field::GetterName(field_name)); |
| 1448 const Function& super_getter = Function::ZoneHandle( | 1433 const Function& super_getter = Function::ZoneHandle( |
| 1449 ResolveDynamicFunction(super_class, getter_name)); | 1434 Resolver::ResolveDynamicAnyArgs(super_class, getter_name)); |
| 1450 if (super_getter.IsNull()) { | 1435 if (super_getter.IsNull()) { |
| 1451 // Check if this is an access to an implicit closure using 'super'. | 1436 // Check if this is an access to an implicit closure using 'super'. |
| 1452 // If a function exists of the specified field_name then try | 1437 // If a function exists of the specified field_name then try |
| 1453 // accessing it as a getter, at runtime we will handle this by | 1438 // accessing it as a getter, at runtime we will handle this by |
| 1454 // creating an implicit closure of the function and returning it. | 1439 // creating an implicit closure of the function and returning it. |
| 1455 const Function& super_function = Function::ZoneHandle( | 1440 const Function& super_function = Function::ZoneHandle( |
| 1456 ResolveDynamicFunction(super_class, field_name)); | 1441 Resolver::ResolveDynamicAnyArgs(super_class, field_name)); |
| 1457 if (super_function.IsNull()) { | 1442 if (super_function.IsNull()) { |
| 1458 ErrorMsg(field_pos, "field or getter '%s' not found in superclass", | 1443 ErrorMsg(field_pos, "field or getter '%s' not found in superclass", |
| 1459 field_name.ToCString()); | 1444 field_name.ToCString()); |
| 1460 } | 1445 } |
| 1461 return CreateImplicitClosureNode(super_function, | 1446 return CreateImplicitClosureNode(super_function, |
| 1462 field_pos, | 1447 field_pos, |
| 1463 implicit_argument); | 1448 implicit_argument); |
| 1464 } | 1449 } |
| 1465 // All dynamic getters take one argument and no named arguments. | |
| 1466 ASSERT(super_getter.AreValidArgumentCounts(1, 0, NULL)); | |
| 1467 ArgumentListNode* getter_arguments = new ArgumentListNode(field_pos); | |
| 1468 getter_arguments->Add(implicit_argument); | |
| 1469 AstNode* super_field = | |
| 1470 new StaticCallNode(field_pos, super_getter, getter_arguments); | |
| 1471 | 1450 |
| 1472 if (Token::IsAssignmentOperator(CurrentToken())) { | 1451 return new StaticGetterNode( |
| 1473 const String& setter_name = | 1452 field_pos, implicit_argument, true, super_class, field_name); |
| 1474 String::ZoneHandle(Field::SetterName(field_name)); | |
| 1475 const Function& super_setter = Function::ZoneHandle( | |
| 1476 ResolveDynamicFunction(super_class, setter_name)); | |
| 1477 if (super_setter.IsNull()) { | |
| 1478 ErrorMsg(field_pos, | |
| 1479 "field '%s' not assignable in superclass", | |
| 1480 field_name.ToCString()); | |
| 1481 } | |
| 1482 // All dynamic setters take two arguments and no named arguments. | |
| 1483 ASSERT(super_setter.AreValidArgumentCounts(2, 0, NULL)); | |
| 1484 | |
| 1485 Token::Kind assignment_op = CurrentToken(); | |
| 1486 ConsumeToken(); | |
| 1487 AstNode* value = ParseExpr(kAllowConst, kConsumeCascades); | |
| 1488 value = ExpandAssignableOp(field_pos, assignment_op, super_field, value); | |
| 1489 | |
| 1490 ArgumentListNode* setter_arguments = new ArgumentListNode(field_pos); | |
| 1491 setter_arguments->Add(implicit_argument); | |
| 1492 setter_arguments->Add(value); | |
| 1493 super_field = new StaticCallNode(field_pos, super_setter, setter_arguments); | |
| 1494 } | |
| 1495 return super_field; | |
| 1496 } | 1453 } |
| 1497 | 1454 |
| 1498 | 1455 |
| 1499 void Parser::GenerateSuperConstructorCall(const Class& cls, | 1456 void Parser::GenerateSuperConstructorCall(const Class& cls, |
| 1500 LocalVariable* receiver) { | 1457 LocalVariable* receiver) { |
| 1501 const intptr_t supercall_pos = TokenPos(); | 1458 const intptr_t supercall_pos = TokenPos(); |
| 1502 const Class& super_class = Class::Handle(cls.SuperClass()); | 1459 const Class& super_class = Class::Handle(cls.SuperClass()); |
| 1503 // Omit the implicit super() if there is no super class (i.e. | 1460 // Omit the implicit super() if there is no super class (i.e. |
| 1504 // we're not compiling class Object), or if the super class is an | 1461 // we're not compiling class Object), or if the super class is an |
| 1505 // artificially generated "wrapper class" that has no constructor. | 1462 // artificially generated "wrapper class" that has no constructor. |
| (...skipping 5246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6752 func = Resolver::ResolveStatic(cls, | 6709 func = Resolver::ResolveStatic(cls, |
| 6753 getter_name, | 6710 getter_name, |
| 6754 kNumArguments, | 6711 kNumArguments, |
| 6755 kNoArgumentNames, | 6712 kNoArgumentNames, |
| 6756 Resolver::kIsQualified); | 6713 Resolver::kIsQualified); |
| 6757 if (!func.IsNull()) { | 6714 if (!func.IsNull()) { |
| 6758 ASSERT(func.kind() != RawFunction::kConstImplicitGetter); | 6715 ASSERT(func.kind() != RawFunction::kConstImplicitGetter); |
| 6759 EnsureExpressionTemp(); | 6716 EnsureExpressionTemp(); |
| 6760 closure = new StaticGetterNode(call_pos, | 6717 closure = new StaticGetterNode(call_pos, |
| 6761 NULL, | 6718 NULL, |
| 6719 false, |
| 6762 Class::ZoneHandle(cls.raw()), | 6720 Class::ZoneHandle(cls.raw()), |
| 6763 func_name); | 6721 func_name); |
| 6764 return new ClosureCallNode(call_pos, closure, arguments); | 6722 return new ClosureCallNode(call_pos, closure, arguments); |
| 6765 } | 6723 } |
| 6766 } else { | 6724 } else { |
| 6767 EnsureExpressionTemp(); | 6725 EnsureExpressionTemp(); |
| 6768 closure = GenerateStaticFieldLookup(field, call_pos); | 6726 closure = GenerateStaticFieldLookup(field, call_pos); |
| 6769 return new ClosureCallNode(call_pos, closure, arguments); | 6727 return new ClosureCallNode(call_pos, closure, arguments); |
| 6770 } | 6728 } |
| 6771 // Could not resolve static method: throw an exception if the arguments | 6729 // Could not resolve static method: throw an exception if the arguments |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6861 ErrorMsg(ident_pos, "unknown static field '%s'", | 6819 ErrorMsg(ident_pos, "unknown static field '%s'", |
| 6862 field_name.ToCString()); | 6820 field_name.ToCString()); |
| 6863 } | 6821 } |
| 6864 | 6822 |
| 6865 // Explicit setter function for the field found, field does not exist. | 6823 // Explicit setter function for the field found, field does not exist. |
| 6866 // Create a getter node first in case it is needed. If getter node | 6824 // Create a getter node first in case it is needed. If getter node |
| 6867 // is used as part of, e.g., "+=", and the explicit getter does not | 6825 // is used as part of, e.g., "+=", and the explicit getter does not |
| 6868 // exist, and error will be reported by the code generator. | 6826 // exist, and error will be reported by the code generator. |
| 6869 access = new StaticGetterNode(call_pos, | 6827 access = new StaticGetterNode(call_pos, |
| 6870 NULL, | 6828 NULL, |
| 6829 false, |
| 6871 Class::ZoneHandle(cls.raw()), | 6830 Class::ZoneHandle(cls.raw()), |
| 6872 String::ZoneHandle(field_name.raw())); | 6831 String::ZoneHandle(field_name.raw())); |
| 6873 } else { | 6832 } else { |
| 6874 // Field exists. | 6833 // Field exists. |
| 6875 if (field.is_final()) { | 6834 if (field.is_final()) { |
| 6876 // Field has been marked as final, report an error as the field | 6835 // Field has been marked as final, report an error as the field |
| 6877 // is not settable. | 6836 // is not settable. |
| 6878 ErrorMsg(ident_pos, | 6837 ErrorMsg(ident_pos, |
| 6879 "field '%s' is const static, cannot assign to it", | 6838 "field '%s' is const static, cannot assign to it", |
| 6880 field_name.ToCString()); | 6839 field_name.ToCString()); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 6900 if (func.IsNull()) { | 6859 if (func.IsNull()) { |
| 6901 // No field or explicit getter function, this is an error. | 6860 // No field or explicit getter function, this is an error. |
| 6902 ErrorMsg(ident_pos, | 6861 ErrorMsg(ident_pos, |
| 6903 "unknown static field '%s'", field_name.ToCString()); | 6862 "unknown static field '%s'", field_name.ToCString()); |
| 6904 } | 6863 } |
| 6905 access = CreateImplicitClosureNode(func, call_pos, NULL); | 6864 access = CreateImplicitClosureNode(func, call_pos, NULL); |
| 6906 } else { | 6865 } else { |
| 6907 ASSERT(func.kind() != RawFunction::kConstImplicitGetter); | 6866 ASSERT(func.kind() != RawFunction::kConstImplicitGetter); |
| 6908 access = new StaticGetterNode(call_pos, | 6867 access = new StaticGetterNode(call_pos, |
| 6909 NULL, | 6868 NULL, |
| 6869 false, |
| 6910 Class::ZoneHandle(cls.raw()), | 6870 Class::ZoneHandle(cls.raw()), |
| 6911 field_name); | 6871 field_name); |
| 6912 } | 6872 } |
| 6913 } else { | 6873 } else { |
| 6914 access = GenerateStaticFieldLookup(field, TokenPos()); | 6874 access = GenerateStaticFieldLookup(field, TokenPos()); |
| 6915 } | 6875 } |
| 6916 } | 6876 } |
| 6917 return access; | 6877 return access; |
| 6918 } | 6878 } |
| 6919 | 6879 |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7300 if (value.raw() == Object::transition_sentinel()) { | 7260 if (value.raw() == Object::transition_sentinel()) { |
| 7301 // TODO(hausner): Remove the check for is_final() once we support | 7261 // TODO(hausner): Remove the check for is_final() once we support |
| 7302 // non-const final fields. | 7262 // non-const final fields. |
| 7303 if (field.is_const() || field.is_final()) { | 7263 if (field.is_const() || field.is_final()) { |
| 7304 ErrorMsg("circular dependency while initializing static field '%s'", | 7264 ErrorMsg("circular dependency while initializing static field '%s'", |
| 7305 String::Handle(field.name()).ToCString()); | 7265 String::Handle(field.name()).ToCString()); |
| 7306 } else { | 7266 } else { |
| 7307 // The implicit static getter will throw the exception if necessary. | 7267 // The implicit static getter will throw the exception if necessary. |
| 7308 return new StaticGetterNode(TokenPos(), | 7268 return new StaticGetterNode(TokenPos(), |
| 7309 NULL, | 7269 NULL, |
| 7270 false, |
| 7310 Class::ZoneHandle(field.owner()), | 7271 Class::ZoneHandle(field.owner()), |
| 7311 String::ZoneHandle(field.name())); | 7272 String::ZoneHandle(field.name())); |
| 7312 } | 7273 } |
| 7313 } else if (value.raw() == Object::sentinel()) { | 7274 } else if (value.raw() == Object::sentinel()) { |
| 7314 // This field has not been referenced yet and thus the value has | 7275 // This field has not been referenced yet and thus the value has |
| 7315 // not been evaluated. If the field is const, call the static getter method | 7276 // not been evaluated. If the field is const, call the static getter method |
| 7316 // to evaluate the expression and canonicalize the value. | 7277 // to evaluate the expression and canonicalize the value. |
| 7317 // TODO(hausner): Remove the check for is_final() once we support | 7278 // TODO(hausner): Remove the check for is_final() once we support |
| 7318 // non-const final fields. | 7279 // non-const final fields. |
| 7319 if (field.is_const() || field.is_final()) { | 7280 if (field.is_const() || field.is_final()) { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7351 ASSERT(const_value.IsNull() || const_value.IsInstance()); | 7312 ASSERT(const_value.IsNull() || const_value.IsInstance()); |
| 7352 Instance& instance = Instance::Handle(); | 7313 Instance& instance = Instance::Handle(); |
| 7353 instance ^= const_value.raw(); | 7314 instance ^= const_value.raw(); |
| 7354 if (!instance.IsNull()) { | 7315 if (!instance.IsNull()) { |
| 7355 instance ^= instance.Canonicalize(); | 7316 instance ^= instance.Canonicalize(); |
| 7356 } | 7317 } |
| 7357 field.set_value(instance); | 7318 field.set_value(instance); |
| 7358 } else { | 7319 } else { |
| 7359 return new StaticGetterNode(TokenPos(), | 7320 return new StaticGetterNode(TokenPos(), |
| 7360 NULL, | 7321 NULL, |
| 7322 false, |
| 7361 Class::ZoneHandle(field.owner()), | 7323 Class::ZoneHandle(field.owner()), |
| 7362 String::ZoneHandle(field.name())); | 7324 String::ZoneHandle(field.name())); |
| 7363 } | 7325 } |
| 7364 } | 7326 } |
| 7365 return NULL; | 7327 return NULL; |
| 7366 } | 7328 } |
| 7367 | 7329 |
| 7368 | 7330 |
| 7369 RawObject* Parser::EvaluateConstConstructorCall( | 7331 RawObject* Parser::EvaluateConstConstructorCall( |
| 7370 const Class& type_class, | 7332 const Class& type_class, |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7474 if (func.IsDynamicFunction()) { | 7436 if (func.IsDynamicFunction()) { |
| 7475 if (node != NULL) { | 7437 if (node != NULL) { |
| 7476 CheckInstanceFieldAccess(ident_pos, ident); | 7438 CheckInstanceFieldAccess(ident_pos, ident); |
| 7477 ASSERT(AbstractType::Handle(func.result_type()).IsResolved()); | 7439 ASSERT(AbstractType::Handle(func.result_type()).IsResolved()); |
| 7478 *node = CallGetter(ident_pos, LoadReceiver(ident_pos), ident); | 7440 *node = CallGetter(ident_pos, LoadReceiver(ident_pos), ident); |
| 7479 } | 7441 } |
| 7480 return true; | 7442 return true; |
| 7481 } else if (func.IsStaticFunction()) { | 7443 } else if (func.IsStaticFunction()) { |
| 7482 if (node != NULL) { | 7444 if (node != NULL) { |
| 7483 ASSERT(AbstractType::Handle(func.result_type()).IsResolved()); | 7445 ASSERT(AbstractType::Handle(func.result_type()).IsResolved()); |
| 7484 // The static getter may be changed later into an instance setter. | 7446 // The static getter may later be changed into a dynamically |
| 7447 // resolved instance setter if no static setter can |
| 7448 // be found. |
| 7485 AstNode* receiver = NULL; | 7449 AstNode* receiver = NULL; |
| 7486 const bool kTestOnly = true; | 7450 const bool kTestOnly = true; |
| 7487 ASSERT(!current_function().IsInFactoryScope()); | 7451 ASSERT(!current_function().IsInFactoryScope()); |
| 7488 if (!current_function().is_static() && | 7452 if (!current_function().is_static() && |
| 7489 (LookupReceiver(current_block_->scope, kTestOnly) != NULL)) { | 7453 (LookupReceiver(current_block_->scope, kTestOnly) != NULL)) { |
| 7490 receiver = LoadReceiver(ident_pos); | 7454 receiver = LoadReceiver(ident_pos); |
| 7491 } | 7455 } |
| 7492 *node = new StaticGetterNode(ident_pos, | 7456 *node = new StaticGetterNode(ident_pos, |
| 7493 receiver, | 7457 receiver, |
| 7458 false, |
| 7494 Class::ZoneHandle(isolate, cls.raw()), | 7459 Class::ZoneHandle(isolate, cls.raw()), |
| 7495 ident); | 7460 ident); |
| 7496 } | 7461 } |
| 7497 return true; | 7462 return true; |
| 7498 } | 7463 } |
| 7499 } | 7464 } |
| 7500 func = cls.LookupSetterFunction(ident); | 7465 func = cls.LookupSetterFunction(ident); |
| 7501 if (!func.IsNull()) { | 7466 if (!func.IsNull()) { |
| 7502 if (func.IsDynamicFunction()) { | 7467 if (func.IsDynamicFunction()) { |
| 7503 if (node != NULL) { | 7468 if (node != NULL) { |
| 7504 // We create a getter node even though a getter doesn't exist as | 7469 // We create a getter node even though a getter doesn't exist as |
| 7505 // it could be followed by an assignment which will convert it to | 7470 // it could be followed by an assignment which will convert it to |
| 7506 // a setter node. If there is no assignment we will get an error | 7471 // a setter node. If there is no assignment we will get an error |
| 7507 // when we try to invoke the getter. | 7472 // when we try to invoke the getter. |
| 7508 CheckInstanceFieldAccess(ident_pos, ident); | 7473 CheckInstanceFieldAccess(ident_pos, ident); |
| 7509 ASSERT(AbstractType::Handle(func.result_type()).IsResolved()); | 7474 ASSERT(AbstractType::Handle(func.result_type()).IsResolved()); |
| 7510 *node = CallGetter(ident_pos, LoadReceiver(ident_pos), ident); | 7475 *node = CallGetter(ident_pos, LoadReceiver(ident_pos), ident); |
| 7511 } | 7476 } |
| 7512 return true; | 7477 return true; |
| 7513 } else if (func.IsStaticFunction()) { | 7478 } else if (func.IsStaticFunction()) { |
| 7514 if (node != NULL) { | 7479 if (node != NULL) { |
| 7515 // We create a getter node even though a getter doesn't exist as | 7480 // We create a getter node even though a getter doesn't exist as |
| 7516 // it could be followed by an assignment which will convert it to | 7481 // it could be followed by an assignment which will convert it to |
| 7517 // a setter node. If there is no assignment we will get an error | 7482 // a setter node. If there is no assignment we will get an error |
| 7518 // when we try to invoke the getter. | 7483 // when we try to invoke the getter. |
| 7519 *node = new StaticGetterNode(ident_pos, | 7484 *node = new StaticGetterNode(ident_pos, |
| 7520 NULL, | 7485 NULL, |
| 7486 false, |
| 7521 Class::ZoneHandle(isolate, cls.raw()), | 7487 Class::ZoneHandle(isolate, cls.raw()), |
| 7522 ident); | 7488 ident); |
| 7523 } | 7489 } |
| 7524 return true; | 7490 return true; |
| 7525 } | 7491 } |
| 7526 } | 7492 } |
| 7527 | 7493 |
| 7528 // Nothing found in scope of current class. | 7494 // Nothing found in scope of current class. |
| 7529 if (node != NULL) { | 7495 if (node != NULL) { |
| 7530 *node = NULL; | 7496 *node = NULL; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7583 obj = lib.LookupObject(accessor_name); | 7549 obj = lib.LookupObject(accessor_name); |
| 7584 } | 7550 } |
| 7585 } | 7551 } |
| 7586 if (!obj.IsNull()) { | 7552 if (!obj.IsNull()) { |
| 7587 ASSERT(obj.IsFunction()); | 7553 ASSERT(obj.IsFunction()); |
| 7588 const Function& func = Function::Cast(obj); | 7554 const Function& func = Function::Cast(obj); |
| 7589 ASSERT(func.is_static()); | 7555 ASSERT(func.is_static()); |
| 7590 ASSERT(AbstractType::Handle(func.result_type()).IsResolved()); | 7556 ASSERT(AbstractType::Handle(func.result_type()).IsResolved()); |
| 7591 return new StaticGetterNode(qual_ident.ident_pos, | 7557 return new StaticGetterNode(qual_ident.ident_pos, |
| 7592 NULL, | 7558 NULL, |
| 7559 false, |
| 7593 Class::ZoneHandle(func.owner()), | 7560 Class::ZoneHandle(func.owner()), |
| 7594 *qual_ident.ident); | 7561 *qual_ident.ident); |
| 7595 } | 7562 } |
| 7596 if (qual_ident.lib_prefix != NULL) { | 7563 if (qual_ident.lib_prefix != NULL) { |
| 7597 return NULL; | 7564 return NULL; |
| 7598 } | 7565 } |
| 7599 // Lexically unresolved primary identifiers are referenced by their name. | 7566 // Lexically unresolved primary identifiers are referenced by their name. |
| 7600 return new PrimaryNode(qual_ident.ident_pos, *qual_ident.ident); | 7567 return new PrimaryNode(qual_ident.ident_pos, *qual_ident.ident); |
| 7601 } | 7568 } |
| 7602 | 7569 |
| (...skipping 1393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8996 void Parser::SkipQualIdent() { | 8963 void Parser::SkipQualIdent() { |
| 8997 ASSERT(IsIdentifier()); | 8964 ASSERT(IsIdentifier()); |
| 8998 ConsumeToken(); | 8965 ConsumeToken(); |
| 8999 if (CurrentToken() == Token::kPERIOD) { | 8966 if (CurrentToken() == Token::kPERIOD) { |
| 9000 ConsumeToken(); // Consume the kPERIOD token. | 8967 ConsumeToken(); // Consume the kPERIOD token. |
| 9001 ExpectIdentifier("identifier expected after '.'"); | 8968 ExpectIdentifier("identifier expected after '.'"); |
| 9002 } | 8969 } |
| 9003 } | 8970 } |
| 9004 | 8971 |
| 9005 } // namespace dart | 8972 } // namespace dart |
| OLD | NEW |