00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef _BML_VM_H_
00020 #define _BML_VM_H_
00021
00022 #include "vm_types.h"
00023 #include "containers.h"
00024 #include "abstract_io.h"
00025 #include "code.h"
00026 #include "thread.h"
00027
00028 #include "../config.h"
00029
00135 #define TINYAML_VERSION PACKAGE_VERSION
00136
00151 vm_t vm_new();
00153 void vm_del(vm_t);
00154
00156 vm_t vm_set_lib_file(vm_t, const char*);
00158 vm_t vm_add_opcode(vm_t, const char*name, opcode_arg_t, opcode_stub_t);
00160 opcode_dict_t vm_get_dict(vm_t);
00161
00163 opcode_t vm_get_opcode_by_name(vm_t, const char*);
00164
00175 vm_t vm_serialize_program(vm_t, program_t, writer_t);
00176
00180 program_t vm_unserialize_program(vm_t, reader_t);
00182 program_t vm_compile_file(vm_t, const char*);
00184 program_t vm_compile_buffer(vm_t, const char*);
00185
00193 vm_t vm_run_program_fg(vm_t, program_t, word_t ip, word_t prio);
00195 vm_t vm_run_program_bg(vm_t, program_t, word_t ip, word_t prio);
00196
00201 thread_t vm_add_thread(vm_t, program_t, word_t ip, word_t prio, int fg);
00202
00204 thread_t vm_get_current_thread(vm_t);
00205
00207 vm_t vm_kill_thread(vm_t,thread_t);
00208
00216 vm_t vm_push_data(vm_t,vm_data_type_t, word_t);
00218 vm_t vm_push_caller(vm_t, program_t, word_t ip, word_t has_closure);
00220 vm_t vm_push_catcher(vm_t, program_t, word_t);
00222 vm_t vm_peek_data(vm_t,int,vm_data_type_t*,word_t*);
00224 vm_t vm_poke_data(vm_t,vm_data_type_t,word_t);
00226 vm_t vm_peek_caller(vm_t,program_t*,word_t*);
00228 vm_t vm_peek_catcher(vm_t,program_t*,word_t*);
00230 vm_t vm_pop_data(vm_t,word_t);
00232 vm_t vm_pop_caller(vm_t,word_t);
00234 vm_t vm_pop_catcher(vm_t,word_t);
00235
00237 program_t _VM_CALL vm_get_CS(vm_t);
00239 word_t _VM_CALL vm_get_IP(vm_t);
00240
00242 vm_data_t _VM_CALL _vm_pop(vm_t vm);
00244 vm_data_t _VM_CALL _vm_peek(vm_t vm);
00245
00253 vm_t vm_set_engine(vm_t, vm_engine_t);
00254
00262 void _VM_CALL vm_schedule_cycle(vm_t);
00263
00267 vm_t _VM_CALL vm_collect(vm_t vm, vm_obj_t o);
00269 vm_t _VM_CALL vm_uncollect(vm_t vm, vm_obj_t o);
00270
00272 int vm_printf(const char* fmt, ...);
00274 int vm_printerrf(const char* fmt, ...);
00277 #endif
00278