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