OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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/ast.h" | 5 #include "vm/ast.h" |
6 #include "vm/compiler.h" | 6 #include "vm/compiler.h" |
7 #include "vm/dart_entry.h" | 7 #include "vm/dart_entry.h" |
8 #include "vm/isolate.h" | 8 #include "vm/isolate.h" |
9 #include "vm/object_store.h" | 9 #include "vm/object_store.h" |
10 #include "vm/resolver.h" | 10 #include "vm/resolver.h" |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 } | 401 } |
402 } | 402 } |
403 | 403 |
404 | 404 |
405 AstNode* StaticCallNode::MakeAssignmentNode(AstNode* rhs) { | 405 AstNode* StaticCallNode::MakeAssignmentNode(AstNode* rhs) { |
406 // Return this node if it represents a 'throw NoSuchMethodError' indicating | 406 // Return this node if it represents a 'throw NoSuchMethodError' indicating |
407 // that a getter was not found, otherwise return null. | 407 // that a getter was not found, otherwise return null. |
408 const Class& cls = Class::Handle(function().Owner()); | 408 const Class& cls = Class::Handle(function().Owner()); |
409 const String& cls_name = String::Handle(cls.Name()); | 409 const String& cls_name = String::Handle(cls.Name()); |
410 const String& func_name = String::Handle(function().name()); | 410 const String& func_name = String::Handle(function().name()); |
411 const String& error_cls_name = String::Handle(Symbols::NoSuchMethodError()); | 411 if (cls_name.Equals(Symbols::NoSuchMethodErrorImpl()) && |
412 const String& error_func_name = String::Handle(Symbols::ThrowNew()); | 412 func_name.StartsWith(Symbols::ThrowNew())) { |
413 if (cls_name.Equals(error_cls_name) && | |
414 func_name.StartsWith(error_func_name)) { | |
415 return this; | 413 return this; |
416 } | 414 } |
417 return NULL; | 415 return NULL; |
418 } | 416 } |
419 | 417 |
420 | 418 |
421 const Instance* StaticGetterNode::EvalConstExpr() const { | 419 const Instance* StaticGetterNode::EvalConstExpr() const { |
422 const String& getter_name = | 420 const String& getter_name = |
423 String::Handle(Field::GetterName(this->field_name())); | 421 String::Handle(Field::GetterName(this->field_name())); |
424 const Function& getter_func = | 422 const Function& getter_func = |
425 Function::Handle(this->cls().LookupStaticFunction(getter_name)); | 423 Function::Handle(this->cls().LookupStaticFunction(getter_name)); |
426 if (getter_func.IsNull() || !getter_func.is_const()) { | 424 if (getter_func.IsNull() || !getter_func.is_const()) { |
427 return NULL; | 425 return NULL; |
428 } | 426 } |
429 const Object& result = Object::Handle( | 427 const Object& result = Object::Handle( |
430 DartEntry::InvokeStatic(getter_func, Object::empty_array())); | 428 DartEntry::InvokeStatic(getter_func, Object::empty_array())); |
431 if (result.IsError() || result.IsNull()) { | 429 if (result.IsError() || result.IsNull()) { |
432 // TODO(turnidge): We could get better error messages by returning | 430 // TODO(turnidge): We could get better error messages by returning |
433 // the Error object directly to the parser. This will involve | 431 // the Error object directly to the parser. This will involve |
434 // replumbing all of the EvalConstExpr methods. | 432 // replumbing all of the EvalConstExpr methods. |
435 return NULL; | 433 return NULL; |
436 } | 434 } |
437 return &Instance::ZoneHandle(Instance::Cast(result).raw()); | 435 return &Instance::ZoneHandle(Instance::Cast(result).raw()); |
438 } | 436 } |
439 | 437 |
440 } // namespace dart | 438 } // namespace dart |
OLD | NEW |