2026-06-20 15:09:10 +01:00
|
|
|
#ifndef RUNTIME_SCOPE_H_
|
|
|
|
|
#define RUNTIME_SCOPE_H_
|
2026-05-17 15:34:24 +01:00
|
|
|
|
2026-05-24 20:22:05 +01:00
|
|
|
#include "var-map.h"
|
2026-05-17 15:34:24 +01:00
|
|
|
|
2026-05-25 10:33:29 +01:00
|
|
|
#include <bshell/runtime/script-block.h>
|
2026-05-24 20:22:05 +01:00
|
|
|
#include <fx/collections/hashtable.h>
|
2026-05-17 15:34:24 +01:00
|
|
|
#include <fx/namemap.h>
|
|
|
|
|
#include <fx/queue.h>
|
|
|
|
|
#include <fx/vector.h>
|
|
|
|
|
|
|
|
|
|
struct bshell_runtime;
|
|
|
|
|
|
2026-05-25 10:33:29 +01:00
|
|
|
enum bshell_runtime_scope_type {
|
2026-05-17 15:34:24 +01:00
|
|
|
RUNTIME_SCOPE_OTHER = 0,
|
|
|
|
|
RUNTIME_SCOPE_SCRIPT,
|
|
|
|
|
RUNTIME_SCOPE_GLOBAL,
|
|
|
|
|
};
|
|
|
|
|
|
2026-05-25 10:33:29 +01:00
|
|
|
struct bshell_runtime_scope {
|
|
|
|
|
enum bshell_runtime_scope_type s_type;
|
2026-05-17 15:34:24 +01:00
|
|
|
fx_queue_entry s_entry;
|
2026-05-24 20:22:05 +01:00
|
|
|
struct var_map s_vars;
|
|
|
|
|
fx_hashtable *s_functions;
|
2026-05-17 15:34:24 +01:00
|
|
|
FX_VECTOR_DECLARE(fx_value, s_stack);
|
|
|
|
|
size_t s_ip;
|
|
|
|
|
|
|
|
|
|
bshell_scriptblock *s_block;
|
|
|
|
|
bshell_instruction *s_instr;
|
|
|
|
|
size_t s_nr_instr;
|
|
|
|
|
fx_value *s_pool;
|
|
|
|
|
size_t s_nr_pool;
|
|
|
|
|
};
|
|
|
|
|
|
2026-05-25 10:33:29 +01:00
|
|
|
extern struct bshell_runtime_scope *runtime_push_scope(
|
2026-05-17 15:34:24 +01:00
|
|
|
struct bshell_runtime *rt,
|
2026-05-25 10:33:29 +01:00
|
|
|
enum bshell_runtime_scope_type type,
|
2026-05-17 15:34:24 +01:00
|
|
|
bshell_scriptblock *block);
|
|
|
|
|
extern void runtime_pop_scope(struct bshell_runtime *rt);
|
2026-06-20 15:09:10 +01:00
|
|
|
extern struct bshell_runtime_scope *runtime_get_scope(
|
|
|
|
|
struct bshell_runtime *rt);
|
2026-05-17 15:34:24 +01:00
|
|
|
|
2026-05-25 10:33:29 +01:00
|
|
|
extern void bshell_runtime_scope_push_value(
|
|
|
|
|
struct bshell_runtime_scope *scope,
|
2026-05-24 20:22:05 +01:00
|
|
|
const fx_value *value);
|
2026-06-20 15:09:10 +01:00
|
|
|
extern fx_value bshell_runtime_scope_pop_value(
|
|
|
|
|
struct bshell_runtime_scope *scope);
|
2026-05-17 15:34:24 +01:00
|
|
|
|
2026-05-25 10:33:29 +01:00
|
|
|
extern void bshell_runtime_scope_set_block(
|
|
|
|
|
struct bshell_runtime_scope *scope,
|
2026-05-17 15:34:24 +01:00
|
|
|
bshell_scriptblock *block);
|
|
|
|
|
|
|
|
|
|
#endif
|