Untyped AST (uAST)

This section contains definitions declared in the chpl::uast namespace.

namespace chpl::uast

Typedefs

using AstList = std::vector<owned<AstNode>>

AstList is just a list that owns some AST nodes.

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
enum IntentList

A centralized list containing all intent and storage specifiers.

Values:

enumerator UNKNOWN

Represents an unknown intent / variable type. This is only used within the compiler.

enumerator DEFAULT_INTENT

Represents the default intent for a type

enumerator CONST_INTENT

Represents a const in / const ref depending on the type

enumerator VAR

Represents a mutable variable declared with ‘var’

enumerator CONST_VAR

Represents a variable declared with ‘const’ which means that the variable is immutable for its lifetime (but note: contained pointers can still point to mutable memory).

enumerator CONST_REF

Represents a const reference - the pointed-to value can’t be changed through this reference (but it could be changed by code referring to it in another way).

enumerator REF

Represents a mutable reference - the pointed-to value can be changed through this reference.

enumerator IN

Represents an ‘in’ intent formal that is a mutable value

enumerator CONST_IN

Represents an ‘const in’ intent formal that is an immutable value

enumerator OUT

Represents an ‘out’ intent formal that is mutable

enumerator INOUT

Represents an ‘inout’ intent formal that is mutable

enumerator PARAM

A ‘param’ variable or formal

enumerator TYPE

A ‘type’ variable or formal

enumerator TYPE_QUERY

A type query (e.g. ?t in proc f(arg: ?t))

enumerator INDEX

A loop index variable

enumerator FUNCTION

A function

enumerator PARENLESS_FUNCTION

A parenless function

enumerator MODULE

A module

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 kind of 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’.

void markAstList(Context *context, const AstList &keep)

Mark UniqueStrings in an AST list.

bool isQuestionMark(const AstNode *node)
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<AstNode> 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 AstNode *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)

class Array : public chpl::uast::AstNode
#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<AstNode> exprs() const

Return a way to iterate over the expressions of this array.

inline int numExprs() const

Return the number of expressions in this array.

inline const AstNode *expr(int i) const

Return the i’th expression in this array.

Public Static Functions

static owned<Array> build(Builder *builder, Location loc, AstList exprs)

Create and return an Array expression.

class As : public chpl::uast::AstNode
#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 AstNode *symbol() const

Return the original name specified by this as expression.

inline const AstNode *rename() const

Return the rename specified by this as expression.

Public Static Functions

static owned<As> build(Builder *builder, Location loc, owned<AstNode> symbol, owned<AstNode> rename)

Create and return an as expression.

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 difference_type = AstList::const_iterator::difference_type
using pointer = const CastToType**
using reference = const CastToType*&

Public Functions

AstListIterator() = default
inline explicit AstListIterator(AstList::const_iterator it)
~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)
template<typename CastToType>
struct AstListIteratorPair

Public Functions

inline AstListIteratorPair(AstList::const_iterator begin, AstList::const_iterator end)
~AstListIteratorPair() = default
inline AstListIterator<CastToType> begin() const
inline AstListIterator<CastToType> end() const
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 difference_type = AstList::const_iterator::difference_type
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
template<typename CastToType>
struct AstListNoCommentsIteratorPair

Public Functions

inline AstListNoCommentsIteratorPair(AstList::const_iterator begin, AstList::const_iterator end)
~AstListNoCommentsIteratorPair() = default
inline AstListNoCommentsIterator<CastToType> begin() const
inline AstListNoCommentsIterator<CastToType> end() const
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::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::EmptyStmt, chpl::uast::ErroneousExpression, chpl::uast::ExternBlock, chpl::uast::Identifier, chpl::uast::Implements, chpl::uast::Import, chpl::uast::Include, chpl::uast::Label, chpl::uast::Let, chpl::uast::Literal, chpl::uast::Loop, chpl::uast::New, chpl::uast::Range, chpl::uast::Require, chpl::uast::Return, chpl::uast::Select, chpl::uast::SimpleBlockLike, chpl::uast::Throw, chpl::uast::Try, chpl::uast::Use, chpl::uast::VisibilityClause, chpl::uast::WithClause, chpl::uast::Yield

Public Functions

virtual ~AstNode() = 0
inline AstTag tag() const

Returns the tag indicating which AstNode subclass this is.

inline ID id() const

Returns the ID of this AST node.

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.

bool shallowMatch(const AstNode *other) const
bool completeMatch(const AstNode *other) const
void mark(Context *context) const
void stringify(std::ostream &ss, chpl::StringifyKind stringKind) const
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::AstNode* 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::AstNode* ast); void MyTraverser::exit(const uast::AstNode* 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);

Public Static Functions

static bool mayContainStatements(AstTag tag)

Returns ‘true’ if the passed type of AST node can contain statements, transitively.

