Fun API Documentation 0.42.1
The programming language that makes you have fun!
Loading...
Searching...
No Matches
bytecode.c
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
10#include "bytecode.h"
11#include <stdio.h>
12#include <stdlib.h>
13
14/**
15 * @file bytecode.c
16 * @brief Bytecode container utilities: creation, mutation, dump helpers.
17 */
18
19/**
20 * @brief Allocate and initialize an empty Bytecode object.
21 *
22 * Initializes instruction and constant arrays to empty and clears metadata.
23 * Caller owns the returned pointer and must free it with bytecode_free().
24 *
25 * @return Newly allocated Bytecode*, or NULL on allocation failure.
26 */
28 Bytecode *bc = (Bytecode *)malloc(sizeof(Bytecode));
29 bc->instructions = NULL;
30 bc->instr_count = 0;
31 bc->constants = NULL;
32 bc->const_count = 0;
33 bc->name = NULL;
34 bc->source_file = NULL;
35 return bc;
36}
37
38/**
39 * @brief Append a constant to a Bytecode's constant table with de-duplication.
40 *
41 * The value is compared against existing constants and if an equal constant is
42 * already present, its index is returned without modifying the table. Equality
43 * uses value_equals which supports numeric cross-type (int/float) equality and
44 * string content equality. The caller retains ownership of @p v in all cases.
45 * When a new constant is inserted, a deep copy is stored in the table.
46 *
47 * @param bc Target bytecode (must not be NULL).
48 * @param v Value to store (copied on insert).
49 * @return The index of the stored or matched existing constant (zero-based).
50 */
52 /* Linear scan for a match. This is fast enough for small constant pools and
53 * avoids duplicates (smaller bytecode, better cache locality). */
54 for (int i = 0; i < bc->const_count; ++i) {
55 if (value_equals(&bc->constants[i], &v)) {
56 return i;
57 }
58 }
59
60 /* Not found: append a copy */
61 bc->constants = (Value *)realloc(bc->constants, sizeof(Value) * (bc->const_count + 1));
62 bc->constants[bc->const_count] = copy_value(&v);
63 return bc->const_count++;
64}
65
66/**
67 * @brief Append a single instruction to the instruction stream.
68 *
69 * @param bc Target bytecode (must not be NULL).
70 * @param op Opcode to emit.
71 * @param operand Operand value (semantics depend on opcode).
72 * @return The index of the emitted instruction (zero-based).
73 */
74int bytecode_add_instruction(Bytecode *bc, OpCode op, int32_t operand) {
75 bc->instructions = (Instruction *)realloc(bc->instructions, sizeof(Instruction) * (bc->instr_count + 1));
76 bc->instructions[bc->instr_count].op = op;
77 bc->instructions[bc->instr_count].operand = operand;
78 return bc->instr_count++;
79}
80
81/**
82 * @brief Patch the operand of a previously emitted instruction.
83 *
84 * Silently ignores out-of-bounds indices.
85 *
86 * @param bc Target bytecode.
87 * @param idx Instruction index to patch.
88 * @param operand New operand value.
89 */
90void bytecode_set_operand(Bytecode *bc, int idx, int32_t operand) {
91 if (idx >= 0 && idx < bc->instr_count) {
92 bc->instructions[idx].operand = operand;
93 }
94}
95
96/**
97 * @brief Free a Bytecode and all memory it owns.
98 *
99 * Frees constants (deep), instruction array, and metadata strings.
100 * Accepts NULL and is then a no-op.
101 *
102 * @param bc Bytecode to free (may be NULL).
103 */
105 if (!bc) return;
106 for (int i = 0; i < bc->const_count; ++i) {
107 free_value(bc->constants[i]);
108 }
109 free(bc->constants);
110 free(bc->instructions);
111 if (bc->name) free((void *)bc->name);
112 if (bc->source_file) free((void *)bc->source_file);
113 free(bc);
114}
115
116/**
117 * @brief Convert an opcode enum to a short mnemonic string.
118 *
119 * @param op Opcode value.
120 * @return Read-only C string with the mnemonic, or "???" if unknown.
121 */
122static const char *opcode_name(OpCode op) {
123 switch (op) {
124 case OP_NOP:
125 return "NOP";
126 case OP_LOAD_CONST:
127 return "LOAD_CONST";
128 case OP_LOAD_LOCAL:
129 return "LOAD_LOCAL";
130 case OP_STORE_LOCAL:
131 return "STORE_LOCAL";
132 case OP_LOAD_GLOBAL:
133 return "LOAD_GLOBAL";
134 case OP_STORE_GLOBAL:
135 return "STORE_GLOBAL";
136 case OP_ADD:
137 return "ADD";
138 case OP_SUB:
139 return "SUB";
140 case OP_MUL:
141 return "MUL";
142 case OP_DIV:
143 return "DIV";
144 case OP_LT:
145 return "LT";
146 case OP_LTE:
147 return "LTE";
148 case OP_GT:
149 return "GT";
150 case OP_GTE:
151 return "GTE";
152 case OP_EQ:
153 return "EQ";
154 case OP_NEQ:
155 return "NEQ";
156 case OP_POP:
157 return "POP";
158 case OP_JUMP:
159 return "JUMP";
160 case OP_JUMP_IF_FALSE:
161 return "JUMP_IF_FALSE";
162 case OP_CALL:
163 return "CALL";
164 case OP_RETURN:
165 return "RETURN";
166 case OP_PRINT:
167 return "PRINT";
168 case OP_ECHO:
169 return "ECHO";
170 case OP_HALT:
171 return "HALT";
172 case OP_MOD:
173 return "MOD";
174 case OP_AND:
175 return "AND";
176 case OP_OR:
177 return "OR";
178 case OP_NOT:
179 return "NOT";
180 case OP_DUP:
181 return "DUP";
182 case OP_SWAP:
183 return "SWAP";
184 case OP_MAKE_ARRAY:
185 return "MAKE_ARRAY";
186 case OP_INDEX_GET:
187 return "INDEX_GET";
188 case OP_INDEX_SET:
189 return "INDEX_SET";
190 case OP_LEN:
191 return "LEN";
192 case OP_PUSH:
193 return "ARR_PUSH";
194 case OP_APOP:
195 return "ARR_POP";
196 case OP_SET:
197 return "ARR_SET";
198 case OP_INSERT:
199 return "ARR_INSERT";
200 case OP_REMOVE:
201 return "ARR_REMOVE";
202 case OP_SLICE:
203 return "SLICE";
204 case OP_TO_NUMBER:
205 return "TO_NUMBER";
206 case OP_TO_STRING:
207 return "TO_STRING";
208 case OP_TYPEOF:
209 return "TYPEOF";
210 case OP_CAST:
211 return "CAST";
212 case OP_SPLIT:
213 return "SPLIT";
214 case OP_JOIN:
215 return "JOIN";
216 case OP_SUBSTR:
217 return "SUBSTR";
218 case OP_FIND:
219 return "FIND";
220 case OP_REGEX_MATCH:
221 return "REGEX_MATCH";
222 case OP_REGEX_SEARCH:
223 return "REGEX_SEARCH";
224 case OP_REGEX_REPLACE:
225 return "REGEX_REPLACE";
226 case OP_CONTAINS:
227 return "CONTAINS";
228 case OP_INDEX_OF:
229 return "INDEX_OF";
230 case OP_CLEAR:
231 return "CLEAR";
232 case OP_ENUMERATE:
233 return "ENUMERATE";
234 case OP_ZIP:
235 return "ZIP";
236 case OP_MIN:
237 return "MIN";
238 case OP_MAX:
239 return "MAX";
240 case OP_CLAMP:
241 return "CLAMP";
242 case OP_ABS:
243 return "ABS";
244 case OP_POW:
245 return "POW";
246 case OP_RANDOM_SEED:
247 return "RANDOM_SEED";
248 case OP_RANDOM_INT:
249 return "RANDOM_INT";
250 case OP_MAKE_MAP:
251 return "MAKE_MAP";
252 case OP_KEYS:
253 return "KEYS";
254 case OP_VALUES:
255 return "VALUES";
256 case OP_HAS_KEY:
257 return "HAS_KEY";
258 case OP_READ_FILE:
259 return "READ_FILE";
260 case OP_WRITE_FILE:
261 return "WRITE_FILE";
262 case OP_ENV:
263 return "ENV";
264 case OP_INPUT_LINE:
265 return "INPUT_LINE";
266 case OP_PROC_RUN:
267 return "PROC_RUN";
268 case OP_PROC_SYSTEM:
269 return "PROC_SYSTEM";
270 case OP_TIME_NOW_MS:
271 return "TIME_NOW_MS";
272 case OP_CLOCK_MONO_MS:
273 return "CLOCK_MONO_MS";
274 case OP_DATE_FORMAT:
275 return "DATE_FORMAT";
276 case OP_ENV_ALL:
277 return "ENV_ALL";
278 case OP_FUN_VERSION:
279 return "FUN_VERSION";
280 case OP_THREAD_SPAWN:
281 return "THREAD_SPAWN";
282 case OP_THREAD_JOIN:
283 return "THREAD_JOIN";
284 case OP_SLEEP_MS:
285 return "SLEEP_MS";
286 case OP_RANDOM_NUMBER:
287 return "RANDOM_NUMBER";
288 case OP_BAND:
289 return "BAND";
290 case OP_BOR:
291 return "BOR";
292 case OP_BXOR:
293 return "BXOR";
294 case OP_BNOT:
295 return "BNOT";
296 case OP_SHL:
297 return "SHL";
298 case OP_SHR:
299 return "SHR";
300 case OP_ROTL:
301 return "ROTL";
302 case OP_ROTR:
303 return "ROTR";
304 case OP_JSON_PARSE:
305 return "JSON_PARSE";
307 return "JSON_STRINGIFY";
309 return "JSON_FROM_FILE";
310 case OP_JSON_TO_FILE:
311 return "JSON_TO_FILE";
312 case OP_CURL_GET:
313 return "CURL_GET";
314 case OP_CURL_POST:
315 return "CURL_POST";
316 case OP_CURL_DOWNLOAD:
317 return "CURL_DOWNLOAD";
318 case OP_SQLITE_OPEN:
319 return "SQLITE_OPEN";
320 case OP_SQLITE_CLOSE:
321 return "SQLITE_CLOSE";
322 case OP_SQLITE_EXEC:
323 return "SQLITE_EXEC";
324 case OP_SQLITE_QUERY:
325 return "SQLITE_QUERY";
327 return "PCSC_ESTABLISH";
328 case OP_PCSC_RELEASE:
329 return "PCSC_RELEASE";
331 return "PCSC_LIST_READERS";
332 case OP_PCSC_CONNECT:
333 return "PCSC_CONNECT";
335 return "PCSC_DISCONNECT";
336 case OP_PCSC_TRANSMIT:
337 return "PCSC_TRANSMIT";
338 case OP_PCRE2_TEST:
339 return "PCRE2_TEST";
340 case OP_PCRE2_MATCH:
341 return "PCRE2_MATCH";
342 case OP_PCRE2_FINDALL:
343 return "PCRE2_FINDALL";
344 case OP_OPENSSL_MD5:
345 return "OPENSSL_MD5";
347 return "OPENSSL_SHA256";
349 return "OPENSSL_SHA512";
351 return "OPENSSL_RIPEMD160";
352 case OP_INI_LOAD:
353 return "INI_LOAD";
354 case OP_INI_FREE:
355 return "INI_FREE";
357 return "INI_GET_STRING";
358 case OP_INI_GET_INT:
359 return "INI_GET_INT";
361 return "INI_GET_DOUBLE";
362 case OP_INI_GET_BOOL:
363 return "INI_GET_BOOL";
364 case OP_INI_SET:
365 return "INI_SET";
366 case OP_INI_UNSET:
367 return "INI_UNSET";
368 case OP_INI_SAVE:
369 return "INI_SAVE";
370 case OP_XML_PARSE:
371 return "XML_PARSE";
372 case OP_XML_ROOT:
373 return "XML_ROOT";
374 case OP_XML_NAME:
375 return "XML_NAME";
376 case OP_XML_TEXT:
377 return "XML_TEXT";
378 case OP_FLOOR:
379 return "FLOOR";
380 case OP_CEIL:
381 return "CEIL";
382 case OP_TRUNC:
383 return "TRUNC";
384 case OP_ROUND:
385 return "ROUND";
386 case OP_SIN:
387 return "SIN";
388 case OP_COS:
389 return "COS";
390 case OP_TAN:
391 return "TAN";
392 case OP_EXP:
393 return "EXP";
394 case OP_LOG:
395 return "LOG";
396 case OP_LOG10:
397 return "LOG10";
398 case OP_SQRT:
399 return "SQRT";
400 case OP_GCD:
401 return "GCD";
402 case OP_LCM:
403 return "LCM";
404 case OP_ISQRT:
405 return "ISQRT";
406 case OP_SIGN:
407 return "SIGN";
408 case OP_FMIN:
409 return "FMIN";
410 case OP_FMAX:
411 return "FMAX";
412 case OP_RUST_HELLO:
413 return "RUST_HELLO";
415 return "RUST_HELLO_ARGS";
417 return "RUST_HELLO_ARGS_RETURN";
418 case OP_RUST_GET_SP:
419 return "RUST_GET_SP";
420 case OP_RUST_SET_EXIT:
421 return "RUST_SET_EXIT";
422 default:
423 return "???";
424 }
425}
426
427/**
428 * @brief Print a human-readable dump of constants and instructions to stdout.
429 *
430 * Intended for debugging and tests. Formats constants with print_value()
431 * and shows each instruction index, mnemonic and operand.
432 *
433 * @param bc Bytecode to dump (prints "<null bytecode>" if NULL).
434 */
435void bytecode_dump(const Bytecode *bc) {
436 if (!bc) {
437 printf("<null bytecode>\n");
438 return;
439 }
440 printf("Constants (%d):\n", bc->const_count);
441 for (int i = 0; i < bc->const_count; ++i) {
442 printf(" [%d] ", i);
443 print_value(&bc->constants[i]);
444 printf("\n");
445 }
446 printf("Instructions (%d):\n", bc->instr_count);
447 for (int i = 0; i < bc->instr_count; ++i) {
448 const Instruction *ins = &bc->instructions[i];
449 printf(" %3d: %-15s %d\n", i, opcode_name(ins->op), ins->operand);
450 }
451}
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:74
static const char * opcode_name(OpCode op)
Convert an opcode enum to a short mnemonic string.
Definition bytecode.c:122
void bytecode_free(Bytecode *bc)
Free a Bytecode and all memory it owns.
Definition bytecode.c:104
void bytecode_dump(const Bytecode *bc)
Print a human-readable dump of constants and instructions to stdout.
Definition bytecode.c:435
void bytecode_set_operand(Bytecode *bc, int idx, int32_t operand)
Patch the operand of a previously emitted instruction.
Definition bytecode.c:90
int bytecode_add_constant(Bytecode *bc, Value v)
Append a constant to a Bytecode's constant table with de-duplication.
Definition bytecode.c:51
Definitions for the Fun VM bytecode: opcodes, instruction format, and bytecode container API.
OpCode
VM operation codes executed by the Fun virtual machine.
Definition bytecode.h:35
@ OP_OPENSSL_SHA512
Definition bytecode.h:210
@ OP_PCSC_RELEASE
Definition bytecode.h:196
@ OP_GCD
Definition bytecode.h:279
@ OP_JSON_PARSE
Definition bytecode.h:173
@ 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:291
@ OP_ROTL
Definition bytecode.h:169
@ OP_TAN
Definition bytecode.h:272
@ OP_OPENSSL_SHA256
Definition bytecode.h:209
@ OP_JSON_STRINGIFY
Definition bytecode.h:174
@ OP_PCSC_TRANSMIT
Definition bytecode.h:200
@ OP_TRUNC
Definition bytecode.h:266
@ OP_CEIL
Definition bytecode.h:265
@ OP_SPLIT
Definition bytecode.h:101
@ OP_CAST
Definition bytecode.h:95
@ OP_EQ
Definition bytecode.h:53
@ OP_PCRE2_MATCH
Definition bytecode.h:204
@ OP_RANDOM_INT
Definition bytecode.h:127
@ OP_LTE
Definition bytecode.h:50
@ OP_NEQ
Definition bytecode.h:54
@ OP_ISQRT
Definition bytecode.h:281
@ OP_FMAX
Definition bytecode.h:286
@ OP_PCSC_ESTABLISH
Definition bytecode.h:195
@ OP_SQLITE_EXEC
Definition bytecode.h:186
@ OP_FMIN
Definition bytecode.h:285
@ OP_SWAP
Definition bytecode.h:76
@ OP_OPENSSL_RIPEMD160
Definition bytecode.h:211
@ OP_PCSC_LIST_READERS
Definition bytecode.h:197
@ OP_BOR
Definition bytecode.h:164
@ OP_CURL_POST
Definition bytecode.h:180
@ OP_XML_NAME
Definition bytecode.h:227
@ OP_REGEX_SEARCH
Definition bytecode.h:108
@ OP_POW
Definition bytecode.h:125
@ OP_NOT
Definition bytecode.h:73
@ OP_SQRT
Definition bytecode.h:276
@ OP_MOD
Definition bytecode.h:70
@ OP_INI_UNSET
Definition bytecode.h:221
@ OP_WRITE_FILE
Definition bytecode.h:137
@ OP_SQLITE_CLOSE
Definition bytecode.h:185
@ OP_FIND
Definition bytecode.h:104
@ OP_SIGN
Definition bytecode.h:282
@ OP_DUP
Definition bytecode.h:75
@ OP_NOP
Definition bytecode.h:36
@ OP_ENV_ALL
Definition bytecode.h:153
@ OP_VALUES
Definition bytecode.h:132
@ OP_RANDOM_NUMBER
Definition bytecode.h:160
@ OP_INDEX_GET
Definition bytecode.h:80
@ OP_LCM
Definition bytecode.h:280
@ OP_LEN
Definition bytecode.h:84
@ OP_THREAD_SPAWN
Definition bytecode.h:157
@ OP_INDEX_OF
Definition bytecode.h:113
@ OP_MIN
Definition bytecode.h:121
@ OP_SLEEP_MS
Definition bytecode.h:159
@ OP_REGEX_REPLACE
Definition bytecode.h:109
@ OP_MAX
Definition bytecode.h:122
@ OP_SQLITE_OPEN
Definition bytecode.h:184
@ OP_XML_PARSE
Definition bytecode.h:225
@ OP_STORE_LOCAL
Definition bytecode.h:39
@ OP_SLICE
Definition bytecode.h:90
@ OP_INI_GET_DOUBLE
Definition bytecode.h:218
@ OP_JOIN
Definition bytecode.h:102
@ OP_COS
Definition bytecode.h:271
@ OP_BAND
Definition bytecode.h:163
@ OP_ECHO
Definition bytecode.h:64
@ OP_ROTR
Definition bytecode.h:170
@ OP_DATE_FORMAT
Definition bytecode.h:152
@ OP_PROC_SYSTEM
Definition bytecode.h:143
@ OP_OPENSSL_MD5
Definition bytecode.h:208
@ OP_ZIP
Definition bytecode.h:118
@ OP_SUB
Definition bytecode.h:45
@ OP_INI_GET_INT
Definition bytecode.h:217
@ OP_XML_ROOT
Definition bytecode.h:226
@ OP_JUMP
Definition bytecode.h:57
@ OP_DIV
Definition bytecode.h:47
@ OP_SHR
Definition bytecode.h:168
@ OP_JSON_TO_FILE
Definition bytecode.h:176
@ OP_LT
Definition bytecode.h:49
@ OP_INI_GET_BOOL
Definition bytecode.h:219
@ OP_ROUND
Definition bytecode.h:267
@ OP_PRINT
Definition bytecode.h:63
@ OP_INI_GET_STRING
Definition bytecode.h:216
@ OP_SHL
Definition bytecode.h:167
@ OP_KEYS
Definition bytecode.h:131
@ OP_RUST_HELLO
Definition bytecode.h:289
@ OP_LOAD_LOCAL
Definition bytecode.h:38
@ OP_CURL_DOWNLOAD
Definition bytecode.h:181
@ OP_PCSC_CONNECT
Definition bytecode.h:198
@ OP_RUST_SET_EXIT
Definition bytecode.h:293
@ 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:154
@ OP_LOAD_CONST
Definition bytecode.h:37
@ OP_ADD
Definition bytecode.h:44
@ OP_CONTAINS
Definition bytecode.h:112
@ OP_INPUT_LINE
Definition bytecode.h:141
@ OP_MUL
Definition bytecode.h:46
@ OP_PCRE2_FINDALL
Definition bytecode.h:205
@ OP_SET
Definition bytecode.h:87
@ OP_PROC_RUN
Definition bytecode.h:142
@ OP_LOG10
Definition bytecode.h:275
@ OP_ENUMERATE
Definition bytecode.h:117
@ OP_PCRE2_TEST
Definition bytecode.h:203
@ OP_SIN
Definition bytecode.h:270
@ OP_TIME_NOW_MS
Definition bytecode.h:144
@ OP_XML_TEXT
Definition bytecode.h:228
@ OP_STORE_GLOBAL
Definition bytecode.h:42
@ OP_SUBSTR
Definition bytecode.h:103
@ OP_INI_SET
Definition bytecode.h:220
@ OP_TO_STRING
Definition bytecode.h:94
@ OP_GT
Definition bytecode.h:51
@ OP_INI_SAVE
Definition bytecode.h:222
@ OP_GTE
Definition bytecode.h:52
@ OP_HALT
Definition bytecode.h:65
@ OP_ABS
Definition bytecode.h:124
@ OP_INI_LOAD
Definition bytecode.h:214
@ OP_TYPEOF
Definition bytecode.h:96
@ OP_RETURN
Definition bytecode.h:61
@ OP_REGEX_MATCH
Definition bytecode.h:107
@ OP_SQLITE_QUERY
Definition bytecode.h:187
@ OP_APOP
Definition bytecode.h:86
@ OP_BNOT
Definition bytecode.h:166
@ OP_THREAD_JOIN
Definition bytecode.h:158
@ OP_CLAMP
Definition bytecode.h:123
@ OP_RUST_HELLO_ARGS
Definition bytecode.h:290
@ OP_CURL_GET
Definition bytecode.h:179
@ OP_MAKE_ARRAY
Definition bytecode.h:79
@ OP_AND
Definition bytecode.h:71
@ 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:274
@ OP_INI_FREE
Definition bytecode.h:215
@ OP_REMOVE
Definition bytecode.h:89
@ OP_HAS_KEY
Definition bytecode.h:133
@ OP_OR
Definition bytecode.h:72
@ OP_PCSC_DISCONNECT
Definition bytecode.h:199
@ OP_FLOOR
Definition bytecode.h:264
@ OP_JSON_FROM_FILE
Definition bytecode.h:175
@ OP_INSERT
Definition bytecode.h:88
@ OP_EXP
Definition bytecode.h:273
@ OP_RUST_GET_SP
Definition bytecode.h:292
@ 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:165
Instruction * instructions
Definition bytecode.h:308
const char * source_file
Definition bytecode.h:316
const char * name
Definition bytecode.h:315
Value * constants
Definition bytecode.h:311
int const_count
Definition bytecode.h:312
int instr_count
Definition bytecode.h:309
OpCode op
Definition bytecode.h:303
int32_t operand
Definition bytecode.h:304
Tagged union representing a Fun value.
Definition value.h:68
void print_value(const Value *v)
Print a human-readable representation of a Value to stdout.
Definition value.c:552
void free_value(Value v)
Free dynamic storage owned by a Value.
Definition value.c:517
int value_equals(const Value *a, const Value *b)
Compare two Values for equality.
Definition value.c:695
Value copy_value(const Value *v)
Shallow copy a Value.
Definition value.c:415