src/Modules.cpp
author Michael Busby <prodigysim@gmail.com>
Mon Jun 10 01:50:18 2013 +0100 (2013-06-10)
changeset 264 70b8f318c379
parent 263 ba85a47ee414
permissions -rw-r--r--
Parse assignment RTL instead of LTR, fixes multiple assignment (bug 5420).
asherkin@263
     1
/*
asherkin@263
     2
 * Copyright (C) 2012 David Anderson
asherkin@263
     3
 *
asherkin@263
     4
 * This file is part of JITCraft.
asherkin@263
     5
 *
asherkin@263
     6
 * JITCraft is free software: you can redistribute it and/or modify it under
asherkin@263
     7
 * the terms of the GNU General Public License as published by the Free
asherkin@263
     8
 * Software Foundation, either version 3 of the License, or (at your option)
asherkin@263
     9
 * any later version.
asherkin@263
    10
 * 
asherkin@263
    11
 * Foobar is distributed in the hope that it will be useful, but WITHOUT ANY
asherkin@263
    12
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
asherkin@263
    13
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
asherkin@263
    14
 *
asherkin@263
    15
 * You should have received a copy of the GNU General Public License along with
asherkin@263
    16
 * JITCraft. If not, see http://www.gnu.org/licenses/.
asherkin@263
    17
 */
asherkin@263
    18
#include "Modules.h"
asherkin@263
    19
#include "Zone.h"
asherkin@263
    20
#include "Heap.h"
asherkin@263
    21
#include "Heap-inl.h"
asherkin@263
    22
asherkin@263
    23
using namespace ke;
asherkin@263
    24
asherkin@263
    25
Module *
asherkin@263
    26
Module::New(Zone *zone, Handle<Package> package, Handle<String> path, Handle<String> name)
asherkin@263
    27
{
asherkin@263
    28
    Local<Module> module(zone, Module::cast(zone->allocate(MapKind_Module, sizeof(Module), Heap::Tenure_Old)));
asherkin@263
    29
    if (!module)
asherkin@263
    30
        return NULL;
asherkin@263
    31
asherkin@263
    32
    module->parent_ = package;
asherkin@263
    33
    module->path_ = path;
asherkin@263
    34
    module->name_ = name;
asherkin@263
    35
    module->globals_ = NULL;
asherkin@263
    36
    module->nativeIdentity_ = NULL;
asherkin@263
    37
    module->globals_ = NULL;
asherkin@263
    38
    module->unit_ = NULL;
asherkin@263
    39
    return module;
asherkin@263
    40
}