[][src]Struct gluon::Compiler

pub struct Compiler { /* fields omitted */ }

Type which makes parsing, typechecking and compiling an AST into bytecode

Methods

impl Compiler
[src]

Creates a new compiler with default settings

Sets whether the implicit prelude should be include when compiling a file using this compiler (default: true)

Sets whether the compiler should emit debug information such as source maps and variable names. (default: true)

Sets whether IO expressions are evaluated. (default: false)

Sets whether full metadata is required (default: false)

Parse expr_str, returning an expression if successful

Parse input, returning an expression if successful

Parse and typecheck expr_str returning the typechecked expression and type of the expression

Compiles expr into a function which can be added and run by the vm

Compiles the source code expr_str into bytecode serialized using serializer

Loads bytecode from a Deserializer and stores it into the module name.

load_script is equivalent to compile_to_bytecode followed by load_bytecode

Parses and typechecks expr_str followed by extracting metadata from the created expression

Compiles input and if it is successful runs the resulting code and stores the resulting value in the vm.

If at any point the function fails the resulting error is returned and nothing is added to the VM.

Loads filename and compiles and runs its input by calling load_script

Compiles and runs the expression in expr_str. If successful the value from running the expression is returned

Examples

Import from gluon's standard library and evaluate a string

let vm = new_vm();
let (result, _) = Compiler::new()
    .run_expr::<String>(
        &vm,
        "example",
        " let string  = import! \"std/string.glu\" in string.trim \"  Hello world  \t\" "
    )
    .unwrap();
assert_eq!(result, "Hello world");

Compiles and runs the expression in expr_str. If successful the value from running the expression is returned

Examples

Import from gluon's standard library and evaluate a string

let vm = new_vm();
let result = Compiler::new()
    .run_expr::<String>(&vm, "example",
        " let string  = import! \"std/string.glu\" in string.trim \"    Hello world  \t\" ")
    .unwrap();
let expected = ("Hello world".to_string(), Type::string());

assert_eq!(result, expected);
}

Trait Implementations

impl Default for Compiler
[src]

Returns the "default value" for a type. Read more

Auto Trait Implementations

impl Send for Compiler

impl Sync for Compiler

Blanket Implementations

impl<T> From for T
[src]

Performs the conversion.

impl<T, U> Into for T where
    U: From<T>, 
[src]

Performs the conversion.

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

🔬 This is a nightly-only experimental API. (try_from)

Performs the conversion.

impl<T> Borrow for T where
    T: ?Sized
[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut for T where
    T: ?Sized
[src]

Mutably borrows from an owned value. Read more

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

🔬 This is a nightly-only experimental API. (try_from)

Performs the conversion.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

🔬 This is a nightly-only experimental API. (get_type_id)

this method will likely be replaced by an associated static

Gets the TypeId of self. Read more

impl<T> Any for T where
    T: Any
[src]

impl<D, T> FromPtr for T
[src]

impl<Choices> CoproductSubsetter for Choices
[src]

Extract a subset of the possible types in a coproduct (or get the remaining possibilities) Read more

impl<Source> Sculptor for Source
[src]

Consumes the current HList and returns an HList with the requested shape. Read more

impl<T, U, I> LiftInto for T where
    U: LiftFrom<T, I>, 
[src]

Performs the indexed conversion.

impl<T> Any for T where
    T: Any
[src]

impl<T> Erased for T
[src]