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/bootstrap_natives.h" | 5 #include "vm/bootstrap_natives.h" |
6 | 6 |
7 #include "vm/exceptions.h" | 7 #include "vm/exceptions.h" |
8 #include "vm/native_entry.h" | 8 #include "vm/native_entry.h" |
9 #include "vm/object.h" | 9 #include "vm/object.h" |
10 | 10 |
11 namespace dart { | 11 namespace dart { |
12 | 12 |
13 DEFINE_NATIVE_ENTRY(Object_toString, 1) { | 13 DEFINE_NATIVE_ENTRY(Object_toString, 1) { |
14 const Instance& instance = Instance::CheckedHandle(arguments->NativeArgAt(0)); | 14 const Instance& instance = Instance::CheckedHandle(arguments->NativeArgAt(0)); |
15 const char* c_str = instance.ToCString(); | 15 const char* c_str = instance.ToCString(); |
16 return String::New(c_str); | 16 return String::New(c_str); |
17 } | 17 } |
18 | 18 |
19 | 19 |
20 DEFINE_NATIVE_ENTRY(Object_noSuchMethod, 3) { | 20 DEFINE_NATIVE_ENTRY(Object_noSuchMethod, 3) { |
21 const Instance& instance = | 21 const Instance& instance = |
22 Instance::CheckedHandle(arguments->NativeArgAt(0)); | 22 Instance::CheckedHandle(arguments->NativeArgAt(0)); |
23 GET_NATIVE_ARGUMENT(String, function_name, arguments->NativeArgAt(1)); | 23 GET_NATIVE_ARGUMENT(String, function_name, arguments->NativeArgAt(1)); |
24 GET_NATIVE_ARGUMENT(Array, func_args, arguments->NativeArgAt(2)); | 24 GET_NATIVE_ARGUMENT(Array, func_args, arguments->NativeArgAt(2)); |
25 if (instance.IsNull()) { | |
26 GrowableArray<const Object*> args; | |
27 args.Add(&function_name); | |
28 args.Add(&func_args); | |
29 Exceptions::ThrowByType(Exceptions::kNullPointer, args); | |
30 } | |
31 const Object& null_object = Object::Handle(Object::null()); | 25 const Object& null_object = Object::Handle(Object::null()); |
32 GrowableArray<const Object*> dart_arguments(3); | 26 GrowableArray<const Object*> dart_arguments(4); |
33 dart_arguments.Add(&instance); | 27 dart_arguments.Add(&instance); |
34 dart_arguments.Add(&function_name); | 28 dart_arguments.Add(&function_name); |
35 dart_arguments.Add(&func_args); | 29 dart_arguments.Add(&func_args); |
36 dart_arguments.Add(&null_object); | 30 dart_arguments.Add(&null_object); |
37 | 31 |
38 // Report if a function with same name (but different arguments) has been | 32 // Report if a function with same name (but different arguments) has been |
39 // found. | 33 // found. |
40 Class& instance_class = Class::Handle(instance.clazz()); | 34 Class& instance_class = Class::Handle(instance.clazz()); |
41 Function& function = | 35 Function& function = |
42 Function::Handle(instance_class.LookupDynamicFunction(function_name)); | 36 Function::Handle(instance_class.LookupDynamicFunction(function_name)); |
(...skipping 23 matching lines...) Expand all Loading... |
66 } | 60 } |
67 | 61 |
68 | 62 |
69 DEFINE_NATIVE_ENTRY(AbstractType_toString, 1) { | 63 DEFINE_NATIVE_ENTRY(AbstractType_toString, 1) { |
70 const AbstractType& type = | 64 const AbstractType& type = |
71 AbstractType::CheckedHandle(arguments->NativeArgAt(0)); | 65 AbstractType::CheckedHandle(arguments->NativeArgAt(0)); |
72 return type.Name(); | 66 return type.Name(); |
73 } | 67 } |
74 | 68 |
75 } // namespace dart | 69 } // namespace dart |
OLD | NEW |