Fun 0.41.5
The programming language that makes You have fun
Loading...
Searching...
No Matches
bytecode.h
Go to the documentation of this file.
1/*
2 * This file is part of the Fun programming language.
3 * https://fun-lang.xyz/
4 *
5 * Copyright 2025 Johannes Findeisen <you@hanez.org>
6 * Licensed under the terms of the Apache-2.0 license.
7 * https://opensource.org/license/apache-2-0
8 */
9
20#ifndef FUN_BYTECODE_H
21#define FUN_BYTECODE_H
22
23#include "value.h"
24#include <stdint.h>
25
35typedef enum {
37 OP_LOAD_CONST, // operand = constant index
38 OP_LOAD_LOCAL, // operand = local slot index
39 OP_STORE_LOCAL, // operand = local slot index
40
43
48
49 OP_LT, // a < b -> push 1/0
50 OP_LTE, // a <= b -> push 1/0
51 OP_GT, // a > b -> push 1/0
52 OP_GTE, // a >= b -> push 1/0
53 OP_EQ, // a == b -> push 1/0
54 OP_NEQ, // a != b -> push 1/0
55
56 OP_POP, // discard top of stack
57 OP_JUMP, // unconditional jump
58 OP_JUMP_IF_FALSE, // jump if top of stack is false (0)
59
60 OP_CALL, // operand = arg count; pops fn + args and enters fn
61 OP_RETURN, // pop optional return value and return to caller
62
64 OP_ECHO, // like print but does not append a newline; prints immediately
66
67 OP_LINE, // operand = source line number (debug marker)
68
69 // add after existing opcodes
70 OP_MOD, // a % b
71 OP_AND, // logical AND
72 OP_OR, // logical OR
73 OP_NOT, // logical NOT
74
75 OP_DUP, // duplicate top of stack
76 OP_SWAP, // swap top two stack values
77
78 // arrays
79 OP_MAKE_ARRAY, // operand = element count; pops N values, pushes array
80 OP_INDEX_GET, // pops index, array; pushes element copy
81 OP_INDEX_SET, // pops value, index, array; sets in place
82
83 // array and builtin helpers
84 OP_LEN, // pops array or string; pushes length
85 OP_PUSH, // pops value, array; pushes new length
86 OP_APOP, // pops array; pushes removed element
87 OP_SET, // pops value, index, array; pushes value
88 OP_INSERT, // pops value, index, array; pushes new length
89 OP_REMOVE, // pops index, array; pushes removed element
90 OP_SLICE, // pops end, start, array; pushes new array
91
92 // conversions
93 OP_TO_NUMBER, // pops any; pushes int (parse strings)
94 OP_TO_STRING, // pops any; pushes string
95 OP_CAST, // pops typeName, value; pushes casted value (see vm/cast.c)
96 OP_TYPEOF, // pops any; pushes string name of type
97 OP_UCLAMP, // pops number; pushes number masked to N bits (operand = bits)
98 OP_SCLAMP, // pops number; pushes number clamped to signed N-bit range (operand = bits)
99
100 // string ops
101 OP_SPLIT, // pops sep, string; pushes array of strings
102 OP_JOIN, // pops sep, array; pushes string
103 OP_SUBSTR, // pops len, start, string; pushes string
104 OP_FIND, // pops needle, haystack; pushes int index or -1
105
106 // regex ops (POSIX)
107 OP_REGEX_MATCH, // pops pattern, string; pushes 1/0 for full match
108 OP_REGEX_SEARCH, // pops pattern, string; pushes map {"match":str, "start":int, "end":int, "groups":array}
109 OP_REGEX_REPLACE, // pops repl, pattern, string; pushes string with global replacements
110
111 // array utils
112 OP_CONTAINS, // pops value, array; pushes 1/0
113 OP_INDEX_OF, // pops value, array; pushes index or -1
114 OP_CLEAR, // pops array; clears it; pushes nothing (we'll push 0)
115
116 // iteration helpers
117 OP_ENUMERATE, // pops array; pushes array of [index, value]
118 OP_ZIP, // pops b, a; pushes array of [a[i], b[i]]
119
120 // math
121 OP_MIN, // pops b, a; pushes min(a,b)
122 OP_MAX, // pops b, a; pushes max(a,b)
123 OP_CLAMP, // pops hi, lo, x; pushes clamped
124 OP_ABS, // pops x; pushes |x|
125 OP_POW, // pops b, a; pushes a^b
126 OP_RANDOM_SEED, // pops seed; sets RNG seed; pushes nothing (we'll push 0)
127 OP_RANDOM_INT, // pops hi, lo; pushes random int in [lo, hi)
128
129 // maps
130 OP_MAKE_MAP, // operand = pair count; pops 2*n (key,value)..., pushes map
131 OP_KEYS, // pops map; pushes array of keys
132 OP_VALUES, // pops map; pushes array of values
133 OP_HAS_KEY, // pops key, map; pushes 1/0
134
135 // file I/O
136 OP_READ_FILE, // pops path string; pushes content string (or "")
137 OP_WRITE_FILE, // pops data string, path string; pushes 1/0
138
139 // OS
140 OP_ENV, // pops name string; pushes value string (or "")
141 OP_INPUT_LINE, // operand: 0=no prompt; 1=has prompt. Pops [prompt?]; pushes input string (no trailing newline)
142 OP_PROC_RUN, // pops command string; pushes map {"out": string, "code": int}
143 OP_PROC_SYSTEM, // pops command string; pushes exit code number
144 OP_TIME_NOW_MS, // pushes current wall-clock time in milliseconds since Unix epoch
145 OP_CLOCK_MONO_MS, // pushes monotonic clock in milliseconds (not wall time)
146 OP_DATE_FORMAT, // pops fmt string, ms epoch (int); pushes formatted date string using strftime
147 OP_ENV_ALL, // pushes map of all environment variables
148 OP_FUN_VERSION, // pushes version string
149
150 // Threads
151 OP_THREAD_SPAWN, // operand: 0=no args, 1=has args; pops [args?], fn; pushes thread id (int>0)
152 OP_THREAD_JOIN, // pops thread id; waits; pushes result value (or Nil)
153 OP_SLEEP_MS, // pops milliseconds; sleeps; pushes Nil (for statement POP safety)
154 OP_RANDOM_NUMBER, // pops length; pushes hex string of that length from OS RNG (hex-encoded)
155
156 // Bitwise (32-bit) and shifts/rotates
157 OP_BAND, // pops b, a; pushes (uint32_t)(a & b)
158 OP_BOR, // pops b, a; pushes (uint32_t)(a | b)
159 OP_BXOR, // pops b, a; pushes (uint32_t)(a ^ b)
160 OP_BNOT, // pops a; pushes (uint32_t)(~a)
161 OP_SHL, // pops s, a; pushes (uint32_t)(a << (s&31))
162 OP_SHR, // pops s, a; pushes (uint32_t)(a >> (s&31)) logical
163 OP_ROTL, // pops s, a; pushes rotl32(a, s)
164 OP_ROTR, // pops s, a; pushes rotr32(a, s)
165
166 // JSON (json-c)
167 OP_JSON_PARSE, // pops text string; pushes value (or Nil on error)
168 OP_JSON_STRINGIFY, // pops pretty(bool), value; pushes string
169 OP_JSON_FROM_FILE, // pops path string; pushes value (or Nil)
170 OP_JSON_TO_FILE, // pops pretty(bool), value, path; pushes 1/0
171
172 // CURL (libcurl)
173 OP_CURL_GET, // pops [headers map?], url; pushes response string (or "")
174 OP_CURL_POST, // pops [headers map?], body string, url; pushes response string (or "")
175 OP_CURL_DOWNLOAD, // pops [headers map?], path, url; pushes 1/0
176
177 // SQLite (optional)
178 OP_SQLITE_OPEN, // pops path; pushes handle (>0) or 0
179 OP_SQLITE_CLOSE, // pops handle; pushes Nil
180 OP_SQLITE_EXEC, // pops sql, handle; pushes sqlite rc (0=OK)
181 OP_SQLITE_QUERY, // pops sql, handle; pushes array<map>
182
183 // PCSC (smart card) opcodes
184 OP_PCSC_ESTABLISH, // returns context id (>0) or 0
185 OP_PCSC_RELEASE, // pops ctx id; returns 1/0
186 OP_PCSC_LIST_READERS, // pops ctx id; returns array of reader names (possibly empty)
187 OP_PCSC_CONNECT, // pops reader, ctx id; returns handle id (>0) or 0
188 OP_PCSC_DISCONNECT, // pops handle id; returns 1/0
189 OP_PCSC_TRANSMIT, // pops apdu array, handle id; returns map {"data":[],"sw1":n,"sw2":n,"code":n}
190
191 // PCRE2 regex ops (optional)
192 OP_PCRE2_TEST, // pops flags, text, pattern; pushes 1/0
193 OP_PCRE2_MATCH, // pops flags, text, pattern; pushes match map or Nil
194 OP_PCRE2_FINDALL, // pops flags, text, pattern; pushes array of match maps
195
196 // OpenSSL (optional)
197 OP_OPENSSL_MD5, // pops data string; pushes md5 hex string
198 OP_OPENSSL_SHA256, // pops data string; pushes sha256 hex string
199 OP_OPENSSL_SHA512, // pops data string; pushes sha512 hex string
200 OP_OPENSSL_RIPEMD160, // pops data string; pushes ripemd160 hex string
201
202 // INI (iniparser 4.2.6) optional
203 OP_INI_LOAD, // pops path; pushes handle (>0) or 0
204 OP_INI_FREE, // pops handle; pushes 1/0
205 OP_INI_GET_STRING, // pops def, key, section, handle; pushes string
206 OP_INI_GET_INT, // pops def, key, section, handle; pushes int
207 OP_INI_GET_DOUBLE, // pops def, key, section, handle; pushes float
208 OP_INI_GET_BOOL, // pops def, key, section, handle; pushes int (0/1)
209 OP_INI_SET, // pops value, key, section, handle; pushes 1/0
210 OP_INI_UNSET, // pops key, section, handle; pushes 1/0
211 OP_INI_SAVE, // pops path, handle; pushes 1/0
212
213 // XML (libxml2) optional minimal API
214 OP_XML_PARSE, // pops text string; pushes doc handle (>0) or 0
215 OP_XML_ROOT, // pops doc handle; pushes node handle (>0) or 0
216 OP_XML_NAME, // pops node handle; pushes string (node name)
217 OP_XML_TEXT, // pops node handle; pushes string (node text)
218
219 // Sockets (UNIX platforms)
220 OP_SOCK_TCP_LISTEN, // pops backlog, port; returns listen fd (>0) or 0
221 OP_SOCK_TCP_ACCEPT, // pops listen fd; returns client fd (>0) or 0
222 OP_SOCK_TCP_CONNECT, // pops port, host; returns fd (>0) or 0
223 OP_SOCK_SEND, // pops data string, fd; returns bytes sent (>=0) or -1
224 OP_SOCK_RECV, // pops maxlen, fd; returns data string ("" on EOF/error)
225 OP_SOCK_CLOSE, // pops fd; returns 1/0
226 OP_SOCK_UNIX_LISTEN, // pops backlog, path; returns listen fd (>0) or 0
227 OP_SOCK_UNIX_CONNECT, // pops path; returns fd (>0) or 0
228
229 // Async-friendly FD helpers (UNIX platforms)
230 OP_FD_SET_NONBLOCK, // pops on:int (0/1), fd:int; returns 1 on success, 0 on error/unsupported
231 OP_FD_POLL_READ, // pops timeout_ms:int, fd:int; returns 1 if readable, 0 if timeout/EOF, -1 on error
232 OP_FD_POLL_WRITE, // pops timeout_ms:int, fd:int; returns 1 if writable, 0 if timeout, -1 on error
233
234 // process control
235 OP_EXIT, // pops code (or uses operand) and terminates script with exit code
236
237 // OS additions
238 OP_OS_LIST_DIR, // pops path string; pushes array of strings
239
240 // Serial communication (termios)
241 OP_SERIAL_OPEN, // pops baud_rate (int), path (string); returns fd (int) or 0
242 OP_SERIAL_CONFIG, // pops flow_control, stop_bits, parity, data_bits, fd; returns 1/0
243 OP_SERIAL_SEND, // pops data (string), fd; returns bytes sent (int)
244 OP_SERIAL_RECV, // pops maxlen (int), fd; returns data (string)
245 OP_SERIAL_CLOSE, // pops fd; returns 1/0
246
247 // exceptions (minimal)
248 OP_TRY_PUSH, // operand = handler ip; push handler onto try-stack
249 OP_TRY_POP, // pop current handler
250 OP_THROW, // pops error value; if handler -> jump to it (push err), else print and terminate
251
252 // C99 math.h rounding family (float-aware)
253 OP_FLOOR, // pops x (int/float); pushes floor(x) (int if integral else float)
254 OP_CEIL, // pops x (int/float); pushes ceil(x) (int if integral else float)
255 OP_TRUNC, // pops x (int/float); pushes trunc(x) (int if integral else float)
256 OP_ROUND, // pops x (int/float); pushes round(x) (half away from zero)
257
258 // C99 math.h transcendentals (float-aware)
259 OP_SIN, // pops x (int/float); pushes sin(x)
260 OP_COS, // pops x (int/float); pushes cos(x)
261 OP_TAN, // pops x (int/float); pushes tan(x)
262 OP_EXP, // pops x (int/float); pushes exp(x)
263 OP_LOG, // pops x (int/float); pushes natural log ln(x)
264 OP_LOG10, // pops x (int/float); pushes log10(x)
265 OP_SQRT, // pops x (int/float); pushes sqrt(x)
266
267 // Integer math helpers
268 OP_GCD, // pops b, a; pushes gcd(|a|,|b|)
269 OP_LCM, // pops b, a; pushes lcm(|a|,|b|) (0 if either is 0)
270 OP_ISQRT, // pops x; pushes floor(sqrt(max(0,x))) for integers
271 OP_SIGN, // pops x; pushes -1, 0, or 1 depending on the sign
272
273 // Min/Max variants (float-aware, C99 semantics)
274 OP_FMIN, // pops b, a (int/float); pushes fmin(a,b) (NaN handling per C99)
275 OP_FMAX, // pops b, a (int/float); pushes fmax(a,b) (NaN handling per C99)
276
277 // Rust FFI demo opcode(s)
278 OP_RUST_HELLO, // pushes string returned from Rust (hello world)
279 OP_RUST_HELLO_ARGS, // pops message string; prints it via Rust; pushes Nil
280 OP_RUST_HELLO_ARGS_RETURN, // pops message string; returns it from Rust without printing; pushes returned string
281 OP_RUST_GET_SP, // pushes current VM stack pointer (via Rust reading VM memory)
282 OP_RUST_SET_EXIT, // pops int and sets VM exit_code (via Rust writing VM memory)
283
284 // C++ demo opcode(s)
285 OP_CPP_ADD, // pops b, a; pushes (a + b)
286} OpCode;
287
288typedef struct {
290 int32_t operand;
292
293typedef struct Bytecode {
296
299
300 /* debug metadata */
301 const char *name; /* function or module name (optional) */
302 const char *source_file; /* originating source filename (optional) */
304
305// constructors / manipulation
307int bytecode_add_constant(Bytecode *bc, Value v); /* stores copy */
308int bytecode_add_instruction(Bytecode *bc, OpCode op, int32_t operand);
309void bytecode_set_operand(Bytecode *bc, int idx, int32_t operand); /* patching */
310void bytecode_free(Bytecode *bc);
311
312// utilities
313void bytecode_dump(const Bytecode *bc);
314
315#endif
Bytecode * bytecode_new(void)
Allocate and initialize an empty Bytecode object.
Definition bytecode.c:27
int bytecode_add_instruction(Bytecode *bc, OpCode op, int32_t operand)
Append a single instruction to the instruction stream.
Definition bytecode.c:62
void bytecode_free(Bytecode *bc)
Free a Bytecode and all memory it owns.
Definition bytecode.c:92
OpCode
VM operation codes executed by the Fun virtual machine.
Definition bytecode.h:35
@ OP_OPENSSL_SHA512
Definition bytecode.h:199
@ OP_PCSC_RELEASE
Definition bytecode.h:185
@ OP_GCD
Definition bytecode.h:268
@ OP_JSON_PARSE
Definition bytecode.h:167
@ OP_READ_FILE
Definition bytecode.h:136
@ OP_CLOCK_MONO_MS
Definition bytecode.h:145
@ OP_CALL
Definition bytecode.h:60
@ OP_RUST_HELLO_ARGS_RETURN
Definition bytecode.h:280
@ OP_ROTL
Definition bytecode.h:163
@ OP_TAN
Definition bytecode.h:261
@ OP_OPENSSL_SHA256
Definition bytecode.h:198
@ OP_JSON_STRINGIFY
Definition bytecode.h:168
@ OP_PCSC_TRANSMIT
Definition bytecode.h:189
@ OP_TRUNC
Definition bytecode.h:255
@ OP_CEIL
Definition bytecode.h:254
@ OP_SPLIT
Definition bytecode.h:101
@ OP_CAST
Definition bytecode.h:95
@ OP_EQ
Definition bytecode.h:53
@ OP_PCRE2_MATCH
Definition bytecode.h:193
@ OP_RANDOM_INT
Definition bytecode.h:127
@ OP_TRY_POP
Definition bytecode.h:249
@ OP_LTE
Definition bytecode.h:50
@ OP_SOCK_TCP_ACCEPT
Definition bytecode.h:221
@ OP_NEQ
Definition bytecode.h:54
@ OP_ISQRT
Definition bytecode.h:270
@ OP_FMAX
Definition bytecode.h:275
@ OP_CPP_ADD
Definition bytecode.h:285
@ OP_PCSC_ESTABLISH
Definition bytecode.h:184
@ OP_SQLITE_EXEC
Definition bytecode.h:180
@ OP_FMIN
Definition bytecode.h:274
@ OP_SWAP
Definition bytecode.h:76
@ OP_SOCK_TCP_LISTEN
Definition bytecode.h:220
@ OP_OPENSSL_RIPEMD160
Definition bytecode.h:200
@ OP_PCSC_LIST_READERS
Definition bytecode.h:186
@ OP_BOR
Definition bytecode.h:158
@ OP_CURL_POST
Definition bytecode.h:174
@ OP_XML_NAME
Definition bytecode.h:216
@ OP_REGEX_SEARCH
Definition bytecode.h:108
@ OP_POW
Definition bytecode.h:125
@ OP_NOT
Definition bytecode.h:73
@ OP_SQRT
Definition bytecode.h:265
@ OP_SOCK_RECV
Definition bytecode.h:224
@ OP_MOD
Definition bytecode.h:70
@ OP_INI_UNSET
Definition bytecode.h:210
@ OP_WRITE_FILE
Definition bytecode.h:137
@ OP_SQLITE_CLOSE
Definition bytecode.h:179
@ OP_FIND
Definition bytecode.h:104
@ OP_SIGN
Definition bytecode.h:271
@ OP_DUP
Definition bytecode.h:75
@ OP_OS_LIST_DIR
Definition bytecode.h:238
@ OP_NOP
Definition bytecode.h:36
@ OP_ENV_ALL
Definition bytecode.h:147
@ OP_VALUES
Definition bytecode.h:132
@ OP_RANDOM_NUMBER
Definition bytecode.h:154
@ OP_INDEX_GET
Definition bytecode.h:80
@ OP_LCM
Definition bytecode.h:269
@ OP_LEN
Definition bytecode.h:84
@ OP_THREAD_SPAWN
Definition bytecode.h:151
@ OP_INDEX_OF
Definition bytecode.h:113
@ OP_LINE
Definition bytecode.h:67
@ OP_MIN
Definition bytecode.h:121
@ OP_SLEEP_MS
Definition bytecode.h:153
@ OP_REGEX_REPLACE
Definition bytecode.h:109
@ OP_MAX
Definition bytecode.h:122
@ OP_SQLITE_OPEN
Definition bytecode.h:178
@ OP_XML_PARSE
Definition bytecode.h:214
@ OP_STORE_LOCAL
Definition bytecode.h:39
@ OP_SLICE
Definition bytecode.h:90
@ OP_INI_GET_DOUBLE
Definition bytecode.h:207
@ OP_JOIN
Definition bytecode.h:102
@ OP_COS
Definition bytecode.h:260
@ OP_BAND
Definition bytecode.h:157
@ OP_ECHO
Definition bytecode.h:64
@ OP_ROTR
Definition bytecode.h:164
@ OP_DATE_FORMAT
Definition bytecode.h:146
@ OP_PROC_SYSTEM
Definition bytecode.h:143
@ OP_OPENSSL_MD5
Definition bytecode.h:197
@ OP_ZIP
Definition bytecode.h:118
@ OP_SUB
Definition bytecode.h:45
@ OP_INI_GET_INT
Definition bytecode.h:206
@ OP_XML_ROOT
Definition bytecode.h:215
@ OP_JUMP
Definition bytecode.h:57
@ OP_DIV
Definition bytecode.h:47
@ OP_SHR
Definition bytecode.h:162
@ OP_SERIAL_OPEN
Definition bytecode.h:241
@ OP_JSON_TO_FILE
Definition bytecode.h:170
@ OP_LT
Definition bytecode.h:49
@ OP_INI_GET_BOOL
Definition bytecode.h:208
@ OP_ROUND
Definition bytecode.h:256
@ OP_PRINT
Definition bytecode.h:63
@ OP_INI_GET_STRING
Definition bytecode.h:205
@ OP_SHL
Definition bytecode.h:161
@ OP_KEYS
Definition bytecode.h:131
@ OP_RUST_HELLO
Definition bytecode.h:278
@ OP_LOAD_LOCAL
Definition bytecode.h:38
@ OP_CURL_DOWNLOAD
Definition bytecode.h:175
@ OP_PCSC_CONNECT
Definition bytecode.h:187
@ OP_RUST_SET_EXIT
Definition bytecode.h:282
@ OP_ENV
Definition bytecode.h:140
@ OP_PUSH
Definition bytecode.h:85
@ OP_TO_NUMBER
Definition bytecode.h:93
@ OP_LOAD_GLOBAL
Definition bytecode.h:41
@ OP_FUN_VERSION
Definition bytecode.h:148
@ OP_SERIAL_SEND
Definition bytecode.h:243
@ OP_LOAD_CONST
Definition bytecode.h:37
@ OP_ADD
Definition bytecode.h:44
@ OP_CONTAINS
Definition bytecode.h:112
@ OP_SOCK_SEND
Definition bytecode.h:223
@ OP_INPUT_LINE
Definition bytecode.h:141
@ OP_FD_POLL_READ
Definition bytecode.h:231
@ OP_MUL
Definition bytecode.h:46
@ OP_SERIAL_CONFIG
Definition bytecode.h:242
@ OP_SOCK_UNIX_CONNECT
Definition bytecode.h:227
@ OP_PCRE2_FINDALL
Definition bytecode.h:194
@ OP_SET
Definition bytecode.h:87
@ OP_PROC_RUN
Definition bytecode.h:142
@ OP_LOG10
Definition bytecode.h:264
@ OP_ENUMERATE
Definition bytecode.h:117
@ OP_FD_POLL_WRITE
Definition bytecode.h:232
@ OP_PCRE2_TEST
Definition bytecode.h:192
@ OP_SIN
Definition bytecode.h:259
@ OP_TIME_NOW_MS
Definition bytecode.h:144
@ OP_SCLAMP
Definition bytecode.h:98
@ OP_XML_TEXT
Definition bytecode.h:217
@ OP_FD_SET_NONBLOCK
Definition bytecode.h:230
@ OP_STORE_GLOBAL
Definition bytecode.h:42
@ OP_SOCK_TCP_CONNECT
Definition bytecode.h:222
@ OP_SUBSTR
Definition bytecode.h:103
@ OP_UCLAMP
Definition bytecode.h:97
@ OP_INI_SET
Definition bytecode.h:209
@ OP_TO_STRING
Definition bytecode.h:94
@ OP_SOCK_CLOSE
Definition bytecode.h:225
@ OP_GT
Definition bytecode.h:51
@ OP_INI_SAVE
Definition bytecode.h:211
@ OP_SERIAL_RECV
Definition bytecode.h:244
@ OP_GTE
Definition bytecode.h:52
@ OP_HALT
Definition bytecode.h:65
@ OP_ABS
Definition bytecode.h:124
@ OP_INI_LOAD
Definition bytecode.h:203
@ OP_TYPEOF
Definition bytecode.h:96
@ OP_RETURN
Definition bytecode.h:61
@ OP_REGEX_MATCH
Definition bytecode.h:107
@ OP_EXIT
Definition bytecode.h:235
@ OP_SQLITE_QUERY
Definition bytecode.h:181
@ OP_APOP
Definition bytecode.h:86
@ OP_SOCK_UNIX_LISTEN
Definition bytecode.h:226
@ OP_BNOT
Definition bytecode.h:160
@ OP_THREAD_JOIN
Definition bytecode.h:152
@ OP_CLAMP
Definition bytecode.h:123
@ OP_SERIAL_CLOSE
Definition bytecode.h:245
@ OP_RUST_HELLO_ARGS
Definition bytecode.h:279
@ OP_CURL_GET
Definition bytecode.h:173
@ OP_MAKE_ARRAY
Definition bytecode.h:79
@ OP_AND
Definition bytecode.h:71
@ OP_TRY_PUSH
Definition bytecode.h:248
@ OP_CLEAR
Definition bytecode.h:114
@ OP_RANDOM_SEED
Definition bytecode.h:126
@ OP_INDEX_SET
Definition bytecode.h:81
@ OP_LOG
Definition bytecode.h:263
@ OP_INI_FREE
Definition bytecode.h:204
@ OP_REMOVE
Definition bytecode.h:89
@ OP_THROW
Definition bytecode.h:250
@ OP_HAS_KEY
Definition bytecode.h:133
@ OP_OR
Definition bytecode.h:72
@ OP_PCSC_DISCONNECT
Definition bytecode.h:188
@ OP_FLOOR
Definition bytecode.h:253
@ OP_JSON_FROM_FILE
Definition bytecode.h:169
@ OP_INSERT
Definition bytecode.h:88
@ OP_EXP
Definition bytecode.h:262
@ OP_RUST_GET_SP
Definition bytecode.h:281
@ OP_JUMP_IF_FALSE
Definition bytecode.h:58
@ OP_MAKE_MAP
Definition bytecode.h:130
@ OP_POP
Definition bytecode.h:56
@ OP_BXOR
Definition bytecode.h:159
void bytecode_dump(const Bytecode *bc)
Print a human-readable dump of constants and instructions to stdout.
Definition bytecode.c:423
void bytecode_set_operand(Bytecode *bc, int idx, int32_t operand)
Patch the operand of a previously emitted instruction.
Definition bytecode.c:78
int bytecode_add_constant(Bytecode *bc, Value v)
Append a constant to a Bytecode's constant table.
Definition bytecode.c:48
Value v
Definition cast.c:22
int idx
Definition index_of.c:38
Instruction * instructions
Definition bytecode.h:294
const char * source_file
Definition bytecode.h:302
const char * name
Definition bytecode.h:301
Value * constants
Definition bytecode.h:297
int const_count
Definition bytecode.h:298
int instr_count
Definition bytecode.h:295
OpCode op
Definition bytecode.h:289
int32_t operand
Definition bytecode.h:290
Tagged union representing a Fun value.
Definition value.h:68
Defines the Value type and associated functions for the Fun VM.