Report a bug
If you spot a problem with this page, click here to create a GitHub 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.backend.type

Types for the back end
Compiler implementation of the D programming language.
Authors:
enum TF: ushort;
Values for Tflags:
nothrow @nogc @trusted targ_size_t type_size(const type* t);
Compute size of type in bytes.
Parameters:
type* t type
Returns:
size
nothrow @trusted uint type_alignsize(const(type)* t);
Return the size of a type for alignment purposes.
nothrow @trusted bool type_zeroSize(const type* t, tym_t tyf);
Compute special zero sized struct.
Parameters:
type* t type of parameter
tym_t tyf function type
Returns:
true if t is a zero size struct
nothrow @safe uint type_parameterSize(const type* t, tym_t tyf);
Compute the size of a single parameter.
Parameters:
type* t type of parameter
tym_t tyf function type
Returns:
size in bytes
nothrow @trusted uint type_paramsize(const type* t);
Compute the total size of parameters for function call. Used for stdcall name mangling. Note that hidden parameters do not contribute to size.
Parameters:
type* t function type
Returns:
total stack usage in bytes
nothrow @nogc @trusted type* type_alloc(tym_t ty);
Create a type & initialize it.

Input ty = TYxxxx

Returns:
pointer to newly created type.
nothrow @nogc @safe type* type_fake(tym_t ty);
Fake a type & initialize it.

Input ty = TYxxxx

Returns:
pointer to newly created type.
nothrow @safe type* type_allocn(tym_t ty, type* tn);
Allocate a type of ty with a Tnext of tn.
nothrow @safe type* type_pointer(type* tnext);
Allocate a pointer type.
Returns:
Tcount already incremented
nothrow @trusted type* type_dyn_array(type* tnext);
Allocate a dynamic array type.
Returns:
Tcount already incremented
nothrow @safe type* type_static_array(targ_size_t dim, type* tnext);
Allocate a static array type.
Returns:
Tcount already incremented
nothrow @trusted type* type_assoc_array(type* tkey, type* tvalue);
Allocate an associative array type, which are key=value pairs
Returns:
Tcount already incremented
nothrow @trusted type* type_delegate(type* tnext);
Allocate a delegate type.
Returns:
Tcount already incremented
nothrow @trusted type* type_function(tym_t tyf, type*[] ptypes, bool variadic, type* tret);
Allocate a function type.
Parameters:
tym_t tyf function type
type*[] ptypes types of the function parameters
bool variadic if ... function
type* tret return type
Returns:
Tcount already incremented
nothrow @trusted type* type_enum(const(char)* name, type* tbase);
Create an enum type.

Input name name of enum tbase "base" type of enum

Returns:
Tcount already incremented
nothrow @trusted type* type_struct_class(const(char)* name, uint alignsize, uint structsize, type* arg1type, type* arg2type, bool isUnion, bool isClass, bool isPOD, bool is0size);
Create a struct/union/class type.
Parameters:
const(char)* name name of struct (this function makes its own copy of the string)
uint alignsize alignment for fields
uint structsize total size of struct
type* arg1type for Sarg1type field
type* arg2type for Sarg2type field
bool isUnion true if a union
bool isClass true if a class
bool isPOD true if Plain Old Data
bool is0size if struct has no fields (even if Sstructsize is 1)
Returns:
Tcount already incremented
nothrow @trusted void type_free(type* t);
Free up data type.
nothrow @trusted type* type_copy(type* tf);
Type type information.
Make copy of a type.
Parameters:
type* tf type to copy
Returns:
copy of tf
nothrow @safe type* type_setty(type** pt, uint newty);
Modify the tym_t field of a type.
nothrow @safe type* type_setmangle(type** pt, Mangle mangle);
Modify the Tmangle field of a type.
nothrow @safe type* type_setcv(type** pt, tym_t cv);
Set/clear const and volatile bits in* pt according to the settings in cv.
nothrow @trusted bool type_embed(type* t, type* u);
Recursively check if type u is embedded in type t.
Returns:
true if embedded
nothrow @trusted void type_print(const type* t);
Pretty-print a type.
nothrow @trusted void param_t_print(scope const param_t* p);
Pretty-print a param_t
nothrow @trusted void param_free(ref param_t[]* pparamlst);
Free parameter list.

Output paramlst = null

nothrow @safe uint param_t_length(scope param_t* p);
Compute number of parameters
nothrow @trusted int typematch(type* t1, type* t2, int relax);
A cheap version of exp2.typematch() and exp2.paramlstmatch(), so that we can get cpp_mangle() to work for MARS. It's less complex because it doesn't do templates and can rely on strict typechecking.
Returns:
!=0 if types match.