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 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 return new InstanceSetterNode(token_pos(), | 380 return new InstanceSetterNode(token_pos(), |
381 receiver(), | 381 receiver(), |
382 field_name(), | 382 field_name(), |
383 rhs); | 383 rhs); |
384 } | 384 } |
385 return NULL; | 385 return NULL; |
386 } | 386 } |
387 } | 387 } |
388 | 388 |
389 | 389 |
| 390 AstNode* StaticCallNode::MakeAssignmentNode(AstNode* rhs) { |
| 391 // Return this node if it represents a 'throw NoSuchMethodError' indicating |
| 392 // that a getter was not found, otherwise return null. |
| 393 const Class& cls = Class::Handle(function().Owner()); |
| 394 const String& cls_name = String::Handle(cls.Name()); |
| 395 const String& func_name = String::Handle(function().name()); |
| 396 const String& error_cls_name = String::Handle(Symbols::NoSuchMethodError()); |
| 397 const String& error_func_name = String::Handle(Symbols::ThrowNew()); |
| 398 if (cls_name.Equals(error_cls_name) && |
| 399 func_name.StartsWith(error_func_name)) { |
| 400 return this; |
| 401 } |
| 402 return NULL; |
| 403 } |
| 404 |
| 405 |
390 const Instance* StaticGetterNode::EvalConstExpr() const { | 406 const Instance* StaticGetterNode::EvalConstExpr() const { |
391 const String& getter_name = | 407 const String& getter_name = |
392 String::Handle(Field::GetterName(this->field_name())); | 408 String::Handle(Field::GetterName(this->field_name())); |
393 const Function& getter_func = | 409 const Function& getter_func = |
394 Function::Handle(this->cls().LookupStaticFunction(getter_name)); | 410 Function::Handle(this->cls().LookupStaticFunction(getter_name)); |
395 if (getter_func.IsNull() || !getter_func.is_const()) { | 411 if (getter_func.IsNull() || !getter_func.is_const()) { |
396 return NULL; | 412 return NULL; |
397 } | 413 } |
398 GrowableArray<const Object*> arguments; | 414 GrowableArray<const Object*> arguments; |
399 const Array& kNoArgumentNames = Array::Handle(); | 415 const Array& kNoArgumentNames = Array::Handle(); |
400 const Object& result = | 416 const Object& result = |
401 Object::Handle(DartEntry::InvokeStatic(getter_func, | 417 Object::Handle(DartEntry::InvokeStatic(getter_func, |
402 arguments, | 418 arguments, |
403 kNoArgumentNames)); | 419 kNoArgumentNames)); |
404 if (result.IsError() || result.IsNull()) { | 420 if (result.IsError() || result.IsNull()) { |
405 // TODO(turnidge): We could get better error messages by returning | 421 // TODO(turnidge): We could get better error messages by returning |
406 // the Error object directly to the parser. This will involve | 422 // the Error object directly to the parser. This will involve |
407 // replumbing all of the EvalConstExpr methods. | 423 // replumbing all of the EvalConstExpr methods. |
408 return NULL; | 424 return NULL; |
409 } | 425 } |
410 return &Instance::ZoneHandle(Instance::Cast(result).raw()); | 426 return &Instance::ZoneHandle(Instance::Cast(result).raw()); |
411 } | 427 } |
412 | 428 |
413 } // namespace dart | 429 } // namespace dart |
OLD | NEW |