Files
bshell/bshell.runtime/runtime/scope.h
T

54 lines
1.3 KiB
C

#ifndef RUNTIME_SCOPE_H_
#define RUNTIME_SCOPE_H_
#include "var-map.h"
#include <bshell/runtime/script-block.h>
#include <fx/collections/hashtable.h>
#include <fx/namemap.h>
#include <fx/queue.h>
#include <fx/vector.h>
struct bshell_runtime;
enum bshell_runtime_scope_type {
RUNTIME_SCOPE_OTHER = 0,
RUNTIME_SCOPE_SCRIPT,
RUNTIME_SCOPE_GLOBAL,
};
struct bshell_runtime_scope {
enum bshell_runtime_scope_type s_type;
fx_queue_entry s_entry;
struct var_map s_vars;
fx_hashtable *s_functions;
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;
};
extern struct bshell_runtime_scope *runtime_push_scope(
struct bshell_runtime *rt,
enum bshell_runtime_scope_type type,
bshell_scriptblock *block);
extern void runtime_pop_scope(struct bshell_runtime *rt);
extern struct bshell_runtime_scope *runtime_get_scope(
struct bshell_runtime *rt);
extern void bshell_runtime_scope_push_value(
struct bshell_runtime_scope *scope,
const fx_value *value);
extern fx_value bshell_runtime_scope_pop_value(
struct bshell_runtime_scope *scope);
extern void bshell_runtime_scope_set_block(
struct bshell_runtime_scope *scope,
bshell_scriptblock *block);
#endif