@@ -50,9 +50,14 @@ fn main() {
50
50
}
51
51
}
52
52
53
- fn _run_string ( source : & String , source_path : Option < String > ) {
53
+ fn _run_string ( source : & str , source_path : Option < String > ) {
54
54
let mut vm = VirtualMachine :: new ( ) ;
55
- let code_obj = compile:: compile ( & mut vm, & source, compile:: Mode :: Exec , source_path) . unwrap ( ) ;
55
+ let code_obj = compile:: compile (
56
+ & mut vm,
57
+ & source. to_string ( ) ,
58
+ compile:: Mode :: Exec ,
59
+ source_path,
60
+ ) . unwrap ( ) ;
56
61
debug ! ( "Code object: {:?}" , code_obj. borrow( ) ) ;
57
62
let builtins = vm. get_builtin_scope ( ) ;
58
63
let vars = vm. context ( ) . new_scope ( Some ( builtins) ) ; // Keep track of local variables
@@ -74,7 +79,7 @@ fn run_command(source: &mut String) {
74
79
_run_string ( source, None )
75
80
}
76
81
77
- fn run_script ( script_file : & String ) {
82
+ fn run_script ( script_file : & str ) {
78
83
debug ! ( "Running file {}" , script_file) ;
79
84
// Parse an ast from it:
80
85
let filepath = Path :: new ( script_file) ;
@@ -87,8 +92,8 @@ fn run_script(script_file: &String) {
87
92
}
88
93
}
89
94
90
- fn shell_exec ( vm : & mut VirtualMachine , source : & String , scope : PyObjectRef ) -> bool {
91
- match compile:: compile ( vm, source, compile:: Mode :: Single , None ) {
95
+ fn shell_exec ( vm : & mut VirtualMachine , source : & str , scope : PyObjectRef ) -> bool {
96
+ match compile:: compile ( vm, & source. to_string ( ) , compile:: Mode :: Single , None ) {
92
97
Ok ( code) => {
93
98
match vm. run_code_obj ( code, scope. clone ( ) ) {
94
99
Ok ( _value) => {
0 commit comments