static bool update(owned<AstNode> &keep, owned<AstNode> &addin)
class Attributes : public chpl::uast::AstNode
#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 Types

using PragmaIterable = Iterable<std::set<PragmaTag>>

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 bool isUnstable() const

Returns true if the declaration associated with this attribute is unstable.

inline UniqueString deprecationMessage() const

Returns a deprecation message, or the empty string if it is not set.

inline UniqueString unstableMessage() const

Returns an unstable 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, bool isUnstable, UniqueString deprecationMessage, UniqueString unstableMessage)
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.

class Block : public chpl::uast::SimpleBlockLike
#include <Block.h>

This class represents a { } block.

Public Functions

~Block() override = default

Public Static Functions

static owned<Block> build(Builder *builder, Location loc, AstList stmts)

Create and return a Block containing the passed stmts.

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.

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<AstNode> iterand, owned<WithClause> withClause, BlockStyle blockStyle, owned<Block> body, bool isExpressionLevel)

Create and return a bracket loop.

class Break : public chpl::uast::AstNode
#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.

Public Static Functions

static owned<Break> build(Builder *builder, Location loc, owned<Identifier> target)

Create and return a break statement.

class Builder
#include <Builder.h>

This class helps to build AST. It should only build AST from one file at a time.

Public Functions

inline Context *context() const
void addToplevelExpression(owned<AstNode> e)

Save a toplevel expression in to the builder. This is called by the parser.

void addError(ErrorMessage)

Save an error.

void noteLocation(AstNode *ast, Location loc)

Record the location of an AST element.

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

static owned<Builder> createForTopLevelModule(Context *context, const char *filepath)

Construct a Builder for parsing a top-level module

static owned<Builder> createForIncludedModule(Context *context, const char *filepath, UniqueString parentSymbolPath)

Construct a Builder for parsing an included module. ‘parentSymbolPath’ is the symbol path component of the ID of the module containing the ‘module include’ statement.

static bool astTagIndicatesNewIdScope(asttags::AstTag tag)

Certain uAST nodes, - Function, Module, Class, Record, Union, Enum - all create a new ID scope. This function returns true for AST tags with this property.

static std::string filenameToModulename(const char *filename)

Compute the module name based on a file name.

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 const AstNode *topLevelExpression(int i) const

return the i’th top-level expression

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.

Location commentToLocation(const Comment *comment) const

Find the Location for a particular comment. The Comment must have been from this BuilderResult, but this is not checked. An empty Location will be returned if the Comment couldn’t be 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)
void mark(Context *context) const

Public Static Functions

static bool update(BuilderResult &keep, BuilderResult &addin)
static void updateFilePaths(Context *context, const BuilderResult &keep)
static void appendError(BuilderResult &keep, const ErrorMessage &error)
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)
class Call : public chpl::uast::AstNode
#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 and 1, 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<AstNode> actuals() const

Returns an iterable expression over the actuals of a call.

inline int numActuals() const
inline const AstNode *actual(int i) const
inline const AstNode *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.

class Catch : public chpl::uast::AstNode
#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 const Block *body() const

Return the block containing the body of this catch.

inline AstListIteratorPair<AstNode> stmts() const

Iterate over the statements contained in the body of this catch.

inline int numStmts() const

Return the number of statements contained in the body of this catch.

inline const AstNode *stmt(int i) const

Return the i’th statement contained in the body of this catch.

inline bool hasParensAroundError() const

Return true if the error of this catch block has parens arounds its declaration.

Public Static Functions

static owned<Catch> build(Builder *builder, Location loc, owned<Variable> error, owned<Block> body, bool hasParensAroundError)

Create and return a catch.

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 AstNode *parentClass() const

Return the AstNode 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<AstNode> parentClass, AstList contents)
class Cobegin : public chpl::uast::AstNode
#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<AstNode> taskBodies() const

Return a way to iterate over the task bodies.

inline int numTaskBodies() const

Return the number of task bodies in this.

inline const AstNode *taskBody(int i) const

Return the i’th task body in this.

Public Static Functions

static owned<Cobegin> build(Builder *builder, Location loc, owned<WithClause> withClause, AstList taskBodies)

Create and return a cobegin statement.

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<AstNode> iterand, owned<WithClause> withClause, BlockStyle blockStyle, owned<Block> body)

Create and return a coforall loop.

class Comment : public chpl::uast::AstNode
#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.

inline CommentID commentId() const

Returns the id of this comment, which is unique in its BuilderResult

Public Static Functions

static owned<Comment> build(Builder *builder, Location loc, std::string c)
class Conditional : public chpl::uast::AstNode
#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 AstNode *condition() const

Get the condition of this conditional.

inline const Block *thenBlock() const

Return the Block containing the then statements.

inline AstListIteratorPair<AstNode> 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 AstNode *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<AstNode> 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 AstNode *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.

