Fun 0.41.5
The programming language that makes You have fun
Loading...
Searching...
No Matches
exec.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
17
22#ifdef FUN_WITH_SQLITE
23 Value vsql = pop_value(vm);
24 Value vh = pop_value(vm);
25 int hid = (int)vh.i;
26 char *sql = value_to_string_alloc(&vsql);
28 free_value(vsql);
29 SqlHandle *h = sql_reg_get(hid);
30 if (!h || !h->db || !sql) {
31 if (sql) free(sql);
32 push_value(vm, make_int(SQLITE_MISUSE));
33 break;
34 }
35 char *errmsg = NULL;
36 int rc = sqlite3_exec(h->db, sql, NULL, NULL, &errmsg);
37 if (errmsg) sqlite3_free(errmsg);
38 free(sql);
40#else
41 Value v1 = pop_value(vm);
43 Value v2 = pop_value(vm);
46#endif
47 break;
48}
@ OP_SQLITE_EXEC
Definition bytecode.h:180
push_value(vm, make_int(-1))
free_value(v1)
Value v2
Definition exec.c:43
int rc
free(vals)
Tagged union representing a Fun value.
Definition value.h:68
Value vh
Definition stubs.c:44
char * value_to_string_alloc(const Value *v)
Allocate a printable C string for a Value.
Definition value.c:641
Value make_int(int64_t v)
Construct a Value representing a 64-bit integer.
Definition value.c:51