Table of Contents

Struct InstructionLoweringOptions

Namespace
RDCore.SDK.Semantics.Instructions
Assembly
RDCore.SDK.dll

What lowering needs to know about the build a procedure is being lowered for.

public readonly record struct InstructionLoweringOptions : IEquatable<InstructionLoweringOptions>
Implements
Inherited Members

Remarks

A growable record rather than a parameter list: lowering already had to be told which conditional-compilation branches are dead, the build now also decides whether Debug statements exist at all, and each later answer of this kind is a property here rather than another parameter on every call site.

Everything here is a property of the build, not of the source — two builds of the same procedure can legitimately lower to different instructions, which is the point.

Constructors

InstructionLoweringOptions(ImmutableArray<SourceRange>, bool, SupportedLanguage?)

What lowering needs to know about the build a procedure is being lowered for.

public InstructionLoweringOptions(ImmutableArray<SourceRange> DeadRanges = default, bool IsReleaseBuild = false, SupportedLanguage? Language = null)

Parameters

DeadRanges ImmutableArray<SourceRange>

The source ranges of every #If/#ElseIf/#Else branch that is not live. Empty when the body has no #If at all. A child lexically inside one is never lowered, at any depth.

IsReleaseBuild bool

Whether this is a release build, in which Debug.Print and Debug.Assert are not lowered at all — they leave no instruction behind, not a no-op one, so a release build pays nothing for a Debug.Print left in the source. Driven by the DEBUG conditional compilation constant, so that #If DEBUG Then and "does this Debug.Print run" are the same fact rather than two settings that can disagree.

Stated negatively on purpose. This is a record struct, so default zeroes every field regardless of the constructor's own defaults — the state a caller gets by saying nothing has to be the safe one, and the safe one is a debug build that keeps the statements.

Language SupportedLanguage

The language the body is written in, which decides which statements exist at all - a bare Print is a statement of a BASIC and of no other language, so lowering one for another is an error. null - the default - states no language, and so applies no language's rules: the body is lowered as written.

Remarks

A growable record rather than a parameter list: lowering already had to be told which conditional-compilation branches are dead, the build now also decides whether Debug statements exist at all, and each later answer of this kind is a property here rather than another parameter on every call site.

Everything here is a property of the build, not of the source — two builds of the same procedure can legitimately lower to different instructions, which is the point.

Fields

Default

A debug build of a body with no conditional compilation in it.

public static readonly InstructionLoweringOptions Default

Field Value

InstructionLoweringOptions

Properties

Dead

DeadRanges, never the default (uninitialized) array.

public ImmutableArray<SourceRange> Dead { get; }

Property Value

ImmutableArray<SourceRange>

DeadRanges

The source ranges of every #If/#ElseIf/#Else branch that is not live. Empty when the body has no #If at all. A child lexically inside one is never lowered, at any depth.

public ImmutableArray<SourceRange> DeadRanges { get; init; }

Property Value

ImmutableArray<SourceRange>

IncludeDebugStatements

Whether Debug statements are lowered — every build but a release one.

public bool IncludeDebugStatements { get; }

Property Value

bool

IsReleaseBuild

Whether this is a release build, in which Debug.Print and Debug.Assert are not lowered at all — they leave no instruction behind, not a no-op one, so a release build pays nothing for a Debug.Print left in the source. Driven by the DEBUG conditional compilation constant, so that #If DEBUG Then and "does this Debug.Print run" are the same fact rather than two settings that can disagree.

Stated negatively on purpose. This is a record struct, so default zeroes every field regardless of the constructor's own defaults — the state a caller gets by saying nothing has to be the safe one, and the safe one is a debug build that keeps the statements.

public bool IsReleaseBuild { get; init; }

Property Value

bool

Language

The language the body is written in, which decides which statements exist at all - a bare Print is a statement of a BASIC and of no other language, so lowering one for another is an error. null - the default - states no language, and so applies no language's rules: the body is lowered as written.

public SupportedLanguage? Language { get; init; }

Property Value

SupportedLanguage