Fix opt clang build.
2 * Copyright (C) 2012 David Anderson
4 * This file is part of JITCraft.
6 * JITCraft is free software: you can redistribute it and/or modify it under
7 * the terms of the GNU General Public License as published by the Free
8 * Software Foundation, either version 3 of the License, or (at your option)
11 * Foobar is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along with
16 * JITCraft. If not, see http://www.gnu.org/licenses/.
18 #ifndef _include_jc_module_h_
19 #define _include_jc_module_h_
23 #include "Functions.h"
29 class Module : public Object
31 Barriered<FixedArray> functions_;
32 Barriered<FixedArray> publics_;
33 Barriered<FixedArray> natives_;
34 Barriered<String> file_;
35 Barriered<Environment> environment_;
36 Barriered<Code> code_;
37 void *nativeIdentity_;
40 static Module *New(Zone *zone, unsigned nfunctions);
42 Function *getFunction(size_t i) {
43 return Function::cast(functions_->at(i));
45 void setFunction(Zone *zone, size_t i, Function *fun) {
46 assert(!functions_->at(i));
48 functions_->set(zone, i, fun);
51 FixedArray *publics() {
54 FixedArray *natives() {
60 Environment *environment() {
67 void setPublics(Handle<FixedArray> publics) {
70 void setNatives(Handle<FixedArray> natives) {
73 void setPath(Handle<String> path) {
76 void setEnvironment(Handle<Environment> environment) {
77 environment_ = environment;
79 void setCode(Handle<Code> code) {
83 void *nativeIdentity() {
84 return nativeIdentity_;
86 void setNativeIdentity(void *identity) {
87 nativeIdentity_ = identity;
90 // Begin GC Descriptor.
91 static inline size_t offsetOfFunctions() {
92 return OFFSETOF(Module, functions_);
94 static inline size_t offsetOfPublics() {
95 return OFFSETOF(Module, publics_);
97 static inline size_t offsetOfNatives() {
98 return OFFSETOF(Module, natives_);
100 static inline size_t offsetOfFile() {
101 return OFFSETOF(Module, file_);
103 static inline size_t offsetOfEnvironment() {
104 return OFFSETOF(Module, environment_);
106 static inline size_t offsetOfCode() {
107 return OFFSETOF(Module, code_);
109 // End GC Descriptor.
111 static inline Module *cast(Object *obj) {
112 assert(!obj || obj->is(MapKind_Module));
113 return reinterpret_cast<Module *>(obj);
119 #endif // _include_jc_module_h_