src/GlobalRoots.cpp
author Asher Baker <asherkin@gmail.com>
Mon Jun 10 15:52:44 2013 +0100 (2013-06-10)
changeset 265 3a903b89a514
parent 262 c4b1341297e5
permissions -rw-r--r--
Fixed type checking for multidimensional arrays.
     1 /* vim: set ts=4 sw=4 tw=99 et:
     2  *
     3  * Copyright (C) 2004-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 "GlobalRoots.h"
    20 #include "Zone.h"
    21 #include "Spaces-inl.h"
    22 #include "Heap-inl.h"
    23 
    24 using namespace ke;
    25 
    26 GlobalRoots::GlobalRoots(Zone *zone)
    27 {
    28 }
    29 
    30 GlobalRoots::~GlobalRoots()
    31 {
    32     InlineList<HeapRoot>::iterator iter = roots_.begin();
    33     while (iter != roots_.end()) {
    34         HeapRoot *root = *iter;
    35         iter = roots_.erase(iter);
    36         delete root;
    37     }
    38 }
    39 
    40 bool
    41 GlobalRoots::initialize()
    42 {
    43     return true;
    44 }
    45 
    46 void
    47 GlobalRoots::accept(VirtualObjectVisitor *visitor)
    48 {
    49     for (InlineList<HeapRoot>::iterator iter = roots_.begin(); iter != roots_.end(); iter++)
    50         visitor->visit(&iter->obj);
    51 }
    52 
    53 HeapRoot *
    54 GlobalRoots::create()
    55 {
    56     HeapRoot *root = new HeapRoot();
    57     if (!root) {
    58         ZONE()->reportOutOfMemory();
    59         return NULL;
    60     }
    61 
    62     root->obj = NULL;
    63 
    64     roots_.append(root);
    65     return root;
    66 }
    67 
    68 void
    69 GlobalRoots::destroy(HeapRoot *root)
    70 {
    71     roots_.remove(root);
    72     delete root;
    73 }