Struct gluon::Compiler
[−]
[src]
pub struct Compiler { /* fields omitted */ }
Type which makes parsing, typechecking and compiling an AST into bytecode
Methods
impl Compiler
[src]
fn new() -> Compiler
Creates a new compiler with default settings
fn implicit_prelude(self, implicit_prelude: bool) -> Compiler
Sets wheter the implicit prelude should be include when compiling a file using this compiler (default: true)
fn parse_expr(&mut self,
file: &str,
expr_str: &str)
-> StdResult<SpannedExpr<Symbol>, InFile<ParseError>>
file: &str,
expr_str: &str)
-> StdResult<SpannedExpr<Symbol>, InFile<ParseError>>
Parse expr_str
, returning an expression if successful
fn parse_partial_expr(&mut self,
file: &str,
expr_str: &str)
-> StdResult<SpannedExpr<Symbol>, (Option<SpannedExpr<Symbol>>, InFile<ParseError>)>
file: &str,
expr_str: &str)
-> StdResult<SpannedExpr<Symbol>, (Option<SpannedExpr<Symbol>>, InFile<ParseError>)>
Parse input
, returning an expression if successful
fn typecheck_expr(&mut self,
vm: &Thread,
file: &str,
expr_str: &str,
expr: &mut SpannedExpr<Symbol>)
-> Result<ArcType>
vm: &Thread,
file: &str,
expr_str: &str,
expr: &mut SpannedExpr<Symbol>)
-> Result<ArcType>
Parse and typecheck expr_str
returning the typechecked expression and type of the
expression
fn typecheck_str(&mut self,
vm: &Thread,
file: &str,
expr_str: &str,
expected_type: Option<&ArcType>)
-> Result<(SpannedExpr<Symbol>, ArcType)>
vm: &Thread,
file: &str,
expr_str: &str,
expected_type: Option<&ArcType>)
-> Result<(SpannedExpr<Symbol>, ArcType)>
fn compile_script(&mut self,
vm: &Thread,
filename: &str,
expr_str: &str,
expr: &SpannedExpr<Symbol>)
-> Result<CompiledFunction>
vm: &Thread,
filename: &str,
expr_str: &str,
expr: &SpannedExpr<Symbol>)
-> Result<CompiledFunction>
Compiles expr
into a function which can be added and run by the vm
fn extract_metadata(&mut self,
vm: &Thread,
file: &str,
expr_str: &str)
-> Result<(SpannedExpr<Symbol>, ArcType, Metadata)>
vm: &Thread,
file: &str,
expr_str: &str)
-> Result<(SpannedExpr<Symbol>, ArcType, Metadata)>
Parses and typechecks expr_str
followed by extracting metadata from the created
expression
fn load_script(&mut self,
vm: &Thread,
filename: &str,
input: &str)
-> Result<()>
vm: &Thread,
filename: &str,
input: &str)
-> Result<()>
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.
fn load_file(&mut self, vm: &Thread, filename: &str) -> Result<()>
Loads filename
and compiles and runs its input by calling load_script
fn run_expr<'vm, T>(&mut self,
vm: &'vm Thread,
name: &str,
expr_str: &str)
-> Result<(T, ArcType)> where T: Getable<'vm> + VmType
vm: &'vm Thread,
name: &str,
expr_str: &str)
-> Result<(T, ArcType)> where T: Getable<'vm> + VmType
Compiles and runs the expression in expr_str
. If successful the value from running the
expression is returned
fn run_io_expr<'vm, T>(&mut self,
vm: &'vm Thread,
name: &str,
expr_str: &str)
-> Result<(T, ArcType)> where T: Getable<'vm> + VmType, T::Type: Sized
vm: &'vm Thread,
name: &str,
expr_str: &str)
-> Result<(T, ArcType)> where T: Getable<'vm> + VmType, T::Type: Sized
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