Struct ezno_checker::context::Context
source · pub struct Context<T: ContextType> {
pub context_id: ContextId,
pub possibly_mutated_objects: HashSet<TypeId>,
pub facts: Facts,
/* private fields */
}Fields§
§context_id: ContextId§possibly_mutated_objects: HashSet<TypeId>When a objects TypeId is in here getting a property returns a constructor rather than
facts: FactsImplementations§
source§impl<'a> Context<Syntax<'a>>
impl<'a> Context<Syntax<'a>>
sourcepub fn assign_to_assignable_handle_errors<'b, T: ReadFromFS, A: ASTImplementation>(
&mut self,
lhs: Assignable,
operator: AssignmentKind,
expression: Option<&'b A::Expression<'b>>,
assignment_span: SpanWithSource,
checking_data: &mut CheckingData<'_, T, A>
) -> TypeId
pub fn assign_to_assignable_handle_errors<'b, T: ReadFromFS, A: ASTImplementation>( &mut self, lhs: Assignable, operator: AssignmentKind, expression: Option<&'b A::Expression<'b>>, assignment_span: SpanWithSource, checking_data: &mut CheckingData<'_, T, A> ) -> TypeId
Handles all assignments, including updates and destructuring
Will evaluate the expression with the right timing and conditions, including never if short circuit
TODO finish operator. Unify increment and decrement. The RHS span should be fine with [Span::NULL ...?] Maybe RHS type could be None to accommodate
pub fn new_function<U, F, A>( &mut self, checking_data: &mut CheckingData<'_, U, A>, function: &F, behavior: FunctionRegisterBehavior<'_, A> ) -> FunctionType
pub fn assign_to_variable_handle_errors<T: ReadFromFS, A: ASTImplementation>( &mut self, variable_name: &str, assignment_position: SpanWithSource, new_type: TypeId, checking_data: &mut CheckingData<'_, T, A> ) -> TypeId
sourcepub fn assign_to_variable(
&mut self,
variable_name: &str,
assignment_position: SpanWithSource,
new_type: TypeId,
store: &TypeStore
) -> Result<TypeId, AssignmentError>
pub fn assign_to_variable( &mut self, variable_name: &str, assignment_position: SpanWithSource, new_type: TypeId, store: &TypeStore ) -> Result<TypeId, AssignmentError>
This is top level variables, not properties.
pub fn get_environment_type(&self) -> &Scope
pub fn get_environment_type_mut(&mut self) -> &mut Scope
sourcepub fn property_in(&self, on: TypeId, property: &PropertyKey<'_>) -> bool
pub fn property_in(&self, on: TypeId, property: &PropertyKey<'_>) -> bool
TODO decidable & private?
sourcepub fn delete_property(
&mut self,
on: TypeId,
property: &PropertyKey<'_>
) -> bool
pub fn delete_property( &mut self, on: TypeId, property: &PropertyKey<'_> ) -> bool
TODO decidable & private?
sourcepub fn get_property(
&mut self,
on: TypeId,
publicity: Publicity,
property: PropertyKey<'_>,
types: &mut TypeStore,
with: Option<TypeId>,
position: SpanWithSource
) -> Option<(PropertyKind, TypeId)>
pub fn get_property( &mut self, on: TypeId, publicity: Publicity, property: PropertyKey<'_>, types: &mut TypeStore, with: Option<TypeId>, position: SpanWithSource ) -> Option<(PropertyKind, TypeId)>
Also evaluates getter and binds this
pub fn get_property_handle_errors<U: ReadFromFS, A: ASTImplementation>( &mut self, on: TypeId, publicity: Publicity, key: PropertyKey<'_>, checking_data: &mut CheckingData<'_, U, A>, site: SpanWithSource ) -> Result<Instance, ()>
pub fn get_variable_handle_error<U: ReadFromFS, A: ASTImplementation>( &mut self, name: &str, position: SpanWithSource, checking_data: &mut CheckingData<'_, U, A> ) -> Result<VariableWithValue, TypeId>
pub fn throw_value(&mut self, value: TypeId, position: SpanWithSource)
pub fn return_value( &mut self, returned: TypeId, returned_position: SpanWithSource )
pub fn add_continue( &mut self, label: Option<&str>, position: Span ) -> Result<(), NotInLoopOrCouldNotFindLabel>
pub fn add_break( &mut self, label: Option<&str>, position: Span ) -> Result<(), NotInLoopOrCouldNotFindLabel>
sourcepub fn set_property(
&mut self,
on: TypeId,
publicity: Publicity,
under: &PropertyKey<'_>,
new: TypeId,
types: &TypeStore,
setter_position: Option<SpanWithSource>
) -> Result<Option<TypeId>, SetPropertyError>
pub fn set_property( &mut self, on: TypeId, publicity: Publicity, under: &PropertyKey<'_>, new: TypeId, types: &TypeStore, setter_position: Option<SpanWithSource> ) -> Result<Option<TypeId>, SetPropertyError>
Updates a existing property
Returns the result of the setter… TODO could return new else
source§impl Context<Root>
impl Context<Root>
pub fn new_with_primitive_references() -> Self
pub fn new_module_context<'a, T: ReadFromFS, A: ASTImplementation>( &self, source: SourceId, module: A::Module<'static>, checking_data: &'a mut CheckingData<'_, T, A> ) -> &'a SynthesisedModule<A::OwnedModule>
sourcepub fn serialize(self) -> Vec<u8> ⓘ
pub fn serialize(self) -> Vec<u8> ⓘ
TODO working things out:
- strings could reference a big string
pub fn deserialize( _source: &[u8], _backing_source: SourceId ) -> Result<Self, String>
source§impl<T: ContextType> Context<T>
impl<T: ContextType> Context<T>
sourcepub fn attempt_to_modify_base(
&mut self,
on: TypeId,
boundary: Boundary,
new_constraint: TypeId
)
pub fn attempt_to_modify_base( &mut self, on: TypeId, boundary: Boundary, new_constraint: TypeId )
This exists on context because bases are localised
sourcepub fn register_variable<'b>(
&mut self,
name: &'b str,
declared_at: SpanWithSource,
behavior: VariableRegisterBehavior,
types: &mut TypeStore
) -> Result<TypeId, CannotRedeclareVariable<'b>>
pub fn register_variable<'b>( &mut self, name: &'b str, declared_at: SpanWithSource, behavior: VariableRegisterBehavior, types: &mut TypeStore ) -> Result<TypeId, CannotRedeclareVariable<'b>>
Declares a new variable in the environment and returns the new variable
THIS IS USED FOR HOISTING, DOES NOT SET THE VALUE
TODO maybe name: VariableDeclarator to include destructuring …?
TODO hoisted vs declared
pub fn register_variable_handle_error<U: ReadFromFS, A: ASTImplementation>( &mut self, name: &str, declared_at: SpanWithSource, behavior: VariableRegisterBehavior, checking_data: &mut CheckingData<'_, U, A> ) -> TypeId
sourcepub fn get_properties_on_type(
&self,
base: TypeId
) -> Vec<(Publicity, PropertyKey<'static>, TypeId)>
pub fn get_properties_on_type( &self, base: TypeId ) -> Vec<(Publicity, PropertyKey<'static>, TypeId)>
Get all properties on a type (for printing and other non one property uses)
- TODO make aware of ands and aliases
- TODO prototypes
- TODO could this be an iterator
- TODO return whether it is fixed
sourcepub fn get_type_from_name(&self, name: &str) -> Option<TypeId>
pub fn get_type_from_name(&self, name: &str) -> Option<TypeId>
Note: this also returns base generic types like Array
pub fn as_general_context(&self) -> GeneralContext<'_>
sourcepub fn is_frozen(&self, value: TypeId) -> Option<TypeId>
pub fn is_frozen(&self, value: TypeId) -> Option<TypeId>
TODO doesn’t look at aliases using get_type_fact!
pub fn new_try_context<U: ReadFromFS, A: ASTImplementation>( &mut self, checking_data: &mut CheckingData<'_, U, A>, func: impl for<'a> FnOnce(&'a mut Environment<'_>, &'a mut CheckingData<'_, U, A>) ) -> TypeId
sourcepub fn new_lexical_environment_fold_into_parent<U: ReadFromFS, Res, A: ASTImplementation>(
&mut self,
scope: Scope,
checking_data: &mut CheckingData<'_, U, A>,
cb: impl for<'a> FnOnce(&'a mut Environment<'_>, &'a mut CheckingData<'_, U, A>) -> Res
) -> (Res, Option<(Facts, ClosedOverReferencesInScope)>, ContextId)
pub fn new_lexical_environment_fold_into_parent<U: ReadFromFS, Res, A: ASTImplementation>( &mut self, scope: Scope, checking_data: &mut CheckingData<'_, U, A>, cb: impl for<'a> FnOnce(&'a mut Environment<'_>, &'a mut CheckingData<'_, U, A>) -> Res ) -> (Res, Option<(Facts, ClosedOverReferencesInScope)>, ContextId)
TODO
- Make internal (public methods should substitute for different scopes)
- Make less complex
pub fn new_explicit_type_parameter( &mut self, name: &str, constraint_type: Option<TypeId>, default_type: Option<TypeId>, types: &mut TypeStore ) -> GenericTypeParameter
pub fn get_type_by_name_handle_errors<U, A: ASTImplementation>( &self, name: &str, pos: SpanWithSource, checking_data: &mut CheckingData<'_, U, A> ) -> TypeId
sourcepub fn new_interface<'a, U: ReadFromFS, A: ASTImplementation>(
&mut self,
name: &str,
nominal: bool,
parameters: Option<&'a [A::TypeParameter<'a>]>,
extends: Option<&'a [A::TypeAnnotation<'a>]>,
position: SpanWithSource,
checking_data: &mut CheckingData<'_, U, A>
) -> TypeId
pub fn new_interface<'a, U: ReadFromFS, A: ASTImplementation>( &mut self, name: &str, nominal: bool, parameters: Option<&'a [A::TypeParameter<'a>]>, extends: Option<&'a [A::TypeAnnotation<'a>]>, position: SpanWithSource, checking_data: &mut CheckingData<'_, U, A> ) -> TypeId
TODO extends