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_type_manager_h_
20 #define _include_jitcraft_type_manager_h_
24 #include "HashTable.h"
25 #include "AllocatorPolicies.h"
26 #include "VirtualObjectVisitor.h"
39 LookupKey(Handle<Type> type, TypeQualifiers quals)
48 typedef Type * Payload;
50 static uint32 hash(const LookupKey &key) {
51 // We'll need to rehash with moving GC.
52 return HashPointer(key.type);
55 static bool matches(const LookupKey &key, Type *type) {
56 assert(type->hasTypeQualifiers());
57 return key.type == type->unqualified() &&
58 key.quals == type->quals();
62 typedef HashTable<Policy, ZoneAllocatorPolicy> TypeHashTable;
65 TypeManager(Zone *zone);
69 Type *getPrimitive(PrimitiveType type) {
70 return primitiveTypes_[type];
79 Type *getUnchecked() {
80 return uncheckedType_;
82 ReferenceType *getReference(Handle<Type> type, bool isConst);
83 ArrayType *newArray(Handle<Type> contained, int elements);
84 ArrayType *newExternalArray(Handle<Type> contained);
85 EnumType *newEnum(Handle<String> name);
87 void accept(VirtualObjectVisitor *visitor);
90 Type *qualify(Handle<Type> type, TypeQualifiers quals);
95 // Primitive type cache.
96 Unbarriered<Type> voidType_;
97 Unbarriered<Type> stringType_;
98 Unbarriered<Type> uncheckedType_;
99 Unbarriered<Type> primitiveTypes_[PrimitiveTypes_Total];
100 Unbarriered<ReferenceType> referenceTypes_[PrimitiveTypes_Total];
102 TypeHashTable qualTable_;
107 #endif // _include_jitcraft_type_manager_h_