code.h 801 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
#ifndef __CODE_H
#define __CODE_H

#include "desc.h"

#define CT_LIT	 			1
#define CT_VAR 				2
#define CT_APP 				3

Laszlo Domoszlai's avatar
Laszlo Domoszlai committed
10
struct Code
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
{
	unsigned int type  		: 3;
	unsigned int local_type : 3;
	unsigned int arity 		: 4;
};

#define LIT_INT   			1
#define LIT_REAL   			2
#define LIT_CHAR			3
#define LIT_BOOL			4
#define LIT_STRING			5

struct CleanString
{
	int length;
26
	char chars[];
27
28
29
30
};

struct LitEntry
{
Laszlo Domoszlai's avatar
Laszlo Domoszlai committed
31
	struct Code base;
32
33
34
35
36
37
38
39
40
41
	union 
	{
		int _int;
		double _real;
		char _char;
		int _bool;
		struct CleanString _string;
	};
};

42
43
44
#define VAR_ARG			1
#define VAR_LOCAL		2
#define VAR_FN			3
45
46
47

struct VarEntry
{
Laszlo Domoszlai's avatar
Laszlo Domoszlai committed
48
	struct Code base;
49
50
51
	union
	{
		int index; // index on the stack
Laszlo Domoszlai's avatar
Laszlo Domoszlai committed
52
		struct Desc* f;
53
54
55
56
57
	};
};

struct AppEntry
{
Laszlo Domoszlai's avatar
Laszlo Domoszlai committed
58
	struct Code base;
59
	struct VarEntry* var; 
Laszlo Domoszlai's avatar
Laszlo Domoszlai committed
60
	struct Code* args[];
61
62
63
};

#endif // __CODE_H