Initial import of some kind of API.
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/.
26 Type::NewPrimitive(Zone *zone, Handle<String> tag)
28 Local<Type> type(zone, Type::cast(zone->allocate(MapKind_Type, sizeof(Type), Heap::Tenure_Old)));
32 type->kind_ = PRIMITIVE;
34 type->contained_ = NULL;
35 type->returnType_ = NULL;
36 type->parameters_ = NULL;
38 if (tag && strcmp(tag->chars(), "Float") == 0)
39 type->primitive_ = PrimitiveType_Float;
40 else if (tag && strcmp(tag->chars(), "String") == 0)
41 type->primitive_ = PrimitiveType_Char;
43 type->primitive_ = PrimitiveType_Int32;
48 Type::NewPrimitive(Zone *zone, PrimitiveType prim)
50 Local<Type> type(zone, Type::cast(zone->allocate(MapKind_Type, sizeof(Type), Heap::Tenure_Old)));
54 type->kind_ = PRIMITIVE;
56 type->contained_ = NULL;
57 type->returnType_ = NULL;
58 type->parameters_ = NULL;
59 type->primitive_ = prim;
64 Type::NewArray(Zone *zone, Handle<Type> contained, int elements, bool isConst)
66 Local<Type> type(zone, Type::cast(zone->allocate(MapKind_Type, sizeof(Type), Heap::Tenure_Old)));
72 type->contained_ = contained;
73 type->returnType_ = NULL;
74 type->parameters_ = NULL;
75 type->elements_ = elements;
76 if (contained->isPrimitive())
79 type->levels_ = contained->levels() + 1;
80 type->const_ = isConst;
85 Type::NewReference(Zone *zone, Handle<Type> contained)
87 Local<Type> type(zone, Type::cast(zone->allocate(MapKind_Type, sizeof(Type), Heap::Tenure_Old)));
91 type->kind_ = REFERENCE;
93 type->contained_ = contained;
94 type->returnType_ = NULL;
95 type->parameters_ = NULL;
100 Type::NewFunction(Zone *zone, Handle<Type> returnType, Handle<FixedArray> parameters)
102 Local<Type> type(zone, Type::cast(zone->allocate(MapKind_Type, sizeof(Type), Heap::Tenure_Old)));
106 type->kind_ = FUNCTION;
107 type->contained_ = NULL;
108 type->returnType_ = returnType;
109 type->parameters_ = parameters;