minid.ast

This module contains the definition of all the classes which correspond to MiniD's grammar productions. These are used to represent the AST during compilation.

License:
Copyright (c) 2008 Jarrett Billingsley


This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.

Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:

1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.

2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.

3. This notice may not be removed or altered from any source distribution.

abstract class AstNode : minid.compilertypes.IAstNode;
The base class for all the Abstract Syntax Tree nodes in the language.

CompileLoc location ;
The location of the beginning of this node.

CompileLoc endLocation ;
The location of the end of this node.

AstTag type ;
The tag indicating what kind of node this actually is.

this(ICompiler c, CompileLoc location, CompileLoc endLocation, AstTag type);
The base constructor, but since this class is abstract, this can only be called from derived classes.

Params:
ICompiler c The compiler with which the node will be associated.
CompileLoc location The location of the beginning of this node.
CompileLoc endLocation The location of the end of this node.
AstTag type The type of this node.

char[] toString ();
By default, toString () will return the string representation of the node type.

char[] niceString ();
Returns a nicer (readable) representation of this kind of node.

T as (T)();
Similar to a dynamic cast, except it uses the 'type' field to determine if the cast is legal, making it faster. Returns this casted to the given class type if the cast succeeds and null otherwise.

class Unknown : minid.ast.AstNode;
Dummy unknown node type.

class Identifier : minid.ast.AstNode;
This node represents an identifier. This isn't the same as an IdentExp, as identifiers can be used in non-expression contexts (such as names in declarations).

class ClassDef : minid.ast.AstNode;
This node represents the guts of an class literal. This node does not directly correspond to a single grammar element; rather it represents the common attributes of both class literals and class declarations.

struct Field ;
Represents a single field in the class. Remember that methods are fields too.

char[] name ;
The name of the field. This corresponds to either the name of a data member or the name of a method.

Expression initializer ;
The initializer of the field. This will never be null. If a field is declared in a class but not given a value, a NullExp will be inserted into this field.

Identifier name ;
The name of the class. This field will never be null.

Expression baseClass ;
The base class from which this class derives. This field will never be null. If no base class is specified, it is given the value of an IdentExp with the identifier "Object".

Field[] fields ;
The fields in this class, in the order they were declared. See the Field struct above.

this(ICompiler c, CompileLoc location, CompileLoc endLocation, Identifier name, Expression baseClass, Field[] fields);


class FuncDef : minid.ast.AstNode;
Similar to ClassDef, this class represents the common attributes of both function literals and function declarations.

struct Param ;
Represents a parameter to the function.

Identifier name ;
The name of the parameter.

ushort typeMask ;
The type mask of the parameter, that is, what basic types can be passed to it. Defaults to TypeMask.Any, which allows any type to be passed. This should not be set to 0; the codegen does not check for this so it's up to you.

Expression[] classTypes ;
If typeMask allows instances, this can be a list of expressions which should evaluate at runtime to class types that this parameter can accept. This is an optional list. If typeMask does not allow instances, this should be empty.

Expression defValue ;
The default value for the parameter. This can be null, in which case it will have no default value.

Identifier name ;
The name of the function. This will never be null. In the case of function literals without names, this will be filled with an auto-generated name based off the location of where the literal occurred.

Param[] params ;
The list of parameters to the function. See the Param struct above. This will always be at least one element long, and element 0 will always be the 'this' parameter.

bool isVararg ;
Indicates whether or not this function is variadic.

Statement code ;
The body of the function. In the case of lambda functions (i.e. "function(x) = x * x"), this is a ReturnStmt with one expression, the expression that is the lambda's body. Otherwise, it must (($B must)) be a BlockStmt. This will be checked upon construction.

this(ICompiler c, CompileLoc location, Identifier name, Param[] params, bool isVararg, Statement code);


class NamespaceDef : minid.ast.AstNode;
Like the ClassDef and FuncDef classes, this represents the common attributes of both namespace literals and declarations.

struct Field ;
Represents a single field in the namespace. Remember that functions are fields too.

char[] name ;
The name of the field. This corresponds to either the name of a data member or the name of a function.

Expression initializer ;
The initializer of the field. This will never be null. If a field is declared in a namespace but not given a value, a NullExp will be inserted into this field.

Identifier name ;
The name of the namespace. This field will never be null.

Expression parent ;
The namespace which will become the parent of this namespace. This field can be null, in which case the namespace's parent will be set to the environment of the current function.

Field[] fields ;
The fields in this namespace, in an arbitrary order. See the Field struct above.

this(ICompiler c, CompileLoc location, CompileLoc endLocation, Identifier name, Expression parent, Field[] fields);


