Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(227)

Side by Side Diff: runtime/vm/flow_graph_builder.cc

Issue 11712002: Remove NoSuchMethodErrorImplementation class and use NoSuchMethodError from core (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/flow_graph_builder.h ('k') | runtime/vm/parser.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2128 matching lines...) Expand 10 before | Expand all | Expand 10 after
2139 // expression (the parser has not distinguished between left and right 2139 // expression (the parser has not distinguished between left and right
2140 // hand side yet at this stage). If the parser establishes later that the 2140 // hand side yet at this stage). If the parser establishes later that the
2141 // field access is part of a left hand side expression, the 2141 // field access is part of a left hand side expression, the
2142 // StaticGetterNode is transformed into a StaticSetterNode referring to 2142 // StaticGetterNode is transformed into a StaticSetterNode referring to
2143 // the existing static setter. 2143 // the existing static setter.
2144 // However, if the field reference appears in a right hand side 2144 // However, if the field reference appears in a right hand side
2145 // expression, no such transformation occurs and we land here with a 2145 // expression, no such transformation occurs and we land here with a
2146 // StaticGetterNode missing a getter function, so we throw a 2146 // StaticGetterNode missing a getter function, so we throw a
2147 // NoSuchMethodError. 2147 // NoSuchMethodError.
2148 2148
2149 // Location argument. 2149 // Throw a NoSuchMethodError.
2150 Value* call_pos = Bind( 2150 StaticCallInstr* call = BuildThrowNoSuchMethodError(node->token_pos(),
2151 new ConstantInstr(Smi::ZoneHandle(Smi::New(node->token_pos())))); 2151 node->cls(),
2152 arguments->Add(PushArgument(call_pos)); 2152 getter_name);
2153 // Function name argument. 2153 ReturnDefinition(call);
2154 const String& method_name = String::ZoneHandle(Symbols::New(getter_name)); 2154 return;
2155 Value* method_name_value = Bind(new ConstantInstr(method_name));
2156 arguments->Add(PushArgument(method_name_value));
2157 const String& cls_name = String::Handle(Symbols::NoSuchMethodError());
2158 const String& func_name = String::Handle(Symbols::ThrowNew());
2159 const Class& cls = Class::Handle(
2160 Library::Handle(Library::CoreLibrary()).LookupClass(cls_name));
2161 ASSERT(!cls.IsNull());
2162 getter_function = Resolver::ResolveStatic(cls,
2163 func_name,
2164 arguments->length(),
2165 Array::ZoneHandle(),
2166 Resolver::kIsQualified);
2167 ASSERT(!getter_function.IsNull());
2168 } 2155 }
2169 } 2156 }
2157 ASSERT(!getter_function.IsNull());
2170 StaticCallInstr* call = new StaticCallInstr(node->token_pos(), 2158 StaticCallInstr* call = new StaticCallInstr(node->token_pos(),
2171 getter_function, 2159 getter_function,
2172 Array::ZoneHandle(), // No names. 2160 Array::ZoneHandle(), // No names.
2173 arguments); 2161 arguments);
2174 ReturnDefinition(call); 2162 ReturnDefinition(call);
2175 } 2163 }
2176 2164
2177 2165
2178 void EffectGraphVisitor::BuildStaticSetter(StaticSetterNode* node, 2166 void EffectGraphVisitor::BuildStaticSetter(StaticSetterNode* node,
2179 bool result_is_needed) { 2167 bool result_is_needed) {
(...skipping 16 matching lines...) Expand all
2196 // Resolve and call noSuchMethod. 2184 // Resolve and call noSuchMethod.
2197 ArgumentListNode* arguments = new ArgumentListNode(node->token_pos()); 2185 ArgumentListNode* arguments = new ArgumentListNode(node->token_pos());
2198 arguments->Add(node->receiver()); 2186 arguments->Add(node->receiver());
2199 arguments->Add(node->value()); 2187 arguments->Add(node->value());
2200 call = BuildStaticNoSuchMethodCall(node->cls(), 2188 call = BuildStaticNoSuchMethodCall(node->cls(),
2201 node->receiver(), 2189 node->receiver(),
2202 setter_name, 2190 setter_name,
2203 arguments); 2191 arguments);
2204 } else { 2192 } else {
2205 // Throw a NoSuchMethodError. 2193 // Throw a NoSuchMethodError.
2206 // Location argument. 2194 call = BuildThrowNoSuchMethodError(node->token_pos(),
2207 Value* call_pos = Bind( 2195 node->cls(),
2208 new ConstantInstr(Smi::ZoneHandle(Smi::New(node->token_pos())))); 2196 setter_name);
2209 arguments->Add(PushArgument(call_pos));
2210 // Function name argument.
2211 const String& method_name = String::ZoneHandle(Symbols::New(setter_name));
2212 Value* method_name_value = Bind(new ConstantInstr(method_name));
2213 arguments->Add(PushArgument(method_name_value));
2214 const String& cls_name = String::Handle(Symbols::NoSuchMethodError());
2215 const String& func_name = String::Handle(Symbols::ThrowNew());
2216 const Class& cls = Class::Handle(
2217 Library::Handle(Library::CoreLibrary()).LookupClass(cls_name));
2218 ASSERT(!cls.IsNull());
2219 setter_function = Resolver::ResolveStatic(cls,
2220 func_name,
2221 arguments->length(),
2222 Array::ZoneHandle(),
2223 Resolver::kIsQualified);
2224 ASSERT(!setter_function.IsNull());
2225 call = new StaticCallInstr(node->token_pos(),
2226 setter_function,
2227 Array::ZoneHandle(), // No names.
2228 arguments);
2229 } 2197 }
2230 } else { 2198 } else {
2231 if (is_super_setter) { 2199 if (is_super_setter) {
2232 // Add receiver of instance getter. 2200 // Add receiver of instance getter.
2233 ValueGraphVisitor for_receiver(owner(), temp_index(), loop_depth()); 2201 ValueGraphVisitor for_receiver(owner(), temp_index(), loop_depth());
2234 node->receiver()->Visit(&for_receiver); 2202 node->receiver()->Visit(&for_receiver);
2235 Append(for_receiver); 2203 Append(for_receiver);
2236 arguments->Add(PushArgument(for_receiver.value())); 2204 arguments->Add(PushArgument(for_receiver.value()));
2237 } 2205 }
2238 ValueGraphVisitor for_value(owner(), temp_index(), loop_depth()); 2206 ValueGraphVisitor for_value(owner(), temp_index(), loop_depth());
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after
2897 new ZoneGrowableArray<PushArgumentInstr*>(2); 2865 new ZoneGrowableArray<PushArgumentInstr*>(2);
2898 args->Add(push_receiver); 2866 args->Add(push_receiver);
2899 args->Add(push_invocation_mirror); 2867 args->Add(push_invocation_mirror);
2900 return new StaticCallInstr(args_pos, 2868 return new StaticCallInstr(args_pos,
2901 no_such_method_func, 2869 no_such_method_func,
2902 Array::ZoneHandle(), 2870 Array::ZoneHandle(),
2903 args); 2871 args);
2904 } 2872 }
2905 2873
2906 2874
2875 StaticCallInstr* EffectGraphVisitor::BuildThrowNoSuchMethodError(
2876 intptr_t token_pos,
2877 const Class& function_class,
2878 const String& function_name) {
2879 ZoneGrowableArray<PushArgumentInstr*>* arguments =
2880 new ZoneGrowableArray<PushArgumentInstr*>();
2881 // Object receiver.
2882 // TODO(regis): For now, we pass a class literal of the unresolved
2883 // method's owner, but this is not specified and will probably change.
2884 Type& type = Type::ZoneHandle(
2885 Type::New(function_class,
2886 TypeArguments::Handle(),
2887 token_pos,
2888 Heap::kOld));
2889 type ^= ClassFinalizer::FinalizeType(
2890 function_class, type, ClassFinalizer::kCanonicalize);
2891 Value* receiver_value = Bind(new ConstantInstr(type));
2892 arguments->Add(PushArgument(receiver_value));
2893 // String memberName.
2894 const String& member_name = String::ZoneHandle(Symbols::New(function_name));
2895 Value* member_name_value = Bind(new ConstantInstr(member_name));
2896 arguments->Add(PushArgument(member_name_value));
2897 // List arguments.
2898 Value* arguments_value = Bind(new ConstantInstr(Array::ZoneHandle()));
2899 arguments->Add(PushArgument(arguments_value));
2900 // List argumentNames.
2901 Value* argument_names_value =
2902 Bind(new ConstantInstr(Array::ZoneHandle()));
2903 arguments->Add(PushArgument(argument_names_value));
2904 // List existingArgumentNames.
2905 Value* existing_argument_names_value =
2906 Bind(new ConstantInstr(Array::ZoneHandle()));
2907 arguments->Add(PushArgument(existing_argument_names_value));
2908 // Resolve and call NoSuchMethodError._throwNew.
2909 const String& cls_name = String::Handle(Symbols::NoSuchMethodError());
2910 const String& func_name = String::Handle(Symbols::ThrowNew());
2911 const Class& cls = Class::Handle(
2912 Library::Handle(Library::CoreLibrary()).LookupClass(cls_name));
2913 ASSERT(!cls.IsNull());
2914 const Function& func = Function::ZoneHandle(
2915 Resolver::ResolveStatic(cls,
2916 func_name,
2917 arguments->length(),
2918 Array::ZoneHandle(),
2919 Resolver::kIsQualified));
2920 ASSERT(!func.IsNull());
2921 return new StaticCallInstr(token_pos,
2922 func,
2923 Array::ZoneHandle(), // No names.
2924 arguments);
2925 }
2926
2927
2907 void EffectGraphVisitor::BuildThrowNode(ThrowNode* node) { 2928 void EffectGraphVisitor::BuildThrowNode(ThrowNode* node) {
2908 // TODO(kmillikin) non-local control flow is not handled correctly 2929 // TODO(kmillikin) non-local control flow is not handled correctly
2909 // by the inliner. 2930 // by the inliner.
2910 InlineBailout("EffectGraphVisitor::BuildThrowNode (exception)"); 2931 InlineBailout("EffectGraphVisitor::BuildThrowNode (exception)");
2911 ValueGraphVisitor for_exception(owner(), temp_index(), loop_depth()); 2932 ValueGraphVisitor for_exception(owner(), temp_index(), loop_depth());
2912 node->exception()->Visit(&for_exception); 2933 node->exception()->Visit(&for_exception);
2913 Append(for_exception); 2934 Append(for_exception);
2914 PushArgument(for_exception.value()); 2935 PushArgument(for_exception.value());
2915 Instruction* instr = NULL; 2936 Instruction* instr = NULL;
2916 if (node->stacktrace() == NULL) { 2937 if (node->stacktrace() == NULL) {
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
3018 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; 3039 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1;
3019 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 3040 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
3020 OS::SNPrint(chars, len, kFormat, function_name, reason); 3041 OS::SNPrint(chars, len, kFormat, function_name, reason);
3021 const Error& error = Error::Handle( 3042 const Error& error = Error::Handle(
3022 LanguageError::New(String::Handle(String::New(chars)))); 3043 LanguageError::New(String::Handle(String::New(chars))));
3023 Isolate::Current()->long_jump_base()->Jump(1, error); 3044 Isolate::Current()->long_jump_base()->Jump(1, error);
3024 } 3045 }
3025 3046
3026 3047
3027 } // namespace dart 3048 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_builder.h ('k') | runtime/vm/parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698