sun::ast::NumberExprAST

sun::ast::NumberExprAST

class · Source (opens in a new tab)

class sun::ast::NumberExprAST : public sun::ast::ExprAST

A 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

Types

Public Functions

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 override

Returns the node label used in syntax-tree graph visualizations.

getFloatVal

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

double sun::ast::NumberExprAST::getFloatVal() const

Returns the floating-point literal value.

getIntegerBits

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

uint64_t sun::ast::NumberExprAST::getIntegerBits() const

The 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() const

The integer literal as written, without its suffix ("-129", "42").

getMagnitude

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

uint64_t sun::ast::NumberExprAST::getMagnitude() const

Absolute value of an integer literal.

getSuffix

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

const std::string & sun::ast::NumberExprAST::getSuffix() const

Returns the suffix stored by this object.

getType

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

ASTNodeType sun::ast::NumberExprAST::getType() const override

Returns 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() const

For backward compatibility, get value as double.

hasSuffix

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

bool sun::ast::NumberExprAST::hasSuffix() const

Reports whether this object has suffix.

isFloat

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

bool sun::ast::NumberExprAST::isFloat() const

Reports whether the semantic type is a floating-point number.

isInteger

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

bool sun::ast::NumberExprAST::isInteger() const

Reports whether this syntax node represents an integer literal.

isNegative

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

bool sun::ast::NumberExprAST::isNegative() const

True 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 override

Returns a readable representation for diagnostics and debugging.

Public Enums

Sign

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

enum class sun::ast::NumberExprAST::Sign

An 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