src/Modules.cpp
author David Anderson <dvander@alliedmods.net>
Mon Jul 30 12:13:22 2012 -0700 (2012-07-30)
changeset 142 a000bafece09
parent 86 32ad0523b309
child 195 c1ba166f3fc4
permissions -rw-r--r--
Implement re-tag unary expression.
     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 #include "Modules.h"
    19 #include "Zone.h"
    20 #include "Heap.h"
    21 #include "Heap-inl.h"
    22 
    23 using namespace ke;
    24 
    25 Module *
    26 Module::New(Zone *zone, unsigned nfunctions)
    27 {
    28     Local<Module> module(zone, Module::cast(zone->allocate(MapKind_Module, sizeof(Module), Heap::Tenure_Old)));
    29     if (!module)
    30         return NULL;
    31 
    32     Local<FixedArray> functions(zone, FixedArray::New(zone, nfunctions, Heap::Tenure_Old));
    33     if (!functions)
    34         return NULL;
    35 
    36     module->functions_ = functions;
    37     module->file_ = NULL;
    38     module->publics_ = NULL;
    39     module->natives_ = NULL;
    40     module->environment_ = NULL;
    41     module->nativeIdentity_ = NULL;
    42     return module;
    43 }