Added support for arbitrary expression 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/.
25 Type::NewPrimitive(Zone *zone, Name *tag)
27 Object *obj = zone->allocate(MapKind_Type, sizeof(Type), Heap::Tenure_Old);
31 Type *type = Type::cast(obj);
32 type->kind_ = PRIMITIVE;
34 type->contained_ = NULL;
36 if (tag && strcmp(tag, "Float") == 0)
37 type->primitive_ = PrimitiveType_Float;
39 type->primitive_ = PrimitiveType_Int32;
44 Type::NewPrimitive(Zone *zone, PrimitiveType prim)
46 Object *obj = zone->allocate(MapKind_Type, sizeof(Type), Heap::Tenure_Old);
50 Type *type = Type::cast(obj);
51 type->kind_ = PRIMITIVE;
53 type->contained_ = NULL;
54 type->primitive_ = prim;
59 Type::NewUnsafeArray(Zone *zone, Type *contained, int elements)
61 Object *obj = zone->allocate(MapKind_Type, sizeof(Type), Heap::Tenure_Old);
65 Type *type = Type::cast(obj);
68 type->contained_ = contained;
69 type->elements_ = elements;
70 if (contained->isPrimitive())
73 type->levels_ = contained->levels() + 1;
78 Type::NewReference(Zone *zone, Type *contained)
80 Object *obj = zone->allocate(MapKind_Type, sizeof(Type), Heap::Tenure_Old);
84 Type *type = Type::cast(obj);
85 type->kind_ = REFERENCE;
87 type->contained_ = contained;
92 Type::NewFunction(Zone *zone, Type *returnType, FixedArray *parameters)
94 Object *obj = zone->allocate(MapKind_Type, sizeof(Type), Heap::Tenure_Old);
98 Type *type = Type::cast(obj);
99 type->kind_ = FUNCTION;
100 type->contained_ = returnType;
101 type->parameters_ = parameters;