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 #ifndef SRC_VM_PROGRAM_INFO_BLOCK_H_ | 5 #ifndef SRC_VM_PROGRAM_INFO_BLOCK_H_ |
6 #define SRC_VM_PROGRAM_INFO_BLOCK_H_ | 6 #define SRC_VM_PROGRAM_INFO_BLOCK_H_ |
7 | 7 |
8 #include "src/vm/program.h" | 8 #include "src/vm/program.h" |
9 | 9 |
10 namespace fletch { | 10 namespace dartino { |
11 class ProgramInfoBlock { | 11 class ProgramInfoBlock { |
12 public: | 12 public: |
13 ProgramInfoBlock(); | 13 ProgramInfoBlock(); |
14 | 14 |
15 void PopulateFromProgram(Program* program); | 15 void PopulateFromProgram(Program* program); |
16 void WriteToProgram(Program* program); | 16 void WriteToProgram(Program* program); |
17 | 17 |
18 Object** roots() { return &entry_; } | 18 Object** roots() { return &entry_; } |
19 | 19 |
20 void* end_of_roots() { return &main_arity_; } | 20 void* end_of_roots() { return &main_arity_; } |
21 | 21 |
22 void set_main_arity(int arity) { main_arity_ = arity; } | 22 void set_main_arity(int arity) { main_arity_ = arity; } |
23 int main_arity() { return main_arity_; } | 23 int main_arity() { return main_arity_; } |
24 | 24 |
25 private: | 25 private: |
26 // This has to remain in sync with all the roots that are traversed by | 26 // This has to remain in sync with all the roots that are traversed by |
27 // IterateRoots in Program. Also, the type does not really matter as long | 27 // IterateRoots in Program. Also, the type does not really matter as long |
28 // as it also is a pointer type and they won't be used in order (as in | 28 // as it also is a pointer type and they won't be used in order (as in |
29 // their names are meaningless). | 29 // their names are meaningless). |
30 Object* entry_; | 30 Object* entry_; |
31 #define ROOT_DECLARATION(type, name, CamelName) type* name##_; | 31 #define ROOT_DECLARATION(type, name, CamelName) type* name##_; |
32 ROOTS_DO(ROOT_DECLARATION) | 32 ROOTS_DO(ROOT_DECLARATION) |
33 #undef ROOT_DECLARATION | 33 #undef ROOT_DECLARATION |
34 // We also store the arity of main. This field is also used as a marker | 34 // We also store the arity of main. This field is also used as a marker |
35 // of the end of the roots data structure. | 35 // of the end of the roots data structure. |
36 intptr_t main_arity_; | 36 intptr_t main_arity_; |
37 }; | 37 }; |
38 | 38 |
39 } // namespace fletch | 39 } // namespace dartino |
40 #endif // SRC_VM_PROGRAM_INFO_BLOCK_H_ | 40 #endif // SRC_VM_PROGRAM_INFO_BLOCK_H_ |
OLD | NEW |