inline bool isExpressionLevel() const

Return true if this conditional is at an expression level.

Public Static Functions

static owned<Conditional> build(Builder *builder, Location loc, owned<AstNode> 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<AstNode> condition, BlockStyle thenBlockStyle, owned<Block> thenBlock, bool isExpressionLevel)

Create and return a conditional without an else block.

class Continue : public chpl::uast::AstNode
#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.

Public Static Functions

static owned<Continue> build(Builder *builder, Location loc, owned<Identifier> target)

Create and return a continue statement.

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)
class Decl : public chpl::uast::AstNode
#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

enum Visibility

Values:

enumerator DEFAULT_VISIBILITY
enumerator PUBLIC
enumerator PRIVATE
enum Linkage

Values:

enumerator DEFAULT_LINKAGE
enumerator EXTERN
enumerator EXPORT

Public Functions

virtual ~Decl() = 0
inline Visibility visibility() const

Return the visibility of this declaration, e.g. “PUBLIC” or “PRIVATE”.

inline Linkage linkage() const

Return the linkage of this declaration, e.g. “EXTERN” or “EXPORT”.

inline const AstNode *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.

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

Public Static Functions

static owned<Defer> build(Builder *builder, Location loc, BlockStyle blockStyle, AstList stmts)

Create and return a Defer containing the passed stmts.

class Delete : public chpl::uast::AstNode
#include <Delete.h>

This class represents a delete statement. For example:

// Example 1:
var c = new unmanaged C();
delete c;

Public Functions

inline AstListIteratorPair<AstNode> exprs() const

Return a way to iterate over the expressions of this delete statement.

inline int numExprs() const

Return the number of expressions in this delete statement.

inline const AstNode *expr(int i) const

Return the i’th expression in this delete statement.

Public Static Functions

static owned<Delete> build(Builder *builder, Location loc, AstList exprs)

Create and return a delete statement.

class Domain : public chpl::uast::AstNode
#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<AstNode> exprs() const

Return a way to iterate over the expressions of this domain.

inline int numExprs() const

Return the number of expressions in this domain.

inline const AstNode *expr(int i) const

Return the i’th expression in this domain.

inline bool usedCurlyBraces() const

Return ‘true’ if this domain was constructed with curly braces.

Public Static Functions

static owned<Domain> build(Builder *builder, Location loc, bool usedCurlyBraces, AstList exprs)

Create and return a Domain expression.

class Dot : public chpl::uast::AstNode
#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(), or x.f(a=3). These are method calls that also involve Dot expressions. These are represented as an FnCall containing a Dot expression. For example, for x.f(a=3), it is represented as

FnCall(calledExpression=x.f, actuals=[3], names=[a]);

where the x.f is a Dot expression.

Public Functions

~Dot() override = default
inline const AstNode *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<AstNode> receiver, UniqueString fieldName)
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 AstNode *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<AstNode> condition)

Create and return a do-while loop.

class EmptyStmt : public chpl::uast::AstNode
#include <EmptyStmt.h>

This class represents an empty statement For example:

;

The single semicolon, ;, represents an empty statement

Public Functions

~EmptyStmt() override = default

Public Static Functions

static owned<EmptyStmt> build(Builder *builder, Location loc)

Create an EmptyStmt at this location.

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<AstNode> 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 AstNode *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)
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 AstNode *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<AstNode> initExpression)
static owned<EnumElement> build(Builder *builder, Location loc, owned<Attributes> attributes, UniqueString name)
class ErroneousExpression : public chpl::uast::AstNode
#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)
class ExternBlock : public chpl::uast::AstNode
#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 Functions

~ExternBlock() override = default
inline const std::string &code() const

Public Static Functions

static owned<ExternBlock> build(Builder *builder, Location loc, std::string code)

Create and return an ExternBlock with the given C 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 function f.

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<AstNode> calledExpression, AstList actuals, std::vector<UniqueString> actualNames, bool callUsedSquareBrackets)
static owned<FnCall> build(Builder *builder, Location loc, owned<AstNode> calledExpression, AstList actuals, bool callUsedSquareBrackets)
static owned<FnCall> build(Builder *builder, Location loc, owned<AstNode> calledExpression, bool callUsedSquareBrackets)
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;
}

Public Functions

~For() override = default
inline bool isParam() const

Returns true if this for loop is param.

Public Static Functions

static owned<For> build(Builder *builder, Location loc, owned<Decl> index, owned<AstNode> iterand, BlockStyle blockStyle, owned<Block> body, bool isExpressionLevel, bool isParam)

Create and return a for loop.

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<AstNode> iterand, owned<WithClause> withClause, BlockStyle blockStyle, owned<Block> body, bool isExpressionLevel)

Create and return a forall loop.

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<AstNode> iterand, owned<WithClause> withClause, BlockStyle blockStyle, owned<Block> body)

