Hash :
c8c572d2
Author :
Thomas de Grivel
Date :
2025-03-09T19:45:56
split env.h and env_eval.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
/* kc3
* Copyright from 2022 to 2025 kmx.io <contact@kmx.io>
*
* Permission is hereby granted to use this software granted the above
* copyright notice and this permission paragraph are included in all
* copies and substantial portions of this software.
*
* THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
* PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
* AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
* THIS SOFTWARE.
*/
#ifndef LIBKC3_ENV_H
#define LIBKC3_ENV_H
#include "types.h"
/* Global singletons. */
s_env * env_default (void);
void env_default_set (s_env *env);
s_env * env_global (void);
bool env_global_set (s_env *env);
/* Stack allocation compatible functions, call env_clean after use. */
void env_clean (s_env *env);
s_env * env_init (s_env *env, int *argc, char ***argv);
s_env * env_init_copy (s_env *env, s_env *src);
/* Heap allocation functions, call env_delete after use. */
void env_delete (s_env *env);
s_env * env_new (int *argc, char ***argv);
/* Observers. */
s_list ** env_args (s_env *env, s_list **dest);
s_tag * env_frames_get (s_env *env, const s_sym *name);
s_ident * env_ident_resolve_module (s_env *env,
const s_ident *ident,
s_ident *dest);
const s_sym ** env_module (s_env *env, const s_sym **dest);
bool * env_module_has_ident (s_env *env, const s_sym *module,
const s_ident *ident, bool *dest);
bool * env_module_has_symbol (s_env *env, const s_sym *module,
const s_sym *sym, bool *dest);
const s_time ** env_module_load_time (s_env *env, const s_sym *module,
const s_time **dest);
s_list ** env_module_search_modules (s_env *env,
const s_sym * const *module,
s_list **dest);
s_list ** env_search_modules (s_env *env, s_list **dest);
s_list ** env_stacktrace (s_env *env, s_list **dest);
bool env_sym_search_modules (s_env *env,
const s_sym *sym,
const s_sym **dest);
/* Operators. */
s_tag * env_and (s_env *env, s_tag *a, s_tag *b, s_tag *dest);
bool env_def (s_env *env, const s_ident *ident, s_tag *value);
const s_sym * env_def_clean (s_env *env, const s_sym *module,
const s_tag *tag_clean);
s_tag * env_defmodule (s_env *env, const s_sym * const *name,
const s_block *block, s_tag *dest);
bool env_defoperator (s_env *env, s_tag *tag_op);
const s_sym * env_defstruct (s_env *env, s_list *spec);
s_fact_w * env_fact_w_eval (s_env *env, s_fact_w *fact,
s_fact_w *dest);
s_tag * env_facts_collect_with (s_env *env, s_facts *facts,
s_list **spec,
s_callable *callback,
s_tag *dest);
s_tag * env_facts_collect_with_tags (s_env *env, s_facts *facts,
s_tag *subject,
s_tag *predicate,
s_tag *object,
s_callable *callback,
s_tag *dest);
s_tag * env_facts_first_with (s_env *env, s_facts *facts,
s_list **spec,
s_callable *callback,
s_tag *dest);
s_tag * env_facts_first_with_tags (s_env *env, s_facts *facts,
s_tag *subject,
s_tag *predicate,
s_tag *object,
s_callable *callback,
s_tag *dest);
s_tag * env_facts_with (s_env *env, s_facts *facts,
s_list **spec, s_callable *callback,
s_tag *dest);
s_tag * env_facts_with_macro (s_env *env, s_tag *facts_tag,
s_tag *spec_tag, s_tag *block_tag,
s_tag *dest);
s_tag * env_facts_with_tags (s_env *env, s_facts *facts,
s_tag *subject, s_tag *predicate,
s_tag *object, s_callable *callback,
s_tag *dest);
s_tag * env_ident_get (s_env *env, const s_ident *ident,
s_tag *dest);
bool * env_ident_is_special_operator (s_env *env,
const s_ident *ident,
bool *dest);
s_tag * env_kc3_def (s_env *env, const s_call *call,
s_tag *dest);
s_tag * env_let (s_env *env, s_tag *vars, s_tag *tag,
s_tag *dest);
bool env_load (s_env *env, const s_str *path);
bool env_maybe_reload (s_env *env, const s_str *path);
bool * env_module_is_loading (s_env *env, const s_sym *module,
bool *dest);
bool env_module_is_loading_set (s_env *env,
const s_sym *module,
bool value);
bool env_module_load (s_env *env, const s_sym *module);
bool env_module_maybe_reload (s_env *env,
const s_sym *module);
s_tag * env_or (s_env *env, s_tag *a, s_tag *b, s_tag *dest);
u8 env_special_operator_arity (s_env *env,
const s_ident *ident);
bool * env_struct_type_exists (s_env *env, const s_sym *module,
bool *dest);
s_struct_type **
env_struct_type_find (s_env *env, const s_sym *module,
s_struct_type **dest);
f_clean env_struct_type_get_clean (s_env *env,
const s_sym *module);
s_list ** env_struct_type_get_spec (s_env *env,
const s_sym *module,
s_list **dest);
bool * env_struct_type_has_spec (s_env *env,
const s_sym *module,
bool *dest);
bool env_tag_ident_is_bound (s_env *env,
const s_tag *tag);
s_tag * env_while (s_env *env, s_tag *cond, s_tag *body,
s_tag *dest);
/* Modifiers. */
bool env_call_get (s_env *env, s_call *call);
bool env_module_ensure_loaded (s_env *env, const s_sym *module);
/* Control structures. */
void env_error_f (s_env *env, const char *fmt, ...);
void env_error_tag (s_env *env, s_tag *tag);
void env_longjmp (s_env *env, jmp_buf *jmp_buf);
#endif /* LIBKC3_ENV_H */