jitcraft/Modules.h
author David Anderson <dvander@alliedmods.net>
Mon Jul 02 01:24:57 2012 -0700 (2012-07-02)
changeset 25 23e8b3d8e4e6
parent 14 0784ac5cc347
child 26 a48382113da6
permissions -rw-r--r--
Scanning, parsing, and static analysis now report errors properly.
     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 
    24 namespace jc {
    25 
    26 class Module : public Object
    27 {
    28     Barriered<FixedArray> functions_;
    29 
    30   public:
    31     static Module *New(Zone *zone, unsigned nfunctions);
    32 
    33     Code *getFunction(size_t i) {
    34         return Code::cast(functions_->at(i));
    35     }
    36     void setFunction(Zone *zone, size_t i, Code *code) {
    37         assert(!functions_->at(i));
    38         assert(code);
    39         functions_->set(zone, i, code);
    40     }
    41 
    42     static inline Module *cast(Object *obj) {
    43         assert(!obj || obj->is(MapKind_Module));
    44         return reinterpret_cast<Module *>(obj);
    45     }
    46 };
    47 
    48 }
    49 
    50 #endif // _include_jc_module_h_