desc.h 1.59 KB
Newer Older
1
2
#ifndef __DESC_H
#define __DESC_H
Laszlo Domoszlai's avatar
Laszlo Domoszlai committed
3

4
#include "desc_base.h"
Laszlo Domoszlai's avatar
Laszlo Domoszlai committed
5
6
7
#include "thunk.h"
#include "code.h"

Laszlo Domoszlai's avatar
Laszlo Domoszlai committed
8
9
10
11
12
13
14
15
16
struct FunEntry {
    struct Desc base;
    int strictness;

    union {
        char* parseCont;
        struct Code* body;
    };
    char name[];
Laszlo Domoszlai's avatar
Laszlo Domoszlai committed
17
18
};

19
// an array of these is just before an ADTEntry/FunEntry (as many as arity)
Laszlo Domoszlai's avatar
Laszlo Domoszlai committed
20
21
22
23

struct SliceEntry {
    struct Desc base;
    Desc* forward_ptr; // FunEntry or ADTEntry
Laszlo Domoszlai's avatar
Laszlo Domoszlai committed
24
};
Laszlo Domoszlai's avatar
Laszlo Domoszlai committed
25

Laszlo Domoszlai's avatar
Laszlo Domoszlai committed
26
27
28
29
struct ADTEntry {
    struct Desc base;
    int strictness;
    char name[];
Laszlo Domoszlai's avatar
Laszlo Domoszlai committed
30
31
};

Laszlo Domoszlai's avatar
Laszlo Domoszlai committed
32
33
34
35
36
37
struct CAFEntry {
    struct Desc base;

    union {
        char* parseCont;
        Code* body;
38
        struct Thunk* value;
Laszlo Domoszlai's avatar
Laszlo Domoszlai committed
39
40
    };
    char name[];
Laszlo Domoszlai's avatar
Laszlo Domoszlai committed
41
42
};

Laszlo Domoszlai's avatar
Laszlo Domoszlai committed
43
44
45
46
47
struct RecordEntry {
    struct Desc base;
    int strictness;
    char** fields;
    char name[];
Laszlo Domoszlai's avatar
Laszlo Domoszlai committed
48
49
};

Laszlo Domoszlai's avatar
Laszlo Domoszlai committed
50
51
52
struct PrimEntry {
    struct Desc base;
    int strictness;
53
    void (*exec)(int frame_ptr);
Laszlo Domoszlai's avatar
Laszlo Domoszlai committed
54
    char name[];
55
56
};

Laszlo Domoszlai's avatar
Laszlo Domoszlai committed
57
void gen_slices(SliceEntry* dest, Desc* forward_ptr, int arity);
58

59
60
void init_desc();

Laszlo Domoszlai's avatar
Laszlo Domoszlai committed
61
62
void add_desc(char* fn, Desc* desc);
Desc* find_desc(char* fn);
Laszlo Domoszlai's avatar
Laszlo Domoszlai committed
63

64
65
Desc* get_slice(Desc* f, int nrargs);

66
67
int printDesc(Desc* f);

68
extern struct FunEntry* __INT__;
Laszlo Domoszlai's avatar
Laszlo Domoszlai committed
69
extern struct FunEntry* __INT_SHARED__;
70
extern struct FunEntry* __BOOL__;
Laszlo Domoszlai's avatar
Laszlo Domoszlai committed
71
extern struct FunEntry* __BOOL_SHARED__;
72
extern struct FunEntry* __CHAR__;
Laszlo Domoszlai's avatar
Laszlo Domoszlai committed
73
extern struct FunEntry* __CHAR_SHARED__;
74
extern struct FunEntry* __REAL__;
Laszlo Domoszlai's avatar
Laszlo Domoszlai committed
75
extern struct FunEntry* __REAL_SHARED__;
Laszlo Domoszlai's avatar
Laszlo Domoszlai committed
76

77
78
79
extern struct FunEntry* __STRING__;
extern struct FunEntry* __ARRAY__;

Laszlo Domoszlai's avatar
Laszlo Domoszlai committed
80
81
82
extern struct FunEntry* __FORWARD_PTR__;
extern struct FunEntry* __STACK_PLACEHOLDER__;

Laszlo Domoszlai's avatar
Laszlo Domoszlai committed
83
84
85
extern struct Thunk* __FALSE__;
extern struct Thunk* __TRUE__;

86
#endif // __DESC_H