Untyped AST (uAST)¶
This section contains definitions declared in the chpl::uast namespace.
-
namespace chpl::uast¶
Typedefs
Enums
-
enum BlockStyle¶
An enum representing whether a construct’s body is preceded by a keyword, a block, or both. For example:
// This would be BlockStyle::IMPLICIT: for i in 0..15 do writeln(i); // This would be BlockStyle::EXPLICIT: for i in 0..15 { writeln(i); } // This would be BlockStyle::UNNECESSARY_KEYWORD_AND_BLOCK: for i in 0..15 do { writeln(i); }
Values:
-
enumerator IMPLICIT¶
-
enumerator EXPLICIT¶
-
enumerator UNNECESSARY_KEYWORD_AND_BLOCK¶
-
enumerator IMPLICIT¶
-
enum IntentList¶
A centralized list containing all intent and storage specifiers.
Values:
-
enumerator DEFAULT¶
-
enumerator VAR¶
-
enumerator CONST¶
-
enumerator CONST_REF¶
-
enumerator REF¶
-
enumerator IN¶
-
enumerator CONST_IN¶
-
enumerator OUT¶
-
enumerator INOUT¶
-
enumerator INDEX¶
-
enumerator PARAM¶
-
enumerator TYPE¶
-
enumerator DEFAULT¶
Functions
-
static inline ASTList makeASTList(owned<ASTNode> ast)¶
Create an ASTList containing a single ast element, transferring ownership of that element to the list.
-
bool updateASTList(ASTList &keep, ASTList &addin)¶
Update an AST list with some replacement AST.
It’s kindof like swapping ‘keep’ and ‘addin’ but it tries to keep old AST nodes when they are the same. This allows for more reuse of results in the query framework.
‘keep’ is some old AST ‘addin’ is some new AST we wish to replace it with
on exit, ‘keep’ stores the AST we need to ‘keep’, and anything not kept is stored in ‘addin’. On exit, the order of nodes stored in ‘addin’ does not matter.
The function returns ‘true’ if anything changed in ‘keep’.
-
class AggregateDecl : public chpl::uast::TypeDecl¶
- #include <AggregateDecl.h>
This is the parent class combining functionality for class, record, and union declarations.
The contained decls can be: Variable Function TupleDecl MultiDecl TypeDecl Comment
Subclassed by chpl::uast::Class, chpl::uast::Record, chpl::uast::Union
Public Functions
-
inline AggregateDecl(ASTTag tag, ASTList children, int attributesChildNum, Decl::Visibility vis, Decl::Linkage linkage, int linkageNameChildNum, UniqueString name, int elementsChildNum, int numElements)¶
-
virtual ~AggregateDecl() = 0¶
-
inline ASTListIteratorPair<Expression> declOrComments() const¶
Return a way to iterate over the contained Decls and Comments.
-
inline int numDeclOrComments() const¶
Return the number of Decls and Comments contained in this AggregateDecl.
-
inline const Expression *declOrComment(int i) const¶
Return the i’th Decl in this AggregateDecl.
-
inline ASTListNoCommentsIteratorPair<Decl> decls() const¶
Return a way to iterate over the contained Decls (ignoring Comments)
-
inline AggregateDecl(ASTTag tag, ASTList children, int attributesChildNum, Decl::Visibility vis, Decl::Linkage linkage, int linkageNameChildNum, UniqueString name, int elementsChildNum, int numElements)¶
-
class Array : public chpl::uast::Expression¶
- #include <Array.h>
This class represents an array expression. For example:
// Example 1: var a = [ 1, 2, 3 ];
An array expression will never contain comments.
Public Functions
-
~Array() override = default¶
-
inline ASTListIteratorPair<Expression> exprs() const¶
Return a way to iterate over the expressions of this array.
-
inline const Expression *expr(int i) const¶
Return the i’th expression in this array.
-
~Array() override = default¶
-
class As : public chpl::uast::Expression¶
- #include <As.h>
This class represents an ‘as’ expression. As expressions are used within use clauses to rename a symbol in the current scope. For example:
// Here an as clause is used to rename 'Foo' to 'X'. use Foo as X;
Public Functions
-
~As() override = default¶
-
inline const Expression *symbol() const¶
Return the original name specified by this as expression.
-
inline const Identifier *rename() const¶
Return the rename specified by this as expression.
Public Static Functions
-
static owned<As> build(Builder *builder, Location loc, owned<Expression> symbol, owned<Identifier> rename)¶
Create and return an as expression.
-
~As() override = default¶
-
template<typename CastToType>
class ASTListIterator¶ - #include <ASTList.h>
Defines an iterator over the AST list elements. The iterator hides the ownership (it always returns a pointer e.g. ASTNode*) and casts elements to a particular type.
Public Types
-
using iterator_category = std::random_access_iterator_tag¶
-
using value_type = const CastToType*¶
-
using pointer = const CastToType**¶
-
using reference = const CastToType*&¶
Public Functions
-
ASTListIterator() = default¶
-
~ASTListIterator() = default¶
-
ASTListIterator<CastToType> &operator=(const ASTListIterator<CastToType> &it) = default¶
-
inline bool operator==(const ASTListIterator<CastToType> rhs) const¶
-
inline bool operator!=(const ASTListIterator<CastToType> rhs) const¶
-
inline const CastToType *operator*() const¶
-
inline const CastToType *operator->() const¶
-
inline ASTListIterator<CastToType> &operator++()¶
-
inline ASTListIterator<CastToType> operator++(int)¶
-
inline ASTListIterator<CastToType> &operator--()¶
-
inline ASTListIterator<CastToType> operator--(int)¶
-
inline ASTListIterator<CastToType> operator+(const difference_type rhs) const¶
-
inline ASTListIterator<CastToType> operator-(const difference_type rhs) const¶
-
inline difference_type operator-(const ASTListIterator<CastToType> rhs) const¶
-
inline bool operator<(const ASTListIterator<CastToType> rhs) const¶
-
inline bool operator>(const ASTListIterator<CastToType> rhs) const¶
-
inline bool operator<=(const ASTListIterator<CastToType> rhs) const¶
-
inline bool operator>=(const ASTListIterator<CastToType> rhs) const¶
-
inline const ASTListIterator<CastToType> &operator+=(const difference_type &rhs)¶
-
inline const ASTListIterator<CastToType> &operator-=(const difference_type &rhs)¶
-
inline const CastToType *operator[](const int rhs)¶
-
using iterator_category = std::random_access_iterator_tag¶
-
template<typename CastToType>
struct ASTListIteratorPair¶ Public Functions
-
~ASTListIteratorPair() = default¶
-
inline ASTListIterator<CastToType> begin() const¶
-
inline ASTListIterator<CastToType> end() const¶
-
~ASTListIteratorPair() = default¶
-
template<typename CastToType>
class ASTListNoCommentsIterator¶ - #include <Comment.h>
Defines an iterator over the AST list elements that ignores comments. The iterator hides the ownership (it always returns a pointer e.g. ASTNode*) and casts elements to a particular type.
Public Types
-
using iterator_category = std::forward_iterator_tag¶
-
using value_type = const CastToType*¶
-
using pointer = const CastToType**¶
-
using reference = const CastToType*&¶
Public Functions
-
ASTListNoCommentsIterator() = default¶
-
inline explicit ASTListNoCommentsIterator(ASTList::const_iterator start, ASTList::const_iterator end)¶
-
~ASTListNoCommentsIterator() = default¶
-
ASTListNoCommentsIterator<CastToType> &operator=(const ASTListNoCommentsIterator<CastToType> &it) = default¶
-
inline bool operator==(const ASTListNoCommentsIterator<CastToType> rhs) const¶
-
inline bool operator!=(const ASTListNoCommentsIterator<CastToType> rhs) const¶
-
inline const CastToType *operator*() const¶
-
inline const CastToType *operator->() const¶
-
inline ASTListNoCommentsIterator<CastToType> &operator++()¶
-
inline ASTListNoCommentsIterator<CastToType> operator++(int)¶
-
inline bool operator<(const ASTListNoCommentsIterator<CastToType> rhs) const¶
-
inline bool operator>(const ASTListNoCommentsIterator<CastToType> rhs) const¶
-
inline bool operator<=(const ASTListNoCommentsIterator<CastToType> rhs) const¶
-
inline bool operator>=(const ASTListNoCommentsIterator<CastToType> rhs) const¶
-
using iterator_category = std::forward_iterator_tag¶
-
template<typename CastToType>
struct ASTListNoCommentsIteratorPair¶ Public Functions
-
~ASTListNoCommentsIteratorPair() = default¶
-
inline ASTListNoCommentsIterator<CastToType> begin() const¶
-
inline ASTListNoCommentsIterator<CastToType> end() const¶
Public Members
-
ASTListNoCommentsIterator<CastToType> begin_¶
-
~ASTListNoCommentsIteratorPair() = default¶
-
class ASTNode¶
- #include <ASTNode.h>
This is the base class for AST types.
Every AST class has: a tag (indicating which AST class it is) an ID (a sort of scoped location used as a key in maps) a list of child AST nodes
The list of child nodes is included in ASTNode to allow for generic tree traversals of the AST.
Functions like someAst->isCall() / someAst->toCall() are available and generated for all AST types.
std::less is defined for every AST class and it compares IDs.
Subclassed by chpl::uast::Expression
Public Functions
-
virtual ~ASTNode() = 0¶
-
inline int numChildren() const¶
Returns the number of child AST nodes in the tree directly under this one.
-
inline ASTListIteratorPair<ASTNode> children() const¶
Return a way to iterate over the children.
-
inline const ASTNode *child(int i) const¶
Returns the i’th child AST node in the tree directly under this one. This function returns a “borrow” of the AST node. It is managed by this object.
-
inline bool contains(const ASTNode *other) const¶
Returns ‘true’ if this symbol contains another AST node. This is an operation on the IDs.
-
template<typename ReturnType, typename Visitor>
inline ReturnType dispatch(Visitor &v) const¶ The dispatch function supports calling a method according to the tag (aka runtime type) of a uast node. It does not itself visit children of the uast node (but of course the called visit function is free to do so).
It is a template and the Visitor argument should provide functions like
MyReturnType MyVisitor::visit(const uast::Expression* ast); MyReturnType MyVisitor::visit(const uast::Variable* ast);
and these will be invoked according to C++ overload resolution (where in particular an exact match will be preferred).
It is generally necessary to specify the ReturnType when calling it, e.g.
ast->dispatch<MyReturnType>(myVisitor);
The return type currently needs to be default constructable.
-
template<typename Visitor>
inline void traverse(Visitor &v) const¶ The traverse function supports calling a method according to the tag (aka runtime type) of a uast node and calling that method also on the children of the uast node.
It is a template and the Visitor argument should provide functions like
bool MyTraverser::enter(const uast::Expression* ast); void MyTraverser::exit(const uast::Expression* ast); bool MyTraverser::enter(const uast::Variable* ast); void MyTraverser::exit(const uast::Variable* ast);
and these will be invoked according to C++ overload resolution (where in particular an exact match will be preferred).
The enter method returns whether or not the children should be visited. In particular, when visiting a node:
First, the enter method is called. If enter returns true, the children are visited. Then the exit method is called (whether or not enter returned true).
Unlike
dispatch
, this function doesn’t support returning a value.The traverse function can be called like this:
traverse(myTraverser, ast);
-
virtual ~ASTNode() = 0¶
-
class Attributes : public chpl::uast::Expression¶
- #include <Attributes.h>
This class represents a collection of attributes which are associated with a particular declaration.
Compiler pragmas and deprecation messages (both intended for internal use only) are both examples of attributes.
Public Functions
-
~Attributes() override = default¶
-
inline bool hasPragma(PragmaTag tag) const¶
Returns true if the given pragma is set for this attributes.
-
inline PragmaIterable pragmas() const¶
Iterate over the pragmas stored in this attributes.
-
inline bool isDeprecated() const¶
Returns true if the declaration associated with this attributes is deprecated.
-
inline UniqueString deprecationMessage() const¶
Returns a deprecation message, or the empty string if it is not set.
Public Static Functions
-
static owned<Attributes> build(Builder *builder, Location loc, std::set<PragmaTag> pragmas, bool isDeprecated, UniqueString deprecationMessage)¶
-
~Attributes() override = default¶
-
class Begin : public chpl::uast::SimpleBlockLike¶
- #include <Begin.h>
This class represents a begin statement. For example:
// Example 1: var x = 0; begin { writeln(x); }
Public Functions
-
inline const WithClause *withClause() const¶
Returns the with clause of this begin statement, or nullptr if there is none.
Public Static Functions
-
static owned<Begin> build(Builder *builder, Location loc, owned<WithClause> withClause, BlockStyle blockStyle, ASTList stmts)¶
Create and return a begin statement.
-
inline const WithClause *withClause() const¶
-
class Block : public chpl::uast::SimpleBlockLike¶
- #include <Block.h>
This class represents a { } block.
Public Functions
-
~Block() override = default¶
-
~Block() override = default¶
-
class BoolLiteral : public chpl::uast::Literal¶
- #include <BoolLiteral.h>
This class represents a boolean literal.
Public Functions
-
~BoolLiteral() override = default¶
-
inline bool value() const¶
Returns the value of this bool literal.
Public Static Functions
-
static owned<BoolLiteral> build(Builder *builder, Location loc, bool value)¶
Create and return a BoolLiteral.
-
~BoolLiteral() override = default¶
-
class BracketLoop : public chpl::uast::IndexableLoop¶
- #include <BracketLoop.h>
This class represents a bracket loop. For example:
// Example 1: [i in 0..15] writeln(i);
Public Functions
-
~BracketLoop() override = default¶
Public Static Functions
-
static owned<BracketLoop> build(Builder *builder, Location loc, owned<Decl> index, owned<Expression> iterand, owned<WithClause> withClause, BlockStyle blockStyle, owned<Block> body, bool isExpressionLevel)¶
Create and return a bracket loop.
-
~BracketLoop() override = default¶
-
class Break : public chpl::uast::Expression¶
- #include <Break.h>
This class represents a break statement. For example:
var i = 0; while true { if i >= 16 then break; writeln(i); i += 1; }
Public Functions
-
inline const Identifier *target() const¶
Returns the target of this break statement, or nullptr if there is none.
-
inline const Identifier *target() const¶
-
class Builder¶
- #include <Builder.h>
This class helps to build AST. It should only build AST from one file at a time.
Public Functions
-
void addToplevelExpression(owned<Expression> e)¶
Save a toplevel expression in to the builder. This is called by the parser.
-
void addError(ErrorMessage)¶
Save an error.
-
BuilderResult result()¶
Assign IDs to all of the AST elements added as toplevel expressions to this builder and return the result. This function clears these elements from the builder and it becomes empty.
Public Static Functions
-
void addToplevelExpression(owned<Expression> e)¶
-
class BuilderResult¶
- #include <BuilderResult.h>
This type records the result of building some AST.
Public Types
-
using ErrorIterable = Iterable<std::vector<ErrorMessage>>¶
Public Functions
-
BuilderResult()¶
Construct an empty BuilderResult
-
BuilderResult(UniqueString filePath)¶
Construct a BuilderResult that records a particular file path.
-
inline UniqueString filePath() const¶
Return the file path this result refers to
-
inline int numTopLevelExpressions() const¶
return the number of top-level expressions
-
inline ASTListIteratorPair<ASTNode> topLevelExpressions() const¶
iterate over the parsed top-level expressions
-
inline const Module *singleModule()¶
If the top-level expressions contain only a single Module, return it. Otherwise, return nullptr.
-
inline int numErrors() const¶
return the number of errors
-
inline const ErrorMessage &error(int i) const¶
return the i’th error
-
inline ErrorIterable errors() const¶
Iterate over the errors.
-
const ASTNode *idToAst(ID id) const¶
Find the ASTNode* corresponding to a particular ID, or return nullptr if there is not one in this result.
-
Location idToLocation(ID id, UniqueString path) const¶
Find the Location for a particular ID. Returns a location just to path if none is found.
-
ID idToParentId(ID id) const¶
Find the ID for a parent given an ID. Returns the empty ID if none is found
-
BuilderResult(BuilderResult&&) = default¶
-
BuilderResult(const BuilderResult&) = delete¶
-
BuilderResult &operator=(const BuilderResult&) = delete¶
-
void swap(BuilderResult &other)¶
Public Static Functions
-
static bool update(BuilderResult &keep, BuilderResult &addin)¶
-
static void mark(Context *context, const BuilderResult &keep)¶
-
using ErrorIterable = Iterable<std::vector<ErrorMessage>>¶
-
class BytesLiteral : public chpl::uast::StringLikeLiteral¶
- #include <BytesLiteral.h>
This class represents a bytes literal, for example
b"hello"
and b’’ bytes contents here ‘’’`.Public Functions
-
~BytesLiteral() override = default¶
-
inline UniqueString str() const¶
Returns the value of this bytes literal as a UniqueString which does not include the quotes.
Public Static Functions
-
static owned<BytesLiteral> build(Builder *builder, Location loc, const std::string &value, StringLikeLiteral::QuoteStyle quotes)¶
-
~BytesLiteral() override = default¶
-
class Call : public chpl::uast::Expression¶
- #include <Call.h>
This abstract class represents something call-like. It represents a called expression as well as a number of actuals.
For example
f(1,2)
,f
is the called expression and1
,2
are the actuals.Subclassed by chpl::uast::FnCall, chpl::uast::OpCall, chpl::uast::PrimCall, chpl::uast::Reduce, chpl::uast::Scan, chpl::uast::Tuple, chpl::uast::Zip
Public Functions
-
virtual ~Call() override = 0¶
-
inline ASTListIteratorPair<Expression> actuals() const¶
Returns an iterable expression over the actuals of a call.
-
inline int numActuals() const¶
-
inline const Expression *actual(int i) const¶
-
inline const Expression *calledExpression() const¶
Returns the called expression, or nullptr if there is not for this call.
Note that some subclasses of Call will never have a called expression and will always return nullptr from this function.
-
virtual ~Call() override = 0¶
-
class Catch : public chpl::uast::Expression¶
- #include <Catch.h>
This class represents a catch block. For example:
try { someCallThatWillThrow(); } catch { writeln('Error!'); }
Public Functions
-
~Catch() override = default¶
-
inline const Variable *error() const¶
Returns the error handled by this catch, or nullptr if there is none.
-
inline ASTListIteratorPair<Expression> stmts() const¶
Iterate over the statements contained in the body of this catch.
-
inline const Expression *stmt(int i) const¶
Return the i’th statement contained in the body of this catch.
-
~Catch() override = default¶
-
class Class : public chpl::uast::AggregateDecl¶
- #include <Class.h>
This class represents a class declaration. For example:
class MyClass : ParentClass { var a: int; proc method() { } }
The class itself (MyClass) is represented by a Class AST node.
Public Functions
-
~Class() override = default¶
-
inline const Expression *parentClass() const¶
Return the Expression indicating the parent class or nullptr if there was none.
Public Static Functions
-
static owned<Class> build(Builder *builder, Location loc, owned<Attributes> attributes, Decl::Visibility vis, UniqueString name, owned<Expression> parentClass, ASTList contents)¶
-
~Class() override = default¶
-
class Cobegin : public chpl::uast::Expression¶
- #include <Cobegin.h>
This class represents a cobegin statement. For example:
// Example 1: var x = 0; cobegin { writeln(x); }
Public Functions
-
inline const WithClause *withClause() const¶
Returns the with clause of this cobegin statement, or nullptr if there is none.
-
inline ASTListIteratorPair<Expression> taskBodies() const¶
Return a way to iterate over the task bodies.
-
inline const Expression *taskBody(int i) const¶
Return the i’th task body in this.
-
inline const WithClause *withClause() const¶
-
class Coforall : public chpl::uast::IndexableLoop¶
- #include <Coforall.h>
This class represents a coforall loop. For example:
// Example 1: coforall i in 0..15 { writeln(i); }
Public Functions
-
~Coforall() override = default¶
Public Static Functions
-
static owned<Coforall> build(Builder *builder, Location loc, owned<Decl> index, owned<Expression> iterand, owned<WithClause> withClause, BlockStyle blockStyle, owned<Block> body)¶
Create and return a coforall loop.
-
~Coforall() override = default¶
-
class Comment : public chpl::uast::Expression¶
- #include <Comment.h>
This class represents a comment that might be used for documentation. Not all comments are represented in the AST (since the comments could go anywhere and that would be hard to represent). However, comments that are at a statement level will be represented with this type.
Public Functions
-
~Comment() override = default¶
-
inline const char *c_str() const¶
Returns the contents of this comment, including the comment characters (e.g.
//
) as a C string.
-
inline const std::string &str() const¶
Returns the contents of this comment, including the comment characters (e.g.
//
) as a C++ string.
-
~Comment() override = default¶
-
class Conditional : public chpl::uast::Expression¶
- #include <Conditional.h>
This class represents a conditional. For example:
// Example 1: const flag = false; if flag then writeln('a'); else writeln('b');
Public Functions
-
~Conditional() override = default¶
-
inline const Expression *condition() const¶
Get the condition of this conditional.
-
inline ASTListIteratorPair<Expression> thenStmts() const¶
Iterate over the statements in the then block of this conditional.
-
inline int numThenStmts() const¶
Get the number of statements in the then block of this conditional.
-
inline const Expression *thenStmt(int i) const¶
Get the i’th statement in the then block of this conditional.
-
inline BlockStyle thenBlockStyle() const¶
Returns the block style of the then block of this conditional.
-
inline bool hasElseBlock() const¶
Returns true if this conditional has an else block.
-
inline const Block *elseBlock() const¶
Return the Block containing the else statements, or nullptr if this Conditional has no else.
-
inline ASTListIteratorPair<Expression> elseStmts() const¶
Iterate over the statements in the else block of this conditional.
-
inline int numElseStmts() const¶
Get the number of statements in the else block of this conditional. If there is no else block, returns 0.
-
inline const Expression *elseStmt(int i) const¶
Get the i’th statement in the else block of this conditional. It is an error to call this function if there is no else block.
-
inline BlockStyle elseBlockStyle() const¶
Returns the block style of the else block of this conditional.
Public Static Functions
-
static owned<Conditional> build(Builder *builder, Location loc, owned<Expression> condition, BlockStyle thenBlockStyle, owned<Block> thenBlock, BlockStyle elseBlockStyle, owned<Block> elseBlock, bool isExpressionLevel)¶
Create and return a conditional.
-
static owned<Conditional> build(Builder *builder, Location loc, owned<Expression> condition, BlockStyle thenBlockStyle, owned<Block> thenBlock, bool isExpressionLevel)¶
Create and return a conditional without an else block.
-
~Conditional() override = default¶
-
class Continue : public chpl::uast::Expression¶
- #include <Continue.h>
This class represents a continue statement. For example:
for i in 0..15 { if !(i % 2) then continue; writeln(i); }
Public Functions
-
inline const Identifier *target() const¶
Returns the target of this continue statement, or nullptr if there is none.
-
inline const Identifier *target() const¶
-
class CStringLiteral : public chpl::uast::StringLikeLiteral¶
- #include <CStringLiteral.h>
This class represents a C string literal, for example
c"hello"
.Public Functions
-
~CStringLiteral() override = default¶
-
inline UniqueString str() const¶
Returns the value of this c string literal as a UniqueString which does not include the quotes.
Public Static Functions
-
static owned<CStringLiteral> build(Builder *builder, Location loc, const std::string &value, StringLikeLiteral::QuoteStyle quotes)¶
-
~CStringLiteral() override = default¶
-
class Decl : public chpl::uast::Expression¶
- #include <Decl.h>
This is an abstract base class for declarations. Note that most Decls inherit from NamedDecl, however these declarations might be contained in MultiDecl or TupleDecl.
Subclassed by chpl::uast::ForwardingDecl, chpl::uast::MultiDecl, chpl::uast::NamedDecl, chpl::uast::TupleDecl
Public Types
Public Functions
-
virtual ~Decl() = 0¶
-
inline Visibility visibility() const¶
Return the visibility of this declaration, e.g. “PUBLIC” or “PRIVATE”.
-
inline const Expression *linkageName() const¶
Return the linkage name expression, e.g. “f_c_name” in the below, or nullptr if there is none.
extern "f_c_name" proc f(arg) { }
-
inline const Attributes *attributes() const¶
Return the attributes associated with this declaration, or nullptr if none exist.
-
virtual ~Decl() = 0¶
-
class Defer : public chpl::uast::SimpleBlockLike¶
- #include <Defer.h>
This class represents a defer block. For example:
// Example 1: proc deferExample() { defer { writeln('bar'); } writeln('foo'); } deferExample();
This code will write ‘bar’ after ‘foo’ due to use of the defer block.
Public Functions
-
~Defer() override = default¶
-
~Defer() override = default¶
-
class Delete : public chpl::uast::Expression¶
- #include <Delete.h>
This class represents a delete statement. For example:
// Example 1: var c = new unmanaged C(); delete c;
Public Functions
-
inline ASTListIteratorPair<Expression> exprs() const¶
Return a way to iterate over the expressions of this delete statement.
-
inline const Expression *expr(int i) const¶
Return the i’th expression in this delete statement.
-
inline ASTListIteratorPair<Expression> exprs() const¶
-
class Domain : public chpl::uast::Expression¶
- #include <Domain.h>
This class represents a domain expression. For example:
// Example 1: var d = { 'foo', 'bar', 'baz' };
A domain expression will never contain comments.
Public Functions
-
~Domain() override = default¶
-
inline ASTListIteratorPair<Expression> exprs() const¶
Return a way to iterate over the expressions of this domain.
-
inline const Expression *expr(int i) const¶
Return the i’th expression in this domain.
-
~Domain() override = default¶
-
class Dot : public chpl::uast::Expression¶
- #include <Dot.h>
This class represents a dot expression. A dot expression might be:
a method call field access qualified access within a module or enum
For example,
a.b
,this.type
,Module.myFunc
are dot expressions.Consider
myObject.myMethod()
, orx.f(a=3)
. These are method calls that also involve Dot expressions. These are represented as an FnCall containing a Dot expression. For example, forx.f(a=3)
, it is represented asFnCall(calledExpression=
x.f
, actuals=[3], names=[a]);where the
x.f
is a Dot expression.Public Functions
-
~Dot() override = default¶
-
inline const Expression *receiver() const¶
Returns the left-hand-side of the Dot expression
-
inline UniqueString field() const¶
Returns the name of the field or method accessed by the Dot expression
Public Static Functions
-
static owned<Dot> build(Builder *builder, Location loc, owned<Expression> receiver, UniqueString fieldName)¶
-
~Dot() override = default¶
-
class DoWhile : public chpl::uast::Loop¶
- #include <DoWhile.h>
This class represents a do-while loop. For example:
// Example 1: var i = 0; do { writeln(i); i += 1; } while i < 5;
Public Functions
-
~DoWhile() override = default¶
-
inline const Expression *condition() const¶
Return the condition of this do-while loop.
Public Static Functions
-
static owned<DoWhile> build(Builder *builder, Location loc, BlockStyle blockStyle, owned<Block> body, owned<Expression> condition)¶
Create and return a do-while loop.
-
~DoWhile() override = default¶
-
class Enum : public chpl::uast::TypeDecl¶
- #include <Enum.h>
This class represents an enum declaration. For example:
enum myEnum { a, b = 2, c }
The enum itself (myEnum) is represented by an Enum AST node. The Enum AST node contains EnumElementDecls which contain the EnumElements (for a, b, c in the example).
Public Functions
-
~Enum() override = default¶
-
inline ASTListIteratorPair<Expression> declOrComments() const¶
Return a way to iterate over the EnumElements and Comments.
-
inline int numDeclOrComments() const¶
Return the number of EnumElements and Comments contained in this Enum.
-
inline const Expression *declOrComment(int i) const¶
Return the i’th EnumElement or Comment in this Enum.
-
inline ASTListNoCommentsIteratorPair<EnumElement> enumElements() const¶
Return a way to iterate over the EnumElements (ignoring Comments)
Public Static Functions
-
static owned<Enum> build(Builder *builder, Location loc, owned<Attributes> attributes, Decl::Visibility vis, UniqueString name, ASTList stmts)¶
-
~Enum() override = default¶
-
class EnumElement : public chpl::uast::NamedDecl¶
- #include <EnumElement.h>
This class represents an element in an enum. For example, a, b, c in the below are EnumElements.
enum myEnum { a, b = 2, c }
Public Functions
-
~EnumElement() override = default¶
-
inline const Expression *initExpression() const¶
Returns the init expression for this EnumElement or nullptr if there was none.
Public Static Functions
-
static owned<EnumElement> build(Builder *builder, Location loc, owned<Attributes> attributes, UniqueString name, owned<Expression> initExpression)¶
-
static owned<EnumElement> build(Builder *builder, Location loc, owned<Attributes> attributes, UniqueString name)¶
-
~EnumElement() override = default¶
-
class ErroneousExpression : public chpl::uast::Expression¶
- #include <ErroneousExpression.h>
This class represents some missing AST due to an error.
Public Functions
-
~ErroneousExpression() = default¶
Public Static Functions
-
static owned<ErroneousExpression> build(Builder *builder, Location loc)¶
-
~ErroneousExpression() = default¶
-
class Expression : public chpl::uast::ASTNode¶
- #include <Expression.h>
This is an abstract base class for expressions
Subclassed by chpl::uast::Array, chpl::uast::As, chpl::uast::Attributes, chpl::uast::Break, chpl::uast::Call, chpl::uast::Catch, chpl::uast::Cobegin, chpl::uast::Comment, chpl::uast::Conditional, chpl::uast::Continue, chpl::uast::Decl, chpl::uast::Delete, chpl::uast::Domain, chpl::uast::Dot, chpl::uast::ErroneousExpression, chpl::uast::ExternBlock, chpl::uast::Identifier, chpl::uast::Import, chpl::uast::Label, chpl::uast::Literal, chpl::uast::Loop, chpl::uast::New, chpl::uast::Range, chpl::uast::Return, chpl::uast::Select, chpl::uast::SimpleBlockLike, chpl::uast::Throw, chpl::uast::Try, chpl::uast::TypeQuery, chpl::uast::Use, chpl::uast::VisibilityClause, chpl::uast::WithClause, chpl::uast::Yield
Public Functions
-
virtual ~Expression() = 0¶
-
virtual ~Expression() = 0¶
-
class ExternBlock : public chpl::uast::Expression¶
- #include <ExternBlock.h>
This class represents an extern block. For example:
extern { int cAdd(int a, int b) { return a + b; } writeln(cAdd(2, 2)); }
Public Static Functions
-
static owned<ExternBlock> build(Builder *builder, Location loc, std::string code)¶
Create and return an ExternBlock with the given C code.
-
static owned<ExternBlock> build(Builder *builder, Location loc, std::string code)¶
-
class FnCall : public chpl::uast::Call¶
- #include <FnCall.h>
This class represents a call to a function.
For example
f(1,2)
, is a call to a functionf
.Note that calls to paren-less free functions are not represented with this type since early in compilation they are just Identifiers.
For example, in
proc x { } x; // here 'x' is represented as an Identifier, not as a Call
Public Functions
-
~FnCall() override = default¶
-
inline bool isNamedActual(int i) const¶
Returns whether actual i is named as with ‘f(a=3)’ where the actual is 3 and the name is ‘a’.
-
inline UniqueString actualName(int i) const¶
Returns the name of the actual, if used; otherwise the empty string
-
inline bool callUsedSquareBrackets() const¶
Returns true if the call used square brackets e.g. f[1]; the alternative is parentheses e.g. f(1).
Public Static Functions
-
static owned<FnCall> build(Builder *builder, Location loc, owned<Expression> calledExpression, ASTList actuals, std::vector<UniqueString> actualNames, bool callUsedSquareBrackets)¶
-
~FnCall() override = default¶
-
class For : public chpl::uast::IndexableLoop¶
- #include <For.h>
This class represents a for loop. For example:
// Example 1: for i in myRange { var x; }
-
class Forall : public chpl::uast::IndexableLoop¶
- #include <Forall.h>
This class represents a forall loop. For example:
// Example 1: var x: atomic int; forall i in myRange { x.fetchAdd(i); }
Public Functions
-
~Forall() override = default¶
Public Static Functions
-
static owned<Forall> build(Builder *builder, Location loc, owned<Decl> index, owned<Expression> iterand, owned<WithClause> withClause, BlockStyle blockStyle, owned<Block> body, bool isExpressionLevel)¶
Create and return a forall loop.
-
~Forall() override = default¶
-
class Foreach : public chpl::uast::IndexableLoop¶
- #include <Foreach.h>
This class represents a foreach loop. For example:
// Example 1: var x: atomic int; foreach i in myRange with (ref x) { x.fetchAdd(i); }
Public Functions
-
~Foreach() override = default¶
Public Static Functions
-
static owned<Foreach> build(Builder *builder, Location loc, owned<Decl> index, owned<Expression> iterand, owned<WithClause> withClause, BlockStyle blockStyle, owned<Block> body)¶
Create and return a foreach loop.
-
~Foreach() override = default¶
-
class Formal : public chpl::uast::VarLikeDecl¶
- #include <Formal.h>
This class represents a formal. For example,
x
is a formal in the below:proc f( x ) { }
The Formals are stored inside of a Function.
Public Types
Public Functions
-
~Formal() override = default¶
Public Static Functions
-
static owned<Formal> build(Builder *builder, Location loc, owned<Attributes> attributes, UniqueString name, Formal::Intent intent, owned<Expression> typeExpression, owned<Expression> initExpression)¶
-
~Formal() override = default¶
-
class ForwardingDecl : public chpl::uast::Decl¶
- #include <ForwardingDecl.h>
This class represents a forwarding statement. Forwarding allows a record or class to specify that certain method calls will be forwarded to a particular expression.
record MyCircle { forwarding var impl: MyCircleImpl; } record MyCircle { var impl: MyCircleImpl; forwarding impl except area; }
The forwarding statement stores an expression that is either a VisibilityClause, a FnCall, or a Variable.
Public Functions
-
~ForwardingDecl() override = default¶
-
inline const Expression *expr() const¶
Returns the child for this ForwardingDecl or nullptr if there was none.
Public Static Functions
-
static owned<ForwardingDecl> build(Builder *builder, Location loc, owned<Attributes> attributes, owned<Expression> expr)¶
-
static owned<ForwardingDecl> build(Builder *builder, Location loc, owned<Attributes> attributes, owned<Expression> expr, Decl::Visibility visibility)¶
-
~ForwardingDecl() override = default¶
-
class Function : public chpl::uast::NamedDecl¶
- #include <Function.h>
This class represents a function. For example:
proc f(arg) { } proc g(x: int = 32) where something() { } iter myiter() { } operator =(ref lhs, rhs) { }
each of these is a Function.
Public Types
Public Functions
-
~Function() override = default¶
-
inline ReturnIntent returnIntent() const¶
-
inline bool isInline() const¶
-
inline bool isOverride() const¶
-
inline bool throws() const¶
-
inline bool isPrimaryMethod() const¶
-
inline bool isParenless() const¶
-
inline ASTListIteratorPair<Decl> formals() const¶
Return a way to iterate over the formals, including the method receiver, if present, as the first formal. This iterator may yield nodes of type Formal, TupleDecl, or VarArgFormal.
-
inline const Formal *thisFormal() const¶
Returns the Formal for the ‘this’ formal argument, or ‘nullptr’ if there is none.
-
inline const Expression *returnType() const¶
Returns the expression for the return type or nullptr if there was none.
-
inline const Expression *whereClause() const¶
Returns the expression for the where clause or nullptr if there was none.
-
inline ASTListIteratorPair<Expression> lifetimeClauses() const¶
Return a way to iterate over the lifetime clauses.
-
inline const Expression *lifetimeClause(int i) const¶
Return the i’th lifetime clause
-
inline ASTListIteratorPair<Expression> stmts() const¶
Return a way to iterate over the statements in the function body.
-
inline int numStmts() const¶
Return the number of statements in the function body or 0 if there is no function body.
-
inline const Expression *stmt(int i) const¶
Return the i’th statement in the function body. It is an error to call this function if there isn’t one.
Public Static Functions
-
static owned<Function> build(Builder *builder, Location loc, owned<Attributes> attributes, Decl::Visibility vis, Decl::Linkage linkage, owned<Expression> linkageName, UniqueString name, bool inline_, bool override_, Function::Kind kind, owned<Formal> receiver, Function::ReturnIntent returnIntent, bool throws, bool primaryMethod, bool parenless, ASTList formals, owned<Expression> returnType, owned<Expression> where, ASTList lifetime, owned<Block> body)¶
-
~Function() override = default¶
-
class Identifier : public chpl::uast::Expression¶
- #include <Identifier.h>
This class represents a reference to a symbol by name. E.g. in
var x = 1; // here, 'x' is not an Identifier (it is the declared symbol) f(x); // here, 'f' and 'x' are Identifiers
Public Static Functions
-
static owned<Identifier> build(Builder *builder, Location loc, UniqueString name)¶
-
static owned<Identifier> build(Builder *builder, Location loc, UniqueString name)¶
-
class ImagLiteral : public chpl::uast::NumericLiteral<double, types::RealParam>¶
- #include <ImagLiteral.h>
This class represents an imaginary floating point literal, e.g.
10.4i
.Public Functions
-
~ImagLiteral() override = default¶
Public Static Functions
-
static owned<ImagLiteral> build(Builder *builder, Location loc, double value, UniqueString text)¶
-
~ImagLiteral() override = default¶
-
class Import : public chpl::uast::Expression¶
- #include <Import.h>
This class represents an import statement. For example:
// Example 1: import Foo, Bar as A;
This creates an import statement that has two visibility clauses, ‘Foo’ and ‘Bar as A’.
Public Functions
-
inline Decl::Visibility visibility() const¶
Return the visibility of this import statement.
-
inline ASTListIteratorPair<VisibilityClause> visibilityClauses() const¶
Return a way to iterate over the visibility clauses.
-
inline int numVisibilityClauses() const¶
Return the number of visibility clauses in this import statement.
-
inline const VisibilityClause *visibilityClause(int i) const¶
Return the i’th visibility clause in this import statement.
-
inline Decl::Visibility visibility() const¶
-
class IndexableLoop : public chpl::uast::Loop¶
- #include <IndexableLoop.h>
This abstract class represents an indexable loop.
Subclassed by chpl::uast::BracketLoop, chpl::uast::Coforall, chpl::uast::For, chpl::uast::Forall, chpl::uast::Foreach
Public Functions
-
virtual ~IndexableLoop() override = 0¶
-
inline const Decl *index() const¶
Returns the index declaration of this indexable loop, or nullptr if there is none.
-
inline const Expression *iterand() const¶
Returns the iterand of this indexable loop.
-
inline const WithClause *withClause() const¶
Returns the with clause of this indexable loop, or nullptr if there is none.
-
inline bool isExpressionLevel() const¶
Returns true if this indexable loop appears at the expression level.
-
virtual ~IndexableLoop() override = 0¶
-
class IntLiteral : public chpl::uast::NumericLiteral<int64_t, types::IntParam>¶
- #include <IntLiteral.h>
This class represents a signed integer literal. All integer literals that are not too big are signed integer literals, i.e. have the type
int
. However there are no negative literals. Negative numbers are created by applying the unary-
operator.Public Functions
-
~IntLiteral() override = default¶
Public Static Functions
-
static owned<IntLiteral> build(Builder *builder, Location loc, int64_t value, UniqueString text)¶
-
~IntLiteral() override = default¶
-
class Label : public chpl::uast::Expression¶
- #include <Label.h>
This class represents a label. For example:
label outer for i in 0..15 do label inner while true do if i == 12 then break outer; else break inner;
Public Functions
-
~Label() override = default¶
-
inline UniqueString name() const¶
Return the name of this label statement.
-
~Label() override = default¶
-
class Literal : public chpl::uast::Expression¶
- #include <Literal.h>
This is an abstract base class for literals. Literals are fixed values in the source code, like 1, 30.24, and “x”.
Subclassed by chpl::uast::BoolLiteral, chpl::uast::NumericLiteral< ValueT, ParamT >, chpl::uast::StringLikeLiteral, chpl::uast::NumericLiteral< double, types::RealParam >, chpl::uast::NumericLiteral< int64_t, types::IntParam >, chpl::uast::NumericLiteral< uint64_t, types::UintParam >
-
class Local : public chpl::uast::SimpleBlockLike¶
- #include <Local.h>
This class represents a local statement. For example:
// Example 1: const flag = true; local flag { var x = 0; writeln(x); } // Example 2: var x = 0; local do writeln(x);
Public Functions
-
inline const Expression *condition() const¶
Returns the condition of this local statement, or nullptr if there is none.
Public Static Functions
-
static owned<Local> build(Builder *builder, Location loc, BlockStyle blockStyle, ASTList stmts)¶
Create and return a local statement containing the passed statements.
-
static owned<Local> build(Builder *builder, Location loc, owned<Expression> condition, BlockStyle blockStyle, ASTList stmts)¶
Create and return a local statement with the given condition and containing the passed statements.
-
inline const Expression *condition() const¶
-
class Loop : public chpl::uast::Expression¶
- #include <Loop.h>
This abstract class represents some sort of loop.
Subclassed by chpl::uast::DoWhile, chpl::uast::IndexableLoop, chpl::uast::While
Public Functions
-
virtual ~Loop() override = 0¶
-
inline ASTListIteratorPair<Expression> stmts() const¶
Return a way to iterate over the statements of this loop.
-
inline const Expression *stmt(int i) const¶
Return the i’th statement in the loop.
-
inline BlockStyle blockStyle() const¶
Returns the block style of the current loop.
-
virtual ~Loop() override = 0¶
-
class Module : public chpl::uast::NamedDecl¶
- #include <Module.h>
This class represents a module declaration. For example:
module M { }
is a declaration for a module named M.
Public Types
Public Functions
-
~Module() override = default¶
-
inline ASTListIteratorPair<Expression> stmts() const¶
Iterate over the statements in this module.
-
inline const Expression *stmt(int i) const¶
Get the i’th statement in this module.
Public Static Functions
-
static owned<Module> build(Builder *builder, Location loc, owned<Attributes> attributes, Decl::Visibility vis, UniqueString name, Module::Kind kind, ASTList stmts)¶
-
~Module() override = default¶
-
class MultiDecl : public chpl::uast::Decl¶
- #include <MultiDecl.h>
This class represents a declaration for multiple variables.
E.g.
var a, b:int, c, d = 1; var x: int, y = 3, z: real;
Each of the lines above is represented by a MultiDecl containing a list of VariableDecls. Note that the initial value and/or type is inferred from later declarations.
Since the MultiDecl does not itself have a name, it is not a NamedDecl. Rather, it can contain NamedDecls.
Public Functions
-
~MultiDecl() override = default¶
-
inline ASTListIteratorPair<Expression> declOrComments() const¶
Return a way to iterate over the contained VariableDecls and Comments.
-
inline const Expression *declOrComment(int i) const¶
-
inline ASTListNoCommentsIteratorPair<Decl> decls() const¶
Return a way to iterate over the contained Decls (ignoring Comments)
-
~MultiDecl() override = default¶
-
class NamedDecl : public chpl::uast::Decl¶
- #include <NamedDecl.h>
This is an abstract base class for declarations that carry a name.
Subclassed by chpl::uast::EnumElement, chpl::uast::Function, chpl::uast::Module, chpl::uast::TypeDecl, chpl::uast::VarLikeDecl
-
class New : public chpl::uast::Expression¶
- #include <New.h>
This class represents a new expression. For example:
var foo = new bar(a = 1, 2);
The initialization expression of foo is an FnCall where the base expression is a New node (representing ‘new bar’).
Public Types
Public Functions
-
inline const Expression *typeExpression() const¶
Returns the type expression of this new expression.
-
inline Management management() const¶
Returns the management style of this new expression.
Public Static Functions
-
static owned<New> build(Builder *builder, Location loc, owned<Expression> typeExpression, Management management)¶
Create and return a new expression with the given type expression and management style.
-
inline const Expression *typeExpression() const¶
-
template<typename ValueT, typename ParamT>
class NumericLiteral : public chpl::uast::Literal¶ - #include <NumericLiteral.h>
This is an abstract parent class for int/real/imag numeric literals.
Public Functions
-
virtual ~NumericLiteral() = 0¶
-
inline ValueT value() const¶
Returns the value of this NumericLiteral.
-
inline UniqueString text() const¶
Returns the number as it was written in the source code (as a string)
-
virtual ~NumericLiteral() = 0¶
-
class On : public chpl::uast::SimpleBlockLike¶
- #include <On.h>
This class represents an on statement. For example:
// Example 1: var x = 0; on Locales[1] do writeln(x);
Public Functions
-
inline const Expression *destination() const¶
Returns the destination of this on statement.
Public Static Functions
-
static owned<On> build(Builder *builder, Location loc, owned<Expression> destination, BlockStyle blockStyle, ASTList stmts)¶
Create and return an on statement.
-
inline const Expression *destination() const¶
-
class OpCall : public chpl::uast::Call¶
- #include <OpCall.h>
This class represents a call to an operator.
For example
a + b
andx = y
are calls to operators (where+
and=
are the operators called).Public Functions
-
~OpCall() override = default¶
-
inline UniqueString op() const¶
Returns the name of the operator called
-
inline bool isBinaryOp() const¶
Returns true if this is a binary operator
-
inline bool isUnaryOp() const¶
Returns true if this is a unary operator
Public Static Functions
-
static owned<OpCall> build(Builder *builder, Location loc, UniqueString op, owned<Expression> lhs, owned<Expression> rhs)¶
-
static owned<OpCall> build(Builder *builder, Location loc, UniqueString op, owned<Expression> expr)¶
-
~OpCall() override = default¶
-
class PrimCall : public chpl::uast::Call¶
- #include <PrimCall.h>
This class represents a call to a primitive (which only appears in low-level code).
__primitive("=", x, y)
-
class Range : public chpl::uast::Expression¶
- #include <Range.h>
This class represents a range expression. For example:
// Example 1: var r = 0..15;
Public Functions
-
~Range() override = default¶
-
inline const Expression *lowerBound() const¶
Returns the lower bound of this range, or nullptr if there is none.
-
inline const Expression *upperBound() const¶
Returns the upper bound of this range, or nullptr if there is none.
Public Static Functions
-
static owned<Range> build(Builder *builder, Location loc, OpKind opKind, owned<Expression> lowerBound, owned<Expression> upperBound)¶
Create and return a range expression.
-
~Range() override = default¶
-
class RealLiteral : public chpl::uast::NumericLiteral<double, types::RealParam>¶
- #include <RealLiteral.h>
This class represents a floating point literal that is not imaginary. That is, it is a “real” number. Examples include
0.0
, and3e24
.Public Functions
-
~RealLiteral() override = default¶
Public Static Functions
-
static owned<RealLiteral> build(Builder *builder, Location loc, double value, UniqueString text)¶
-
~RealLiteral() override = default¶
-
class Record : public chpl::uast::AggregateDecl¶
- #include <Record.h>
This class represents a record declaration. For example:
record myRecord { var a: int; proc method() { } }
The record itself (myRecord) is represented by a Record AST node.
Public Functions
-
~Record() override = default¶
Public Static Functions
-
static owned<Record> build(Builder *builder, Location loc, owned<Attributes> attributes, Decl::Visibility vis, Decl::Linkage linkage, owned<Expression> linkageName, UniqueString name, ASTList contents)¶
-
~Record() override = default¶
-
class Reduce : public chpl::uast::Call¶
- #include <Reduce.h>
This class represents a reduction.
Public Functions
-
~Reduce() override = default¶
-
inline UniqueString op() const¶
Returns the reduction operator. It may be either a regular operator (e.g. ‘+’, ‘-‘) or the name of a class.
Public Static Functions
-
static owned<Reduce> build(Builder *builder, Location loc, UniqueString op, owned<Expression> expr)¶
Create and return a reduction.
-
~Reduce() override = default¶
-
class Return : public chpl::uast::Expression¶
- #include <Return.h>
This class represents a return statement. For example:
// Example 1: proc foo(): int { return 0; }
Public Functions
-
~Return() override = default¶
-
inline const Expression *value() const¶
Returns the value of this return statement, or nullptr if there is none.
-
~Return() override = default¶
-
class Scan : public chpl::uast::Call¶
- #include <Scan.h>
This class represents a scan expression. For example:
- ..code-block :: chapel
var A: [1..3] int = 1; // Prints ‘1 2 3’ writeln(+ scan A);
The scan expression is ‘+ scan A’.
Public Functions
-
~Scan() override = default¶
-
inline UniqueString op() const¶
Returns the scan operator. It may be either a regular operator (e.g. ‘+’, ‘-‘) or the name of a class.
Public Static Functions
-
static owned<Scan> build(Builder *builder, Location loc, UniqueString op, owned<Expression> expr)¶
Create and return a scan.
-
class Select : public chpl::uast::Expression¶
- #include <Select.h>
This class represents a select statement. For example:
// Example 1: const i = 2; select i { when 0 do writeln('zero'); otherwise do writeln('number: ', i); }
Public Functions
-
inline const Expression *expr() const¶
Returns the expression of this select statement.
-
inline int numWhenStmts() const¶
Returns the number of when statements in this select statement.
-
inline ASTListIteratorPair<When> whenStmts() const¶
Iterate over the when statements in this select statement.
-
inline const Expression *expr() const¶
-
class Serial : public chpl::uast::SimpleBlockLike¶
- #include <Serial.h>
This class represents a serial statement. For example:
// Example 1: const flag = true; serial flag { var x = 0; writeln(x); } // Example 2: var x = 0; serial do writeln(x);
Public Functions
-
inline const Expression *condition() const¶
Returns the condition of this serial statement, or nullptr if there is none.
Public Static Functions
-
static owned<Serial> build(Builder *builder, Location loc, BlockStyle blockStyle, ASTList stmts)¶
Create and return a serial statement containing the passed statements.
-
static owned<Serial> build(Builder *builder, Location loc, owned<Expression> condition, BlockStyle blockStyle, ASTList stmts)¶
Create and return a serial statement with the given condition and containing the passed statements.
-
inline const Expression *condition() const¶
-
class SimpleBlockLike : public chpl::uast::Expression¶
- #include <SimpleBlockLike.h>
This class represents any sort of block-like construct. Candidates for use of this abstract class have:
A body that may be enclosed by curly braces
A body containing statements that execute serially
Thus Begin would be a candidate for this class (because while it spawns a new task, the contained statements execute serially), while Cobegin would not because the contained statements each execute in a different task.
Conditional would not be a candidate for this class because its control flow is slightly more complex than “conditionally execute entire block”. This is because the conditional may have an else block.
Subclassed by chpl::uast::Begin, chpl::uast::Block, chpl::uast::Defer, chpl::uast::Local, chpl::uast::On, chpl::uast::Serial, chpl::uast::Sync, chpl::uast::When
Public Functions
-
virtual ~SimpleBlockLike() override = 0¶
-
inline ASTListIteratorPair<Expression> stmts() const¶
Return a way to iterate over the statements.
-
inline const Expression *stmt(int i) const¶
Return the i’th statement in this.
-
inline BlockStyle blockStyle() const¶
Get the block style of this.
-
class StringLikeLiteral : public chpl::uast::Literal¶
- #include <StringLikeLiteral.h>
This is an abstract parent class for string/bytes/c-string literals.
Subclassed by chpl::uast::BytesLiteral, chpl::uast::CStringLiteral, chpl::uast::StringLiteral
Public Types
Public Functions
-
virtual ~StringLikeLiteral() = 0¶
-
inline QuoteStyle quoteStyle() const¶
Returns the type of quotes used for this string literal.
-
virtual ~StringLikeLiteral() = 0¶
-
class StringLiteral : public chpl::uast::StringLikeLiteral¶
- #include <StringLiteral.h>
This class represents a string literal, for example
"hello"
and ‘’ string contents here ‘’’`.Public Functions
-
~StringLiteral() override = default¶
-
inline UniqueString str() const¶
Returns the value of this string literal as a UniqueString which does not include the quotes.
Public Static Functions
-
static owned<StringLiteral> build(Builder *builder, Location loc, const std::string &value, StringLikeLiteral::QuoteStyle quotes)¶
-
~StringLiteral() override = default¶
-
class Sync : public chpl::uast::SimpleBlockLike¶
- #include <Sync.h>
This class represents a sync statement. For example:
// Example 1: proc syncExample() { sync { begin task1(); begin task2(); } writeln("Task 1 and 2 complete"); } syncExample();
This code will wait for both task1 and task2 to complete before printing due to use of the sync block.
Public Functions
-
~Sync() override = default¶
-
~Sync() override = default¶
-
class TaskVar : public chpl::uast::VarLikeDecl¶
- #include <TaskVar.h>
This class represents a task variable. Task variables are declared in with clauses. For example:
var a: atomic int; forall x in 1..15 with (ref a) do a.fetchAdd(x);
Creates a task variable ‘a’ which refers to the outer variable ‘a’ by ref intent.
Public Types
Public Functions
-
~TaskVar() override = default¶
Public Static Functions
-
static owned<TaskVar> build(Builder *builder, Location loc, owned<Attributes> attributes, UniqueString name, TaskVar::Intent intent, owned<Expression> typeExpression, owned<Expression> initExpression)¶
-
~TaskVar() override = default¶
-
class Throw : public chpl::uast::Expression¶
- #include <Throw.h>
This class represents a throw statement. For example:
// Example 1: proc mayThrow() throws { throw new Error(); }
Public Functions
-
inline const Expression *errorExpression() const¶
Return the error expression of this throw statement.
-
inline const Expression *errorExpression() const¶
-
class Try : public chpl::uast::Expression¶
- #include <Try.h>
This class represents a try statement or try expression. For example:
// Example of a try expression: var x = try! foo(); // Example of a try statement: try! { foo(); } catch e: FooError { halt('A FooError occurred'); }
A try statement may contain a number of catch blocks (represented by the Catch uAST node), while a try expression will never contain a catch block.
Public Functions
-
~Try() override = default¶
-
inline ASTListIteratorPair<Expression> stmts() const¶
Iterate over the statements contained in this try.
-
inline const Expression *stmt(int i) const¶
Get the i’th statement in the body of this try.
-
inline ASTListIteratorPair<Catch> handlers() const¶
Iterate over the catch blocks contained in this try.
-
~Try() override = default¶
-
class Tuple : public chpl::uast::Call¶
- #include <Tuple.h>
This class represents a tuple literal. For example:
// Here '(1, 2, 3)' is a tuple literal. var x = (1, 2, 3);
Public Functions
-
~Tuple() override = default¶
-
~Tuple() override = default¶
-
class TupleDecl : public chpl::uast::Decl¶
- #include <TupleDecl.h>
This class represents a tuple variable declaration
E.g.
var (a, b) = (1,2); var (c, _) = (3.0,"hi"); var (d, e) = returnTuple();
Each of the lines above is represented by a MultiDecl containing a list of VariableDecls. Note that the initial value and/or type is inferred from later declarations.
Since the Tuple does not itself have a name, it is not a NamedDecl. Rather, it can contain NamedDecls.
Public Types
Public Functions
-
~TupleDecl() override = default¶
-
inline IntentOrKind intentOrKind() const¶
Returns the intent or kind of the tuple (
var
/in
/param
etc).
-
inline ASTListIteratorPair<Decl> decls() const¶
Return a way to iterate over the contained Decls (which are each Variables or TupleDecls).
-
inline const Expression *typeExpression() const¶
Returns the type expression used in this TupleDecl’s declaration, or nullptr if there wasn’t one.
-
inline const Expression *initExpression() const¶
Returns the init expression used in this TupleDecl’s declaration, or nullptr if there wasn’t one.
Public Static Functions
-
static owned<TupleDecl> build(Builder *builder, Location loc, owned<Attributes> attributes, Decl::Visibility vis, Decl::Linkage linkage, IntentOrKind intentOrKind, ASTList elements, owned<Expression> typeExpression, owned<Expression> initExpression)¶
-
~TupleDecl() override = default¶
-
class TypeDecl : public chpl::uast::NamedDecl¶
- #include <TypeDecl.h>
This is an abstract base class for Symbols defining a type (e.g. classes, records, enums).
Subclassed by chpl::uast::AggregateDecl, chpl::uast::Enum
Public Functions
-
virtual ~TypeDecl() = 0¶
-
virtual ~TypeDecl() = 0¶
-
class TypeQuery : public chpl::uast::Expression¶
- #include <TypeQuery.h>
This class represents a type query.
// Here ?D is a type query which names the domain of A. proc foo(A: [?D] int) { for idx in D do writeln(idx, A[idx]); }
Public Functions
-
~TypeQuery() override = default¶
-
inline UniqueString name() const¶
Returns the name of this type query, e.g. in
proc foo(?x)
, this method would return thex
portion of the type query?x
.
-
~TypeQuery() override = default¶
-
class UintLiteral : public chpl::uast::NumericLiteral<uint64_t, types::UintParam>¶
- #include <UintLiteral.h>
This class represents an unsigned integer literal. It is only used for integers too large to fit into
int64_t
. Such integer literals have typeuint
.Public Functions
-
~UintLiteral() override = default¶
Public Static Functions
-
static owned<UintLiteral> build(Builder *builder, Location loc, uint64_t value, UniqueString text)¶
-
~UintLiteral() override = default¶
-
class Union : public chpl::uast::AggregateDecl¶
- #include <Union.h>
This class represents a union declaration. For example:
union myUnion { var a: int; var b: real; }
The union itself (myUnion) is represented by a Union AST node.
Public Functions
-
~Union() override = default¶
Public Static Functions
-
static owned<Union> build(Builder *builder, Location loc, owned<Attributes> attributes, Decl::Visibility vis, Decl::Linkage linkage, owned<Expression> linkageName, UniqueString name, ASTList contents)¶
-
~Union() override = default¶
-
class Use : public chpl::uast::Expression¶
- #include <Use.h>
This class represents a use statement. For example:
// Example 1: use Foo, Bar as A;
This creates a use statement that has two visibility clauses, ‘Foo’ and ‘Bar as A’.
Public Functions
-
inline Decl::Visibility visibility() const¶
Return the visibility of this use statement.
-
inline ASTListIteratorPair<VisibilityClause> visibilityClauses() const¶
Return a way to iterate over the visibility clauses.
-
inline int numVisibilityClauses() const¶
Return the number of visibility clauses in this use statement.
-
inline const VisibilityClause *visibilityClause(int i) const¶
Return the i’th visibility clause in this use statement.
-
inline Decl::Visibility visibility() const¶
-
class VarArgFormal : public chpl::uast::VarLikeDecl¶
- #include <VarArgFormal.h>
This class represents a varargs formal.
proc f(x: int ...?k) { writeln(x); }
Here
x
is a formal that may take a variable number of actual arguments, the number of which is denoted by the TypeQuery?k
.Public Functions
-
~VarArgFormal() override = default¶
-
inline Formal::Intent intent() const¶
Returns the intent of the varargs formal, e.g. in
proc f(ref x: int ...?k)
, the formalx
has intentref
.
-
inline const Expression *count() const¶
Returns the count expression of the varargs formal, e.g. in
proc f(ref x: int ...?k)
, the count expression is the TypeQuery?k
.If the count expression does not exist then nullptr is returned.
Public Static Functions
-
static owned<VarArgFormal> build(Builder *builder, Location loc, owned<Attributes> attributes, UniqueString name, Formal::Intent intent, owned<Expression> typeExpression, owned<Expression> count)¶
-
~VarArgFormal() override = default¶
-
class Variable : public chpl::uast::VarLikeDecl¶
- #include <Variable.h>
This class represents a variable. For example:
var a = 1; ref b = a; const c = 2; const ref d = c; param e = "hi"; class C { var f: int; }
each of a-f are Variables.
Public Types
Public Functions
-
~Variable() override = default¶
-
inline bool isConfig() const¶
Returns true if this variable is a config variable.
Public Static Functions
-
static owned<Variable> build(Builder *builder, Location loc, owned<Attributes> attributes, Decl::Visibility vis, Decl::Linkage linkage, owned<Expression> linkageName, UniqueString name, Variable::Kind kind, bool isConfig, bool isField, owned<Expression> typeExpression, owned<Expression> initExpression)¶
-
~Variable() override = default¶
-
class VarLikeDecl : public chpl::uast::NamedDecl¶
- #include <VarLikeDecl.h>
This abstract class represents any sort of variable-like declaration. This includes things like fields, formals, or variables.
Subclassed by chpl::uast::Formal, chpl::uast::TaskVar, chpl::uast::VarArgFormal, chpl::uast::Variable
Public Functions
-
virtual ~VarLikeDecl() = 0¶
-
inline IntentList storageKind() const¶
Returns the storage kind (e.g. type, param, in, etc). Subclasses have more specific functions that return the subset appropriate for that subclass.
-
inline const Expression *typeExpression() const¶
Returns the type expression used in this VarLikeDecl’s declaration, or nullptr if there wasn’t one.
-
inline const Expression *initExpression() const¶
Returns the init expression used in this VarLikeDecl’s declaration, or nullptr if there wasn’t one.
-
virtual ~VarLikeDecl() = 0¶
-
class VisibilityClause : public chpl::uast::Expression¶
- #include <VisibilityClause.h>
This class represents a visibility clause. Visibility clauses make up the contents of Use and Import statements. For example:
// This contains two visibility clauses, 'Foo as X' and 'Baz as Y'. use Foo as X, Baz as Y; // This contains one visibility clause, 'Baz as Z'. import Baz as Z;
Public Types
-
enum LimitationKind¶
These values represent the kind of limitations possessed by a visibility clause. Visibility clauses within use statements may have limitations of kind ‘EXCEPT’, ‘ONLY’, or ‘NONE’. Those within import statements may have have limitations of kind ‘BRACES’ or ‘NONE’.
If the limitation kind is ‘NONE’, then the visibility clause should have no limitations. If the kind is ‘BRACES’ or ‘EXCEPT’, then the visibility clause should have one or more limitations. If the kind is ‘ONLY’, then it may have zero or more limitations.
Values:
-
enumerator BRACES¶
-
enumerator EXCEPT¶
-
enumerator ONLY¶
-
enumerator NONE¶
-
enumerator BRACES¶
Public Functions
-
~VisibilityClause() override = default¶
-
inline const Expression *symbol() const¶
Get the symbol of this visibility clause. It may be a Dot, As, or Identifier.
-
inline LimitationKind limitationKind() const¶
Return the kind of limitations contained by this visibility clause.
-
inline ASTListIteratorPair<Expression> limitations() const¶
Return a way to iterate over the limitations of this visibility clause.
-
inline int numLimitations() const¶
Return the number of limitations contained in this visibility clause.
-
inline const Expression *limitation(int i) const¶
Return the i’th limitation of this visibility clause. If the limitation kind is ‘EXCEPT’, then the limitations will all be Identifier. If the limitation kind is ‘ONLY’ or ‘BRACES’, then the limitations may be Identifer or As expressions.
Public Static Functions
-
static owned<VisibilityClause> build(Builder *builder, Location loc, owned<Expression> symbol)¶
Create and return a visibility clause.
-
static owned<VisibilityClause> build(Builder *builder, Location loc, owned<Expression> symbol, LimitationKind limitationKind, ASTList limitations)¶
Create and return a visibility clause.
-
enum LimitationKind¶
-
class When : public chpl::uast::SimpleBlockLike¶
- #include <When.h>
This class represents a when statement. When statements make up the body of the select statement.
Public Functions
-
inline int numCaseExprs() const¶
Returns the number of case expressions for this when statement.
-
inline const Expression *caseExpr(int i) const¶
Returns the i’th case of this when statement.
-
inline ASTListIteratorPair<Expression> caseExprs() const¶
Return a way to iterate over the cases of this when statement.
-
inline bool isOtherwise() const¶
Returns true if this when statement uses the otherwise keyword.
Public Static Functions
-
static owned<When> build(Builder *builder, Location loc, ASTList caseExprs, BlockStyle blockStyle, ASTList stmts)¶
Create and return a when statement. If ‘caseExprs’ is empty then ‘isOtherwise()’ will evaluate to true.
-
inline int numCaseExprs() const¶
-
class While : public chpl::uast::Loop¶
- #include <While.h>
This class represents a while loop. For example:
// Example 1: var i = 0; while i < 5 { writeln(i); i += 1; }
Public Functions
-
~While() override = default¶
-
inline const Expression *condition() const¶
Return the condition of this while loop.
Public Static Functions
-
static owned<While> build(Builder *builder, Location loc, owned<Expression> condition, BlockStyle blockStyle, owned<Block> stmts)¶
Create and return a while loop.
-
~While() override = default¶
-
class WithClause : public chpl::uast::Expression¶
- #include <WithClause.h>
This class represents a with clause. For example:
// Example 1: forall myRange with (var x = 0) { writeln(x); }
Creates a forall loop that has a with clause which declares a single task variable named ‘x’.
Public Functions
-
inline ASTListIteratorPair<Expression> exprs() const¶
Return a way to iterate over the expressions of this with clause.
-
inline const Expression *expr(int i) const¶
Return the i’th expression in this with clause.
-
inline ASTListIteratorPair<Expression> exprs() const¶
-
class Yield : public chpl::uast::Expression¶
- #include <Yield.h>
This class represents a yield statement. For example:
// Example 1: iter foo(): int { for i in range 0..15 do yield i; }
Public Functions
-
~Yield() override = default¶
-
inline const Expression *value() const¶
Returns the value of this yield statement.
-
~Yield() override = default¶
-
class Zip : public chpl::uast::Call¶
- #include <Zip.h>
This class represents a zip expression.
Public Functions
-
~Zip() override = default¶
-
~Zip() override = default¶
-
namespace asttags¶
Enums
-
namespace pragmatags¶
-
namespace primtags¶
Enums
Functions
-
const char *primTagToName(PrimitiveTag tag)¶
Return the string name associated with a PrimitiveTag
-
PrimitiveTag primNameToTag(const char *name)¶
Return the PrimitiveTag associated with a const char*
-
const char *primTagToName(PrimitiveTag tag)¶
-
enum BlockStyle¶