| 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 "include/dart_api.h" | 5 #include "include/dart_api.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/dart.h" | 10 #include "vm/dart.h" | 
| (...skipping 3001 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3012               lookup_class_name.ToCString())); | 3012               lookup_class_name.ToCString())); | 
| 3013       return ApiError::New(message); | 3013       return ApiError::New(message); | 
| 3014     } else { | 3014     } else { | 
| 3015       const String& message = String::Handle( | 3015       const String& message = String::Handle( | 
| 3016           String::NewFormatted("%s: could not find constructor '%s'.", | 3016           String::NewFormatted("%s: could not find constructor '%s'.", | 
| 3017                                current_func, constr_name.ToCString())); | 3017                                current_func, constr_name.ToCString())); | 
| 3018       return ApiError::New(message); | 3018       return ApiError::New(message); | 
| 3019     } | 3019     } | 
| 3020   } | 3020   } | 
| 3021   int extra_args = (constructor.IsConstructor() ? 2 : 1); | 3021   int extra_args = (constructor.IsConstructor() ? 2 : 1); | 
| 3022   if (!constructor.AreValidArgumentCounts(num_args + extra_args, 0)) { | 3022   String& error_message = String::Handle(); | 
|  | 3023   if (!constructor.AreValidArgumentCounts(num_args + extra_args, | 
|  | 3024                                           0, | 
|  | 3025                                           &error_message)) { | 
| 3023     const String& message = String::Handle( | 3026     const String& message = String::Handle( | 
| 3024         String::NewFormatted("%s: wrong argument count for constructor '%s': " | 3027         String::NewFormatted("%s: wrong argument count for " | 
| 3025                              "expected %d but saw %d.", | 3028                              "constructor '%s': %s.", | 
| 3026                              current_func, | 3029                              current_func, | 
| 3027                              constr_name.ToCString(), | 3030                              constr_name.ToCString(), | 
| 3028                              constructor.num_fixed_parameters() - extra_args, | 3031                              error_message.ToCString())); | 
| 3029                              num_args)); |  | 
| 3030     return ApiError::New(message); | 3032     return ApiError::New(message); | 
| 3031   } | 3033   } | 
| 3032   return constructor.raw(); | 3034   return constructor.raw(); | 
| 3033 } | 3035 } | 
| 3034 | 3036 | 
| 3035 | 3037 | 
| 3036 DART_EXPORT Dart_Handle Dart_New(Dart_Handle clazz, | 3038 DART_EXPORT Dart_Handle Dart_New(Dart_Handle clazz, | 
| 3037                                  Dart_Handle constructor_name, | 3039                                  Dart_Handle constructor_name, | 
| 3038                                  int number_of_arguments, | 3040                                  int number_of_arguments, | 
| 3039                                  Dart_Handle* arguments) { | 3041                                  Dart_Handle* arguments) { | 
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3266     // Finalize all classes if needed. | 3268     // Finalize all classes if needed. | 
| 3267     if (finalize_classes) { | 3269     if (finalize_classes) { | 
| 3268       const char* msg = CheckIsolateState(isolate); | 3270       const char* msg = CheckIsolateState(isolate); | 
| 3269       if (msg != NULL) { | 3271       if (msg != NULL) { | 
| 3270         return Api::NewError(msg); | 3272         return Api::NewError(msg); | 
| 3271       } | 3273       } | 
| 3272     } | 3274     } | 
| 3273 | 3275 | 
| 3274     Function& function = Function::Handle(isolate); | 3276     Function& function = Function::Handle(isolate); | 
| 3275     function = lib.LookupFunctionAllowPrivate(function_name); | 3277     function = lib.LookupFunctionAllowPrivate(function_name); | 
| 3276     // LookupFunctionAllowPrivate does not check argument arity, so we |  | 
| 3277     // do it here. |  | 
| 3278     if (!function.IsNull() && |  | 
| 3279         !function.AreValidArgumentCounts(number_of_arguments, 0)) { |  | 
| 3280       function = Function::null(); |  | 
| 3281     } |  | 
| 3282     if (function.IsNull()) { | 3278     if (function.IsNull()) { | 
| 3283       return Api::NewError("%s: did not find top-level function '%s'.", | 3279       return Api::NewError("%s: did not find top-level function '%s'.", | 
| 3284                            CURRENT_FUNC, | 3280                            CURRENT_FUNC, | 
| 3285                            function_name.ToCString()); | 3281                            function_name.ToCString()); | 
| 3286     } | 3282     } | 
|  | 3283     // LookupFunctionAllowPrivate does not check argument arity, so we | 
|  | 3284     // do it here. | 
|  | 3285     String& error_message = String::Handle(); | 
|  | 3286     if (!function.AreValidArgumentCounts(number_of_arguments, | 
|  | 3287                                          0, | 
|  | 3288                                          &error_message)) { | 
|  | 3289       return Api::NewError("%s: wrong argument count for function '%s': %s.", | 
|  | 3290                            CURRENT_FUNC, | 
|  | 3291                            function_name.ToCString(), | 
|  | 3292                            error_message.ToCString()); | 
|  | 3293     } | 
| 3287     return Api::NewHandle( | 3294     return Api::NewHandle( | 
| 3288         isolate, DartEntry::InvokeStatic(function, args, kNoArgNames)); | 3295         isolate, DartEntry::InvokeStatic(function, args, kNoArgNames)); | 
| 3289 | 3296 | 
| 3290   } else { | 3297   } else { | 
| 3291     return Api::NewError( | 3298     return Api::NewError( | 
| 3292         "%s expects argument 'target' to be an object, class, or library.", | 3299         "%s expects argument 'target' to be an object, class, or library.", | 
| 3293         CURRENT_FUNC); | 3300         CURRENT_FUNC); | 
| 3294   } | 3301   } | 
| 3295 } | 3302 } | 
| 3296 | 3303 | 
| (...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 4113     *buffer_size = 0; | 4120     *buffer_size = 0; | 
| 4114   } | 4121   } | 
| 4115 } | 4122 } | 
| 4116 | 4123 | 
| 4117 | 4124 | 
| 4118 DART_EXPORT void Dart_InitFlowGraphPrinting(FileWriterFunction function) { | 4125 DART_EXPORT void Dart_InitFlowGraphPrinting(FileWriterFunction function) { | 
| 4119   Dart::set_flow_graph_writer(function); | 4126   Dart::set_flow_graph_writer(function); | 
| 4120 } | 4127 } | 
| 4121 | 4128 | 
| 4122 }  // namespace dart | 4129 }  // namespace dart | 
| OLD | NEW | 
|---|