Create and return a foreach loop.

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

enum Intent

Values:

enumerator DEFAULT_INTENT
enumerator CONST
enumerator CONST_REF
enumerator REF
enumerator IN
enumerator CONST_IN
enumerator OUT
enumerator INOUT
enumerator PARAM
enumerator TYPE

Public Functions

~Formal() override = default
inline Intent intent() const

Returns the intent of the formal, e.g. in proc f(const ref y: int), the formal y has intent const ref.

Public Static Functions

static owned<Formal> build(Builder *builder, Location loc, owned<Attributes> attributes, UniqueString name, Formal::Intent intent, owned<AstNode> typeExpression, owned<AstNode> initExpression)
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 AstNode *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<AstNode> expr)
static owned<ForwardingDecl> build(Builder *builder, Location loc, owned<Attributes> attributes, owned<AstNode> expr, Decl::Visibility visibility)
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

enum Kind

Values:

enumerator PROC
enumerator ITER
enumerator OPERATOR
enumerator LAMBDA
enum ReturnIntent

Values:

enumerator DEFAULT_RETURN_INTENT
enumerator CONST
enumerator CONST_REF
enumerator REF
enumerator PARAM
enumerator TYPE

Public Functions

~Function() override = default
inline Kind kind() const
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 int numFormals() const

Return the number of Formals

inline const Decl *formal(int i) const

Return the i’th formal

inline const Formal *thisFormal() const

Returns the Formal for the ‘this’ formal argument, or ‘nullptr’ if there is none.

inline bool isMethod() const

Returns ‘true’ if this Function represents a method.

inline const AstNode *returnType() const

Returns the expression for the return type or nullptr if there was none.

inline const AstNode *whereClause() const

Returns the expression for the where clause or nullptr if there was none.

inline AstListIteratorPair<AstNode> lifetimeClauses() const

Return a way to iterate over the lifetime clauses.

inline int numLifetimeClauses() const

Return the number of lifetime clauses

inline const AstNode *lifetimeClause(int i) const

Return the i’th lifetime clause

inline const Block *body() const

Return the function’s body, or nullptr if there is none.

inline AstListIteratorPair<AstNode> 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 AstNode *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<AstNode> 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<AstNode> returnType, owned<AstNode> where, AstList lifetime, owned<Block> body)
class Identifier : public chpl::uast::AstNode
#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 Functions

~Identifier() override = default
inline UniqueString name() const

Public Static Functions

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)
class Implements : public chpl::uast::AstNode
#include <Implements.h>

This class represents an ‘implements’ statement or expression.

For example:

T implements Foo(A, B);

Is an implements statement which states that type ‘T’ implements the interface ‘Foo(A, B)’.

Public Functions

~Implements() override = default
inline const Identifier *typeIdent() const

Returns an Identifier naming the type this implements is for. May return nullptr.

For the following:

T implements Foo(A, B);

This method returns the identifier storing ‘T’.

inline bool isExpressionLevel() const

Returns true if this implements statement is at an expression level.

UniqueString interfaceName() const

Returns the name of the interface this is implementing.

For the following:

T implements Foo(A, B);
T implements Bar;

This method returns ‘Foo’ and ‘Bar’, respectively.

inline const AstNode *interfaceExpr() const

Returns the interface expression. This method may return either an Identifier or a FnCall.

For the following:

T implements Foo(A, B);
T implements Bar;

This method returns the FnCall ‘Foo(A, B)’ or the Identifier ‘Bar’, respectively.

Public Static Functions

static owned<Implements> build(Builder *builder, Location loc, owned<Identifier> typeIdent, owned<AstNode> interfaceExpr, bool isExpressionLevel)
class Import : public chpl::uast::AstNode
#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.

Public Static Functions

static owned<Import> build(Builder *builder, Location loc, Decl::Visibility visibility, AstList visibilityClauses)

Create and return an import statement.

class Include : public chpl::uast::AstNode
#include <Include.h>

This class represents an include statement. For example:

module Foo {
  // Example 1:
  include private module Memory;
}

Includes the contents of the module Memory so that they are privately visible within the module Foo.

Public Functions

inline Decl::Visibility visibility() const

Return the visibility of this include statement.

inline bool isPrototype() const

Returns ‘true’ if this include statement is for a prototype module.

inline UniqueString name() const

Return the name of the module included by this include statement.

Public Static Functions

static owned<Include> build(Builder *builder, Location loc, Decl::Visibility visibility, bool isPrototype, UniqueString name)

Create and return an include statement.

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 AstNode *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.

class Interface : public chpl::uast::NamedDecl
#include <Interface.h>

This class represents an interface.

interface example(T) {
  operator ==(a: T, b: T): bool;
}

Creates an interface named ‘example’ with one interface formal named ‘T’. The interface body contains one required function named ‘==’.

