Added support for non-array references.
2 * Copyright (C) 2012 David Anderson
4 * This file is part of JITCraft.
6 * JITCraft is free software: you can redistribute it and/or modify it under
7 * the terms of the GNU General Public License as published by the Free
8 * Software Foundation, either version 3 of the License, or (at your option)
11 * Foobar is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along with
16 * JITCraft. If not, see http://www.gnu.org/licenses/.
19 #include "TypeManager.h"
25 TypeManager::TypeManager(Zone *zone)
31 TypeManager::initialize()
33 if ((primitiveTypes_[PrimitiveType_Int32] = Type::NewPrimitive(zone_, NULL)) == NULL)
35 if ((primitiveTypes_[PrimitiveType_Float] = Type::NewPrimitive(zone_, "Float")) == NULL)
37 if ((primitiveTypes_[PrimitiveType_Native] = Type::NewPrimitive(zone_, PrimitiveType_Native)) == NULL)
40 for (unsigned i = 0; i < PrimitiveTypes_Total; i++) {
41 if ((referenceTypes_[i] = Type::NewReference(zone_, primitiveTypes_[i])) == NULL)
49 TypeManager::getPrimitiveForTag(Name *tag)
52 return getPrimitive(PrimitiveType_Int32);
53 if (strcmp(tag, "Float") == 0)
54 return getPrimitive(PrimitiveType_Float);
60 TypeManager::unsafeArray(Type *contained, int elements)
63 return Type::NewUnsafeArray(zone_, contained, elements);
67 TypeManager::getReference(Type *type)
69 if (type->isFloat() || (type->isInt() && !type->tag()))
70 return referenceTypes_[type->primitive()];
73 return Type::NewReference(zone_, type);
77 TypeManager::newFunction(Type *returnType, FixedArray *args)
80 return Type::NewFunction(zone_, returnType, args);