| 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 #include "platform/assert.h" | 6 #include "platform/assert.h" |
| 7 #include "vm/class_finalizer.h" | 7 #include "vm/class_finalizer.h" |
| 8 #include "vm/compiler.h" | 8 #include "vm/compiler.h" |
| 9 #include "vm/dart_api_impl.h" | 9 #include "vm/dart_api_impl.h" |
| 10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 | 144 |
| 145 static Dart_NativeFunction native_lookup(Dart_Handle name, | 145 static Dart_NativeFunction native_lookup(Dart_Handle name, |
| 146 int argument_count) { | 146 int argument_count) { |
| 147 const Object& obj = Object::Handle(Api::UnwrapHandle(name)); | 147 const Object& obj = Object::Handle(Api::UnwrapHandle(name)); |
| 148 ASSERT(obj.IsString()); | 148 ASSERT(obj.IsString()); |
| 149 const char* function_name = obj.ToCString(); | 149 const char* function_name = obj.ToCString(); |
| 150 ASSERT(function_name != NULL); | 150 ASSERT(function_name != NULL); |
| 151 int num_entries = sizeof(BuiltinEntries) / sizeof(struct NativeEntries); | 151 int num_entries = sizeof(BuiltinEntries) / sizeof(struct NativeEntries); |
| 152 for (int i = 0; i < num_entries; i++) { | 152 for (int i = 0; i < num_entries; i++) { |
| 153 struct NativeEntries* entry = &(BuiltinEntries[i]); | 153 struct NativeEntries* entry = &(BuiltinEntries[i]); |
| 154 if (!strcmp(function_name, entry->name_)) { | 154 if (!strcmp(function_name, entry->name_) && |
| 155 if (entry->argument_count_ == argument_count) { | 155 (entry->argument_count_ == argument_count)) { |
| 156 return reinterpret_cast<Dart_NativeFunction>(entry->function_); | 156 return reinterpret_cast<Dart_NativeFunction>(entry->function_); |
| 157 } else { | |
| 158 // Wrong number of arguments. | |
| 159 // TODO(regis): Should we pass a buffer for error reporting? | |
| 160 return NULL; | |
| 161 } | |
| 162 } | 157 } |
| 163 } | 158 } |
| 164 return NULL; | 159 return NULL; |
| 165 } | 160 } |
| 166 | 161 |
| 167 | 162 |
| 168 // Unit test case to verify stack frame iteration. | 163 // Unit test case to verify stack frame iteration. |
| 169 TEST_CASE(ValidateStackFrameIteration) { | 164 TEST_CASE(ValidateStackFrameIteration) { |
| 170 const char* kScriptChars = | 165 const char* kScriptChars = |
| 171 "class StackFrame {" | 166 "class StackFrame {" |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 "}"; | 285 "}"; |
| 291 Dart_Handle lib = TestCase::LoadTestScript( | 286 Dart_Handle lib = TestCase::LoadTestScript( |
| 292 kScriptChars, | 287 kScriptChars, |
| 293 reinterpret_cast<Dart_NativeEntryResolver>(native_lookup)); | 288 reinterpret_cast<Dart_NativeEntryResolver>(native_lookup)); |
| 294 Dart_Handle cls = Dart_GetClass(lib, Dart_NewString("StackFrame2Test")); | 289 Dart_Handle cls = Dart_GetClass(lib, Dart_NewString("StackFrame2Test")); |
| 295 EXPECT_VALID(Dart_Invoke(cls, Dart_NewString("testMain"), 0, NULL)); | 290 EXPECT_VALID(Dart_Invoke(cls, Dart_NewString("testMain"), 0, NULL)); |
| 296 } | 291 } |
| 297 #endif // TARGET_ARCH_IA32 || TARGET_ARCH_X64. | 292 #endif // TARGET_ARCH_IA32 || TARGET_ARCH_X64. |
| 298 | 293 |
| 299 } // namespace dart | 294 } // namespace dart |
| OLD | NEW |