File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed
Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,12 @@ use std::str::FromStr;
2323
2424mod shell;
2525
26- fn main ( ) {
26+ pub use rustpython_vm;
27+
28+ pub fn run < F > ( init : F ) -> !
29+ where
30+ F : FnOnce ( & mut VirtualMachine ) ,
31+ {
2732 #[ cfg( feature = "flame-it" ) ]
2833 let main_guard = flame:: start_guard ( "RustPython main" ) ;
2934 env_logger:: init ( ) ;
@@ -45,13 +50,16 @@ fn main() {
4550 }
4651
4752 // We only include the standard library bytecode in WASI when initializing
48- let init = if cfg ! ( target_os = "wasi" ) {
53+ let init_param = if cfg ! ( target_os = "wasi" ) {
4954 InitParameter :: Internal
5055 } else {
5156 InitParameter :: External
5257 } ;
5358
54- let interp = Interpreter :: new ( settings, init) ;
59+ let interp = Interpreter :: new_with_init ( settings, |vm| {
60+ init ( vm) ;
61+ init_param
62+ } ) ;
5563
5664 let exitcode = interp. enter ( move |vm| {
5765 let res = run_rustpython ( vm, & matches) ;
@@ -110,7 +118,7 @@ fn main() {
110118 exitcode
111119 } ) ;
112120
113- process:: exit ( exitcode) ;
121+ process:: exit ( exitcode)
114122}
115123
116124fn flush_std ( vm : & VirtualMachine ) {
You can’t perform that action at this time.
0 commit comments