class Module : minid.ast.AstNode;
Represents a MiniD module. This node forms the root of an AST when a module is compiled.

char[][] names ;
The name of this module. This is an array of strings, each element of which is one piece of a dotted name. This array will always be at least one element long.

Statement statements ;
The statements which make up the body of the module. Normally this will be a block statement but it can be other kinds due to semantic analysis.

Decorator decorator ;


this(ICompiler c, CompileLoc location, CompileLoc endLocation, char[][] names, Statement statements, Decorator decorator);


abstract class Statement : minid.ast.AstNode;
The base class for all statements.

enum Protection ;
Defines the types of protection possible for class, function, namespace, and variable declarations.

Default
This indicates "default" protection, which means global at module-level scope and local everywhere else.

Local
This forces local protection.

Global
This forces global protection.

class VarDecl : minid.ast.Statement;
Represents local and global variable declarations.

Protection protection ;
What protection level this declaration uses.

Identifier[] names ;
The list of names to be declared. This will always have at least one name.

Expression[] initializer ;
The initializer for the variables. This can be empty, in which case the variables will be all be initialized to null.

this(ICompiler c, CompileLoc location, CompileLoc endLocation, Protection protection, Identifier[] names, Expression[] initializer);


class Decorator : minid.ast.AstNode;


Expression func ;


Expression context ;


Expression[] args ;


Decorator nextDec ;


this(ICompiler c, CompileLoc location, CompileLoc endLocation, Expression func, Expression context, Expression[] args, Decorator nextDec);


class FuncDecl : minid.ast.Statement;
This node represents a function declaration. Note that there are some places in the grammar which look like function declarations (like inside classes and namespaces) but which actually are just syntactic sugar. This is for actual declarations.

Protection protection ;
What protection level this declaration uses.

FuncDef def ;
The "guts" of the function declaration.

Decorator decorator ;


this(ICompiler c, CompileLoc location, Protection protection, FuncDef def, Decorator decorator);
The protection parameter can be any kind of protection.

class ClassDecl : minid.ast.Statement;
This node represents a class declaration.

Protection protection ;
What protection level this declaration uses.

ClassDef def ;
The actual "guts" of the class.

Decorator decorator ;


this(ICompiler c, CompileLoc location, Protection protection, ClassDef def, Decorator decorator);
The protection parameter can be any kind of protection.

class NamespaceDecl : minid.ast.Statement;
This node represents a namespace declaration.

Protection protection ;
What protection level this declaration uses.

NamespaceDef def ;
The "guts" of the namespace.

Decorator decorator ;


this(ICompiler c, CompileLoc location, Protection protection, NamespaceDef def, Decorator decorator);
The protection parameter can be any level of protection.

class AssertStmt : minid.ast.Statement;
This node represents an assertion statement.

Expression cond ;
A required expression that is the condition checked by the assertion.

Expression msg ;
An optional message that will be used if the assertion fails. This member can be null, in which case a message will be generated for the assertion based on its location. If it's not null, it must evaluate to a string.

this(ICompiler c, CompileLoc location, CompileLoc endLocation, Expression cond, Expression msg = null);


class ImportStmt : minid.ast.Statement;
This node represents an import statement.

Identifier importName ;
An optional renaming of the import. This member can be null, in which case no renaming is done. In the code "import x = y;", this member corresponds to "x".

