Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using a local clone.

dmd.cond

Evaluate compile-time conditionals, such as static if version and debug.
Authors:

Source cond.d

enum Include: ubyte;
notComputed
not computed yet
yes
include the conditional code
no
do not include the conditional code
class StaticForeach: dmd.rootobject.RootObject;
Implements common functionality for StaticForeachDeclaration and StaticForeachStatement This performs the necessary lowerings before dmd.statementsem.makeTupleForeach can be used to expand the corresponding static foreach declaration or statement.
ForeachStatement aggrfe;
Not null iff the static foreach is over an aggregate. In this case, it contains the corresponding ForeachStatement. For StaticForeachDeclaration, the body is null.
ForeachRangeStatement rangefe;
Not null iff the static foreach is over a range. Exactly one of the aggrefe and rangefe fields is not null. See aggrfe field for more details.
bool needExpansion;
true if it is necessary to expand a tuple into multiple variables (see lowerNonArrayAggregate).
Expression wrapAndCall(Loc loc, Statement s);
Wrap a statement into a function literal and call it.
Parameters:
Loc loc The source location.
Statement s The statement.
Returns:
AST of the expression (){ s; }() with location loc.
Statement createForeach(Loc loc, Parameters* parameters, Statement s);
Create a foreach statement from aggrefe/rangefe with given foreach variables and body s.
Parameters:
Loc loc The source location.
Parameters* parameters The foreach variables.
Statement s The foreach body.
Returns:
foreach (parameters; aggregate) s; or foreach (parameters; lower .. upper) s; Where aggregate/lower, upper are as for the current StaticForeach.
TypeStruct createTupleType(Loc loc, Expressions* e, Scope* sc);
For a static foreach with multiple loop variables, the aggregate is lowered to an array of tuples. As D does not have built-in tuples, we need a suitable tuple type. This generates a struct that serves as the tuple type. This type is only used during CTFE and hence its typeinfo will not go to the object file.
Parameters:
Loc loc The source location.
Expressions* e The expressions we wish to store in the tuple.
Scope* sc The current scope.
Returns:
A struct type of the form struct Tuple { typeof(AliasSeq!(e)) tuple; }
@safe Expression createTuple(Loc loc, TypeStruct type, Expressions* e);
Create the AST for an instantiation of a suitable tuple type.
Parameters:
Loc loc The source location.
TypeStruct type A Tuple type, created with createTupleType.
Expressions* e The expressions we wish to store in the tuple.
Returns:
An AST for the expression Tuple(e).
bool ready();
Returns:
true iff ready to call dmd.statementsem.makeTupleForeach.
abstract class DVCondition: dmd.cond.Condition;
class DebugCondition: dmd.cond.DVCondition;
deprecated static void addGlobalIdent(const(char)* ident);

static void addGlobalIdent(string ident);

static void addGlobalIdent(const(char)[] ident);
Add an user-supplied identifier to the list of global debug identifiers
Can be called from either the driver or a debug = Ident; statement. Unlike version identifier, there isn't any reserved debug identifier so no validation takes place.
Parameters:
const(char)* ident identifier to add
@safe this(Loc loc, Module mod, Identifier ident);
Instantiate a new DebugCondition
Parameters:
Module mod Module this node belongs to
Identifier ident Identifier required for this condition to pass. If null, this conditiion will use an integer level.
Loc loc Location in the source file
class VersionCondition: dmd.cond.DVCondition;
Node to represent a version condition
A version condition is of the form:
version (Identifier)
In user code. This class also provides means to add version identifier to the list of global (cross module) identifiers.
static void checkReserved(Loc loc, const(char)[] ident);
Raises an error if a version identifier is reserved.
Called when setting a version identifier, e.g. -version=identifier parameter to the compiler or version = Foo in user code.
Parameters:
Loc loc Where the identifier is set
const(char)[] ident identifier being checked (ident[$] must be '\0')
deprecated static void addGlobalIdent(const(char)* ident);

static void addGlobalIdent(string ident);

static void addGlobalIdent(const(char)[] ident);
Add an user-supplied global identifier to the list
Only called from the driver for -version=Ident parameters. Will raise an error if the identifier is reserved.
Parameters:
const(char)* ident identifier to add
deprecated static void addPredefinedGlobalIdent(const(char)* ident);

static void addPredefinedGlobalIdent(string ident);

static void addPredefinedGlobalIdent(const(char)[] ident);
Add any global identifier to the list, without checking if it's predefined
Only called from the driver after platform detection, and internally.
Parameters:
const(char)* ident identifier to add (ident[$] must be '\0')
@safe this(Loc loc, Module mod, Identifier ident);
Instantiate a new VersionCondition
Parameters:
Module mod Module this node belongs to
Identifier ident Identifier required for this condition to pass. If null, this conditiion will use an integer level.
Loc loc Location in the source file
class StaticIfCondition: dmd.cond.Condition;
pure nothrow @safe bool findCondition(ref Identifiers ids, Identifier ident);
Find ident in an array of identifiers.
Parameters:
Identifiers ids array of identifiers
Identifier ident identifier to search for
Returns:
true if found