sun::semantic_analysis::constants::ConstantValue
struct · Source (opens in a new tab)
struct sun::semantic_analysis::constants::ConstantValueA 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
- getFloat
- getInteger
- getString
- isArray
- isFloat
- isInteger
- isString
- isUnsigned
- toDisplayString
getElements
public · function · Source (opens in a new tab)
const Elements & sun::semantic_analysis::constants::ConstantValue::getElements() constThe 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() constThe 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() constThe 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() constThe text; the value must be a string.
isArray
public · function · Source (opens in a new tab)
bool sun::semantic_analysis::constants::ConstantValue::isArray() constReports whether the value is an array of values.
isFloat
public · function · Source (opens in a new tab)
bool sun::semantic_analysis::constants::ConstantValue::isFloat() constReports whether the value is a floating-point number.
isInteger
public · function · Source (opens in a new tab)
bool sun::semantic_analysis::constants::ConstantValue::isInteger() constReports whether the value is held as an integer.
isString
public · function · Source (opens in a new tab)
bool sun::semantic_analysis::constants::ConstantValue::isString() constReports 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() constReports 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() constRenders 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::dataNo documentation comment.
Related: Elements
type
public · variable · Source (opens in a new tab)
sun::types::TypePtr sun::semantic_analysis::constants::ConstantValue::typeNo 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