summaryrefslogtreecommitdiff
path: root/src/value.h
blob: 37954863972b3fe99b9ef0bdb863adf7fb855746 (plain)
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
#ifndef IMB3_VALUE_H
#define IMB3_VALUE_H

#include <stddef.h>
#include <stdint.h>

struct value {
  uintptr_t bits;
};

enum value_tag {
  /**
   * A big integer or the nil constant.
   */
  TAG_BIGINT_OR_NIL = 0b000,

  /**
   * Fixnums, i.e. integers that are stored directly in the value rather than
   * being pointed to. This is a two-bit tag rather than a three-bit tag...
   */
  VALUE_FIXNUM = 0b01,

  /**
   * A builtin-object.
   */
  TAG_BUILTIN_OBJECT = 0b010,

  /**
   * A simple-array, i.e. an array of values without a fill-pointer.
   */
  TAG_SIMPLE_ARRAY = 0b100,

  /**
   * A standard-object, effectively a pair of a class and a slot array.
   */
  TAG_STANDARD_OBJECT = 0b110,
};

/**
 * Allocates a builtin-object with the given class and slot count.
 */
struct value make_builtin_object(struct value class, size_t value_slot_count,
                                 size_t untraced_slot_count);

/**
 * Bootstraps the class heirarchy. This should only be called once.
 */
void bootstrap(void);

#endif // IMB3_VALUE_H