-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlhs_code.h
103 lines (92 loc) · 3.7 KB
/
lhs_code.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#pragma once
#include "lhs_config.h"
#include "lhs_vm.h"
#define LHS_UNCERTAIN (-1)
#define LHS_VOID (0)
#define LHS_RESULT (1)
#define OP_NONE (0)
#define OP_ADD (1)
#define OP_SUB (2)
#define OP_MUL (3)
#define OP_DIV (4)
#define OP_MOD (5)
#define OP_ANDB (6)
#define OP_ORB (7)
#define OP_XORB (8)
#define OP_L (9)
#define OP_G (10)
#define OP_E (11)
#define OP_NE (12)
#define OP_GE (13)
#define OP_LE (14)
#define OP_AND (15)
#define OP_OR (16)
#define OP_SHL (17)
#define OP_SHR (18)
#define OP_NEG (19)
#define OP_NOT (20)
#define OP_NOTB (21)
#define OP_MOV (22)
#define OP_CONCAT (23)
#define OP_MOVS (24)
#define OP_PUSH (25)
#define OP_POP (26)
#define OP_JMP (27)
#define OP_JZ (28)
#define OP_JNZ (29)
#define OP_JE (30)
#define OP_NOP (31)
#define OP_CALL (32)
#define OP_CALLS (33)
#define OP_RET (34)
#define OP_RET1 (35)
#define OP_SWAP (36)
#define OP_PUSHTAB (37)
#define OP_INSTAB (38)
#define OP_SETTAB (39)
#define OP_GETTAB (40)
#define OP_EXIT (41)
#define OP_MAX (42)
#define lhscode_boolean(vm, buf, v) \
{ \
lhsbuf_pushc((vm), (buf), LHS_MARKBOOLEAN); \
lhsbuf_pushc((vm), (buf), (v)); \
}
#define lhscode_integer(vm, buf, v) \
{ \
lhsbuf_pushc((vm), (buf), LHS_MARKINTEGER); \
lhsbuf_pushl((vm), (buf), (v)); \
}
#define lhscode_number(vm, buf, v) \
{ \
lhsbuf_pushc((vm), (buf), LHS_MARKNUMBER); \
lhsbuf_pushf((vm), (buf), (v)); \
}
#define lhscode_ref(vm, buf, m, v) \
{ \
lhsbuf_pushc((vm), (buf), (m)); \
lhsbuf_pushi((vm), (buf), (v)); \
}
#define lhscode_op1(vm, buf, s, c) \
{ \
lhsbuf_pushc((vm), (buf), (s)); \
lhsbuf_pushi((vm), (buf), (c)->line); \
lhsbuf_pushi((vm), (buf), (c)->column); \
lhsbuf_pushi((vm), (buf), (c)->refer); \
}
#define lhscode_op2(vm, buf, s, l, c, n) \
{ \
lhsbuf_pushc((vm), (buf), (s)); \
lhsbuf_pushi((vm), (buf), (l)); \
lhsbuf_pushi((vm), (buf), (c)); \
lhsbuf_pushi((vm), (buf), (n)); \
}
#define lhscode_index(vm, buf, v) \
{ \
lhsbuf_pushi((vm), buf, (v)); \
}
#define lhscode_byte(vm, buf, v) \
{ \
lhsbuf_pushc((vm), buf, (v)); \
}
int lhscode_dmpcode(LHSVM* vm);