Public Functions

~Interface() override = default
inline bool isFormalListPresent() const

Returns ‘true’ if this interface has a formal list.

For the following:

interface example(T) {
  operator ==(a: T, b: T): bool;
}

The formal list ‘(T)’ is present, so this method returns ‘true’.

inline AstListIteratorPair<AstNode> formals() const

Iterate over the formals in the formal list.

inline int numFormals() const

Return the number of interface formals. For the following:

interface example(T) {
  operator ==(a: T, b: T): bool;
}

This method would return ‘1’.

inline const AstNode *formal(int i) const

Return the i’th interface formal.

inline AstListIteratorPair<AstNode> stmts() const

Iterate over the statements in the body of this interface.

inline int numStmts() const

Return the number of statements in the body of this interface.

inline const AstNode *stmt(int i) const

Get the i’th statement in the body of this interface.

Public Static Functions

static owned<Interface> build(Builder *builder, Location loc, owned<Attributes> attributes, Decl::Visibility visibility, UniqueString name, bool isFormalListPresent, AstList formals, AstList body)
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)
class Label : public chpl::uast::AstNode
#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 const Loop *loop() const

Return the loop of this label statement.

inline UniqueString name() const

Return the name of this label statement.

Public Static Functions

static owned<Label> build(Builder *builder, Location loc, UniqueString name, owned<Loop> loop)

Create and return a label statement.

class Let : public chpl::uast::AstNode
#include <Let.h>

This class represents a let statement. For example:

// Example 1:
let x = 0 in writeln(x);

Public Functions

~Let() override = default
inline AstListIteratorPair<Decl> decls() const

Iterate over the declarations in this let statement.

inline int numDecls() const

Return the number of declarations in this let statement.

inline const Decl *decl(int i) const

Return the i’th declaration in this let statement.

inline const AstNode *expression() const

Return the expression of this let statement.

Public Static Functions

static owned<Let> build(Builder *builder, Location loc, AstList decls, owned<AstNode> expression)

Create a Let containing the passed declarations and expression.

class Literal : public chpl::uast::AstNode
#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 >

Public Functions

virtual ~Literal() = 0
inline const types::Param *param() const

Returns the value stored in this Literal as a types::Param.

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 AstNode *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<AstNode> condition, BlockStyle blockStyle, AstList stmts)

Create and return a local statement with the given condition and containing the passed statements.

class Loop : public chpl::uast::AstNode
#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 const Block *body() const

Returns the block containing the body of this loop.

inline AstListIteratorPair<AstNode> stmts() const

Return a way to iterate over the statements of this loop.

inline int numStmts() const

Return the number of statements in the loop.

inline const AstNode *stmt(int i) const

Return the i’th statement in the loop.

inline BlockStyle blockStyle() const

Returns the block style of the current loop.

class Manage : public chpl::uast::SimpleBlockLike
#include <Manage.h>

This class represents a manage statement. For example:

// Example 1:
manage myManager as res do writeln(res);

This code will manage ‘myManager’, which returns a handle to a resource that can be referred to as ‘res’.

Public Functions

~Manage() override = default
inline AstListIteratorPair<AstNode> managers() const

Iterate over the managers of this manage statement. They may be either expressions or ‘As’ expressions. If a manager is an ‘As’ expression, the right-hand-side component is guaranteed to be a variable representing the managed resource.

inline int numManagers() const

Return the number of managers in this manage statement.

inline const AstNode *manager(int i) const

Return the i’th manager in this manage statement.

Public Static Functions

static owned<Manage> build(Builder *builder, Location loc, AstList managers, BlockStyle blockStyle, AstList stmts)

Create and return a Manage containing the passed managers and statements.

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

enum Kind

Values:

enumerator DEFAULT_MODULE_KIND
enumerator PROTOTYPE
enumerator IMPLICIT

Public Functions

~Module() override = default
inline Kind kind() const

Return the kind of this module (e.g. ‘PROTOTYPE’ or ‘IMPLICIT’);

inline AstListIteratorPair<AstNode> stmts() const

Iterate over the statements in this module.

inline int numStmts() const

Return the number of statements in this module.

inline const AstNode *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)
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<AstNode> declOrComments() const

Return a way to iterate over the contained VariableDecls and Comments.

inline int numDeclOrComments() const

Return the number of VariableDecls and Comments contained.

inline const AstNode *declOrComment(int i) const

Return the i’th contained VariableDecl or Comment.

inline AstListNoCommentsIteratorPair<Decl> decls() const

Return a way to iterate over the contained Decls (ignoring Comments)

Public Static Functions

static owned<MultiDecl> build(Builder *builder, Location loc, owned<Attributes> attributes, Decl::Visibility vis, Decl::Linkage linkage, AstList varDecls)
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::Interface, chpl::uast::Module, chpl::uast::ReduceIntent, chpl::uast::TypeDecl, chpl::uast::TypeQuery, chpl::uast::VarLikeDecl

