asherkin@263: /* vim: set ts=4 sw=4 tw=99 et: asherkin@263: * asherkin@263: * Copyright (C) 2012 David Anderson asherkin@263: * asherkin@263: * This file is part of SourcePawn. asherkin@263: * asherkin@263: * SourcePawn is free software: you can redistribute it and/or modify it under asherkin@263: * the terms of the GNU General Public License as published by the Free asherkin@263: * Software Foundation, either version 3 of the License, or (at your option) asherkin@263: * any later version. asherkin@263: * asherkin@263: * SourcePawn is distributed in the hope that it will be useful, but WITHOUT ANY asherkin@263: * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS asherkin@263: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. asherkin@263: * asherkin@263: * You should have received a copy of the GNU General Public License along with asherkin@263: * SourcePawn. If not, see http://www.gnu.org/licenses/. asherkin@263: */ asherkin@263: #include "Reference.h" asherkin@263: #include "Zone.h" asherkin@263: #include "Array.h" asherkin@263: #include "Structures.h" asherkin@263: #include "Heap-inl.h" asherkin@263: asherkin@263: using namespace ke; asherkin@263: asherkin@263: Reference * asherkin@263: Reference::NewStack(Zone *zone, void *location, Heap::Tenure tenure) asherkin@263: { asherkin@263: Local ref(zone, Reference::cast(zone->allocate(MapKind_Reference, sizeof(Reference), tenure))); asherkin@263: if (!ref) asherkin@263: return NULL; asherkin@263: asherkin@263: ref->location_ = location; asherkin@263: ref->base_ = NULL; asherkin@263: return ref; asherkin@263: } asherkin@263: asherkin@263: Reference * asherkin@263: Reference::NewStack(Zone *zone, const LocalSlot &slot, Heap::Tenure tenure) asherkin@263: { asherkin@263: Local ref(zone, Reference::cast(zone->allocate(MapKind_Reference, sizeof(Reference), tenure))); asherkin@263: if (!ref) asherkin@263: return NULL; asherkin@263: asherkin@263: ref->location_ = &ref->slot_; asherkin@263: ref->slot_ = slot; asherkin@263: ref->base_ = NULL; asherkin@263: return ref; asherkin@263: } asherkin@263: