pub fn with_debug_options(
      mut stdlib: impl StandardLibrary,
      debug_options: DebugOptions,
   ) -> Self {
      let mut gc = Memory::new();
      // This is a little bad because it allocates a bunch of empty dtables only to discard them.
      let mut env = Environment::new(BuiltinDispatchTables::empty());

      macro_rules! get_dtables {
         ($type_name:tt, $define:tt) => {{
            let tb = TypeBuilder::new($type_name);
            let tb = stdlib.$define(tb);
            // Unwrapping here is fine because the stdlib should never declare THAT many methods.
            tb.build(&mut env, &mut gc).unwrap()
         }};
      }
      // TODO: Expose _*_type in the global scope.
      let nil = get_dtables!("Nil", define_nil);
      let boolean = get_dtables!("Boolean", define_boolean);
      let number = get_dtables!("Number", define_number);
      let string = get_dtables!("String", define_string);
      let list = get_dtables!("List", define_list);
      env.builtin_dtables = BuiltinDispatchTables {
         nil: Gc::clone(&nil.instance_dtable),
         boolean: Gc::clone(&boolean.instance_dtable),
         number: Gc::clone(&number.instance_dtable),
         string: Gc::clone(&string.instance_dtable),
         function: Gc::new(DispatchTable::new_for_instance("Function")),
         list: Gc::clone(&list.instance_dtable),
      };

      let mut engine = Self {
         env,
         globals: Globals::new(),
         gc,
         debug_options,
      };
      // Unwrapping here is fine because at this point we haven't got quite that many globals
      // registered to overflow an Opr24.
      engine.set_built_type(&nil).unwrap();
      engine.set_built_type(&boolean).unwrap();
      engine.set_built_type(&number).unwrap();
      engine.set_built_type(&string).unwrap();

      engine
   }
/// Creates a new engine with specific debug options.
///
/// [`Engine::new`] creates an engine with [`Default`] debug options, and should generally be
/// preferred unless you're debugging the language's internals.
///
/// Constructing the engine can fail if the standard library defines way too many methods.
Creates a new engine with specific debug options.
[`Engine::new`] creates an engine with [`Default`] debug options, and should generally be
preferred unless you're debugging the language's internals.

Constructing the engine can fail if the standard library defines way too many methods.
Creates a new engine with specific debug options . [ ` Engine :: new ` ] creates an engine with [ ` Default ` ] debug options and should generally be preferred unless you ' re debugging the language ' s internals . Constructing the engine can fail if the standard library defines way too many methods .
pub fn with_debug_options(
      mut stdlib: impl StandardLibrary,
      debug_options: DebugOptions,
   ) -> Self {
      let mut gc = Memory::new();
      // This is a little bad because it allocates a bunch of empty dtables only to discard them.
      let mut env = Environment::new(BuiltinDispatchTables::empty());
      macro_rules! get_dtables {
         ($type_name:tt, $define:tt) => {{
            let tb = TypeBuilder::new($type_name);
            let tb = stdlib.$define(tb);
            // Unwrapping here is fine because the stdlib should never declare THAT many methods.
            tb.build(&mut env, &mut gc).unwrap()
         }};
      }
      // TODO: Expose _*_type in the global scope.
      let nil = get_dtables!("Nil", define_nil);
      let boolean = get_dtables!("Boolean", define_boolean);
      let number = get_dtables!("Number", define_number);
      let string = get_dtables!("String", define_string);
      let list = get_dtables!("List", define_list);
      env.builtin_dtables = BuiltinDispatchTables {
         nil: Gc::clone(&nil.instance_dtable),
         boolean: Gc::clone(&boolean.instance_dtable),
         number: Gc::clone(&number.instance_dtable),
         string: Gc::clone(&string.instance_dtable),
         function: Gc::new(DispatchTable::new_for_instance("Function")),
         list: Gc::clone(&list.instance_dtable),
      };
      let mut engine = Self {
         env,
         globals: Globals::new(),
         gc,
         debug_options,
      };
      // Unwrapping here is fine because at this point we haven't got quite that many globals
      // registered to overflow an Opr24.
      engine.set_built_type(&nil).unwrap();
      engine.set_built_type(&boolean).unwrap();
      engine.set_built_type(&number).unwrap();
      engine.set_built_type(&string).unwrap();
      engine
   }
pub fn with_debug_options ( mut stdlib : impl StandardLibrary , debug_options : DebugOptions , ) -> Self { let mut gc = Memory :: new ( ) ; // This is a little bad because it allocates a bunch of empty dtables only to discard them. let mut env = Environment :: new ( BuiltinDispatchTables :: empty ( ) ) ; macro_rules! get_dtables { ( $type_name : tt $define : tt ) => { { let tb TypeBuilder new ( $type_name ) let tb stdlib $define ( tb ) // Unwrapping here is fine because the stdlib should never declare THAT many methods. tb build ( mut env mut gc ) unwrap ( ) } } ; } // TODO: Expose _*_type in the global scope. let nil = get_dtables ! ( " " define_nil ) ; let boolean = get_dtables ! ( " " define_boolean ) ; let number = get_dtables ! ( " " define_number ) ; let string = get_dtables ! ( " " define_string ) ; let list = get_dtables ! ( " " define_list ) ; env . builtin_dtables = BuiltinDispatchTables { nil : Gc :: clone ( & nil . instance_dtable ) , boolean : Gc :: clone ( & boolean . instance_dtable ) , number : Gc :: clone ( & number . instance_dtable ) , string : Gc :: clone ( & string . instance_dtable ) , function : Gc :: new ( DispatchTable :: new_for_instance ( " " ) ) , list : Gc :: clone ( & list . instance_dtable ) , } ; let mut engine = Self { env , globals : Globals :: new ( ) , gc , debug_options , } ; // Unwrapping here is fine because at this point we haven't got quite that many globals // registered to overflow an Opr24. engine . set_built_type ( & nil ) . unwrap ( ) ; engine . set_built_type ( & boolean ) . unwrap ( ) ; engine . set_built_type ( & number ) . unwrap ( ) ; engine . set_built_type ( & string ) . unwrap ( ) ; engine }
Creates a new engine with specific debug options.
Creates a new engine with specific debug options .
stdlib
impl StandardLibrary
debug_options
DebugOptions