@@ -418,32 +418,42 @@ impl Runtime {
418418 rval : MutableHandleValue ,
419419 options : CompileOptionsWrapper ,
420420 ) -> Result < ( ) , ( ) > {
421- debug ! (
422- "Evaluating script from {} with content {}" ,
423- options. filename( ) ,
424- script
425- ) ;
426-
427- let _ac = JSAutoRealm :: new ( unsafe { self . cx ( ) . raw_cx ( ) } , glob. get ( ) ) ;
428-
429- unsafe {
430- let mut source = transform_str_to_source_text ( & script) ;
431- if !Evaluate2 ( self . cx ( ) . raw_cx ( ) , options. ptr , & mut source, rval. into ( ) ) {
432- debug ! ( "...err!" ) ;
433- maybe_resume_unwind ( ) ;
434- Err ( ( ) )
435- } else {
436- // we could return the script result but then we'd have
437- // to root it and so forth and, really, who cares?
438- debug ! ( "...ok!" ) ;
439- Ok ( ( ) )
440- }
441- }
421+ evaluate_script ( self . cx ( ) , glob, script, rval, options)
442422 }
443423
444- pub fn new_compile_options ( & mut self , filename : & str , line : u32 ) -> CompileOptionsWrapper {
424+ pub fn new_compile_options ( & self , filename : & str , line : u32 ) -> CompileOptionsWrapper {
445425 // SAFETY: `cx` argument points to a non-null, valid JSContext
446- unsafe { CompileOptionsWrapper :: new ( self . cx ( ) . raw_cx ( ) , filename, line) }
426+ unsafe { CompileOptionsWrapper :: new ( self . cx_no_gc ( ) . raw_cx_no_gc ( ) , filename, line) }
427+ }
428+ }
429+
430+ pub fn evaluate_script (
431+ cx : & mut crate :: context:: JSContext ,
432+ glob : HandleObject ,
433+ script : & str ,
434+ rval : MutableHandleValue ,
435+ options : CompileOptionsWrapper ,
436+ ) -> Result < ( ) , ( ) > {
437+ debug ! (
438+ "Evaluating script from {} with content {}" ,
439+ options. filename( ) ,
440+ script
441+ ) ;
442+
443+ let _ac = JSAutoRealm :: new ( unsafe { cx. raw_cx ( ) } , glob. get ( ) ) ;
444+
445+ unsafe {
446+ let mut source = transform_str_to_source_text ( & script) ;
447+ if !Evaluate2 ( cx. raw_cx ( ) , options. ptr , & mut source, rval. into ( ) ) {
448+ debug ! ( "...err!" ) ;
449+ maybe_resume_unwind ( ) ;
450+ Err ( ( ) )
451+ } else {
452+ // we could return the script result but then we'd have
453+ // to root it and so forth and, really, who cares?
454+ debug ! ( "...ok!" ) ;
455+ Ok ( ( ) )
456+ }
447457 }
448458}
449459
0 commit comments