5 * Permission is hereby granted, free of charge, to any person obtaining a copy of
6 * this software and associated documentation files (the "Software"), to deal in
7 * the Software without restriction, including without limitation the rights to
8 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
9 * of the Software, and to permit persons to whom the Software is furnished to do
10 * so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in all
13 * copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 #ifndef GMQCC_EXEC_HDR
25 #define GMQCC_EXEC_HDR
27 /* darkplaces has (or will have) a 64 bit prog loader
28 * where the 32 bit qc program is autoconverted on load.
29 * Since we may want to support that as well, let's redefine
32 typedef float qcfloat;
33 typedef int32_t qcint;
45 typedef char qcfloat_size_is_correct [sizeof(qcfloat) == 4 ?1:-1];
46 typedef char qcint_size_is_correct [sizeof(int) == 4 ?1:-1];
58 prog_section statements;
61 prog_section functions;
67 typedef prog_section_both prog_def;
68 typedef prog_section_function prog_function;
69 typedef prog_section_statement prog_statement;
73 VMERR_TEMPSTRING_ALLOC,
78 #define JUMPS_DEFAULT 1000000
80 #define VMXF_DEFAULT 0x0000
81 #define VMXF_TRACE 0x0001
82 #define VMXF_PROFILE 0x0002
86 typedef int (*prog_builtin)(struct qc_program_s *prog);
91 prog_function *function;
94 typedef struct qc_program_s {
97 MEM_VECTOR_MAKE(prog_statement, code);
98 MEM_VECTOR_MAKE(prog_def, defs);
99 MEM_VECTOR_MAKE(prog_def, fields);
100 MEM_VECTOR_MAKE(prog_function, functions);
101 MEM_VECTOR_MAKE(char, strings);
102 MEM_VECTOR_MAKE(qcint, globals);
103 MEM_VECTOR_MAKE(qcint, entitydata);
105 size_t tempstring_start;
106 size_t tempstring_at;
110 MEM_VECTOR_MAKE(size_t, profile);
112 MEM_VECTOR_MAKE(prog_builtin, builtins);
117 bool allowworldwrites;
119 MEM_VECTOR_MAKE(qcint, localstack);
120 MEM_VECTOR_MAKE(qc_exec_stack, stack);
123 int argc; /* current arg count for debugging */
125 MEM_VEC_FUNCTIONS(qc_program, prog_statement, code)
126 MEM_VEC_FUNCTIONS(qc_program, prog_def, defs)
127 MEM_VEC_FUNCTIONS(qc_program, prog_def, fields)
128 MEM_VEC_FUNCTIONS(qc_program, prog_function, functions)
129 MEM_VEC_FUNCTIONS(qc_program, char, strings)
130 _MEM_VEC_FUN_APPEND(qc_program, char, strings)
131 _MEM_VEC_FUN_RESIZE(qc_program, char, strings)
132 MEM_VEC_FUNCTIONS(qc_program, qcint, globals)
133 MEM_VEC_FUNCTIONS(qc_program, qcint, entitydata)
135 MEM_VEC_FUNCTIONS(qc_program, qcint, localstack)
136 _MEM_VEC_FUN_APPEND(qc_program, qcint, localstack)
137 _MEM_VEC_FUN_RESIZE(qc_program, qcint, localstack)
138 MEM_VEC_FUNCTIONS(qc_program, qc_exec_stack, stack)
140 MEM_VEC_FUNCTIONS(qc_program, size_t, profile)
141 _MEM_VEC_FUN_RESIZE(qc_program, size_t, profile)
143 qc_program* prog_load(const char *filename);
144 void prog_delete(qc_program *prog);
146 #endif /* GMQCC_EXEC_HDR */