sun::semantic_analysis::constants::ConstantValue

sun::semantic_analysis::constants::ConstantValue

struct · Source (opens in a new tab)

struct sun::semantic_analysis::constants::ConstantValue

A value known at compile time, together with the Sun type it has.

Integers, bools, chars and payload-free enum variants are all held as an integer whose width is the width the type has in generated code; whether it is signed is a property of the type, not of the stored bits. Floats keep their own precision. An array holds one value per element, and nests for more than one dimension.

Public Functions

getElements

public · function · Source (opens in a new tab)

const Elements & sun::semantic_analysis::constants::ConstantValue::getElements() const

The elements; the value must be an array.

Related: Elements

getFloat

public · function · Source (opens in a new tab)

const llvm::APFloat & sun::semantic_analysis::constants::ConstantValue::getFloat() const

The floating-point number; the value must be a float.

getInteger

public · function · Source (opens in a new tab)

const llvm::APInt & sun::semantic_analysis::constants::ConstantValue::getInteger() const

The integer bits; the value must be held as an integer.

getString

public · function · Source (opens in a new tab)

const std::string & sun::semantic_analysis::constants::ConstantValue::getString() const

The text; the value must be a string.

isArray

public · function · Source (opens in a new tab)

bool sun::semantic_analysis::constants::ConstantValue::isArray() const

Reports whether the value is an array of values.

isFloat

public · function · Source (opens in a new tab)

bool sun::semantic_analysis::constants::ConstantValue::isFloat() const

Reports whether the value is a floating-point number.

isInteger

public · function · Source (opens in a new tab)

bool sun::semantic_analysis::constants::ConstantValue::isInteger() const

Reports whether the value is held as an integer.

isString

public · function · Source (opens in a new tab)

bool sun::semantic_analysis::constants::ConstantValue::isString() const

Reports whether the value is the text of a string literal.

isUnsigned

public · function · Source (opens in a new tab)

bool sun::semantic_analysis::constants::ConstantValue::isUnsigned() const

Reports whether an integer value reads as unsigned, which is decided by its type exactly as generated code decides it.

toDisplayString

public · function · Source (opens in a new tab)

std::string sun::semantic_analysis::constants::ConstantValue::toDisplayString() const

Renders the value for diagnostics and tests, such as -4 or [1, 2].

Public Fields

data

public · variable · Source (opens in a new tab)

std::variant<llvm::APInt, llvm::APFloat, std::string, Elements> sun::semantic_analysis::constants::ConstantValue::data

No documentation comment.

Related: Elements

type

public · variable · Source (opens in a new tab)

sun::types::TypePtr sun::semantic_analysis::constants::ConstantValue::type

No documentation comment.

Related: sun::types::TypePtr

Public Type Aliases

Elements

public · typedef · Source (opens in a new tab)

using sun::semantic_analysis::constants::ConstantValue::Elements =  std::vector<ConstantValue>

The elements of an array value, outermost dimension first.

Related: ConstantValue