IR Expression Nodes

IR Nodes

Expressions compute a value based on an operation and one or more values. Exp Nodes represent this. There are a lot of expressions with wide ranging effects.

Literals (integer constants, strings) are also expressions.

An expression may or may not have a side effect depending on the operation, and what is being operated on.

The expression nodes are mostly flat. Expressions contain other expressions, but generally not a specific kind.

Classes

Exp Base class for all expressions.
LiteralExp Base class for literal expressions.
Ternary A ternary expression is a shorthand if statement in the form of an expression.
BinOp A BinOp is an operation the operates on two expressions with a given operation.
Unary A Unary operation is prepended to the back of an expression.
Postfix A postfix operation is appended to an expression.
PropertyExp A looked up postfix operation is appended to an expression.
Constant A Constant is a literal value of a given type.
ArrayLiteral Represents an array literal. Contains a list of expressions with (if semantically sound) a common type.
AssocArray Represents an associative array literal -- a list of key/value pairs.
IdentifierExp Represents a single identifier. Replaced with ExpReference in a pass.
Assert An Assert checks that a condition is true, and dies with an optional message if not.
StringImport A StringImport creates a string literal from a file on disk at compile time.
Typeid The typeid expression returns the typeinfo of a given type or expression.
IsExp The is expression is a bit of a swiss army knife. It can be simply used to determine whether a given type is well-formed, or if a given type is a certain other type, or can be converted into another type.
FunctionLiteral A function literal can define a normal function, or a delegate (a function with context). There are multiple ways to define these but the long hand way is int function(int a, int b) { return a + b; } Defines a function that takes two integers and returns them added up. int delegate(int a, int b) { return a + b + c; } Is the same, except it has access to the outer scope's variables.
ExpReference An ExpReference replaces chained postfix look ups with the result of the lookup. A cache that is inserted later, in other words.
TypeExp A TypeExp is used when a primitive type is used in an expression. This is currently limited to .max/min and (void*).max/min.
StoreExp A StoreExp is used when a NamedType is used in an expression within a WithStatement, like so: with (Class.Enum) { int val = DeclInEnum; }.
StatementExp A StatementExp is a internal expression for inserting statements into a expression. Note that this is not a function and executes the statements just as if they where inserted in the BlockStatement that the StatementExp is in. Meaning any ReturnStatement will return the current function not this StatementExp.
TokenExp Expression that corresponds to what was once special tokens. FUNCTION, PRETTY_FUNCTION, FILE, and __LINE.
VaArgExp Expression that assists in working with varargs.
AccessExp An expression that represents a simple identifier.identifier lookup.
RunExp An expression that forces the compiler to evaluate another expression at compile time.
ComposableString A string that contains expressions to be formatted inline.