Struct gluon::Compiler[][src]

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