Class SemanticContextFlagsBuilder<TContext, TFlags>
Builds the semantic flags of a specific semantic operation.
public record SemanticContextFlagsBuilder<TContext, TFlags> : ISemanticContextFlagsBuilder<TContext, TFlags>, ISemanticContextContributor<TContext, TFlags>, ISemanticFlagsAccumulator<TFlags>, IEquatable<SemanticContextFlagsBuilder<TContext, TFlags>> where TContext : SemanticContext<TFlags>, new() where TFlags : struct, Enum
Type Parameters
TContextThe type of
SemanticContextto build.TFlagsA
[Flags]enumtype with bit-shifted members that can be composed to encode the semantic flags of the context.
- Inheritance
-
SemanticContextFlagsBuilder<TContext, TFlags>
- Implements
-
ISemanticContextFlagsBuilder<TContext, TFlags>ISemanticContextContributor<TContext, TFlags>ISemanticFlagsAccumulator<TFlags>IEquatable<SemanticContextFlagsBuilder<TContext, TFlags>>
- Derived
- Inherited Members
Properties
Flags
Builds the current aggregate flags and returns the result.
public TFlags Flags { get; }
Property Value
- TFlags
Remarks
🧩 This property enumerates and casts all flags to compute the current aggregate flags value every time it is invoked. Avoid calling it repeatedly.
Methods
AddFlags(TFlags)
Adds the specified semantic flag(s) to the context.
public ISemanticFlagsAccumulator<TFlags> AddFlags(TFlags flags)
Parameters
flagsTFlagsThe semantic flag values.
Returns
- ISemanticFlagsAccumulator<TFlags>
AddLetCoercionFlags(ConversionSemanticFlags, InputIndex)
Adds the specified conversion semantic flag(s) to the let-coercion of the specified operand; the flags of one operand accumulate across calls, and are kept apart from the other operands'.
public virtual ISemanticFlagsAccumulator<TFlags> AddLetCoercionFlags(ConversionSemanticFlags flags, InputIndex operand)
Parameters
flagsConversionSemanticFlagsThe conversion flag(s) to add.
operandInputIndexThe operand whose let-coercion the flags describe.
Returns
- ISemanticFlagsAccumulator<TFlags>
Remarks
The flags are read back per operand with LetCoercionFlagsOf(InputIndex). A builder whose own flags are conversion flags (LetCoercionSemanticContextFlagsBuilder) also contributes them to its Flags: they describe the operation's conversion just as much as they describe the operand's.
AddOnError<TError>(TError?)
Adds the specified error to the semantic context if it isn't null.
public ISemanticContextFlagsBuilder<TContext, TFlags> AddOnError<TError>(TError? error) where TError : VBErrorInfo
Parameters
errorTErrorHolds information about an error.
Returns
- ISemanticContextFlagsBuilder<TContext, TFlags>
Type Parameters
TErrorThe specific type of VBErrorInfo encapsulating the error metadata.
Build()
Builds and returns an immutable SemanticContext instance from the current builder state.
public virtual TContext Build()
Returns
- TContext
Remarks
👉 The context of an operator expression also holds the conversion semantic context of each operand (OperandConversionContexts), built from the flags added with AddLetCoercionFlags(ConversionSemanticFlags, InputIndex).
LetCoercionFlagsOf(InputIndex)
Gets the conversion semantic flags added so far to the let-coercion of the specified operand.
public ConversionSemanticFlags LetCoercionFlagsOf(InputIndex operand)
Parameters
operandInputIndexThe operand to read the flags of.
Returns
- ConversionSemanticFlags
The accumulated flags, or none if nothing was added for that operand.
WithFlags(TFlags)
Adds the specified semantic flag(s) to the context and returns the builder instance.
protected ISemanticFlagsAccumulator<TFlags> WithFlags(TFlags flags)
Parameters
flagsTFlagsThe semantic flag value(s) to compose into the semantic context.
Returns
- ISemanticFlagsAccumulator<TFlags>