Fix linux/mac support.
1 /* vim: set ts=4 sw=4 tw=99 et:
3 * Copyright (C) 2012 David Anderson
5 * This file is part of SourcePawn.
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)
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.
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/.
19 #ifndef _include_jitcraft_objects_h_
20 #define _include_jitcraft_objects_h_
30 // Garbage-collection objects require a header to describe their layout. This
31 // header is called a "map". The different kinds of maps are enumerated below.
36 // Represents Type objects.
41 MapKind_ReferenceType,
44 // Represents basic data structures. When adding to this, don't forget
45 // to update Zone::initialize(), or you'll get a NULL crash trying to
46 // allocate, since these maps are cached.
55 MapKind_FreeRegion, // Special map denoting freed space.
56 MapKind_EnvironmentSlotDescriptorArray,
63 // These do not have canonical maps.
65 MapKind_DependentArray,
68 // These represent special Map subclasses that require special tracing.
70 MapKind_Meta, // (default map class)
71 MapKind_MetaArray, // ArrayMap instances
72 MapKind_MetaEnvironment, // EnvironmentMap instances
73 MapKind_MetaStruct, // StructMap instances
79 // All garbage collected objects must inherit from GCObject. Note that using
80 // virtual functions is illegal, as the |map| field would be displaced.
93 inline bool is(MapKind map);
95 inline void write(Zone *zone, Object **ptr, Object *value);
97 static inline Object *cast(Object *obj) {
101 static inline size_t offsetOfMap() {
102 // Clang doesn't accept offsetof here and it's not clear why...
103 return reinterpret_cast<size_t>(&((Object *)NULL)->map_);
107 // Maps describe the layout of GCObjects. Every GCObject requires a map.
108 class Map : public Object
113 void setKind(MapKind kind) {
120 static inline Map *cast(Object *obj) {
121 // Note that ArrayMap is a map, but a special one: since it is non-
122 assert(obj->map()->kind() > MapKinds_Special &&
123 obj->map()->kind() < MapKinds_EndSpecial);
124 return reinterpret_cast<Map *>(obj);
129 Object::is(MapKind kind)
131 return map()->kind() == kind;
136 #endif //_include_jitcraft_objects_h_