src/Modules.cpp
author David Anderson <dvander@alliedmods.net>
Sat Jan 12 16:35:26 2013 -0800 (2013-01-12)
changeset 260 05de34f712fe
parent 251 ca99a81745fe
child 263 ba85a47ee414
permissions -rw-r--r--
Add support for mutually recursive imports.
     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, Handle<Package> package, Handle<String> path, Handle<String> name)
    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     module->parent_ = package;
    33     module->path_ = path;
    34     module->name_ = name;
    35     module->globals_ = NULL;
    36     module->nativeIdentity_ = NULL;
    37     module->globals_ = NULL;
    38     module->unit_ = NULL;
    39     return module;
    40 }