Fun 0.41.5
The programming language that makes you have fun!
Loading...
Searching...
No Matches
close.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/**
11 * @file close.c
12 * @brief Implements the OP_SQLITE_CLOSE opcode (conditional build).
13 *
14 * Closes a registered SQLite database handle and unregisters it when
15 * FUN_WITH_SQLITE is enabled. No-op when SQLite support is disabled.
16 *
17 * OP_SQLITE_CLOSE: (handle:int) -> Nil
18 */
19
21#ifdef FUN_WITH_SQLITE
22 Value vh = pop_value(vm);
23 int hid = (int)vh.i;
26 if (h && h->db) {
27 sqlite3_close(h->db);
28 h->db = NULL;
30 }
32#else
33 Value v = pop_value(vm);
35 push_value(vm, make_nil());
36#endif
37 break;
38}
@ OP_SQLITE_CLOSE
Definition bytecode.h:179
Value v
Definition cast.c:22
free_value(vh)
push_value(vm, make_nil())
int hid
Definition disconnect.c:33
CURL * h
Definition download.c:59
Value vh
Definition get_bool.c:38
static void sql_reg_del(int id)
Remove a SQLite handle entry from the registry.
Definition sqlite.c:85
static SqlHandle * sql_reg_get(int id)
Look up a registered SQLite handle by id.
Definition sqlite.c:70
Node in a singly-linked list of registered SQLite handles.
Definition sqlite.c:29
Tagged union representing a Fun value.
Definition value.h:68
Value make_nil(void)
Construct a nil Value.
Definition value.c:126
static Value pop_value(VM *vm)
Pop a Value from the VM operand stack.
Definition vm.c:580