[−][src]Struct gluon::Compiler
Type which makes parsing, typechecking and compiling an AST into bytecode
Methods
impl Compiler
[src]
pub fn new() -> Compiler
[src]
Creates a new compiler with default settings
pub fn implicit_prelude(self, implicit_prelude: bool) -> Self
[src]
Sets whether the implicit prelude should be include when compiling a file using this compiler (default: true)
pub fn set_implicit_prelude(&mut self, implicit_prelude: bool)
[src]
pub fn emit_debug_info(self, emit_debug_info: bool) -> Self
[src]
Sets whether the compiler should emit debug information such as source maps and variable names. (default: true)
pub fn set_emit_debug_info(&mut self, emit_debug_info: bool)
[src]
pub fn run_io(self, run_io: bool) -> Self
[src]
Sets whether IO
expressions are evaluated.
(default: false)
pub fn set_run_io(&mut self, run_io: bool)
[src]
pub fn full_metadata(self, full_metadata: bool) -> Self
[src]
Sets whether full metadata is required (default: false)
pub fn set_full_metadata(&mut self, full_metadata: bool)
[src]
pub fn code_map(&self) -> CodeMap
[src]
pub fn update_filemap<S>(
&mut self,
file: &str,
source: S
) -> Option<Arc<FileMap>> where
S: Into<String>,
[src]
&mut self,
file: &str,
source: S
) -> Option<Arc<FileMap>> where
S: Into<String>,
pub fn get_filemap(&self, file: &str) -> Option<Arc<FileMap>>
[src]
pub fn mut_symbols(&mut self) -> &mut Symbols
[src]
pub fn split(&self) -> Self
[src]
pub fn parse_expr(
&mut self,
type_cache: &TypeCache<Symbol, ArcType>,
file: &str,
expr_str: &str
) -> StdResult<SpannedExpr<Symbol>, InFile<Error>>
[src]
&mut self,
type_cache: &TypeCache<Symbol, ArcType>,
file: &str,
expr_str: &str
) -> StdResult<SpannedExpr<Symbol>, InFile<Error>>
Parse expr_str
, returning an expression if successful
pub fn parse_partial_expr(
&mut self,
type_cache: &TypeCache<Symbol, ArcType>,
file: &str,
expr_str: &str
) -> StdResult<SpannedExpr<Symbol>, (Option<SpannedExpr<Symbol>>, InFile<Error>)>
[src]
&mut self,
type_cache: &TypeCache<Symbol, ArcType>,
file: &str,
expr_str: &str
) -> StdResult<SpannedExpr<Symbol>, (Option<SpannedExpr<Symbol>>, InFile<Error>)>
Parse input
, returning an expression if successful
pub fn typecheck_expr(
&mut self,
vm: &Thread,
file: &str,
expr_str: &str,
expr: &mut SpannedExpr<Symbol>
) -> Result<ArcType>
[src]
&mut self,
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
pub fn typecheck_str(
&mut self,
vm: &Thread,
file: &str,
expr_str: &str,
expected_type: Option<&ArcType>
) -> Result<(SpannedExpr<Symbol>, ArcType)>
[src]
&mut self,
vm: &Thread,
file: &str,
expr_str: &str,
expected_type: Option<&ArcType>
) -> Result<(SpannedExpr<Symbol>, ArcType)>
pub fn compile_script(
&mut self,
vm: &Thread,
filename: &str,
expr_str: &str,
expr: &SpannedExpr<Symbol>
) -> Result<CompiledModule>
[src]
&mut self,
vm: &Thread,
filename: &str,
expr_str: &str,
expr: &SpannedExpr<Symbol>
) -> Result<CompiledModule>
Compiles expr
into a function which can be added and run by the vm
pub fn compile_to_bytecode<S>(
&mut self,
thread: &Thread,
name: &str,
expr_str: &str,
serializer: S
) -> StdResult<S::Ok, Either<Error, S::Error>> where
S: Serializer,
S::Error: 'static,
[src]
&mut self,
thread: &Thread,
name: &str,
expr_str: &str,
serializer: S
) -> StdResult<S::Ok, Either<Error, S::Error>> where
S: Serializer,
S::Error: 'static,
Compiles the source code expr_str
into bytecode serialized using serializer
pub fn load_bytecode<'vm, D>(
&mut self,
thread: &'vm Thread,
name: &str,
deserializer: D
) -> impl Future<Item = (), Error = Error> + 'vm where
D: Deserializer<'vm> + 'vm,
D::Error: Send + Sync,
[src]
&mut self,
thread: &'vm Thread,
name: &str,
deserializer: D
) -> impl Future<Item = (), Error = Error> + 'vm where
D: Deserializer<'vm> + 'vm,
D::Error: Send + Sync,
Loads bytecode from a Deserializer
and stores it into the module name
.
load_script
is equivalent to compile_to_bytecode
followed by load_bytecode
pub fn extract_metadata(
&mut self,
vm: &Thread,
file: &str,
expr_str: &str
) -> Result<(SpannedExpr<Symbol>, ArcType, Arc<Metadata>)>
[src]
&mut self,
vm: &Thread,
file: &str,
expr_str: &str
) -> Result<(SpannedExpr<Symbol>, ArcType, Arc<Metadata>)>
Parses and typechecks expr_str
followed by extracting metadata from the created
expression
pub fn load_script(
&mut self,
vm: &Thread,
filename: &str,
input: &str
) -> Result<()>
[src]
&mut self,
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.
pub fn load_script_async<'vm>(
&mut self,
vm: &'vm Thread,
filename: &str,
input: &str
) -> impl Future<Item = (), Error = Error> + 'vm
[src]
&mut self,
vm: &'vm Thread,
filename: &str,
input: &str
) -> impl Future<Item = (), Error = Error> + 'vm
pub fn load_file<'vm>(&mut self, vm: &'vm Thread, filename: &str) -> Result<()>
[src]
Loads filename
and compiles and runs its input by calling load_script
pub fn load_file_async<'vm>(
&mut self,
vm: &'vm Thread,
filename: &str
) -> impl Future<Item = (), Error = Error>
[src]
&mut self,
vm: &'vm Thread,
filename: &str
) -> impl Future<Item = (), Error = Error>
pub fn run_expr<'vm, T>(
&mut self,
vm: &'vm Thread,
name: &str,
expr_str: &str
) -> Result<(T, ArcType)> where
T: for<'value> Getable<'vm, 'value> + VmType + Send + 'vm,
[src]
&mut self,
vm: &'vm Thread,
name: &str,
expr_str: &str
) -> Result<(T, ArcType)> where
T: for<'value> Getable<'vm, 'value> + VmType + Send + 'vm,
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");
pub fn run_expr_async<T>(
&mut self,
vm: &Thread,
name: &str,
expr_str: &str
) -> impl Future<Item = (T, ArcType), Error = Error> where
T: for<'vm, 'value> Getable<'vm, 'value> + VmType + Send + 'static,
[src]
&mut self,
vm: &Thread,
name: &str,
expr_str: &str
) -> impl Future<Item = (T, ArcType), Error = Error> where
T: for<'vm, 'value> Getable<'vm, 'value> + VmType + Send + 'static,
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); }
pub fn format_expr(
&mut self,
formatter: &mut Formatter,
thread: &Thread,
file: &str,
input: &str
) -> Result<String>
[src]
&mut self,
formatter: &mut Formatter,
thread: &Thread,
file: &str,
input: &str
) -> Result<String>
Trait Implementations
Auto Trait Implementations
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: Any,
T: Any,
impl<D, T> FromPtr for T
[src]
impl<T> Any for T where
T: Any,
T: Any,
fn get_type_id(&self) -> TypeId
impl<Choices> CoproductSubsetter for Choices
type Remainder = Choices
fn subset(
self
) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>
self
) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>
impl<Source> Sculptor for Source
impl<T, U, I> LiftInto for T where
U: LiftFrom<T, I>,
U: LiftFrom<T, I>,