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>>

source

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

source

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

source

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.

source

pub fn get_environment_type(&self) -> &Scope

source

pub fn get_environment_type_mut(&mut self) -> &mut Scope

source

pub fn property_in(&self, on: TypeId, property: &PropertyKey<'_>) -> bool

TODO decidable & private?

source

pub fn delete_property( &mut self, on: TypeId, property: &PropertyKey<'_> ) -> bool

TODO decidable & private?

source

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)>

source

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, ()>

source

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>

source

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

source

pub fn throw_value(&mut self, thrown: TypeId, position: SpanWithSource)

source

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

source

pub fn add_continue( &mut self, label: Option<&str>, position: Span ) -> Result<(), NotInLoopOrCouldNotFindLabel>

source

pub fn add_break( &mut self, label: Option<&str>, position: Span ) -> Result<(), NotInLoopOrCouldNotFindLabel>

source

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>

source

pub fn new_with_primitive_references() -> Self

source

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>

source

pub fn serialize(self) -> Vec<u8>

TODO working things out:

  • strings could reference a big string
source

pub fn deserialize( _source: &[u8], _backing_source: SourceId ) -> Result<Self, String>

source§

impl<T: ContextType> Context<T>

source

pub fn attempt_to_modify_base( &mut self, on: TypeId, boundary: Boundary, new_constraint: TypeId )

This exists on context because bases are localised

source

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

source

pub fn register_variable_handle_error( &mut self, name: &str, argument: VariableRegisterArguments, declared_at: SpanWithSource, diagnostics_container: &mut DiagnosticsContainer )

source

pub fn get_type_from_name(&self, name: &str) -> Option<TypeId>

Note: this also returns base generic types like Array

source

pub fn as_general_context(&self) -> GeneralContext<'_>

source

pub fn is_frozen(&self, value: TypeId) -> Option<TypeId>

TODO doesn’t look at aliases using get_type_fact!

source

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

source

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
source

pub fn new_explicit_type_parameter( &mut self, name: &str, constraint_type: Option<TypeId>, default_type: Option<TypeId>, types: &mut TypeStore ) -> GenericTypeParameter

source

pub fn get_type_by_name_handle_errors<U, A: ASTImplementation>( &self, name: &str, pos: SpanWithSource, checking_data: &mut CheckingData<'_, U, A> ) -> TypeId

source

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

source

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

source

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

source

pub fn register_initial_variable_declaration_value( &mut self, id: VariableId, value_ty: TypeId )

source

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

source

pub fn get_value_of_this( &mut self, _types: &TypeStore, _position: SpanWithSource ) -> TypeId

TODO is this the generic?

source

pub fn get_source(&self) -> SourceId

source

pub fn get_expected_return_type(&self) -> Option<ExpectedReturnType>

Trait Implementations§

source§

impl<T: Debug + ContextType> Debug for Context<T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'a> From<&'a Context<Root>> for GeneralContext<'a>

source§

fn from(root: &'a RootContext) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a Context<Syntax<'a>>> for GeneralContext<'a>

source§

fn from(env: &'a Environment<'a>) -> Self

Converts to this type from the input type.
source§

impl<T: ContextType> InformationChain for Context<T>

Auto Trait Implementations§

§

impl<T> Freeze for Context<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Context<T>
where T: RefUnwindSafe,

§

impl<T> Send for Context<T>
where T: Send,

§

impl<T> Sync for Context<T>
where T: Sync,

§

impl<T> Unpin for Context<T>
where T: Unpin,

§

impl<T> UnwindSafe for Context<T>
where T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.