Added support for bitwise 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/.
18 #ifndef _include_jc_types_h_
19 #define _include_jc_types_h_
21 #include "StringPool.h"
39 static const int UNKNOWN_SIZE = -1;
40 static const size_t MAX_UNSAFE_ARRAY_DEPTH = 5;
42 static Type *NewPrimitive(Name *tag);
43 static Type *NewPrimitive(PrimitiveType type);
44 static Type *NewUnsafeArray(Type *contained, int elements);
46 bool isPrimitive() const {
47 return kind_ == PRIMITIVE;
49 bool isArray() const {
50 return isUnsafeArray();
52 bool isUnsafeArray() const {
53 return kind_ == UNSAFE_ARRAY;
55 PrimitiveType primitive() const {
56 assert(isPrimitive());
59 Type *contained() const {
63 int elements() const {
67 unsigned levels() const {
72 assert(isPrimitive());
75 Type *innermost() const {
77 Type *temp = contained();
78 while (temp->isArray())
79 temp = temp->contained();
82 bool isFloat() const {
83 return isPrimitive() && primitive() == PrimitiveType_Float;
86 return isPrimitive() && primitive() == PrimitiveType_Int32;
92 // If a primitive type, these tell the kind of type.
94 PrimitiveType primitive_;
96 // The contained type of an array.
99 // The number of elements in the array.
102 // Levels deep this array goes (minimum is 1).
114 static BoxedPrimitive Int(int i) {
116 b.type_ = PrimitiveType_Int32;
121 PrimitiveType type() const {
125 assert(type() == PrimitiveType_Int32);
132 #endif // _include_jc_types_h_