dvander@85: /* vim: set ts=4 sw=4 tw=99 et dvander@85: * dvander@85: * Copyright (C) 2012 David Anderson dvander@85: * dvander@85: * This file is part of JITCraft. dvander@85: * dvander@85: * JITCraft is free software: you can redistribute it and/or modify it under dvander@85: * the terms of the GNU General Public License as published by the Free dvander@85: * Software Foundation, either version 3 of the License, or (at your option) dvander@85: * any later version. dvander@85: * dvander@85: * Foobar is distributed in the hope that it will be useful, but WITHOUT ANY dvander@85: * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS dvander@85: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. dvander@85: * dvander@85: * You should have received a copy of the GNU General Public License along with dvander@85: * JITCraft. If not, see http://www.gnu.org/licenses/. dvander@85: */ dvander@85: #ifndef _include_jc_structure_h_ dvander@85: #define _include_jc_structure_h_ dvander@85: dvander@85: #include "Objects.h" dvander@85: #include "Handles.h" dvander@85: #include "Vector.h" dvander@85: dvander@85: namespace ke { dvander@85: dvander@85: class Type; dvander@85: class String; dvander@85: class FixedArray; dvander@85: dvander@85: // When describing composite structures, the GC must be able to trace interior dvander@85: // references to Objects. To make this possible, maps that describe composite dvander@85: // structures must provide a list of offsets into their objects that are dvander@85: // traceable. StructureBufferBuilder assists with this. dvander@85: class StructureBufferBuilder dvander@85: { dvander@85: public: dvander@85: StructureBufferBuilder(); dvander@85: dvander@85: bool add(Handle type, unsigned *offset); dvander@85: dvander@85: unsigned structureSize() const { dvander@85: return size_; dvander@85: } dvander@85: unsigned traceableOffsetCount() const { dvander@85: return offsets_.length(); dvander@85: } dvander@85: const unsigned *offsets() { dvander@85: return offsets_.buffer(); dvander@85: } dvander@85: dvander@85: private: dvander@85: Vector offsets_; dvander@85: unsigned size_; dvander@85: }; dvander@85: dvander@85: } dvander@85: dvander@85: #endif // _include_jc_structure_h_