src/Reference.cpp
author David Anderson <dvander@alliedmods.net>
Sat Jan 12 16:35:26 2013 -0800 (2013-01-12)
changeset 260 05de34f712fe
parent 195 c1ba166f3fc4
child 263 ba85a47ee414
permissions -rw-r--r--
Add support for mutually recursive imports.
     1 /* vim: set ts=4 sw=4 tw=99 et:
     2  *
     3  * Copyright (C) 2012 David Anderson
     4  *
     5  * This file is part of SourcePawn.
     6  *
     7  * SourcePawn is free software: you can redistribute it and/or modify it under
     8  * the terms of the GNU General Public License as published by the Free
     9  * Software Foundation, either version 3 of the License, or (at your option)
    10  * any later version.
    11  * 
    12  * SourcePawn is distributed in the hope that it will be useful, but WITHOUT ANY
    13  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    14  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
    15  *
    16  * You should have received a copy of the GNU General Public License along with
    17  * SourcePawn. If not, see http://www.gnu.org/licenses/.
    18  */
    19 #include "Reference.h"
    20 #include "Zone.h"
    21 #include "Array.h"
    22 #include "Structures.h"
    23 #include "Heap-inl.h"
    24 
    25 using namespace ke;
    26 
    27 Reference *
    28 Reference::NewStack(Zone *zone, void *location, Heap::Tenure tenure)
    29 {
    30     Local<Reference> ref(zone, Reference::cast(zone->allocate(MapKind_Reference, sizeof(Reference), tenure)));
    31     if (!ref)
    32         return NULL;
    33 
    34     ref->location_ = location;
    35     ref->base_ = NULL;
    36     return ref;
    37 }
    38 
    39 Reference *
    40 Reference::NewStack(Zone *zone, const LocalSlot &slot, Heap::Tenure tenure)
    41 {
    42     Local<Reference> ref(zone, Reference::cast(zone->allocate(MapKind_Reference, sizeof(Reference), tenure)));
    43     if (!ref)
    44         return NULL;
    45 
    46     ref->location_ = &ref->slot_;
    47     ref->slot_ = slot;
    48     ref->base_ = NULL;
    49     return ref;
    50 }
    51