@@ -51,26 +51,26 @@ fn main() {
51
51
. get_matches ( ) ;
52
52
53
53
// Construct vm:
54
- let mut vm = VirtualMachine :: new ( ) ;
54
+ let vm = VirtualMachine :: new ( ) ;
55
55
56
56
// Figure out if a -c option was given:
57
57
let result = if let Some ( command) = matches. value_of ( "c" ) {
58
- run_command ( & mut vm, command. to_string ( ) )
58
+ run_command ( & vm, command. to_string ( ) )
59
59
} else if let Some ( module) = matches. value_of ( "m" ) {
60
- run_module ( & mut vm, module)
60
+ run_module ( & vm, module)
61
61
} else {
62
62
// Figure out if a script was passed:
63
63
match matches. value_of ( "script" ) {
64
- None => run_shell ( & mut vm) ,
65
- Some ( filename) => run_script ( & mut vm, filename) ,
64
+ None => run_shell ( & vm) ,
65
+ Some ( filename) => run_script ( & vm, filename) ,
66
66
}
67
67
} ;
68
68
69
69
// See if any exception leaked out:
70
- handle_exception ( & mut vm, result) ;
70
+ handle_exception ( & vm, result) ;
71
71
}
72
72
73
- fn _run_string ( vm : & mut VirtualMachine , source : & str , source_path : String ) -> PyResult {
73
+ fn _run_string ( vm : & VirtualMachine , source : & str , source_path : String ) -> PyResult {
74
74
let code_obj = compile:: compile (
75
75
source,
76
76
& compile:: Mode :: Exec ,
@@ -86,28 +86,28 @@ fn _run_string(vm: &mut VirtualMachine, source: &str, source_path: String) -> Py
86
86
vm. run_code_obj ( code_obj, vars)
87
87
}
88
88
89
- fn handle_exception ( vm : & mut VirtualMachine , result : PyResult ) {
89
+ fn handle_exception ( vm : & VirtualMachine , result : PyResult ) {
90
90
if let Err ( err) = result {
91
91
print_exception ( vm, & err) ;
92
92
std:: process:: exit ( 1 ) ;
93
93
}
94
94
}
95
95
96
- fn run_command ( vm : & mut VirtualMachine , mut source : String ) -> PyResult {
96
+ fn run_command ( vm : & VirtualMachine , mut source : String ) -> PyResult {
97
97
debug ! ( "Running command {}" , source) ;
98
98
99
99
// This works around https://github.com/RustPython/RustPython/issues/17
100
100
source. push ( '\n' ) ;
101
101
_run_string ( vm, & source, "<stdin>" . to_string ( ) )
102
102
}
103
103
104
- fn run_module ( vm : & mut VirtualMachine , module : & str ) -> PyResult {
104
+ fn run_module ( vm : & VirtualMachine , module : & str ) -> PyResult {
105
105
debug ! ( "Running module {}" , module) ;
106
106
let current_path = PathBuf :: from ( "." ) ;
107
107
import:: import_module ( vm, current_path, module)
108
108
}
109
109
110
- fn run_script ( vm : & mut VirtualMachine , script_file : & str ) -> PyResult {
110
+ fn run_script ( vm : & VirtualMachine , script_file : & str ) -> PyResult {
111
111
debug ! ( "Running file {}" , script_file) ;
112
112
// Parse an ast from it:
113
113
let file_path = Path :: new ( script_file) ;
@@ -120,7 +120,7 @@ fn run_script(vm: &mut VirtualMachine, script_file: &str) -> PyResult {
120
120
}
121
121
}
122
122
123
- fn shell_exec ( vm : & mut VirtualMachine , source : & str , scope : Scope ) -> Result < ( ) , CompileError > {
123
+ fn shell_exec ( vm : & VirtualMachine , source : & str , scope : Scope ) -> Result < ( ) , CompileError > {
124
124
match compile:: compile (
125
125
source,
126
126
& compile:: Mode :: Single ,
@@ -159,7 +159,7 @@ fn get_history_path() -> PathBuf {
159
159
xdg_dirs. place_cache_file ( "repl_history.txt" ) . unwrap ( )
160
160
}
161
161
162
- fn run_shell ( vm : & mut VirtualMachine ) -> PyResult {
162
+ fn run_shell ( vm : & VirtualMachine ) -> PyResult {
163
163
println ! (
164
164
"Welcome to the magnificent Rust Python {} interpreter" ,
165
165
crate_version!( )
0 commit comments