Struct ezno_checker::context::Context
source · pub struct Context<T: ContextType> {
pub context_id: ContextId,
pub possibly_mutated_objects: HashSet<TypeId>,
pub info: LocalInformation,
/* 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
info: LocalInformation
Implementations§
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<A>,
operator: AssignmentKind,
expression: Option<&'b A::Expression<'b>>,
assignment_span: Span,
checking_data: &mut CheckingData<'_, T, A>
) -> TypeId
pub fn assign_to_assignable_handle_errors<'b, T: ReadFromFS, A: ASTImplementation>( &mut self, lhs: Assignable<A>, operator: AssignmentKind, expression: Option<&'b A::Expression<'b>>, assignment_span: Span, 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 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,
types: &mut TypeStore
) -> Result<TypeId, AssignmentError>
pub fn assign_to_variable( &mut self, variable_name: &str, assignment_position: SpanWithSource, new_type: TypeId, types: &mut 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?
pub fn get_property( &mut self, on: TypeId, publicity: Publicity, property: &PropertyKey<'_>, types: &mut TypeStore, with: Option<TypeId>, position: SpanWithSource, options: &TypeCheckOptions, bind_this: bool ) -> Option<(PropertyKind, TypeId)>
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, bind_this: bool ) -> 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 new_conditional_context<T, A, R>( &mut self, (condition, pos): (TypeId, Span), then_evaluate: impl FnOnce(&mut Environment<'_>, &mut CheckingData<'_, T, A>) -> R, else_evaluate: Option<impl FnOnce(&mut Environment<'_>, &mut CheckingData<'_, T, A>) -> R>, checking_data: &mut CheckingData<'_, T, A> ) -> R
pub fn throw_value(&mut self, thrown: TypeId, position: SpanWithSource)
sourcepub fn return_value<T: ReadFromFS, A: ASTImplementation>(
&mut self,
expression: &Returnable<'_, A>,
checking_data: &mut CheckingData<'_, T, A>
)
pub fn return_value<T: ReadFromFS, A: ASTImplementation>( &mut self, expression: &Returnable<'_, A>, checking_data: &mut CheckingData<'_, T, A> )
Also appends invalid return type checks
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: &mut TypeStore,
setter_position: Option<SpanWithSource>,
options: &TypeCheckOptions
) -> Result<Option<TypeId>, SetPropertyError>
pub fn set_property( &mut self, on: TypeId, publicity: Publicity, under: &PropertyKey<'_>, new: TypeId, types: &mut TypeStore, setter_position: Option<SpanWithSource>, options: &TypeCheckOptions ) -> 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,
_: VariableRegisterArguments
) -> Result<(), CannotRedeclareVariable<'b>>
pub fn register_variable<'b>( &mut self, name: &'b str, declared_at: SpanWithSource, _: VariableRegisterArguments ) -> Result<(), CannotRedeclareVariable<'b>>
Declares a new variable in the environment and returns the new variable
TODO maybe name: VariableDeclarator
to include destructuring …?
TODO hoisted vs declared
pub fn register_variable_handle_error( &mut self, name: &str, argument: VariableRegisterArguments, declared_at: SpanWithSource, diagnostics_container: &mut DiagnosticsContainer )
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<(LocalInformation, 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<(LocalInformation, 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 register_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 register_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
sourcepub fn register_class<'a, A: ASTImplementation>(
&mut self,
name: &str,
parameters: Option<&'a [A::TypeParameter<'a>]>,
_extends: Option<&'a A::Expression<'a>>,
types: &mut TypeStore
) -> TypeId
pub fn register_class<'a, A: ASTImplementation>( &mut self, name: &str, parameters: Option<&'a [A::TypeParameter<'a>]>, _extends: Option<&'a A::Expression<'a>>, types: &mut TypeStore ) -> TypeId
Registers the class type
pub fn new_alias<'a, U: ReadFromFS, A: ASTImplementation>( &mut self, name: &str, parameters: Option<&'a [A::TypeParameter<'a>]>, to: &'a A::TypeAnnotation<'a>, position: Span, checking_data: &mut CheckingData<'_, U, A> ) -> TypeId
pub fn register_initial_variable_declaration_value( &mut self, id: VariableId, value_ty: TypeId )
sourcepub fn declare_variable<'a>(
&mut self,
name: &'a str,
declared_at: SpanWithSource,
variable_ty: TypeId,
types: &mut TypeStore,
context: Option<String>
) -> Result<TypeId, CannotRedeclareVariable<'a>>
pub fn declare_variable<'a>( &mut self, name: &'a str, declared_at: SpanWithSource, variable_ty: TypeId, types: &mut TypeStore, context: Option<String> ) -> Result<TypeId, CannotRedeclareVariable<'a>>
TODO remove types
sourcepub fn get_value_of_this(
&mut self,
_types: &TypeStore,
_position: SpanWithSource
) -> TypeId
pub fn get_value_of_this( &mut self, _types: &TypeStore, _position: SpanWithSource ) -> TypeId
TODO is this the generic?