src/Modules.cpp
changeset 86 32ad0523b309
parent 85 06a0015b6a5c
child 195 c1ba166f3fc4
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/Modules.cpp	Tue Jul 24 23:53:34 2012 -0700
     1.3 @@ -0,0 +1,43 @@
     1.4 +/*
     1.5 + * Copyright (C) 2012 David Anderson
     1.6 + *
     1.7 + * This file is part of JITCraft.
     1.8 + *
     1.9 + * JITCraft is free software: you can redistribute it and/or modify it under
    1.10 + * the terms of the GNU General Public License as published by the Free
    1.11 + * Software Foundation, either version 3 of the License, or (at your option)
    1.12 + * any later version.
    1.13 + * 
    1.14 + * Foobar is distributed in the hope that it will be useful, but WITHOUT ANY
    1.15 + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    1.16 + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License along with
    1.19 + * JITCraft. If not, see http://www.gnu.org/licenses/.
    1.20 + */
    1.21 +#include "Modules.h"
    1.22 +#include "Zone.h"
    1.23 +#include "Heap.h"
    1.24 +#include "Heap-inl.h"
    1.25 +
    1.26 +using namespace ke;
    1.27 +
    1.28 +Module *
    1.29 +Module::New(Zone *zone, unsigned nfunctions)
    1.30 +{
    1.31 +    Local<Module> module(zone, Module::cast(zone->allocate(MapKind_Module, sizeof(Module), Heap::Tenure_Old)));
    1.32 +    if (!module)
    1.33 +        return NULL;
    1.34 +
    1.35 +    Local<FixedArray> functions(zone, FixedArray::New(zone, nfunctions, Heap::Tenure_Old));
    1.36 +    if (!functions)
    1.37 +        return NULL;
    1.38 +
    1.39 +    module->functions_ = functions;
    1.40 +    module->file_ = NULL;
    1.41 +    module->publics_ = NULL;
    1.42 +    module->natives_ = NULL;
    1.43 +    module->environment_ = NULL;
    1.44 +    module->nativeIdentity_ = NULL;
    1.45 +    return module;
    1.46 +}