sun::ast::NumberExprAST
class · Source (opens in a new tab)
class sun::ast::NumberExprAST : public sun::ast::ExprASTA numeric literal.
An integer literal is kept as a magnitude and a sign rather than a signed 64-bit value so the whole u64 range is representable: 18446744073709551615 has no int64_t form, yet it is a valid u64 literal. The sign is set only when a minus was folded into a suffixed literal (-128i8).
Inherits
- sun::ast::ExprAST (public)
Types
Public Functions
- NumberExprAST
- dotLabel
- getFloatVal
- getIntegerBits
- getIntegerText
- getMagnitude
- getSuffix
- getType
- getVal
- hasSuffix
- isFloat
- isInteger
- isNegative
- toString
NumberExprAST
NumberExprAST(int64_t intVal)
public · function · Source (opens in a new tab)
sun::ast::NumberExprAST::NumberExprAST(int64_t intVal)Creates this syntax node and takes ownership of any supplied child expressions.
NumberExprAST(uint64_t magnitude, Sign sign, std::string suffix="")
public · function · Source (opens in a new tab)
sun::ast::NumberExprAST::NumberExprAST(uint64_t magnitude, Sign sign, std::string suffix="")Creates this syntax node and takes ownership of any supplied child expressions.
Related: Sign
NumberExprAST(double floatVal, std::string suffix="")
public · function · Source (opens in a new tab)
sun::ast::NumberExprAST::NumberExprAST(double floatVal, std::string suffix="")Creates this syntax node and takes ownership of any supplied child expressions.
dotLabel
public · function · Source (opens in a new tab)
std::string sun::ast::NumberExprAST::dotLabel() const overrideReturns the node label used in syntax-tree graph visualizations.
getFloatVal
public · function · Source (opens in a new tab)
double sun::ast::NumberExprAST::getFloatVal() constReturns the floating-point literal value.
getIntegerBits
public · function · Source (opens in a new tab)
uint64_t sun::ast::NumberExprAST::getIntegerBits() constThe integer literal's two's-complement bit pattern, 64 bits wide.
Every integer type the literal was range-checked against reads its value from the low bits of this pattern.
getIntegerText
public · function · Source (opens in a new tab)
std::string sun::ast::NumberExprAST::getIntegerText() constThe integer literal as written, without its suffix ("-129", "42").
getMagnitude
public · function · Source (opens in a new tab)
uint64_t sun::ast::NumberExprAST::getMagnitude() constAbsolute value of an integer literal.
getSuffix
public · function · Source (opens in a new tab)
const std::string & sun::ast::NumberExprAST::getSuffix() constReturns the suffix stored by this object.
getType
public · function · Source (opens in a new tab)
ASTNodeType sun::ast::NumberExprAST::getType() const overrideReturns the syntax-node kind used to dispatch tree visitors.
Related: ASTNodeType
getVal
public · function · Source (opens in a new tab)
double sun::ast::NumberExprAST::getVal() constFor backward compatibility, get value as double.
hasSuffix
public · function · Source (opens in a new tab)
bool sun::ast::NumberExprAST::hasSuffix() constReports whether this object has suffix.
isFloat
public · function · Source (opens in a new tab)
bool sun::ast::NumberExprAST::isFloat() constReports whether the semantic type is a floating-point number.
isInteger
public · function · Source (opens in a new tab)
bool sun::ast::NumberExprAST::isInteger() constReports whether this syntax node represents an integer literal.
isNegative
public · function · Source (opens in a new tab)
bool sun::ast::NumberExprAST::isNegative() constTrue when the integer literal is negative; never true for a zero.
toString
public · function · Source (opens in a new tab)
std::string sun::ast::NumberExprAST::toString() const overrideReturns a readable representation for diagnostics and debugging.
Public Enums
Sign
public · enum · Source (opens in a new tab)
enum class sun::ast::NumberExprAST::SignAn enum rather than a bool so a suffix string can never be mistaken for the sign at a construction site.
Positive
Positive
No documentation comment.
Negative
Negative
No documentation comment.
Private Fields
suffix_
private · variable · Source (opens in a new tab)
std::string sun::ast::NumberExprAST::suffix_No documentation comment.
value_
private · variable · Source (opens in a new tab)
std::variant<IntegerValue, double> sun::ast::NumberExprAST::value_No documentation comment.
Related: IntegerValue