Struct gluon::Compiler [] [src]

pub struct Compiler { /* fields omitted */ }

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

Methods

impl Compiler
[src]

[src]

Creates a new compiler with default settings

[src]

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

[src]

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

[src]

[src]

Parse expr_str, returning an expression if successful

[src]

Parse input, returning an expression if successful

[src]

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

[src]

[src]

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

[src]

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

[src]

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.

[src]

[src]

Loads filename and compiles and runs its input by calling load_script

[src]

[src]

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");

[src]

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_async::<String>(&vm, "example",
        " let string  = import! \"std/string.glu\" in string.trim \"    Hello world  \t\" ")
    .sync_or_error()
    .unwrap();
let expected = ("Hello world".to_string(), Type::string());

assert_eq!(result, expected);
}

[src]

Compiles and runs expr_str. If the expression is of type IO a the action is evaluated and a value of type a is returned

[src]

Trait Implementations

impl Default for Compiler
[src]

[src]

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