src/Modules.h
author David Anderson <dvander@alliedmods.net>
Wed Dec 26 17:20:55 2012 -0800 (2012-12-26)
changeset 244 3c57bbf22aa2
parent 195 c1ba166f3fc4
child 251 ca99a81745fe
permissions -rw-r--r--
Fix clang bustage.
     1 /*
     2  * Copyright (C) 2012 David Anderson
     3  *
     4  * This file is part of JITCraft.
     5  *
     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)
     9  * any later version.
    10  * 
    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.
    14  *
    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/.
    17  */
    18 #ifndef _include_jc_module_h_
    19 #define _include_jc_module_h_
    20 
    21 #include "Heap.h"
    22 #include "Code.h"
    23 #include "Functions.h"
    24 
    25 namespace ke {
    26 
    27 class Environment;
    28 class Struct;
    29 
    30 class Module : public Object
    31 {
    32     Barriered<String> file_;
    33     Barriered<Code> code_;
    34     Barriered<Struct> globals_;
    35     void *nativeIdentity_;
    36 
    37   public:
    38     static Module *New(Zone *zone);
    39     
    40     String *file() {
    41         return file_;
    42     }
    43     Code *code() {
    44         return code_;
    45     }
    46     Struct *globals() {
    47         return globals_;
    48     }
    49 
    50     void setPath(Handle<String> path) {
    51         file_ = path;
    52     }
    53     void setCode(Handle<Code> code) {
    54         code_ = code;
    55     }
    56     void setGlobals(Handle<Struct> globals) {
    57         globals_ = globals;
    58     }
    59 
    60     void *nativeIdentity() {
    61         return nativeIdentity_;
    62     }
    63     void setNativeIdentity(void *identity) {
    64         nativeIdentity_ = identity;
    65     }
    66 
    67     // Begin GC Descriptor.
    68     static inline size_t offsetOfFile() {
    69         return OFFSETOF(Module, file_);
    70     }
    71     static inline size_t offsetOfCode() {
    72         return OFFSETOF(Module, code_);
    73     }
    74     static inline size_t offsetOfGlobals() {
    75         return OFFSETOF(Module, globals_);
    76     }
    77     // End GC Descriptor.
    78 
    79     static inline Module *cast(Object *obj) {
    80         assert(!obj || obj->is(MapKind_Module));
    81         return reinterpret_cast<Module *>(obj);
    82     }
    83 };
    84 
    85 }
    86 
    87 #endif // _include_jc_module_h_