Implement ++ and -- operators.
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)
39 if ((primitiveTypes_[PrimitiveType_Char] = Type::NewPrimitive(zone_, "String")) == NULL)
42 for (unsigned i = 0; i < PrimitiveTypes_Total; i++) {
43 if ((referenceTypes_[i] = Type::NewReference(zone_, primitiveTypes_[i])) == NULL)
51 TypeManager::getPrimitiveForTag(Name *tag)
54 return getPrimitive(PrimitiveType_Int32);
55 if (strcmp(tag, "Float") == 0)
56 return getPrimitive(PrimitiveType_Float);
57 if (strcmp(tag, "String") == 0)
58 return getPrimitive(PrimitiveType_Char);
63 TypeManager::unsafeArray(Type *contained, int elements)
66 return Type::NewArray(zone_, contained, elements, false);
70 TypeManager::getReference(Type *type)
72 if (type->isFloat() || (type->isInt32() && !type->tag()))
73 return referenceTypes_[type->primitive()];
76 return Type::NewReference(zone_, type);
80 TypeManager::newFunction(Type *returnType, FixedArray *args)
83 return Type::NewFunction(zone_, returnType, args);