Public Functions

virtual ~NamedDecl() = 0
inline UniqueString name() const
class New : public chpl::uast::AstNode
#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

enum Management

Possible management flavors for a new expression.

Values:

enumerator DEFAULT_MANAGEMENT
enumerator BORROWED
enumerator OWNED
enumerator SHARED
enumerator UNMANAGED

Public Functions

inline const AstNode *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 const char *managementToString(Management management)

Given a management style, return the Chapel keyword representing it.

static Management stringToManagement(UniqueString ustr)

Given a string, return a management style, or ‘DEFAULT_MANAGEMENT’ if there was not a match.

static owned<New> build(Builder *builder, Location loc, owned<AstNode> typeExpression, Management management)

Create and return a new expression with the given type expression and management style.

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)

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 AstNode *destination() const

Returns the destination of this on statement.

Public Static Functions

static owned<On> build(Builder *builder, Location loc, owned<AstNode> destination, BlockStyle blockStyle, AstList stmts)

Create and return an on statement.

class OpCall : public chpl::uast::Call
#include <OpCall.h>

This class represents a call to an operator.

For example a + b and x = 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<AstNode> lhs, owned<AstNode> rhs)
static owned<OpCall> build(Builder *builder, Location loc, UniqueString op, owned<AstNode> expr)
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)

Public Functions

~PrimCall() override = default
inline PrimitiveTag prim() const

Returns the enum value of the primitive called

Public Static Functions

static owned<PrimCall> build(Builder *builder, Location loc, PrimitiveTag prim, AstList actuals)
class Range : public chpl::uast::AstNode
#include <Range.h>

This class represents a range expression. For example:

// Example 1:
var r = 0..15;

Public Types

enum OpKind

Values:

enumerator DEFAULT
enumerator OPEN_HIGH

Public Functions

~Range() override = default
inline OpKind opKind() const

Returns the operator kind used to construct this range.

inline const AstNode *lowerBound() const

Returns the lower bound of this range, or nullptr if there is none.

inline const AstNode *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<AstNode> lowerBound, owned<AstNode> upperBound)

Create and return a range expression.

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, and 3e24.

Public Functions

~RealLiteral() override = default

Public Static Functions

static owned<RealLiteral> build(Builder *builder, Location loc, double value, UniqueString text)
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<AstNode> linkageName, UniqueString name, AstList contents)
class Reduce : public chpl::uast::Call
#include <Reduce.h>

This class represents a reduction.

// Example 1:
var eltAvg = (+ reduce A) / size**2;

Where + is the op

Also supported are reduce intents

// Example 2:
forall elm in A with (PlusReduceOp(int) reduce sum) {
  sum reduce= elm;   // bools are implicitly coerced to 'int' input type
  writeln(sum);      // accumulation state: int
}

Where PlusReduceOp(int) is a FnCall with PlusReduceOp as the op and int is the input type

}

Public Functions

~Reduce() override = default
inline const AstNode *op() const

Returns the reduce op expression, e.g. minmax(int) in the expression minmax(int) reduce sum.

inline const AstNode *iterand() const

Returns the iterand of the reduction, e,g., sum in the expression minmax(int) reduce sum.

Public Static Functions

static owned<Reduce> build(Builder *builder, Location loc, owned<AstNode> op, owned<AstNode> iterand)

Create and return a reduction.

class ReduceIntent : public chpl::uast::NamedDecl
#include <ReduceIntent.h>

This class represents a reduce intent.

// Example 1:
var sum = 0;
forall elm in A with (PlusReduceOp(int) reduce sum) {
  sum reduce= elm;   // bools are implicitly coerced to 'int' input type
  writeln(sum);      // accumulation state: int
}

Where PlusReduceOp(int) is a FnCall with PlusReduceOp as the op and int is the input type

}

Public Functions

~ReduceIntent() override = default
inline const AstNode *op() const

Returns the reduce op expression, e.g. minmax(int) in the expression minmax(int) reduce sum.

Public Static Functions

static owned<ReduceIntent> build(Builder *builder, Location loc, owned<AstNode> op, UniqueString name)

Create and return a reduction.

class Require : public chpl::uast::AstNode
#include <Require.h>

This class represents a require statement.

// 'Require' tells the compiler where to look for C functions:
require "foo.h", "foo.c";

Public Functions

~Require() override = default
inline AstListIteratorPair<AstNode> exprs() const

Return a way to iterate over the expressions of this require statement.

inline int numExprs() const

Return the number of expressions in this require statement.

inline const AstNode *expr(int i) const

Return the i’th expression in this require statement.

Public Static Functions

static owned<Require> build(Builder *builder, Location loc, AstList exprs)

Create and return a require statement.

