OLD | NEW |
1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dartino 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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
4 | 4 |
5 #include "src/vm/intrinsics.h" | 5 #include "src/vm/intrinsics.h" |
6 | 6 |
7 #include "src/shared/assert.h" | 7 #include "src/shared/assert.h" |
8 | 8 |
9 namespace fletch { | 9 namespace dartino { |
10 | 10 |
11 IntrinsicsTable* IntrinsicsTable::default_table_ = NULL; | 11 IntrinsicsTable* IntrinsicsTable::default_table_ = NULL; |
12 | 12 |
13 IntrinsicsTable* IntrinsicsTable::GetDefault() { | 13 IntrinsicsTable* IntrinsicsTable::GetDefault() { |
14 if (default_table_ == NULL) { | 14 if (default_table_ == NULL) { |
15 default_table_ = new IntrinsicsTable( | 15 default_table_ = new IntrinsicsTable( |
16 #define ADDRESS_GETTER(name) &Intrinsic_##name, | 16 #define ADDRESS_GETTER(name) &Intrinsic_##name, |
17 INTRINSICS_DO(ADDRESS_GETTER) | 17 INTRINSICS_DO(ADDRESS_GETTER) |
18 #undef ADDRESS_GETTER | 18 #undef ADDRESS_GETTER |
19 NULL); | 19 NULL); |
20 } | 20 } |
21 return default_table_; | 21 return default_table_; |
22 } | 22 } |
23 | 23 |
24 bool IntrinsicsTable::set_from_string(const char* name, void (*ptr)(void)) { | 24 bool IntrinsicsTable::set_from_string(const char* name, void (*ptr)(void)) { |
25 #define SET_INTRINSIC(name_) \ | 25 #define SET_INTRINSIC(name_) \ |
26 if (strcmp(#name_, name) == 0) { \ | 26 if (strcmp(#name_, name) == 0) { \ |
27 intrinsic_##name_##_ = ptr; \ | 27 intrinsic_##name_##_ = ptr; \ |
28 return true; \ | 28 return true; \ |
29 } | 29 } |
30 INTRINSICS_DO(SET_INTRINSIC) | 30 INTRINSICS_DO(SET_INTRINSIC) |
31 #undef SET_INTRINSIC | 31 #undef SET_INTRINSIC |
32 return false; | 32 return false; |
33 } | 33 } |
34 | 34 |
35 } // namespace fletch | 35 } // namespace dartino |
OLD | NEW |