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/flow_graph_builder.h" | 5 #include "vm/flow_graph_builder.h" |
6 | 6 |
7 #include "vm/ast_printer.h" | 7 #include "vm/ast_printer.h" |
8 #include "vm/code_descriptors.h" | 8 #include "vm/code_descriptors.h" |
9 #include "vm/dart_entry.h" | 9 #include "vm/dart_entry.h" |
10 #include "vm/flags.h" | 10 #include "vm/flags.h" |
(...skipping 1976 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1987 getter_function = | 1987 getter_function = |
1988 Resolver::ResolveDynamicAnyArgs(node->cls(), getter_name); | 1988 Resolver::ResolveDynamicAnyArgs(node->cls(), getter_name); |
1989 ASSERT(!getter_function.IsNull()); | 1989 ASSERT(!getter_function.IsNull()); |
1990 ASSERT(node->receiver() != NULL); | 1990 ASSERT(node->receiver() != NULL); |
1991 ValueGraphVisitor receiver_value(owner(), temp_index()); | 1991 ValueGraphVisitor receiver_value(owner(), temp_index()); |
1992 node->receiver()->Visit(&receiver_value); | 1992 node->receiver()->Visit(&receiver_value); |
1993 Append(receiver_value); | 1993 Append(receiver_value); |
1994 arguments->Add(PushArgument(receiver_value.value())); | 1994 arguments->Add(PushArgument(receiver_value.value())); |
1995 } else { | 1995 } else { |
1996 getter_function = node->cls().LookupStaticFunction(getter_name); | 1996 getter_function = node->cls().LookupStaticFunction(getter_name); |
1997 ASSERT(!getter_function.IsNull()); | 1997 if (getter_function.IsNull()) { |
| 1998 // When the parser encounters a reference to a static field materialized |
| 1999 // only by a static setter, but no corresponding static getter, it creates |
| 2000 // a StaticGetterNode ast node referring to the non-existing static getter |
| 2001 // for the case this field reference appears in a left hand side |
| 2002 // expression (the parser has not distinguished between left and right |
| 2003 // hand side yet at this stage). If the parser establishes later that the |
| 2004 // field access is part of a left hand side expression, the |
| 2005 // StaticGetterNode is transformed into a StaticSetterNode referring to |
| 2006 // the existing static setter. |
| 2007 // However, if the field reference appears in a right hand side |
| 2008 // expression, no such transformation occurs and we land here with a |
| 2009 // StaticGetterNode missing a getter function, so we throw a |
| 2010 // NoSuchMethodError. |
| 2011 |
| 2012 // Location argument. |
| 2013 Value* call_pos = Bind( |
| 2014 new ConstantInstr(Smi::ZoneHandle(Smi::New(node->token_pos())))); |
| 2015 arguments->Add(PushArgument(call_pos)); |
| 2016 // Function name argument. |
| 2017 const String& method_name = String::ZoneHandle(Symbols::New(getter_name)); |
| 2018 Value* method_name_value = Bind(new ConstantInstr(method_name)); |
| 2019 arguments->Add(PushArgument(method_name_value)); |
| 2020 const String& cls_name = String::Handle(Symbols::NoSuchMethodError()); |
| 2021 const String& func_name = String::Handle(Symbols::ThrowNew()); |
| 2022 const Class& cls = Class::Handle( |
| 2023 Library::Handle(Library::CoreImplLibrary()).LookupClass(cls_name)); |
| 2024 ASSERT(!cls.IsNull()); |
| 2025 getter_function = Resolver::ResolveStatic(cls, |
| 2026 func_name, |
| 2027 arguments->length(), |
| 2028 Array::ZoneHandle(), |
| 2029 Resolver::kIsQualified); |
| 2030 ASSERT(!getter_function.IsNull()); |
| 2031 } |
1998 } | 2032 } |
1999 StaticCallInstr* call = new StaticCallInstr(node->token_pos(), | 2033 StaticCallInstr* call = new StaticCallInstr(node->token_pos(), |
2000 getter_function, | 2034 getter_function, |
2001 Array::ZoneHandle(), // No names. | 2035 Array::ZoneHandle(), // No names. |
2002 arguments); | 2036 arguments); |
2003 ReturnDefinition(call); | 2037 ReturnDefinition(call); |
2004 } | 2038 } |
2005 | 2039 |
2006 | 2040 |
2007 void EffectGraphVisitor::BuildStaticSetter(StaticSetterNode* node, | 2041 void EffectGraphVisitor::BuildStaticSetter(StaticSetterNode* node, |
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2643 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; | 2677 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; |
2644 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 2678 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
2645 OS::SNPrint(chars, len, kFormat, function_name, reason); | 2679 OS::SNPrint(chars, len, kFormat, function_name, reason); |
2646 const Error& error = Error::Handle( | 2680 const Error& error = Error::Handle( |
2647 LanguageError::New(String::Handle(String::New(chars)))); | 2681 LanguageError::New(String::Handle(String::New(chars)))); |
2648 Isolate::Current()->long_jump_base()->Jump(1, error); | 2682 Isolate::Current()->long_jump_base()->Jump(1, error); |
2649 } | 2683 } |
2650 | 2684 |
2651 | 2685 |
2652 } // namespace dart | 2686 } // namespace dart |
OLD | NEW |