Struct kailua_check::env::Env
[−]
[src]
pub struct Env<'ctx, R: 'ctx> { /* fields omitted */ }
A per-file environment which depends to Context
.
Methods
impl<'ctx, R: Report> Env<'ctx, R>
[src]
fn new(
context: &'ctx mut Context<R>,
opts: Rc<RefCell<Options>>,
map: ScopeMap<Name>
) -> Env<'ctx, R>
context: &'ctx mut Context<R>,
opts: Rc<RefCell<Options>>,
map: ScopeMap<Name>
) -> Env<'ctx, R>
fn types(&mut self) -> &mut Types
fn context(&mut self) -> &mut Context<R>
fn opts(&self) -> &Rc<RefCell<Options>>
fn scope_map(&self) -> &ScopeMap<Name>
fn display<'a, 'c, T: Display>(
&'c self,
x: &'a T
) -> Displayed<'a, T, &'c TypeContext>
&'c self,
x: &'a T
) -> Displayed<'a, T, &'c TypeContext>
fn id_from_nameref(&self, nameref: &Spanned<NameRef>) -> Spanned<Id>
fn enter(&mut self, scope: Scope)
fn leave(&mut self)
fn get_type_bounds(&self, ty: &Ty) -> (Flags, Flags)
Returns a pair of type flags that is an exact lower and upper bound for that type.
Used as an approximate type bound testing like arithmetics. If possible, however, better be replaced with a non-instantiating assertion though.
fn resolve_exact_type<'a>(&self, ty: &Ty) -> Option<Ty>
Exactly resolves the type variable inside ty
if possible.
This is a requirement for table indexing and function calls.
fn return_from_module(
self,
modname: &[u8],
diverging: bool,
span: Span
) -> Result<Option<Module>>
self,
modname: &[u8],
diverging: bool,
span: Span
) -> Result<Option<Module>>
fn global_scope(&self) -> &Scope
fn global_scope_mut(&mut self) -> &mut Scope
fn current_scope(&self) -> &Scope
fn current_scope_mut(&mut self) -> &mut Scope
fn get_name<'a>(&'a self, nameref: &'a NameRef) -> &'a Name
fn get_var<'a>(&'a self, nameref: &NameRef) -> Option<&'a NameDef>
fn get_var_mut<'a>(&'a mut self, nameref: &NameRef) -> Option<&'a mut NameDef>
fn get_frame<'a>(&'a self) -> &'a Frame
fn get_frame_mut<'a>(&'a mut self) -> &'a mut Frame
fn get_vararg<'a>(&'a self) -> Option<&'a TySeq>
fn get_string_meta(&self) -> Option<Spanned<Slot>>
fn assign(&mut self, lhs: &Spanned<Slot>, rhs: &Spanned<Slot>) -> Result<()>
Same to Slot::accept
but also able to handle the built-in semantics;
should be used for any kind of non-internal assignments.
fn assign_new(
&mut self,
lhs: &Spanned<Slot>,
initrhs: &Spanned<Slot>,
specrhs: Option<&SlotSpec>
) -> Result<Slot>
&mut self,
lhs: &Spanned<Slot>,
initrhs: &Spanned<Slot>,
specrhs: Option<&SlotSpec>
) -> Result<Slot>
Same to Env::assign
but the slot is assumed to be newly created (out of field)
and the strict equality instead of subtyping is applied.
This is required because the slot itself is generated before doing any assignment; the usual notion of accepting by subtyping does not work well here. This is technically two assignments, of which the latter is done via the strict equality.
Returns a resulting slot. (This is important for some features relying on the strict referential slot identity, e.g. delayed type checking.)
fn ensure_var(&mut self, nameref: &Spanned<NameRef>) -> Result<Slot>
Ensures that the variable has been initialized (possibly implicitly to nil
).
Raises an appropriate error when the implicit initialization was impossible.
fn name_class_and_type(&mut self, cid: ClassId, id: &Spanned<Id>) -> Result<()>
fn add_var(
&mut self,
nameref: &Spanned<NameRef>,
specinfo: Option<SlotSpec>,
initinfo: Option<Spanned<Slot>>
) -> Result<Option<Slot>>
&mut self,
nameref: &Spanned<NameRef>,
specinfo: Option<SlotSpec>,
initinfo: Option<Spanned<Slot>>
) -> Result<Option<Slot>>
Adds a local variable with the explicit type specinfo
and the implicit type initinfo
.
Returns the resulting slot of that variable, if the variable has been indeed added. The slot is referentially identical to what one will get from using it as an r-value.
fn add_local_var_already_set(
&mut self,
scoped_id: &Spanned<ScopedId>,
info: Spanned<Slot>
) -> Result<Slot>
&mut self,
scoped_id: &Spanned<ScopedId>,
info: Spanned<Slot>
) -> Result<Slot>
Adds a local variable with that has been already initialized with the type info
.
This is necessary for non-assignment statements that introduce a new variable without assignment semantics. Currently function arguments are the only such case.
Returns the resulting slot of that variable. The slot is referentially identical to what one will get from using it as an r-value.
fn assign_to_var(
&mut self,
nameref: &Spanned<NameRef>,
info: Spanned<Slot>
) -> Result<Slot>
&mut self,
nameref: &Spanned<NameRef>,
info: Spanned<Slot>
) -> Result<Slot>
Assigns to a global or local variable with a right-hand-side type of info
.
This may create a new global variable if there is no variable with that name.
Returns the slot of that variable. The slot is referentially identical to what one will get from using it as an r-value.
fn assume_var(
&mut self,
name: &Spanned<NameRef>,
info: Spanned<Slot>
) -> Result<Slot>
&mut self,
name: &Spanned<NameRef>,
info: Spanned<Slot>
) -> Result<Slot>
Adds a new global or local variable with given type. It entirely skips the assignment phase and forces the variable to be exactly that type.
Returns the resulting slot of that variable. The slot is referentially identical to what one will get from using it as an r-value.
fn get_tvar_bounds(&self, tvar: TVar) -> (Flags, Flags)
fn get_tvar_exact_type(&self, tvar: TVar) -> Option<Ty>
fn get_named_global_type<'a>(&'a self, name: &Name) -> Option<&'a TypeDef>
fn get_named_local_type<'a>(&'a self, name: &Name) -> Option<&'a TypeDef>
fn get_named_type<'a>(&'a self, name: &Name) -> Option<&'a TypeDef>
fn define_local_type(&mut self, name: &Spanned<Name>, ty: Ty) -> Result<()>
fn define_global_type(&mut self, name: &Spanned<Name>, ty: Ty) -> Result<()>
fn define_and_export_type(&mut self, name: &Spanned<Name>, ty: Ty) -> Result<()>
fn redefine_global_type(
&mut self,
name: &Spanned<Name>,
tyspan: Span
) -> Result<()>
&mut self,
name: &Spanned<Name>,
tyspan: Span
) -> Result<()>
fn reexport_local_type(
&mut self,
name: &Spanned<Name>,
tyspan: Span
) -> Result<()>
&mut self,
name: &Spanned<Name>,
tyspan: Span
) -> Result<()>
fn import_types(
&mut self,
typedefs: Spanned<HashMap<Name, TypeDef>>
) -> Result<()>
&mut self,
typedefs: Spanned<HashMap<Name, TypeDef>>
) -> Result<()>
fn define_class_system(
&mut self,
name: &Spanned<Name>,
system: Box<ClassSystem>
) -> Result<Option<ClassSystemId>>
&mut self,
name: &Spanned<Name>,
system: Box<ClassSystem>
) -> Result<Option<ClassSystemId>>
fn dumb_class_system(&self) -> ClassSystemId
Trait Implementations
impl<'ctx, R: Report> Report for Env<'ctx, R>
[src]
impl<'ctx, R: Report> TypeResolver for Env<'ctx, R>
[src]
fn context(&self) -> &TypeContext
Returns an immutable reference to associated type context.
fn context_mut(&mut self) -> &mut TypeContext
Returns a mutable reference to associated type context.
fn ty_from_name(&self, name: &Spanned<Name>) -> Result<Ty>
Resolves a type name to a type if any. The span is used for error reporting.
fn class_system_from_name(
&self,
name: &Spanned<Name>
) -> Result<Option<ClassSystemId>>
&self,
name: &Spanned<Name>
) -> Result<Option<ClassSystemId>>
Resolves a class system name to an identifier if any. The span is used for error reporting.