-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstate.h
More file actions
79 lines (59 loc) · 1020 Bytes
/
state.h
File metadata and controls
79 lines (59 loc) · 1020 Bytes
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#ifndef SMPL_STATE_H
#define SMPL_STATE_H
#include <stdbool.h>
#include <setjmp.h>
#include "env.h"
#include "obj.h"
#include "error.h"
#include "lex.h"
#include "smpl.h"
#include "opcodes.h"
#define sp_on_error(S) if(setjmp((S)->err))
#define sp_any_error(S) ((S)->errtop > 0)
struct sp_Label
{
uint i;
uint id;
};
struct sp_State
{
// execution stack
uint top;
sp_Object **stack;
// runtime environment
/*
uint vartop;
sp_Variable *vars;
*/
sp_Object **vars;
// parsing state
sp_Ast *ast;
sp_Ast *gcast;
// lexing state
char *fn;
char *p, *e;
uint ln;
char c;
bool nl;
sp_Number n;
sp_String *s;
sp_Token t;
uint status;
sp_printn_F pnum;
sp_prints_F pstr;
sp_gets_F gstr;
uint lbltop;
sp_Label *lbls;
uint errtop;
sp_Error *errs;
uint instop;
sp_OpCode *inss;
uint opargtop;
sp_Object **opargs;
jmp_buf err;
#ifdef SMPL_DEBUG
uint tabs;
char *tabc;
#endif
};
#endif // SMPL_STATE_H