// expr-defs.h // Syntax class definitions for expressions. // Base class for expressions that will reference declarations ABSTRACT_SYNTAX_CLASS(DeclRefExpr, ExpressionSyntaxNode) // The scope in which to perform lookup FIELD(RefPtr, scope) // The declaration of the symbol being referenced DECL_FIELD(DeclRef, declRef) // The name of the symbol being referenced FIELD(String, name) END_SYNTAX_CLASS() SIMPLE_SYNTAX_CLASS(VarExpressionSyntaxNode, DeclRefExpr) // An expression that references an overloaded set of declarations // having the same name. SYNTAX_CLASS(OverloadedExpr, ExpressionSyntaxNode) // Optional: the base expression is this overloaded result // arose from a member-reference expression. SYNTAX_FIELD(RefPtr, base) // The lookup result that was ambiguous FIELD(LookupResult, lookupResult2) END_SYNTAX_CLASS() SYNTAX_CLASS(ConstantExpressionSyntaxNode, ExpressionSyntaxNode) FIELD(Token, token) RAW( enum class ConstantType { Int, Bool, Float, String, }; ConstantType ConstType; union { IntegerLiteralValue integerValue; FloatingPointLiteralValue floatingPointValue; }; String stringValue; ) END_SYNTAX_CLASS() // An initializer list, e.g. `{ 1, 2, 3 }` SYNTAX_CLASS(InitializerListExpr, ExpressionSyntaxNode) SYNTAX_FIELD(List>, args) END_SYNTAX_CLASS() // A base class for expressions with arguments ABSTRACT_SYNTAX_CLASS(ExprWithArgsBase, ExpressionSyntaxNode) SYNTAX_FIELD(List>, Arguments) END_SYNTAX_CLASS() // An aggregate type constructor SYNTAX_CLASS(AggTypeCtorExpr, ExprWithArgsBase) SYNTAX_FIELD(TypeExp, base); END_SYNTAX_CLASS() // A base expression being applied to arguments: covers // both ordinary `()` function calls and `<>` generic application ABSTRACT_SYNTAX_CLASS(AppExprBase, ExprWithArgsBase) SYNTAX_FIELD(RefPtr, FunctionExpr) END_SYNTAX_CLASS() SIMPLE_SYNTAX_CLASS(InvokeExpressionSyntaxNode, AppExprBase) SIMPLE_SYNTAX_CLASS(OperatorExpressionSyntaxNode, InvokeExpressionSyntaxNode) SIMPLE_SYNTAX_CLASS(InfixExpr , OperatorExpressionSyntaxNode) SIMPLE_SYNTAX_CLASS(PrefixExpr , OperatorExpressionSyntaxNode) SIMPLE_SYNTAX_CLASS(PostfixExpr, OperatorExpressionSyntaxNode) SYNTAX_CLASS(IndexExpressionSyntaxNode, ExpressionSyntaxNode) SYNTAX_FIELD(RefPtr, BaseExpression) SYNTAX_FIELD(RefPtr, IndexExpression) END_SYNTAX_CLASS() SYNTAX_CLASS(MemberExpressionSyntaxNode, DeclRefExpr) SYNTAX_FIELD(RefPtr, BaseExpression) END_SYNTAX_CLASS() SYNTAX_CLASS(SwizzleExpr, ExpressionSyntaxNode) SYNTAX_FIELD(RefPtr, base) FIELD(int, elementCount) FIELD(int, elementIndices[4]) END_SYNTAX_CLASS() // A dereference of a pointer or pointer-like type SYNTAX_CLASS(DerefExpr, ExpressionSyntaxNode) SYNTAX_FIELD(RefPtr, base) END_SYNTAX_CLASS() // Any operation that performs type-casting SYNTAX_CLASS(TypeCastExpressionSyntaxNode, ExpressionSyntaxNode) SYNTAX_FIELD(TypeExp, TargetType) SYNTAX_FIELD(RefPtr, Expression) END_SYNTAX_CLASS() // An explicit type-cast that appear in the user's code with `(Type) expr` syntax SYNTAX_CLASS(ExplicitCastExpr, TypeCastExpressionSyntaxNode) END_SYNTAX_CLASS() // An implicit type-cast inserted during semantic checking SYNTAX_CLASS(ImplicitCastExpr, TypeCastExpressionSyntaxNode) END_SYNTAX_CLASS() // An implicit type-cast that should also be hidden on output, // because we don't want to mess with the user's code SYNTAX_CLASS(HiddenImplicitCastExpr, ImplicitCastExpr) END_SYNTAX_CLASS() SIMPLE_SYNTAX_CLASS(SelectExpressionSyntaxNode, OperatorExpressionSyntaxNode) SIMPLE_SYNTAX_CLASS(GenericAppExpr, AppExprBase) // An expression representing re-use of the syntax for a type in more // than once conceptually-distinct declaration SYNTAX_CLASS(SharedTypeExpr, ExpressionSyntaxNode) // The underlying type expression that we want to share SYNTAX_FIELD(TypeExp, base) END_SYNTAX_CLASS() SYNTAX_CLASS(AssignExpr, ExpressionSyntaxNode) SYNTAX_FIELD(RefPtr, left); SYNTAX_FIELD(RefPtr, right); END_SYNTAX_CLASS() // Just an expression inside parentheses `(exp)` // // We keep this around explicitly to be sure we don't lose any structure // when we do rewriter stuff. SYNTAX_CLASS(ParenExpr, ExpressionSyntaxNode) SYNTAX_FIELD(RefPtr, base); END_SYNTAX_CLASS()