Class TypedSymbolAccess
java.lang.Object
org.ek9lang.compiler.common.RuleSupport
org.ek9lang.compiler.common.TypedSymbolAccess
- Direct Known Subclasses:
AbstractOperatorOverFieldsOrError, AbstractSafeSymbolMarker, AccessLeftAndRightOrError, AccessTernaryExpressionsOrError, AccessToSymbolOrError, AllTextBodiesPresentOrError, AssertDoesNotThrowExpressionOrError, AssertPanicExpressionOrError, AssertStatementOrError, AssertThrowsExpressionOrError, AssignIfUnsetDecidedOrError, AssignmentExpressionOrError, AssignmentOrError, AssignmentStatementOrError, AssignmentStatementOrError, AugmentAggregateWithTraitMethods, AutoMatchSuperFunctionSignature, CallableReturnsInitialisedOrError, CallOrError, CannotAssignFromSanitizedOrError, CapabilityTypeReferenceOrError, CheckConflictingMethods, CloseableHolderDeclaresCloseOrError, CoalescingComparisonTypeOrError, CompoundConditionOrError, ConcurrentEntryPointMarker, ConstantArithmeticOrError, ConstantCoalescingOrError, ConstantComparisonOrError, ConstrainedConstructionOrError, ConstructorCallOrError, ConstructorThisEscapeOrError, ControlIsBooleanOrError, DefaultOperatorsOrError, DictUseOrError, DispatcherHandlerInTraitOrError, DynamicCaptureOrError, DynamicFunctionBodyPresentOrError, DynamicFunctionOrError, EnumeratedTypeOrError, ExceptionNotCloseableOrError, ExceptionTypeOrError, ExcessiveTypeTraversalOrError, ExpressionIsBooleanResultOrError, ExpressionOrError, FlowConditionOrError, ForLoopOrError, ForRangeOrError, ForStatementExpressionOrError, FunctionDelegateOrError, FunctionOverridesOrError, GetGuardVariable, GetIteratorType, HeadTailSkipOrError, IdentifierAsPropertyOrError, IdentifierAssignmentOrError, IdentifierOrError, IdentifierReadOrError, IdentifierReferenceOrError, IfStatementOrError, IfStatementOrError, IncompleteConstructorCallOrError, InfiniteStreamSourceOrError, InheritedOperatorOverFieldsOrError, InstructionBlockVariablesOrError, IsSetOperatorRequiredOrError, LhsAndRhsAssignmentOrError, LhsFromPreFlowOrError, ListUseOrError, LockedItemExposureOrError, LogicalTautologyOrError, MethodOverridesOrError, MethodSymbolSearchForExpression, MutexLockArgumentFreshnessOrError, MutexLockConstructionPositionOrError, NoDelegateMethodClashesOrError, NoDuplicatedPropertyNamesOrError, NotAbstractOrError, NoTraitByVariablesOrError, ObjectAccessExpressionOrError, ObjectAccessStartOrError, ObjectUsedBeforeConstructedOrError, OperationCallOrError, OperatorTest, ParameterTypesExactMatchOrError, PipelinePartOrError, PossibleExpressionConstruct, PreFlowStatementOrError, PrimaryOrError, PrivilegedRevealOrError, ProcessDynamicFunctionEntry, ProcessWhileControlVariable, ProgramOrError, PropertyFieldOrError, PureModifierOrError, PureProcessingInPureContextOrError, RangeNeverProgressesOrError, RangeOrError, RecordCarriesDataOrError, RedundantBooleanComparisonOrError, RedundantEmptyCheckOrError, RedundantIsSetCheckOrError, RegisteredConstructionOrError, RegistrationDataOrError, RequiredOperatorPresentOrError, RequireStatementOrError, ResolveByTraitVariables, ResolveFunctionOrDelegateByNameOrError, ResolveFunctionOrError, ResolveIdentifierReferenceCallOrError, ResolveMethodOnAggregateOrError, ResolveMethodOrError, ReturningVariableOrError, ReturnInitialisedBeforeRequireOrError, SafeSymbolAccess, SamenessOrError, SanitizedModifierOrError, SelfComparisonOrError, ServiceApplicationMarker, ServiceSecurityConstraintOrError, SetTypeFromReturningParam, SharedStateMutationOutsideLockOrError, StatementOrError, StreamAppendsToItsSourceOrError, StreamAssemblyOrError, StreamCatOrError, StreamExpressionOrError, StreamExpressionTerminationOrError, StreamForOrError, StreamFunctionArgumentsOrError, StreamFunctionOrError, StreamReplaceNeedsFreshValueOrError, StreamStatementOrError, StreamStatementTerminationOrError, SuitablePropertyInitialisationOrError, SuperConstructorAccessOrError, SwitchStatementExpressionOrError, SymbolFromContextOrError, SymbolHasTypeOrError, SymbolReferencedOrError, ThisOrSuperCallOrError, ThisOrSuperOrError, ThrowStatementOrError, TraitAccessibleOrError, TryStatementExpressionOrError, TypeConstraintOrError, TypeCovarianceOrError, TypesCompatibleOrError, ValidDispatcherMethodsOrError, ValidFunctionAbstractnessOrError, VariableAssignmentOrError, VariableOnlyOrError, VariableOnlyOrError, WhileStatementExpressionOrError
Designed to be used in phase3 or after - FULL_RESOLUTION.
Because at this stage whenever a symbol is accessed via 'getRecordedSymbol'
in @link org.ek9lang.compiler.common.SymbolsAndScopes' it must be typed
or an error issued. Clearly the symbol could still be null at this stage (if there were
errors in expressions).
But if the symbol provided is not null then it must by now have a type.
So if not typed, then we need to emit an error. This means other code can just focus on
symbol != null && symbol.getType.isPresent() then it can continue with its processing.
-
Field Summary
Fields inherited from class RuleSupport
errorListener, symbolsAndScopes -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedTypedSymbolAccess(SymbolsAndScopes symbolsAndScopes, SemanticErrorReporter errorListener) Constructor to provided typed access. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidemitTypeNotResolvedError(ISymbol symbol) getRecordedAndTypedSymbol(org.antlr.v4.runtime.tree.ParseTree node) Gets any symbol associated with this node.static booleanisAlreadyInError(ISymbol symbol) THE test that a symbol has no type because the expression it was declared from is already reported (E-7): its readers stay silent rather than adding a 'type not resolved' for every later use.protected booleanUses the SymbolsAndScopes to get the main processing scope a method or a function.protected booleanisPureReassignmentDisallowed(ISymbol leftHandSideSymbol) THE purity half of E08100 (NO_PURE_REASSIGNMENT): true when a plain reassignment (:=) ofleftHandSideSymbolwould be refused here because the processing scope ispure.voidrecordATypedSymbol(ISymbol symbol, org.antlr.v4.runtime.tree.ParseTree node) Records a symbol against a node and also emits an error if its type has not been set.
-
Constructor Details
-
TypedSymbolAccess
Constructor to provided typed access.
-
-
Method Details
-
isProcessingScopePure
protected boolean isProcessingScopePure()Uses the SymbolsAndScopes to get the main processing scope a method or a function. Then checks it that is marked as pure or not.- Returns:
- true if pure, false if mutable.
-
isPureReassignmentDisallowed
THE purity half of E08100 (NO_PURE_REASSIGNMENT): true when a plain reassignment (:=) ofleftHandSideSymbolwould be refused here because the processing scope ispure. A returning variable may always be (re)assigned, so it is never refused. Phase 3 reports E08100 with it; phase 5 asks it so that:=?- the ONLY reassignment a pure scope permits - is never reported as "use ':=' instead" (E08097). Do not derive a second purity test for assignments - call this. -
recordATypedSymbol
Records a symbol against a node and also emits an error if its type has not been set. -
getRecordedAndTypedSymbol
Gets any symbol associated with this node. If the symbol is not null then its type is checked. If there is no type then an error is emitted. -
isAlreadyInError
THE test that a symbol has no type because the expression it was declared from is already reported (E-7): its readers stay silent rather than adding a 'type not resolved' for every later use. -
emitTypeNotResolvedError
-