Added a mark-sweep garbage collector.
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 Local<Type> type(zone, Type::cast(zone->allocate(MapKind_Type, sizeof(Type), Heap::Tenure_Old)));
31 type->kind_ = PRIMITIVE;
33 type->contained_ = NULL;
34 type->returnType_ = NULL;
35 type->parameters_ = NULL;
37 if (tag && strcmp(tag, "Float") == 0)
38 type->primitive_ = PrimitiveType_Float;
39 else if (tag && strcmp(tag, "String") == 0)
40 type->primitive_ = PrimitiveType_Char;
42 type->primitive_ = PrimitiveType_Int32;
47 Type::NewPrimitive(Zone *zone, PrimitiveType prim)
49 Local<Type> type(zone, Type::cast(zone->allocate(MapKind_Type, sizeof(Type), Heap::Tenure_Old)));
53 type->kind_ = PRIMITIVE;
55 type->contained_ = NULL;
56 type->returnType_ = NULL;
57 type->parameters_ = NULL;
58 type->primitive_ = prim;
63 Type::NewArray(Zone *zone, Handle<Type> contained, int elements, bool isConst)
65 Local<Type> type(zone, Type::cast(zone->allocate(MapKind_Type, sizeof(Type), Heap::Tenure_Old)));
71 type->contained_ = contained;
72 type->returnType_ = NULL;
73 type->parameters_ = NULL;
74 type->elements_ = elements;
75 if (contained->isPrimitive())
78 type->levels_ = contained->levels() + 1;
79 type->const_ = isConst;
84 Type::NewReference(Zone *zone, Handle<Type> contained)
86 Local<Type> type(zone, Type::cast(zone->allocate(MapKind_Type, sizeof(Type), Heap::Tenure_Old)));
90 type->kind_ = REFERENCE;
92 type->contained_ = contained;
93 type->returnType_ = NULL;
94 type->parameters_ = NULL;
99 Type::NewFunction(Zone *zone, Handle<Type> returnType, Handle<FixedArray> parameters)
101 Local<Type> type(zone, Type::cast(zone->allocate(MapKind_Type, sizeof(Type), Heap::Tenure_Old)));
105 type->kind_ = FUNCTION;
106 type->contained_ = NULL;
107 type->returnType_ = returnType;
108 type->parameters_ = parameters;