MysoreScript
Public Member Functions | Public Attributes | Protected Member Functions | List of all members
AST::Number Struct Reference

A number literal. More...

#include <ast.hh>

Inheritance diagram for AST::Number:
Inheritance graph
[legend]
Collaboration diagram for AST::Number:
Collaboration graph
[legend]

Public Member Functions

bool construct (const pegmatite::InputRange &r, pegmatite::ASTStack &st, const ErrorReporter &) override
 Constructs the class from the source range. More...
 
bool isConstantExpression () override
 All literals are constant expressions. More...
 
- Public Member Functions inherited from AST::Expression
Obj evaluate (Interpreter::Context &c)
 Evaluate the expression, caching the result if it's a constant expression. More...
 
void interpret (Interpreter::Context &c) override final
 Interpret this expression as if it were a statement. More...
 
void compile (Compiler::Context &c) override final
 Compile this expression as if it were a statement. More...
 

Public Attributes

int64_t value
 The value of this literal. More...
 

Protected Member Functions

Obj evaluateExpr (Interpreter::Context &c) override
 Construct the small integer (integer in a pointer with the low bit set to 1) value corresponding to this literal. More...
 
llvm::Value * compileExpression (Compiler::Context &c) override
 Compile the expression, returning an LLVM constant integer. More...
 
void collectVarUses (std::unordered_set< std::string > &decls, std::unordered_set< std::string > &uses) override
 Literals do not define or use any values. More...
 

Additional Inherited Members

- Protected Attributes inherited from AST::Expression
Interpreter::Value cache
 Cached result for constant expression. More...
 

Detailed Description

A number literal.

Definition at line 123 of file ast.hh.

Member Function Documentation

§ collectVarUses()

void AST::Number::collectVarUses ( std::unordered_set< std::string > &  decls,
std::unordered_set< std::string > &  uses 
)
inlineoverrideprotectedvirtual

Literals do not define or use any values.

Implements AST::Statement.

Definition at line 160 of file ast.hh.

§ compileExpression()

Value * Number::compileExpression ( Compiler::Context c)
overrideprotectedvirtual

Compile the expression, returning an LLVM constant integer.

Implements AST::Expression.

Definition at line 595 of file compiler.cc.

Here is the call graph for this function:

§ construct()

bool AST::Number::construct ( const pegmatite::InputRange &  r,
pegmatite::ASTStack &  st,
const ErrorReporter &   
)
inlineoverride

Constructs the class from the source range.

Numbers are terminals, so this will construct the numeric value from the text.

Definition at line 134 of file ast.hh.

§ evaluateExpr()

Obj AST::Number::evaluateExpr ( Interpreter::Context c)
inlineoverrideprotectedvirtual

Construct the small integer (integer in a pointer with the low bit set to 1) value corresponding to this literal.

Implements AST::Expression.

Definition at line 149 of file ast.hh.

§ isConstantExpression()

bool AST::Number::isConstantExpression ( )
inlineoverridevirtual

All literals are constant expressions.

Reimplemented from AST::Expression.

Definition at line 143 of file ast.hh.

Member Data Documentation

§ value

int64_t AST::Number::value

The value of this literal.

MysoreScript integers are 61 bits, so a 64-bit integer is enough to store the value.

Definition at line 129 of file ast.hh.


The documentation for this struct was generated from the following files: