src/Structures.h
author David Anderson <dvander@alliedmods.net>
Sat Jul 28 16:42:38 2012 -0700 (2012-07-28)
changeset 108 9dcf58a17d32
parent 86 32ad0523b309
child 146 dc7d3b7a918c
permissions -rw-r--r--
Stop using ccache on OS X.
     1 /* vim: set ts=4 sw=4 tw=99 et
     2  *
     3  * Copyright (C) 2012 David Anderson
     4  *
     5  * This file is part of JITCraft.
     6  *
     7  * JITCraft 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  * Foobar 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  * JITCraft. If not, see http://www.gnu.org/licenses/.
    18  */
    19 #ifndef _include_jc_structure_h_
    20 #define _include_jc_structure_h_
    21 
    22 #include "Objects.h"
    23 #include "Handles.h"
    24 #include "Vector.h"
    25 
    26 namespace ke {
    27 
    28 class Type;
    29 class String;
    30 class FixedArray;
    31 
    32 // When describing composite structures, the GC must be able to trace interior
    33 // references to Objects. To make this possible, maps that describe composite
    34 // structures must provide a list of offsets into their objects that are
    35 // traceable. StructureBufferBuilder assists with this.
    36 class StructureBufferBuilder
    37 {
    38   public:
    39     StructureBufferBuilder();
    40 
    41     bool add(Handle<Type> type, unsigned *offset);
    42 
    43     unsigned structureSize() const {
    44         return size_;
    45     }
    46     unsigned traceableOffsetCount() const {
    47         return offsets_.length();
    48     }
    49     const unsigned *offsets() {
    50         return offsets_.buffer();
    51     }
    52 
    53   private:
    54     Vector<unsigned> offsets_;
    55     unsigned size_;
    56 };
    57 
    58 }
    59 
    60 #endif // _include_jc_structure_h_