-
Notifications
You must be signed in to change notification settings - Fork 1
/
int.h
60 lines (48 loc) · 1.03 KB
/
int.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// -*- mode:c++ -*-
#ifndef ICI_INT_H
#define ICI_INT_H
#include "object.h"
namespace ici
{
/*
* The following portion of this file exports to ici.h. --ici.h-start--
*/
/*
* The C struct that is the ICI int object.
*
* This --struct-- forms part of the --ici-api--.
*/
struct integer : object
{
int64_t i_value;
};
inline integer *intof(object *o)
{
return o->as<integer>();
}
inline bool isint(object *o)
{
return o->hastype(TC_INT);
}
class int_type : public type
{
public:
int_type() : type("int", sizeof(struct integer))
{
}
int cmp(object *, object *) override;
unsigned long hash(object *) override;
int save(archiver *, object *) override;
object *restore(archiver *) override;
};
/*
* End of ici.h export. --ici.h-end--
*/
/*
* So-called "small" integers are pre-created to prime the atom table.
*/
constexpr int small_int_count = 256;
constexpr int small_int_mask = 0xFF;
extern integer *small_ints[small_int_count];
} // namespace ici
#endif /* ICI_INT_H */