Struct Compiler

Source
pub struct Compiler { /* private fields */ }
Available on crate feature luau only.
Expand description

Luau compiler

Implementations§

Source§

impl Compiler

Source

pub const fn new() -> Self

Creates Luau compiler instance with default options

Source

pub const fn set_optimization_level(self, level: u8) -> Self

Sets Luau compiler optimization level.

Possible values:

  • 0 - no optimization
  • 1 - baseline optimization level that doesn’t prevent debuggability (default)
  • 2 - includes optimizations that harm debuggability such as inlining
Source

pub const fn set_debug_level(self, level: u8) -> Self

Sets Luau compiler debug level.

Possible values:

  • 0 - no debugging support
  • 1 - line info & function names only; sufficient for backtraces (default)
  • 2 - full debug info with local & upvalue names; necessary for debugger
Source

pub const fn set_type_info_level(self, level: u8) -> Self

Sets Luau type information level used to guide native code generation decisions.

Possible values:

  • 0 - generate for native modules (default)
  • 1 - generate for all modules
Source

pub const fn set_coverage_level(self, level: u8) -> Self

Sets Luau compiler code coverage level.

Possible values:

  • 0 - no code coverage support (default)
  • 1 - statement coverage
  • 2 - statement and expression coverage (verbose)
Source

pub fn set_mutable_globals<S: Into<String>>(self, globals: Vec<S>) -> Self

Sets a list of globals that are mutable.

It disables the import optimization for fields accessed through these.

Source

pub fn set_userdata_types<S: Into<String>>(self, types: Vec<S>) -> Self

Sets a list of userdata types that will be included in the type information.

Source

pub fn set_library_constants<L, M>( self, constants: Vec<(L, M, CompileConstant)>, ) -> Self
where L: Into<String>, M: Into<String>,

Sets constants for known library members.

The constants are used by the compiler to optimize the generated bytecode. Optimization level must be at least 2 for this to have any effect.

The first element of the tuple is the library name,the second is the member name, and the third is the constant value.

Source

pub fn set_disabled_builtins<S: Into<String>>(self, builtins: Vec<S>) -> Self

Sets a list of builtins that should be disabled.

Source

pub fn compile(&self, source: impl AsRef<[u8]>) -> Result<Vec<u8>>

Compiles the source into bytecode.

Returns Error::SyntaxError if the source code is invalid.

Trait Implementations§

Source§

impl Clone for Compiler

Source§

fn clone(&self) -> Compiler

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Compiler

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Compiler

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> MaybeSend for T
where T: Send,