def tp_main(TP,char *fname, void *code, int len) ->tp_obj: print("tp_interp.cpp:tp_main") print(fname) return tp_import_from_buffer_with_filename(tp,fname, "__main__", code, len) def tp_ez_call(TP, const char *mod, const char *func, tp_obj params) ->tp_obj: tp_obj tmp tmp = tp_get(tp,tp->modules,tp_string_atom(tp, mod)) tmp = tp_get(tp,tmp,tp_string_atom(tp, func)) return tp_call(tp,tmp,params) ## Function: tp_compile ## Compile some tinypy code. ## TODO this must call out to CPython in a subprocess ##def tp_compile(TP, tp_obj text, tp_obj fname) ->tp_obj: ## return tp_ez_call(tp, "tinypy.compiler.py2bc", "compile", tp_params_v2(tp, text, fname)) #ifndef __EMSCRIPTEN_major__ def tp_args(TP, int argc, char *argv[]) ->tp_obj: tp_obj self = tp_list_t(tp) int i for (i=1; imodules) tp_set(tp, sys, tp_string_atom(tp, "argv"), args) tp_set(tp, tp->modules, tp_string_atom(tp, "sys"), sys) #endif ## Function: tp_init ## Initializes a new virtual machine. ## The given parameters have the same format as the parameters to main, and ## allow passing arguments to your tinypy scripts. ## Returns: ## The newly created tinypy instance. def tp_init(int argc, char *argv[]) -> tp_vm*: tp_vm *tp = tp_create_vm() tp_module_builtins_init(tp) if not defined(__EMSCRIPTEN_major__): tp_module_sys_init(tp, argc, argv) tp_module_corelib_init(tp) ##tp_module_compiler_init(tp) return tp ## Function: tp_deinit ## Destroys a VM instance. ## When you no longer need an instance of tinypy, you can use this to free all ## memory used by it. Even when you are using only a single tinypy instance, it ## may be good practice to call this function on shutdown. def tp_deinit(TP): while tp->root.list.val->len: tpd_list_pop(tp, tp->root.list.val, 0, "tp_deinit") tp_full(tp) tp_full(tp) tp_delete(tp,tp->root) tp_gc_deinit(tp) free(tp)