class Return : public chpl::uast::AstNode
#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 AstNode *value() const

Returns the value of this return statement, or nullptr if there is none.

Public Static Functions

static owned<Return> build(Builder *builder, Location loc, owned<AstNode> value)

Create and return a return statement. If value is nullptr, then there is no return value.

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 const AstNode *op() const

Returns the scan op expression, e.g., + in the expression + scan A.

inline const AstNode *iterand() const

Returns the iterand of the scan, e.g., ‘A’ in the expression + scan A.

Public Static Functions

static owned<Scan> build(Builder *builder, Location loc, owned<AstNode> op, owned<AstNode> iterand)

Create and return a scan.

class Select : public chpl::uast::AstNode
#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 AstNode *expr() const

Returns the expression of this select statement.

inline int numWhenStmts() const

Returns the number of when statements in this select statement.

inline const When *whenStmt(int i) const

Return the i’th when statement in this select statement.

inline AstListIteratorPair<When> whenStmts() const

Iterate over the when statements in this select statement.

Public Static Functions

static owned<Select> build(Builder *builder, Location loc, owned<AstNode> expr, AstList whenStmts)

Create and return a select statement.

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 AstNode *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<AstNode> condition, BlockStyle blockStyle, AstList stmts)

Create and return a serial statement with the given condition and containing the passed statements.

class SimpleBlockLike : public chpl::uast::AstNode
#include <SimpleBlockLike.h>

This class represents any sort of block-like construct. Candidates for use of this abstract class have:

  • Simple-to-no (e.g. Local, or Block) control flow

  • 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::Manage, chpl::uast::On, chpl::uast::Serial, chpl::uast::Sync, chpl::uast::When

Public Functions

virtual ~SimpleBlockLike() override = 0
inline AstListIteratorPair<AstNode> stmts() const

Return a way to iterate over the statements.

inline int numStmts() const

Return the number of statements in this.

inline const AstNode *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

enum QuoteStyle

Values:

enumerator SINGLE
enumerator DOUBLE
enumerator TRIPLE_SINGLE
enumerator TRIPLE_DOUBLE

Public Functions

virtual ~StringLikeLiteral() = 0
inline QuoteStyle quoteStyle() const

Returns the type of quotes used for this string literal.

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)
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

Public Static Functions

static owned<Sync> build(Builder *builder, Location loc, BlockStyle blockStyle, AstList stmts)

Create and return a Sync containing the passed stmts.

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

enum Intent

Values:

enumerator VAR
enumerator CONST
enumerator CONST_REF
enumerator REF
enumerator IN
enumerator CONST_IN

Public Functions

~TaskVar() override = default
inline Intent intent() const

Returns the intent of this task variable.

Public Static Functions

static owned<TaskVar> build(Builder *builder, Location loc, owned<Attributes> attributes, UniqueString name, TaskVar::Intent intent, owned<AstNode> typeExpression, owned<AstNode> initExpression)
class Throw : public chpl::uast::AstNode
#include <Throw.h>

This class represents a throw statement. For example:

// Example 1:
proc mayThrow() throws {
  throw new Error();
}

Public Functions

inline const AstNode *errorExpression() const

Return the error expression of this throw statement.

Public Static Functions

static owned<Throw> build(Builder *builder, Location loc, owned<AstNode> expr)

Create and return a throw statement.

class Try : public chpl::uast::AstNode
#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<AstNode> stmts() const

Iterate over the statements contained in this try.

inline int numStmts() const

Return the number of statements contained in this try.

inline const AstNode *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.

inline int numHandlers() const

Return the number of catch blocks contained in this try.

inline const Catch *handler(int i) const

Return the i’th catch block contained in this try.

inline bool isExpressionLevel() const

Return true if this try is at an expression level.

inline bool isTryBang() const

Return true if this try should halt when an error is not handled.

Public Static Functions

static owned<Try> build(Builder *builder, Location loc, AstList stmts, AstList catches, bool isTryBang)

Create and return a try statement.

static owned<Try> build(Builder *builder, Location loc, owned<AstNode> expr, bool isTryBang, bool isExpressionLevel)

Create and return a try expression.

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

Public Static Functions

static owned<Tuple> build(Builder *builder, Location loc, AstList exprs)

Create and return a tuple.

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 TupleDecl 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

enum IntentOrKind

Values:

enumerator DEFAULT_INTENT
enumerator CONST_INTENT
enumerator VAR
enumerator CONST_VAR
enumerator CONST_REF
enumerator REF
enumerator IN
enumerator CONST_IN
enumerator OUT
enumerator INOUT
enumerator INDEX
enumerator PARAM
enumerator TYPE

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 int numDecls() const

Return the number of Decls contained within this TupleDecl.

inline const Decl *decl(int i) const

Return the i’th contained Decl.

inline const AstNode *typeExpression() const

