@@ -45,26 +45,26 @@ fn main() {
45
45
. get_matches ( ) ;
46
46
47
47
// Construct vm:
48
- let mut vm = VirtualMachine :: new ( ) ;
48
+ let vm = VirtualMachine :: new ( ) ;
49
49
50
50
// Figure out if a -c option was given:
51
51
let result = if let Some ( command) = matches. value_of ( "c" ) {
52
- run_command ( & mut vm, command. to_string ( ) )
52
+ run_command ( & vm, command. to_string ( ) )
53
53
} else if let Some ( module) = matches. value_of ( "m" ) {
54
- run_module ( & mut vm, module)
54
+ run_module ( & vm, module)
55
55
} else {
56
56
// Figure out if a script was passed:
57
57
match matches. value_of ( "script" ) {
58
- None => run_shell ( & mut vm) ,
59
- Some ( filename) => run_script ( & mut vm, filename) ,
58
+ None => run_shell ( & vm) ,
59
+ Some ( filename) => run_script ( & vm, filename) ,
60
60
}
61
61
} ;
62
62
63
63
// See if any exception leaked out:
64
- handle_exception ( & mut vm, result) ;
64
+ handle_exception ( & vm, result) ;
65
65
}
66
66
67
- fn _run_string ( vm : & mut VirtualMachine , source : & str , source_path : String ) -> PyResult {
67
+ fn _run_string ( vm : & VirtualMachine , source : & str , source_path : String ) -> PyResult {
68
68
let code_obj = compile:: compile (
69
69
source,
70
70
& compile:: Mode :: Exec ,
@@ -80,28 +80,28 @@ fn _run_string(vm: &mut VirtualMachine, source: &str, source_path: String) -> Py
80
80
vm. run_code_obj ( code_obj, vars)
81
81
}
82
82
83
- fn handle_exception ( vm : & mut VirtualMachine , result : PyResult ) {
83
+ fn handle_exception ( vm : & VirtualMachine , result : PyResult ) {
84
84
if let Err ( err) = result {
85
85
print_exception ( vm, & err) ;
86
86
std:: process:: exit ( 1 ) ;
87
87
}
88
88
}
89
89
90
- fn run_command ( vm : & mut VirtualMachine , mut source : String ) -> PyResult {
90
+ fn run_command ( vm : & VirtualMachine , mut source : String ) -> PyResult {
91
91
debug ! ( "Running command {}" , source) ;
92
92
93
93
// This works around https://github.com/RustPython/RustPython/issues/17
94
94
source. push ( '\n' ) ;
95
95
_run_string ( vm, & source, "<stdin>" . to_string ( ) )
96
96
}
97
97
98
- fn run_module ( vm : & mut VirtualMachine , module : & str ) -> PyResult {
98
+ fn run_module ( vm : & VirtualMachine , module : & str ) -> PyResult {
99
99
debug ! ( "Running module {}" , module) ;
100
100
let current_path = PathBuf :: from ( "." ) ;
101
101
import:: import_module ( vm, current_path, module)
102
102
}
103
103
104
- fn run_script ( vm : & mut VirtualMachine , script_file : & str ) -> PyResult {
104
+ fn run_script ( vm : & VirtualMachine , script_file : & str ) -> PyResult {
105
105
debug ! ( "Running file {}" , script_file) ;
106
106
// Parse an ast from it:
107
107
let file_path = Path :: new ( script_file) ;
@@ -114,7 +114,7 @@ fn run_script(vm: &mut VirtualMachine, script_file: &str) -> PyResult {
114
114
}
115
115
}
116
116
117
- fn shell_exec ( vm : & mut VirtualMachine , source : & str , scope : Scope ) -> Result < ( ) , CompileError > {
117
+ fn shell_exec ( vm : & VirtualMachine , source : & str , scope : Scope ) -> Result < ( ) , CompileError > {
118
118
match compile:: compile (
119
119
source,
120
120
& compile:: Mode :: Single ,
@@ -153,7 +153,7 @@ fn get_history_path() -> PathBuf {
153
153
xdg_dirs. place_cache_file ( "repl_history.txt" ) . unwrap ( )
154
154
}
155
155
156
- fn run_shell ( vm : & mut VirtualMachine ) -> PyResult {
156
+ fn run_shell ( vm : & VirtualMachine ) -> PyResult {
157
157
println ! (
158
158
"Welcome to the magnificent Rust Python {} interpreter" ,
159
159
crate_version!( )
0 commit comments