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 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
-
enumerator UNKNOWN¶
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’.
-
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)
-
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::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.
-
~Array() override = default¶
-
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¶
-
~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::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 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.
-
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);
-
virtual ~AstNode() = 0¶
-
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 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)¶
-
~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<AstNode> 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::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.
-
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<AstNode> 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
-
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.
-
void addToplevelExpression(owned<AstNode> 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.
-
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)¶
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)¶
-
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::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 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<AstNode> actuals() const¶
Returns an iterable expression over the actuals of a call.
-
inline int numActuals() const¶
-
virtual ~Call() override = 0¶
-
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 AstListIteratorPair<AstNode> stmts() const¶
Iterate over the statements 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¶
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() override = default¶
-
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 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¶
-
~Coforall() override = default¶
-
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
-
~Comment() override = default¶
-
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 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.
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.
-
~Conditional() override = default¶
-
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.
-
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::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
Public Functions
-
virtual ~Decl() = 0¶
-
inline Visibility visibility() const¶
Return the visibility of this declaration, e.g. “PUBLIC” or “PRIVATE”.
-
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.
-
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::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 AstListIteratorPair<AstNode> exprs() const¶
-
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.
-
~Domain() override = default¶
-
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()
, 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 UniqueString field() const¶
Returns the name of the field or method accessed by the Dot expression
-
~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¶
-
~DoWhile() override = default¶
-
class EmptyStmt : public chpl::uast::AstNode¶
- #include <EmptyStmt.h>
This class represents an empty statement For example:
;
The single semicolon,
;
, represents an empty statementPublic Functions
-
~EmptyStmt() override = default¶
-
~EmptyStmt() 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<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)¶
-
~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 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)¶
-
~EnumElement() override = default¶
-
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)¶
-
~ErroneousExpression() = default¶
-
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 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<AstNode> 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¶
-
~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¶
-
~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¶
-
~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 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)¶
-
~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 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 AstListIteratorPair<AstNode> stmts() const¶
Return a way to iterate over the statements in the function body.
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)¶
-
~Function() override = default¶
-
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 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 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)¶
-
~Implements() override = default¶
-
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.
-
inline Decl::Visibility visibility() const¶
-
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.
-
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 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 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 AstListIteratorPair<AstNode> stmts() const¶
Iterate over the statements 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)¶
-
~Interface() override = default¶
-
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::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 UniqueString name() const¶
Return the name of this label statement.
-
~Label() override = default¶
-
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.
-
~Let() override = default¶
-
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 >
-
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
-
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 AstListIteratorPair<AstNode> stmts() const¶
Return a way to iterate over the statements of this loop.
-
inline BlockStyle blockStyle() const¶
Returns the block style of the current loop.
-
virtual ~Loop() override = 0¶
-
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.
-
~Manage() override = default¶
-
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<AstNode> stmts() const¶
Iterate over the statements 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<AstNode> declOrComments() const¶
Return a way to iterate over the contained VariableDecls and Comments.
-
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::Interface, chpl::uast::Module, chpl::uast::ReduceIntent, chpl::uast::TypeDecl, chpl::uast::TypeQuery, chpl::uast::VarLikeDecl
-
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
Public Functions
-
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.
-
inline Management management() 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
-
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
-
~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::AstNode¶
- #include <Range.h>
This class represents a range expression. For example:
// Example 1: var r = 0..15;
-
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<AstNode> linkageName, UniqueString name, AstList contents)¶
-
~Record() override = default¶
-
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
}
-
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¶
Public Static Functions
-
static owned<ReduceIntent> build(Builder *builder, Location loc, owned<AstNode> op, UniqueString name)¶
Create and return a reduction.
-
~ReduceIntent() override = default¶
-
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.
-
~Require() override = default¶
-
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¶
-
~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’.
-
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 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 int numWhenStmts() 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
-
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:
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 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¶
-
~TaskVar() override = default¶
-
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
-
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 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 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
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).
-
~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::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 nameD
.Note that, at present,
proc bar(arg: ?)
uses an Identifier?
rather than a TypeQuery.Public Functions
-
~TypeQuery() override = default¶
-
~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<AstNode> linkageName, UniqueString name, AstList contents)¶
-
~Union() override = default¶
-
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.
-
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¶
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)¶
-
~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
-
~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 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.
-
virtual ~VarLikeDecl() = 0¶
-
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¶
-
enumerator BRACES¶
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.
-
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 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.
-
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¶
-
~While() override = default¶
-
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 AstListIteratorPair<AstNode> exprs() const¶
-
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¶
-
~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¶