Returns the type expression used in this TupleDecl’s declaration, or nullptr if there wasn’t one.

inline const AstNode *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<AstNode> typeExpression, owned<AstNode> initExpression)
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
class TypeQuery : public chpl::uast::NamedDecl
#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]);
}

It is a NamedDecl because, as you can see above, D is available within the body of foo. So, ?D is represented as a TypeQuery with name D.

Note that, at present, proc bar(arg: ?) uses an Identifier ? rather than a TypeQuery.

Public Functions

~TypeQuery() override = default

Public Static Functions

static owned<TypeQuery> build(Builder *builder, Location loc, UniqueString name)
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 type uint.

Public Functions

~UintLiteral() override = default

Public Static Functions

static owned<UintLiteral> build(Builder *builder, Location loc, uint64_t value, UniqueString text)
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<AstNode> linkageName, UniqueString name, AstList contents)
class Use : public chpl::uast::AstNode
#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.

Public Static Functions

static owned<Use> build(Builder *builder, Location loc, Decl::Visibility visibility, AstList visibilityClauses)

Create and return a use statement.

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 formal x has intent ref.

inline const AstNode *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<AstNode> typeExpression, owned<AstNode> count)
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

enum Kind

Values:

enumerator VAR
enumerator CONST
enumerator CONST_REF
enumerator REF
enumerator PARAM
enumerator TYPE
enumerator INDEX

Public Functions

~Variable() override = default
inline Kind kind() const

Returns the kind of the variable (var / const / param etc).

inline bool isConfig() const

Returns true if this variable is a config variable.

inline bool isField() const

Returns true if this Variable represents a field.

Public Static Functions

static owned<Variable> build(Builder *builder, Location loc, owned<Attributes> attributes, Decl::Visibility vis, Decl::Linkage linkage, owned<AstNode> linkageName, UniqueString name, Variable::Kind kind, bool isConfig, bool isField, owned<AstNode> typeExpression, owned<AstNode> initExpression)
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 AstNode *typeExpression() const

Returns the type expression used in this VarLikeDecl’s declaration, or nullptr if there wasn’t one.

inline const AstNode *initExpression() const

Returns the init expression used in this VarLikeDecl’s declaration, or nullptr if there wasn’t one.

class VisibilityClause : public chpl::uast::AstNode
#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

Public Functions

~VisibilityClause() override = default
inline const AstNode *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<AstNode> 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 AstNode *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 Identifier or As expressions.

Public Static Functions

static owned<VisibilityClause> build(Builder *builder, Location loc, owned<AstNode> symbol)

Create and return a visibility clause.

static owned<VisibilityClause> build(Builder *builder, Location loc, owned<AstNode> symbol, LimitationKind limitationKind, AstList limitations)

Create and return a visibility clause.

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 AstNode *caseExpr(int i) const

Returns the i’th case of this when statement.

inline AstListIteratorPair<AstNode> 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.

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 AstNode *condition() const

Return the condition of this while loop.

Public Static Functions

static owned<While> build(Builder *builder, Location loc, owned<AstNode> condition, BlockStyle blockStyle, owned<Block> stmts)

Create and return a while loop.

class WithClause : public chpl::uast::AstNode
#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<AstNode> exprs() const

Return a way to iterate over the expressions of this with clause.

inline int numExprs() const

Return the number of expressions in this with clause.

inline const AstNode *expr(int i) const

Return the i’th expression in this with clause.

Public Static Functions

static owned<WithClause> build(Builder *builder, Location loc, AstList exprs)

Create and return a with clause.

class Yield : public chpl::uast::AstNode
#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 AstNode *value() const

Returns the value of this yield statement.

Public Static Functions

static owned<Yield> build(Builder *builder, Location loc, owned<AstNode> value)

Create and return a yield statement. The value formal cannot be nullptr.

class Zip : public chpl::uast::Call
#include <Zip.h>

This class represents a zip expression.

Public Functions

~Zip() override = default

Public Static Functions

static owned<Zip> build(Builder *builder, Location loc, AstList actuals)

Create and return a zip expression.

namespace asttags

Enums

enum AstTag

This enum is used to identify which AST class a node is.

Values:

enumerator NUM_AST_TAGS
enumerator AST_TAG_UNKNOWN

Functions

const char *tagToString(AstTag tag)
namespace pragmatags

Enums

enum PragmaTag

Values:

enumerator PRAGMA_UNKNOWN
enumerator NUM_KNOWN_PRAGMAS

Functions

const char *pragmaTagToName(PragmaTag tag)

Return the string name associated with a PragmaTag

PragmaTag pragmaNameToTag(const char *name)

Return the PragmaTag associated with a const char*

namespace primtags

Enums

enum PrimitiveTag

An enum containing the various PrimOp values e.g. PRIM_MOVE.

Values:

enumerator NUM_KNOWN_PRIMS

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*