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 Qualifier¶
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 REF_MAYBE_CONST¶
Represents a formal that will be passed with ‘ref’ or ‘const ref’ depending on subsequent analysis.
-
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’.
-
bool isOpName(UniqueString name)¶
-
bool isGenericQualifier(Qualifier kind)¶
Returns ‘true’ for qualifiers that are generic such as DEFAULT_INTENT
-
bool isConstQualifier(Qualifier kind)¶
Returns ‘true’ for qualifiers that are known to be const, that is, cannot be modified directly, (but might be modified by some other aliasing variable). Returns ‘false’ for qualifiers where it is unknown if it is const or not (such as DEFAULT_INTENT).
-
bool isImmutableQualifier(Qualifier kind)¶
Returns ‘true’ for qualifiers that are known to be immutable, that is, cannot be modified by any task or reference, including the current reference. Returns ‘false’ for qualifiers where it is unknown if it is immutable (such as DEFAULT_INTENT).
-
bool isRefQualifier(Qualifier kind)¶
Returns ‘true’ for qualifiers that are ‘ref’ or ‘const ref’, and returns ‘false’ for qualifiers where it is unknown if it is ref or not (such as DEFAULT_INTENT).
-
bool isInQualifier(Qualifier kind)¶
Returns ‘true’ for qualifiers that are ‘in’ or ‘const in’. Returns ‘false’ for qualifiers where it is unknown if it is ‘const in’ or not, such as DEFAULT_INTENT.
-
void checkBuilderResult(Context *context, UniqueString path, const BuilderResult &result)¶
Runs post-parse checks on the given given builder result, constructed from the contents of the file at path. This is not itself a query, and thus errors are reported to the calling query.
-
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 attributeGroupChildNum, Decl::Visibility vis, Decl::Linkage linkage, int linkageNameChildNum, UniqueString name, int elementsChildNum, int numElements)¶
-
inline AggregateDecl(AstTag tag, Deserializer &des)¶
-
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 virtual void serialize(Serializer &ser) const override¶
-
inline AggregateDecl(AstTag tag, AstList children, int attributeGroupChildNum, Decl::Visibility vis, Decl::Linkage linkage, int linkageNameChildNum, UniqueString name, int elementsChildNum, int numElements)¶
-
class AnonFormal : public chpl::uast::AstNode¶
- #include <AnonFormal.h>
This class represents an anonymous formal. Anonymous formals can appear in function types. Their presence indicates that the name of a particular formal does not matter for the purposes of resolution.
// Both formals of this procedure type are anonymous (no name). proc T = proc(int, int): int; proc foo(x: int, y: int) { return x + y; } proc bar(a: int, b: int) { return a + b; } var x: T = nil; x = foo; // OK, the names of T's formals are not specified. x = bar; // OK, the names of T's formals are not specified.
Because the formals of ‘T’ are anonymous, the corresponding formal names for concrete functions assigned to ‘x’ are not significant. If the formals were not anonymous, then a type error would be issued when one (or either) of the procedures was assigned to ‘x’.
As anonymous formals do not have a name, they do not inherit from NamedDecl (and their API is appropriately more simple).
They also do not carry an initialization expression.
Public Functions
-
~AnonFormal() override = default¶
-
inline Intent intent() const¶
Returns the intent of the formal, e.g. in
proc(const ref: int)
, the first formal has intentconst ref
.
-
inline virtual void serialize(Serializer &ser) const override¶
-
DECLARE_STATIC_DESERIALIZE(AnonFormal)¶
-
~AnonFormal() override = default¶
-
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 bool hasTrailingComma() const¶
-
inline bool isAssociative() const¶
-
inline AstListIteratorPair<AstNode> exprs() const¶
Return a way to iterate over the expressions of this array.
-
inline virtual void serialize(Serializer &ser) const override¶
-
~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¶
-
inline virtual void serialize(Serializer &ser) const override¶
-
~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::AnonFormal, chpl::uast::Array, chpl::uast::As, chpl::uast::Attribute, chpl::uast::AttributeGroup, 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::FunctionSignature, 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¶
-
bool isLeaf() const¶
Returns ‘true’ if this AST node is a leaf node by tag.
-
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 int attributeGroupChildNum() const¶
Returns the index into children of the attributeGroup child node, or AstNode::NO_CHILD if no attributeGroup exists on this node.
-
inline const AttributeGroup *attributeGroup() const¶
Return the attributeGroup associated with this AstNode, or nullptr if none exists. Note that it would be better to use the parsing query idToAttributeGroup to ensure you get the AttributeGroup when the AstNode is a child of a MultiDecl or TupleDecl.
-
inline bool contains(const AstNode *other) const¶
Returns ‘true’ if this symbol contains another AST node. This is an operation on the IDs.
-
bool isInherentlyStatement() const¶
Returns ‘true’ if this uAST node is a inherently a statement. Note that anything contained directly in a Block is also a statement.
-
void stringify(std::ostream &ss, chpl::StringifyKind stringKind) const¶
-
int computeMaxIdStringWidth() const¶
-
virtual void serialize(Serializer &os) 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:
UnlikeFirst, 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).
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 owned<AstNode> deserialize(Deserializer &des)¶
Public Static Attributes
-
static constexpr int NO_CHILD = -1¶
-
virtual ~AstNode() = 0¶
-
class Attribute : public chpl::uast::AstNode¶
Public Functions
-
~Attribute() override = default¶
-
inline UniqueString name() const¶
returns the name of the attribute without the toolspace
-
inline AstListIteratorPair<AstNode> actuals() const¶
Returns an iterable expression over the actuals of an attribute.
-
inline int numActuals() const¶
-
inline UniqueString getOnlyStringActualOrError(Context *ctx) const¶
-
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 const std::string fullyQualifiedAttributeName() const¶
-
inline virtual void serialize(Serializer &ser) const override¶
-
inline bool usedParens() const¶
Public Static Functions
-
static owned<Attribute> build(Builder *builder, Location loc, UniqueString name, bool usedParens, AstList actuals, std::vector<UniqueString> actualNames)¶
-
~Attribute() override = default¶
-
class AttributeGroup : public chpl::uast::AstNode¶
- #include <AttributeGroup.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
-
~AttributeGroup() override = default¶
-
inline bool hasPragma(PragmaTag tag) const¶
Returns true if the given pragma is set for this attributeGroup.
-
inline PragmaIterable pragmas() const¶
Iterate over the pragmas stored in this attributes.
-
inline const Attribute *getAttributeNamed(UniqueString attributeName) const¶
-
inline bool isDeprecated() const¶
Returns true if the declaration associated with this attributeGroup 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.
-
inline virtual void serialize(Serializer &ser) const override¶
-
DECLARE_STATIC_DESERIALIZE(AttributeGroup)¶
-
inline int numAttributes() const¶
Returns the number of attributes in this group.
Public Static Functions
-
static owned<AttributeGroup> build(Builder *builder, Location loc, std::set<PragmaTag> pragmas, bool isDeprecated, bool isUnstable, UniqueString deprecationMessage, UniqueString unstableMessage)¶
-
static owned<AttributeGroup> build(Builder *builder, Location loc, std::set<PragmaTag> pragmas, bool isDeprecated, bool isUnstable, UniqueString deprecationMessage, UniqueString unstableMessage, AstList attributes)¶
-
~AttributeGroup() 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.
-
inline virtual void serialize(Serializer &ser) const override¶
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¶
-
inline virtual void serialize(Serializer &ser) const override¶
-
~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.
-
inline virtual void serialize(Serializer &ser) const override¶
-
DECLARE_STATIC_DESERIALIZE(BoolLiteral)¶
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¶
-
bool isMaybeArrayType() const¶
Check if this bracket loop is actually an array type
-
inline virtual void serialize(Serializer &ser) const override¶
-
DECLARE_STATIC_DESERIALIZE(BracketLoop)¶
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 virtual void serialize(Serializer &ser) const override¶
-
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.
-
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 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() const¶
If the top-level expressions contain only a single Module, return it. Otherwise, return nullptr.
-
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 serialize(std::ostream &os) const¶
-
void serialize(Serializer &ser) const¶
-
bool equals(const BuilderResult &other) const¶
Public Static Functions
-
static bool update(BuilderResult &keep, BuilderResult &addin)¶
-
static void updateFilePaths(Context *context, const BuilderResult &keep)¶
-
static BuilderResult deserialize(Deserializer &des)¶
-
BuilderResult()¶
-
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 virtual void serialize(Serializer &ser) const override¶
-
DECLARE_STATIC_DESERIALIZE(BytesLiteral)¶
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¶
-
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.
-
inline virtual void serialize(Serializer &ser) const override¶
-
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.
-
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.
-
inline virtual void serialize(Serializer &ser) const override¶
-
~Catch() override = default¶
-
class Class : public chpl::uast::AggregateDecl¶
- #include <Class.h>
This class represents a class declaration. For example:
class MyClass : ParentClass { var a: int; proc method() { } }
The class itself (MyClass) is represented by a Class AST node.
Public Functions
-
~Class() override = default¶
-
inline const AstNode *parentClass() const¶
Return the AstNode indicating the parent class or nullptr if there was none.
-
inline virtual void serialize(Serializer &ser) const override¶
Public Static Functions
-
static owned<Class> build(Builder *builder, Location loc, owned<AttributeGroup> attributeGroup, 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 virtual void serialize(Serializer &ser) const override¶
-
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¶
-
inline virtual void serialize(Serializer &ser) const override¶
-
~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
-
inline virtual void serialize(Serializer &ser) const override¶
-
~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.
-
inline virtual void serialize(Serializer &ser) const override¶
-
DECLARE_STATIC_DESERIALIZE(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 virtual void serialize(Serializer &ser) const override¶
-
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 virtual void serialize(Serializer &ser) const override¶
-
DECLARE_STATIC_DESERIALIZE(CStringLiteral)¶
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 virtual void serialize(Serializer &ser) const override¶
Public Static Functions
-
static const char *visibilityToString(Visibility v)¶
Convert Decl::Visibility to a string
-
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¶
-
inline virtual void serialize(Serializer &ser) const override¶
-
~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 virtual void serialize(Serializer &ser) const override¶
-
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.
-
inline bool usedCurlyBraces() const¶
Return ‘true’ if this domain was constructed with curly braces.
-
inline virtual void serialize(Serializer &ser) const override¶
-
~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
-
inline virtual void serialize(Serializer &ser) const override¶
-
~Dot() override = default¶
-
class DoWhile : public chpl::uast::Loop¶
- #include <DoWhile.h>
This class represents a do-while loop. For example:
// Example 1: var i = 0; do { writeln(i); i += 1; } while i < 5;
Public Functions
-
~DoWhile() override = default¶
-
inline virtual void serialize(Serializer &ser) const override¶
-
~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¶
-
inline virtual void serialize(Serializer &ser) const override¶
-
~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)
-
inline virtual void serialize(Serializer &ser) const override¶
Public Static Functions
-
static owned<Enum> build(Builder *builder, Location loc, owned<AttributeGroup> attributeGroup, 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.
-
inline virtual void serialize(Serializer &ser) const override¶
-
DECLARE_STATIC_DESERIALIZE(EnumElement)¶
Public Static Functions
-
static owned<EnumElement> build(Builder *builder, Location loc, owned<AttributeGroup> attributeGroup, UniqueString name, owned<AstNode> initExpression)¶
-
static owned<EnumElement> build(Builder *builder, Location loc, owned<AttributeGroup> attributeGroup, 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¶
-
inline virtual void serialize(Serializer &ser) const override¶
-
DECLARE_STATIC_DESERIALIZE(ErroneousExpression)¶
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 Functions
-
~ExternBlock() override = default¶
-
inline const std::string &code() const¶
-
inline virtual void serialize(Serializer &ser) const override¶
-
DECLARE_STATIC_DESERIALIZE(ExternBlock)¶
Public Static Functions
-
static owned<ExternBlock> build(Builder *builder, Location loc, std::string code)¶
Create and return an ExternBlock with the given C code.
-
~ExternBlock() override = default¶
-
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).
-
inline virtual void serialize(Serializer &ser) const override¶
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; }
Public Functions
-
~For() override = default¶
-
inline bool isParam() const¶
Returns true if this for loop is param.
-
inline virtual void serialize(Serializer &ser) const override¶
-
~For() override = default¶
-
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¶
-
inline virtual void serialize(Serializer &ser) const override¶
-
~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¶
-
inline virtual void serialize(Serializer &ser) const override¶
-
~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¶
-
inline Intent intent() const¶
Returns the intent of the formal, e.g. in
proc f(const ref y: int)
, the formaly
has intentconst ref
.
-
inline bool isExplicitlyAnonymous() const¶
If
true
, then this formal’s name is ‘_’, as inproc(_: int)
. This is different from a formal that is anonymous in a type context, e.g.,type T = proc(int)
, where the formal might be anonymous if it is taken to represent a type.
-
inline virtual void serialize(Serializer &ser) const override¶
-
~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.
-
inline virtual void serialize(Serializer &ser) const override¶
-
DECLARE_STATIC_DESERIALIZE(ForwardingDecl)¶
Public Static Functions
-
static owned<ForwardingDecl> build(Builder *builder, Location loc, owned<AttributeGroup> attributeGroup, owned<AstNode> expr)¶
-
static owned<ForwardingDecl> build(Builder *builder, Location loc, owned<AttributeGroup> attributeGroup, 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 bool isAnonymous() 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.
-
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.
-
inline virtual void serialize(Serializer &ser) const override¶
Public Static Functions
-
static owned<Function> build(Builder *builder, Location loc, owned<AttributeGroup> attributeGroup, 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)¶
-
static const char *returnIntentToString(ReturnIntent intent)¶
-
~Function() override = default¶
-
class FunctionSignature : public chpl::uast::AstNode¶
- #include <FunctionSignature.h>
This class represents a function signature. For example:
type T = proc(int, int): int;
The type alias ‘T’ stores the function signature for a procedure that takes two ints and returns an int.
Public Functions
-
~FunctionSignature() override = default¶
-
inline ReturnIntent returnIntent() const¶
-
inline bool throws() const¶
-
inline bool isParenless() const¶
-
inline AstListIteratorPair<AstNode> formals() const¶
Return a way to iterate over the formals, including the method receiver, if present, as the first formal.
-
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 virtual void serialize(Serializer &ser) const override¶
-
DECLARE_STATIC_DESERIALIZE(FunctionSignature)¶
-
~FunctionSignature() 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 Functions
-
~Identifier() override = default¶
-
inline UniqueString name() const¶
-
inline virtual void serialize(Serializer &ser) const override¶
-
DECLARE_STATIC_DESERIALIZE(Identifier)¶
Public Static Functions
-
static owned<Identifier> build(Builder *builder, Location loc, UniqueString name)¶
-
~Identifier() override = default¶
-
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¶
-
inline virtual void serialize(Serializer &ser) const override¶
-
DECLARE_STATIC_DESERIALIZE(ImagLiteral)¶
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.
-
inline virtual void serialize(Serializer &ser) const override¶
-
DECLARE_STATIC_DESERIALIZE(Implements)¶
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 virtual void serialize(Serializer &ser) const override¶
-
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.
-
inline virtual void serialize(Serializer &ser) const override¶
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.
-
inline virtual void serialize(Serializer &ser) const override¶
-
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 isFormalListExplicit() 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.
-
inline virtual void serialize(Serializer &ser) const override¶
Public Static Functions
-
static owned<Interface> build(Builder *builder, Location loc, owned<AttributeGroup> attributeGroup, Decl::Visibility visibility, UniqueString name, bool isFormalListExplicit, 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¶
-
inline virtual void serialize(Serializer &ser) const override¶
-
DECLARE_STATIC_DESERIALIZE(IntLiteral)¶
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.
-
inline virtual void serialize(Serializer &ser) const override¶
-
~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.
-
inline virtual void serialize(Serializer &ser) const override¶
-
~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::NumericLiteral< double, types::RealParam >, chpl::uast::NumericLiteral< int64_t, types::IntParam >, chpl::uast::NumericLiteral< uint64_t, types::UintParam >, chpl::uast::BoolLiteral, chpl::uast::NumericLiteral< ValueT, ParamT >, chpl::uast::StringLikeLiteral
Public Functions
-
virtual ~Literal() = 0¶
-
inline const types::Param *param() const¶
Returns the value stored in this Literal as a types::Param.
-
inline virtual void serialize(Serializer &ser) const override¶
-
virtual ~Literal() = 0¶
-
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.
-
inline virtual void serialize(Serializer &ser) const override¶
-
inline const AstNode *condition() const¶
-
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.
-
inline virtual void serialize(Serializer &ser) const override¶
-
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.
-
inline virtual void serialize(Serializer &ser) const override¶
-
~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.
-
inline virtual void serialize(Serializer &ser) const override¶
-
~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)
-
inline virtual void serialize(Serializer &ser) const override¶
-
~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
Public Functions
-
virtual ~NamedDecl() = 0¶
-
inline virtual void serialize(Serializer &ser) const override¶
-
inline UniqueString name() const¶
-
virtual ~NamedDecl() = 0¶
-
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.
-
inline virtual void serialize(Serializer &ser) const override¶
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 virtual void serialize(Serializer &ser) const override¶
-
inline UniqueString text() const¶
Returns the number as it was written in the source code (as a string)
-
virtual ~NumericLiteral() = 0¶
-
class On : public chpl::uast::SimpleBlockLike¶
- #include <On.h>
This class represents an on statement. For example:
// Example 1: var x = 0; on Locales[1] do writeln(x);
Public Functions
-
inline virtual void serialize(Serializer &ser) const override¶
-
inline virtual void serialize(Serializer &ser) const override¶
-
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
-
inline virtual void serialize(Serializer &ser) const override¶
-
~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)
Public Functions
-
~PrimCall() override = default¶
-
inline PrimitiveTag prim() const¶
Returns the enum value of the primitive called
-
inline virtual void serialize(Serializer &ser) const override¶
-
~PrimCall() override = default¶
-
class Range : public chpl::uast::AstNode¶
- #include <Range.h>
This class represents a range expression. For example:
// Example 1: var r = 0..15;
Public Functions
-
~Range() override = default¶
-
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.
-
inline virtual void serialize(Serializer &ser) const override¶
-
~Range() override = default¶
-
class RealLiteral : public chpl::uast::NumericLiteral<double, types::RealParam>¶
- #include <RealLiteral.h>
This class represents a floating point literal that is not imaginary. That is, it is a “real” number. Examples include
0.0
, and3e24
.Public Functions
-
~RealLiteral() override = default¶
-
inline virtual void serialize(Serializer &ser) const override¶
-
DECLARE_STATIC_DESERIALIZE(RealLiteral)¶
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¶
-
inline virtual void serialize(Serializer &ser) const override¶
Public Static Functions
-
static owned<Record> build(Builder *builder, Location loc, owned<AttributeGroup> attributeGroup, 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
}
Public Functions
-
~Reduce() override = default¶
-
inline const AstNode *op() const¶
Returns the reduce op expression, e.g.
minmax(int)
in the expressionminmax(int) reduce sum
.
-
inline const AstNode *iterand() const¶
Returns the iterand of the reduction, e,g.,
sum
in the expressionminmax(int) reduce sum
.
-
inline virtual void serialize(Serializer &ser) const override¶
-
~Reduce() override = default¶
-
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 expressionminmax(int) reduce sum
.
-
inline virtual void serialize(Serializer &ser) const override¶
-
DECLARE_STATIC_DESERIALIZE(ReduceIntent)¶
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.
-
inline virtual void serialize(Serializer &ser) const override¶
-
~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¶
-
inline const AstNode *value() const¶
Returns the value of this return statement, or nullptr if there is none.
-
inline virtual void serialize(Serializer &ser) const override¶
-
~Return() override = default¶
-
class Scan : public chpl::uast::Call¶
- #include <Scan.h>
This class represents a scan expression. For example:
- ..code-block :: chapel
var A: [1..3] int = 1; // Prints ‘1 2 3’ writeln(+ scan A);
The scan expression is ‘+ scan A’.
Public Functions
-
~Scan() override = default¶
-
inline 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
.
-
inline virtual void serialize(Serializer &ser) const override¶
-
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 virtual void serialize(Serializer &ser) const override¶
-
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
-
inline const AstNode *condition() const¶
Returns the condition of this serial statement, or nullptr if there is none.
-
inline virtual void serialize(Serializer &ser) const override¶
-
inline const AstNode *condition() const¶
-
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.
-
inline virtual void serialize(Serializer &ser) const override¶
-
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 UniqueString value() const¶
Returns the value of this bytes literal as a UniqueString which does not include the quotes.
-
inline QuoteStyle quoteStyle() const¶
Returns the type of quotes used for this string literal.
-
inline virtual void serialize(Serializer &ser) const override¶
Public Static Functions
-
static const char *quoteStyleToString(QuoteStyle q)¶
Returns a string containing the characters to open a quote with the passed quote style
-
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 virtual void serialize(Serializer &ser) const override¶
-
DECLARE_STATIC_DESERIALIZE(StringLiteral)¶
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¶
-
inline virtual void serialize(Serializer &ser) const override¶
-
~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¶
-
inline virtual void serialize(Serializer &ser) const override¶
-
~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
-
inline virtual void serialize(Serializer &ser) const override¶
-
inline virtual void serialize(Serializer &ser) const override¶
-
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 const Block *body() const¶
Return the contained block for a try statement. For an expression-level try, returns nullptr.
-
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.
-
inline virtual void serialize(Serializer &ser) const override¶
-
~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¶
-
inline virtual void serialize(Serializer &ser) const override¶
-
~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).
-
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.
-
inline virtual void serialize(Serializer &ser) const override¶
Public Static Functions
-
static owned<TupleDecl> build(Builder *builder, Location loc, owned<AttributeGroup> attributeGroup, Decl::Visibility vis, Decl::Linkage linkage, IntentOrKind intentOrKind, AstList elements, owned<AstNode> typeExpression, owned<AstNode> initExpression)¶
-
static const char *intentOrKindToString(IntentOrKind kind)¶
Returns a string describing the passed intentOrKind.
-
~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¶
-
inline virtual void serialize(Serializer &ser) const override¶
-
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¶
-
inline virtual void serialize(Serializer &ser) const override¶
-
~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¶
-
inline virtual void serialize(Serializer &ser) const override¶
-
DECLARE_STATIC_DESERIALIZE(UintLiteral)¶
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¶
-
inline virtual void serialize(Serializer &ser) const override¶
Public Static Functions
-
static owned<Union> build(Builder *builder, Location loc, owned<AttributeGroup> attributeGroup, 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 virtual void serialize(Serializer &ser) const override¶
-
inline Decl::Visibility visibility() const¶
-
class VarArgFormal : public chpl::uast::VarLikeDecl¶
- #include <VarArgFormal.h>
This class represents a varargs formal.
proc f(x: int ...?k) { writeln(x); }
Here
x
is a formal that may take a variable number of actual arguments, the number of which is denoted by the TypeQuery?k
.Public Functions
-
~VarArgFormal() override = default¶
-
inline Formal::Intent intent() const¶
Returns the intent of the varargs formal, e.g. in
proc f(ref x: int ...?k)
, the formalx
has intentref
.
-
inline const 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.
-
inline virtual void serialize(Serializer &ser) const override¶
-
DECLARE_STATIC_DESERIALIZE(VarArgFormal)¶
Public Static Functions
-
static owned<VarArgFormal> build(Builder *builder, Location loc, owned<AttributeGroup> attributeGroup, 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.
-
inline virtual void serialize(Serializer &ser) const override¶
Public Static Functions
-
static owned<Variable> build(Builder *builder, Location loc, owned<AttributeGroup> attributeGroup, Decl::Visibility vis, Decl::Linkage linkage, owned<AstNode> linkageName, UniqueString name, Variable::Kind kind, bool isConfig, bool isField, owned<AstNode> typeExpression, owned<AstNode> initExpression)¶
-
~Variable() override = default¶
-
class VarLikeDecl : public chpl::uast::NamedDecl¶
- #include <VarLikeDecl.h>
This abstract class represents any sort of variable-like declaration. This includes things like fields, formals, or variables.
Subclassed by chpl::uast::Formal, chpl::uast::TaskVar, chpl::uast::VarArgFormal, chpl::uast::Variable
Public Functions
-
virtual ~VarLikeDecl() = 0¶
-
inline Qualifier 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.
-
inline virtual void serialize(Serializer &ser) const override¶
-
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.
-
inline virtual void serialize(Serializer &ser) const override¶
-
DECLARE_STATIC_DESERIALIZE(VisibilityClause)¶
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.
-
static const char *limitationKindToString(LimitationKind kind)¶
Return a string describing the passed LimitationKind.
-
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.
-
inline virtual void serialize(Serializer &ser) const override¶
Public Static Functions
-
static owned<When> build(Builder *builder, Location loc, AstList caseExprs, BlockStyle blockStyle, AstList stmts)¶
Create and return a when statement. If ‘caseExprs’ is empty then ‘isOtherwise()’ will evaluate to true.
-
inline int numCaseExprs() const¶
-
class While : public chpl::uast::Loop¶
- #include <While.h>
This class represents a while loop. For example:
// Example 1: var i = 0; while i < 5 { writeln(i); i += 1; }
Public Functions
-
~While() override = default¶
-
inline virtual void serialize(Serializer &ser) const override¶
-
~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 virtual void serialize(Serializer &ser) const override¶
-
DECLARE_STATIC_DESERIALIZE(WithClause)¶
-
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¶
-
inline virtual void serialize(Serializer &ser) const override¶
-
~Yield() override = default¶
-
class Zip : public chpl::uast::Call¶
- #include <Zip.h>
This class represents a zip expression.
Public Functions
-
~Zip() override = default¶
-
inline virtual void serialize(Serializer &ser) const override¶
-
~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¶