Expression expr ;
The expression which evaluates to a string containing the name of the module to import. The statement "import a.b.c" is actually syntactic sugar for "import("a.b.c")", so expr will be a StringExp in this case. This expression is checked (if it's constant) to ensure that it's a string when constant folding occurs.

Identifier[] symbols ;
An optional list of symbols to import from the module. In the code "import x : a, b, c", this corresponds to "a, b, c".

Identifier[] symbolNames ;
A parallel array to the symbols array. This holds the names of the symbols as they should be called in this module. The code "import x : a, b" is sugar for "import x : a = a, b = b". In the code "import x : y = a, z = b", this array corresponds to "y, z".

this(ICompiler c, CompileLoc location, CompileLoc endLocation, Identifier importName, Expression expr, Identifier[] symbols, Identifier[] symbolNames);


class BlockStmt : minid.ast.Statement;
This node represents a block statement (i.e. one surrounded by curly braces).

Statement[] statements ;
The list of statements contained in the braces.

this(ICompiler c, CompileLoc location, CompileLoc endLocation, Statement[] statements);


class ScopeStmt : minid.ast.Statement;
A node which doesn't correspond to a grammar element. This indicates a new nested scope. An example of where this would be used is in an anonymous scope with some code in it. All it does is affects the codegen of the contained statement by beginning a new scope before it and ending the scope after it.

If you're looking for the "scope(exit)" kind of statements, look at the ScopeActionStmt node.

Statement statement ;
The statement contained within this scope. Typically a block statement , but can be anything.

this(ICompiler c, Statement statement);


class ExpressionStmt : minid.ast.Statement;
A statement that holds a side-effecting expression to be evaluated as a statement, such as a function call, assignment etc.

Expression expr ;
The expression to be evaluated for this statement. This must be a side-effecting expression, including function calls, yields, and assignments. Conditional (?:) expressions and logical or and logical and (|| and &&) expressions are also allowed, providing at least one component is side-effecting.

This class does not check that this expression is side-effecting; that is up to you.

this(ICompiler c, CompileLoc location, CompileLoc endLocation, Expression expr);


this(ICompiler c, Expression expr);


class IfStmt : minid.ast.Statement;
This node represents an if statement.

IdentExp condVar ;
An optional variable to declare inside the statement's condition which will take on the value of the condition. In the code "if(local x = y < z){}", this corresponds to "x". This member may be null, in which case there is no variable there.

Expression condition ;
The condition to test.

Statement ifBody ;
The code to execute if the condition evaluates to true.

Statement elseBody ;
If there is an else clause, this is the code to execute if the condition evaluates to false. If there is no else clause, this member is null.

this(ICompiler c, CompileLoc location, CompileLoc endLocation, IdentExp condVar, Expression condition, Statement ifBody, Statement elseBody);


class WhileStmt : minid.ast.Statement;
This node represents a while loop.

IdentExp condVar ;
An optional variable to declare inside the statement's condition which will take on the value of the condition. In the code "while(local x = y < z){}", this corresponds to "x". This member may be null, in which case there is no variable there.

Expression condition ;
The condition to test.

Statement code ;
The code inside the loop.

this(ICompiler c, CompileLoc location, IdentExp condVar, Expression condition, Statement code);


class DoWhileStmt : minid.ast.Statement;
This node corresponds to a do-while loop.

Statement code ;
The code inside the loop.

Expression condition ;
The condition to test at the end of the loop.

this(ICompiler c, CompileLoc location, CompileLoc endLocation, Statement code, Expression condition);


class ForStmt : minid.ast.Statement;
This node represents a C-style for loop.

struct Init ;
There are two types of initializers possible in the first clause of the for loop header: variable declarations and expression statements. This struct holds one or the other.

bool isDecl ;
If true, the 'decl' member should be used; else, the 'init' member should be used.

Statement stmt ;
If isDecl is false, this holds an expression statement to be evaluated at the beginning of the loop.

VarDecl decl ;
If isDecl is true, this holds a variable declaration to be performed at the beginning of the loop.

Init[] init ;
A list of 0 or more initializers (the first clause of the foreach header).

Expression condition ;
The condition to test at the beginning of each iteration of the loop. This can be null, in which case the only way to get out of the loop is to break, return, or throw an exception.

Statement[] increment ;
A list of 0 or more increment expression statements to be evaluated at the end of each iteration of the loop.

Statement code ;
The code inside the loop.

this(ICompiler c, CompileLoc location, Init[] init, Expression cond, Statement[] inc, Statement code);


class ForNumStmt : minid.ast.Statement;
This node represents a numeric for loop, i.e. "for(i: 0 .. 10){}".

Identifier index ;
The name of the index variable.

Expression lo ;
The lower bound of the loop (the value before the ".."). If constant, it must be an int.

Expression hi ;
The upper bound of the loop (the value after the ".."). If constant, it must be an int.

Expression step ;
The step value of the loop. If specified, this is the value after the comma after the upper bound. If not specified, this is given an IntExp of value 1. This member is never null. If constant, it must be an int.

Statement code ;
The code inside the loop.

this(ICompiler c, CompileLoc location, Identifier index, Expression lo, Expression hi, Expression step, Statement code);


class ForeachStmt : minid.ast.Statement;
This node represents a foreach loop.

Identifier[] indices ;
The list of index names (the names before the semicolon). This list is always at least two elements long. This is because when you write a foreach loop with only one index, an implicit dummy index is inserted before it.

Expression[] container ;
The container (the stuff after the semicolon). This array can be 1, 2, or 3 elements long. Semantically, the first element is the "iterator", the second the "state", and the third the "index". However MiniD will automatically call opApply on the "iterator" if it's not a function, so this can function like a foreach loop in D.

Statement code ;
The code inside the loop.

this(ICompiler c, CompileLoc location, Identifier[] indices, Expression[] container, Statement code);


class SwitchStmt : minid.ast.Statement;
This node represents a switch statement.

Expression condition ;
The value to switch on.

CaseStmt[] cases ;
A list of cases . This is always at least one element long.

DefaultStmt caseDefault ;
An optional default case. This member can be null.

this(ICompiler c, CompileLoc location, CompileLoc endLocation, Expression condition, CaseStmt[] cases, DefaultStmt caseDefault);


class CaseStmt : minid.ast.Statement;
This node represents a single case statement within a switch statement.

CaseCond[] conditions ;
The list of values which will cause execution to jump to this case. In the code "case 1, 2, 3:" this corresponds to "1, 2, 3". This will always be at least one element long.

Expression highRange ;
If this member is null, this is a "normal" case statement. If this member is non-null, this is a ranged case statement like "case 1 .. 10:". In that case, the 'conditions' member will be exactly one element long and will contain the low range value.

Statement code ;
The code of the case statement.

this(ICompiler c, CompileLoc location, CompileLoc endLocation, CaseCond[] conditions, Expression highRange, Statement code);


class DefaultStmt : minid.ast.Statement;
This node represents the default case in a switch statement.

Statement code ;
The code of the statement.

this(ICompiler c, CompileLoc location, CompileLoc endLocation, Statement code);


class ContinueStmt : minid.ast.Statement;
This node represents a continue statement.

this(ICompiler c, CompileLoc location);


class BreakStmt : minid.ast.Statement;
This node represents a break statement.

this(ICompiler c, CompileLoc location);


class ReturnStmt : minid.ast.Statement;
This node represents a return statement.

Expression[] exprs ;
The list of expressions to return. This array may have 0 or more elements.

this(ICompiler c, CompileLoc location, CompileLoc endLocation, Expression[] exprs);


class TryStmt : minid.ast.Statement;
This node represents a try-catch-finally statement. It holds not only the try clause, but either or both the catch and finally clauses.

Statement tryBody ;
The body of code to try.

Identifier catchVar ;
The variable to use in the catch block. In the code "try{}catch(e){}", this corresponds to 'e'. This member can be null, in which case there is no catch block (and therefore there must be a finally block). If this member is non-null, catchBody must also be non-null.

Statement catchBody ;
The body of the catch block. If this member is non-null, catchVar must also be non-null. If this member is null, finallyBody must be non-null.

Statement finallyBody ;
The body of the finally block. If this member is null, catchVar and catchBody must be non-null.

this(ICompiler c, CompileLoc location, CompileLoc endLocation, Statement tryBody, Identifier catchVar, Statement catchBody, Statement finallyBody);


class ThrowStmt : minid.ast.Statement;
This node represents a throw statement.

Expression exp ;
The value that should be thrown.

this(ICompiler c, CompileLoc location, Expression exp);


class ScopeActionStmt : minid.ast.Statement;
This node represents a scope (exit, success, or failure) statement.

Exit
scope(exit)

Success
scope(success)

Failure
scope(failure)

ubyte type ;
One of the above constants, indicates which kind of scope statement this is.

Statement stmt ;
The statement which will be executed if this scope statement is run.

this(ICompiler c, CompileLoc location, ubyte type, Statement stmt);


class AssignStmt : minid.ast.Statement;
This node represents normal assignment, either single- or multi-target.

Expression[] lhs ;
The list of destination expressions. This list always has at least one element. This list must contain only expressions which can be LHSes. That will be checked at codegen time.

Expression[] rhs ;
The right-hand side of the assignment. Must always have at least 1 item. This is not checked by the ctor.

this(ICompiler c, CompileLoc location, CompileLoc endLocation, Expression[] lhs, Expression[] rhs);


abstract class OpAssignStmt : minid.ast.Statement;
This node handles the common features of the reflexive assignments, as well as conditional assignment (?=).

Expression lhs ;
The left-hand-side of the assignment. This may not be a constant value or '#vararg', and if this is a conditional assignment, it may not be 'this'. These conditions will be checked at codegen.

Expression rhs ;
The right-hand-side of the assignment.

this(ICompiler c, CompileLoc location, CompileLoc endLocation, AstTag type, Expression lhs, Expression rhs);


class AddAssignStmt : minid.ast.OpAssignStmt;
This node represents addition assignment (+=).

this(ICompiler c, CompileLoc location, CompileLoc endLocation, Expression lhs, Expression rhs);


class SubAssignStmt : minid.ast.OpAssignStmt;
This node represents subtraction assignment (-=).

this(ICompiler c, CompileLoc location, CompileLoc endLocation, Expression lhs, Expression rhs);


class CatAssignStmt : minid.ast.Statement;
This node represents concatenation assignment (~=).

Expression lhs ;
The left-hand-side of the assignment. The same constraints apply here as for other reflexive assignments.

Expression rhs ;
The right-hand-side of the assignment.

this(ICompiler c, CompileLoc location, CompileLoc endLocation, Expression lhs, Expression rhs);


class MulAssignStmt : minid.ast.OpAssignStmt;
This node represents multiplication assignment (*=).

this(ICompiler c, CompileLoc location, CompileLoc endLocation, Expression lhs, Expression rhs);


class DivAssignStmt : minid.ast.OpAssignStmt;
This node represents division assignment (/=).

this(ICompiler c, CompileLoc location, CompileLoc endLocation, Expression lhs, Expression rhs);


class ModAssignStmt : minid.ast.OpAssignStmt;
This node represents modulo assignment (%=).

this(ICompiler c, CompileLoc location, CompileLoc endLocation, Expression lhs, Expression rhs);


class OrAssignStmt : minid.ast.OpAssignStmt;
This node represents bitwise OR assignment (|=).

this(ICompiler c, CompileLoc location, CompileLoc endLocation, Expression lhs, Expression rhs);


class XorAssignStmt : minid.ast.OpAssignStmt;
This node represents bitwise XOR assignment (^=).

this(ICompiler c, CompileLoc location, CompileLoc endLocation, Expression lhs, Expression rhs);


class AndAssignStmt : minid.ast.OpAssignStmt;
This node represents bitwise AND assignment (&=).

this(ICompiler c, CompileLoc location, CompileLoc endLocation, Expression lhs, Expression rhs);


class ShlAssignStmt : minid.ast.OpAssignStmt;
This node represents bitwise left-shift assignment (<<=).

this(ICompiler c, CompileLoc location, CompileLoc endLocation, Expression lhs, Expression rhs);


class ShrAssignStmt : minid.ast.OpAssignStmt;
This node represents bitwise right-shift assignment (>>=).

this(ICompiler c, CompileLoc location, CompileLoc endLocation, Expression lhs, Expression rhs);


class UShrAssignStmt : minid.ast.OpAssignStmt;
This node represents bitwise unsigned right-shift assignment (>>>=).

this(ICompiler c, CompileLoc location, CompileLoc endLocation, Expression lhs, Expression rhs);


class CondAssignStmt : minid.ast.OpAssignStmt;
This node represents conditional assignment (?=).

this(ICompiler c, CompileLoc location, CompileLoc endLocation, Expression lhs, Expression rhs);


class IncStmt : minid.ast.Statement;
This node represents an increment, either prefix or postfix (++a or a++).

Expression exp ;
The expression to modify. The same constraints apply as for reflexive assignments.

this(ICompiler c, CompileLoc location, CompileLoc endLocation, Expression exp);


class DecStmt : minid.ast.Statement;
This node represents a decrement, either prefix or postfix (--a or a--).

Expression exp ;
The expression to modify. The same constraints apply as for reflexive assignments.

this(ICompiler c, CompileLoc location, CompileLoc endLocation, Expression exp);


class TypecheckStmt : minid.ast.Statement;
This node is an internal node inserted in function bodies if parameter type checking is enabled.

FuncDef def ;


this(ICompiler c, CompileLoc location, FuncDef def);


abstract class Expression : minid.ast.AstNode;
The base class for all expressions.

this(ICompiler c, CompileLoc location, CompileLoc endLocation, AstTag type);


void checkToNothing (ICompiler c);
Ensure that this expression can be evaluated to nothing, i.e. that it can exist on its own. Throws an exception if not.

bool hasSideEffects ();
Returns whether or not this expression has side effects. If this returns false, checkToNothing will throw an error.

void checkMultRet (ICompiler c);
Ensure that this expression can give multiple return values. If it can't, throws an exception.

bool isMultRet ();
Returns whether this expression can give multiple return values. If this returns false, checkMultRet will throw an error.

void checkLHS (ICompiler c);
Ensure that this expression can be the left-hand side of an assignment. If it can't, throws an exception.

bool isLHS ();
Returns whether this expression can be the left-hand side of an assignment. If this returns false, checkLHS will throw an error.

bool isConstant ();
Returns whether this expression is a constant value.

bool isNull ();
Returns whether this expression is 'null'.

bool isBool ();
Returns whether this expression is a boolean constant.

bool asBool ();
Returns this expression as a boolean constant, if possible. assert(false)s otherwise.

bool isInt ();
Returns whether this expression is an integer constant.

long asInt ();
Returns this expression as an integer constant, if possible. assert(false)s otherwise.

bool isFloat ();
Returns whether this expression is a floating point constant.

double asFloat ();
Returns this expression as a floating point constant, if possible. assert(false)s otherwise.

bool isChar ();
Returns whether this expression is a character constant.

dchar asChar ();
Returns this expression as a character constant, if possible. assert(false)s otherwise.

bool isString ();
Returns whether this expression is a string constant.

char[] asString ();
Returns this expression as a string constant, if possible. assert(false)s otherwise.

bool isTrue ();
If this expression is a constant value, returns whether this expression would evaluate as true according to MiniD's definition of truth. Otherwise returns false.

class CondExp : minid.ast.Expression;
This node represents a conditional (?:) expression.

Expression cond ;
The first expression, which comes before the question mark.

Expression op1 ;
The second expression, which comes between the question mark and the colon.

Expression op2 ;
The third expression, which comes after the colon.

this(ICompiler c, CompileLoc location, CompileLoc endLocation, Expression cond, Expression op1, Expression op2);


abstract class BinaryExp : minid.ast.Expression;
The base class for binary expressions. Many of them share some or all of their code generation phases, as well has having other similar properties.

Expression op1 ;
The left-hand operand.

Expression op2 ;
The right-hand operand.

this(ICompiler c, CompileLoc location, CompileLoc endLocation, AstTag type, Expression op1, Expression op2);


class OrOrExp : minid.ast.BinaryExp;
This node represents a logical or (||) expression.

class AndAndExp : minid.ast.BinaryExp;
This node represents a logical or (||) expression.

class OrExp : minid.ast.BinaryExp;
This node represents a bitwise or expression.

class XorExp : minid.ast.BinaryExp;
This node represents a bitwise xor expression.

class AndExp : minid.ast.BinaryExp;
This node represents a bitwise and expression.

abstract class BaseEqualExp : minid.ast.BinaryExp;
This class serves as a base class for all equality expressions.

class EqualExp : minid.ast.BaseEqualExp;
This node represents an equality (==) expression.

class NotEqualExp : minid.ast.BaseEqualExp;
This node represents an inequality (!=) expression.

class IsExp : minid.ast.BaseEqualExp;
This node represents an identity (is) expression.

class NotIsExp : minid.ast.BaseEqualExp;
This node represents a nonidentity (!is) expression.

abstract class BaseCmpExp : minid.ast.BinaryExp;
This class serves as a base class for comparison expressions.

class LTExp : minid.ast.BaseCmpExp;
This node represents a less-than (<) comparison.

class LEExp : minid.ast.BaseCmpExp;
This node represents a less-than-or-equals (<=) comparison.

class GTExp : minid.ast.BaseCmpExp;
This node represents a greater-than (>) comparison.

class GEExp : minid.ast.BaseCmpExp;
This node represents a greater-than-or-equals (>=) comparison.

class Cmp3Exp : minid.ast.BinaryExp;
This node represents a three-way comparison (<=>) expression.

class AsExp : minid.ast.BinaryExp;
This node represents an 'as' expression.

class InExp : minid.ast.BinaryExp;
This node represents an 'in' expression.

class NotInExp : minid.ast.BinaryExp;
This node represents a '!in' expression.

class ShlExp : minid.ast.BinaryExp;
This node represents a bitwise left-shift (<<) expression.

class ShrExp : minid.ast.BinaryExp;
This node represents a bitwise right-shift (>>) expression.

class UShrExp : minid.ast.BinaryExp;
This node represents a bitwise unsigned right-shift (>>>) expression.

class AddExp : minid.ast.BinaryExp;
This node represents an addition (+) expression.

class SubExp : minid.ast.BinaryExp;
This node represents a subtraction (-) expression.

class CatExp : minid.ast.BinaryExp;
This node represents a concatenation (~) expression.

class MulExp : minid.ast.BinaryExp;
This node represents a multiplication (*) expression.

class DivExp : minid.ast.BinaryExp;
This node represents a division (/) expression.

class ModExp : minid.ast.BinaryExp;
This node represents a modulo (%) expression.

abstract class UnExp : minid.ast.Expression;
This class is the base class for unary expressions. These tend to share some code generation, as well as all having a single operand.

Expression op ;
The operand of the expression.

this(ICompiler c, CompileLoc location, CompileLoc endLocation, AstTag type, Expression operand);


class NegExp : minid.ast.UnExp;
This node represents a negation (-a).

class NotExp : minid.ast.UnExp;
This node represents a logical not expression (!a).

class ComExp : minid.ast.UnExp;
This node represents a bitwise complement expression (~a).

class LenExp : minid.ast.UnExp;
This node represents a length expression (#a).

class CoroutineExp : minid.ast.UnExp;
This node represents the coroutine expression (coroutine a).

abstract class PostfixExp : minid.ast.UnExp;
This class is the base class for postfix expressions, that is expressions which kind of attach to the end of other expressions. It inherits from UnExp, so that the single operand becomes the expression to which the postfix expression becomes attached.

this(ICompiler c, CompileLoc location, CompileLoc endLocation, AstTag type, Expression operand);


class DotExp : minid.ast.PostfixExp;
This node represents dot expressions, in both the dot-ident (a.x) and dot-expression (a.(expr)) forms. These correspond to field access.

Expression name ;
The name . This can be any expression, as long as it evaluates to a string. An expression like "a.x" is sugar for "a.("x")", so this will be a string literal in that case.

this(ICompiler c, Expression operand, Expression name);


class DotSuperExp : minid.ast.PostfixExp;
This node corresponds to the super expression (a.super).

class IndexExp : minid.ast.PostfixExp;
This node corresponds to an indexing operation (a[x]).

Expression index ;
The index of the operation (the value inside the brackets).

this(ICompiler c, CompileLoc endLocation, Expression operand, Expression index);


class SliceExp : minid.ast.PostfixExp;
This node corresponds to a slicing operation (a[x .. y]).

Expression loIndex ;
The low index of the slice. If no low index is given, this will be a NullExp. This member will therefore never be null.

Expression hiIndex ;
The high index of the slice. If no high index is given, this will be a NullExp. This member will therefore never be null.

this(ICompiler c, CompileLoc endLocation, Expression operand, Expression loIndex, Expression hiIndex);


class CallExp : minid.ast.PostfixExp;
This node corresponds to a non-method function call (f()).

Expression context ;
The context to be used when calling the function. This corresponds to 'x' in the expression "f(with x)". If this member is null, a context of 'null' will be passed to the function.

Expression[] args ;
The list of arguments to be passed to the function. This can be 0 or more elements.

this(ICompiler c, CompileLoc endLocation, Expression operand, Expression context, Expression[] args);


class MethodCallExp : minid.ast.PostfixExp;
This class corresponds to a method call in either form (a.f() or a.("f")()).

Expression method ;


Expression context ;
The context to be used when calling the method. This corresponds to 'x' in the expression "a.f(with x)". If this member is null, there is no custom context and the context will be determined automatically.

Expression[] args ;
The list of argument to pass to the method. This can have 0 or more elements.

bool isSuperCall ;
If this member is true, 'op' will be null (and will be interpreted as a "this").

this(ICompiler c, CompileLoc location, CompileLoc endLocation, Expression operand, Expression method, Expression context, Expression[] args, bool isSuperCall);


class PrimaryExp : minid.ast.Expression;
The base class for primary expressions.

this(ICompiler c, CompileLoc location, AstTag type);


this(ICompiler c, CompileLoc location, CompileLoc endLocation, AstTag type);


class IdentExp : minid.ast.PrimaryExp;
An identifier expression. These can refer to locals, upvalues, or globals.

Identifier name ;
The identifier itself.

this(ICompiler c, Identifier i);
Create an ident exp from an identifier object.

class ThisExp : minid.ast.PrimaryExp;
Represents the ubiquitous 'this' variable.

this(ICompiler c, CompileLoc location);


class NullExp : minid.ast.PrimaryExp;
Represents the 'null' literal.

this(ICompiler c, CompileLoc location);


class BoolExp : minid.ast.PrimaryExp;
Represents either a 'true' or 'false' literal.

bool value ;
The actual value of the literal.

this(ICompiler c, CompileLoc location, bool value);


class VarargExp : minid.ast.PrimaryExp;
Represents the 'vararg' exp outside of a special form (i.e. not #vararg, vararg[x], or vararg[x .. y]).

this(ICompiler c, CompileLoc location);


class VargLenExp : minid.ast.PrimaryExp;
This node represents the variadic-length expression (#vararg).

this(ICompiler c, CompileLoc location, CompileLoc endLocation);


class VargIndexExp : minid.ast.PrimaryExp;
This node corresponds to a variadic indexing operation (vararg[x]).

Expression index ;
The index of the operation (the value inside the brackets).

this(ICompiler c, CompileLoc location, CompileLoc endLocation, Expression index);


class VargSliceExp : minid.ast.PrimaryExp;
This node represents a variadic slice operation (vararg[x .. y]).

Expression loIndex ;
The low index of the slice.

Expression hiIndex ;
The high index of the slice.

this(ICompiler c, CompileLoc location, CompileLoc endLocation, Expression loIndex, Expression hiIndex);


class IntExp : minid.ast.PrimaryExp;
Represents an integer literal.

mdint value ;
The actual value of the literal.

this(ICompiler c, CompileLoc location, mdint value);


class FloatExp : minid.ast.PrimaryExp;
Represents a floating-point literal.

mdfloat value ;
The actual value of the literal.

this(ICompiler c, CompileLoc location, mdfloat value);


class CharExp : minid.ast.PrimaryExp;
Represents a character literal.

dchar value ;
The actual character of the literal.

this(ICompiler c, CompileLoc location, dchar value);


class StringExp : minid.ast.PrimaryExp;
Represents a string literal.

char[] value ;
The actual value of the literal.

this(ICompiler c, CompileLoc location, char[] value);


class FuncLiteralExp : minid.ast.PrimaryExp;
Represents a function literal.

FuncDef def ;
The actual "guts" of the function.

this(ICompiler c, CompileLoc location, FuncDef def);


class ClassLiteralExp : minid.ast.PrimaryExp;
Represents a class literal.

ClassDef def ;
The actual "guts" of the class.

this(ICompiler c, CompileLoc location, ClassDef def);


class ParenExp : minid.ast.PrimaryExp;
Represents an expression inside a pair of parentheses. Besides controlling order-of- operations, this expression will make a multiple-return-value expression return exactly one result instead. Thus 'vararg' can give 0 or more values but '(vararg)' gives exactly one (null in the case that there are no varargs).

Expression exp ;
The parenthesized expression.

this(ICompiler c, CompileLoc location, CompileLoc endLocation, Expression exp);


class TableCtorExp : minid.ast.PrimaryExp;
This node represents a table literal.

Field[] fields ;
An array of fields . The first value in each element is the key; the second the value.

this(ICompiler c, CompileLoc location, CompileLoc endLocation, Field[] fields);


class ArrayCtorExp : minid.ast.PrimaryExp;
This node represents an array literal.

Expression[] values ;
The list of values .

this(ICompiler c, CompileLoc location, CompileLoc endLocation, Expression[] values);


class NamespaceCtorExp : minid.ast.PrimaryExp;
This node represents a namespace literal.

NamespaceDef def ;
The actual "guts" of the namespace.

this(ICompiler c, CompileLoc location, NamespaceDef def);


class YieldExp : minid.ast.PrimaryExp;
This node represents a yield expression, such as "yield(1, 2, 3)".

Expression[] args ;
The arguments inside the yield expression.

this(ICompiler c, CompileLoc location, CompileLoc endLocation, Expression[] args);


abstract class ForComprehension : minid.ast.AstNode;
This is the base class for both numeric and generic for comprehensions inside array and table comprehensions.

IfComprehension ifComp ;
Optional if comprehension that follows this. This member may be null.

ForComprehension forComp ;
Optional for comprehension that follows this. This member may be null.

this(ICompiler c, CompileLoc location, CompileLoc endLocation, AstTag tag);


class ForeachComprehension : minid.ast.ForComprehension;
This node represents a foreach comprehension in an array or table comprehension, i.e. in the code "[x for x in a]", it represents "for x in a".

Identifier[] indices ;
Expression[] container ;
These members are the same as for a ForeachStmt.

this(ICompiler c, CompileLoc location, Identifier[] indices, Expression[] container, IfComprehension ifComp, ForComprehension forComp);


class ForNumComprehension : minid.ast.ForComprehension;
This node represents a numeric for comprehension in an array or table comprehension, i.e. in the code "[x for x in 0 .. 10]" this represents "for x in 0 .. 10".

Identifier index ;
Expression lo ;
Expression hi ;
Expression step ;
These members are the same as for a ForNumStmt.

this(ICompiler c, CompileLoc location, Identifier index, Expression lo, Expression hi, Expression step, IfComprehension ifComp, ForComprehension forComp);


class IfComprehension : minid.ast.AstNode;
This node represents an if comprehension an an array or table comprehension, i.e. in the code "[x for x in a if x < 10]", this represents "if x < 10".

Expression condition ;
The condition to test.

this(ICompiler c, CompileLoc location, Expression condition);


class ArrayComprehension : minid.ast.PrimaryExp;
This node represents an array comprehension, such as "[x for x in a]".

Expression exp ;
The expression which is executed as the innermost thing in the loop and whose values are used to construct the array.

ForComprehension forComp ;
The root of the comprehension tree.

this(ICompiler c, CompileLoc location, CompileLoc endLocation, Expression exp, ForComprehension forComp);


class TableComprehension : minid.ast.PrimaryExp;
This node represents a table comprehension, such as "{[v] = k for k, v in a}".

Expression key ;
The key expression. This is the thing in the brackets at the beginning.

Expression value ;
The value expression. This is the thing after the equals sign at the beginning.

ForComprehension forComp ;
The root of the comprehension tree.

this(ICompiler c, CompileLoc location, CompileLoc endLocation, Expression key, Expression value, ForComprehension forComp);


Page was generated with on Thu Jul 16 22:47:46 2009