Added support for fused math-assign ops (+=, etc).
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;
38 else if (tag && strcmp(tag, "String") == 0)
39 type->primitive_ = PrimitiveType_Char;
41 type->primitive_ = PrimitiveType_Int32;
46 Type::NewPrimitive(Zone *zone, PrimitiveType prim)
48 Object *obj = zone->allocate(MapKind_Type, sizeof(Type), Heap::Tenure_Old);
52 Type *type = Type::cast(obj);
53 type->kind_ = PRIMITIVE;
55 type->contained_ = NULL;
56 type->primitive_ = prim;
61 Type::NewArray(Zone *zone, Type *contained, int elements, bool isConst)
63 Object *obj = zone->allocate(MapKind_Type, sizeof(Type), Heap::Tenure_Old);
67 Type *type = Type::cast(obj);
70 type->contained_ = contained;
71 type->elements_ = elements;
72 if (contained->isPrimitive())
75 type->levels_ = contained->levels() + 1;
76 type->const_ = isConst;
81 Type::NewReference(Zone *zone, Type *contained)
83 Object *obj = zone->allocate(MapKind_Type, sizeof(Type), Heap::Tenure_Old);
87 Type *type = Type::cast(obj);
88 type->kind_ = REFERENCE;
90 type->contained_ = contained;
95 Type::NewFunction(Zone *zone, Type *returnType, FixedArray *parameters)
97 Object *obj = zone->allocate(MapKind_Type, sizeof(Type), Heap::Tenure_Old);
101 Type *type = Type::cast(obj);
102 type->kind_ = FUNCTION;
103 type->contained_ = returnType;
104 type->parameters_ = parameters;