-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcompile.h
93 lines (84 loc) · 2.71 KB
/
compile.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
/*
* j2 - A simple concatenative programming language that can understand
* the structure of and dynamically link with compatible C binaries.
*
* Copyright (C) 2011 Jason Nyberg <[email protected]>
* Copyright (C) 2018 Jason Nyberg <[email protected]> (dual-licensed)
* (C) Copyright 2019 Hewlett Packard Enterprise Development LP.
*
* This file is part of j2.
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of either
*
* * the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at
* your option) any later version
*
* or
*
* * the GNU General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at
* your option) any later version
*
* or both in parallel, as here.
*
* j2 is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received copies of the GNU General Public License and
* the GNU Lesser General Public License along with this program. If
* not, see <http://www.gnu.org/licenses/>.
*/
#ifndef COMPILE_H
#define COMPILE_H
#include <stdio.h>
#include "listree.h"
typedef struct {
unsigned char op;
unsigned int len; // extended
LTV_FLAGS flags; // extended
char *data; // extended
} VM_CMD; // exploded bytecode template
typedef int (*EMITTER)(VM_CMD *cmd);
typedef int (*COMPILER)(EMITTER emit,void *data,int len);
enum {
VMOP_RESET,
VMOP_YIELD,
VMOP_EXT,
VMOP_THROW,
VMOP_CATCH,
VMOP_PUSHEXT,
VMOP_EVAL,
VMOP_REF,
VMOP_DEREF,
VMOP_ASSIGN,
VMOP_REMOVE,
VMOP_CTX_PUSH,
VMOP_CTX_POP,
VMOP_FUN_PUSH,
VMOP_FUN_EVAL,
VMOP_FUN_POP,
VMOP_S2S,
VMOP_D2S,
VMOP_E2S,
VMOP_F2S,
VMOP_S2D,
VMOP_S2E,
VMOP_S2F,
} VM_OPCODES;
extern LTV *compile(COMPILER compiler,void *data,int len);
extern LTV *compile_ltv(COMPILER compiler,LTV *ltv);
extern void disassemble(FILE *ofile,LTV *ltv);
extern int jit_asm(EMITTER emit,void *data,int len);
extern int jit_edict(EMITTER emit,void *data,int len);
extern int jit_xml(EMITTER emit,void *data,int len);
extern int jit_edict2(EMITTER emit, void *data, int len);
//extern int jit_json(EMITTER emit,void *data,int len);
//extern int jit_yaml(EMITTER emit,void *data,int len);
//extern int jit_swagger(EMITTER emit,void *data,int len);
//extern int jit_lisp(EMITTER emit,void *data,int len);
//extern int jit_massoc(EMITTER emit,void *data,int len); // mathematica association
#endif // COMPILE_H