tree attribs = NULL_TREE;
- for (size_t i = 0; i < eattrs->dim; i++)
+ for (size_t i = 0; i < eattrs->length; i++)
{
Expression *attr = (*eattrs)[i];
Dsymbol *sym = attr->type->toDsymbol (0);
/* Chain all attribute arguments together. */
tree args = NULL_TREE;
- for (size_t j = 1; j < elems->dim; j++)
+ for (size_t j = 1; j < elems->length; j++)
{
Expression *e = (*elems)[j];
tree t;
/* GCC generic and placeholder built-ins are marked as variadic, yet
have no named parameters, and so can't be represented in D. */
- if (args->dim != 0 || !varargs_p)
+ if (args->length != 0 || !varargs_p)
{
dtype = TypeFunction::create (args, dtype, varargs_p, LINKc);
return dtype->addMod (mod);
{
/* Recursively search through attribute decls. */
Dsymbols *decls = ad->include (NULL, NULL);
- if (decls && decls->dim)
+ if (decls && decls->length)
{
- for (size_t i = 0; i < decls->dim; i++)
+ for (size_t i = 0; i < decls->length; i++)
{
Dsymbol *sym = (*decls)[i];
maybe_set_builtin_1 (sym);
if (!m || !m->members)
return;
- for (size_t i = 0; i < m->members->dim; i++)
+ for (size_t i = 0; i < m->members->length; i++)
{
Dsymbol *sym = (*m->members)[i];
maybe_set_builtin_1 (sym);
tree
build_interface_binfo (tree super, ClassDeclaration *cd, unsigned& offset)
{
- tree binfo = make_tree_binfo (cd->baseclasses->dim);
+ tree binfo = make_tree_binfo (cd->baseclasses->length);
tree ctype = build_ctype (cd->type);
/* Want RECORD_TYPE, not POINTER_TYPE. */
BINFO_OFFSET (binfo) = size_int (offset * Target::ptrsize);
BINFO_VIRTUAL_P (binfo) = 1;
- for (size_t i = 0; i < cd->baseclasses->dim; i++, offset++)
+ for (size_t i = 0; i < cd->baseclasses->length; i++, offset++)
{
BaseClass *bc = (*cd->baseclasses)[i];
BINFO_BASE_APPEND (binfo, build_interface_binfo (binfo, bc->sym, offset));
unsigned offset = 0;
- for (size_t i = 0; i < sd->fields.dim; i++)
+ for (size_t i = 0; i < sd->fields.length; i++)
{
VarDeclaration *vd = sd->fields[i];
Type *tb = vd->type->toBasetype ();
tree tmemcmp = NULL_TREE;
/* We can skip the compare if the structs are empty. */
- if (sd->fields.dim == 0)
+ if (sd->fields.length == 0)
{
tmemcmp = build_boolop (code, integer_zero_node, integer_zero_node);
if (TREE_SIDE_EFFECTS (t2))
return build_boolop (code, tmemcmp, integer_zero_node);
}
- for (size_t i = 0; i < sd->fields.dim; i++)
+ for (size_t i = 0; i < sd->fields.length; i++)
{
VarDeclaration *vd = sd->fields[i];
Type *type = vd->type->toBasetype ();
tree t1, tree t2)
{
/* We can skip the compare if the structs are empty. */
- if (sd->fields.dim == 0)
+ if (sd->fields.length == 0)
{
tree exp = build_boolop (code, integer_zero_node, integer_zero_node);
if (TREE_SIDE_EFFECTS (t2))
if (arguments)
{
/* First pass, evaluated expanded tuples in function arguments. */
- for (size_t i = 0; i < arguments->dim; ++i)
+ for (size_t i = 0; i < arguments->length; ++i)
{
Lagain:
Expression *arg = (*arguments)[i];
/* if _arguments[] is the first argument. */
size_t varargs = (tf->linkage == LINKd && tf->varargs == 1);
- /* Assumes arguments->dim <= formal_args->dim if (!tf->varargs). */
- for (size_t i = 0; i < arguments->dim; ++i)
+ /* Assumes arguments->length <= formal_args->length if (!tf->varargs). */
+ for (size_t i = 0; i < arguments->length; ++i)
{
Expression *arg = (*arguments)[i];
tree targ = build_expr (arg);
{
if (fd->parameters)
{
- for (size_t i = 0; fd->parameters && i < fd->parameters->dim; i++)
+ for (size_t i = 0; fd->parameters && i < fd->parameters->length; i++)
{
VarDeclaration *v = (*fd->parameters)[i];
/* Remove if already in closureVars so can push to front. */
- for (size_t j = i; j < fd->closureVars.dim; j++)
+ for (size_t j = i; j < fd->closureVars.length; j++)
{
Dsymbol *s = fd->closureVars[j];
if (s == v)
/* Also add hidden 'this' to outer context. */
if (fd->vthis)
{
- for (size_t i = 0; i < fd->closureVars.dim; i++)
+ for (size_t i = 0; i < fd->closureVars.length; i++)
{
Dsymbol *s = fd->closureVars[i];
if (s == fd->vthis)
}
}
- for (size_t i = 0; i < fd->closureVars.dim; i++)
+ for (size_t i = 0; i < fd->closureVars.length; i++)
{
VarDeclaration *v = fd->closureVars[i];
tree vsym = get_symbol_decl (v);
}
/* Copy parameters that are referenced nonlocally. */
- for (size_t i = 0; i < fd->closureVars.dim; i++)
+ for (size_t i = 0; i < fd->closureVars.length; i++)
{
VarDeclaration *v = fd->closureVars[i];
Expressions *elements = ((ArrayLiteralExp *) expr)->elements;
vec<constructor_elt, va_gc> *elms = NULL;
- vec_safe_reserve (elms, elements->dim);
- for (size_t i = 0; i < elements->dim; i++)
+ vec_safe_reserve (elms, elements->length);
+ for (size_t i = 0; i < elements->length; i++)
{
Expression *e = (*elements)[i];
if (e->type->isintegral ())
if (!strcmp (id->toChars (), "object"))
create_tinfo_types (m);
}
- else if (md->packages->dim == 1)
+ else if (md->packages->length == 1)
{
if (!strcmp ((*md->packages)[0]->toChars (), "gcc")
&& !strcmp (md->id->toChars (), "builtins"))
d_build_builtins_module (m);
}
- else if (md->packages->dim == 2)
+ else if (md->packages->length == 2)
{
if (!strcmp ((*md->packages)[0]->toChars (), "core")
&& !strcmp ((*md->packages)[1]->toChars (), "stdc"))
if (!global.path)
global.path = new Strings ();
- for (size_t i = 0; i < paths->dim; i++)
+ for (size_t i = 0; i < paths->length; i++)
{
const char *path = (*paths)[i];
const char *target = lrealpath (path);
if (!global.filePath)
global.filePath = new Strings ();
- for (size_t i = 0; i < paths->dim; i++)
+ for (size_t i = 0; i < paths->length; i++)
{
const char *path = (*paths)[i];
const char *target = lrealpath (path);
/* Ignore duplicate entries. */
bool found = false;
- for (size_t i = 0; i < global.params.imppath->dim; i++)
+ for (size_t i = 0; i < global.params.imppath->length; i++)
{
if (strcmp (path, (*global.params.imppath)[i]) == 0)
{
/* Add import search paths. */
if (global.params.imppath)
{
- for (size_t i = 0; i < global.params.imppath->dim; i++)
+ for (size_t i = 0; i < global.params.imppath->length; i++)
{
const char *path = (*global.params.imppath)[i];
if (path)
/* Add string import search paths. */
if (global.params.fileImppath)
{
- for (size_t i = 0; i < global.params.fileImppath->dim; i++)
+ for (size_t i = 0; i < global.params.fileImppath->length; i++)
{
const char *path = (*global.params.fileImppath)[i];
if (path)
column++;
/* Search all modules for file dependencies. */
- while (modlist.dim > 0)
+ while (modlist.length > 0)
{
Module *depmod = modlist.pop ();
phonylist.safe_push (modstr);
/* Add imported files to dependency list. */
- for (size_t i = 0; i < depmod->contentImportedFiles.dim; i++)
+ for (size_t i = 0; i < depmod->contentImportedFiles.length; i++)
{
const char *impstr = depmod->contentImportedFiles[i];
dependencies.safe_push (impstr);
}
/* Search all imports of the module. */
- for (size_t i = 0; i < depmod->aimports.dim; i++)
+ for (size_t i = 0; i < depmod->aimports.length; i++)
{
Module *m = depmod->aimports[i];
{
OutBuffer buf;
buf.writestring ("predefs ");
- for (size_t i = 0; i < global.params.versionids->dim; i++)
+ for (size_t i = 0; i < global.params.versionids->length; i++)
{
const char *s = (*global.params.versionids)[i];
buf.writestring (" ");
}
/* Read all D source files. */
- for (size_t i = 0; i < modules.dim; i++)
+ for (size_t i = 0; i < modules.length; i++)
{
Module *m = modules[i];
m->read (Loc ());
}
/* Parse all D source files. */
- for (size_t i = 0; i < modules.dim; i++)
+ for (size_t i = 0; i < modules.length; i++)
{
Module *m = modules[i];
/* Generate 'header' import files. Since 'header' import files must be
independent of command line switches and what else is imported, they
are generated before any semantic analysis. */
- for (size_t i = 0; i < modules.dim; i++)
+ for (size_t i = 0; i < modules.length; i++)
{
Module *m = modules[i];
if (d_option.fonly && m != Module::rootModule)
goto had_errors;
/* Load all unconditional imports for better symbol resolving. */
- for (size_t i = 0; i < modules.dim; i++)
+ for (size_t i = 0; i < modules.length; i++)
{
Module *m = modules[i];
/* Do semantic analysis. */
doing_semantic_analysis_p = true;
- for (size_t i = 0; i < modules.dim; i++)
+ for (size_t i = 0; i < modules.length; i++)
{
Module *m = modules[i];
Module::dprogress = 1;
Module::runDeferredSemantic ();
- if (Module::deferred.dim)
+ if (Module::deferred.length)
{
- for (size_t i = 0; i < Module::deferred.dim; i++)
+ for (size_t i = 0; i < Module::deferred.length; i++)
{
Dsymbol *sd = Module::deferred[i];
error_at (make_location_t (sd->loc),
}
/* Process all built-in modules or functions now for CTFE. */
- while (builtin_modules.dim != 0)
+ while (builtin_modules.length != 0)
{
Module *m = builtin_modules.pop ();
d_maybe_set_builtin (m);
}
/* Do pass 2 semantic analysis. */
- for (size_t i = 0; i < modules.dim; i++)
+ for (size_t i = 0; i < modules.length; i++)
{
Module *m = modules[i];
goto had_errors;
/* Do pass 3 semantic analysis. */
- for (size_t i = 0; i < modules.dim; i++)
+ for (size_t i = 0; i < modules.length; i++)
{
Module *m = modules[i];
Module::runDeferredSemantic3 ();
/* Check again, incase semantic3 pass loaded any more modules. */
- while (builtin_modules.dim != 0)
+ while (builtin_modules.length != 0)
{
Module *m = builtin_modules.pop ();
d_maybe_set_builtin (m);
{
OutBuffer buf;
- for (size_t i = 0; i < modules.dim; i++)
+ for (size_t i = 0; i < modules.length; i++)
deps_write (modules[i], &buf);
/* -MF <arg> overrides -M[M]D. */
/* Generate Ddoc files. */
if (global.params.doDocComments && !global.errors && !errorcount)
{
- for (size_t i = 0; i < modules.dim; i++)
+ for (size_t i = 0; i < modules.length; i++)
{
Module *m = modules[i];
gendocfile (m);
/* Handle -fdump-d-original. */
if (global.params.vcg_ast)
{
- for (size_t i = 0; i < modules.dim; i++)
+ for (size_t i = 0; i < modules.length; i++)
{
Module *m = modules[i];
OutBuffer buf;
}
}
- for (size_t i = 0; i < modules.dim; i++)
+ for (size_t i = 0; i < modules.length; i++)
{
Module *m = modules[i];
if (d_option.fonly && m != Module::rootModule)
{
ModuleDeclaration *md = decl->getModule ()->md;
- if (md && md->packages && md->packages->dim == 1)
+ if (md && md->packages && md->packages->length == 1)
{
if (!strcmp ((*md->packages)[0]->toChars (), "gcc")
&& !strcmp (md->id->toChars (), "attribute"))
if (d->ident == NULL)
{
/* Importing declaration list. */
- for (size_t i = 0; i < d->names.dim; i++)
+ for (size_t i = 0; i < d->names.length; i++)
{
AliasDeclaration *aliasdecl = d->aliasdecls[i];
tree decl = build_import_decl (aliasdecl);
void visit (TupleDeclaration *d)
{
- for (size_t i = 0; i < d->objects->dim; i++)
+ for (size_t i = 0; i < d->objects->length; i++)
{
RootObject *o = (*d->objects)[i];
if ((o->dyncast () == DYNCAST_EXPRESSION)
if (!ds)
return;
- for (size_t i = 0; i < ds->dim; i++)
+ for (size_t i = 0; i < ds->length; i++)
this->build_dsymbol ((*ds)[i]);
}
if (isError (d) || !d->members)
return;
- for (size_t i = 0; i < d->members->dim; i++)
+ for (size_t i = 0; i < d->members->length; i++)
this->build_dsymbol ((*d->members)[i]);
}
if (!d->needsCodegen ())
return;
- for (size_t i = 0; i < d->members->dim; i++)
+ for (size_t i = 0; i < d->members->length; i++)
this->build_dsymbol ((*d->members)[i]);
}
if (isError (d)|| !d->members)
return;
- for (size_t i = 0; i < d->members->dim; i++)
+ for (size_t i = 0; i < d->members->length; i++)
this->build_dsymbol ((*d->members)[i]);
}
/* Put out the members. There might be static constructors in the members
list, and they cannot be put in separate object files. */
- for (size_t i = 0; i < d->members->dim; i++)
+ for (size_t i = 0; i < d->members->length; i++)
this->build_dsymbol ((*d->members)[i]);
/* Put out xopEquals, xopCmp and xopHash. */
bool has_errors = false;
/* Finish semantic analysis of functions in vtbl[]. */
- for (size_t i = d->vtblOffset (); i < d->vtbl.dim; i++)
+ for (size_t i = d->vtblOffset (); i < d->vtbl.length; i++)
{
FuncDeclaration *fd = d->vtbl[i]->isFuncDeclaration ();
/* The function fd is hidden from the view of the class.
If it overlaps with any function in the vtbl[], then
issue an error. */
- for (size_t j = 1; j < d->vtbl.dim; j++)
+ for (size_t j = 1; j < d->vtbl.length; j++)
{
if (j == i)
continue;
return;
/* Put out the members. */
- for (size_t i = 0; i < d->members->dim; i++)
+ for (size_t i = 0; i < d->members->length; i++)
this->build_dsymbol ((*d->members)[i]);
/* If something goes wrong during final semantic pass, don't bother with
if (d->vtblOffset ())
CONSTRUCTOR_APPEND_ELT (elms, size_zero_node, build_address (d->csym));
- for (size_t i = d->vtblOffset (); i < d->vtbl.dim; i++)
+ for (size_t i = d->vtblOffset (); i < d->vtbl.length; i++)
{
FuncDeclaration *fd = d->vtbl[i]->isFuncDeclaration ();
return;
/* Put out the members. */
- for (size_t i = 0; i < d->members->dim; i++)
+ for (size_t i = 0; i < d->members->length; i++)
this->build_dsymbol ((*d->members)[i]);
/* Generate C symbols. */
}
/* formal function parameters. */
- size_t n_parameters = d->parameters ? d->parameters->dim : 0;
+ size_t n_parameters = d->parameters ? d->parameters->length : 0;
for (size_t i = 0; i < n_parameters; i++)
{
{
unsigned csymoffset = Target::classinfosize;
unsigned interfacesize = int_size_in_bytes (vtbl_interface_type_node);
- csymoffset += cd->vtblInterfaces->dim * interfacesize;
+ csymoffset += cd->vtblInterfaces->length * interfacesize;
- for (size_t i = 0; i < cd->vtblInterfaces->dim; i++)
+ for (size_t i = 0; i < cd->vtblInterfaces->length; i++)
{
BaseClass *b = (*cd->vtblInterfaces)[i];
if (b == bc)
return csymoffset;
- csymoffset += b->sym->vtbl.dim * Target::ptrsize;
+ csymoffset += b->sym->vtbl.length * Target::ptrsize;
}
/* Check all overriding interface vtbl[]s. */
for (ClassDeclaration *cd2 = cd->baseClass; cd2; cd2 = cd2->baseClass)
{
- for (size_t k = 0; k < cd2->vtblInterfaces->dim; k++)
+ for (size_t k = 0; k < cd2->vtblInterfaces->length; k++)
{
BaseClass *bs = (*cd2->vtblInterfaces)[k];
if (bs->fillVtbl (cd, NULL, 0))
{
if (bc == bs)
return csymoffset;
- csymoffset += bs->sym->vtbl.dim * Target::ptrsize;
+ csymoffset += bs->sym->vtbl.length * Target::ptrsize;
}
}
}
tree ident = mangle_internal_decl (decl, "__vtbl", "Z");
/* Note: Using a static array type for the VAR_DECL, the DECL_INITIAL value
will have a different type. However the back-end seems to accept this. */
- tree type = build_ctype (Type::tvoidptr->sarrayOf (decl->vtbl.dim));
+ tree type = build_ctype (Type::tvoidptr->sarrayOf (decl->vtbl.length));
decl->vtblsym = declare_extern_var (ident, type);
DECL_LANG_SPECIFIC (decl->vtblsym) = build_lang_decl (NULL);
/* Anonymous vtable interface fields are laid out before the fields of
each class. The interface offset is used to determine where to put
the classinfo offset reference. */
- for (size_t i = 0; i < bcd->vtblInterfaces->dim; i++)
+ for (size_t i = 0; i < bcd->vtblInterfaces->length; i++)
{
BaseClass *bc = (*bcd->vtblInterfaces)[i];
/* Generate initial values of all fields owned by current class.
Use both the name and offset to find the right field. */
- for (size_t i = 0; i < bcd->fields.dim; i++)
+ for (size_t i = 0; i < bcd->fields.length; i++)
{
VarDeclaration *vfield = bcd->fields[i];
int index = exp->findFieldIndexByName (vfield);
-47ed0330f877897233bcaffd4e206e5f5ab66c98
+48d704f082ebe8b199a9ef7712c223216cd70d3a
The first line of this file holds the git revision number of the last
merge done from the dlang/dmd repository.
}
if (ClassDeclaration *cd = ad->isClassDeclaration())
{
- for (size_t i = 0; i < cd->baseclasses->dim; i++)
+ for (size_t i = 0; i < cd->baseclasses->length; i++)
{
BaseClass *b = (*cd->baseclasses)[i];
if (ClassDeclaration *cdthis = dthis->isClassDeclaration())
{
- for (size_t i = 0; i < cdthis->baseclasses->dim; i++)
+ for (size_t i = 0; i < cdthis->baseclasses->length; i++)
{
BaseClass *b = (*cdthis->baseclasses)[i];
Prot access = getAccess(b->sym, smember);
{
if (ClassDeclaration *cdthis = dthis->isClassDeclaration())
{
- for (size_t i = 0; i < cdthis->baseclasses->dim; i++)
+ for (size_t i = 0; i < cdthis->baseclasses->length; i++)
{
BaseClass *b = (*cdthis->baseclasses)[i];
if (isAccessible(smember, sfunc, b->sym, cdscope))
{
if (!e)
return false;
- for (size_t i = 0; i < e->dim && !stop; i++)
+ for (size_t i = 0; i < e->length && !stop; i++)
doCond((*e)[i]);
return stop;
}
void visit(Expression *e)
{
- Identifier *id = Identifier::generateId("c", fparams->dim);
+ Identifier *id = Identifier::generateId("c", fparams->length);
Parameter *param = new Parameter(0, e->type, id, NULL);
fparams->shift(param);
result = new IdentifierExp(Loc(), id);
void visit(ArrayLiteralExp *e)
{
- Identifier *id = Identifier::generateId("p", fparams->dim);
+ Identifier *id = Identifier::generateId("p", fparams->length);
Parameter *param = new Parameter(STCconst, e->type, id, NULL);
fparams->shift(param);
Expression *ie = new IdentifierExp(Loc(), id);
void visit(SliceExp *e)
{
- Identifier *id = Identifier::generateId("p", fparams->dim);
+ Identifier *id = Identifier::generateId("p", fparams->length);
Parameter *param = new Parameter(STCconst, e->type, id, NULL);
fparams->shift(param);
Expression *ie = new IdentifierExp(Loc(), id);
#pragma once
-#include "root/root.h"
+#include "root/array.h"
+#include "root/bitarray.h"
typedef Array<class TemplateParameter *> TemplateParameters;
if (d)
{
- for (size_t i = 0; i < d->dim; i++)
+ for (size_t i = 0; i < d->length; i++)
{
Dsymbol *s = (*d)[i];
if (s)
{
Scope *sc2 = newScope(sc);
- for (size_t i = 0; i < d->dim; i++)
+ for (size_t i = 0; i < d->length; i++)
{
Dsymbol *s = (*d)[i];
//printf("\taddMember %s to %s\n", s->toChars(), sds->toChars());
{
Scope *sc2 = newScope(sc);
- for (size_t i = 0; i < d->dim; i++)
+ for (size_t i = 0; i < d->length; i++)
{
Dsymbol *s = (*d)[i];
s->setScope(sc2);
{
Scope *sc2 = newScope(sc);
- for (size_t i = 0; i < d->dim; i++)
+ for (size_t i = 0; i < d->length; i++)
{
Dsymbol *s = (*d)[i];
s->importAll(sc2);
{
Scope *sc2 = newScope(sc);
- for (size_t i = 0; i < d->dim; i++)
+ for (size_t i = 0; i < d->length; i++)
{
Dsymbol *s = (*d)[i];
s->semantic(sc2);
{
Scope *sc2 = newScope(sc);
- for (size_t i = 0; i < d->dim; i++)
+ for (size_t i = 0; i < d->length; i++)
{
Dsymbol *s = (*d)[i];
s->semantic2(sc2);
{
Scope *sc2 = newScope(sc);
- for (size_t i = 0; i < d->dim; i++)
+ for (size_t i = 0; i < d->length; i++)
{
Dsymbol *s = (*d)[i];
s->semantic3(sc2);
if (d)
{
- for (size_t i = 0; i < d->dim; i++)
+ for (size_t i = 0; i < d->length; i++)
{
Dsymbol *s = (*d)[i];
//printf("AttribDeclaration::addComment %s\n", s->toChars());
if (d)
{
- for (size_t i = 0; i < d->dim; i++)
+ for (size_t i = 0; i < d->length; i++)
{
Dsymbol *s = (*d)[i];
s->setFieldOffset(ad, poffset, isunion);
if (d)
{
- for (size_t i = 0; i < d->dim; i++)
+ for (size_t i = 0; i < d->length; i++)
{
Dsymbol *s = (*d)[i];
if (s->hasPointers())
if (d)
{
- for (size_t i = 0; i < d->dim; i++)
+ for (size_t i = 0; i < d->length; i++)
{
Dsymbol *s = (*d)[i];
if (s->hasStaticCtorOrDtor())
if (d)
{
- for (size_t i = 0; i < d->dim; i++)
+ for (size_t i = 0; i < d->length; i++)
{
Dsymbol *s = (*d)[i];
s->checkCtorConstInit();
if (d)
{
- for (size_t i = 0; i < d->dim; i++)
+ for (size_t i = 0; i < d->length; i++)
{
Dsymbol *s = (*d)[i];
s->addLocalClass(aclasses);
if (d)
{
Scope *sc2 = newScope(sc);
- for (size_t i = 0; i < d->dim; i++)
+ for (size_t i = 0; i < d->length; i++)
{
Dsymbol *s = (*d)[i];
//printf("\taddMember %s to %s\n", s->toChars(), sds->toChars());
sc->inunion = isunion;
sc->flags = 0;
- for (size_t i = 0; i < decl->dim; i++)
+ for (size_t i = 0; i < decl->length; i++)
{
Dsymbol *s = (*decl)[i];
s->semantic(sc);
* size and alignment.
*/
- size_t fieldstart = ad->fields.dim;
+ size_t fieldstart = ad->fields.length;
/* Hackishly hijack ad's structsize and alignsize fields
* for use in our fake anon aggregate member.
ad->alignsize = 0;
unsigned offset = 0;
- for (size_t i = 0; i < decl->dim; i++)
+ for (size_t i = 0; i < decl->length; i++)
{
Dsymbol *s = (*decl)[i];
s->setFieldOffset(ad, &offset, this->isunion);
* added in ad->fields, just update *poffset for the subsequent
* field offset calculation.
*/
- if (fieldstart == ad->fields.dim)
+ if (fieldstart == ad->fields.length)
{
ad->structsize = savestructsize;
ad->alignsize = savealignsize;
// Add to the anon fields the base offset of this anonymous aggregate
//printf("anon fields, anonoffset = %d\n", anonoffset);
- for (size_t i = fieldstart; i < ad->fields.dim; i++)
+ for (size_t i = fieldstart; i < ad->fields.length; i++)
{
VarDeclaration *v = ad->fields[i];
//printf("\t[%d] %s %d\n", i, v->toChars(), v->offset);
if (ident == Id::Pinline)
{
PINLINE inlining = PINLINEdefault;
- if (!args || args->dim == 0)
+ if (!args || args->length == 0)
inlining = PINLINEdefault;
- else if (args->dim != 1)
+ else if (args->length != 1)
{
- error("one boolean expression expected for pragma(inline), not %d", args->dim);
+ error("one boolean expression expected for pragma(inline), not %d", args->length);
args->setDim(1);
(*args)[0] = new ErrorExp();
}
Dsymbols *decls = ad->include(NULL, NULL);
unsigned nestedCount = 0;
- if (decls && decls->dim)
- for (size_t i = 0; i < decls->dim; ++i)
+ if (decls && decls->length)
+ for (size_t i = 0; i < decls->length; ++i)
nestedCount += setMangleOverride((*decls)[i], sym);
return nestedCount;
{
if (args)
{
- for (size_t i = 0; i < args->dim; i++)
+ for (size_t i = 0; i < args->length; i++)
{
Expression *e = (*args)[i];
}
else if (ident == Id::lib)
{
- if (!args || args->dim != 1)
+ if (!args || args->length != 1)
error("string expected for library name");
else
{
}
else if (ident == Id::startaddress)
{
- if (!args || args->dim != 1)
+ if (!args || args->length != 1)
error("function name expected for start address");
else
{
{
if (!args)
args = new Expressions();
- if (args->dim != 1)
+ if (args->length != 1)
{
error("string expected for mangled name");
args->setDim(1);
buf.writestring(ident->toChars());
if (args)
{
- for (size_t i = 0; i < args->dim; i++)
+ for (size_t i = 0; i < args->length; i++)
{
Expression *e = (*args)[i];
buf.writeByte(',');
buf.writestring(e->toChars());
}
- if (args->dim)
+ if (args->length)
buf.writeByte(')');
}
message("pragma %s", buf.peekString());
{
Scope *sc2 = newScope(sc);
- for (size_t i = 0; i < decl->dim; i++)
+ for (size_t i = 0; i < decl->length; i++)
{
Dsymbol *s = (*decl)[i];
if (ident == Id::mangle)
{
- assert(args && args->dim == 1);
+ assert(args && args->length == 1);
if (StringExp *se = (*args)[0]->toStringExp())
{
char *name = (char *)mem.xmalloc(se->len + 1);
//printf("\tConditionalDeclaration::setScope '%s', d = %p\n",toChars(), d);
if (d)
{
- for (size_t i = 0; i < d->dim; i++)
+ for (size_t i = 0; i < d->length; i++)
{
Dsymbol *s = (*d)[i];
s->setScope(sc);
{
if (d)
{
- for (size_t i = 0; i < d->dim; i++)
+ for (size_t i = 0; i < d->length; i++)
{
Dsymbol *s = (*d)[i];
//printf("ConditionalDeclaration::addComment %s\n", s->toChars());
if (d && !addisdone)
{
// Add members lazily.
- for (size_t i = 0; i < d->dim; i++)
+ for (size_t i = 0; i < d->length; i++)
{
Dsymbol *s = (*d)[i];
s->addMember(_scope, scopesym);
}
// Set the member scopes lazily.
- for (size_t i = 0; i < d->dim; i++)
+ for (size_t i = 0; i < d->length; i++)
{
Dsymbol *s = (*d)[i];
s->setScope(_scope);
if (d) // process generated declarations
{
// Add members lazily.
- for (size_t i = 0; i < d->dim; i++)
+ for (size_t i = 0; i < d->length; i++)
{
Dsymbol *s = (*d)[i];
s->addMember(_scope, scopesym);
}
// Set the member scopes lazily.
- for (size_t i = 0; i < d->dim; i++)
+ for (size_t i = 0; i < d->length; i++)
{
Dsymbol *s = (*d)[i];
s->setScope(_scope);
if (_scope && decl)
{
- for (size_t i = 0; i < decl->dim; i++)
+ for (size_t i = 0; i < decl->length; i++)
{
Dsymbol *s = (*decl)[i];
s->setScope(_scope);
Scope *UserAttributeDeclaration::newScope(Scope *sc)
{
Scope *sc2 = sc;
- if (atts && atts->dim)
+ if (atts && atts->length)
{
// create new one for changes
sc2 = sc->copy();
static void udaExpressionEval(Scope *sc, Expressions *exps)
{
- for (size_t i = 0; i < exps->dim; i++)
+ for (size_t i = 0; i < exps->length; i++)
{
Expression *e = (*exps)[i];
if (e)
void UserAttributeDeclaration::semantic2(Scope *sc)
{
- if (decl && atts && atts->dim && _scope)
+ if (decl && atts && atts->length && _scope)
{
_scope = NULL;
udaExpressionEval(sc, atts);
Expressions *UserAttributeDeclaration::concat(Expressions *udas1, Expressions *udas2)
{
Expressions *udas;
- if (!udas1 || udas1->dim == 0)
+ if (!udas1 || udas1->length == 0)
udas = udas2;
- else if (!udas2 || udas2->dim == 0)
+ else if (!udas2 || udas2->length == 0)
udas = udas1;
else
{
Expressions *exps = new Expressions();
if (userAttribDecl)
exps->push(new TupleExp(Loc(), userAttribDecl->getAttributes()));
- if (atts && atts->dim)
+ if (atts && atts->length)
exps->push(new TupleExp(Loc(), atts));
return exps;
void visit(CompoundStatement *cs)
{
- //printf("CompoundStatement::blockExit(%p) %d result = x%X\n", cs, cs->statements->dim, result);
+ //printf("CompoundStatement::blockExit(%p) %d result = x%X\n", cs, cs->statements->length, result);
result = BEfallthru;
Statement *slast = NULL;
- for (size_t i = 0; i < cs->statements->dim; i++)
+ for (size_t i = 0; i < cs->statements->length; i++)
{
Statement *s = (*cs->statements)[i];
if (s)
void visit(UnrolledLoopStatement *uls)
{
result = BEfallthru;
- for (size_t i = 0; i < uls->statements->dim; i++)
+ for (size_t i = 0; i < uls->statements->length; i++)
{
Statement *s = (*uls->statements)[i];
if (s)
result = blockExit(s->_body, func, false);
int catchresult = 0;
- for (size_t i = 0; i < s->catches->dim; i++)
+ for (size_t i = 0; i < s->catches->length; i++)
{
Catch *c = (*s->catches)[i];
if (c->type == Type::terror)
if (ad)
{
Dsymbols *decl = ad->include(NULL, NULL);
- if (decl && decl->dim)
+ if (decl && decl->length)
{
- for (size_t i = 0; i < decl->dim; i++)
+ for (size_t i = 0; i < decl->length; i++)
{
s = (*decl)[i];
if (Dsymbol_canThrow(s, func, mustNotThrow))
//printf("%s\n", tm->toChars());
if (tm->members)
{
- for (size_t i = 0; i < tm->members->dim; i++)
+ for (size_t i = 0; i < tm->members->length; i++)
{
Dsymbol *sm = (*tm->members)[i];
if (Dsymbol_canThrow(sm, func, mustNotThrow))
}
else if ((td = s->isTupleDeclaration()) != NULL)
{
- for (size_t i = 0; i < td->objects->dim; i++)
+ for (size_t i = 0; i < td->objects->length; i++)
{
RootObject *o = (*td->objects)[i];
if (o->dyncast() == DYNCAST_EXPRESSION)
return NULL;
int varargs;
Parameters *fparams = f->getParameters(&varargs);
- if (fparams->dim >= 1)
+ if (fparams->length >= 1)
{
Parameter *fparam0 = Parameter::getNth(fparams, 0);
if (fparam0->type->toDsymbol(NULL) != ad)
/* If any of the fields need an opAssign, then we
* need it too.
*/
- for (size_t i = 0; i < sd->fields.dim; i++)
+ for (size_t i = 0; i < sd->fields.length; i++)
{
VarDeclaration *v = sd->fields[i];
if (v->storage_class & STCref)
// check for it.
// In this event, it will be reflected by having `stc` (opAssign's
// storage class) include `STCdisabled`.
- for (size_t i = 0; i < sd->fields.dim; i++)
+ for (size_t i = 0; i < sd->fields.length; i++)
{
VarDeclaration *v = sd->fields[i];
if (v->storage_class & STCref)
* In both cases, it will change the parent context.
*/
//printf("\tmemberwise copy\n");
- for (size_t i = 0; i < sd->fields.dim; i++)
+ for (size_t i = 0; i < sd->fields.length; i++)
{
VarDeclaration *v = sd->fields[i];
// this.v = s.v;
/* If any of the fields has an opEquals, then we
* need it too.
*/
- for (size_t i = 0; i < sd->fields.dim; i++)
+ for (size_t i = 0; i < sd->fields.length; i++)
{
VarDeclaration *v = sd->fields[i];
if (v->storage_class & STCref)
/* If any of the fields has an opEquals, then we
* need it too.
*/
- for (size_t i = 0; i < sd->fields.dim; i++)
+ for (size_t i = 0; i < sd->fields.length; i++)
{
VarDeclaration *v = sd->fields[i];
if (v->storage_class & STCref)
return NULL;
StorageClass stc = STCsafe | STCnothrow | STCpure | STCnogc;
- Loc declLoc = sd->postblits.dim ? sd->postblits[0]->loc : sd->loc;
+ Loc declLoc = sd->postblits.length ? sd->postblits[0]->loc : sd->loc;
Loc loc = Loc(); // internal code should have no loc to prevent coverage
- for (size_t i = 0; i < sd->postblits.dim; i++)
+ for (size_t i = 0; i < sd->postblits.length; i++)
{
stc |= sd->postblits[i]->storage_class & STCdisable;
}
Statements *a = new Statements();
- for (size_t i = 0; i < sd->fields.dim && !(stc & STCdisable); i++)
+ for (size_t i = 0; i < sd->fields.length && !(stc & STCdisable); i++)
{
VarDeclaration *v = sd->fields[i];
if (v->storage_class & STCref)
}
// Build our own "postblit" which executes a, but only if needed.
- if (a->dim || (stc & STCdisable))
+ if (a->length || (stc & STCdisable))
{
//printf("Building __fieldPostBlit()\n");
PostBlitDeclaration *dd = new PostBlitDeclaration(declLoc, Loc(), stc, Id::__fieldPostblit);
}
FuncDeclaration *xpostblit = NULL;
- switch (sd->postblits.dim)
+ switch (sd->postblits.length)
{
case 0:
break;
default:
Expression *e = NULL;
stc = STCsafe | STCnothrow | STCpure | STCnogc;
- for (size_t i = 0; i < sd->postblits.dim; i++)
+ for (size_t i = 0; i < sd->postblits.length; i++)
{
FuncDeclaration *fd = sd->postblits[i];
stc = mergeFuncAttrs(stc, fd);
return NULL;
StorageClass stc = STCsafe | STCnothrow | STCpure | STCnogc;
- Loc declLoc = ad->dtors.dim ? ad->dtors[0]->loc : ad->loc;
+ Loc declLoc = ad->dtors.length ? ad->dtors[0]->loc : ad->loc;
Loc loc = Loc(); // internal code should have no loc to prevent coverage
Expression *e = NULL;
- for (size_t i = 0; i < ad->fields.dim; i++)
+ for (size_t i = 0; i < ad->fields.length; i++)
{
VarDeclaration *v = ad->fields[i];
if (v->storage_class & STCref)
}
FuncDeclaration *xdtor = NULL;
- switch (ad->dtors.dim)
+ switch (ad->dtors.length)
{
case 0:
break;
default:
e = NULL;
stc = STCsafe | STCnothrow | STCpure | STCnogc;
- for (size_t i = 0; i < ad->dtors.dim; i++)
+ for (size_t i = 0; i < ad->dtors.length; i++)
{
FuncDeclaration *fd = ad->dtors[i];
stc = mergeFuncAttrs(stc, fd);
Loc declLoc = ad->loc;
Loc loc = Loc(); // internal code should have no loc to prevent coverage
- switch (ad->invs.dim)
+ switch (ad->invs.length)
{
case 0:
return NULL;
default:
Expression *e = NULL;
StorageClass stcx = 0;
- for (size_t i = 0; i < ad->invs.dim; i++)
+ for (size_t i = 0; i < ad->invs.length; i++)
{
stc = mergeFuncAttrs(stc, ad->invs[i]);
if (stc & STCdisable)
#pragma once
#include "root/array.h"
+#include "root/bitarray.h"
// This file contains a data structure that describes a back-end compiler
// and implements compiler-specific actions.
{
if (ids)
{
- for (size_t i = 0; i < ids->dim; i++)
+ for (size_t i = 0; i < ids->length; i++)
{
const char *id = (*ids)[i];
}
else
{
- assert(sfe->rangefe && parameters->dim == 1);
+ assert(sfe->rangefe && parameters->length == 1);
return new ForeachRangeStatement(loc, sfe->rangefe->op, (*parameters)[0],
sfe->rangefe->lwr->syntaxCopy(),
sfe->rangefe->upr->syntaxCopy(), s, loc);
static void lowerNonArrayAggregate(StaticForeach *sfe, Scope *sc)
{
- size_t nvars = sfe->aggrfe ? sfe->aggrfe->parameters->dim : 1;
+ size_t nvars = sfe->aggrfe ? sfe->aggrfe->parameters->length : 1;
Loc aloc = sfe->aggrfe ? sfe->aggrfe->aggr->loc : sfe->rangefe->lwr->loc;
// We need three sets of foreach loop variables because the
// lowering contains three foreach loops.
for (size_t i = 0; i < 2; i++)
{
Expressions *e = new Expressions();
- for (size_t j = 0; j < pparams[0]->dim; j++)
+ for (size_t j = 0; j < pparams[0]->length; j++)
{
Parameter *p = (*pparams[i])[j];
e->push(new IdentifierExp(aloc, p->ident));
else if (e2->op == TOKarrayliteral)
{
ArrayLiteralExp *es2 = (ArrayLiteralExp *)e2;
- cmp = !es2->elements || (0 == es2->elements->dim);
+ cmp = !es2->elements || (0 == es2->elements->length);
}
else
{
else if (e1->op == TOKarrayliteral)
{
ArrayLiteralExp *es1 = (ArrayLiteralExp *)e1;
- cmp = !es1->elements || (0 == es1->elements->dim);
+ cmp = !es1->elements || (0 == es1->elements->length);
}
else
{
ArrayLiteralExp *es1 = (ArrayLiteralExp *)e1;
ArrayLiteralExp *es2 = (ArrayLiteralExp *)e2;
- if ((!es1->elements || !es1->elements->dim) &&
- (!es2->elements || !es2->elements->dim))
+ if ((!es1->elements || !es1->elements->length) &&
+ (!es2->elements || !es2->elements->length))
cmp = 1; // both arrays are empty
else if (!es1->elements || !es2->elements)
cmp = 0;
- else if (es1->elements->dim != es2->elements->dim)
+ else if (es1->elements->length != es2->elements->length)
cmp = 0;
else
{
- for (size_t i = 0; i < es1->elements->dim; i++)
+ for (size_t i = 0; i < es1->elements->length; i++)
{
Expression *ee1 = es1->getElement(i);
Expression *ee2 = es2->getElement(i);
StringExp *es1 = (StringExp *)e1;
ArrayLiteralExp *es2 = (ArrayLiteralExp *)e2;
size_t dim1 = es1->len;
- size_t dim2 = es2->elements ? es2->elements->dim : 0;
+ size_t dim2 = es2->elements ? es2->elements->length : 0;
if (dim1 != dim2)
cmp = 0;
else
if (es1->sd != es2->sd)
cmp = 0;
- else if ((!es1->elements || !es1->elements->dim) &&
- (!es2->elements || !es2->elements->dim))
+ else if ((!es1->elements || !es1->elements->length) &&
+ (!es2->elements || !es2->elements->length))
cmp = 1; // both arrays are empty
else if (!es1->elements || !es2->elements)
cmp = 0;
- else if (es1->elements->dim != es2->elements->dim)
+ else if (es1->elements->length != es2->elements->length)
cmp = 0;
else
{
cmp = 1;
- for (size_t i = 0; i < es1->elements->dim; i++)
+ for (size_t i = 0; i < es1->elements->length; i++)
{
Expression *ee1 = (*es1->elements)[i];
Expression *ee2 = (*es2->elements)[i];
StructDeclaration *sd = tb->toDsymbol(NULL)->isStructDeclaration();
assert(sd);
Expressions *elements = new Expressions;
- for (size_t i = 0; i < sd->fields.dim; i++)
+ for (size_t i = 0; i < sd->fields.length; i++)
{
VarDeclaration *v = sd->fields[i];
UnionExp zero;
else if (e1->op == TOKarrayliteral)
{
ArrayLiteralExp *ale = (ArrayLiteralExp *)e1;
- size_t dim = ale->elements ? ale->elements->dim : 0;
+ size_t dim = ale->elements ? ale->elements->length : 0;
new(&ue) IntegerExp(loc, dim, type);
}
else if (e1->op == TOKassocarrayliteral)
{
AssocArrayLiteralExp *ale = (AssocArrayLiteralExp *)e1;
- size_t dim = ale->keys->dim;
+ size_t dim = ale->keys->length;
new(&ue) IntegerExp(loc, dim, type);
}
if (e1->op == TOKarrayliteral)
{
ArrayLiteralExp *ale = (ArrayLiteralExp *)e1;
- if (i >= ale->elements->dim)
+ if (i >= ale->elements->length)
{
- e1->error("array index %llu is out of bounds %s[0 .. %u]", i, e1->toChars(), ale->elements->dim);
+ e1->error("array index %llu is out of bounds %s[0 .. %u]", i, e1->toChars(), ale->elements->length);
new(&ue) ErrorExp();
}
else
AssocArrayLiteralExp *ae = (AssocArrayLiteralExp *)e1;
/* Search the keys backwards, in case there are duplicate keys
*/
- for (size_t i = ae->keys->dim; i;)
+ for (size_t i = ae->keys->length; i;)
{
i--;
Expression *ekey = (*ae->keys)[i];
uinteger_t ilwr = lwr->toInteger();
uinteger_t iupr = upr->toInteger();
- if (iupr > es1->elements->dim || ilwr > iupr)
+ if (iupr > es1->elements->length || ilwr > iupr)
{
e1->error("array slice [%llu .. %llu] is out of bounds", ilwr, iupr);
new(&ue) ErrorExp();
void sliceAssignStringFromArrayLiteral(StringExp *existingSE, ArrayLiteralExp *newae, size_t firstIndex)
{
void *s = existingSE->string;
- for (size_t j = 0; j < newae->elements->dim; j++)
+ for (size_t j = 0; j < newae->elements->length; j++)
{
unsigned val = (unsigned)newae->getElement(j)->toInteger();
switch (existingSE->sz)
// [chars] ~ string --> [chars]
StringExp *es = (StringExp *)e2;
ArrayLiteralExp *ea = (ArrayLiteralExp *)e1;
- size_t len = es->len + ea->elements->dim;
+ size_t len = es->len + ea->elements->length;
Expressions * elems = new Expressions;
elems->setDim(len);
- for (size_t i= 0; i < ea->elements->dim; ++i)
+ for (size_t i= 0; i < ea->elements->length; ++i)
{
(*elems)[i] = ea->getElement(i);
}
new(&ue) ArrayLiteralExp(e1->loc, type, elems);
ArrayLiteralExp *dest = (ArrayLiteralExp *)ue.exp();
- sliceAssignArrayLiteralFromString(dest, es, ea->elements->dim);
+ sliceAssignArrayLiteralFromString(dest, es, ea->elements->length);
assert(ue.exp()->type);
return ue;
}
// string ~ [chars] --> [chars]
StringExp *es = (StringExp *)e1;
ArrayLiteralExp *ea = (ArrayLiteralExp *)e2;
- size_t len = es->len + ea->elements->dim;
+ size_t len = es->len + ea->elements->length;
Expressions * elems = new Expressions;
elems->setDim(len);
- for (size_t i= 0; i < ea->elements->dim; ++i)
+ for (size_t i= 0; i < ea->elements->length; ++i)
{
(*elems)[es->len + i] = ea->getElement(i);
}
e = ue.exp();
if (type->toBasetype()->ty == Tsarray)
{
- e->type = t1->nextOf()->sarrayOf(elems->dim);
+ e->type = t1->nextOf()->sarrayOf(elems->length);
}
else
e->type = type;
e = ue.exp();
if (type->toBasetype()->ty == Tsarray)
{
- e->type = t1->nextOf()->sarrayOf(elems->dim);
+ e->type = t1->nextOf()->sarrayOf(elems->length);
}
else
e->type = type;
e = ue.exp();
if (type->toBasetype()->ty == Tsarray)
{
- e->type = e2->type->sarrayOf(elems->dim);
+ e->type = e2->type->sarrayOf(elems->length);
}
else
e->type = type;
e = ue.exp();
if (type->toBasetype()->ty == Tsarray)
{
- e->type = e1->type->sarrayOf(elems->dim);
+ e->type = e1->type->sarrayOf(elems->length);
}
else
e->type = type;
int find(RootObject *p)
{
//printf("find %p %d %s\n", p, p.dyncast(), p ? p.toChars() : NULL);
- for (size_t i = 0; i < components.dim; i++)
+ for (size_t i = 0; i < components.length; i++)
{
if (p == components[i])
return (int)i;
if (!ti) // could happen if std::basic_string is not a template
return;
buf->writeByte('I');
- for (size_t i = 0; i < ti->tiargs->dim; i++)
+ for (size_t i = 0; i < ti->tiargs->length; i++)
{
RootObject *o = (*ti->tiargs)[i];
TemplateDeclaration *td = ti->tempdecl->isTemplateDeclaration();
buf->writeByte('I'); // argument pack
// mangle the rest of the arguments as types
- for (size_t j = i; j < ti->tiargs->dim; j++)
+ for (size_t j = i; j < ti->tiargs->length; j++)
{
Type *t = isType((*ti->tiargs)[j]);
assert(t);
if (!ti)
return false;
Dsymbol *q = getQualifier(ti);
- return isStd(q) && ti->tiargs->dim == 1 && isChar((*ti->tiargs)[0]);
+ return isStd(q) && ti->tiargs->length == 1 && isChar((*ti->tiargs)[0]);
}
/***
*/
bool char_std_char_traits_char(TemplateInstance *ti, const char *st)
{
- if (ti->tiargs->dim == 2 &&
+ if (ti->tiargs->length == 2 &&
isChar((*ti->tiargs)[0]) &&
isChar_traits_char((*ti->tiargs)[1]))
{
if (s->ident == Id::basic_string)
{
// ::std::basic_string<char, ::std::char_traits<char>, ::std::allocator<char>>
- if (ti->tiargs->dim == 3 &&
+ if (ti->tiargs->length == 3 &&
isChar((*ti->tiargs)[0]) &&
isChar_traits_char((*ti->tiargs)[1]) &&
isAllocator_char((*ti->tiargs)[2]))
else if (s->ident == Id::basic_string)
{
// ::std::basic_string<char, ::std::char_traits<char>, ::std::allocator<char>>
- if (ti->tiargs->dim == 3 &&
+ if (ti->tiargs->length == 3 &&
isChar((*ti->tiargs)[0]) &&
isChar_traits_char((*ti->tiargs)[1]) &&
isAllocator_char((*ti->tiargs)[2]))
{
ClassDeclaration *cd = originalClass();
unsigned fieldsSoFar = 0;
- for (size_t j = 0; j < value->elements->dim; j++)
+ for (size_t j = 0; j < value->elements->length; j++)
{
- while (j - fieldsSoFar >= cd->fields.dim)
+ while (j - fieldsSoFar >= cd->fields.length)
{
- fieldsSoFar += cd->fields.dim;
+ fieldsSoFar += cd->fields.length;
cd = cd->baseClass;
}
VarDeclaration *v2 = cd->fields[j - fieldsSoFar];
if (fieldoffset == v2->offset &&
fieldtype->size() == v2->type->size())
{
- return (int)(value->elements->dim - fieldsSoFar - cd->fields.dim + (j-fieldsSoFar));
+ return (int)(value->elements->length - fieldsSoFar - cd->fields.length + (j-fieldsSoFar));
}
}
return -1;
{
ClassDeclaration *cd = originalClass();
size_t fieldsSoFar = 0;
- for (size_t j = 0; j < value->elements->dim; j++)
+ for (size_t j = 0; j < value->elements->length; j++)
{
- while (j - fieldsSoFar >= cd->fields.dim)
+ while (j - fieldsSoFar >= cd->fields.length)
{
- fieldsSoFar += cd->fields.dim;
+ fieldsSoFar += cd->fields.length;
cd = cd->baseClass;
}
VarDeclaration *v2 = cd->fields[j - fieldsSoFar];
if (v == v2)
{
- return (int)(value->elements->dim - fieldsSoFar - cd->fields.dim + (j-fieldsSoFar));
+ return (int)(value->elements->length - fieldsSoFar - cd->fields.length + (j-fieldsSoFar));
}
}
return -1;
// Same as getFieldIndex, but checks for a direct match with the VarDeclaration
int findFieldIndexByName(StructDeclaration *sd, VarDeclaration *v)
{
- for (size_t i = 0; i < sd->fields.dim; ++i)
+ for (size_t i = 0; i < sd->fields.length; ++i)
{
if (sd->fields[i] == v)
return (int)i;
return oldelems;
CtfeStatus::numArrayAllocs++;
Expressions *newelems = new Expressions();
- newelems->setDim(oldelems->dim);
- for (size_t i = 0; i < oldelems->dim; i++)
+ newelems->setDim(oldelems->length);
+ for (size_t i = 0; i < oldelems->length; i++)
{
Expression *el = (*oldelems)[i];
if (!el)
StructLiteralExp *sle = (StructLiteralExp *)e;
Expressions *oldelems = sle->elements;
Expressions * newelems = new Expressions();
- newelems->setDim(oldelems->dim);
- for (size_t i = 0; i < newelems->dim; i++)
+ newelems->setDim(oldelems->length);
+ for (size_t i = 0; i < newelems->length; i++)
{
// We need the struct definition to detect block assignment
VarDeclaration *v = sle->sd->fields[i];
if (e->op == TOKarrayliteral)
{
ArrayLiteralExp *ale = (ArrayLiteralExp *)e;
- return ale->elements ? ale->elements->dim : 0;
+ return ale->elements ? ale->elements->length : 0;
}
if (e->op == TOKassocarrayliteral)
{
AssocArrayLiteralExp *ale = (AssocArrayLiteralExp *)e;
- return ale->keys->dim;
+ return ale->keys->length;
}
assert(0);
return 0;
if (es1->sd != es2->sd)
return 1;
- else if ((!es1->elements || !es1->elements->dim) &&
- (!es2->elements || !es2->elements->dim))
+ else if ((!es1->elements || !es1->elements->length) &&
+ (!es2->elements || !es2->elements->length))
return 0; // both arrays are empty
else if (!es1->elements || !es2->elements)
return 1;
- else if (es1->elements->dim != es2->elements->dim)
+ else if (es1->elements->length != es2->elements->length)
return 1;
else
{
- for (size_t i = 0; i < es1->elements->dim; i++)
+ for (size_t i = 0; i < es1->elements->length; i++)
{
Expression *ee1 = (*es1->elements)[i];
Expression *ee2 = (*es2->elements)[i];
AssocArrayLiteralExp *es1 = (AssocArrayLiteralExp *)e1;
AssocArrayLiteralExp *es2 = (AssocArrayLiteralExp *)e2;
- size_t dim = es1->keys->dim;
- if (es2->keys->dim != dim)
+ size_t dim = es1->keys->length;
+ if (es2->keys->length != dim)
return 1;
bool *used = (bool *)mem.xmalloc(sizeof(bool) * dim);
// [chars] ~ string => string (only valid for CTFE)
StringExp *es1 = (StringExp *)e2;
ArrayLiteralExp *es2 = (ArrayLiteralExp *)e1;
- size_t len = es1->len + es2->elements->dim;
+ size_t len = es1->len + es2->elements->length;
unsigned char sz = es1->sz;
void *s = mem.xmalloc((len + 1) * sz);
- memcpy((char *)s + sz * es2->elements->dim, es1->string, es1->len * sz);
- for (size_t i = 0; i < es2->elements->dim; i++)
+ memcpy((char *)s + sz * es2->elements->length, es1->string, es1->len * sz);
+ for (size_t i = 0; i < es2->elements->length; i++)
{
Expression *es2e = (*es2->elements)[i];
if (es2e->op != TOKint64)
// Concatenate the strings
StringExp *es1 = (StringExp *)e1;
ArrayLiteralExp *es2 = (ArrayLiteralExp *)e2;
- size_t len = es1->len + es2->elements->dim;
+ size_t len = es1->len + es2->elements->length;
unsigned char sz = es1->sz;
void *s = mem.xmalloc((len + 1) * sz);
memcpy(s, es1->string, es1->len * sz);
- for (size_t i = 0; i < es2->elements->dim; i++)
+ for (size_t i = 0; i < es2->elements->length; i++)
{
Expression *es2e = (*es2->elements)[i];
if (es2e->op != TOKint64)
new(&ue) ArrayLiteralExp(es1->loc, type, copyLiteralArray(es1->elements));
es1 = (ArrayLiteralExp *)ue.exp();
- es1->elements->insert(es1->elements->dim, copyLiteralArray(es2->elements));
+ es1->elements->insert(es1->elements->length, copyLiteralArray(es2->elements));
return ue;
}
if (e1->op == TOKarrayliteral && e2->op == TOKnull &&
{
/* Search the keys backwards, in case there are duplicate keys
*/
- for (size_t i = ae->keys->dim; i;)
+ for (size_t i = ae->keys->length; i;)
{
i--;
Expression *ekey = (*ae->keys)[i];
assert(e1->op == TOKarrayliteral);
{
ArrayLiteralExp *ale = (ArrayLiteralExp *)e1;
- if (indx >= ale->elements->dim)
+ if (indx >= ale->elements->length)
{
- error(loc, "array index %llu is out of bounds %s[0 .. %llu]", (ulonglong)indx, e1->toChars(), (ulonglong)ale->elements->dim);
+ error(loc, "array index %llu is out of bounds %s[0 .. %llu]", (ulonglong)indx, e1->toChars(), (ulonglong)ale->elements->length);
return CTFEExp::cantexp;
}
Expression *e = (*ale->elements)[(size_t)indx];
assert(dest->op == src->op);
oldelems = ((StructLiteralExp *)dest)->elements;
newelems = ((StructLiteralExp *)src)->elements;
- if (((StructLiteralExp *)dest)->sd->isNested() && oldelems->dim == newelems->dim - 1)
+ if (((StructLiteralExp *)dest)->sd->isNested() && oldelems->length == newelems->length - 1)
oldelems->push(NULL);
}
else if (dest->op == TOKarrayliteral && src->op==TOKarrayliteral)
else
assert(0);
- assert(oldelems->dim == newelems->dim);
+ assert(oldelems->length == newelems->length);
- for (size_t i= 0; i < oldelems->dim; ++i)
+ for (size_t i= 0; i < oldelems->length; ++i)
{
Expression *e = (*newelems)[i];
Expression *o = (*oldelems)[i];
{
Expressions *expsx = new Expressions();
++CtfeStatus::numArrayAllocs;
- expsx->setDim(oldelems->dim);
- for (size_t j = 0; j < expsx->dim; j++)
+ expsx->setDim(oldelems->length);
+ for (size_t j = 0; j < expsx->length; j++)
{
if (j == indexToChange)
(*expsx)[j] = newelem;
Expressions *keysx = aae->keys;
Expressions *valuesx = aae->values;
int updated = 0;
- for (size_t j = valuesx->dim; j; )
+ for (size_t j = valuesx->length; j; )
{
j--;
Expression *ekey = (*aae->keys)[j];
if (elements)
{
size_t fieldsSoFar = 0;
- for (size_t i = 0; i < elements->dim; i++)
+ for (size_t i = 0; i < elements->length; i++)
{
Expression *z = NULL;
VarDeclaration *v = NULL;
if (i > 15)
{
- printf("...(total %d elements)\n", (int)elements->dim);
+ printf("...(total %d elements)\n", (int)elements->length);
return;
}
if (sd)
}
else if (cd)
{
- while (i - fieldsSoFar >= cd->fields.dim)
+ while (i - fieldsSoFar >= cd->fields.length)
{
- fieldsSoFar += cd->fields.dim;
+ fieldsSoFar += cd->fields.length;
cd = cd->baseClass;
for (int j = level; j > 0; --j) printf(" ");
printf(" BASE CLASS: %s\n", cd->toChars());
}
v = cd->fields[i - fieldsSoFar];
- assert((elements->dim + i) >= (fieldsSoFar + cd->fields.dim));
- size_t indx = (elements->dim - fieldsSoFar)- cd->fields.dim + i;
- assert(indx < elements->dim);
+ assert((elements->length + i) >= (fieldsSoFar + cd->fields.length));
+ size_t indx = (elements->length - fieldsSoFar)- cd->fields.length + i;
+ assert(indx < elements->length);
z = (*elements)[indx];
}
if (!z)
{
TypeStruct *ts = (TypeStruct *)t;
Expressions *exps = new Expressions();
- exps->setDim(ts->sym->fields.dim);
- for (size_t i = 0; i < ts->sym->fields.dim; i++)
+ exps->setDim(ts->sym->fields.length);
+ for (size_t i = 0; i < ts->sym->fields.length; i++)
{
(*exps)[i] = voidInitLiteral(ts->sym->fields[i]->type, ts->sym->fields[i]).copy();
}
Type *tb = t->toBasetype();
Type *tx;
if (tb->ty == Tsarray)
- tx = tb->nextOf()->sarrayOf(ale->elements ? ale->elements->dim : 0);
+ tx = tb->nextOf()->sarrayOf(ale->elements ? ale->elements->length : 0);
else
tx = tb->nextOf()->arrayOf();
e->e1 = ale->implicitCastTo(sc, tx);
((TypeStruct *)e->type)->sym == ((TypeStruct *)t)->sym)
{
result = MATCHconst;
- for (size_t i = 0; i < e->elements->dim; i++)
+ for (size_t i = 0; i < e->elements->length; i++)
{
Expression *el = (*e->elements)[i];
if (!el)
if (tb->ty == Tsarray)
{
TypeSArray *tsa = (TypeSArray *)tb;
- if (e->elements->dim != tsa->dim->toInteger())
+ if (e->elements->length != tsa->dim->toInteger())
result = MATCHnomatch;
}
Type *telement = tb->nextOf();
- if (!e->elements->dim)
+ if (!e->elements->length)
{
if (typen->ty != Tvoid)
result = typen->implicitConvTo(telement);
if (m < result)
result = m;
}
- for (size_t i = 0; i < e->elements->dim; i++)
+ for (size_t i = 0; i < e->elements->length; i++)
{
Expression *el = (*e->elements)[i];
if (result == MATCHnomatch)
TypeVector *tv = (TypeVector *)tb;
TypeSArray *tbase = (TypeSArray *)tv->basetype;
assert(tbase->ty == Tsarray);
- const size_t edim = e->elements->dim;
+ const size_t edim = e->elements->length;
const size_t tbasedim = tbase->dim->toInteger();
if (edim > tbasedim)
{
if (tb->ty == Taarray && typeb->ty == Taarray)
{
result = MATCHexact;
- for (size_t i = 0; i < e->keys->dim; i++)
+ for (size_t i = 0; i < e->keys->length; i++)
{
Expression *el = (*e->keys)[i];
MATCH m = el->implicitConvTo(((TypeAArray *)tb)->index);
if (targ->constConv(targ->castMod(mod)) == MATCHnomatch)
return;
}
- for (size_t i = j; i < e->arguments->dim; ++i)
+ for (size_t i = j; i < e->arguments->length; ++i)
{
Expression *earg = (*e->arguments)[i];
Type *targ = earg->type->toBasetype();
{
OverExp *eo = (OverExp *)e->e1;
FuncDeclaration *f = NULL;
- for (size_t i = 0; i < eo->vars->a.dim; i++)
+ for (size_t i = 0; i < eo->vars->a.length; i++)
{
Dsymbol *s = eo->vars->a[i];
FuncDeclaration *f2 = s->isFuncDeclaration();
size_t nparams = Parameter::dim(tf->parameters);
size_t j = (tf->linkage == LINKd && tf->varargs == 1); // if TypeInfoArray was prepended
- for (size_t i = j; i < e->arguments->dim; ++i)
+ for (size_t i = j; i < e->arguments->length; ++i)
{
Expression *earg = (*args)[i];
Type *targ = earg->type->toBasetype();
*/
if (!e->member && e->arguments)
{
- for (size_t i = 0; i < e->arguments->dim; ++i)
+ for (size_t i = 0; i < e->arguments->length; ++i)
{
Expression *earg = (*e->arguments)[i];
if (!earg) // Bugzilla 14853: if it's on overlapped field
{
static bool convertible(Loc loc, ClassDeclaration *cd, MOD mod)
{
- for (size_t i = 0; i < cd->fields.dim; i++)
+ for (size_t i = 0; i < cd->fields.length; i++)
{
VarDeclaration *v = cd->fields[i];
Initializer *init = v->_init;
{
OverExp *eo = (OverExp *)e->e1;
FuncDeclaration *f = NULL;
- for (size_t i = 0; i < eo->vars->a.dim; i++)
+ for (size_t i = 0; i < eo->vars->a.length; i++)
{
Dsymbol *s = eo->vars->a[i];
FuncDeclaration *f2 = s->isFuncDeclaration();
TupleExp *te = (TupleExp *)e->copy();
te->e0 = e->e0 ? e->e0->copy() : NULL;
te->exps = (Expressions *)e->exps->copy();
- for (size_t i = 0; i < te->exps->dim; i++)
+ for (size_t i = 0; i < te->exps->length; i++)
{
Expression *ex = (*te->exps)[i];
ex = ex->castTo(sc, t);
if (tb->ty == Tsarray)
{
TypeSArray *tsa = (TypeSArray *)tb;
- if (e->elements->dim != tsa->dim->toInteger())
+ if (e->elements->length != tsa->dim->toInteger())
goto L1;
}
if (e->basis)
ae->basis = e->basis->castTo(sc, tb->nextOf());
ae->elements = e->elements->copy();
- for (size_t i = 0; i < e->elements->dim; i++)
+ for (size_t i = 0; i < e->elements->length; i++)
{
Expression *ex = (*e->elements)[i];
if (!ex)
TypeVector *tv = (TypeVector *)tb;
TypeSArray *tbase = (TypeSArray *)tv->basetype;
assert(tbase->ty == Tsarray);
- const size_t edim = e->elements->dim;
+ const size_t edim = e->elements->length;
const size_t tbasedim = tbase->dim->toInteger();
if (edim > tbasedim)
goto L1;
AssocArrayLiteralExp *ae = (AssocArrayLiteralExp *)e->copy();
ae->keys = e->keys->copy();
ae->values = e->values->copy();
- assert(e->keys->dim == e->values->dim);
- for (size_t i = 0; i < e->keys->dim; i++)
+ assert(e->keys->length == e->values->length);
+ for (size_t i = 0; i < e->keys->length; i++)
{
Expression *ex = (*e->values)[i];
ex = ex->castTo(sc, tb->nextOf());
Type *tn = tb->nextOf();
if (ale->basis)
ale->basis = inferType(ale->basis, tn, flag);
- for (size_t i = 0; i < ale->elements->dim; i++)
+ for (size_t i = 0; i < ale->elements->length; i++)
{
Expression *e = (*ale->elements)[i];
if (e)
TypeAArray *taa = (TypeAArray *)tb;
Type *ti = taa->index;
Type *tv = taa->nextOf();
- for (size_t i = 0; i < aale->keys->dim; i++)
+ for (size_t i = 0; i < aale->keys->length; i++)
{
Expression *e = (*aale->keys)[i];
if (e)
(*aale->keys)[i] = e;
}
}
- for (size_t i = 0; i < aale->values->dim; i++)
+ for (size_t i = 0; i < aale->values->length; i++)
{
Expression *e = (*aale->values)[i];
if (e)
bool isVoidArrayLiteral(Expression *e, Type *other)
{
while (e->op == TOKarrayliteral && e->type->ty == Tarray
- && (((ArrayLiteralExp *)e)->elements->dim == 1))
+ && (((ArrayLiteralExp *)e)->elements->length == 1))
{
ArrayLiteralExp *ale = (ArrayLiteralExp *)e;
e = ale->getElement(0);
Type *t = e->type;
return (e->op == TOKarrayliteral && t->ty == Tarray &&
t->nextOf()->ty == Tvoid &&
- ((ArrayLiteralExp *)e)->elements->dim == 0);
+ ((ArrayLiteralExp *)e)->elements->length == 0);
}
// used by deduceType()
vtblInterfaces = NULL;
- //printf("ClassDeclaration(%s), dim = %d\n", id->toChars(), this->baseclasses->dim);
+ //printf("ClassDeclaration(%s), dim = %d\n", id->toChars(), this->baseclasses->length);
// For forward references
type = new TypeClass(this);
cd->storage_class |= storage_class;
- cd->baseclasses->setDim(this->baseclasses->dim);
- for (size_t i = 0; i < cd->baseclasses->dim; i++)
+ cd->baseclasses->setDim(this->baseclasses->length);
+ for (size_t i = 0; i < cd->baseclasses->length; i++)
{
BaseClass *b = (*this->baseclasses)[i];
BaseClass *b2 = new BaseClass(b->type->syntaxCopy());
baseok = BASEOKin;
// Expand any tuples in baseclasses[]
- for (size_t i = 0; i < baseclasses->dim; )
+ for (size_t i = 0; i < baseclasses->length; )
{
BaseClass *b = (*baseclasses)[i];
b->type = resolveBase(this, sc, scx, b->type);
}
// See if there's a base class as first in baseclasses[]
- if (baseclasses->dim)
+ if (baseclasses->length)
{
BaseClass *b = (*baseclasses)[0];
Type *tb = b->type->toBasetype();
// Treat the remaining entries in baseclasses as interfaces
// Check for errors, handle forward references
- for (size_t i = (baseClass ? 1 : 0); i < baseclasses->dim; )
+ for (size_t i = (baseClass ? 1 : 0); i < baseclasses->length; )
{
BaseClass *b = (*baseclasses)[i];
Type *tb = b->type->toBasetype();
storage_class |= baseClass->storage_class & STC_TYPECTOR;
}
- interfaces.length = baseclasses->dim - (baseClass ? 1 : 0);
+ interfaces.length = baseclasses->length - (baseClass ? 1 : 0);
interfaces.ptr = baseclasses->tdata() + (baseClass ? 1 : 0);
for (size_t i = 0; i < interfaces.length; i++)
* it can be resolved as a normal forward reference.
* Call addMember() and setScope() to make this class members visible from the base classes.
*/
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{
Dsymbol *s = (*members)[i];
s->addMember(sc, this);
/* Set scope so if there are forward references, we still might be able to
* resolve individual members like enums.
*/
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{
Dsymbol *s = (*members)[i];
//printf("[%d] setScope %s %s, sc2 = %p\n", i, s->kind(), s->toChars(), sc2);
sc2->pop();
}
- for (size_t i = 0; i < baseclasses->dim; i++)
+ for (size_t i = 0; i < baseclasses->length; i++)
{
BaseClass *b = (*baseclasses)[i];
Type *tb = b->type->toBasetype();
// initialize vtbl
if (baseClass)
{
- if (isCPPclass() && baseClass->vtbl.dim == 0)
+ if (isCPPclass() && baseClass->vtbl.length == 0)
{
error("C++ base class %s needs at least one virtual function", baseClass->toChars());
}
// Copy vtbl[] from base class
- vtbl.setDim(baseClass->vtbl.dim);
- memcpy(vtbl.tdata(), baseClass->vtbl.tdata(), sizeof(void *) * vtbl.dim);
+ vtbl.setDim(baseClass->vtbl.length);
+ memcpy(vtbl.tdata(), baseClass->vtbl.tdata(), sizeof(void *) * vtbl.length);
vthis = baseClass->vthis;
}
Scope *sc2 = newScope(sc);
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{
Dsymbol *s = (*members)[i];
s->importAll(sc2);
}
- // Note that members.dim can grow due to tuple expansion during semantic()
- for (size_t i = 0; i < members->dim; i++)
+ // Note that members.length can grow due to tuple expansion during semantic()
+ for (size_t i = 0; i < members->length; i++)
{
Dsymbol *s = (*members)[i];
s->semantic(sc2);
/* Following special member functions creation needs semantic analysis
* completion of sub-structs in each field types.
*/
- for (size_t i = 0; i < fields.dim; i++)
+ for (size_t i = 0; i < fields.length; i++)
{
VarDeclaration *v = fields[i];
Type *tb = v->type->baseElemOf();
if (!ctor && noDefaultCtor)
{
// A class object is always created by constructor, so this check is legitimate.
- for (size_t i = 0; i < fields.dim; i++)
+ for (size_t i = 0; i < fields.length; i++)
{
VarDeclaration *v = fields[i];
if (v->storage_class & STCnodefaultctor)
// Verify fields of a synchronized class are not public
if (storage_class & STCsynchronized)
{
- for (size_t i = 0; i < fields.dim; i++)
+ for (size_t i = 0; i < fields.length; i++)
{
VarDeclaration *vd = fields[i];
if (!vd->isThisDeclaration() &&
if (!cd)
return false;
//printf("ClassDeclaration::isBaseOf2(this = '%s', cd = '%s')\n", toChars(), cd->toChars());
- for (size_t i = 0; i < cd->baseclasses->dim; i++)
+ for (size_t i = 0; i < cd->baseclasses->length; i++)
{
BaseClass *b = (*cd->baseclasses)[i];
if (b->sym == this || isBaseOf2(b->sym))
{
// Search bases classes in depth-first, left to right order
- for (size_t i = 0; i < baseclasses->dim; i++)
+ for (size_t i = 0; i < baseclasses->length; i++)
{
BaseClass *b = (*baseclasses)[i];
*/
ClassDeclaration *ClassDeclaration::searchBase(Identifier *ident)
{
- for (size_t i = 0; i < baseclasses->dim; i++)
+ for (size_t i = 0; i < baseclasses->length; i++)
{
BaseClass *b = (*baseclasses)[i];
ClassDeclaration *cdb = b->type->isClassHandle();
if (!b->sym->alignsize)
b->sym->alignsize = Target::ptrsize;
cd->alignmember(b->sym->alignsize, b->sym->alignsize, &offset);
- assert(bi < vtblInterfaces->dim);
+ assert(bi < vtblInterfaces->length);
BaseClass *bv = (*vtblInterfaces)[bi];
if (b->sym->interfaces.length == 0)
{
fields.setDim(0);
unsigned offset = structsize;
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{
Dsymbol *s = (*members)[i];
s->setFieldOffset(this, &offset, false);
OverloadSet *os = s->isOverloadSet();
if (os)
{
- for (size_t i = 0; i < os->a.dim; i++)
+ for (size_t i = 0; i < os->a.length; i++)
{
Dsymbol *s2 = os->a[i];
FuncDeclaration *f2 = s2->isFuncDeclaration();
Dsymbols *vtbl = &cd->vtbl;
while (1)
{
- for (size_t i = 0; i < vtbl->dim; i++)
+ for (size_t i = 0; i < vtbl->length; i++)
{
FuncDeclaration *fd = (*vtbl)[i]->isFuncDeclaration();
if (!fd)
}
};
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{
Dsymbol *s = (*members)[i];
if (s->apply(&SearchAbstract::fp, this))
/* Iterate inherited member functions and check their abstract attribute.
*/
- for (size_t i = 1; i < vtbl.dim; i++)
+ for (size_t i = 1; i < vtbl.length; i++)
{
FuncDeclaration *fd = vtbl[i]->isFuncDeclaration();
//if (fd) printf("\tvtbl[%d] = [%s] %s\n", i, fd->loc.toChars(), fd->toChars());
baseok = BASEOKin;
// Expand any tuples in baseclasses[]
- for (size_t i = 0; i < baseclasses->dim; )
+ for (size_t i = 0; i < baseclasses->length; )
{
BaseClass *b = (*baseclasses)[i];
b->type = resolveBase(this, sc, scx, b->type);
goto Lancestorsdone;
}
- if (!baseclasses->dim && sc->linkage == LINKcpp)
+ if (!baseclasses->length && sc->linkage == LINKcpp)
classKind = ClassKind::cpp;
if (sc->linkage == LINKobjc)
objc()->setObjc(this);
// Check for errors, handle forward references
- for (size_t i = 0; i < baseclasses->dim; )
+ for (size_t i = 0; i < baseclasses->length; )
{
BaseClass *b = (*baseclasses)[i];
Type *tb = b->type->toBasetype();
}
baseok = BASEOKdone;
- interfaces.length = baseclasses->dim;
+ interfaces.length = baseclasses->length;
interfaces.ptr = baseclasses->tdata();
for (size_t i = 0; i < interfaces.length; i++)
if (!symtab)
symtab = new DsymbolTable();
- for (size_t i = 0; i < baseclasses->dim; i++)
+ for (size_t i = 0; i < baseclasses->length; i++)
{
BaseClass *b = (*baseclasses)[i];
Type *tb = b->type->toBasetype();
// Copy vtbl[] from base class
if (b->sym->vtblOffset())
{
- size_t d = b->sym->vtbl.dim;
+ size_t d = b->sym->vtbl.length;
if (d > 1)
{
vtbl.reserve(d - 1);
}
}
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{
Dsymbol *s = (*members)[i];
s->addMember(sc, this);
/* Set scope so if there are forward references, we still might be able to
* resolve individual members like enums.
*/
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{
Dsymbol *s = (*members)[i];
//printf("setScope %s %s\n", s->kind(), s->toChars());
s->setScope(sc2);
}
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{
Dsymbol *s = (*members)[i];
s->importAll(sc2);
}
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{
Dsymbol *s = (*members)[i];
s->semantic(sc2);
//printf("BaseClass::fillVtbl(this='%s', cd='%s')\n", sym->toChars(), cd->toChars());
if (vtbl)
- vtbl->setDim(sym->vtbl.dim);
+ vtbl->setDim(sym->vtbl.length);
// first entry is ClassInfo reference
- for (size_t j = sym->vtblOffset(); j < sym->vtbl.dim; j++)
+ for (size_t j = sym->vtblOffset(); j < sym->vtbl.length; j++)
{
FuncDeclaration *ifd = sym->vtbl[j]->isFuncDeclaration();
FuncDeclaration *fd;
void *pb = &baseInterfaces.ptr[i];
BaseClass *b2 = sym->interfaces.ptr[i];
- assert(b2->vtbl.dim == 0); // should not be filled yet
+ assert(b2->vtbl.length == 0); // should not be filled yet
BaseClass *b = (BaseClass *)memcpy(pb, b2, sizeof(BaseClass));
if (i) // single inheritance is i==0
}
bool result = false;
- for (size_t i = iStart; i < ad->fields.dim; i++)
+ for (size_t i = iStart; i < ad->fields.length; i++)
{
VarDeclaration *vd = ad->fields[i];
Type *tb = vd->type->baseElemOf();
{
/* It's only a type tuple if all the Object's are types
*/
- for (size_t i = 0; i < objects->dim; i++)
+ for (size_t i = 0; i < objects->length; i++)
{
RootObject *o = (*objects)[i];
if (o->dyncast() != DYNCAST_TYPE)
*/
Types *types = (Types *)objects;
Parameters *args = new Parameters();
- args->setDim(objects->dim);
+ args->setDim(objects->length);
OutBuffer buf;
int hasdeco = 1;
- for (size_t i = 0; i < types->dim; i++)
+ for (size_t i = 0; i < types->length; i++)
{
Type *t = (*types)[i];
//printf("type = %s\n", t->toChars());
{
//printf("TupleDeclaration::toAlias2() '%s' objects = %s\n", toChars(), objects->toChars());
- for (size_t i = 0; i < objects->dim; i++)
+ for (size_t i = 0; i < objects->length; i++)
{
RootObject *o = (*objects)[i];
if (Dsymbol *s = isDsymbol(o))
bool TupleDeclaration::needThis()
{
//printf("TupleDeclaration::needThis(%s)\n", toChars());
- for (size_t i = 0; i < objects->dim; i++)
+ for (size_t i = 0; i < objects->length; i++)
{
RootObject *o = (*objects)[i];
if (o->dyncast() == DYNCAST_EXPRESSION)
Expressions *exps = new Expressions();
- for (size_t pos = 0; pos < iexps->dim; pos++)
+ for (size_t pos = 0; pos < iexps->length; pos++)
{
Lexpand1:
Expression *e = (*iexps)[pos];
Parameter *arg = Parameter::getNth(tt->arguments, pos);
arg->type = arg->type->semantic(loc, sc);
- //printf("[%d] iexps->dim = %d, ", pos, iexps->dim);
+ //printf("[%d] iexps->length = %d, ", pos, iexps->length);
//printf("e = (%s %s, %s), ", Token::tochars[e->op], e->toChars(), e->type->toChars());
//printf("arg = (%s, %s)\n", arg->toChars(), arg->type->toChars());
if (e != ie)
{
- if (iexps->dim > nelems)
+ if (iexps->length > nelems)
goto Lnomatch;
if (e->type->implicitConvTo(arg->type))
continue;
if (e->op == TOKtuple)
{
TupleExp *te = (TupleExp *)e;
- if (iexps->dim - 1 + te->exps->dim > nelems)
+ if (iexps->length - 1 + te->exps->length > nelems)
goto Lnomatch;
iexps->remove(pos);
(*exps)[0] = ve;
expandAliasThisTuples(exps, 0);
- for (size_t u = 0; u < exps->dim ; u++)
+ for (size_t u = 0; u < exps->length ; u++)
{
Lexpand2:
Expression *ee = (*exps)[u];
arg = Parameter::getNth(tt->arguments, pos + u);
arg->type = arg->type->semantic(loc, sc);
- //printf("[%d+%d] exps->dim = %d, ", pos, u, exps->dim);
+ //printf("[%d+%d] exps->length = %d, ", pos, u, exps->length);
//printf("ee = (%s %s, %s), ", Token::tochars[ee->op], ee->toChars(), ee->type->toChars());
//printf("arg = (%s, %s)\n", arg->toChars(), arg->type->toChars());
- size_t iexps_dim = iexps->dim - 1 + exps->dim;
+ size_t iexps_dim = iexps->length - 1 + exps->length;
if (iexps_dim > nelems)
goto Lnomatch;
if (ee->type->implicitConvTo(arg->type))
}
}
}
- if (iexps->dim < nelems)
+ if (iexps->length < nelems)
goto Lnomatch;
ie = new TupleExp(_init->loc, iexps);
if (ie && ie->op == TOKtuple)
{
TupleExp *te = (TupleExp *)ie;
- size_t tedim = te->exps->dim;
+ size_t tedim = te->exps->length;
if (tedim != nelems)
{
::error(loc, "tuple of %d elements cannot be assigned to tuple of %d elements", (int)tedim, (int)nelems);
NewExp *ne = (NewExp *)ex;
if (type->toBasetype()->ty == Tclass)
{
- if (ne->newargs && ne->newargs->dim > 1)
+ if (ne->newargs && ne->newargs->length > 1)
{
mynew = true;
}
{
static bool arrayHasInvalidEnumInitializer(Expressions *elems)
{
- for (size_t i = 0; i < elems->dim; i++)
+ for (size_t i = 0; i < elems->length; i++)
{
Expression *e = (*elems)[i];
if (e && hasInvalidEnumInitializer(e))
// If this variable was really a tuple, set the offsets for the tuple fields
TupleDeclaration *v2 = aliassym->isTupleDeclaration();
assert(v2);
- for (size_t i = 0; i < v2->objects->dim; i++)
+ for (size_t i = 0; i < v2->objects->length; i++)
{
RootObject *o = (*v2->objects)[i];
assert(o->dyncast() == DYNCAST_EXPRESSION);
*poffset = ad->structsize; // Bugzilla 13613
return;
}
- for (size_t i = 0; i < ad->fields.dim; i++)
+ for (size_t i = 0; i < ad->fields.length; i++)
{
if (ad->fields[i] == this)
{
return false;
// Add fdthis to nestedrefs[] if not already there
- for (size_t i = 0; 1; i++)
- {
- if (i == nestedrefs.dim)
- {
- nestedrefs.push(fdthis);
- break;
- }
- if (nestedrefs[i] == fdthis)
- break;
- }
+ if (!nestedrefs.contains(fdthis))
+ nestedrefs.push(fdthis);
/* __require and __ensure will always get called directly,
* so they never make outer functions closure.
}
// Add this to fdv->closureVars[] if not already there
- for (size_t i = 0; 1; i++)
+ if (!sc->intypeof && !(sc->flags & SCOPEcompile))
{
- if (i == fdv->closureVars.dim)
- {
- if (!sc->intypeof && !(sc->flags & SCOPEcompile))
- fdv->closureVars.push(this);
- break;
- }
- if (fdv->closureVars[i] == this)
- break;
+ if (!fdv->closureVars.contains(this))
+ fdv->closureVars.push(this);
}
//printf("fdthis is %s\n", fdthis->toChars());
if (members)
{
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{
EnumMember *em = (*members)[i]->isEnumMember();
em->ed = this;
errors = true;
if (members)
{
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{
Dsymbol *s = (*members)[i];
s->errors = true; // poison all the members
if (!members) // enum ident : memtype;
return;
- if (members->dim == 0)
+ if (members->length == 0)
{
error("enum %s must have at least one member", toChars());
errors = true;
/* Each enum member gets the sce scope
*/
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{
EnumMember *em = (*members)[i]->isEnumMember();
if (em)
scopesym = this;
}
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{
EnumMember *em = (*members)[i]->isEnumMember();
if (em)
}
}
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{
EnumMember *em = (*members)[i]->isEnumMember();
if (em)
goto Lerrors;
}
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{
EnumMember *em = (*members)[i]->isEnumMember();
if (!em)
goto Lerrors;
}
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{
EnumMember *em = (*members)[i]->isEnumMember();
if (em)
* with the first member. If the following members were referenced
* during the first member semantic, their types should be unified.
*/
- for (size_t i = 0; i < ed->members->dim; i++)
+ for (size_t i = 0; i < ed->members->length; i++)
{
EnumMember *em = (*ed->members)[i]->isEnumMember();
if (!em || em == this || em->semanticRun < PASSsemanticdone || em->origType)
* and set this to be the previous value + 1
*/
EnumMember *emprev = NULL;
- for (size_t i = 0; i < ed->members->dim; i++)
+ for (size_t i = 0; i < ed->members->length; i++)
{
EnumMember *em = (*ed->members)[i]->isEnumMember();
if (em)
// import [cstdio] = std.stdio;
this->ident = aliasId;
}
- else if (packages && packages->dim)
+ else if (packages && packages->length)
{
// import [std].stdio;
this->ident = (*packages)[0];
Import *si = new Import(loc, packages, id, aliasId, isstatic);
- for (size_t i = 0; i < names.dim; i++)
+ for (size_t i = 0; i < names.length; i++)
{
si->addAlias(names[i], aliases[i]);
}
if (sc->explicitProtection)
protection = sc->protection;
- if (!isstatic && !aliasId && !names.dim)
+ if (!isstatic && !aliasId && !names.length)
{
sc->scopesym->importScope(mod, protection);
}
if (sc->explicitProtection)
protection = sc->protection;
- if (!aliasId && !names.dim) // neither a selective nor a renamed import
+ if (!aliasId && !names.length) // neither a selective nor a renamed import
{
ScopeDsymbol *scopesym = NULL;
if (sc->explicitProtection)
// import a.b.c.d;
Package *p = pkg; // a
scopesym->addAccessiblePackage(p, protection);
- for (size_t i = 1; i < packages->dim; i++) // [b, c]
+ for (size_t i = 1; i < packages->length; i++) // [b, c]
{
Identifier *id = (*packages)[i];
p = (Package *) p->symtab->lookup(id);
sc = sc->push(mod);
sc->protection = protection;
- for (size_t i = 0; i < aliasdecls.dim; i++)
+ for (size_t i = 0; i < aliasdecls.length; i++)
{
AliasDeclaration *ad = aliasdecls[i];
//printf("\tImport %s alias %s = %s, scope = %p\n", toPrettyChars(), aliases[i]->toChars(), names[i]->toChars(), ad->_scope);
if (packages)
{
- for (size_t i = 0; i < packages->dim; i++)
+ for (size_t i = 0; i < packages->length; i++)
{
Identifier *pid = (*packages)[i];
ob->printf("%s.", pid->toChars());
ob->writestring("???");
ob->writeByte(')');
- for (size_t i = 0; i < names.dim; i++)
+ for (size_t i = 0; i < names.length; i++)
{
if (i == 0)
ob->writeByte(':');
void Import::addMember(Scope *sc, ScopeDsymbol *sd)
{
//printf("Import::addMember(this=%s, sd=%s, sc=%p)\n", toChars(), sd->toChars(), sc);
- if (names.dim == 0)
+ if (names.length == 0)
return Dsymbol::addMember(sc, sd);
if (aliasId)
/* Instead of adding the import to sd's symbol table,
* add each of the alias=name pairs
*/
- for (size_t i = 0; i < names.dim; i++)
+ for (size_t i = 0; i < names.length; i++)
{
Identifier *name = names[i];
Identifier *alias = aliases[i];
void Import::setScope(Scope *sc)
{
Dsymbol::setScope(sc);
- if (aliasdecls.dim)
+ if (aliasdecls.length)
{
if (!mod)
importAll(sc);
sc = sc->push(mod);
sc->protection = protection;
- for (size_t i = 0; i < aliasdecls.dim; i++)
+ for (size_t i = 0; i < aliasdecls.length; i++)
{
AliasDeclaration *ad = aliasdecls[i];
ad->setScope(sc);
size_t CtfeStack::stackPointer()
{
- return values.dim;
+ return values.length;
}
Expression *CtfeStack::getThis()
void CtfeStack::endFrame()
{
- size_t oldframe = (size_t)(frames[frames.dim-1]);
- localThis = savedThis[savedThis.dim-1];
+ size_t oldframe = (size_t)(frames[frames.length-1]);
+ localThis = savedThis[savedThis.length-1];
popAll(framepointer);
framepointer = oldframe;
- frames.setDim(frames.dim - 1);
- savedThis.setDim(savedThis.dim -1);
+ frames.setDim(frames.length - 1);
+ savedThis.setDim(savedThis.length -1);
}
bool CtfeStack::isInCurrentFrame(VarDeclaration *v)
if ((v->isDataseg() || v->storage_class & STCmanifest) && !v->isCTFE())
{
assert(v->ctfeAdrOnStack >= 0 &&
- v->ctfeAdrOnStack < (int)globalValues.dim);
+ v->ctfeAdrOnStack < (int)globalValues.length);
return globalValues[v->ctfeAdrOnStack];
}
assert(v->ctfeAdrOnStack >= 0 && v->ctfeAdrOnStack < (int)stackPointer());
return;
}
savedId.push((void *)(size_t)(v->ctfeAdrOnStack));
- v->ctfeAdrOnStack = (int)values.dim;
+ v->ctfeAdrOnStack = (int)values.length;
vars.push(v);
values.push(NULL);
}
assert(!(v->storage_class & (STCref | STCout)));
int oldid = v->ctfeAdrOnStack;
v->ctfeAdrOnStack = (int)(size_t)(savedId[oldid]);
- if (v->ctfeAdrOnStack == (int)values.dim - 1)
+ if (v->ctfeAdrOnStack == (int)values.length - 1)
{
values.pop();
vars.pop();
{
if (stackPointer() > maxStackPointer)
maxStackPointer = stackPointer();
- assert(values.dim >= stackpointer);
- for (size_t i = stackpointer; i < values.dim; ++i)
+ assert(values.length >= stackpointer);
+ for (size_t i = stackpointer; i < values.length; ++i)
{
VarDeclaration *v = vars[i];
v->ctfeAdrOnStack = (int)(size_t)(savedId[i]);
void CtfeStack::saveGlobalConstant(VarDeclaration *v, Expression *e)
{
assert(v->_init && (v->isConst() || v->isImmutable() || v->storage_class & STCmanifest) && !v->isCTFE());
- v->ctfeAdrOnStack = (int)globalValues.dim;
+ v->ctfeAdrOnStack = (int)globalValues.length;
globalValues.push(e);
}
{
if (!td->objects)
return;
- for (size_t i= 0; i < td->objects->dim; ++i)
+ for (size_t i= 0; i < td->objects->length; ++i)
{
RootObject *o = td->objects->tdata()[i];
Expression *ex = isExpression(o);
void visit(CompoundStatement *s)
{
- for (size_t i = 0; i < s->statements->dim; i++)
+ for (size_t i = 0; i < s->statements->length; i++)
{
Statement *sx = (*s->statements)[i];
if (sx)
void visit(UnrolledLoopStatement *s)
{
- for (size_t i = 0; i < s->statements->dim; i++)
+ for (size_t i = 0; i < s->statements->length; i++)
{
Statement *sx = (*s->statements)[i];
if (sx)
ccf->onExpression(s->condition);
// Note that the body contains the the Case and Default
// statements, so we only need to compile the expressions
- for (size_t i = 0; i < s->cases->dim; i++)
+ for (size_t i = 0; i < s->cases->length; i++)
{
ccf->onExpression((*s->cases)[i]->exp);
}
{
if (s->_body)
ctfeCompile(s->_body);
- for (size_t i = 0; i < s->catches->dim; i++)
+ for (size_t i = 0; i < s->catches->length; i++)
{
Catch *ca = (*s->catches)[i];
if (ca->var)
{
Type *tb = fd->type->toBasetype();
assert(tb->ty == Tfunction);
- for (size_t i = 0; i < fd->parameters->dim; i++)
+ for (size_t i = 0; i < fd->parameters->length; i++)
{
VarDeclaration *v = (*fd->parameters)[i];
fd->ctfeCode->onDeclaration(v);
TupleExp *tup = (TupleExp *)e;
Expressions *expsx = NULL;
- for (size_t i = 0; i < tup->exps->dim; ++i)
+ for (size_t i = 0; i < tup->exps->length; ++i)
{
Expression *g = (*tup->exps)[i];
Expression *h = g;
if (!expsx)
{
expsx = new Expressions();
- expsx->setDim(tup->exps->dim);
- for (size_t j = 0; j < tup->exps->dim; j++)
+ expsx->setDim(tup->exps->length);
+ for (size_t j = 0; j < tup->exps->length; j++)
(*expsx)[j] = (*tup->exps)[j];
}
(*expsx)[i] = h;
assert(tb->ty == Tfunction);
TypeFunction *tf = (TypeFunction *)tb;
if (tf->varargs && arguments &&
- ((fd->parameters && arguments->dim != fd->parameters->dim) || (!fd->parameters && arguments->dim)))
+ ((fd->parameters && arguments->length != fd->parameters->length) || (!fd->parameters && arguments->length)))
{
fd->error("C-style variadic functions are not yet implemented in CTFE");
return CTFEExp::cantexp;
// Place to hold all the arguments to the function while
// we are evaluating them.
Expressions eargs;
- size_t dim = arguments ? arguments->dim : 0;
- assert((fd->parameters ? fd->parameters->dim : 0) == dim);
+ size_t dim = arguments ? arguments->length : 0;
+ assert((fd->parameters ? fd->parameters->length : 0) == dim);
/* Evaluate all the arguments to the function,
* store the results in eargs[]
if (istate->start == s)
istate->start = NULL;
- const size_t dim = s->statements ? s->statements->dim : 0;
+ const size_t dim = s->statements ? s->statements->length : 0;
for (size_t i = 0; i < dim; i++)
{
Statement *sx = (*s->statements)[i];
if (istate->start == s)
istate->start = NULL;
- const size_t dim = s->statements ? s->statements->dim : 0;
+ const size_t dim = s->statements ? s->statements->length : 0;
for (size_t i = 0; i < dim; i++)
{
Statement *sx = (*s->statements)[i];
// Check all members of an array for escaping local variables. Return false if error
static bool stopPointersEscapingFromArray(Loc loc, Expressions *elems)
{
- for (size_t i = 0; i < elems->dim; i++)
+ for (size_t i = 0; i < elems->length; i++)
{
Expression *m = (*elems)[i];
if (!m)
result = interpret(pue, s->exp, istate, ctfeNeedLvalue);
return;
}
- if (tf->next && tf->next->ty == Tdelegate && istate->fd->closureVars.dim > 0)
+ if (tf->next && tf->next->ty == Tdelegate && istate->fd->closureVars.length > 0)
{
// To support this, we need to copy all the closure vars
// into the delegate literal.
return;
Statement *scase = NULL;
- size_t dim = s->cases ? s->cases->dim : 0;
+ size_t dim = s->cases ? s->cases->length : 0;
for (size_t i = 0; i < dim; i++)
{
CaseStatement *cs = (*s->cases)[i];
{
Expression *e = NULL;
e = interpret(pue, s->_body, istate);
- for (size_t i = 0; i < s->catches->dim; i++)
+ for (size_t i = 0; i < s->catches->length; i++)
{
if (e || !istate->start) // goto target was found
break;
Type *extype = ex->thrown->originalClass()->type;
// Search for an appropriate catch clause.
- for (size_t i = 0; i < s->catches->dim; i++)
+ for (size_t i = 0; i < s->catches->length; i++)
{
Catch *ca = (*s->catches)[i];
Type *catype = ca->type;
// Reserve stack space for all tuple members
if (!td->objects)
return;
- for (size_t i = 0; i < td->objects->dim; ++i)
+ for (size_t i = 0; i < td->objects->length; ++i)
{
RootObject * o = (*td->objects)[i];
Expression *ex = isExpression(o);
{
// Check for static struct declarations, which aren't executable
AttribDeclaration *ad = e->declaration->isAttribDeclaration();
- if (ad && ad->decl && ad->decl->dim == 1)
+ if (ad && ad->decl && ad->decl->length == 1)
{
Dsymbol *sparent = (*ad->decl)[0];
if (sparent->isAggregateDeclaration() ||
return;
Expressions *expsx = e->exps;
- for (size_t i = 0; i < expsx->dim; i++)
+ for (size_t i = 0; i < expsx->length; i++)
{
Expression *exp = (*expsx)[i];
Expression *ex = interpret(exp, istate);
return;
Expressions *expsx = e->elements;
- size_t dim = expsx ? expsx->dim : 0;
+ size_t dim = expsx ? expsx->length : 0;
for (size_t i = 0; i < dim; i++)
{
Expression *exp = (*expsx)[i];
{
// todo: all tuple expansions should go in semantic phase.
expandTuples(expsx);
- if (expsx->dim != dim)
+ if (expsx->length != dim)
{
e->error("CTFE internal error: invalid array literal");
result = CTFEExp::cantexp;
Expressions *keysx = e->keys;
Expressions *valuesx = e->values;
- for (size_t i = 0; i < keysx->dim; i++)
+ for (size_t i = 0; i < keysx->length; i++)
{
Expression *ekey = (*keysx)[i];
Expression *evalue = (*valuesx)[i];
expandTuples(keysx);
if (valuesx != e->values)
expandTuples(valuesx);
- if (keysx->dim != valuesx->dim)
+ if (keysx->length != valuesx->length)
{
e->error("CTFE internal error: invalid AA");
result = CTFEExp::cantexp;
/* Remove duplicate keys
*/
- for (size_t i = 1; i < keysx->dim; i++)
+ for (size_t i = 1; i < keysx->length; i++)
{
Expression *ekey = (*keysx)[i - 1];
- for (size_t j = i; j < keysx->dim; j++)
+ for (size_t j = i; j < keysx->length; j++)
{
Expression *ekey2 = (*keysx)[j];
if (!ctfeEqual(e->loc, TOKequal, ekey, ekey2))
return;
}
- size_t dim = e->elements ? e->elements->dim : 0;
+ size_t dim = e->elements ? e->elements->length : 0;
Expressions *expsx = e->elements;
- if (dim != e->sd->fields.dim)
+ if (dim != e->sd->fields.length)
{
// guaranteed by AggregateDeclaration.fill and TypeStruct.defaultInitLiteral
- assert(e->sd->isNested() && dim == e->sd->fields.dim - 1);
+ assert(e->sd->isNested() && dim == e->sd->fields.length - 1);
/* If a nested struct has no initialized hidden pointer,
* set it to null to match the runtime behaviour.
expsx->push(ne);
++dim;
}
- assert(dim == e->sd->fields.dim);
+ assert(dim == e->sd->fields.length);
for (size_t i = 0; i < dim; i++)
{
if (expsx != e->elements)
{
expandTuples(expsx);
- if (expsx->dim != e->sd->fields.dim)
+ if (expsx->length != e->sd->fields.length)
{
e->error("CTFE internal error: invalid struct literal");
result = CTFEExp::cantexp;
return lenExpr;
size_t len = (size_t)(lenExpr->toInteger());
Type *elemType = ((TypeArray *)newtype)->next;
- if (elemType->ty == Tarray && argnum < (int)arguments->dim - 1)
+ if (elemType->ty == Tarray && argnum < (int)arguments->length - 1)
{
Expression *elem = recursivelyCreateArrayLiteral(pue, loc, elemType, istate,
arguments, argnum + 1);
ae->ownedByCtfe = OWNEDctfe;
return ae;
}
- assert(argnum == (int)arguments->dim - 1);
+ assert(argnum == (int)arguments->length - 1);
if (elemType->ty == Tchar || elemType->ty == Twchar || elemType->ty == Tdchar)
{
const unsigned ch = (unsigned)elemType->defaultInitLiteral(loc)->toInteger();
{
StructDeclaration *sd = ((TypeStruct *)e->newtype->toBasetype())->sym;
Expressions *exps = new Expressions();
- exps->reserve(sd->fields.dim);
+ exps->reserve(sd->fields.length);
if (e->arguments)
{
- exps->setDim(e->arguments->dim);
- for (size_t i = 0; i < exps->dim; i++)
+ exps->setDim(e->arguments->length);
+ for (size_t i = 0; i < exps->length; i++)
{
Expression *ex = (*e->arguments)[i];
ex = interpret(ex, istate);
ClassDeclaration *cd = ((TypeClass *)e->newtype->toBasetype())->sym;
size_t totalFieldCount = 0;
for (ClassDeclaration *c = cd; c; c = c->baseClass)
- totalFieldCount += c->fields.dim;
+ totalFieldCount += c->fields.length;
Expressions *elems = new Expressions;
elems->setDim(totalFieldCount);
size_t fieldsSoFar = totalFieldCount;
for (ClassDeclaration *c = cd; c; c = c->baseClass)
{
- fieldsSoFar -= c->fields.dim;
- for (size_t i = 0; i < c->fields.dim; i++)
+ fieldsSoFar -= c->fields.length;
+ for (size_t i = 0; i < c->fields.length; i++)
{
VarDeclaration *v = c->fields[i];
if (v->inuse)
if (e->newtype->toBasetype()->isscalar())
{
Expression *newval;
- if (e->arguments && e->arguments->dim)
+ if (e->arguments && e->arguments->length)
newval = (*e->arguments)[0];
else
newval = e->newtype->defaultInitLiteral(e->loc);
if (!v->overlapped)
return;
- for (size_t i = 0; i < sle->sd->fields.dim; i++)
+ for (size_t i = 0; i < sle->sd->fields.length; i++)
{
VarDeclaration *v2 = sle->sd->fields[i];
if (v == v2 || !v->isOverlappedWith(v2))
e->error("CTFE internal error: cannot find field %s in %s", v->toChars(), ex->toChars());
return CTFEExp::cantexp;
}
- assert(0 <= fieldi && fieldi < (int)sle->elements->dim);
+ assert(0 <= fieldi && fieldi < (int)sle->elements->length);
// If it's a union, set all other members of this union to void
stompOverlappedFields(sle, v);
Expressions *oldelems = ((ArrayLiteralExp *)oldval)->elements;
Expressions *newelems = ((ArrayLiteralExp *)newval)->elements;
- assert(oldelems->dim == newelems->dim);
+ assert(oldelems->length == newelems->length);
Type *elemtype = oldval->type->nextOf();
- for (size_t i = 0; i < newelems->dim; i++)
+ for (size_t i = 0; i < newelems->length; i++)
{
Expression *oldelem = (*oldelems)[i];
Expression *newelem = paintTypeOntoLiteral(elemtype, (*newelems)[i]);
if (e1->op == TOKarrayliteral)
{
lowerbound = 0;
- upperbound = ((ArrayLiteralExp *)e1)->elements->dim;
+ upperbound = ((ArrayLiteralExp *)e1)->elements->length;
}
else if (e1->op == TOKstring)
{
Expressions *newelems = ((ArrayLiteralExp *)newval)->elements;
Type *elemtype = existingAE->type->nextOf();
bool needsPostblit = e->op != TOKblit && e->e2->isLvalue();
- for (size_t j = 0; j < newelems->dim; j++)
+ for (size_t j = 0; j < newelems->length; j++)
{
Expression *newelem = (*newelems)[j];
newelem = paintTypeOntoLiteral(elemtype, newelem);
Expression *assignTo(ArrayLiteralExp *ae)
{
- return assignTo(ae, 0, ae->elements->dim);
+ return assignTo(ae, 0, ae->elements->length);
}
Expression *assignTo(ArrayLiteralExp *ae, size_t lwr, size_t upr)
if (fd->ident == Id::__ArrayPostblit ||
fd->ident == Id::__ArrayDtor)
{
- assert(e->arguments->dim == 1);
+ assert(e->arguments->length == 1);
Expression *ea = (*e->arguments)[0];
//printf("1 ea = %s %s\n", ea->type->toChars(), ea->toChars());
if (ea->op == TOKslice)
// Convert literal __vector(int) -> __vector([array])
Expressions *elements = new Expressions();
elements->setDim(e->dim);
- for (size_t i = 0; i < elements->dim; i++)
+ for (size_t i = 0; i < elements->length; i++)
(*elements)[i] = copyLiteral(e->e1).copy();
TypeSArray *type = NULL;
if (e->type->ty == Tvector)
ale->ownedByCtfe = OWNEDctfe;
// Bugzilla 14686
- for (size_t i = 0; i < ale->elements->dim; i++)
+ for (size_t i = 0; i < ale->elements->length; i++)
{
Expression *ex = evaluatePostblit(istate, (*ale->elements)[i]);
if (exceptionOrCant(ex))
if (sd->dtor)
{
ArrayLiteralExp *ale = (ArrayLiteralExp *)result;
- for (size_t i = 0; i < ale->elements->dim; i++)
+ for (size_t i = 0; i < ale->elements->length; i++)
{
Expression *el = (*ale->elements)[i];
result = interpretFunction(pue, sd->dtor, istate, NULL, el);
{
ArrayLiteralExp *ale = (ArrayLiteralExp *)ie->e1;
const size_t indx = (size_t)ie->e2->toInteger();
- if (indx < ale->elements->dim)
+ if (indx < ale->elements->length)
{
Expression *xx = (*ale->elements)[indx];
if (xx)
Expressions *keysx = aae->keys;
Expressions *valuesx = aae->values;
size_t removed = 0;
- for (size_t j = 0; j < valuesx->dim; ++j)
+ for (size_t j = 0; j < valuesx->length; ++j)
{
Expression *ekey = (*keysx)[j];
int eq = ctfeEqual(e->loc, TOKequal, ekey, index);
(*valuesx)[j - removed] = (*valuesx)[j];
}
}
- valuesx->dim = valuesx->dim - removed;
- keysx->dim = keysx->dim - removed;
+ valuesx->length = valuesx->length - removed;
+ keysx->length = keysx->length - removed;
new(pue) IntegerExp(e->loc, removed ? 1 : 0, Type::tbool);
result = pue->exp();
}
// or is an array literal or struct literal of void elements.
bool isEntirelyVoid(Expressions *elems)
{
- for (size_t i = 0; i < elems->dim; i++)
+ for (size_t i = 0; i < elems->length; i++)
{
Expression *e = (*elems)[i];
// It can be NULL for performance reasons,
// Scrub all members of an array. Return false if error
Expression *scrubArray(Loc loc, Expressions *elems, bool structlit)
{
- for (size_t i = 0; i < elems->dim; i++)
+ for (size_t i = 0; i < elems->length; i++)
{
Expression *e = (*elems)[i];
// It can be NULL for performance reasons,
Expression *scrubArrayCache(Expressions *elems)
{
- for (size_t i = 0; i < elems->dim; i++)
+ for (size_t i = 0; i < elems->length; i++)
{
Expression *e = (*elems)[i];
(*elems)[i] = scrubCacheValue(e);
return earg;
dinteger_t len = 0;
if (earg->op == TOKassocarrayliteral)
- len = ((AssocArrayLiteralExp *)earg)->keys->dim;
+ len = ((AssocArrayLiteralExp *)earg)->keys->length;
else
assert(earg->op == TOKnull);
new(pue) IntegerExp(earg->loc, len, Type::tsize_t);
return NULL;
assert(earg->op == TOKassocarrayliteral);
AssocArrayLiteralExp *aae = (AssocArrayLiteralExp *)copyLiteral(earg).copy();
- for (size_t i = 0; i < aae->keys->dim; i++)
+ for (size_t i = 0; i < aae->keys->length; i++)
{
if (Expression *e = evaluatePostblit(istate, (*aae->keys)[i]))
return e;
assert(fd && fd->fbody);
assert(fd->parameters);
- size_t numParams = fd->parameters->dim;
+ size_t numParams = fd->parameters->length;
assert(numParams == 1 || numParams == 2);
Parameter *fparam = Parameter::getNth(((TypeFunction *)fd->type)->parameters, numParams - 1);
args.setDim(numParams);
AssocArrayLiteralExp *ae = (AssocArrayLiteralExp *)aa;
- if (!ae->keys || ae->keys->dim == 0)
+ if (!ae->keys || ae->keys->length == 0)
return new IntegerExp(deleg->loc, 0, Type::tsize_t);
Expression *eresult;
- for (size_t i = 0; i < ae->keys->dim; ++i)
+ for (size_t i = 0; i < ae->keys->length; ++i)
{
Expression *ekey = (*ae->keys)[i];
Expression *evalue = (*ae->values)[i];
assert(fd && fd->fbody);
assert(fd->parameters);
- size_t numParams = fd->parameters->dim;
+ size_t numParams = fd->parameters->length;
assert(numParams == 1 || numParams == 2);
Type *charType = (*fd->parameters)[numParams-1]->type;
Type *indexType = numParams == 2 ? (*fd->parameters)[0]->type
FuncDeclaration *fd, Expressions *arguments, Expression *pthis)
{
Expression *e = NULL;
- size_t nargs = arguments ? arguments->dim : 0;
+ size_t nargs = arguments ? arguments->length : 0;
if (!pthis)
{
if (isBuiltin(fd) == BUILTINyes)
{
Expressions args;
args.setDim(nargs);
- for (size_t i = 0; i < args.dim; i++)
+ for (size_t i = 0; i < args.length; i++)
{
Expression *earg = (*arguments)[i];
earg = interpret(earg, istate);
else // (nargs == 3)
{
if (id == Id::_aaApply)
- return interpret_aaApply(pue, istate, firstarg, (Expression *)(arguments->data[2]));
+ return interpret_aaApply(pue, istate, firstarg, (*arguments)[2]);
if (id == Id::_aaApply2)
- return interpret_aaApply(pue, istate, firstarg, (Expression *)(arguments->data[2]));
+ return interpret_aaApply(pue, istate, firstarg, (*arguments)[2]);
}
}
}
// At present, the constructors just copy their arguments into the struct.
// But we might need some magic if stack tracing gets added to druntime.
StructLiteralExp *se = ((ClassReferenceExp *)pthis)->value;
- assert(arguments->dim <= se->elements->dim);
- for (size_t i = 0; i < arguments->dim; ++i)
+ assert(arguments->length <= se->elements->length);
+ for (size_t i = 0; i < arguments->length; ++i)
{
e = interpret((*arguments)[i], istate);
if (exceptionOrCantInterpret(e))
if (e->op == TOKarrayliteral)
{
ArrayLiteralExp *ale = (ArrayLiteralExp *)e;
- for (size_t i = 0; i < ale->elements->dim; i++)
+ for (size_t i = 0; i < ale->elements->length; i++)
{
e = evaluatePostblit(istate, (*ale->elements)[i]);
if (e)
if (e->op == TOKarrayliteral)
{
ArrayLiteralExp *alex = (ArrayLiteralExp *)e;
- for (size_t i = alex->elements->dim; 0 < i--; )
+ for (size_t i = alex->elements->length; 0 < i--; )
e = evaluateDtor(istate, (*alex->elements)[i]);
}
else if (e->op == TOKstructliteral)
void visit(ArrayLiteralExp *e)
{
- size_t dim = e->elements ? e->elements->dim : 0;
+ size_t dim = e->elements ? e->elements->length : 0;
buf->printf("A%u", dim);
for (size_t i = 0; i < dim; i++)
{
void visit(AssocArrayLiteralExp *e)
{
- size_t dim = e->keys->dim;
+ size_t dim = e->keys->length;
buf->printf("A%u", dim);
for (size_t i = 0; i < dim; i++)
{
void visit(StructLiteralExp *e)
{
- size_t dim = e->elements ? e->elements->dim : 0;
+ size_t dim = e->elements ? e->elements->length : 0;
buf->printf("S%u", dim);
for (size_t i = 0; i < dim; i++)
{
// into:
// foo\bar\baz
const char *filename = ident->toChars();
- if (packages && packages->dim)
+ if (packages && packages->length)
{
OutBuffer buf;
OutBuffer dotmods;
Array<const char *> *ms = global.params.modFileAliasStrings;
- const size_t msdim = ms ? ms->dim : 0;
+ const size_t msdim = ms ? ms->length : 0;
- for (size_t i = 0; i < packages->dim; i++)
+ for (size_t i = 0; i < packages->length; i++)
{
Identifier *pid = (*packages)[i];
const char *p = pid->toChars();
OutBuffer buf;
if (packages)
{
- for (size_t i = 0; i < packages->dim; i++)
+ for (size_t i = 0; i < packages->length; i++)
{
Identifier *pid = (*packages)[i];
buf.writestring(pid->toChars());
*/
if (global.path)
{
- for (size_t i = 0; i < global.path->dim; i++)
+ for (size_t i = 0; i < global.path->length; i++)
{
const char *p = (*global.path)[i];
fprintf(stderr, "import path[%llu] = %s\n", (ulonglong)i, p);
// If it isn't there, some compiler rewrites, like
// classinst == classinst -> .object.opEquals(classinst, classinst)
// would fail inside object.d.
- if (members->dim == 0 || ((*members)[0])->ident != Id::object ||
+ if (members->length == 0 || ((*members)[0])->ident != Id::object ||
(*members)[0]->isImport() == NULL)
{
Import *im = new Import(Loc(), NULL, Id::object, NULL, 0);
{
// Add all symbols into module's symbol table
symtab = new DsymbolTable();
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{
Dsymbol *s = (*members)[i];
s->addMember(sc, sc->scopesym);
* before any semantic() on any of them.
*/
setScope(sc); // remember module scope for semantic
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{
Dsymbol *s = (*members)[i];
s->setScope(sc);
}
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{
Dsymbol *s = (*members)[i];
s->importAll(sc);
//printf("Module = %p, linkage = %d\n", sc->scopesym, sc->linkage);
// Pass 1 semantic routines: do public side of the definition
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{
Dsymbol *s = (*members)[i];
//printf("Module = %p\n", sc.scopesym);
// Pass 2 semantic routines: do initializers and function bodies
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{
Dsymbol *s = (*members)[i];
s->semantic2(sc);
//printf("Module = %p\n", sc.scopesym);
// Pass 3 semantic routines: do initializers and function bodies
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{
Dsymbol *s = (*members)[i];
//printf("Module %s: %s.semantic3()\n", toChars(), s->toChars());
void Module::clearCache()
{
- for (size_t i = 0; i < amodules.dim; i++)
+ for (size_t i = 0; i < amodules.length; i++)
{
Module *m = amodules[i];
m->searchCacheIdent = NULL;
void Module::addDeferredSemantic(Dsymbol *s)
{
// Don't add it if it is already there
- for (size_t i = 0; i < deferred.dim; i++)
+ for (size_t i = 0; i < deferred.length; i++)
{
Dsymbol *sd = deferred[i];
static int nested;
if (nested)
return;
- //if (deferred.dim) printf("+Module::runDeferredSemantic(), len = %d\n", deferred.dim);
+ //if (deferred.length) printf("+Module::runDeferredSemantic(), len = %d\n", deferred.length);
nested++;
size_t len;
do
{
dprogress = 0;
- len = deferred.dim;
+ len = deferred.length;
if (!len)
break;
s->semantic(NULL);
//printf("deferred: %s, parent = %s\n", s->toChars(), s->parent->toChars());
}
- //printf("\tdeferred.dim = %d, len = %d, dprogress = %d\n", deferred.dim, len, dprogress);
+ //printf("\tdeferred.length = %d, len = %d, dprogress = %d\n", deferred.length, len, dprogress);
if (todoalloc)
free(todoalloc);
- } while (deferred.dim < len || dprogress); // while making progress
+ } while (deferred.length < len || dprogress); // while making progress
nested--;
- //printf("-Module::runDeferredSemantic(), len = %d\n", deferred.dim);
+ //printf("-Module::runDeferredSemantic(), len = %d\n", deferred.length);
}
void Module::runDeferredSemantic2()
Module::runDeferredSemantic();
Dsymbols *a = &Module::deferred2;
- for (size_t i = 0; i < a->dim; i++)
+ for (size_t i = 0; i < a->length; i++)
{
Dsymbol *s = (*a)[i];
//printf("[%d] %s semantic2a\n", i, s->toPrettyChars());
Module::runDeferredSemantic2();
Dsymbols *a = &Module::deferred3;
- for (size_t i = 0; i < a->dim; i++)
+ for (size_t i = 0; i < a->length; i++)
{
Dsymbol *s = (*a)[i];
//printf("[%d] %s semantic3a\n", i, s->toPrettyChars());
int Module::imports(Module *m)
{
//printf("%s Module::imports(%s)\n", toChars(), m->toChars());
- for (size_t i = 0; i < aimports.dim; i++)
+ for (size_t i = 0; i < aimports.length; i++)
{
Module *mi = aimports[i];
if (mi == m)
//printf("Module::selfImports() %s\n", toChars());
if (selfimports == 0)
{
- for (size_t i = 0; i < amodules.dim; i++)
+ for (size_t i = 0; i < amodules.length; i++)
amodules[i]->insearch = 0;
selfimports = imports(this) + 1;
- for (size_t i = 0; i < amodules.dim; i++)
+ for (size_t i = 0; i < amodules.length; i++)
amodules[i]->insearch = 0;
}
return selfimports == 2;
//printf("Module::rootImports() %s\n", toChars());
if (rootimports == 0)
{
- for (size_t i = 0; i < amodules.dim; i++)
+ for (size_t i = 0; i < amodules.length; i++)
amodules[i]->insearch = 0;
rootimports = 1;
- for (size_t i = 0; i < amodules.dim; ++i)
+ for (size_t i = 0; i < amodules.length; ++i)
{
Module *m = amodules[i];
if (m->isRoot() && imports(m))
}
}
- for (size_t i = 0; i < amodules.dim; i++)
+ for (size_t i = 0; i < amodules.length; i++)
amodules[i]->insearch = 0;
}
return rootimports == 2;
{
OutBuffer buf;
- if (packages && packages->dim)
+ if (packages && packages->length)
{
- for (size_t i = 0; i < packages->dim; i++)
+ for (size_t i = 0; i < packages->length; i++)
{
Identifier *pid = (*packages)[i];
buf.writestring(pid->toChars());
if (packages)
{
- for (size_t i = 0; i < packages->dim; i++)
+ for (size_t i = 0; i < packages->length; i++)
{
Identifier *pid = (*packages)[i];
Package *pkg;
if (!global.path)
return NULL;
- for (size_t i = 0; i < global.path->dim; i++)
+ for (size_t i = 0; i < global.path->length; i++)
{
const char *p = (*global.path)[i];
// Workaround for missing Parameter instance for variadic params. (it's unnecessary to instantiate one).
bool isCVariadicParameter(Dsymbols *a, const utf8_t *p, size_t len)
{
- for (size_t i = 0; i < a->dim; i++)
+ for (size_t i = 0; i < a->length; i++)
{
TypeFunction *tf = isTypeFunction((*a)[i]);
if (tf && tf->varargs == 1 && cmp("...", p, len) == 0)
TypeFunction *tf = isTypeFunction(s);
if (tf && tf->parameters)
{
- for (size_t k = 0; k < tf->parameters->dim; k++)
+ for (size_t k = 0; k < tf->parameters->length; k++)
{
Parameter *fparam = (*tf->parameters)[k];
if (fparam->ident && cmp(fparam->ident->toChars(), p, len) == 0)
*/
static Parameter *isEponymousFunctionParameter(Dsymbols *a, const utf8_t *p, size_t len)
{
- for (size_t i = 0; i < a->dim; i++)
+ for (size_t i = 0; i < a->length; i++)
{
TemplateDeclaration *td = (*a)[i]->isTemplateDeclaration();
if (td && td->onemember)
global.params.ddocfiles->shift(p);
// Override with the ddoc macro files from the command line
- for (size_t i = 0; i < global.params.ddocfiles->dim; i++)
+ for (size_t i = 0; i < global.params.ddocfiles->length; i++)
{
FileName f((*global.params.ddocfiles)[i]);
File file(&f);
tm->tempdecl->isTemplateDeclaration() : NULL;
if (td && td->members)
{
- for (size_t i = 0; i < td->members->dim; i++)
+ for (size_t i = 0; i < td->members->length; i++)
{
Dsymbol *sm = (*td->members)[i];
TemplateMixin *tmc = sm->isTemplateMixin();
sc = sc->push(sds);
- for (size_t i = 0; i < sds->members->dim; i++)
+ for (size_t i = 0; i < sds->members->length; i++)
{
Dsymbol *s = (*sds->members)[i];
//printf("\ts = '%s'\n", s->toChars());
{
// Put the declaration signatures as the document 'title'
buf->writestring(ddoc_decl_s);
- for (size_t i = 0; i < dc->a.dim; i++)
+ for (size_t i = 0; i < dc->a.length; i++)
{
Dsymbol *sx = dc->a[i];
return;
if (ed->isAnonymous() && ed->members)
{
- for (size_t i = 0; i < ed->members->dim; i++)
+ for (size_t i = 0; i < ed->members->length; i++)
{
Dsymbol *s = (*ed->members)[i];
emitComment(s, buf, sc);
if (d)
{
- for (size_t i = 0; i < d->dim; i++)
+ for (size_t i = 0; i < d->length; i++)
{
Dsymbol *s = (*d)[i];
//printf("AttribDeclaration::emitComment %s\n", s->toChars());
* a template, then include(NULL, NULL) will fail.
*/
Dsymbols *d = cd->decl ? cd->decl : cd->elsedecl;
- for (size_t i = 0; i < d->dim; i++)
+ for (size_t i = 0; i < d->length; i++)
{
Dsymbol *s = (*d)[i];
emitComment(s, buf, sc);
if (d->isVarDeclaration() && td)
{
buf->writeByte('(');
- if (td->origParameters && td->origParameters->dim)
+ if (td->origParameters && td->origParameters->length)
{
- for (size_t i = 0; i < td->origParameters->dim; i++)
+ for (size_t i = 0; i < td->origParameters->length; i++)
{
if (i)
buf->writestring(", ");
buf->printf("%s %s", cd->kind(), cd->toChars());
}
int any = 0;
- for (size_t i = 0; i < cd->baseclasses->dim; i++)
+ for (size_t i = 0; i < cd->baseclasses->length; i++)
{
BaseClass *bc = (*cd->baseclasses)[i];
dc->parseSections(comment);
- for (size_t i = 0; i < dc->sections.dim; i++)
+ for (size_t i = 0; i < dc->sections.length; i++)
{
Section *sec = dc->sections[i];
void DocComment::writeSections(Scope *sc, Dsymbols *a, OutBuffer *buf)
{
- assert(a->dim);
+ assert(a->length);
//printf("DocComment::writeSections()\n");
Loc loc = (*a)[0]->loc;
buf->writestring("$(DDOC_SECTIONS ");
size_t offset2 = buf->offset;
- for (size_t i = 0; i < sections.dim; i++)
+ for (size_t i = 0; i < sections.length; i++)
{
Section *sec = sections[i];
if (sec->nooutput)
sec->write(loc, this, sc, a, buf);
}
- for (size_t i = 0; i < a->dim; i++)
+ for (size_t i = 0; i < a->length; i++)
{
Dsymbol *s = (*a)[i];
if (Dsymbol *td = getEponymousParent(s))
void Section::write(Loc loc, DocComment *, Scope *sc, Dsymbols *a, OutBuffer *buf)
{
- assert(a->dim);
+ assert(a->length);
if (namelen)
{
void ParamSection::write(Loc loc, DocComment *, Scope *sc, Dsymbols *a, OutBuffer *buf)
{
- assert(a->dim);
+ assert(a->length);
Dsymbol *s = (*a)[0]; // test
const utf8_t *p = body;
goto L1; // write out last one
buf->writestring(")\n");
- TypeFunction *tf = a->dim == 1 ? isTypeFunction(s) : NULL;
+ TypeFunction *tf = a->length == 1 ? isTypeFunction(s) : NULL;
if (tf)
{
- size_t pcount = (tf->parameters ? tf->parameters->dim : 0) + (int)(tf->varargs == 1);
+ size_t pcount = (tf->parameters ? tf->parameters->length : 0) + (int)(tf->varargs == 1);
if (pcount != paramcount)
{
warning(s->loc, "Ddoc: parameter count mismatch");
bool isIdentifier(Dsymbols *a, const utf8_t *p, size_t len)
{
- for (size_t i = 0; i < a->dim; i++)
+ for (size_t i = 0; i < a->length; i++)
{
const char *s = (*a)[i]->ident->toChars();
if (cmp(s, p, len) == 0)
Parameter *isFunctionParameter(Dsymbols *a, const utf8_t *p, size_t len)
{
- for (size_t i = 0; i < a->dim; i++)
+ for (size_t i = 0; i < a->length; i++)
{
Parameter *fparam = isFunctionParameter((*a)[i], p, len);
if (fparam)
TemplateParameter *isTemplateParameter(Dsymbols *a, const utf8_t *p, size_t len)
{
- for (size_t i = 0; i < a->dim; i++)
+ for (size_t i = 0; i < a->length; i++)
{
TemplateDeclaration *td = (*a)[i]->isTemplateDeclaration();
// Check for the parent, if the current symbol is not a template declaration.
td = getEponymousParent((*a)[i]);
if (td && td->origParameters)
{
- for (size_t k = 0; k < td->origParameters->dim; k++)
+ for (size_t k = 0; k < td->origParameters->length; k++)
{
TemplateParameter *tp = (*td->origParameters)[k];
if (tp->ident && cmp(tp->ident->toChars(), p, len) == 0)
void highlightText(Scope *sc, Dsymbols *a, OutBuffer *buf, size_t offset)
{
- Dsymbol *s = a->dim ? (*a)[0] : NULL; // test
+ Dsymbol *s = a->length ? (*a)[0] : NULL; // test
//printf("highlightText()\n");
AggregateDeclaration *ad = f->isMember2();
assert(ad);
- for (size_t i = 0; i < ad->fields.dim; i++)
+ for (size_t i = 0; i < ad->fields.length; i++)
{
VarDeclaration *v = ad->fields[i];
bool mustInit = (v->storage_class & STCnodefaultctor ||
OverloadSet *osnew = NULL;
if (sold && (osold = sold->isOverloadSet()) != NULL &&
snew && (osnew = snew->isOverloadSet()) != NULL &&
- osold->a.dim == osnew->a.dim)
+ osold->a.length == osnew->a.length)
return;
OutBuffer buf;
buf.writestring("local import search method found ");
if (osold)
- buf.printf("%s %s (%d overloads)", sold->kind(), sold->toPrettyChars(), (int)osold->a.dim);
+ buf.printf("%s %s (%d overloads)", sold->kind(), sold->toPrettyChars(), (int)osold->a.length);
else if (sold)
buf.printf("%s %s", sold->kind(), sold->toPrettyChars());
else
buf.writestring("nothing");
buf.writestring(" instead of ");
if (osnew)
- buf.printf("%s %s (%d overloads)", snew->kind(), snew->toPrettyChars(), (int)osnew->a.dim);
+ buf.printf("%s %s (%d overloads)", snew->kind(), snew->toPrettyChars(), (int)osnew->a.length);
else if (snew)
buf.printf("%s %s", snew->kind(), snew->toPrettyChars());
else
{
if (t->arguments)
{
- for (size_t i = 0; i < t->arguments->dim; i++)
+ for (size_t i = 0; i < t->arguments->length; i++)
{
Type *tprm = (*t->arguments)[i]->type;
if (tprm)
determineSize(loc);
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{
Dsymbol *s = (*members)[i];
//printf("\t[%d] %s\n", i, s->toChars());
Scope *sc2 = newScope(sc);
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{
Dsymbol *s = (*members)[i];
s->semantic3(sc2);
if (sizeok != SIZEOKnone)
return true;
- //printf("determineFields() %s, fields.dim = %d\n", toChars(), fields.dim);
+ //printf("determineFields() %s, fields.length = %d\n", toChars(), fields.length);
fields.setDim(0);
struct SV
SV sv;
sv.agg = this;
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{
Dsymbol *s = (*members)[i];
if (s->apply(&SV::func, &sv))
{
//printf("AggregateDeclaration::checkOverlappedFields() %s\n", toChars());
assert(sizeok == SIZEOKdone);
- size_t nfields = fields.dim;
+ size_t nfields = fields.length;
if (isNested())
{
ClassDeclaration *cd = isClassDeclaration();
//printf("AggregateDeclaration::fill() %s\n", toChars());
assert(sizeok == SIZEOKdone);
assert(elements);
- size_t nfields = fields.dim - isNested();
+ size_t nfields = fields.length - isNested();
bool errors = false;
- size_t dim = elements->dim;
+ size_t dim = elements->length;
elements->setDim(nfields);
for (size_t i = dim; i < nfields; i++)
(*elements)[i] = NULL;
}
}
- for (size_t i = 0; i < elements->dim; i++)
+ for (size_t i = 0; i < elements->length; i++)
{
Expression *e = (*elements)[i];
if (e && e->op == TOKerror)
}
};
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{
Dsymbol *sm = (*members)[i];
sm->apply(&SearchCtor::fp, NULL);
{
symtab = new DsymbolTable();
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{
Dsymbol *s = (*members)[i];
//printf("adding member '%s' to '%s'\n", s->toChars(), this->toChars());
/* Set scope so if there are forward references, we still might be able to
* resolve individual members like enums.
*/
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{
Dsymbol *s = (*members)[i];
//printf("struct: setScope %s %s\n", s->kind(), s->toChars());
s->setScope(sc2);
}
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{
Dsymbol *s = (*members)[i];
s->importAll(sc2);
}
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{
Dsymbol *s = (*members)[i];
s->semantic(sc2);
* needs to check existence of elaborate dtor in type of each fields.
* See the case in compilable/test14838.d
*/
- for (size_t i = 0; i < fields.dim; i++)
+ for (size_t i = 0; i < fields.length; i++)
{
VarDeclaration *v = fields[i];
Type *tb = v->type->baseElemOf();
//printf("StructDeclaration::finalizeSize() %s, sizeok = %d\n", toChars(), sizeok);
assert(sizeok != SIZEOKdone);
- //printf("+StructDeclaration::finalizeSize() %s, fields.dim = %d, sizeok = %d\n", toChars(), fields.dim, sizeok);
+ //printf("+StructDeclaration::finalizeSize() %s, fields.length = %d, sizeok = %d\n", toChars(), fields.length, sizeok);
fields.setDim(0); // workaround
// Set the offsets of the fields and determine the size of the struct
unsigned offset = 0;
bool isunion = isUnionDeclaration() != NULL;
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{
Dsymbol *s = (*members)[i];
s->setFieldOffset(this, &offset, isunion);
sizeok = SIZEOKdone;
- //printf("-StructDeclaration::finalizeSize() %s, fields.dim = %d, structsize = %d\n", toChars(), fields.dim, structsize);
+ //printf("-StructDeclaration::finalizeSize() %s, fields.length = %d, structsize = %d\n", toChars(), fields.length, structsize);
if (errors)
return;
// Determine if struct is all zeros or not
zeroInit = 1;
- for (size_t i = 0; i < fields.dim; i++)
+ for (size_t i = 0; i < fields.length; i++)
{
VarDeclaration *vd = fields[i];
if (vd->_init)
}
TypeTuple *tt = Target::toArgTypes(type);
- size_t dim = tt ? tt->arguments->dim : 0;
+ size_t dim = tt ? tt->arguments->length : 0;
if (dim >= 1)
{
assert(dim <= 2);
if (!elements)
return true;
- size_t nfields = fields.dim - isNested();
+ size_t nfields = fields.length - isNested();
size_t offset = 0;
- for (size_t i = 0; i < elements->dim; i++)
+ for (size_t i = 0; i < elements->length; i++)
{
Expression *e = (*elements)[i];
if (!e)
e = resolveProperties(sc, e);
if (i >= nfields)
{
- if (i == fields.dim - 1 && isNested() && e->op == TOKnull)
+ if (i == fields.length - 1 && isNested() && e->op == TOKnull)
{
// CTFE sometimes creates null as hidden pointer; we'll allow this.
continue;
ispod = ISPODno;
// Recursively check all fields are POD.
- for (size_t i = 0; i < fields.dim; i++)
+ for (size_t i = 0; i < fields.length; i++)
{
VarDeclaration *v = fields[i];
if (v->storage_class & STCref)
bool Dsymbol::oneMembers(Dsymbols *members, Dsymbol **ps, Identifier *ident)
{
- //printf("Dsymbol::oneMembers() %d\n", members ? members->dim : 0);
+ //printf("Dsymbol::oneMembers() %d\n", members ? members->length : 0);
Dsymbol *s = NULL;
if (members)
{
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{
Dsymbol *sx = (*members)[i];
bool x = sx->oneMember(ps, ident);
if (a)
{
b = a->copy();
- for (size_t i = 0; i < b->dim; i++)
+ for (size_t i = 0; i < b->length; i++)
{
(*b)[i] = (*b)[i]->syntaxCopy(NULL);
}
{
if (os)
{
- for (size_t i = 0; i < os->a.dim; i++)
+ for (size_t i = 0; i < os->a.length; i++)
{
a.push(os->a[i]);
}
OverloadSet *a = NULL;
// Look in imported modules
- for (size_t i = 0; i < importedScopes->dim; i++)
+ for (size_t i = 0; i < importedScopes->length; i++)
{
// If private import, don't search it
if ((flags & IgnorePrivateImports) && prots[i] == PROTprivate)
if (OverloadSet *os2 = s->isOverloadSet())
{
// Merge the cross-module overload set 'os2' into 'os'
- if (os->a.dim == 0)
+ if (os->a.length == 0)
{
- os->a.setDim(os2->a.dim);
- memcpy(os->a.tdata(), os2->a.tdata(), sizeof(os->a[0]) * os2->a.dim);
+ os->a.setDim(os2->a.length);
+ memcpy(os->a.tdata(), os2->a.tdata(), sizeof(os->a[0]) * os2->a.length);
}
else
{
- for (size_t i = 0; i < os2->a.dim; i++)
+ for (size_t i = 0; i < os2->a.length; i++)
{
os = mergeOverloadSet(ident, os, os2->a[i]);
}
/* Don't add to os[] if s is alias of previous sym
*/
- for (size_t j = 0; j < os->a.dim; j++)
+ for (size_t j = 0; j < os->a.length; j++)
{
Dsymbol *s2 = os->a[j];
if (s->toAlias() == s2->toAlias())
importedScopes = new Dsymbols();
else
{
- for (size_t i = 0; i < importedScopes->dim; i++)
+ for (size_t i = 0; i < importedScopes->length; i++)
{
Dsymbol *ss = (*importedScopes)[i];
if (ss == s) // if already imported
}
}
importedScopes->push(s);
- prots = (PROTKIND *)mem.xrealloc(prots, importedScopes->dim * sizeof(prots[0]));
- prots[importedScopes->dim - 1] = protection.kind;
+ prots = (PROTKIND *)mem.xrealloc(prots, importedScopes->length * sizeof(prots[0]));
+ prots[importedScopes->length - 1] = protection.kind;
}
}
return true;
if (importedScopes)
{
- for (size_t i = 0; i < importedScopes->dim; i++)
+ for (size_t i = 0; i < importedScopes->length; i++)
{
// only search visible scopes && imported modules should ignore private imports
Dsymbol *ss = (*importedScopes)[i];
{
if (members)
{
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{ Dsymbol *member = (*members)[i];
if (member->hasStaticCtorOrDtor())
size_t n = pn ? *pn : 0; // take over index
int result = 0;
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{ Dsymbol *s = (*members)[i];
if (AttribDeclaration *a = s->isAttribDeclaration())
/* $ gives the number of elements in the tuple
*/
VarDeclaration *v = new VarDeclaration(loc, Type::tsize_t, Id::dollar, NULL);
- Expression *e = new IntegerExp(Loc(), td->objects->dim, Type::tsize_t);
+ Expression *e = new IntegerExp(Loc(), td->objects->length, Type::tsize_t);
v->_init = new ExpInitializer(Loc(), e);
v->storage_class |= STCtemp | STCstatic | STCconst;
v->semantic(sc);
/* $ gives the number of type entries in the type tuple
*/
VarDeclaration *v = new VarDeclaration(loc, Type::tsize_t, Id::dollar, NULL);
- Expression *e = new IntegerExp(Loc(), type->arguments->dim, Type::tsize_t);
+ Expression *e = new IntegerExp(Loc(), type->arguments->length, Type::tsize_t);
v->_init = new ExpInitializer(Loc(), e);
v->storage_class |= STCtemp | STCstatic | STCconst;
v->semantic(sc);
/* It is for an expression tuple, so the
* length will be a const.
*/
- Expression *e = new IntegerExp(Loc(), ((TupleExp *)ce)->exps->dim, Type::tsize_t);
+ Expression *e = new IntegerExp(Loc(), ((TupleExp *)ce)->exps->length, Type::tsize_t);
v = new VarDeclaration(loc, Type::tsize_t, Id::dollar, new ExpInitializer(Loc(), e));
v->storage_class |= STCtemp | STCstatic | STCconst;
}
* Note that it's impossible to have both template & function opDollar,
* because both take no arguments.
*/
- if (exp->op == TOKarray && ((ArrayExp *)exp)->arguments->dim != 1)
+ if (exp->op == TOKarray && ((ArrayExp *)exp)->arguments->length != 1)
{
exp->error("%s only defines opDollar for one dimension", ad->toChars());
return NULL;
*/
bool arrayObjectIsError(Objects *args)
{
- for (size_t i = 0; i < args->dim; i++)
+ for (size_t i = 0; i < args->length; i++)
{
RootObject *o = (*args)[i];
if (isError(o))
{
if (oa1 == oa2)
return 1;
- if (oa1->dim != oa2->dim)
+ if (oa1->length != oa2->length)
return 0;
- for (size_t j = 0; j < oa1->dim; j++)
+ for (size_t j = 0; j < oa1->length; j++)
{
RootObject *o1 = (*oa1)[j];
RootObject *o2 = (*oa2)[j];
TupleExp *te = (TupleExp *)e;
size_t hash = 0;
hash += te->e0 ? expressionHash(te->e0) : 0;
- for (size_t i = 0; i < te->exps->dim; i++)
+ for (size_t i = 0; i < te->exps->length; i++)
{
Expression *elem = (*te->exps)[i];
hash = mixHash(hash, expressionHash(elem));
{
ArrayLiteralExp *ae = (ArrayLiteralExp *)e;
size_t hash = 0;
- for (size_t i = 0; i < ae->elements->dim; i++)
+ for (size_t i = 0; i < ae->elements->length; i++)
hash = mixHash(hash, expressionHash(ae->getElement(i)));
return hash;
}
{
AssocArrayLiteralExp *ae = (AssocArrayLiteralExp *)e;
size_t hash = 0;
- for (size_t i = 0; i < ae->keys->dim; i++)
+ for (size_t i = 0; i < ae->keys->length; i++)
// reduction needs associative op as keys are unsorted (use XOR)
hash ^= mixHash(expressionHash((*ae->keys)[i]), expressionHash((*ae->values)[i]));
return hash;
{
StructLiteralExp *se = (StructLiteralExp *)e;
size_t hash = 0;
- for (size_t i = 0; i < se->elements->dim; i++)
+ for (size_t i = 0; i < se->elements->length; i++)
{
Expression *elem = (*se->elements)[i];
hash = mixHash(hash, elem ? expressionHash(elem) : 0);
static hash_t arrayObjectHash(Objects *oa1)
{
hash_t hash = 0;
- for (size_t j = 0; j < oa1->dim; j++)
+ for (size_t j = 0; j < oa1->length; j++)
{
/* Must follow the logic of match()
*/
if (parameters)
{
p = new TemplateParameters();
- p->setDim(parameters->dim);
- for (size_t i = 0; i < p->dim; i++)
+ p->setDim(parameters->length);
+ for (size_t i = 0; i < p->length; i++)
(*p)[i] = (*parameters)[i]->syntaxCopy();
}
return new TemplateDeclaration(loc, ident, p,
if (global.params.doDocComments)
{
origParameters = new TemplateParameters();
- origParameters->setDim(parameters->dim);
- for (size_t i = 0; i < parameters->dim; i++)
+ origParameters->setDim(parameters->length);
+ for (size_t i = 0; i < parameters->length; i++)
{
TemplateParameter *tp = (*parameters)[i];
(*origParameters)[i] = tp->syntaxCopy();
}
}
- for (size_t i = 0; i < parameters->dim; i++)
+ for (size_t i = 0; i < parameters->length; i++)
{
TemplateParameter *tp = (*parameters)[i];
{
errors = true;
}
- if (i + 1 != parameters->dim && tp->isTemplateTupleParameter())
+ if (i + 1 != parameters->length && tp->isTemplateTupleParameter())
{
error("template tuple parameter must be last one");
errors = true;
*/
TemplateParameters tparams;
tparams.setDim(1);
- for (size_t i = 0; i < parameters->dim; i++)
+ for (size_t i = 0; i < parameters->length; i++)
{
TemplateParameter *tp = (*parameters)[i];
tparams[0] = tp;
- for (size_t j = 0; j < parameters->dim; j++)
+ for (size_t j = 0; j < parameters->length; j++)
{
// Skip cases like: X(T : T)
if (i == j)
if (fvarargs == 2 && i + 1 == nfparams)
fparam->storageClass |= STCvariadic;
}
- for (size_t i = 0; i < fparameters->dim; i++)
+ for (size_t i = 0; i < fparameters->length; i++)
{
Parameter *fparam = (*fparameters)[i];
if (!fparam->ident)
Objects *dedtypes, Expressions *fargs, int flag)
{
MATCH m;
- size_t dedtypes_dim = dedtypes->dim;
+ size_t dedtypes_dim = dedtypes->length;
dedtypes->zero();
if (errors)
return MATCHnomatch;
- size_t parameters_dim = parameters->dim;
+ size_t parameters_dim = parameters->length;
int variadic = isVariadic() != NULL;
// If more arguments than parameters, no match
- if (ti->tiargs->dim > parameters_dim && !variadic)
+ if (ti->tiargs->length > parameters_dim && !variadic)
{
return MATCHnomatch;
}
assert(dedtypes_dim == parameters_dim);
- assert(dedtypes_dim >= ti->tiargs->dim || variadic);
+ assert(dedtypes_dim >= ti->tiargs->length || variadic);
assert(_scope);
{
if (!(*dedtypes)[i])
{
- assert(i < ti->tiargs->dim);
+ assert(i < ti->tiargs->length);
(*dedtypes)[i] = (Type *)(*ti->tiargs)[i];
}
}
fd->inferRetType = true;
// Shouldn't run semantic on default arguments and return type.
- for (size_t i = 0; i < tf->parameters->dim; i++)
+ for (size_t i = 0; i < tf->parameters->length; i++)
(*tf->parameters)[i]->defaultArg = NULL;
tf->next = NULL;
// Set type arguments to dummy template instance to be types
// generated from the parameters to this template declaration
ti.tiargs = new Objects();
- ti.tiargs->reserve(parameters->dim);
- for (size_t i = 0; i < parameters->dim; i++)
+ ti.tiargs->reserve(parameters->length);
+ for (size_t i = 0; i < parameters->length; i++)
{
TemplateParameter *tp = (*parameters)[i];
if (tp->dependent)
// Temporary Array to hold deduced types
Objects dedtypes;
- dedtypes.setDim(td2->parameters->dim);
+ dedtypes.setDim(td2->parameters->length);
// Attempt a type deduction
MATCH m = td2->matchWithInstance(sc, &ti, &dedtypes, fargs, 1);
MATCH matchAll(Type *tt)
{
MATCH match = MATCHexact;
- for (size_t j = 0; j < argexps.dim; j++)
+ for (size_t j = 0; j < argexps.length; j++)
{
Expression *e = argexps[j];
assert(e);
assert(_scope);
- dedargs->setDim(parameters->dim);
+ dedargs->setDim(parameters->length);
dedargs->zero();
- dedtypes->setDim(parameters->dim);
+ dedtypes->setDim(parameters->length);
dedtypes->zero();
if (errors || fd->errors)
if (tiargs)
{
// Set initial template arguments
- ntargs = tiargs->dim;
- size_t n = parameters->dim;
+ ntargs = tiargs->length;
+ size_t n = parameters->length;
if (tp)
n--;
if (ntargs > n)
* now form the tuple argument.
*/
Tuple *t = new Tuple();
- assert(parameters->dim);
- (*dedargs)[parameters->dim - 1] = t;
+ assert(parameters->length);
+ (*dedargs)[parameters->length - 1] = t;
t->objects.setDim(ntargs - n);
- for (size_t i = 0; i < t->objects.dim; i++)
+ for (size_t i = 0; i < t->objects.length; i++)
{
t->objects[i] = (*tiargs)[n + i];
}
for (size_t i = 0; i < n; i++)
{
- assert(i < parameters->dim);
+ assert(i < parameters->length);
Declaration *sparam = NULL;
MATCH m = (*parameters)[i]->matchArg(instLoc, paramscope, dedargs, i, parameters, dedtypes, &sparam);
//printf("\tdeduceType m = %d\n", m);
if (!paramscope->insert(sparam))
goto Lnomatch;
}
- if (n < parameters->dim && !declaredTuple)
+ if (n < parameters->length && !declaredTuple)
{
inferStart = n;
}
else
- inferStart = parameters->dim;
+ inferStart = parameters->length;
//printf("tiargs matchTiargs = %d\n", matchTiargs);
}
fparameters = fd->getParameters(&fvarargs);
nfparams = Parameter::dim(fparameters); // number of function parameters
- nfargs = fargs ? fargs->dim : 0; // number of function arguments
+ nfargs = fargs ? fargs->length : 0; // number of function arguments
/* Check for match of function arguments with variadic template
* parameter, such as:
{
Tuple *t = new Tuple();
//printf("t = %p\n", t);
- (*dedargs)[parameters->dim - 1] = t;
+ (*dedargs)[parameters->length - 1] = t;
declareParameter(paramscope, tp, t);
declaredTuple = t;
}
if (fparam->type->ty != Tident)
continue;
TypeIdentifier *tid = (TypeIdentifier *)fparam->type;
- if (!tp->ident->equals(tid->ident) || tid->idents.dim)
+ if (!tp->ident->equals(tid->ident) || tid->idents.length)
continue;
if (fvarargs) // variadic function doesn't
bool hasttp = false;
// Match 'tthis' to any TemplateThisParameter's
- for (size_t i = 0; i < parameters->dim; i++)
+ for (size_t i = 0; i < parameters->length; i++)
{
TemplateThisParameter *ttp = (*parameters)[i]->isTemplateThisParameter();
if (ttp)
// Loop through the function parameters
{
- //printf("%s\n\tnfargs = %d, nfparams = %d, tuple_dim = %d\n", toChars(), nfargs, nfparams, declaredTuple ? declaredTuple->objects.dim : 0);
+ //printf("%s\n\tnfargs = %d, nfparams = %d, tuple_dim = %d\n", toChars(), nfargs, nfparams, declaredTuple ? declaredTuple->objects.length : 0);
//printf("\ttp = %p, fptupindex = %d, found = %d, declaredTuple = %s\n", tp, fptupindex, fptupindex != IDX_NOTFOUND, declaredTuple ? declaredTuple->toChars() : NULL);
size_t argi = 0;
size_t nfargs2 = nfargs; // nfargs + supplied defaultArgs
* now form the tuple argument.
*/
declaredTuple = new Tuple();
- (*dedargs)[parameters->dim - 1] = declaredTuple;
+ (*dedargs)[parameters->length - 1] = declaredTuple;
/* Count function parameters following a tuple parameter.
* void foo(U, T...)(int y, T, U, int) {} // rem == 2 (U, int)
if (!reliesOnTident(p->type, parameters, inferStart))
{
Type *pt = p->type->syntaxCopy()->semantic(fd->loc, paramscope);
- rem += pt->ty == Ttuple ? ((TypeTuple *)pt)->arguments->dim : 1;
+ rem += pt->ty == Ttuple ? ((TypeTuple *)pt)->arguments->length : 1;
}
else
{
if (nfargs2 - argi < rem)
goto Lnomatch;
declaredTuple->objects.setDim(nfargs2 - argi - rem);
- for (size_t i = 0; i < declaredTuple->objects.dim; i++)
+ for (size_t i = 0; i < declaredTuple->objects.length; i++)
{
farg = (*fargs)[argi + i];
{
// Bugzilla 6810: If declared tuple is not a type tuple,
// it cannot be function parameter types.
- for (size_t i = 0; i < declaredTuple->objects.dim; i++)
+ for (size_t i = 0; i < declaredTuple->objects.length; i++)
{
if (!isType(declaredTuple->objects[i]))
goto Lnomatch;
}
}
assert(declaredTuple);
- argi += declaredTuple->objects.dim;
+ argi += declaredTuple->objects.length;
continue;
}
if (prmtype->ty == Ttuple)
{
TypeTuple *tt = (TypeTuple *)prmtype;
- size_t tt_dim = tt->arguments->dim;
+ size_t tt_dim = tt->arguments->length;
for (size_t j = 0; j < tt_dim; j++, ++argi)
{
Parameter *p = (*tt->arguments)[j];
*/
if (argi == nfargs)
{
- for (size_t i = 0; i < dedtypes->dim; i++)
+ for (size_t i = 0; i < dedtypes->length; i++)
{
Type *at = isType((*dedtypes)[i]);
if (at && at->ty == Tnone)
delete xt;
}
}
- for (size_t i = ntargs; i < dedargs->dim; i++)
+ for (size_t i = ntargs; i < dedargs->length; i++)
{
TemplateParameter *tparam = (*parameters)[i];
if (argtype->ty == Tarray &&
(prmtype->ty == Tsarray ||
(prmtype->ty == Taarray && (taai = ((TypeAArray *)prmtype)->index)->ty == Tident &&
- ((TypeIdentifier *)taai)->idents.dim == 0)))
+ ((TypeIdentifier *)taai)->idents.length == 0)))
{
if (farg->op == TOKstring)
{
else if (farg->op == TOKarrayliteral)
{
ArrayLiteralExp *ae = (ArrayLiteralExp *)farg;
- argtype = ae->type->nextOf()->sarrayOf(ae->elements->dim);
+ argtype = ae->type->nextOf()->sarrayOf(ae->elements->length);
}
else if (farg->op == TOKslice)
{
else if ((fparam->storageClass & STCout) == 0 &&
(argtype->ty == Tarray || argtype->ty == Tpointer) &&
templateParameterLookup(prmtype, parameters) != IDX_NOTFOUND &&
- ((TypeIdentifier *)prmtype)->idents.dim == 0)
+ ((TypeIdentifier *)prmtype)->idents.length == 0)
{
/* The farg passing to the prmtype always make a copy. Therefore,
* we can shrink the set of the deduced type arguments for prmtype
Lmatch:
- for (size_t i = 0; i < dedtypes->dim; i++)
+ for (size_t i = 0; i < dedtypes->length; i++)
{
Type *at = isType((*dedtypes)[i]);
if (at)
(*dedtypes)[i] = at->merge2();
}
}
- for (size_t i = ntargs; i < dedargs->dim; i++)
+ for (size_t i = ntargs; i < dedargs->length; i++)
{
TemplateParameter *tparam = (*parameters)[i];
//printf("tparam[%d] = %s\n", i, tparam->ident->toChars());
// we're one or more arguments short (i.e. no tuple argument)
if (tparam == tp &&
fptupindex == IDX_NOTFOUND &&
- ntargs <= dedargs->dim - 1)
+ ntargs <= dedargs->length - 1)
{
// make tuple argument an empty tuple
oded = (RootObject *)new Tuple();
/* Bugzilla 7469: As same as the code for 7469 in findBestMatch,
* expand a Tuple in dedargs to normalize template arguments.
*/
- if (size_t d = dedargs->dim)
+ if (size_t d = dedargs->length)
{
if (Tuple *va = isTuple((*dedargs)[d - 1]))
{
- if (va->objects.dim)
+ if (va->objects.length)
{
dedargs->setDim(d - 1);
dedargs->insert(d - 1, &va->objects);
TemplateTupleParameter *isVariadic(TemplateParameters *parameters)
{
- size_t dim = parameters->dim;
+ size_t dim = parameters->length;
TemplateTupleParameter *tp = NULL;
if (dim)
if (fd == m->lastf)
return 0;
// explicitly specified tiargs never match to non template function
- if (tiargs && tiargs->dim > 0)
+ if (tiargs && tiargs->length > 0)
return 0;
// constructors need a valid scope in order to detect semantic errors
tiargs = new Objects();
TemplateInstance *ti = new TemplateInstance(loc, td, tiargs);
Objects dedtypes;
- dedtypes.setDim(td->parameters->dim);
+ dedtypes.setDim(td->parameters->length);
assert(td->semanticRun != PASSinit);
MATCH mta = td->matchWithInstance(sc, ti, &dedtypes, fargs, 0);
//printf("matchWithInstance = %d\n", mta);
{
// Match 'tthis' to any TemplateThisParameter's
bool hasttp = false;
- for (size_t i = 0; i < parameters->dim; i++)
+ for (size_t i = 0; i < parameters->length; i++)
{
TemplateParameter *tp = (*parameters)[i];
TemplateThisParameter *ttp = tp->isTemplateThisParameter();
Scope *scx = sc2->push();
// Shouldn't run semantic on default arguments and return type.
- for (size_t i = 0; i < tf->parameters->dim; i++)
+ for (size_t i = 0; i < tf->parameters->length; i++)
(*tf->parameters)[i]->defaultArg = NULL;
if (fd->isCtorDeclaration())
{
buf.writestring(ident->toChars());
buf.writeByte('(');
- for (size_t i = 0; i < parameters->dim; i++)
+ for (size_t i = 0; i < parameters->length; i++)
{
TemplateParameter *tp = (*parameters)[i];
if (i)
TemplateInstances *tinstances = (TemplateInstances *)dmd_aaGetRvalue((AA *)instances, (void *)tithis->toHash());
if (tinstances)
{
- for (size_t i = 0; i < tinstances->dim; i++)
+ for (size_t i = 0; i < tinstances->length; i++)
{
TemplateInstance *ti = (*tinstances)[i];
if (tithis->compare(ti) == 0)
TemplateInstances *tinstances = (TemplateInstances *)dmd_aaGetRvalue((AA *)instances, (void *)handle->toHash());
if (tinstances)
{
- for (size_t i = 0; i < tinstances->dim; i++)
+ for (size_t i = 0; i < tinstances->length; i++)
{
TemplateInstance *ti = (*tinstances)[i];
if (handle == ti)
static size_t templateIdentifierLookup(Identifier *id, TemplateParameters *parameters)
{
- for (size_t i = 0; i < parameters->dim; i++)
+ for (size_t i = 0; i < parameters->length; i++)
{
TemplateParameter *tp = (*parameters)[i];
if (tp->ident->equals(id))
/* Need a loc to go with the semantic routine.
*/
Loc loc;
- if (parameters->dim)
+ if (parameters->length)
{
TemplateParameter *tp = (*parameters)[0];
loc = tp->loc;
TemplateParameter *tp = (*parameters)[i];
TypeIdentifier *tident = (TypeIdentifier *)tparam;
- if (tident->idents.dim > 0)
+ if (tident->idents.length > 0)
{
//printf("matching %s to %s\n", tparam->toChars(), t->toChars());
Dsymbol *s = t->toDsymbol(sc);
- for (size_t j = tident->idents.dim; j-- > 0; )
+ for (size_t j = tident->idents.length; j-- > 0; )
{
RootObject *id = tident->idents[j];
if (id->dyncast() == DYNCAST_IDENTIFIER)
/* Need a loc to go with the semantic routine.
*/
Loc loc;
- if (parameters->dim)
+ if (parameters->length)
{
TemplateParameter *tp = (*parameters)[0];
loc = tp->loc;
if (fparam->type->ty != Tident)
goto L1;
TypeIdentifier *tid = (TypeIdentifier *)fparam->type;
- if (tid->idents.dim)
+ if (tid->idents.length)
goto L1;
/* Look through parameters to find tuple matching tid->ident
size_t tupi = 0;
for (; 1; tupi++)
{
- if (tupi == parameters->dim)
+ if (tupi == parameters->length)
goto L1;
TemplateParameter *tx = (*parameters)[tupi];
TemplateTupleParameter *tup = tx->isTemplateTupleParameter();
{
// Existing deduced argument must be a tuple, and must match
Tuple *tup = isTuple(o);
- if (!tup || tup->objects.dim != tuple_dim)
+ if (!tup || tup->objects.length != tuple_dim)
{
result = MATCHnomatch;
return;
{
TypeIdentifier *tp = (TypeIdentifier *)tparam;
- for (size_t i = 0; i < t->idents.dim; i++)
+ for (size_t i = 0; i < t->idents.length; i++)
{
RootObject *id1 = t->idents[i];
RootObject *id2 = tp->idents[i];
{
//printf("\ttest: tempinst->tiargs[%d]\n", i);
RootObject *o1 = NULL;
- if (i < t->tempinst->tiargs->dim)
+ if (i < t->tempinst->tiargs->length)
o1 = (*t->tempinst->tiargs)[i];
- else if (i < t->tempinst->tdtypes.dim && i < tp->tempinst->tiargs->dim)
+ else if (i < t->tempinst->tdtypes.length && i < tp->tempinst->tiargs->length)
{
// Pick up default arg
o1 = t->tempinst->tdtypes[i];
}
- else if (i >= tp->tempinst->tiargs->dim)
+ else if (i >= tp->tempinst->tiargs->length)
break;
- if (i >= tp->tempinst->tiargs->dim)
+ if (i >= tp->tempinst->tiargs->length)
{
- size_t dim = tempdecl->parameters->dim - (tempdecl->isVariadic() ? 1 : 0);
+ size_t dim = tempdecl->parameters->length - (tempdecl->isVariadic() ? 1 : 0);
while (i < dim && ((*tempdecl->parameters)[i]->dependent ||
(*tempdecl->parameters)[i]->hasDefaultArg()))
{
RootObject *o2 = (*tp->tempinst->tiargs)[i];
Type *t2 = isType(o2);
- size_t j = (t2 && t2->ty == Tident && i == tp->tempinst->tiargs->dim - 1)
+ size_t j = (t2 && t2->ty == Tident && i == tp->tempinst->tiargs->length - 1)
? templateParameterLookup(t2, parameters) : IDX_NOTFOUND;
- if (j != IDX_NOTFOUND && j == parameters->dim - 1 &&
+ if (j != IDX_NOTFOUND && j == parameters->length - 1 &&
(*parameters)[j]->isTemplateTupleParameter())
{
/* Given:
*/
Tuple *vt = new Tuple();
size_t vtdim = (tempdecl->isVariadic()
- ? t->tempinst->tiargs->dim : t->tempinst->tdtypes.dim) - i;
+ ? t->tempinst->tiargs->length : t->tempinst->tdtypes.length) - i;
vt->objects.setDim(vtdim);
for (size_t k = 0; k < vtdim; k++)
{
RootObject *o;
- if (k < t->tempinst->tiargs->dim)
+ if (k < t->tempinst->tiargs->length)
o = (*t->tempinst->tiargs)[i + k];
else // Pick up default arg
o = t->tempinst->tdtypes[i + k];
* S!(T).foo
*/
TypeInstance *tpi = (TypeInstance *)tparam;
- if (tpi->idents.dim)
+ if (tpi->idents.length)
{
- RootObject *id = tpi->idents[tpi->idents.dim - 1];
+ RootObject *id = tpi->idents[tpi->idents.length - 1];
if (id->dyncast() == DYNCAST_IDENTIFIER && t->sym->ident->equals((Identifier *)id))
{
Type *tparent = t->sym->parent->getType();
{
/* Slice off the .foo in S!(T).foo
*/
- tpi->idents.dim--;
+ tpi->idents.length--;
result = deduceType(tparent, sc, tpi, parameters, dedtypes, wm);
- tpi->idents.dim++;
+ tpi->idents.length++;
return;
}
}
{
// Make a temporary copy of dedtypes so we don't destroy it
Objects *tmpdedtypes = new Objects();
- tmpdedtypes->setDim(dedtypes->dim);
- memcpy(tmpdedtypes->tdata(), dedtypes->tdata(), dedtypes->dim * sizeof(void *));
+ tmpdedtypes->setDim(dedtypes->length);
+ memcpy(tmpdedtypes->tdata(), dedtypes->tdata(), dedtypes->length * sizeof(void *));
TypeInstance *t = new TypeInstance(Loc(), parti);
MATCH m = deduceType(t, sc, tparam, parameters, tmpdedtypes);
{
// If this is the first ever match, it becomes our best estimate
if (numBaseClassMatches==0)
- memcpy(best->tdata(), tmpdedtypes->tdata(), tmpdedtypes->dim * sizeof(void *));
- else for (size_t k = 0; k < tmpdedtypes->dim; ++k)
+ memcpy(best->tdata(), tmpdedtypes->tdata(), tmpdedtypes->length * sizeof(void *));
+ else for (size_t k = 0; k < tmpdedtypes->length; ++k)
{
// If we've found more than one possible type for a parameter,
// mark it as unknown.
* S!(T).foo
*/
TypeInstance *tpi = (TypeInstance *)tparam;
- if (tpi->idents.dim)
+ if (tpi->idents.length)
{
- RootObject *id = tpi->idents[tpi->idents.dim - 1];
+ RootObject *id = tpi->idents[tpi->idents.length - 1];
if (id->dyncast() == DYNCAST_IDENTIFIER && t->sym->ident->equals((Identifier *)id))
{
Type *tparent = t->sym->parent->getType();
{
/* Slice off the .foo in S!(T).foo
*/
- tpi->idents.dim--;
+ tpi->idents.length--;
result = deduceType(tparent, sc, tpi, parameters, dedtypes, wm);
- tpi->idents.dim++;
+ tpi->idents.length++;
return;
}
}
// Our best guess at dedtypes
Objects *best = new Objects();
- best->setDim(dedtypes->dim);
+ best->setDim(dedtypes->length);
ClassDeclaration *s = t->sym;
- while (s && s->baseclasses->dim > 0)
+ while (s && s->baseclasses->length > 0)
{
// Test the base class
deduceBaseClassParameters((*s->baseclasses)[0],
}
// If we got at least one match, copy the known types into dedtypes
- memcpy(dedtypes->tdata(), best->tdata(), best->dim * sizeof(void *));
+ memcpy(dedtypes->tdata(), best->tdata(), best->length * sizeof(void *));
result = MATCHconvert;
return;
}
{
//printf("Expression::deduceType(e = %s)\n", e->toChars());
size_t i = templateParameterLookup(tparam, parameters);
- if (i == IDX_NOTFOUND || ((TypeIdentifier *)tparam)->idents.dim > 0)
+ if (i == IDX_NOTFOUND || ((TypeIdentifier *)tparam)->idents.length > 0)
{
if (e == emptyArrayElement && tparam->ty == Tarray)
{
if (e->type->ty == Tarray &&
(tparam->ty == Tsarray ||
(tparam->ty == Taarray && (taai = ((TypeAArray *)tparam)->index)->ty == Tident &&
- ((TypeIdentifier *)taai)->idents.dim == 0)))
+ ((TypeIdentifier *)taai)->idents.length == 0)))
{
// Consider compile-time known boundaries
e->type->nextOf()->sarrayOf(e->len)->accept(this);
void visit(ArrayLiteralExp *e)
{
- if ((!e->elements || !e->elements->dim) &&
+ if ((!e->elements || !e->elements->length) &&
e->type->toBasetype()->nextOf()->ty == Tvoid &&
tparam->ty == Tarray)
{
return;
}
- if (tparam->ty == Tarray && e->elements && e->elements->dim)
+ if (tparam->ty == Tarray && e->elements && e->elements->length)
{
Type *tn = ((TypeDArray *)tparam)->next;
result = MATCHexact;
if (m < result)
result = m;
}
- for (size_t i = 0; i < e->elements->dim; i++)
+ for (size_t i = 0; i < e->elements->length; i++)
{
if (result <= MATCHnomatch)
break;
if (e->type->ty == Tarray &&
(tparam->ty == Tsarray ||
(tparam->ty == Taarray && (taai = ((TypeAArray *)tparam)->index)->ty == Tident &&
- ((TypeIdentifier *)taai)->idents.dim == 0)))
+ ((TypeIdentifier *)taai)->idents.length == 0)))
{
// Consider compile-time known boundaries
- e->type->nextOf()->sarrayOf(e->elements->dim)->accept(this);
+ e->type->nextOf()->sarrayOf(e->elements->length)->accept(this);
return;
}
visit((Expression *)e);
void visit(AssocArrayLiteralExp *e)
{
- if (tparam->ty == Taarray && e->keys && e->keys->dim)
+ if (tparam->ty == Taarray && e->keys && e->keys->length)
{
TypeAArray *taa = (TypeAArray *)tparam;
result = MATCHexact;
- for (size_t i = 0; i < e->keys->dim; i++)
+ for (size_t i = 0; i < e->keys->length; i++)
{
MATCH m1 = deduceType((*e->keys)[i], sc, taa->index, parameters, dedtypes, wm);
if (m1 < result)
return;
Objects *tiargs = new Objects();
- tiargs->reserve(e->td->parameters->dim);
+ tiargs->reserve(e->td->parameters->length);
- for (size_t i = 0; i < e->td->parameters->dim; i++)
+ for (size_t i = 0; i < e->td->parameters->length; i++)
{
TemplateParameter *tp = (*e->td->parameters)[i];
size_t u = 0;
if (e->type->ty == Tarray &&
(tparam->ty == Tsarray ||
(tparam->ty == Taarray && (taai = ((TypeAArray *)tparam)->index)->ty == Tident &&
- ((TypeIdentifier *)taai)->idents.dim == 0)))
+ ((TypeIdentifier *)taai)->idents.length == 0)))
{
// Consider compile-time known boundaries
if (Type *tsa = toStaticArrayType(e))
return;
}
- for (size_t i = iStart; i < tparams->dim; i++)
+ for (size_t i = iStart; i < tparams->length; i++)
{
TemplateParameter *tp = (*tparams)[i];
if (tp->ident->equals(t->ident))
if (!tparams)
return;
- for (size_t i = iStart; i < tparams->dim; i++)
+ for (size_t i = iStart; i < tparams->length; i++)
{
TemplateParameter *tp = (*tparams)[i];
if (t->tempinst->name == tp->ident)
}
if (!t->tempinst->tiargs)
return;
- for (size_t i = 0; i < t->tempinst->tiargs->dim; i++)
+ for (size_t i = 0; i < t->tempinst->tiargs->length; i++)
{
Type *ta = isType((*t->tempinst->tiargs)[i]);
if (ta)
{
if (t->arguments)
{
- for (size_t i = 0; i < t->arguments->dim; i++)
+ for (size_t i = 0; i < t->arguments->length; i++)
{
Parameter *arg = (*t->arguments)[i];
arg->type->accept(this);
void visit(IdentifierExp *e)
{
//printf("IdentifierExp::reliesOnTident('%s')\n", e->toChars());
- for (size_t i = iStart; i < tparams->dim; i++)
+ for (size_t i = iStart; i < tparams->length; i++)
{
TemplateParameter *tp = (*tparams)[i];
if (e->ident == tp->ident)
//printf("TupleExp::reliesOnTident('%s')\n", e->toChars());
if (e->exps)
{
- for (size_t i = 0; i < e->exps->dim; i++)
+ for (size_t i = 0; i < e->exps->length; i++)
{
Expression *ea = (*e->exps)[i];
ea->accept(this);
//printf("ArrayLiteralExp::reliesOnTident('%s')\n", e->toChars());
if (e->elements)
{
- for (size_t i = 0; i < e->elements->dim; i++)
+ for (size_t i = 0; i < e->elements->length; i++)
{
Expression *el = (*e->elements)[i];
el->accept(this);
void visit(AssocArrayLiteralExp *e)
{
//printf("AssocArrayLiteralExp::reliesOnTident('%s')\n", e->toChars());
- for (size_t i = 0; i < e->keys->dim; i++)
+ for (size_t i = 0; i < e->keys->length; i++)
{
Expression *ek = (*e->keys)[i];
ek->accept(this);
if (result)
return;
}
- for (size_t i = 0; i < e->values->dim; i++)
+ for (size_t i = 0; i < e->values->length; i++)
{
Expression *ev = (*e->values)[i];
ev->accept(this);
//printf("StructLiteralExp::reliesOnTident('%s')\n", e->toChars());
if (e->elements)
{
- for (size_t i = 0; i < e->elements->dim; i++)
+ for (size_t i = 0; i < e->elements->length; i++)
{
Expression *ea = (*e->elements)[i];
ea->accept(this);
e->thisexp->accept(this);
if (!result && e->newargs)
{
- for (size_t i = 0; i < e->newargs->dim; i++)
+ for (size_t i = 0; i < e->newargs->length; i++)
{
Expression *ea = (*e->newargs)[i];
ea->accept(this);
e->newtype->accept(this);
if (!result && e->arguments)
{
- for (size_t i = 0; i < e->arguments->dim; i++)
+ for (size_t i = 0; i < e->arguments->length; i++)
{
Expression *ea = (*e->arguments)[i];
ea->accept(this);
//printf("TraitsExp::reliesOnTident('%s')\n", e->toChars());
if (e->args)
{
- for (size_t i = 0; i < e->args->dim; i++)
+ for (size_t i = 0; i < e->args->length; i++)
{
RootObject *oa = (*e->args)[i];
if (Expression *ea = isExpression(oa))
visit((UnaExp *)e);
if (!result && e->ti->tiargs)
{
- for (size_t i = 0; i < e->ti->tiargs->dim; i++)
+ for (size_t i = 0; i < e->ti->tiargs->length; i++)
{
RootObject *oa = (*e->ti->tiargs)[i];
if (Expression *ea = isExpression(oa))
visit((UnaExp *)e);
if (!result && e->arguments)
{
- for (size_t i = 0; i < e->arguments->dim; i++)
+ for (size_t i = 0; i < e->arguments->length; i++)
{
Expression *ea = (*e->arguments)[i];
ea->accept(this);
visit((UnaExp *)e);
if (!result && e->arguments)
{
- for (size_t i = 0; i < e->arguments->dim; i++)
+ for (size_t i = 0; i < e->arguments->length; i++)
{
Expression *ea = (*e->arguments)[i];
ea->accept(this);
{
RootObject *oarg;
- if (i < tiargs->dim)
+ if (i < tiargs->length)
oarg = (*tiargs)[i];
else
{
oarg = defaultArg(instLoc, sc);
if (!oarg)
{
- assert(i < dedtypes->dim);
+ assert(i < dedtypes->length);
// It might have already been deduced
oarg = (*dedtypes)[i];
if (!oarg)
/* The rest of the actual arguments (tiargs[]) form the match
* for the variadic parameter.
*/
- assert(i + 1 == dedtypes->dim); // must be the last one
+ assert(i + 1 == dedtypes->length); // must be the last one
Tuple *ovar;
if (Tuple *u = isTuple((*dedtypes)[i]))
// It has already been deduced
ovar = u;
}
- else if (i + 1 == tiargs->dim && isTuple((*tiargs)[i]))
+ else if (i + 1 == tiargs->length && isTuple((*tiargs)[i]))
ovar = isTuple((*tiargs)[i]);
else
{
ovar = new Tuple();
//printf("ovar = %p\n", ovar);
- if (i < tiargs->dim)
+ if (i < tiargs->length)
{
- //printf("i = %d, tiargs->dim = %d\n", i, tiargs->dim);
- ovar->objects.setDim(tiargs->dim - i);
- for (size_t j = 0; j < ovar->objects.dim; j++)
+ //printf("i = %d, tiargs->length = %d\n", i, tiargs->length);
+ ovar->objects.setDim(tiargs->length - i);
+ for (size_t j = 0; j < ovar->objects.length; j++)
ovar->objects[j] = (*tiargs)[i + j];
}
}
Tuple *v = isTuple(oded);
assert(v);
- //printf("|%d| ", v->objects.dim);
- for (size_t i = 0; i < v->objects.dim; i++)
+ //printf("|%d| ", v->objects.length);
+ for (size_t i = 0; i < v->objects.length; i++)
{
if (i)
printf(", ");
if (objs)
{
a = new Objects();
- a->setDim(objs->dim);
- for (size_t i = 0; i < objs->dim; i++)
+ a->setDim(objs->length);
+ for (size_t i = 0; i < objs->length; i++)
(*a)[i] = objectSyntaxCopy((*objs)[i]);
}
return a;
void TemplateInstance::expandMembers(Scope *sc2)
{
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{
Dsymbol *s = (*members)[i];
s->setScope(sc2);
}
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{
Dsymbol *s = (*members)[i];
s->importAll(sc2);
}
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{
Dsymbol *s = (*members)[i];
//printf("\t[%d] semantic on '%s' %p kind %s in '%s'\n", i, s->toChars(), s, s->kind(), this->toChars());
// Store the place we added it to in target_symbol_list(_idx) so we can
// remove it later if we encounter an error.
Dsymbols *target_symbol_list = appendToModuleMember();
- size_t target_symbol_list_idx = target_symbol_list ? target_symbol_list->dim - 1 : 0;
+ size_t target_symbol_list_idx = target_symbol_list ? target_symbol_list->length - 1 : 0;
// Copy the syntax trees from the TemplateDeclaration
members = Dsymbol::arraySyntaxCopy(tempdecl->members);
// resolve TemplateThisParameter
- for (size_t i = 0; i < tempdecl->parameters->dim; i++)
+ for (size_t i = 0; i < tempdecl->parameters->length; i++)
{
if ((*tempdecl->parameters)[i]->isTemplateThisParameter() == NULL)
continue;
// Add members of template instance to template instance symbol table
// parent = scope->scopesym;
symtab = new DsymbolTable();
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{
Dsymbol *s = (*members)[i];
s->addMember(scope, this);
* member has the same name as the template instance.
* If so, this template instance becomes an alias for that member.
*/
- //printf("members->dim = %d\n", members->dim);
- if (members->dim)
+ //printf("members->length = %d\n", members->length);
+ if (members->length)
{
Dsymbol *s;
if (Dsymbol::oneMembers(members, &s, tempdecl->ident) && s)
/* ConditionalDeclaration may introduce eponymous declaration,
* so we should find it once again after semantic.
*/
- if (members->dim)
+ if (members->length)
{
Dsymbol *s;
if (Dsymbol::oneMembers(members, &s, tempdecl->ident) && s)
*/
{
bool found_deferred_ad = false;
- for (size_t i = 0; i < Module::deferred.dim; i++)
+ for (size_t i = 0; i < Module::deferred.length; i++)
{
Dsymbol *sd = Module::deferred[i];
AggregateDeclaration *ad = sd->isAggregateDeclaration();
}
}
}
- if (found_deferred_ad || Module::deferred.dim)
+ if (found_deferred_ad || Module::deferred.length)
goto Laftersemantic;
}
//printf("Run semantic3 on %s\n", toChars());
trySemantic3(sc2);
- for (size_t i = 0; i < deferred.dim; i++)
+ for (size_t i = 0; i < deferred.length; i++)
{
//printf("+ run deferred semantic3 on %s\n", deferred[i]->toChars());
deferred[i]->semantic3(NULL);
* all instantiated functions should run the semantic3 immediately.
* See also compilable/test14973.d
*/
- for (size_t i = 0; i < tdtypes.dim; i++)
+ for (size_t i = 0; i < tdtypes.length; i++)
{
RootObject *oarg = tdtypes[i];
Dsymbol *s = getDsymbol(oarg);
{
if (!td->literal)
continue;
- assert(td->members && td->members->dim == 1);
+ assert(td->members && td->members->length == 1);
s = (*td->members)[0];
}
if (FuncLiteralDeclaration *fld = s->isFuncLiteralDeclaration())
//printf("deferred semantic3 of %p %s, ti = %s, ti->deferred = %p\n", this, toChars(), ti->toChars());
for (size_t i = 0; ; i++)
{
- if (i == ti->deferred->dim)
+ if (i == ti->deferred->length)
{
ti->deferred->push(this);
break;
//printf("replaceInstance()\n");
TemplateInstances *tinstances = (TemplateInstances *)dmd_aaGetRvalue((AA *)tempdecl->instances, (void *)hash);
assert(tinstances);
- for (size_t i = 0; i < tinstances->dim; i++)
+ for (size_t i = 0; i < tinstances->length; i++)
{
TemplateInstance *ti = (*tinstances)[i];
if (ti == errinst)
};
// Look for forward references
OverloadSet *tovers = tempdecl->isOverloadSet();
- size_t overs_dim = tovers ? tovers->a.dim : 1;
+ size_t overs_dim = tovers ? tovers->a.length : 1;
for (size_t oi = 0; oi < overs_dim; oi++)
{
if (overloadApply(tovers ? tovers->a[oi] : tempdecl, (void *)this, &ParamFwdTi::fp))
if (os)
{
s = NULL;
- for (size_t i = 0; i < os->a.dim; i++)
+ for (size_t i = 0; i < os->a.length; i++)
{
Dsymbol *s2 = os->a[i];
if (FuncDeclaration *f = s2->isFuncDeclaration())
if (!tiargs)
return true;
bool err = false;
- for (size_t j = 0; j < tiargs->dim; j++)
+ for (size_t j = 0; j < tiargs->length; j++)
{
RootObject *o = (*tiargs)[j];
Type *ta = isType(o);
{
// Expand tuple
TypeTuple *tt = (TypeTuple *)ta;
- size_t dim = tt->arguments->dim;
+ size_t dim = tt->arguments->length;
tiargs->remove(j);
if (dim)
{
{
// Expand tuple
TupleExp *te = (TupleExp *)ea;
- size_t dim = te->exps->dim;
+ size_t dim = te->exps->length;
tiargs->remove(j);
if (dim)
{
assert(tempdecl);
assert(tempdecl->_scope);
// Deduce tdtypes
- tdtypes.setDim(tempdecl->parameters->dim);
+ tdtypes.setDim(tempdecl->parameters->length);
if (!tempdecl->matchWithInstance(sc, this, &tdtypes, fargs, 2))
{
error("incompatible arguments for template instantiation");
// If more arguments than parameters,
// then this is no match.
- if (td->parameters->dim < ti->tiargs->dim)
+ if (td->parameters->length < ti->tiargs->length)
{
if (!td->isVariadic())
return 0;
}
- dedtypes.setDim(td->parameters->dim);
+ dedtypes.setDim(td->parameters->length);
dedtypes.zero();
assert(td->semanticRun != PASSinit);
MATCH m = td->matchWithInstance(sc, ti, &dedtypes, ti->fargs, 0);
td_ambig = NULL;
td_best = td;
m_best = m;
- ti->tdtypes.setDim(dedtypes.dim);
- memcpy(ti->tdtypes.tdata(), dedtypes.tdata(), ti->tdtypes.dim * sizeof(void *));
+ ti->tdtypes.setDim(dedtypes.length);
+ memcpy(ti->tdtypes.tdata(), dedtypes.tdata(), ti->tdtypes.length * sizeof(void *));
return 0;
}
};
TemplateDeclaration *td_last = NULL;
OverloadSet *tovers = tempdecl->isOverloadSet();
- size_t overs_dim = tovers ? tovers->a.dim : 1;
+ size_t overs_dim = tovers ? tovers->a.length : 1;
for (size_t oi = 0; oi < overs_dim; oi++)
{
// result
* S!num s; // S!1 is instantiated, not S!num
* }
*/
- size_t dim = td_last->parameters->dim - (td_last->isVariadic() ? 1 : 0);
+ size_t dim = td_last->parameters->length - (td_last->isVariadic() ? 1 : 0);
for (size_t i = 0; i < dim; i++)
{
- if (tiargs->dim <= i)
+ if (tiargs->length <= i)
tiargs->push(tdtypes[i]);
- assert(i < tiargs->dim);
+ assert(i < tiargs->length);
TemplateValueParameter *tvp = (*td_last->parameters)[i]->isTemplateValueParameter();
if (!tvp)
(*tiargs)[i] = tdtypes[i];
}
- if (td_last->isVariadic() && tiargs->dim == dim && tdtypes[dim])
+ if (td_last->isVariadic() && tiargs->length == dim && tdtypes[dim])
{
Tuple *va = isTuple(tdtypes[dim]);
assert(va);
- for (size_t i = 0; i < va->objects.dim; i++)
+ for (size_t i = 0; i < va->objects.length; i++)
tiargs->push(va->objects[i]);
}
}
{
if (!td2->onemember || !td2->onemember->isFuncDeclaration())
return 0;
- if (ti->tiargs->dim >= td->parameters->dim - (td->isVariadic() ? 1 : 0))
+ if (ti->tiargs->length >= td->parameters->length - (td->isVariadic() ? 1 : 0))
return 0;
return 1;
}
return 0;
}
- for (size_t i = 0; i < td->parameters->dim; i++)
+ for (size_t i = 0; i < td->parameters->length; i++)
{
if ((*td->parameters)[i]->isTemplateThisParameter())
return 1;
/* Determine if the instance arguments, tiargs, are all that is necessary
* to instantiate the template.
*/
- //printf("tp = %p, td->parameters->dim = %d, tiargs->dim = %d\n", tp, td->parameters->dim, ti->tiargs->dim);
+ //printf("tp = %p, td->parameters->length = %d, tiargs->length = %d\n", tp, td->parameters->length, ti->tiargs->length);
TypeFunction *tf = (TypeFunction *)fd->type;
if (size_t dim = Parameter::dim(tf->parameters))
{
TemplateParameter *tp = td->isVariadic();
- if (tp && td->parameters->dim > 1)
+ if (tp && td->parameters->length > 1)
return 1;
- if (!tp && ti->tiargs->dim < td->parameters->dim)
+ if (!tp && ti->tiargs->length < td->parameters->length)
{
// Can remain tiargs be filled by default arguments?
- for (size_t i = ti->tiargs->dim; i < td->parameters->dim; i++)
+ for (size_t i = ti->tiargs->length; i < td->parameters->length; i++)
{
if (!(*td->parameters)[i]->hasDefaultArg())
return 1;
/* Calculate the need for overload resolution.
* When only one template can match with tiargs, inference is not necessary.
*/
- dedtypes.setDim(td->parameters->dim);
+ dedtypes.setDim(td->parameters->length);
dedtypes.zero();
if (td->semanticRun == PASSinit)
{
p.count = 0;
OverloadSet *tovers = tempdecl->isOverloadSet();
- size_t overs_dim = tovers ? tovers->a.dim : 1;
+ size_t overs_dim = tovers ? tovers->a.length : 1;
unsigned olderrs = global.errors;
for (size_t oi = 0; oi < overs_dim; oi++)
{
/* A nested instance happens when an argument references a local
* symbol that is on the stack.
*/
- for (size_t i = 0; i < args->dim; i++)
+ for (size_t i = 0; i < args->length; i++)
{
RootObject *o = (*args)[i];
Expression *ea = isExpression(o);
}
else
buf.printf("__T%llu%s", (ulonglong)strlen(id), id);
- size_t nparams = tempdecl->parameters->dim - (tempdecl->isVariadic() ? 1 : 0);
- for (size_t i = 0; i < args->dim; i++)
+ size_t nparams = tempdecl->parameters->length - (tempdecl->isVariadic() ? 1 : 0);
+ for (size_t i = 0; i < args->length; i++)
{
RootObject *o = (*args)[i];
Type *ta = isType(o);
}
else if (va)
{
- assert(i + 1 == args->dim); // must be last one
+ assert(i + 1 == args->length); // must be last one
args = &va->objects;
i = -(size_t)1;
}
assert(tempdecl);
//printf("TemplateInstance::declareParameters()\n");
- for (size_t i = 0; i < tdtypes.dim; i++)
+ for (size_t i = 0; i < tdtypes.length; i++)
{
TemplateParameter *tp = (*tempdecl->parameters)[i];
//RootObject *o = (*tiargs)[i];
if (needGagging)
oldGaggedErrors = global.startGagging();
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{
Dsymbol *s = (*members)[i];
s->semantic2(sc);
if (needGagging)
oldGaggedErrors = global.startGagging();
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{
Dsymbol *s = (*members)[i];
s->semantic3(sc);
TemplateInstance *ti = (TemplateInstance *)o;
//printf("this = %p, ti = %p\n", this, ti);
- assert(tdtypes.dim == ti->tdtypes.dim);
+ assert(tdtypes.length == ti->tdtypes.length);
// Nesting must match
if (enclosing != ti->enclosing)
{
if (!fargs)
goto Lnotequals;
- if (fargs->dim <= j)
+ if (fargs->length <= j)
break;
Expression *farg = (*fargs)[j];
if (farg->isLvalue())
if (Tuple *tup = isTuple(o))
{
- for (size_t i = 0; i < tup->objects.dim; i++)
+ for (size_t i = 0; i < tup->objects.length; i++)
{
unSpeculative(sc, tup->objects[i]);
}
/* ======================== TemplateMixin ================================ */
TemplateMixin::TemplateMixin(Loc loc, Identifier *ident, TypeQualified *tqual, Objects *tiargs)
- : TemplateInstance(loc, tqual->idents.dim ? (Identifier *)tqual->idents[tqual->idents.dim - 1]
+ : TemplateInstance(loc, tqual->idents.length ? (Identifier *)tqual->idents[tqual->idents.length - 1]
: ((TypeIdentifier *)tqual)->ident)
{
//printf("TemplateMixin(ident = '%s')\n", ident ? ident->toChars() : "");
if (os)
{
Dsymbol *ds = NULL;
- for (size_t i = 0; i < os->a.dim; i++)
+ for (size_t i = 0; i < os->a.length; i++)
{
Dsymbol *s2 = os->a[i]->isTemplateDeclaration();
if (s2)
};
// Look for forward references
OverloadSet *tovers = tempdecl->isOverloadSet();
- size_t overs_dim = tovers ? tovers->a.dim : 1;
+ size_t overs_dim = tovers ? tovers->a.length : 1;
for (size_t oi = 0; oi < overs_dim; oi++)
{
if (overloadApply(tovers ? tovers->a[oi] : tempdecl, (void *)this, &ParamFwdResTm::fp))
/* Different argument list lengths happen with variadic args
*/
- if (tiargs->dim != tm->tiargs->dim)
+ if (tiargs->length != tm->tiargs->length)
continue;
- for (size_t i = 0; i < tiargs->dim; i++)
+ for (size_t i = 0; i < tiargs->length; i++)
{
RootObject *o = (*tiargs)[i];
Type *ta = isType(o);
declareParameters(argscope);
// Add members to enclosing scope, as well as this scope
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{
Dsymbol *s = (*members)[i];
s->addMember(argscope, this);
// Do semantic() analysis on template instance members
Scope *sc2 = argscope->push(this);
- //size_t deferred_dim = Module::deferred.dim;
+ //size_t deferred_dim = Module::deferred.length;
static int nest;
//printf("%d\n", nest);
fatal();
}
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{
Dsymbol *s = (*members)[i];
s->setScope(sc2);
}
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{
Dsymbol *s = (*members)[i];
s->importAll(sc2);
}
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{
Dsymbol *s = (*members)[i];
s->semantic(sc2);
* Because the members would already call Module::addDeferredSemantic() for themselves.
* See Struct, Class, Interface, and EnumDeclaration::semantic().
*/
- //if (!sc->func && Module::deferred.dim > deferred_dim) {}
+ //if (!sc->func && Module::deferred.length > deferred_dim) {}
AggregateDeclaration *ad = toParent()->isAggregateDeclaration();
if (sc->func && !ad)
assert(sc);
sc = sc->push(argsym);
sc = sc->push(this);
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{
Dsymbol *s = (*members)[i];
s->semantic2(sc);
{
sc = sc->push(argsym);
sc = sc->push(this);
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{
Dsymbol *s = (*members)[i];
s->semantic3(sc);
semantic(NULL); // try to resolve it
if (members)
{
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{
Dsymbol *s = (*members)[i];
if (s)
if (members)
{
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{
Dsymbol *s = (*members)[i];
//printf(" s = %s %s\n", s->kind(), s->toChars());
semantic(NULL); // try to resolve it
if (members)
{
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{
Dsymbol *s = (*members)[i];
//printf("\t%s\n", s->toChars());
escapeByValue(arg, &er);
- if (!er.byref.dim && !er.byvalue.dim && !er.byfunc.dim && !er.byexp.dim)
+ if (!er.byref.length && !er.byvalue.length && !er.byfunc.length && !er.byexp.length)
return false;
bool result = false;
- for (size_t i = 0; i < er.byvalue.dim; i++)
+ for (size_t i = 0; i < er.byvalue.length; i++)
{
//printf("byvalue %s\n", v->toChars());
VarDeclaration *v = er.byvalue[i];
}
}
- for (size_t i = 0; i < er.byref.dim; i++)
+ for (size_t i = 0; i < er.byref.length; i++)
{
VarDeclaration *v = er.byref[i];
if (v->isDataseg())
}
}
- for (size_t i = 0; i < er.byfunc.dim; i++)
+ for (size_t i = 0; i < er.byfunc.length; i++)
{
FuncDeclaration *fd = er.byfunc[i];
//printf("fd = %s, %d\n", fd->toChars(), fd->tookAddressOf);
VarDeclarations vars;
findAllOuterAccessedVariables(fd, &vars);
- for (size_t j = 0; j < vars.dim; j++)
+ for (size_t j = 0; j < vars.length; j++)
{
VarDeclaration *v = vars[j];
//printf("v = %s\n", v->toChars());
}
}
- for (size_t i = 0; i < er.byexp.dim; i++)
+ for (size_t i = 0; i < er.byexp.length; i++)
{
Expression *ee = er.byexp[i];
if (sc->func->setUnsafe())
escapeByValue(e2, &er);
- if (!er.byref.dim && !er.byvalue.dim && !er.byfunc.dim && !er.byexp.dim)
+ if (!er.byref.length && !er.byvalue.length && !er.byfunc.length && !er.byexp.length)
return false;
VarDeclaration *va = NULL;
inferScope = ((TypeFunction *)sc->func->type)->trust != TRUSTsystem;
bool result = false;
- for (size_t i = 0; i < er.byvalue.dim; i++)
+ for (size_t i = 0; i < er.byvalue.length; i++)
{
VarDeclaration *v = er.byvalue[i];
//printf("byvalue: %s\n", v->toChars());
}
}
- for (size_t i = 0; i < er.byref.dim; i++)
+ for (size_t i = 0; i < er.byref.length; i++)
{
VarDeclaration *v = er.byref[i];
//printf("byref: %s\n", v->toChars());
}
}
- for (size_t i = 0; i < er.byfunc.dim; i++)
+ for (size_t i = 0; i < er.byfunc.length; i++)
{
FuncDeclaration *fd = er.byfunc[i];
//printf("fd = %s, %d\n", fd->toChars(), fd->tookAddressOf);
VarDeclarations vars;
findAllOuterAccessedVariables(fd, &vars);
- for (size_t j = 0; j < vars.dim; j++)
+ for (size_t j = 0; j < vars.length; j++)
{
VarDeclaration *v = vars[j];
//printf("v = %s\n", v->toChars());
}
}
- for (size_t i = 0; i < er.byexp.dim; i++)
+ for (size_t i = 0; i < er.byexp.length; i++)
{
Expression *ee = er.byexp[i];
if (va && !va->isDataseg() && !va->doNotInferScope)
escapeByValue(e, &er);
- if (!er.byref.dim && !er.byvalue.dim && !er.byexp.dim)
+ if (!er.byref.length && !er.byvalue.length && !er.byexp.length)
return false;
bool result = false;
- for (size_t i = 0; i < er.byvalue.dim; i++)
+ for (size_t i = 0; i < er.byvalue.length; i++)
{
VarDeclaration *v = er.byvalue[i];
//printf("byvalue %s\n", v->toChars());
else
escapeByValue(e, &er);
- if (!er.byref.dim && !er.byvalue.dim && !er.byexp.dim)
+ if (!er.byref.length && !er.byvalue.length && !er.byexp.length)
return false;
bool result = false;
- for (size_t i = 0; i < er.byvalue.dim; i++)
+ for (size_t i = 0; i < er.byvalue.length; i++)
{
VarDeclaration *v = er.byvalue[i];
//printf("byvalue %s\n", v->toChars());
}
}
- for (size_t i = 0; i < er.byref.dim; i++)
+ for (size_t i = 0; i < er.byref.length; i++)
{
VarDeclaration *v = er.byref[i];
//printf("byref %s\n", v->toChars());
}
}
- for (size_t i = 0; i < er.byexp.dim; i++)
+ for (size_t i = 0; i < er.byexp.length; i++)
{
Expression *ee = er.byexp[i];
//printf("byexp %s\n", ee->toChars());
{
if (e->basis)
e->basis->accept(this);
- for (size_t i = 0; i < e->elements->dim; i++)
+ for (size_t i = 0; i < e->elements->length; i++)
{
Expression *el = (*e->elements)[i];
if (el)
{
if (e->elements)
{
- for (size_t i = 0; i < e->elements->dim; i++)
+ for (size_t i = 0; i < e->elements->length; i++)
{
Expression *ex = (*e->elements)[i];
if (ex)
Type *tb = e->newtype->toBasetype();
if (tb->ty == Tstruct && !e->member && e->arguments)
{
- for (size_t i = 0; i < e->arguments->dim; i++)
+ for (size_t i = 0; i < e->arguments->length; i++)
{
Expression *ex = (*e->arguments)[i];
if (ex)
else
return;
- if (e->arguments && e->arguments->dim)
+ if (e->arguments && e->arguments->length)
{
/* j=1 if _arguments[] is first argument,
* skip it because it is not passed by ref
*/
size_t j = (tf->linkage == LINKd && tf->varargs == 1);
- for (size_t i = j; i < e->arguments->dim; ++i)
+ for (size_t i = j; i < e->arguments->length; ++i)
{
Expression *arg = (*e->arguments)[i];
size_t nparams = Parameter::dim(tf->parameters);
return;
if (tf->isref)
{
- if (e->arguments && e->arguments->dim)
+ if (e->arguments && e->arguments->length)
{
/* j=1 if _arguments[] is first argument,
* skip it because it is not passed by ref
*/
size_t j = (tf->linkage == LINKd && tf->varargs == 1);
- for (size_t i = j; i < e->arguments->dim; ++i)
+ for (size_t i = j; i < e->arguments->length; ++i)
{
Expression *arg = (*e->arguments)[i];
size_t nparams = Parameter::dim(tf->parameters);
FuncDeclaration *fdp = p->isFuncDeclaration();
if (fdp)
{
- for (size_t i = 0; i < fdp->closureVars.dim; i++)
+ for (size_t i = 0; i < fdp->closureVars.length; i++)
{
VarDeclaration *v = fdp->closureVars[i];
- for (size_t j = 0; j < v->nestedrefs.dim; j++)
+ for (size_t j = 0; j < v->nestedrefs.length; j++)
{
FuncDeclaration *fdv = v->nestedrefs[j];
if (fdv == fd)
Expressions a;
a.push(e2);
- for (size_t i = 0; i < os->a.dim; i++)
+ for (size_t i = 0; i < os->a.length; i++)
{
FuncDeclaration *f = resolveFuncCall(loc, sc, os->a[i], tiargs, tthis, &a, 1);
if (f)
}
}
{
- for (size_t i = 0; i < os->a.dim; i++)
+ for (size_t i = 0; i < os->a.length; i++)
{
FuncDeclaration *f = resolveFuncCall(loc, sc, os->a[i], tiargs, tthis, NULL, 1);
if (f)
os = ((OverExp *)e1)->vars;
Los:
assert(os);
- for (size_t i = 0; i < os->a.dim; i++)
+ for (size_t i = 0; i < os->a.length; i++)
{
Dsymbol *s = os->a[i];
fd = s->isFuncDeclaration();
/* Transform:
* aa.remove(arg) into delete aa[arg]
*/
- if (!ce->arguments || ce->arguments->dim != 1)
+ if (!ce->arguments || ce->arguments->length != 1)
{
ce->error("expected key as argument to aa.remove()");
return new ErrorExp();
bool err = false;
if (exps)
{
- for (size_t i = 0; i < exps->dim; i++)
+ for (size_t i = 0; i < exps->length; i++)
{
Expression *e = (*exps)[i];
if (e)
//printf("expandTuples()\n");
if (exps)
{
- for (size_t i = 0; i < exps->dim; i++)
+ for (size_t i = 0; i < exps->length; i++)
{
Expression *arg = (*exps)[i];
if (!arg)
{
TypeTuple *tt = (TypeTuple *)e->type->toBasetype();
- if (!tt->arguments || tt->arguments->dim == 0)
+ if (!tt->arguments || tt->arguments->length == 0)
{
exps->remove(i);
- if (i == exps->dim)
+ if (i == exps->length)
return;
i--;
continue;
TupleExp *te = (TupleExp *)arg;
exps->remove(i); // remove arg
exps->insert(i, te->exps); // replace with tuple contents
- if (i == exps->dim)
+ if (i == exps->length)
return; // empty tuple, no more arguments
(*exps)[i] = Expression::combine(te->e0, (*exps)[i]);
arg = (*exps)[i];
int expandAliasThisTuples(Expressions *exps, size_t starti)
{
- if (!exps || exps->dim == 0)
+ if (!exps || exps->length == 0)
return -1;
- for (size_t u = starti; u < exps->dim; u++)
+ for (size_t u = starti; u < exps->length; u++)
{
Expression *exp = (*exps)[u];
TupleDeclaration *td = isAliasThisTuple(exp);
if (td)
{
exps->remove(u);
- for (size_t i = 0; i<td->objects->dim; ++i)
+ for (size_t i = 0; i<td->objects->length; ++i)
{
Expression *e = isExpression((*td->objects)[i]);
assert(e);
size_t j0 = ~0; // dead-store to prevent spurious warning
bool foundType = false;
- for (size_t i = 0; i < exps->dim; i++)
+ for (size_t i = 0; i < exps->length; i++)
{
Expression *e = (*exps)[i];
if (!e)
t0 = Type::tvoid; // [] is typed as void[]
else if (t0->ty != Terror)
{
- for (size_t i = 0; i < exps->dim; i++)
+ for (size_t i = 0; i < exps->length; i++)
{
Expression *e = (*exps)[i];
if (!e)
//printf("functionParameters()\n");
assert(arguments);
assert(fd || tf->next);
- size_t nargs = arguments ? arguments->dim : 0;
+ size_t nargs = arguments ? arguments->length : 0;
size_t nparams = Parameter::dim(tf->parameters);
unsigned olderrors = global.errors;
bool err = false;
Expressions *elements = new Expressions();
elements->setDim(nargs - i);
- for (size_t u = 0; u < elements->dim; u++)
+ for (size_t u = 0; u < elements->length; u++)
{
Expression *a = (*arguments)[i + u];
if (tret && a->implicitConvTo(tret))
// If D linkage and variadic, add _arguments[] as first argument
if (tf->linkage == LINKd && tf->varargs == 1)
{
- assert(arguments->dim >= nparams);
+ assert(arguments->length >= nparams);
Parameters *args = new Parameters;
- args->setDim(arguments->dim - nparams);
- for (size_t i = 0; i < arguments->dim - nparams; i++)
+ args->setDim(arguments->length - nparams);
+ for (size_t i = 0; i < arguments->length - nparams; i++)
{
Parameter *arg = new Parameter(STCin, (*arguments)[nparams + i]->type, NULL, NULL);
(*args)[i] = arg;
if (exps)
{
a = new Expressions();
- a->setDim(exps->dim);
- for (size_t i = 0; i < a->dim; i++)
+ a->setDim(exps->length);
+ for (size_t i = 0; i < a->length; i++)
{
Expression *e = (*exps)[i];
(*a)[i] = e ? e->syntaxCopy() : NULL;
((Expression *)o)->op == TOKarrayliteral)
{
ArrayLiteralExp *ae = (ArrayLiteralExp *)o;
- if (elements->dim != ae->elements->dim)
+ if (elements->length != ae->elements->length)
return false;
- if (elements->dim == 0 &&
+ if (elements->length == 0 &&
!type->equals(ae->type))
{
return false;
}
- for (size_t i = 0; i < elements->dim; i++)
+ for (size_t i = 0; i < elements->length; i++)
{
Expression *e1 = (*elements)[i];
Expression *e2 = (*ae->elements)[i];
{
if (!ale->elements)
return;
- size_t d = elems->dim;
+ size_t d = elems->length;
elems->append(ale->elements);
- for (size_t i = d; i < elems->dim; i++)
+ for (size_t i = d; i < elems->length; i++)
{
Expression *el = (*elems)[i];
if (!el)
bool ArrayLiteralExp::isBool(bool result)
{
- size_t dim = elements ? elements->dim : 0;
+ size_t dim = elements ? elements->length : 0;
return result ? (dim != 0) : (dim == 0);
}
TY telem = type->nextOf()->toBasetype()->ty;
if (telem == Tchar || telem == Twchar || telem == Tdchar ||
- (telem == Tvoid && (!elements || elements->dim == 0)))
+ (telem == Tvoid && (!elements || elements->length == 0)))
{
unsigned char sz = 1;
if (telem == Twchar) sz = 2;
OutBuffer buf;
if (elements)
{
- for (size_t i = 0; i < elements->dim; ++i)
+ for (size_t i = 0; i < elements->length; ++i)
{
Expression *ch = getElement(i);
if (ch->op != TOKint64)
Expressions *keys, Expressions *values)
: Expression(loc, TOKassocarrayliteral, sizeof(AssocArrayLiteralExp))
{
- assert(keys->dim == values->dim);
+ assert(keys->length == values->length);
this->keys = keys;
this->values = values;
this->ownedByCtfe = OWNEDcode;
((Expression *)o)->op == TOKassocarrayliteral)
{
AssocArrayLiteralExp *ae = (AssocArrayLiteralExp *)o;
- if (keys->dim != ae->keys->dim)
+ if (keys->length != ae->keys->length)
return false;
size_t count = 0;
- for (size_t i = 0; i < keys->dim; i++)
+ for (size_t i = 0; i < keys->length; i++)
{
- for (size_t j = 0; j < ae->keys->dim; j++)
+ for (size_t j = 0; j < ae->keys->length; j++)
{
if ((*keys)[i]->equals((*ae->keys)[j]))
{
}
}
}
- return count == keys->dim;
+ return count == keys->length;
}
return false;
}
bool AssocArrayLiteralExp::isBool(bool result)
{
- size_t dim = keys->dim;
+ size_t dim = keys->length;
return result ? (dim != 0) : (dim == 0);
}
StructLiteralExp *se = (StructLiteralExp *)o;
if (!type->equals(se->type))
return false;
- if (elements->dim != se->elements->dim)
+ if (elements->length != se->elements->length)
return false;
- for (size_t i = 0; i < elements->dim; i++)
+ for (size_t i = 0; i < elements->length; i++)
{
Expression *e1 = (*elements)[i];
Expression *e2 = (*se->elements)[i];
if (i != -1)
{
//printf("\ti = %d\n", i);
- if (i == (int)sd->fields.dim - 1 && sd->isNested())
+ if (i == (int)sd->fields.length - 1 && sd->isNested())
return NULL;
- assert(i < (int)elements->dim);
+ assert(i < (int)elements->length);
e = (*elements)[i];
if (e)
{
{
/* Find which field offset is by looking at the field offsets
*/
- if (elements->dim)
+ if (elements->length)
{
- for (size_t i = 0; i < sd->fields.dim; i++)
+ for (size_t i = 0; i < sd->fields.length; i++)
{
VarDeclaration *v = sd->fields[i];
type->size() == v->type->size())
{
/* context field might not be filled. */
- if (i == sd->fields.dim - 1 && sd->isNested())
+ if (i == sd->fields.length - 1 && sd->isNested())
return (int)i;
Expression *e = (*elements)[i];
if (e)
this->e0 = NULL;
this->exps = new Expressions();
- this->exps->reserve(tup->objects->dim);
- for (size_t i = 0; i < tup->objects->dim; i++)
+ this->exps->reserve(tup->objects->length);
+ for (size_t i = 0; i < tup->objects->length; i++)
{ RootObject *o = (*tup->objects)[i];
if (Dsymbol *s = getDsymbol(o))
{
if (((Expression *)o)->op == TOKtuple)
{
TupleExp *te = (TupleExp *)o;
- if (exps->dim != te->exps->dim)
+ if (exps->length != te->exps->length)
return false;
if ((e0 && !e0->equals(te->e0)) || (!e0 && te->e0))
return false;
- for (size_t i = 0; i < exps->dim; i++)
+ for (size_t i = 0; i < exps->length; i++)
{
Expression *e1 = (*exps)[i];
Expression *e2 = (*te->exps)[i];
if (td)
{
assert(td->literal);
- assert(td->members && td->members->dim == 1);
+ assert(td->members && td->members->length == 1);
fd = (*td->members)[0]->isFuncLiteralDeclaration();
}
tok = fd->tok; // save original kind of function/delegate/(infer)
goto L1;
Objects *tiargs = new Objects();
- tiargs->reserve(td->parameters->dim);
+ tiargs->reserve(td->parameters->length);
- for (size_t i = 0; i < td->parameters->dim; i++)
+ for (size_t i = 0; i < td->parameters->length; i++)
{
TemplateParameter *tp = (*td->parameters)[i];
size_t u = 0;
if (parameters)
{
p = new TemplateParameters();
- p->setDim(parameters->dim);
- for (size_t i = 0; i < p->dim; i++)
+ p->setDim(parameters->length);
+ for (size_t i = 0; i < p->length; i++)
(*p)[i] = (*parameters)[i]->syntaxCopy();
}
return new IsExp(loc,
sc->fieldinit[i] |= CSXthis_ctor;
if (var->overlapped) // Bugzilla 15258
{
- for (size_t j = 0; j < ad->fields.dim; j++)
+ for (size_t j = 0; j < ad->fields.length; j++)
{
VarDeclaration *v = ad->fields[j];
if (v == var || !var->isOverlappedWith(v))
Dsymbol *slice = search_function(ad, Id::slice);
//printf("slice = %s %s\n", slice->kind(), slice->toChars());
- for (size_t i = 0; i < ae->arguments->dim; i++)
+ for (size_t i = 0; i < ae->arguments->length; i++)
{
if (i == 0)
*pe0 = extractOpDollarSideEffect(sc, ae);
if (e->op == TOKinterval && !(slice && slice->isTemplateDeclaration()))
{
Lfallback:
- if (ae->arguments->dim == 1)
+ if (ae->arguments->length == 1)
return NULL;
ae->error("multi-dimensional slicing requires template opSlice");
return new ErrorExp();
{
expandTuples(exps);
- for (size_t i = 0; i < exps->dim; i++)
+ for (size_t i = 0; i < exps->length; i++)
{
Expression *arg = (*exps)[i];
OverloadSet *os, Objects* tiargs, Type *tthis, Expressions *arguments)
{
FuncDeclaration *f = NULL;
- for (size_t i = 0; i < os->a.dim; i++)
+ for (size_t i = 0; i < os->a.length; i++)
{
Dsymbol *s = os->a[i];
if (tiargs && s->isFuncDeclaration())
/* Disallow array literals of type void being used.
*/
- if (e->elements->dim > 0 && t0->ty == Tvoid)
+ if (e->elements->length > 0 && t0->ty == Tvoid)
{
e->error("%s of type %s has no value", e->toChars(), e->type->toChars());
return setError();
return setError();
expandTuples(e->keys);
expandTuples(e->values);
- if (e->keys->dim != e->values->dim)
+ if (e->keys->length != e->values->length)
{
- e->error("number of keys is %u, must match number of values %u", e->keys->dim, e->values->dim);
+ e->error("number of keys is %u, must match number of values %u", e->keys->length, e->values->length);
return setError();
}
return setError();
}
- if (checkFrameAccess(e->loc, sc, e->sd, e->elements->dim))
+ if (checkFrameAccess(e->loc, sc, e->sd, e->elements->length))
return setError();
e->type = e->stype ? e->stype : e->sd->type;
return setError();
}
- size_t nargs = exp->arguments ? exp->arguments->dim : 0;
+ size_t nargs = exp->arguments ? exp->arguments->length : 0;
Expression *newprefix = NULL;
if (tb->ty == Tclass)
if (cd->isAbstract())
{
exp->error("cannot create instance of abstract class %s", cd->toChars());
- for (size_t i = 0; i < cd->vtbl.dim; i++)
+ for (size_t i = 0; i < cd->vtbl.length; i++)
{
FuncDeclaration *fd = cd->vtbl[i]->isFuncDeclaration();
if (fd && fd->isAbstract())
}
else
{
- if (exp->newargs && exp->newargs->dim)
+ if (exp->newargs && exp->newargs->length)
{
exp->error("no allocator for %s", cd->toChars());
return setError();
// references. This is the same as done for structs in sd->fill().
for (ClassDeclaration *c = cd; c; c = c->baseClass)
{
- for (size_t i = 0; i < c->fields.dim; i++)
+ for (size_t i = 0; i < c->fields.length; i++)
{
VarDeclaration *v = c->fields[i];
if (v->inuse || v->_scope == NULL || v->_init == NULL ||
}
else
{
- if (exp->newargs && exp->newargs->dim)
+ if (exp->newargs && exp->newargs->length)
{
exp->error("no allocator for %s", sd->toChars());
return setError();
exp->member = f->isCtorDeclaration();
assert(exp->member);
- if (checkFrameAccess(exp->loc, sc, sd, sd->fields.dim))
+ if (checkFrameAccess(exp->loc, sc, sd, sd->fields.length))
return setError();
}
else
return setError();
if (!sd->fill(exp->loc, exp->arguments, false))
return setError();
- if (checkFrameAccess(exp->loc, sc, sd, exp->arguments ? exp->arguments->dim : 0))
+ if (checkFrameAccess(exp->loc, sc, sd, exp->arguments ? exp->arguments->length : 0))
return setError();
}
// Run semantic() on each argument
bool err = false;
- for (size_t i = 0; i < exp->exps->dim; i++)
+ for (size_t i = 0; i < exp->exps->length; i++)
{
Expression *e = (*exp->exps)[i];
e = semantic(e, sc);
//printf("td = %p, treq = %p\n", exp->td, exp->fd->treq);
if (exp->td)
{
- assert(exp->td->parameters && exp->td->parameters->dim);
+ assert(exp->td->parameters && exp->td->parameters->length);
exp->td->semantic(sc);
exp->type = Type::tvoid; // temporary type
// used from CallExp::semantic()
Expression *callExpSemantic(FuncExp *exp, Scope *sc, Expressions *arguments)
{
- if ((!exp->type || exp->type == Type::tvoid) && exp->td && arguments && arguments->dim)
+ if ((!exp->type || exp->type == Type::tvoid) && exp->td && arguments && arguments->length)
{
- for (size_t k = 0; k < arguments->dim; k++)
+ for (size_t k = 0; k < arguments->length; k++)
{ Expression *checkarg = (*arguments)[k];
if (checkarg->op == TOKerror)
return checkarg;
exp->genIdent(sc);
- assert(exp->td->parameters && exp->td->parameters->dim);
+ assert(exp->td->parameters && exp->td->parameters->length);
exp->td->semantic(sc);
TypeFunction *tfl = (TypeFunction *)exp->fd->type;
size_t dim = Parameter::dim(tfl->parameters);
- if (arguments->dim < dim)
+ if (arguments->length < dim)
{ // Default arguments are always typed, so they don't need inference.
- Parameter *p = Parameter::getNth(tfl->parameters, arguments->dim);
+ Parameter *p = Parameter::getNth(tfl->parameters, arguments->length);
if (p->defaultArg)
- dim = arguments->dim;
+ dim = arguments->length;
}
- if ((!tfl->varargs && arguments->dim == dim) ||
- ( tfl->varargs && arguments->dim >= dim))
+ if ((!tfl->varargs && arguments->length == dim) ||
+ ( tfl->varargs && arguments->length >= dim))
{
Objects *tiargs = new Objects();
- tiargs->reserve(exp->td->parameters->dim);
+ tiargs->reserve(exp->td->parameters->length);
- for (size_t i = 0; i < exp->td->parameters->dim; i++)
+ for (size_t i = 0; i < exp->td->parameters->length; i++)
{
TemplateParameter *tp = (*exp->td->parameters)[i];
for (size_t u = 0; u < dim; u++)
AttribDeclaration *ad = s->isAttribDeclaration();
if (ad)
{
- if (ad->decl && ad->decl->dim == 1)
+ if (ad->decl && ad->decl->length == 1)
{
s = (*ad->decl)[0];
continue;
{
ClassDeclaration *cd = ((TypeClass *)e->targ)->sym;
Parameters *args = new Parameters;
- args->reserve(cd->baseclasses->dim);
+ args->reserve(cd->baseclasses->length);
if (cd->semanticRun < PASSsemanticdone)
cd->semantic(NULL);
- for (size_t i = 0; i < cd->baseclasses->dim; i++)
+ for (size_t i = 0; i < cd->baseclasses->length; i++)
{
BaseClass *b = (*cd->baseclasses)[i];
args->push(new Parameter(STCin, b->type, NULL, NULL));
}
goto Lyes;
}
- else if (e->tspec && !e->id && !(e->parameters && e->parameters->dim))
+ else if (e->tspec && !e->id && !(e->parameters && e->parameters->length))
{
/* Evaluate to true if targ matches tspec
* is(targ == tspec)
e->parameters->insert(0, new TemplateTypeParameter(e->loc, tid, NULL, NULL));
Objects dedtypes;
- dedtypes.setDim(e->parameters->dim);
+ dedtypes.setDim(e->parameters->length);
dedtypes.zero();
MATCH m = deduceType(e->targ, sc, e->tspec, e->parameters, &dedtypes);
/* Declare trailing parameters
*/
- for (size_t i = 1; i < e->parameters->dim; i++)
+ for (size_t i = 1; i < e->parameters->length; i++)
{
TemplateParameter *tp = (*e->parameters)[i];
Declaration *s = NULL;
Expression *ev = sc->func ? extractSideEffect(sc, "__tup", &e0, exp->e1) : exp->e1;
Expressions *exps = new Expressions;
- exps->reserve(tup->objects->dim);
- for (size_t i = 0; i < tup->objects->dim; i++)
+ exps->reserve(tup->objects->length);
+ for (size_t i = 0; i < tup->objects->length; i++)
{
RootObject *o = (*tup->objects)[i];
Expression *e;
// First look for constructor
if (exp->e1->op == TOKtype && sd->ctor)
{
- if (!sd->noDefaultCtor && !(exp->arguments && exp->arguments->dim))
+ if (!sd->noDefaultCtor && !(exp->arguments && exp->arguments->length))
goto Lx;
StructLiteralExp *sle = new StructLiteralExp(exp->loc, sd, NULL, exp->e1->type);
if (!sd->fill(exp->loc, sle->elements, true))
return setError();
- if (checkFrameAccess(exp->loc, sc, sd, sle->elements->dim))
+ if (checkFrameAccess(exp->loc, sc, sd, sle->elements->length))
return setError();
// Bugzilla 14556: Set concrete type to avoid further redundant semantic().
sle->type = exp->e1->type;
t1 = exp->e1->type;
}
- if (!exp->arguments || exp->arguments->dim == 0)
+ if (!exp->arguments || exp->arguments->length == 0)
{
e = t1->defaultInitLiteral(exp->loc);
}
- else if (exp->arguments->dim == 1)
+ else if (exp->arguments->length == 1)
{
e = (*exp->arguments)[0];
e = e->implicitCastTo(sc, t1);
ue->e1 = ue->e1->castTo(sc, ad2->type->addMod(ue->e1->type->mod));
ue->e1 = semantic(ue->e1, sc);
ue1 = ue->e1;
- int vi = exp->f->findVtblIndex((Dsymbols*)&ad2->vtbl, (int)ad2->vtbl.dim);
+ int vi = exp->f->findVtblIndex((Dsymbols*)&ad2->vtbl, (int)ad2->vtbl.length);
assert(vi >= 0);
exp->f = ad2->vtbl[vi]->isFuncDeclaration();
assert(exp->f);
{
te = (TupleExp *)exp->e1;
tup = NULL;
- length = te->exps->dim;
+ length = te->exps->length;
}
else if (exp->e1->op == TOKtype) // slicing a type tuple
{
if (exp->e2->op == TOKtuple)
{
TupleExp *te = (TupleExp *)exp->e2;
- if (te->exps && te->exps->dim == 1)
+ if (te->exps && te->exps->length == 1)
exp->e2 = Expression::combine(te->e0, (*te->exps)[0]); // bug 4444 fix
}
if (sc != scx)
{
te = (TupleExp *)exp->e1;
tup = NULL;
- length = te->exps->dim;
+ length = te->exps->length;
}
else if (exp->e1->op == TOKtype)
{
Expression *ae1old = ae->e1;
const bool maybeSlice =
- (ae->arguments->dim == 0 ||
- (ae->arguments->dim == 1 && (*ae->arguments)[0]->op == TOKinterval));
+ (ae->arguments->length == 0 ||
+ (ae->arguments->length == 1 && (*ae->arguments)[0]->op == TOKinterval));
IntervalExp *ie = NULL;
- if (maybeSlice && ae->arguments->dim)
+ if (maybeSlice && ae->arguments->length)
{
assert((*ae->arguments)[0]->op == TOKinterval);
ie = (IntervalExp *)(*ae->arguments)[0];
{
TupleExp *tup1 = (TupleExp *)exp->e1;
TupleExp *tup2 = (TupleExp *)e2x;
- size_t dim = tup1->exps->dim;
+ size_t dim = tup1->exps->length;
Expression *e = NULL;
- if (dim != tup2->exps->dim)
+ if (dim != tup2->exps->length)
{
- exp->error("mismatched tuple lengths, %d and %d", (int)dim, (int)tup2->exps->dim);
+ exp->error("mismatched tuple lengths, %d and %d", (int)dim, (int)tup2->exps->length);
return setError();
}
if (dim == 0)
Expressions *iexps = new Expressions();
iexps->push(ev);
- for (size_t u = 0; u < iexps->dim ; u++)
+ for (size_t u = 0; u < iexps->length ; u++)
{
Lexpand:
Expression *e = (*iexps)[u];
Parameter *arg = Parameter::getNth(tt->arguments, u);
- //printf("[%d] iexps->dim = %d, ", u, iexps->dim);
+ //printf("[%d] iexps->length = %d, ", u, iexps->length);
//printf("e = (%s %s, %s), ", Token::tochars[e->op], e->toChars(), e->type->toChars());
//printf("arg = (%s, %s)\n", arg->toChars(), arg->type->toChars());
// expand initializer to tuple
if (expandAliasThisTuples(iexps, u) != -1)
{
- if (iexps->dim <= u)
+ if (iexps->length <= u)
break;
goto Lexpand;
}
if (e2x->op == TOKarrayliteral)
{
ArrayLiteralExp *ale = (ArrayLiteralExp *)e2x;
- dim2 = ale->elements ? ale->elements->dim : 0;
+ dim2 = ale->elements ? ale->elements->length : 0;
}
else if (e2x->op == TOKslice)
{
TypeSArray *tsa1 = (TypeSArray *)toStaticArrayType(se1);
TypeSArray *tsa2 = NULL;
if (e2x->op == TOKarrayliteral)
- tsa2 = (TypeSArray *)t2->nextOf()->sarrayOf(((ArrayLiteralExp *)e2x)->elements->dim);
+ tsa2 = (TypeSArray *)t2->nextOf()->sarrayOf(((ArrayLiteralExp *)e2x)->elements->length);
else if (e2x->op == TOKslice)
tsa2 = (TypeSArray *)toStaticArrayType((SliceExp *)e2x);
else if (t2->ty == Tsarray)
*/
TupleExp *te = (TupleExp *)exp->e1;
Expressions *exps = new Expressions();
- exps->setDim(te->exps->dim);
- for (size_t i = 0; i < exps->dim; i++)
+ exps->setDim(te->exps->length);
+ for (size_t i = 0; i < exps->length; i++)
{
Expression *e = (*te->exps)[i];
e = semantic(e, sc);
{
TupleExp *te = (TupleExp *)exp->e1;
// Don't evaluate te->e0 in runtime
- Expression *e = new IntegerExp(exp->loc, te->exps->dim, Type::tsize_t);
+ Expression *e = new IntegerExp(exp->loc, te->exps->length, Type::tsize_t);
return e;
}
void visit(CompileStatement *) { }
void visit(CompoundStatement *s)
{
- if (s->statements && s->statements->dim)
+ if (s->statements && s->statements->length)
{
- for (size_t i = 0; i < s->statements->dim; i++)
+ for (size_t i = 0; i < s->statements->length; i++)
{
if ((*s->statements)[i])
visitStmt((*s->statements)[i]);
void visit(CompoundDeclarationStatement *s) { visit((CompoundStatement *)s); }
void visit(UnrolledLoopStatement *s)
{
- if (s->statements && s->statements->dim)
+ if (s->statements && s->statements->length)
{
- for (size_t i = 0; i < s->statements->dim; i++)
+ for (size_t i = 0; i < s->statements->length; i++)
{
if ((*s->statements)[i])
visitStmt((*s->statements)[i]);
{
if (s->_body)
visitStmt(s->_body);
- if (s->catches && s->catches->dim)
+ if (s->catches && s->catches->length)
{
- for (size_t i = 0; i < s->catches->dim; i++)
+ for (size_t i = 0; i < s->catches->length; i++)
{
Catch *c = (*s->catches)[i];
if (c && c->handler)
goto Ldone;
bool may_override = false;
- for (size_t i = 0; i < cd->baseclasses->dim; i++)
+ for (size_t i = 0; i < cd->baseclasses->length; i++)
{
BaseClass *b = (*cd->baseclasses)[i];
ClassDeclaration *cbd = b->type->toBasetype()->isClassHandle();
if (!cbd)
continue;
- for (size_t j = 0; j < cbd->vtbl.dim; j++)
+ for (size_t j = 0; j < cbd->vtbl.length; j++)
{
FuncDeclaration *f2 = cbd->vtbl[j]->isFuncDeclaration();
if (!f2 || f2->ident != ident)
/* Find index of existing function in base class's vtbl[] to override
* (the index will be the same as in cd's current vtbl[])
*/
- int vi = cd->baseClass ? findVtblIndex((Dsymbols*)&cd->baseClass->vtbl, (int)cd->baseClass->vtbl.dim)
+ int vi = cd->baseClass ? findVtblIndex((Dsymbols*)&cd->baseClass->vtbl, (int)cd->baseClass->vtbl.length)
: -1;
bool doesoverride = false;
/* These quirky conditions mimic what VC++ appears to do
*/
if (global.params.mscoff && cd->isCPPclass() &&
- cd->baseClass && cd->baseClass->vtbl.dim)
+ cd->baseClass && cd->baseClass->vtbl.length)
{
/* if overriding an interface function, then this is not
* introducing and don't put it in the class vtbl[]
if (cd->isCPPclass() && Target::reverseCppOverloads)
{
// with dmc, overloaded functions are grouped and in reverse order
- vtblIndex = (int)cd->vtbl.dim;
- for (int i = 0; i < (int)cd->vtbl.dim; i++)
+ vtblIndex = (int)cd->vtbl.length;
+ for (int i = 0; i < (int)cd->vtbl.length; i++)
{
if (cd->vtbl[i]->ident == ident && cd->vtbl[i]->parent == parent)
{
}
}
// shift all existing functions back
- for (int i = (int)cd->vtbl.dim; i > vtblIndex; i--)
+ for (int i = (int)cd->vtbl.length; i > vtblIndex; i--)
{
FuncDeclaration *fd = cd->vtbl[i-1]->isFuncDeclaration();
assert(fd);
else
{
// Append to end of vtbl[]
- vi = (int)cd->vtbl.dim;
+ vi = (int)cd->vtbl.length;
cd->vtbl.push(this);
vtblIndex = vi;
}
}
else
{
- int vi2 = findVtblIndex(&cd->baseClass->vtbl, (int)cd->baseClass->vtbl.dim, false);
+ int vi2 = findVtblIndex(&cd->baseClass->vtbl, (int)cd->baseClass->vtbl.length, false);
if (vi2 < 0)
// https://issues.dlang.org/show_bug.cgi?id=17349
::deprecation(loc, "cannot implicitly override base class method `%s` with `%s`; add `override` attribute",
for (size_t i = 0; i < cd->interfaces.length; i++)
{
BaseClass *b = cd->interfaces.ptr[i];
- vi = findVtblIndex((Dsymbols *)&b->sym->vtbl, (int)b->sym->vtbl.dim);
+ vi = findVtblIndex((Dsymbols *)&b->sym->vtbl, (int)b->sym->vtbl.length);
switch (vi)
{
case -1:
{
BaseClass *bc = NULL;
Dsymbol *s = NULL;
- for (size_t i = 0; i < cd->baseclasses->dim; i++)
+ for (size_t i = 0; i < cd->baseclasses->length; i++)
{
bc = (*cd->baseclasses)[i];
s = bc->sym->search_correct(ident);
if (fd->fensure)
return true;
- for (size_t i = 0; i < fd->foverrides.dim; i++)
+ for (size_t i = 0; i < fd->foverrides.length; i++)
{
FuncDeclaration *fdv = fd->foverrides[i];
if (frequire)
{
- for (size_t i = 0; i < foverrides.dim; i++)
+ for (size_t i = 0; i < foverrides.length; i++)
{
FuncDeclaration *fdv = foverrides[i];
// but not in parameters[].
if (f->parameters)
{
- for (size_t i = 0; i < f->parameters->dim; i++)
+ for (size_t i = 0; i < f->parameters->length; i++)
{
Parameter *fparam = (*f->parameters)[i];
*/
if (ad2 && isCtorDeclaration())
{
- allocFieldinit(sc2, ad2->fields.dim);
- for (size_t i = 0; i < ad2->fields.dim; i++)
+ allocFieldinit(sc2, ad2->fields.length);
+ for (size_t i = 0; i < ad2->fields.length; i++)
{
VarDeclaration *v = ad2->fields[i];
v->ctorinit = 0;
if (returns && !fbody->isErrorStatement())
{
- for (size_t i = 0; i < returns->dim; )
+ for (size_t i = 0; i < returns->length; )
{
Expression *exp = (*returns)[i]->exp;
if (exp->op == TOKvar && ((VarExp *)exp)->var == vresult)
* ctor consts were initialized.
*/
ScopeDsymbol *pd = toParent()->isScopeDsymbol();
- for (size_t i = 0; i < pd->members->dim; i++)
+ for (size_t i = 0; i < pd->members->length; i++)
{
Dsymbol *s = (*pd->members)[i];
s->checkCtorConstInit();
// Verify that all the ctorinit fields got initialized
if (!(sc2->callSuper & CSXthis_ctor))
{
- for (size_t i = 0; i < ad2->fields.dim; i++)
+ for (size_t i = 0; i < ad2->fields.length; i++)
{
VarDeclaration *v = ad2->fields[i];
if (v->isThisDeclaration())
/* Cannot move this loop into NrvoWalker, because
* returns[i] may be in the nested delegate for foreach-body.
*/
- for (size_t i = 0; i < returns->dim; i++)
+ for (size_t i = 0; i < returns->length; i++)
{
ReturnStatement *rs = (*returns)[i];
Expression *exp = rs->exp;
// Merge in initialization of 'out' parameters
if (parameters)
{
- for (size_t i = 0; i < parameters->dim; i++)
+ for (size_t i = 0; i < parameters->length; i++)
{
VarDeclaration *v = (*parameters)[i];
if (v->storage_class & STCout)
*/
if (parameters)
{
- for (size_t i = 0; i < parameters->dim; i++)
+ for (size_t i = 0; i < parameters->length; i++)
{
VarDeclaration *v = (*parameters)[i];
// Fix up forward-referenced gotos
if (gotos)
{
- for (size_t i = 0; i < gotos->dim; ++i)
+ for (size_t i = 0; i < gotos->length; ++i)
{
(*gotos)[i]->checkLabel();
}
if (parameters)
{
size_t nfparams = Parameter::dim(f->parameters);
- assert(nfparams == parameters->dim);
- for (size_t u = 0; u < parameters->dim; u++)
+ assert(nfparams == parameters->length);
+ for (size_t u = 0; u < parameters->length; u++)
{
VarDeclaration *v = (*parameters)[u];
if (v->storage_class & STCmaybescope)
* a stack local, allocate that local immediately following the exception
* handler block, so it is always at the same offset from EBP.
*/
- for (size_t i = 0; i < foverrides.dim; i++)
+ for (size_t i = 0; i < foverrides.length; i++)
{
FuncDeclaration *fdv = foverrides[i];
* list for the 'this' pointer, something that would need an unknown amount
* of tweaking of various parts of the compiler that I'd rather leave alone.
*/
- for (size_t i = 0; i < foverrides.dim; i++)
+ for (size_t i = 0; i < foverrides.length; i++)
{
FuncDeclaration *fdv = foverrides[i];
}
/*************************************************
- * Find index of function in vtbl[0..dim] that
+ * Find index of function in vtbl[0..length] that
* this function overrides.
* Prefer an exact match to a covariant one.
* Params:
for (size_t i = 0; i < cd->interfaces.length; i++)
{
BaseClass *b = cd->interfaces.ptr[i];
- int v = findVtblIndex((Dsymbols *)&b->sym->vtbl, (int)b->sym->vtbl.dim);
+ int v = findVtblIndex((Dsymbols *)&b->sym->vtbl, (int)b->sym->vtbl.length);
if (v >= 0)
return b;
}
if (!isVirtual())
return false;
// If it's a final method, and does not override anything, then it is not virtual
- if (isFinalFunc() && foverrides.dim == 0)
+ if (isFinalFunc() && foverrides.length == 0)
{
return false;
}
c.type = tb;
AggregateDeclaration *sym = tb->toDsymbol(NULL)->isAggregateDeclaration();
- for (size_t i = 0; i < sym->fields.dim; i++)
+ for (size_t i = 0; i < sym->fields.length; i++)
{
VarDeclaration *v = sym->fields[i];
Type *tprmi = v->type->addMod(tb->mod);
if (fdthis != this)
{
bool found = false;
- for (size_t i = 0; i < siblingCallers.dim; ++i)
+ for (size_t i = 0; i < siblingCallers.length; ++i)
{
if (siblingCallers[i] == fdthis)
found = true;
for (Dsymbol *sx = f; sx && sx != outerFunc; sx = sx->parent)
{
FuncDeclaration *fy = sx->isFuncDeclaration();
- if (fy && fy->closureVars.dim)
+ if (fy && fy->closureVars.length)
{
/* fy needs a closure if it has closureVars[],
* because the frame pointer in the closure will be accessed.
//printf("checkEscapingSiblings(f = %s, outerfunc = %s)\n", f->toChars(), outerFunc->toChars());
bool bAnyClosures = false;
- for (size_t i = 0; i < f->siblingCallers.dim; ++i)
+ for (size_t i = 0; i < f->siblingCallers.length; ++i)
{
FuncDeclaration *g = f->siblingCallers[i];
if (g->isThis() || g->tookAddressOf)
if (requiresClosure)
goto Lyes;
- for (size_t i = 0; i < closureVars.dim; i++)
+ for (size_t i = 0; i < closureVars.length; i++)
{
VarDeclaration *v = closureVars[i];
//printf("\tv = %s\n", v->toChars());
- for (size_t j = 0; j < v->nestedrefs.dim; j++)
+ for (size_t j = 0; j < v->nestedrefs.length; j++)
{
FuncDeclaration *f = v->nestedrefs[j];
assert(f != this);
}
FuncDeclarations a;
- for (size_t i = 0; i < closureVars.dim; i++)
+ for (size_t i = 0; i < closureVars.length; i++)
{
VarDeclaration *v = closureVars[i];
- for (size_t j = 0; j < v->nestedrefs.dim; j++)
+ for (size_t j = 0; j < v->nestedrefs.length; j++)
{
FuncDeclaration *f = v->nestedrefs[j];
assert(f != this);
Lfound:
for (size_t k = 0; ; k++)
{
- if (k == a.dim)
+ if (k == a.length)
{
a.push(f);
::errorSupplemental(f->loc, "%s closes over variable %s at %s",
bool FuncDeclaration::hasNestedFrameRefs()
{
- if (closureVars.dim)
+ if (closureVars.length)
return true;
/* If a virtual function has contracts, assume its variables are referenced
if (fdrequire || fdensure)
return true;
- if (foverrides.dim && isVirtualMethod())
+ if (foverrides.length && isVirtualMethod())
{
- for (size_t i = 0; i < foverrides.dim; i++)
+ for (size_t i = 0; i < foverrides.length; i++)
{
FuncDeclaration *fdv = foverrides[i];
if (fdv->hasNestedFrameRefs())
void visit(CompoundStatement *s)
{
- for (size_t i = 0; i < s->statements->dim; i++)
+ for (size_t i = 0; i < s->statements->length; i++)
{
Statement *sx = (*s->statements)[i];
if (sx)
void visit(CompoundDeclarationStatement *s)
{
bool anywritten = false;
- for (size_t i = 0; i < s->statements->dim; i++)
+ for (size_t i = 0; i < s->statements->length; i++)
{
Statement *sx = (*s->statements)[i];
ExpStatement *ds = sx ? sx->isExpStatement() : NULL;
buf->writenl();
buf->level++;
- for (size_t i = 0; i < s->statements->dim; i++)
+ for (size_t i = 0; i < s->statements->length; i++)
{
Statement *sx = (*s->statements)[i];
if (sx)
{
buf->writestring(Token::toChars(s->op));
buf->writestring(" (");
- for (size_t i = 0; i < s->parameters->dim; i++)
+ for (size_t i = 0; i < s->parameters->length; i++)
{
Parameter *p = (*s->parameters)[i];
if (i)
{
buf->writestring("pragma (");
buf->writestring(s->ident->toChars());
- if (s->args && s->args->dim)
+ if (s->args && s->args->length)
{
buf->writestring(", ");
argsToBuffer(s->args);
buf->writenl();
if (s->_body)
s->_body->accept(this);
- for (size_t i = 0; i < s->catches->dim; i++)
+ for (size_t i = 0; i < s->catches->length; i++)
{
Catch *c = (*s->catches)[i];
visit(c);
void visit(ImportStatement *s)
{
- for (size_t i = 0; i < s->imports->dim; i++)
+ for (size_t i = 0; i < s->imports->length; i++)
{
Dsymbol *imp = (*s->imports)[i];
imp->accept(this);
if (td)
{
buf->writeByte('(');
- for (size_t i = 0; i < td->origParameters->dim; i++)
+ for (size_t i = 0; i < td->origParameters->length; i++)
{
TemplateParameter *p = (*td->origParameters)[i];
if (i)
void visitTypeQualifiedHelper(TypeQualified *t)
{
- for (size_t i = 0; i < t->idents.dim; i++)
+ for (size_t i = 0; i < t->idents.length; i++)
{
RootObject *id = t->idents[i];
{
buf->printf("%s = ", imp->aliasId->toChars());
}
- if (imp->packages && imp->packages->dim)
+ if (imp->packages && imp->packages->length)
{
- for (size_t i = 0; i < imp->packages->dim; i++)
+ for (size_t i = 0; i < imp->packages->length; i++)
{
Identifier *pid = (*imp->packages)[i];
buf->printf("%s.", pid->toChars());
}
}
buf->printf("%s", imp->id->toChars());
- if (imp->names.dim)
+ if (imp->names.length)
{
buf->writestring(" : ");
- for (size_t i = 0; i < imp->names.dim; i++)
+ for (size_t i = 0; i < imp->names.length; i++)
{
if (i)
buf->writestring(", ");
return;
}
- if (d->decl->dim == 0)
+ if (d->decl->length == 0)
buf->writestring("{}");
- else if (hgs->hdrgen && d->decl->dim == 1 && (*d->decl)[0]->isUnitTestDeclaration())
+ else if (hgs->hdrgen && d->decl->length == 1 && (*d->decl)[0]->isUnitTestDeclaration())
{
// hack for bugzilla 8081
buf->writestring("{}");
}
- else if (d->decl->dim == 1)
+ else if (d->decl->length == 1)
{
((*d->decl)[0])->accept(this);
return;
buf->writeByte('{');
buf->writenl();
buf->level++;
- for (size_t i = 0; i < d->decl->dim; i++)
+ for (size_t i = 0; i < d->decl->length; i++)
{
Dsymbol *de = (*d->decl)[i];
de->accept(this);
buf->level++;
if (d->decl)
{
- for (size_t i = 0; i < d->decl->dim; i++)
+ for (size_t i = 0; i < d->decl->length; i++)
{
Dsymbol *de = (*d->decl)[i];
de->accept(this);
void visit(PragmaDeclaration *d)
{
buf->printf("pragma (%s", d->ident->toChars());
- if (d->args && d->args->dim)
+ if (d->args && d->args->length)
{
buf->writestring(", ");
argsToBuffer(d->args);
buf->level++;
if (d->decl)
{
- for (size_t i = 0; i < d->decl->dim; i++)
+ for (size_t i = 0; i < d->decl->length; i++)
{
Dsymbol *de = (*d->decl)[i];
de->accept(this);
buf->writeByte('{');
buf->writenl();
buf->level++;
- for (size_t i = 0; i < d->elsedecl->dim; i++)
+ for (size_t i = 0; i < d->elsedecl->length; i++)
{
Dsymbol *de = (*d->elsedecl)[i];
de->accept(this);
buf->writeByte('{');
buf->writenl();
buf->level++;
- for (size_t i = 0; i < d->members->dim; i++)
+ for (size_t i = 0; i < d->members->length; i++)
{
Dsymbol *s = (*d->members)[i];
s->accept(this);
bool visitEponymousMember(TemplateDeclaration *d)
{
- if (!d->members || d->members->dim != 1)
+ if (!d->members || d->members->length != 1)
return false;
Dsymbol *onemember = (*d->members)[0];
buf->writeByte('{');
buf->writenl();
buf->level++;
- for (size_t i = 0; i < ad->members->dim; i++)
+ for (size_t i = 0; i < ad->members->length; i++)
{
Dsymbol *s = (*ad->members)[i];
s->accept(this);
}
void visitTemplateParameters(TemplateParameters *parameters)
{
- if (!parameters || !parameters->dim)
+ if (!parameters || !parameters->length)
return;
- for (size_t i = 0; i < parameters->dim; i++)
+ for (size_t i = 0; i < parameters->length; i++)
{
TemplateParameter *p = (*parameters)[i];
if (i)
return;
}
- if (ti->tiargs->dim == 1)
+ if (ti->tiargs->length == 1)
{
RootObject *oarg = (*ti->tiargs)[0];
if (Type *t = isType(oarg))
t->equals(Type::tdstring) ||
(t->mod == 0 &&
(t->isTypeBasic() ||
- (t->ty == Tident && ((TypeIdentifier *)t)->idents.dim == 0))))
+ (t->ty == Tident && ((TypeIdentifier *)t)->idents.length == 0))))
{
buf->writestring(t->toChars());
return;
}
buf->writeByte('(');
ti->nest++;
- for (size_t i = 0; i < ti->tiargs->dim; i++)
+ for (size_t i = 0; i < ti->tiargs->length; i++)
{
RootObject *arg = (*ti->tiargs)[i];
if (i)
else if (Tuple *v = isTuple(oarg))
{
Objects *args = &v->objects;
- for (size_t i = 0; i < args->dim; i++)
+ for (size_t i = 0; i < args->length; i++)
{
RootObject *arg = (*args)[i];
if (i)
buf->writeByte('{');
buf->writenl();
buf->level++;
- for (size_t i = 0; i < d->members->dim; i++)
+ for (size_t i = 0; i < d->members->length; i++)
{
EnumMember *em = (*d->members)[i]->isEnumMember();
if (!em)
buf->writeByte('{');
buf->writenl();
buf->level++;
- for (size_t i = 0; i < d->members->dim; i++)
+ for (size_t i = 0; i < d->members->length; i++)
{
Dsymbol *s = (*d->members)[i];
s->accept(this);
buf->writeByte('{');
buf->writenl();
buf->level++;
- for (size_t i = 0; i < d->members->dim; i++)
+ for (size_t i = 0; i < d->members->length; i++)
{
Dsymbol *s = (*d->members)[i];
s->accept(this);
buf->writeByte('{');
buf->writenl();
buf->level++;
- for (size_t i = 0; i < d->members->dim; i++)
+ for (size_t i = 0; i < d->members->length; i++)
{
Dsymbol *s = (*d->members)[i];
s->accept(this);
void visitBaseClasses(ClassDeclaration *d)
{
- if (!d || !d->baseclasses->dim)
+ if (!d || !d->baseclasses->length)
return;
buf->writestring(" : ");
- for (size_t i = 0; i < d->baseclasses->dim; i++)
+ for (size_t i = 0; i < d->baseclasses->length; i++)
{
if (i)
buf->writestring(", ");
Statement *s1;
if (f->semanticRun >= PASSsemantic3done && cs)
{
- s1 = (*cs->statements)[cs->statements->dim - 1];
+ s1 = (*cs->statements)[cs->statements->length - 1];
}
else
s1 = !cs ? f->fbody : NULL;
{
//printf("StructInitializer::toCBuffer()\n");
buf->writeByte('{');
- for (size_t i = 0; i < si->field.dim; i++)
+ for (size_t i = 0; i < si->field.length; i++)
{
if (i)
buf->writestring(", ");
void visit(ArrayInitializer *ai)
{
buf->writeByte('[');
- for (size_t i = 0; i < ai->index.dim; i++)
+ for (size_t i = 0; i < ai->index.length; i++)
{
if (i)
buf->writestring(", ");
*/
void argsToBuffer(Expressions *expressions, Expression *basis = NULL)
{
- if (!expressions || !expressions->dim)
+ if (!expressions || !expressions->length)
return;
- for (size_t i = 0; i < expressions->dim; i++)
+ for (size_t i = 0; i < expressions->length; i++)
{
Expression *el = (*expressions)[i];
if (i)
EnumDeclaration *sym = te->sym;
if (inEnumDecl != sym)
{
- for (size_t i = 0; i < sym->members->dim; i++)
+ for (size_t i = 0; i < sym->members->length; i++)
{
EnumMember *em = (EnumMember *)(*sym->members)[i];
if (em->value()->toInteger() == v)
void visit(AssocArrayLiteralExp *e)
{
buf->writeByte('[');
- for (size_t i = 0; i < e->keys->dim; i++)
+ for (size_t i = 0; i < e->keys->length; i++)
{
Expression *key = (*e->keys)[i];
Expression *value = (*e->values)[i];
buf->writeByte('.');
}
buf->writestring("new ");
- if (e->newargs && e->newargs->dim)
+ if (e->newargs && e->newargs->length)
{
buf->writeByte('(');
argsToBuffer(e->newargs);
buf->writeByte(')');
}
typeToBuffer(e->newtype, NULL);
- if (e->arguments && e->arguments->dim)
+ if (e->arguments && e->arguments->length)
{
buf->writeByte('(');
argsToBuffer(e->arguments);
buf->writeByte('.');
}
buf->writestring("new");
- if (e->newargs && e->newargs->dim)
+ if (e->newargs && e->newargs->length)
{
buf->writeByte('(');
argsToBuffer(e->newargs);
buf->writeByte(')');
}
buf->writestring(" class ");
- if (e->arguments && e->arguments->dim)
+ if (e->arguments && e->arguments->length)
{
buf->writeByte('(');
argsToBuffer(e->arguments);
buf->writestring(e->ident->toChars());
if (e->args)
{
- for (size_t i = 0; i < e->args->dim; i++)
+ for (size_t i = 0; i < e->args->length; i++)
{
RootObject *arg = (*e->args)[i];
buf->writestring(", ");
buf->writestring(" == ");
typeToBuffer(e->tspec, NULL);
}
- if (e->parameters && e->parameters->dim)
+ if (e->parameters && e->parameters->length)
{
buf->writestring(", ");
visitTemplateParameters(e->parameters);
}
if (varargs)
{
- if (parameters->dim && varargs == 1)
+ if (parameters->length && varargs == 1)
buf->writestring(", ");
buf->writestring("...");
}
buf->writeByte(';');
buf->writenl();
}
- for (size_t i = 0; i < m->members->dim; i++)
+ for (size_t i = 0; i < m->members->length; i++)
{
Dsymbol *s = (*m->members)[i];
s->accept(this);
*/
void argExpTypesToCBuffer(OutBuffer *buf, Expressions *arguments)
{
- if (!arguments || !arguments->dim)
+ if (!arguments || !arguments->length)
return;
HdrGenState hgs;
PrettyPrintVisitor v(buf, &hgs);
- for (size_t i = 0; i < arguments->dim; i++)
+ for (size_t i = 0; i < arguments->length; i++)
{
Expression *arg = (*arguments)[i];
if (i)
void arrayObjectsToBuffer(OutBuffer *buf, Objects *objects)
{
- if (!objects || !objects->dim)
+ if (!objects || !objects->length)
return;
HdrGenState hgs;
PrettyPrintVisitor v(buf, &hgs);
- for (size_t i = 0; i < objects->dim; i++)
+ for (size_t i = 0; i < objects->length; i++)
{
RootObject *o = (*objects)[i];
if (i)
// Analyse all input and output operands.
if (s->args)
{
- for (size_t i = 0; i < s->args->dim; i++)
+ for (size_t i = 0; i < s->args->length; i++)
{
Expression *e = (*s->args)[i];
e = semantic(e, sc);
// Analyse all clobbers.
if (s->clobbers)
{
- for (size_t i = 0; i < s->clobbers->dim; i++)
+ for (size_t i = 0; i < s->clobbers->length; i++)
{
Expression *e = (*s->clobbers)[i];
e = semantic(e, sc);
// Analyse all goto labels.
if (s->labels)
{
- for (size_t i = 0; i < s->labels->dim; i++)
+ for (size_t i = 0; i < s->labels->length; i++)
{
Identifier *ident = (*s->labels)[i];
GotoStatement *gs = new GotoStatement(s->loc, ident);
if (ai)
{
a = new Initializers();
- a->setDim(ai->dim);
- for (size_t i = 0; i < a->dim; i++)
+ a->setDim(ai->length);
+ for (size_t i = 0; i < a->length; i++)
(*a)[i] = (*ai)[i]->syntaxCopy();
}
return a;
Initializer *StructInitializer::syntaxCopy()
{
StructInitializer *ai = new StructInitializer(loc);
- assert(field.dim == value.dim);
- ai->field.setDim(field.dim);
- ai->value.setDim(value.dim);
- for (size_t i = 0; i < field.dim; i++)
+ assert(field.length == value.length);
+ ai->field.setDim(field.length);
+ ai->value.setDim(value.length);
+ for (size_t i = 0; i < field.length; i++)
{
ai->field[i] = field[i];
ai->value[i] = value[i]->syntaxCopy();
{
//printf("ArrayInitializer::syntaxCopy()\n");
ArrayInitializer *ai = new ArrayInitializer(loc);
- assert(index.dim == value.dim);
- ai->index.setDim(index.dim);
- ai->value.setDim(value.dim);
- for (size_t i = 0; i < ai->value.dim; i++)
+ assert(index.length == value.length);
+ ai->index.setDim(index.length);
+ ai->value.setDim(value.length);
+ for (size_t i = 0; i < ai->value.length; i++)
{
ai->index[i] = index[i] ? index[i]->syntaxCopy() : NULL;
ai->value[i] = value[i]->syntaxCopy();
bool ArrayInitializer::isAssociativeArray()
{
- for (size_t i = 0; i < value.dim; i++)
+ for (size_t i = 0; i < value.length; i++)
{
if (index[i])
return true;
//printf("ArrayInitializer::toAssocArrayInitializer()\n");
//static int i; if (++i == 2) halt();
Expressions *keys = new Expressions();
- keys->setDim(value.dim);
+ keys->setDim(value.length);
Expressions *values = new Expressions();
- values->setDim(value.dim);
+ values->setDim(value.length);
- for (size_t i = 0; i < value.dim; i++)
+ for (size_t i = 0; i < value.length; i++)
{
e = index[i];
if (!e)
bool arrayHasNonConstPointers(Expressions *elems)
{
- for (size_t i = 0; i < elems->dim; i++)
+ for (size_t i = 0; i < elems->length; i++)
{
Expression *e = (*elems)[i];
if (e && hasNonConstPointers(e))
result = new ErrorInitializer();
return;
}
- size_t nfields = sd->fields.dim - sd->isNested();
+ size_t nfields = sd->fields.length - sd->isNested();
//expandTuples for non-identity arguments?
Expressions *elements = new Expressions();
elements->setDim(nfields);
- for (size_t j = 0; j < elements->dim; j++)
+ for (size_t j = 0; j < elements->length; j++)
(*elements)[j] = NULL;
// Run semantic for explicitly given initializers
// TODO: this part is slightly different from StructLiteralExp::semantic.
bool errors = false;
- for (size_t fieldi = 0, j = 0; j < i->field.dim; j++)
+ for (size_t fieldi = 0, j = 0; j < i->field.length; j++)
{
if (Identifier *id = i->field[j])
{
result = ::semantic(ie, sc, t, needInterpret);
return;
}
- else if ((t->ty == Tdelegate || (t->ty == Tpointer && t->nextOf()->ty == Tfunction)) && i->value.dim == 0)
+ else if ((t->ty == Tdelegate || (t->ty == Tpointer && t->nextOf()->ty == Tfunction)) && i->value.length == 0)
{
TOK tok = (t->ty == Tdelegate) ? TOKdelegate : TOKfunction;
/* Rewrite as empty delegate literal { }
i->type = t;
length = 0;
- for (size_t j = 0; j < i->index.dim; j++)
+ for (size_t j = 0; j < i->index.length; j++)
{
Expression *idx = i->index[j];
if (idx)
i->index.remove(j);
i->value.remove(j);
- for (size_t k = 0; k < te->exps->dim; ++k)
+ for (size_t k = 0; k < te->exps->length; ++k)
{
Expression *e = (*te->exps)[k];
i->index.insert(j + k, (Expression *)NULL);
return;
}
- if (i->exp->type->ty == Ttuple && ((TypeTuple *)i->exp->type)->arguments->dim == 0)
+ if (i->exp->type->ty == Ttuple && ((TypeTuple *)i->exp->type)->arguments->length == 0)
{
Type *et = i->exp->type;
i->exp = new TupleExp(i->exp->loc, new Expressions());
if (i->exp->op == TOKarrayliteral)
{
ArrayLiteralExp *ale = (ArrayLiteralExp *)i->exp;
- dim2 = ale->elements ? ale->elements->dim : 0;
+ dim2 = ale->elements ? ale->elements->length : 0;
}
else if (i->exp->op == TOKslice)
{
if (init->isAssociativeArray())
{
keys = new Expressions();
- keys->setDim(init->value.dim);
+ keys->setDim(init->value.length);
values = new Expressions();
- values->setDim(init->value.dim);
+ values->setDim(init->value.length);
- for (size_t i = 0; i < init->value.dim; i++)
+ for (size_t i = 0; i < init->value.length; i++)
{
Expression *e = init->index[i];
if (!e)
else
{
Expressions *elements = new Expressions();
- elements->setDim(init->value.dim);
+ elements->setDim(init->value.length);
elements->zero();
- for (size_t i = 0; i < init->value.dim; i++)
+ for (size_t i = 0; i < init->value.length; i++)
{
assert(!init->index[i]); // already asserted by isAssociativeArray()
void visit(ArrayInitializer *init)
{
- //printf("ArrayInitializer::toExpression(), dim = %d\n", init->dim);
+ //printf("ArrayInitializer::toExpression(), dim = %d\n", init->length);
//static int i; if (++i == 2) halt();
Expressions *elements;
}
else
{
- edim = (unsigned)init->value.dim;
- for (size_t i = 0, j = 0; i < init->value.dim; i++, j++)
+ edim = (unsigned)init->value.length;
+ for (size_t i = 0, j = 0; i < init->value.length; i++, j++)
{
if (init->index[i])
{
elements = new Expressions();
elements->setDim(edim);
elements->zero();
- for (size_t i = 0, j = 0; i < init->value.dim; i++, j++)
+ for (size_t i = 0, j = 0; i < init->value.length; i++, j++)
{
if (init->index[i])
j = (size_t)(init->index[i])->toInteger();
{
size_t dim = ((TypeSArray *)tn)->dim->toInteger();
Type *te = tn->nextOf()->toBasetype();
- for (size_t i = 0; i < elements->dim; i++)
+ for (size_t i = 0; i < elements->length; i++)
{
Expression *e = (*elements)[i];
if (te->equals(e->type))
void property(const char *name, Parameters *parameters)
{
- if (parameters == NULL || parameters->dim == 0)
+ if (parameters == NULL || parameters->length == 0)
return;
propertyStart(name);
if (parameters)
{
- for (size_t i = 0; i < parameters->dim; i++)
+ for (size_t i = 0; i < parameters->length; i++)
{
Parameter *p = (*parameters)[i];
objectStart();
propertyStart("members");
arrayStart();
- for (size_t i = 0; i < s->members->dim; i++)
+ for (size_t i = 0; i < s->members->length; i++)
{
(*s->members)[i]->accept(this);
}
propertyStart("name");
stringStart();
- if (s->packages && s->packages->dim)
+ if (s->packages && s->packages->length)
{
- for (size_t i = 0; i < s->packages->dim; i++)
+ for (size_t i = 0; i < s->packages->length; i++)
{
Identifier *pid = (*s->packages)[i];
stringPart(pid->toChars());
bool hasRenamed = false;
bool hasSelective = false;
- for (size_t i = 0; i < s->aliases.dim; i++)
+ for (size_t i = 0; i < s->aliases.length; i++)
{
// avoid empty "renamed" and "selective" sections
if (hasRenamed && hasSelective)
// import foo : alias1 = target1;
propertyStart("renamed");
objectStart();
- for (size_t i = 0; i < s->aliases.dim; i++)
+ for (size_t i = 0; i < s->aliases.length; i++)
{
Identifier *name = s->names[i];
Identifier *alias = s->aliases[i];
// import foo : target1;
propertyStart("selective");
arrayStart();
- for (size_t i = 0; i < s->names.dim; i++)
+ for (size_t i = 0; i < s->names.length; i++)
{
Identifier *name = s->names[i];
if (!s->aliases[i]) item(name->toChars());
if (ds)
{
- for (size_t i = 0; i < ds->dim; i++)
+ for (size_t i = 0; i < ds->length; i++)
{
Dsymbol *s = (*ds)[i];
s->accept(this);
{
propertyStart("members");
arrayStart();
- for (size_t i = 0; i < d->members->dim; i++)
+ for (size_t i = 0; i < d->members->length; i++)
{
Dsymbol *s = (*d->members)[i];
s->accept(this);
property("endline", "endchar", &d->endloc);
- if (d->foverrides.dim)
+ if (d->foverrides.length)
{
propertyStart("overrides");
arrayStart();
- for (size_t i = 0; i < d->foverrides.dim; i++)
+ for (size_t i = 0; i < d->foverrides.length; i++)
{
FuncDeclaration *fd = d->foverrides[i];
item(fd->toPrettyChars());
propertyStart("parameters");
arrayStart();
- for (size_t i = 0; i < d->parameters->dim; i++)
+ for (size_t i = 0; i < d->parameters->length; i++)
{
TemplateParameter *s = (*d->parameters)[i];
objectStart();
propertyStart("members");
arrayStart();
- for (size_t i = 0; i < d->members->dim; i++)
+ for (size_t i = 0; i < d->members->length; i++)
{
Dsymbol *s = (*d->members)[i];
s->accept(this);
{
if (d->members)
{
- for (size_t i = 0; i < d->members->dim; i++)
+ for (size_t i = 0; i < d->members->length; i++)
{
Dsymbol *s = (*d->members)[i];
s->accept(this);
{
propertyStart("members");
arrayStart();
- for (size_t i = 0; i < d->members->dim; i++)
+ for (size_t i = 0; i < d->members->length; i++)
{
Dsymbol *s = (*d->members)[i];
s->accept(this);
ToJsonVisitor json(buf);
json.arrayStart();
- for (size_t i = 0; i < modules->dim; i++)
+ for (size_t i = 0; i < modules->length; i++)
{
Module *m = (*modules)[i];
if (global.params.verbose)
static Parameters *stripParams(Parameters *parameters)
{
Parameters *params = parameters;
- if (params && params->dim > 0)
+ if (params && params->length > 0)
{
- for (size_t i = 0; i < params->dim; i++)
+ for (size_t i = 0; i < params->length; i++)
{
Parameter *p = (*params)[i];
Type *ta = stripDefaultArgs(p->type);
if (params == parameters)
{
params = new Parameters();
- params->setDim(parameters->dim);
- for (size_t j = 0; j < params->dim; j++)
+ params->setDim(parameters->length);
+ for (size_t j = 0; j < params->length; j++)
(*params)[j] = (*parameters)[j];
}
(*params)[i] = new Parameter(p->storageClass, ta, NULL, NULL);
Parameters *params = parameters;
if (mod & MODwild)
params = parameters->copy();
- for (size_t i = 0; i < params->dim; i++)
+ for (size_t i = 0; i < params->length; i++)
{
Parameter *p = (*params)[i];
Type *t = p->type->substWildTo(m);
dim = dim->ctfeInterpret();
uinteger_t d = dim->toUInteger();
- if (d >= td->objects->dim)
+ if (d >= td->objects->length)
{
- error(loc, "tuple index %llu exceeds length %u", d, td->objects->dim);
+ error(loc, "tuple index %llu exceeds length %u", d, td->objects->length);
*ps = NULL;
*pt = Type::terror;
return;
dim = dim->ctfeInterpret();
uinteger_t d = dim->toUInteger();
- if (d >= sd->objects->dim)
- { error(loc, "tuple index %llu exceeds %u", d, sd->objects->dim);
+ if (d >= sd->objects->length)
+ { error(loc, "tuple index %llu exceeds %u", d, sd->objects->length);
return Type::terror;
}
RootObject *o = (*sd->objects)[(size_t)d];
TypeTuple *tt = (TypeTuple *)tbn;
uinteger_t d = dim->toUInteger();
- if (d >= tt->arguments->dim)
- { error(loc, "tuple index %llu exceeds %u", d, tt->arguments->dim);
+ if (d >= tt->arguments->length)
+ { error(loc, "tuple index %llu exceeds %u", d, tt->arguments->length);
goto Lerror;
}
Type *telem = (*tt->arguments)[(size_t)d]->type;
if (!fhash) fhash = search_function(ClassDeclaration::object, Id::tohash)->isFuncDeclaration();
assert(fcmp && feq && fhash);
- if (feq->vtblIndex < (int)cd->vtbl.dim && cd->vtbl[feq ->vtblIndex] == feq)
+ if (feq->vtblIndex < (int)cd->vtbl.length && cd->vtbl[feq ->vtblIndex] == feq)
{
- if (fcmp->vtblIndex < (int)cd->vtbl.dim && cd->vtbl[fcmp->vtblIndex] != fcmp)
+ if (fcmp->vtblIndex < (int)cd->vtbl.length && cd->vtbl[fcmp->vtblIndex] != fcmp)
{
const char *s = (index->toBasetype()->ty != Tclass) ? "bottom of " : "";
error(loc, "%sAA key type %s now requires equality rather than comparison",
}
else if (t1->parameters != t2->parameters)
{
- size_t dim1 = !t1->parameters ? 0 : t1->parameters->dim;
- size_t dim2 = !t2->parameters ? 0 : t2->parameters->dim;
+ size_t dim1 = !t1->parameters ? 0 : t1->parameters->length;
+ size_t dim2 = !t2->parameters ? 0 : t2->parameters->length;
if (dim1 || dim2)
goto Ldistinct;
}
if (parameters)
{
tf->parameters = parameters->copy();
- for (size_t i = 0; i < parameters->dim; i++)
+ for (size_t i = 0; i < parameters->length; i++)
{
void *pp = mem.xmalloc(sizeof(Parameter));
Parameter *p = (Parameter *)memcpy(pp, (void *)(*parameters)[i], sizeof(Parameter));
* sharing of Parameter object among other functions.
*/
TypeTuple *tt = (TypeTuple *)t;
- if (tt->arguments && tt->arguments->dim)
+ if (tt->arguments && tt->arguments->length)
{
/* Propagate additional storage class from tuple parameters to their
* element-parameters.
* Make a copy, as original may be referenced elsewhere.
*/
- size_t tdim = tt->arguments->dim;
+ size_t tdim = tt->arguments->length;
Parameters *newparams = new Parameters();
newparams->setDim(tdim);
for (size_t j = 0; j < tdim; j++)
*/
if (fparam->storageClass & STCauto)
{
- if (fargs && i < fargs->dim && (fparam->storageClass & STCref))
+ if (fargs && i < fargs->length && (fparam->storageClass & STCref))
{
Expression *farg = (*fargs)[i];
if (farg->isLvalue())
}
size_t nparams = Parameter::dim(parameters);
- size_t nargs = args ? args->dim : 0;
+ size_t nargs = args ? args->length : 0;
if (nparams == nargs)
;
else if (nargs > nparams)
{
TupleExp *te = e->toTupleExp();
Objects *elems = new Objects;
- elems->setDim(te->exps->dim);
- for (size_t i = 0; i < elems->dim; i++)
+ elems->setDim(te->exps->length);
+ for (size_t i = 0; i < elems->length; i++)
{
Expression *src = (*te->exps)[i];
switch (src->op)
void TypeQualified::syntaxCopyHelper(TypeQualified *t)
{
//printf("TypeQualified::syntaxCopyHelper(%s) %s\n", t->toChars(), toChars());
- idents.setDim(t->idents.dim);
- for (size_t i = 0; i < idents.dim; i++)
+ idents.setDim(t->idents.length);
+ for (size_t i = 0; i < idents.length; i++)
{
RootObject *id = t->idents[i];
if (id->dyncast() == DYNCAST_DSYMBOL)
}
const uinteger_t d = eindex->toUInteger();
- if (d >= td->objects->dim)
+ if (d >= td->objects->length)
{
- ::error(loc, "tuple index %llu exceeds length %u", (ulonglong)d, (unsigned)td->objects->dim);
+ ::error(loc, "tuple index %llu exceeds length %u", (ulonglong)d, (unsigned)td->objects->length);
*pt = Type::terror;
return;
}
s = s->toAlias();
//printf("\t2: s = '%s' %p, kind = '%s'\n",s->toChars(), s, s->kind());
- for (size_t i = 0; i < idents.dim; i++)
+ for (size_t i = 0; i < idents.length; i++)
{
RootObject *id = idents[i];
Type *TypeInstance::syntaxCopy()
{
- //printf("TypeInstance::syntaxCopy() %s, %d\n", toChars(), idents.dim);
+ //printf("TypeInstance::syntaxCopy() %s, %d\n", toChars(), idents.length);
TypeInstance *t = new TypeInstance(loc, (TemplateInstance *)tempinst->syntaxCopy(NULL));
t->syntaxCopyHelper(this);
t->mod = mod;
goto Lerr;
}
}
- if (idents.dim == 0)
+ if (idents.length == 0)
*pt = t;
else
{
goto Lerr;
}
}
- if (idents.dim == 0)
+ if (idents.length == 0)
*pt = t;
else
{
ev = extractSideEffect(sc, "__tup", &e0, ev);
Expressions *exps = new Expressions;
- exps->reserve(sym->fields.dim);
- for (size_t i = 0; i < sym->fields.dim; i++)
+ exps->reserve(sym->fields.length);
+ for (size_t i = 0; i < sym->fields.length; i++)
{
VarDeclaration *v = sym->fields[i];
Expression *ex;
if (sym->sizeok != SIZEOKdone)
return new ErrorExp();
Expressions *structelems = new Expressions();
- structelems->setDim(sym->fields.dim - sym->isNested());
+ structelems->setDim(sym->fields.length - sym->isNested());
unsigned offset = 0;
- for (size_t j = 0; j < structelems->dim; j++)
+ for (size_t j = 0; j < structelems->length; j++)
{
VarDeclaration *vd = sym->fields[j];
Expression *e;
if (sym->isNested())
return true;
- for (size_t i = 0; i < sym->fields.dim; i++)
+ for (size_t i = 0; i < sym->fields.length; i++)
{
VarDeclaration *v = sym->fields[i];
if (!v->isDataseg() && v->type->needsNested())
/* If any of the fields are const or immutable,
* then one cannot assign this struct.
*/
- for (size_t i = 0; i < sym->fields.dim; i++)
+ for (size_t i = 0; i < sym->fields.length; i++)
{
VarDeclaration *v = sym->fields[i];
//printf("%s [%d] v = (%s) %s, v->offset = %d, v->parent = %s", sym->toChars(), i, v->kind(), v->toChars(), v->offset, v->parent->kind());
StructDeclaration *s = sym;
sym->size(Loc()); // give error for forward references
- for (size_t i = 0; i < s->fields.dim; i++)
+ for (size_t i = 0; i < s->fields.length; i++)
{
Declaration *d = s->fields[i];
if (d->storage_class & STCref || d->hasPointers())
StructDeclaration *s = sym;
sym->size(Loc()); // give error for forward references
- for (size_t i = 0; i < s->fields.dim; i++)
+ for (size_t i = 0; i < s->fields.length; i++)
{
VarDeclaration *v = s->fields[i];
if (v->_init && v->_init->isVoidInitializer() && v->type->hasPointers())
* allow the conversion.
*/
unsigned offset = ~0; // dead-store to prevent spurious warning
- for (size_t i = 0; i < sym->fields.dim; i++)
+ for (size_t i = 0; i < sym->fields.length; i++)
{
VarDeclaration *v = sym->fields[i];
if (i == 0)
ev = extractSideEffect(sc, "__tup", &e0, ev);
Expressions *exps = new Expressions;
- exps->reserve(sym->fields.dim);
- for (size_t i = 0; i < sym->fields.dim; i++)
+ exps->reserve(sym->fields.length);
+ for (size_t i = 0; i < sym->fields.length; i++)
{
VarDeclaration *v = sym->fields[i];
// Don't include hidden 'this' pointer
Parameters *arguments = new Parameters;
if (exps)
{
- arguments->setDim(exps->dim);
- for (size_t i = 0; i < exps->dim; i++)
+ arguments->setDim(exps->length);
+ for (size_t i = 0; i < exps->length; i++)
{ Expression *e = (*exps)[i];
if (e->type->ty == Ttuple)
e->error("cannot form tuple of tuples");
if (t->ty == Ttuple)
{
TypeTuple *tt = (TypeTuple *)t;
- if (arguments->dim == tt->arguments->dim)
+ if (arguments->length == tt->arguments->length)
{
- for (size_t i = 0; i < tt->arguments->dim; i++)
+ for (size_t i = 0; i < tt->arguments->length; i++)
{
Parameter *arg1 = (*arguments)[i];
Parameter *arg2 = (*tt->arguments)[i];
if (ident == Id::length)
{
- e = new IntegerExp(loc, arguments->dim, Type::tsize_t);
+ e = new IntegerExp(loc, arguments->length, Type::tsize_t);
}
else if (ident == Id::_init)
{
Expression *TypeTuple::defaultInit(Loc loc)
{
Expressions *exps = new Expressions();
- exps->setDim(arguments->dim);
- for (size_t i = 0; i < arguments->dim; i++)
+ exps->setDim(arguments->length);
+ for (size_t i = 0; i < arguments->length; i++)
{
Parameter *p = (*arguments)[i];
assert(p->type);
upr = upr->ctfeInterpret();
uinteger_t i2 = upr->toUInteger();
- if (!(i1 <= i2 && i2 <= tt->arguments->dim))
+ if (!(i1 <= i2 && i2 <= tt->arguments->length))
{
- error(loc, "slice [%llu..%llu] is out of range of [0..%u]", i1, i2, tt->arguments->dim);
+ error(loc, "slice [%llu..%llu] is out of range of [0..%u]", i1, i2, tt->arguments->length);
return Type::terror;
}
uinteger_t i1 = lwr->toUInteger();
uinteger_t i2 = upr->toUInteger();
- if (!(i1 <= i2 && i2 <= td->objects->dim))
+ if (!(i1 <= i2 && i2 <= td->objects->length))
{
- error(loc, "slice [%llu..%llu] is out of range of [0..%u]", i1, i2, td->objects->dim);
+ error(loc, "slice [%llu..%llu] is out of range of [0..%u]", i1, i2, td->objects->length);
*ps = NULL;
*pt = Type::terror;
return;
}
- if (i1 == 0 && i2 == td->objects->dim)
+ if (i1 == 0 && i2 == td->objects->length)
{
*ps = td;
return;
*/
Objects *objects = new Objects;
objects->setDim((size_t)(i2 - i1));
- for (size_t i = 0; i < objects->dim; i++)
+ for (size_t i = 0; i < objects->length; i++)
{
(*objects)[i] = (*td->objects)[(size_t)i1 + i];
}
if (parameters)
{
params = new Parameters();
- params->setDim(parameters->dim);
- for (size_t i = 0; i < params->dim; i++)
+ params->setDim(parameters->length);
+ for (size_t i = 0; i < params->length; i++)
(*params)[i] = (*parameters)[i]->syntaxCopy();
}
return params;
size_t n = pn ? *pn : 0; // take over index
int result = 0;
- for (size_t i = 0; i < parameters->dim; i++)
+ for (size_t i = 0; i < parameters->length; i++)
{
Parameter *p = (*parameters)[i];
Type *t = p->type->toBasetype();
#include "root/root.h"
#include "root/stringtable.h"
-#include "root/rmem.h" // for d_size_t
+#include "root/dcompat.h" // for d_size_t
#include "arraytypes.h"
#include "expression.h"
void visit(ArrayLiteralExp *e)
{
- if (e->type->ty != Tarray || !e->elements || !e->elements->dim)
+ if (e->type->ty != Tarray || !e->elements || !e->elements->length)
return;
if (f->setGC())
void visit(AssocArrayLiteralExp *e)
{
- if (!e->keys->dim)
+ if (!e->keys->length)
return;
if (f->setGC())
sc = sc->push(this);
sc->linkage = LINKcpp; // namespaces default to C++ linkage
sc->parent = this;
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{
Dsymbol *s = (*members)[i];
//printf("add %s to scope %s\n", s->toChars(), toChars());
sc = sc->push(this);
sc->linkage = LINKcpp; // namespaces default to C++ linkage
sc->parent = this;
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{
Dsymbol *s = (*members)[i];
s->setScope(sc);
sc->linkage = LINKcpp; // note that namespaces imply C++ linkage
sc->parent = this;
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{
Dsymbol *s = (*members)[i];
s->importAll(sc);
}
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{
Dsymbol *s = (*members)[i];
s->semantic(sc);
assert(sc);
sc = sc->push(this);
sc->linkage = LINKcpp;
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{
Dsymbol *s = (*members)[i];
s->semantic2(sc);
{
sc = sc->push(this);
sc->linkage = LINKcpp;
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{
Dsymbol *s = (*members)[i];
s->semantic3(sc);
{
if (members)
{
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{
Dsymbol *s = (*members)[i];
if (s)
if (members)
{
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{
Dsymbol *s = (*members)[i];
//printf(" s = %s %s\n", s->kind(), s->toChars());
semantic(NULL); // try to resolve it
if (members)
{
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{
Dsymbol *s = (*members)[i];
//printf("\t%s\n", s->toChars());
Expression *ae1old = ae->e1;
const bool maybeSlice =
- (ae->arguments->dim == 0 ||
- (ae->arguments->dim == 1 && (*ae->arguments)[0]->op == TOKinterval));
+ (ae->arguments->length == 0 ||
+ (ae->arguments->length == 1 && (*ae->arguments)[0]->op == TOKinterval));
IntervalExp *ie = NULL;
- if (maybeSlice && ae->arguments->dim)
+ if (maybeSlice && ae->arguments->length)
{
assert((*ae->arguments)[0]->op == TOKinterval);
ie = (IntervalExp *)(*ae->arguments)[0];
Expression *ae1old = ae->e1;
const bool maybeSlice =
- (ae->arguments->dim == 0 ||
- (ae->arguments->dim == 1 && (*ae->arguments)[0]->op == TOKinterval));
+ (ae->arguments->length == 0 ||
+ (ae->arguments->length == 1 && (*ae->arguments)[0]->op == TOKinterval));
IntervalExp *ie = NULL;
- if (maybeSlice && ae->arguments->dim)
+ if (maybeSlice && ae->arguments->length)
{
assert((*ae->arguments)[0]->op == TOKinterval);
ie = (IntervalExp *)(*ae->arguments)[0];
return;
}
// Convert to IndexExp
- if (ae->arguments->dim == 1)
+ if (ae->arguments->length == 1)
{
result = new IndexExp(ae->loc, ae->e1, (*ae->arguments)[0]);
result = semantic(result, sc);
{
TupleExp *tup1 = (TupleExp *)e->e1;
TupleExp *tup2 = (TupleExp *)e->e2;
- size_t dim = tup1->exps->dim;
- if (dim != tup2->exps->dim)
+ size_t dim = tup1->exps->length;
+ if (dim != tup2->exps->length)
{
e->error("mismatched tuple lengths, %d and %d",
- (int)dim, (int)tup2->exps->dim);
+ (int)dim, (int)tup2->exps->length);
result = new ErrorExp();
return;
}
Expression *ae1old = ae->e1;
const bool maybeSlice =
- (ae->arguments->dim == 0 ||
- (ae->arguments->dim == 1 && (*ae->arguments)[0]->op == TOKinterval));
+ (ae->arguments->length == 0 ||
+ (ae->arguments->length == 1 && (*ae->arguments)[0]->op == TOKinterval));
IntervalExp *ie = NULL;
- if (maybeSlice && ae->arguments->dim)
+ if (maybeSlice && ae->arguments->length)
{
assert((*ae->arguments)[0]->op == TOKinterval);
ie = (IntervalExp *)(*ae->arguments)[0];
bool inferApplyArgTypes(ForeachStatement *fes, Scope *sc, Dsymbol *&sapply)
{
- if (!fes->parameters || !fes->parameters->dim)
+ if (!fes->parameters || !fes->parameters->length)
return false;
if (sapply) // prefer opApply
{
- for (size_t u = 0; u < fes->parameters->dim; u++)
+ for (size_t u = 0; u < fes->parameters->length; u++)
{
Parameter *p = (*fes->parameters)[u];
if (p->type)
/* Return if no parameters need types.
*/
- for (size_t u = 0; u < fes->parameters->dim; u++)
+ for (size_t u = 0; u < fes->parameters->length; u++)
{
Parameter *p = (*fes->parameters)[u];
if (!p->type)
case Tarray:
case Tsarray:
case Ttuple:
- if (fes->parameters->dim == 2)
+ if (fes->parameters->length == 2)
{
if (!p->type)
{
{
TypeAArray *taa = (TypeAArray *)tab;
- if (fes->parameters->dim == 2)
+ if (fes->parameters->length == 2)
{
if (!p->type)
{
goto Laggr;
Laggr:
- if (fes->parameters->dim == 1)
+ if (fes->parameters->length == 1)
{
if (!p->type)
{
nparams = Parameter::dim(tf->parameters);
if (nparams == 0 || tf->varargs)
goto Lnomatch; // not enough parameters
- if (parameters->dim != nparams)
+ if (parameters->length != nparams)
goto Lnomatch; // not enough parameters
for (size_t u = 0; u < nparams; u++)
void visit(TupleExp *e)
{
expOptimize(e->e0, WANTvalue);
- for (size_t i = 0; i < e->exps->dim; i++)
+ for (size_t i = 0; i < e->exps->length; i++)
{
expOptimize((*e->exps)[i], WANTvalue);
}
if (e->elements)
{
expOptimize(e->basis, result & WANTexpand);
- for (size_t i = 0; i < e->elements->dim; i++)
+ for (size_t i = 0; i < e->elements->length; i++)
{
expOptimize((*e->elements)[i], result & WANTexpand);
}
void visit(AssocArrayLiteralExp *e)
{
- assert(e->keys->dim == e->values->dim);
- for (size_t i = 0; i < e->keys->dim; i++)
+ assert(e->keys->length == e->values->length);
+ for (size_t i = 0; i < e->keys->length; i++)
{
expOptimize((*e->keys)[i], result & WANTexpand);
expOptimize((*e->values)[i], result & WANTexpand);
e->stageflags |= stageOptimize;
if (e->elements)
{
- for (size_t i = 0; i < e->elements->dim; i++)
+ for (size_t i = 0; i < e->elements->length; i++)
{
expOptimize((*e->elements)[i], result & WANTexpand);
}
// Optimize parameters
if (e->newargs)
{
- for (size_t i = 0; i < e->newargs->dim; i++)
+ for (size_t i = 0; i < e->newargs->length; i++)
{
expOptimize((*e->newargs)[i], WANTvalue);
}
if (e->arguments)
{
- for (size_t i = 0; i < e->arguments->dim; i++)
+ for (size_t i = 0; i < e->arguments->length; i++)
{
expOptimize((*e->arguments)[i], WANTvalue);
}
if (t1->ty == Tdelegate) t1 = t1->nextOf();
assert(t1->ty == Tfunction);
TypeFunction *tf = (TypeFunction *)t1;
- for (size_t i = 0; i < e->arguments->dim; i++)
+ for (size_t i = 0; i < e->arguments->length; i++)
{
Parameter *p = Parameter::getNth(tf->parameters, i);
bool keep = p && (p->storageClass & (STCref | STCout)) != 0;
if (arr->op == TOKstring)
len = ((StringExp *)arr)->len;
else if (arr->op == TOKarrayliteral)
- len = ((ArrayLiteralExp *)arr)->elements->dim;
+ len = ((ArrayLiteralExp *)arr)->elements->length;
else
{
Type *t = arr->type->toBasetype();
case TOKtraits:
Ldeclaration:
a = parseDeclarations(false, pAttrs, pAttrs->comment);
- if (a && a->dim)
- *pLastDecl = (*a)[a->dim-1];
+ if (a && a->length)
+ *pLastDecl = (*a)[a->length-1];
break;
case TOKthis:
{
a = parseAutoDeclarations(pAttrs->storageClass, pAttrs->comment);
pAttrs->storageClass = STCundefined;
- if (a && a->dim)
- *pLastDecl = (*a)[a->dim-1];
+ if (a && a->length)
+ *pLastDecl = (*a)[a->length-1];
if (pAttrs->udas)
{
s = new UserAttributeDeclaration(pAttrs->udas, a);
)
{
a = parseDeclarations(true, pAttrs, pAttrs->comment);
- if (a && a->dim)
- *pLastDecl = (*a)[a->dim-1];
+ if (a && a->length)
+ *pLastDecl = (*a)[a->length-1];
if (pAttrs->udas)
{
s = new UserAttributeDeclaration(pAttrs->udas, a);
if (idents)
{
assert(link == LINKcpp);
- assert(idents->dim);
- for (size_t i = idents->dim; i;)
+ assert(idents->length);
+ for (size_t i = idents->length; i;)
{
Identifier *id = (*idents)[--i];
if (s)
decldefs->push(s);
addComment(s, pAttrs->comment);
}
- else if (a && a->dim)
+ else if (a && a->length)
{
decldefs->append(a);
}
break;
}
}
- assert(dimStack.dim > 0);
+ assert(dimStack.length > 0);
// We're good. Replay indices in the reverse order.
tid = (TypeQualified *)t;
- while (dimStack.dim)
+ while (dimStack.length)
{
tid->addIndex(dimStack.pop());
}
check(TOKsemicolon);
Expression *aggr = parseExpression();
- if (token.value == TOKslice && parameters->dim == 1)
+ if (token.value == TOKslice && parameters->length == 1)
{
Parameter *p = (*parameters)[0];
delete parameters;
Ldeclaration:
{
Dsymbols *a = parseDeclarations(false, NULL, NULL);
- if (a->dim > 1)
+ if (a->length > 1)
{
Statements *as = new Statements();
- as->reserve(a->dim);
- for (size_t i = 0; i < a->dim; i++)
+ as->reserve(a->length);
+ for (size_t i = 0; i < a->length; i++)
{
Dsymbol *d = (*a)[i];
s = new ExpStatement(loc, d);
}
s = new CompoundDeclarationStatement(loc, as);
}
- else if (a->dim == 1)
+ else if (a->length == 1)
{
Dsymbol *d = (*a)[0];
s = new ExpStatement(loc, d);
*/
if (token.value == TOKslice)
{
- if (cases.dim > 1)
+ if (cases.length > 1)
error("only one case allowed for start of case range");
nextToken();
check(TOKcase);
else
{
// Keep cases in order by building the case statements backwards
- for (size_t i = cases.dim; i; i--)
+ for (size_t i = cases.length; i; i--)
{
exp = cases[i - 1];
s = new CaseStatement(loc, exp, s);
while (token.value != TOKrbracket && token.value != TOKeof)
{
e = parseAssignExp();
- if (token.value == TOKcolon && (keys || values->dim == 0))
+ if (token.value == TOKcolon && (keys || values->length == 0))
{ nextToken();
if (!keys)
keys = new Expressions();
#pragma once
#include "dsystem.h"
+#include "dcompat.h"
#include "object.h"
#include "rmem.h"
template <typename TYPE>
struct Array
{
- d_size_t dim;
- TYPE *data;
+ d_size_t length;
private:
- Array(const Array&);
-
- d_size_t allocdim;
+ DArray<TYPE> data;
#define SMALLARRAYCAP 1
TYPE smallarray[SMALLARRAYCAP]; // inline storage for small arrays
+ Array(const Array&);
+
public:
Array()
{
- data = SMALLARRAYCAP ? &smallarray[0] : NULL;
- dim = 0;
- allocdim = SMALLARRAYCAP;
+ data.ptr = SMALLARRAYCAP ? &smallarray[0] : NULL;
+ length = 0;
+ data.length = SMALLARRAYCAP;
}
~Array()
{
- if (data != &smallarray[0])
- mem.xfree(data);
+ if (data.ptr != &smallarray[0])
+ mem.xfree(data.ptr);
}
- char *toChars()
+ char *toChars() const
{
- const char **buf = (const char **)mem.xmalloc(dim * sizeof(const char *));
+ const char **buf = (const char **)mem.xmalloc(length * sizeof(const char *));
d_size_t len = 2;
- for (d_size_t u = 0; u < dim; u++)
+ for (d_size_t u = 0; u < length; u++)
{
- buf[u] = ((RootObject *)data[u])->toChars();
+ buf[u] = ((RootObject *)data.ptr[u])->toChars();
len += strlen(buf[u]) + 1;
}
char *str = (char *)mem.xmalloc(len);
str[0] = '[';
char *p = str + 1;
- for (d_size_t u = 0; u < dim; u++)
+ for (d_size_t u = 0; u < length; u++)
{
if (u)
*p++ = ',';
return str;
}
+ void push(TYPE ptr)
+ {
+ reserve(1);
+ data.ptr[length++] = ptr;
+ }
+
+ void append(Array *a)
+ {
+ insert(length, a);
+ }
+
void reserve(d_size_t nentries)
{
- //printf("Array::reserve: dim = %d, allocdim = %d, nentries = %d\n", (int)dim, (int)allocdim, (int)nentries);
- if (allocdim - dim < nentries)
+ //printf("Array::reserve: length = %d, data.length = %d, nentries = %d\n", (int)length, (int)data.length, (int)nentries);
+ if (data.length - length < nentries)
{
- if (allocdim == 0)
- { // Not properly initialized, someone memset it to zero
+ if (data.length == 0)
+ {
+ // Not properly initialized, someone memset it to zero
if (nentries <= SMALLARRAYCAP)
- { allocdim = SMALLARRAYCAP;
- data = SMALLARRAYCAP ? &smallarray[0] : NULL;
+ {
+ data.length = SMALLARRAYCAP;
+ data.ptr = SMALLARRAYCAP ? &smallarray[0] : NULL;
}
else
- { allocdim = nentries;
- data = (TYPE *)mem.xmalloc(allocdim * sizeof(*data));
+ {
+ data.length = nentries;
+ data.ptr = (TYPE *)mem.xmalloc(data.length * sizeof(TYPE));
}
}
- else if (allocdim == SMALLARRAYCAP)
+ else if (data.length == SMALLARRAYCAP)
{
- allocdim = dim + nentries;
- data = (TYPE *)mem.xmalloc(allocdim * sizeof(*data));
- memcpy(data, &smallarray[0], dim * sizeof(*data));
+ data.length = length + nentries;
+ data.ptr = (TYPE *)mem.xmalloc(data.length * sizeof(TYPE));
+ memcpy(data.ptr, &smallarray[0], length * sizeof(TYPE));
}
else
{
/* Increase size by 1.5x to avoid excessive memory fragmentation
*/
- d_size_t increment = dim / 2;
+ d_size_t increment = length / 2;
if (nentries > increment) // if 1.5 is not enough
increment = nentries;
- allocdim = dim + increment;
- data = (TYPE *)mem.xrealloc(data, allocdim * sizeof(*data));
+ data.length = length + increment;
+ data.ptr = (TYPE *)mem.xrealloc(data.ptr, data.length * sizeof(TYPE));
}
}
}
- void setDim(d_size_t newdim)
+ void remove(d_size_t i)
{
- if (dim < newdim)
- {
- reserve(newdim - dim);
- }
- dim = newdim;
+ if (length - i - 1)
+ memmove(data.ptr + i, data.ptr + i + 1, (length - i - 1) * sizeof(TYPE));
+ length--;
}
- TYPE pop()
+ void insert(d_size_t index, Array *a)
{
- return data[--dim];
+ if (a)
+ {
+ d_size_t d = a->length;
+ reserve(d);
+ if (length != index)
+ memmove(data.ptr + index + d, data.ptr + index, (length - index) * sizeof(TYPE));
+ memcpy(data.ptr + index, a->data.ptr, d * sizeof(TYPE));
+ length += d;
+ }
}
- void shift(TYPE ptr)
+ void insert(d_size_t index, TYPE ptr)
{
reserve(1);
- memmove(data + 1, data, dim * sizeof(*data));
- data[0] = ptr;
- dim++;
- }
-
- void remove(d_size_t i)
- {
- if (dim - i - 1)
- memmove(data + i, data + i + 1, (dim - i - 1) * sizeof(data[0]));
- dim--;
+ memmove(data.ptr + index + 1, data.ptr + index, (length - index) * sizeof(TYPE));
+ data.ptr[index] = ptr;
+ length++;
}
- void zero()
+ void setDim(d_size_t newdim)
{
- memset(data,0,dim * sizeof(data[0]));
+ if (length < newdim)
+ {
+ reserve(newdim - length);
+ }
+ length = newdim;
}
- void sort()
+ d_size_t find(TYPE ptr) const
{
- struct ArraySort
- {
- static int
- #if _WIN32
- __cdecl
- #endif
- Array_sort_compare(const void *x, const void *y)
- {
- RootObject *ox = *(RootObject **)const_cast<void *>(x);
- RootObject *oy = *(RootObject **)const_cast<void *>(y);
-
- return ox->compare(oy);
- }
- };
-
- if (dim)
+ for (d_size_t i = 0; i < length; i++)
{
- qsort(data, dim, sizeof(RootObject *), &ArraySort::Array_sort_compare);
+ if (data.ptr[i] == ptr)
+ return i;
}
+ return SIZE_MAX;
}
- TYPE *tdata()
+ bool contains(TYPE ptr) const
{
- return data;
+ return find(ptr) != SIZE_MAX;
}
TYPE& operator[] (d_size_t index)
{
- return data[index];
+#ifdef DEBUG
+ assert(index < length);
+#endif
+ return data.ptr[index];
}
- void insert(d_size_t index, TYPE v)
+ TYPE *tdata()
{
- reserve(1);
- memmove(data + index + 1, data + index, (dim - index) * sizeof(*data));
- data[index] = v;
- dim++;
+ return data.ptr;
}
- void insert(d_size_t index, Array *a)
+ Array *copy()
{
- if (a)
- {
- d_size_t d = a->dim;
- reserve(d);
- if (dim != index)
- memmove(data + index + d, data + index, (dim - index) * sizeof(*data));
- memcpy(data + index, a->data, d * sizeof(*data));
- dim += d;
- }
+ Array *a = new Array();
+ a->setDim(length);
+ memcpy(a->data.ptr, data.ptr, length * sizeof(TYPE));
+ return a;
}
- void append(Array *a)
+ void shift(TYPE ptr)
{
- insert(dim, a);
+ reserve(1);
+ memmove(data.ptr + 1, data.ptr, length * sizeof(TYPE));
+ data.ptr[0] = ptr;
+ length++;
}
- void push(TYPE a)
+ void zero()
{
- reserve(1);
- data[dim++] = a;
+ memset(data.ptr, 0, length * sizeof(TYPE));
}
- Array *copy()
+ TYPE pop()
{
- Array *a = new Array();
- a->setDim(dim);
- memcpy(a->data, data, dim * sizeof(*data));
- return a;
+ return data.ptr[--length];
}
-};
-
-struct BitArray
-{
- BitArray()
- : len(0)
- , ptr(NULL)
- {}
- ~BitArray()
+ void sort()
{
- mem.xfree(ptr);
- }
+ struct ArraySort
+ {
+ static int
+ #if _WIN32
+ __cdecl
+ #endif
+ Array_sort_compare(const void *x, const void *y)
+ {
+ RootObject *ox = *(RootObject **)const_cast<void *>(x);
+ RootObject *oy = *(RootObject **)const_cast<void *>(y);
- d_size_t len;
- d_size_t *ptr;
+ return ox->compare(oy);
+ }
+ };
-private:
- BitArray(const BitArray&);
+ if (length)
+ {
+ qsort(data.ptr, length, sizeof(RootObject *), &ArraySort::Array_sort_compare);
+ }
+ }
};
+
--- /dev/null
+/* Copyright (C) 2011-2020 by The D Language Foundation, All Rights Reserved
+ * written by Walter Bright
+ * http://www.digitalmars.com
+ * Distributed under the Boost Software License, Version 1.0.
+ * http://www.boost.org/LICENSE_1_0.txt
+ * https://github.com/dlang/dmd/blob/master/src/dmd/root/bitarray.h
+ */
+
+#pragma once
+
+#include "dsystem.h"
+#include "object.h"
+#include "rmem.h"
+
+struct BitArray
+{
+ BitArray()
+ : len(0)
+ , ptr(NULL)
+ {}
+
+ ~BitArray()
+ {
+ mem.xfree(ptr);
+ }
+
+ d_size_t len;
+ d_size_t *ptr;
+
+private:
+ BitArray(const BitArray&);
+};
size_t length;
T *ptr;
};
+
+/// Corresponding C++ type that maps to D size_t
+#if __APPLE__ && __i386__
+// size_t is 'unsigned long', which makes it mangle differently than D's 'uint'
+typedef unsigned d_size_t;
+#elif MARS && DMD_VERSION >= 2079 && DMD_VERSION <= 2081 && \
+ __APPLE__ && __SIZEOF_SIZE_T__ == 8
+// DMD versions between 2.079 and 2.081 mapped D ulong to uint64_t on OS X.
+typedef uint64_t d_size_t;
+#else
+typedef size_t d_size_t;
+#endif
if (path)
{
- for (size_t i = 0; i < path->dim; i++)
+ for (size_t i = 0; i < path->length; i++)
{
const char *p = (*path)[i];
const char *n = combine(p, name);
/* Each path is converted to a cannonical name and then a check is done to see
* that the searched name is really a child one of the the paths searched.
*/
- for (size_t i = 0; i < path->dim; i++)
+ for (size_t i = 0; i < path->length; i++)
{
const char *cname = NULL;
const char *cpath = canonicalName((*path)[i]);
#pragma once
-#include "dsystem.h" // for size_t
-
-#if __APPLE__ && __i386__
- /* size_t is 'unsigned long', which makes it mangle differently
- * than D's 'uint'
- */
- typedef unsigned d_size_t;
-#else
- typedef size_t d_size_t;
-#endif
+#include "dcompat.h" // for d_size_t
struct Mem
{
#pragma once
#include "root.h"
-#include "rmem.h" // for d_size_t
+#include "dcompat.h" // for d_size_t
struct StringEntry;
}
void visit(CompoundStatement *s)
{
- for (size_t i = 0; i < s->statements->dim; i++)
+ for (size_t i = 0; i < s->statements->length; i++)
if (doCond((*s->statements)[i]))
return;
applyTo(s);
}
void visit(UnrolledLoopStatement *s)
{
- for (size_t i = 0; i < s->statements->dim; i++)
+ for (size_t i = 0; i < s->statements->length; i++)
if (doCond((*s->statements)[i]))
return;
applyTo(s);
if (doCond(s->_body))
return;
- for (size_t i = 0; i < s->catches->dim; i++)
+ for (size_t i = 0; i < s->catches->length; i++)
if (doCond((*s->catches)[i]->handler))
return;
applyTo(s);
return NULL;
Statements *statements = new Statements();
- for (size_t i = 0; i < a->dim; i++)
+ for (size_t i = 0; i < a->length; i++)
{
statements->push(toStatement((*a)[i]));
}
void visit(TemplateMixin *tm)
{
Statements *a = new Statements();
- for (size_t i = 0; i < tm->members->dim; i++)
+ for (size_t i = 0; i < tm->members->length; i++)
{
Statement *s = toStatement((*tm->members)[i]);
if (s)
Statement *CompoundStatement::syntaxCopy()
{
Statements *a = new Statements();
- a->setDim(statements->dim);
- for (size_t i = 0; i < statements->dim; i++)
+ a->setDim(statements->length);
+ for (size_t i = 0; i < statements->length; i++)
{
Statement *s = (*statements)[i];
(*a)[i] = s ? s->syntaxCopy() : NULL;
{
ReturnStatement *rs = NULL;
- for (size_t i = 0; i < statements->dim; i++)
+ for (size_t i = 0; i < statements->length; i++)
{
Statement *s = (*statements)[i];
if (s)
{
Statement *s = NULL;
- for (size_t i = statements->dim; i; --i)
+ for (size_t i = statements->length; i; --i)
{ s = (*statements)[i - 1];
if (s)
{
Statement *CompoundDeclarationStatement::syntaxCopy()
{
Statements *a = new Statements();
- a->setDim(statements->dim);
- for (size_t i = 0; i < statements->dim; i++)
+ a->setDim(statements->length);
+ for (size_t i = 0; i < statements->length; i++)
{
Statement *s = (*statements)[i];
(*a)[i] = s ? s->syntaxCopy() : NULL;
Statement *UnrolledLoopStatement::syntaxCopy()
{
Statements *a = new Statements();
- a->setDim(statements->dim);
- for (size_t i = 0; i < statements->dim; i++)
+ a->setDim(statements->length);
+ for (size_t i = 0; i < statements->length; i++)
{
Statement *s = (*statements)[i];
(*a)[i] = s ? s->syntaxCopy() : NULL;
return a;
}
Statements *b = new Statements();
- b->setDim(a->dim);
- for (size_t i = 0; i < a->dim; i++)
+ b->setDim(a->length);
+ for (size_t i = 0; i < a->length; i++)
{
Statement *s = (*a)[i];
(*b)[i] = s ? new ForwardingStatement(s->loc, sym, s) : NULL;
{
bool result = false;
- for (size_t i = 0; i < parameters->dim; i++)
+ for (size_t i = 0; i < parameters->length; i++)
{
Parameter *p = (*parameters)[i];
if (!p->type)
if (sdefault && checkVar(this, sdefault->lastVar))
return !error; // return error once fully deprecated
- for (size_t i = 0; i < cases->dim; i++)
+ for (size_t i = 0; i < cases->length; i++)
{
CaseStatement *scase = (*cases)[i];
if (scase && checkVar(this, scase->lastVar))
Statement *TryCatchStatement::syntaxCopy()
{
Catches *a = new Catches();
- a->setDim(catches->dim);
- for (size_t i = 0; i < a->dim; i++)
+ a->setDim(catches->length);
+ for (size_t i = 0; i < a->length; i++)
{
Catch *c = (*catches)[i];
(*a)[i] = c->syntaxCopy();
Statements *a = statement ? statement->flatten(sc) : NULL;
if (a)
{
- for (size_t i = 0; i < a->dim; i++)
+ for (size_t i = 0; i < a->length; i++)
{ Statement *s = (*a)[i];
s = new DebugStatement(loc, s);
a = statement->flatten(sc);
if (a)
{
- if (!a->dim)
+ if (!a->length)
{
a->push(new ExpStatement(loc, (Expression *)NULL));
}
CompoundAsmStatement *CompoundAsmStatement::syntaxCopy()
{
Statements *a = new Statements();
- a->setDim(statements->dim);
- for (size_t i = 0; i < statements->dim; i++)
+ a->setDim(statements->length);
+ for (size_t i = 0; i < statements->length; i++)
{
Statement *s = (*statements)[i];
(*a)[i] = s ? s->syntaxCopy() : NULL;
Statement *ImportStatement::syntaxCopy()
{
Dsymbols *m = new Dsymbols();
- m->setDim(imports->dim);
- for (size_t i = 0; i < imports->dim; i++)
+ m->setDim(imports->length);
+ for (size_t i = 0; i < imports->length; i++)
{
Dsymbol *s = (*imports)[i];
(*m)[i] = s->syntaxCopy(NULL);
void visit(CompoundStatement *cs)
{
//printf("CompoundStatement::semantic(this = %p, sc = %p)\n", cs, sc);
- for (size_t i = 0; i < cs->statements->dim; )
+ for (size_t i = 0; i < cs->statements->length; )
{
Statement *s = (*cs->statements)[i];
if (s)
sexception = semantic(sexception, sc);
if (sexception)
{
- if (i + 1 == cs->statements->dim && !sfinally)
+ if (i + 1 == cs->statements->length && !sfinally)
{
}
else
* { sexception; throw __o; }
*/
Statements *a = new Statements();
- for (size_t j = i + 1; j < cs->statements->dim; j++)
+ for (size_t j = i + 1; j < cs->statements->length; j++)
{
a->push((*cs->statements)[j]);
}
}
else if (sfinally)
{
- if (0 && i + 1 == cs->statements->dim)
+ if (0 && i + 1 == cs->statements->length)
{
cs->statements->push(sfinally);
}
* s; try { s1; s2; } finally { sfinally; }
*/
Statements *a = new Statements();
- for (size_t j = i + 1; j < cs->statements->dim; j++)
+ for (size_t j = i + 1; j < cs->statements->length; j++)
{
a->push((*cs->statements)[j]);
}
}
i++;
}
- for (size_t i = 0; i < cs->statements->dim; ++i)
+ for (size_t i = 0; i < cs->statements->length; ++i)
{
Lagain:
Statement *s = (*cs->statements)[i];
{
cs->statements->remove(i);
cs->statements->insert(i, flt);
- if (cs->statements->dim <= i)
+ if (cs->statements->length <= i)
break;
goto Lagain;
}
}
- if (cs->statements->dim == 1)
+ if (cs->statements->length == 1)
{
result = (*cs->statements)[0];
return;
scd->scontinue = uls;
Statement *serror = NULL;
- for (size_t i = 0; i < uls->statements->dim; i++)
+ for (size_t i = 0; i < uls->statements->length; i++)
{
Statement *s = (*uls->statements)[i];
if (s)
Statements *stmts = (isDecl) ? NULL : new Statements();
Dsymbols *decls = (isDecl) ? new Dsymbols() : NULL;
- size_t dim = fs->parameters->dim;
+ size_t dim = fs->parameters->length;
if (!needExpansion && dim == 2)
{
// Declare key
Statements *statements, Dsymbols *declarations, Dsymbols *dbody)
{
Loc loc = fs->loc;
- size_t dim = fs->parameters->dim;
+ size_t dim = fs->parameters->length;
if (!needExpansion && (dim < 1 || dim > 2))
{
fs->error("only one (value) or two (key,value) arguments for tuple foreach");
if (fs->aggr->op == TOKtuple) // expression tuple
{
te = (TupleExp *)fs->aggr;
- n = te->exps->dim;
+ n = te->exps->length;
}
else if (fs->aggr->op == TOKtype) // type tuple
{
ScopeDsymbol *sym;
Statement *s = fs;
Loc loc = fs->loc;
- size_t dim = fs->parameters->dim;
+ size_t dim = fs->parameters->length;
TypeAArray *taa = NULL;
Dsymbol *sapply = NULL;
}
}
- //printf("dim = %d, parameters->dim = %d\n", dim, fs->parameters->dim);
+ //printf("dim = %d, parameters->length = %d\n", dim, fs->parameters->length);
if (foundMismatch && dim != foreachParamCount)
{
const char *plural = foreachParamCount > 1 ? "s" : "";
!((*fs->parameters)[dim - 1]->storageClass & STCref))
{
ArrayLiteralExp *ale = (ArrayLiteralExp *)fs->aggr;
- size_t edim = ale->elements ? ale->elements->dim : 0;
+ size_t edim = ale->elements ? ale->elements->length : 0;
Type *telem = (*fs->parameters)[dim - 1]->type;
// Bugzilla 12936: if telem has been specified explicitly,
Expressions *exps = new Expressions();
exps->push(ve);
int pos = 0;
- while (exps->dim < dim)
+ while (exps->length < dim)
{
pos = expandAliasThisTuples(exps, pos);
if (pos == -1)
break;
}
- if (exps->dim != dim)
+ if (exps->length != dim)
{
- const char *plural = exps->dim > 1 ? "s" : "";
+ const char *plural = exps->length > 1 ? "s" : "";
fs->error("cannot infer argument types, expected %d argument%s, not %d",
- exps->dim, plural, dim);
+ exps->length, plural, dim);
goto Lerror2;
}
tfld = (TypeFunction *)tab->nextOf();
Lget:
//printf("tfld = %s\n", tfld->toChars());
- if (tfld->parameters->dim == 1)
+ if (tfld->parameters->length == 1)
{
Parameter *p = Parameter::getNth(tfld->parameters, 0);
if (p->type && p->type->ty == Tdelegate)
fld->tookAddressOf = 0;
// Resolve any forward referenced goto's
- for (size_t i = 0; i < fs->gotos->dim; i++)
+ for (size_t i = 0; i < fs->gotos->length; i++)
{
GotoStatement *gs = (GotoStatement *)(*fs->gotos)[i]->statement;
if (!gs->label->statement)
{
// 'Promote' it to this scope, and replace with a return
fs->cases->push(gs);
- s = new ReturnStatement(Loc(), new IntegerExp(fs->cases->dim + 1));
+ s = new ReturnStatement(Loc(), new IntegerExp(fs->cases->length + 1));
(*fs->gotos)[i]->statement = s;
}
}
}
e = Expression::combine(e, ec);
- if (!fs->cases->dim)
+ if (!fs->cases->length)
{
// Easy case, a clean exit from the loop
e = new CastExp(loc, e, Type::tvoid); // Bugzilla 13899
a->push(s);
// cases 2...
- for (size_t i = 0; i < fs->cases->dim; i++)
+ for (size_t i = 0; i < fs->cases->length; i++)
{
s = (*fs->cases)[i];
s = new CaseStatement(Loc(), new IntegerExp(i + 2), s);
{
if (ps->args)
{
- for (size_t i = 0; i < ps->args->dim; i++)
+ for (size_t i = 0; i < ps->args->length; i++)
{
Expression *e = (*ps->args)[i];
}
else if (ps->ident == Id::startaddress)
{
- if (!ps->args || ps->args->dim != 1)
+ if (!ps->args || ps->args->length != 1)
ps->error("function name expected for start address");
else
{
else if (ps->ident == Id::Pinline)
{
PINLINE inlining = PINLINEdefault;
- if (!ps->args || ps->args->dim == 0)
+ if (!ps->args || ps->args->length == 0)
inlining = PINLINEdefault;
- else if (!ps->args || ps->args->dim != 1)
+ else if (!ps->args || ps->args->length != 1)
{
ps->error("boolean expression expected for pragma(inline)");
goto Lerror;
goto Lerror;
// Resolve any goto case's with exp
- for (size_t i = 0; i < ss->gotoCases.dim; i++)
+ for (size_t i = 0; i < ss->gotoCases.length; i++)
{
GotoCaseStatement *gcs = ss->gotoCases[i];
{
if (!scx->sw)
continue;
- for (size_t j = 0; j < scx->sw->cases->dim; j++)
+ for (size_t j = 0; j < scx->sw->cases->length; j++)
{
CaseStatement *cs = (*scx->sw->cases)[j];
ed = ds->isEnumDeclaration();
if (ed)
{
- size_t dim = ed->members->dim;
+ size_t dim = ed->members->length;
for (size_t i = 0; i < dim; i++)
{
EnumMember *em = (*ed->members)[i]->isEnumMember();
if (em)
{
- for (size_t j = 0; j < ss->cases->dim; j++)
+ for (size_t j = 0; j < ss->cases->length; j++)
{
CaseStatement *cs = (*ss->cases)[j];
if (cs->exp->equals(em->value()) ||
}
L1:
- for (size_t i = 0; i < sw->cases->dim; i++)
+ for (size_t i = 0; i < sw->cases->length; i++)
{
CaseStatement *cs2 = (*sw->cases)[i];
sw->cases->push(cs);
// Resolve any goto case's with no exp to this case statement
- for (size_t i = 0; i < sw->gotoCases.dim; )
+ for (size_t i = 0; i < sw->gotoCases.length; )
{
GotoCaseStatement *gcs = sw->gotoCases[i];
{
assert(rs->caseDim == 0);
sc->fes->cases->push(rs);
- result = new ReturnStatement(Loc(), new IntegerExp(sc->fes->cases->dim + 1));
+ result = new ReturnStatement(Loc(), new IntegerExp(sc->fes->cases->length + 1));
return;
}
if (fd->returnLabel)
sc->fes->cases->push(s);
// Immediately rewrite "this" return statement as:
- // return cases->dim+1;
- rs->exp = new IntegerExp(sc->fes->cases->dim + 1);
+ // return cases->length+1;
+ rs->exp = new IntegerExp(sc->fes->cases->length + 1);
if (e0)
{
result = new CompoundStatement(rs->loc, new ExpStatement(rs->loc, e0), rs);
// return exp;
// to:
// vresult = exp; retrun caseDim;
- rs->caseDim = sc->fes->cases->dim + 1;
+ rs->caseDim = sc->fes->cases->length + 1;
}
}
if (rs->exp)
* and 1 is break.
*/
sc->fes->cases->push(bs);
- result = new ReturnStatement(Loc(), new IntegerExp(sc->fes->cases->dim + 1));
+ result = new ReturnStatement(Loc(), new IntegerExp(sc->fes->cases->length + 1));
return;
}
break; // can't break to it
* and 1 is break.
*/
sc->fes->cases->push(cs);
- result = new ReturnStatement(Loc(), new IntegerExp(sc->fes->cases->dim + 1));
+ result = new ReturnStatement(Loc(), new IntegerExp(sc->fes->cases->length + 1));
return;
}
break; // can't continue to it
/* Even if body is empty, still do semantic analysis on catches
*/
bool catchErrors = false;
- for (size_t i = 0; i < tcs->catches->dim; i++)
+ for (size_t i = 0; i < tcs->catches->length; i++)
{
Catch *c = (*tcs->catches)[i];
semantic(c, sc);
if (!(blockExit(tcs->_body, sc->func, false) & BEthrow) && ClassDeclaration::exception)
{
- for (size_t i = 0; i < tcs->catches->dim; i++)
+ for (size_t i = 0; i < tcs->catches->length; i++)
{
Catch *c = (*tcs->catches)[i];
}
}
- if (tcs->catches->dim == 0)
+ if (tcs->catches->length == 0)
{
result = tcs->_body->hasCode() ? tcs->_body : NULL;
return;
sc = sc->push();
sc->stc |= cas->stc;
- for (size_t i = 0; i < cas->statements->dim; i++)
+ for (size_t i = 0; i < cas->statements->length; i++)
{
Statement *s = (*cas->statements)[i];
(*cas->statements)[i] = s ? semantic(s, sc) : NULL;
void visit(ImportStatement *imps)
{
- for (size_t i = 0; i < imps->imports->dim; i++)
+ for (size_t i = 0; i < imps->imports->length; i++)
{
Import *s = (*imps->imports)[i]->isImport();
- assert(!s->aliasdecls.dim);
- for (size_t j = 0; j < s->names.dim; j++)
+ assert(!s->aliasdecls.length);
+ for (size_t j = 0; j < s->names.length; j++)
{
Identifier *name = s->names[j];
Identifier *alias = s->aliases[j];
Module::addDeferredSemantic2(s); // Bugzilla 14666
sc->insert(s);
- for (size_t j = 0; j < s->aliasdecls.dim; j++)
+ for (size_t j = 0; j < s->aliasdecls.length; j++)
{
sc->insert(s->aliasdecls[j]);
}
{
if (!symbols)
return;
- for (size_t i = 0; i < symbols->dim; i++)
+ for (size_t i = 0; i < symbols->length; i++)
{
Dsymbol *symbol = (*symbols)[i];
UnitTestDeclaration *unitTest = symbol->isUnitTestDeclaration();
Expression *isTypeX(TraitsExp *e, bool (*fp)(Type *t))
{
- if (!e->args || !e->args->dim)
+ if (!e->args || !e->args->length)
return False(e);
- for (size_t i = 0; i < e->args->dim; i++)
+ for (size_t i = 0; i < e->args->length; i++)
{
Type *t = getType((*e->args)[i]);
if (!t || !fp(t))
Expression *isFuncX(TraitsExp *e, bool (*fp)(FuncDeclaration *f))
{
- if (!e->args || !e->args->dim)
+ if (!e->args || !e->args->length)
return False(e);
- for (size_t i = 0; i < e->args->dim; i++)
+ for (size_t i = 0; i < e->args->length; i++)
{
Dsymbol *s = getDsymbol((*e->args)[i]);
if (!s)
Expression *isDeclX(TraitsExp *e, bool (*fp)(Declaration *d))
{
- if (!e->args || !e->args->dim)
+ if (!e->args || !e->args->length)
return False(e);
- for (size_t i = 0; i < e->args->dim; i++)
+ for (size_t i = 0; i < e->args->length; i++)
{
Dsymbol *s = getDsymbol((*e->args)[i]);
if (!s)
Expression *isSymbolX(TraitsExp *e, bool (*fp)(Dsymbol *s))
{
- if (!e->args || !e->args->dim)
+ if (!e->args || !e->args->length)
return False(e);
- for (size_t i = 0; i < e->args->dim; i++)
+ for (size_t i = 0; i < e->args->length; i++)
{
Dsymbol *s = getDsymbol((*e->args)[i]);
if (!s || !fp(s))
*/
Expression *pointerBitmap(TraitsExp *e)
{
- if (!e->args || e->args->dim != 1)
+ if (!e->args || e->args->length != 1)
{
error(e->loc, "a single type expected for trait pointerBitmap");
return new ErrorExp();
virtual void visit(TypeStruct *t)
{
d_uns64 structoff = offset;
- for (size_t i = 0; i < t->sym->fields.dim; i++)
+ for (size_t i = 0; i < t->sym->fields.length; i++)
{
VarDeclaration *v = t->sym->fields[i];
offset = structoff + v->offset;
if (t->sym->baseClass)
visitClass((TypeClass*)t->sym->baseClass->type);
- for (size_t i = 0; i < t->sym->fields.dim; i++)
+ for (size_t i = 0; i < t->sym->fields.length; i++)
{
VarDeclaration *v = t->sym->fields[i];
offset = classoff + v->offset;
if (!TemplateInstance::semanticTiargs(e->loc, sc, e->args, 1))
return new ErrorExp();
}
- size_t dim = e->args ? e->args->dim : 0;
+ size_t dim = e->args ? e->args->length : 0;
if (e->ident == Id::isArithmetic)
{
/* Skip if already present in idents[]
*/
- for (size_t j = 0; j < idents->dim; j++)
+ for (size_t j = 0; j < idents->length; j++)
{
Identifier *id = (*idents)[j];
if (id == sm->ident)
{
static void dg(ClassDeclaration *cd, PushIdentsDg *ctx)
{
- for (size_t i = 0; i < cd->baseclasses->dim; i++)
+ for (size_t i = 0; i < cd->baseclasses->length; i++)
{
ClassDeclaration *cb = (*cd->baseclasses)[i]->sym;
assert(cb);
ScopeDsymbol_foreach(NULL, cb->members, &PushIdentsDg::dg, ctx);
- if (cb->baseclasses->dim)
+ if (cb->baseclasses->length)
dg(cb, ctx);
}
}
// Turn Identifiers into StringExps reusing the allocated array
assert(sizeof(Expressions) == sizeof(Identifiers));
Expressions *exps = (Expressions *)idents;
- for (size_t i = 0; i < idents->dim; i++)
+ for (size_t i = 0; i < idents->length; i++)
{
Identifier *id = (*idents)[i];
StringExp *se = new StringExp(e->loc, const_cast<char *>(id->toChars()));
Expression *typeToExpressionHelper(TypeQualified *t, Expression *e, size_t i)
{
//printf("toExpressionHelper(e = %s %s)\n", Token::toChars(e->op), e->toChars());
- for (; i < t->idents.dim; i++)
+ for (; i < t->idents.length; i++)
{
RootObject *id = t->idents[i];
//printf("\t[%d] e: '%s', id: '%s'\n", i, e->toChars(), id->toChars());
{
StructDeclaration *sd = ((TypeStruct *) tnext)->sym;
- for (size_t i = 0; i < sd->fields.dim; i++)
+ for (size_t i = 0; i < sd->fields.length; i++)
{
VarDeclaration *field = sd->fields[i];
{
/* If we have a user supplied initializer, then set-up with a
struct literal. */
- if (e->arguments != NULL && sd->fields.dim != 0)
+ if (e->arguments != NULL && sd->fields.length != 0)
{
StructLiteralExp *se = StructLiteralExp::create (e->loc, sd,
e->arguments,
TypeDArray *tarray = (TypeDArray *) tb;
gcc_assert (!e->allocator);
- gcc_assert (e->arguments && e->arguments->dim >= 1);
+ gcc_assert (e->arguments && e->arguments->length >= 1);
- if (e->arguments->dim == 1)
+ if (e->arguments->length == 1)
{
/* Single dimension array allocations. */
Expression *arg = (*e->arguments)[0];
else
{
/* Multidimensional array allocations. */
- tree tarray = make_array_type (Type::tsize_t, e->arguments->dim);
+ tree tarray = make_array_type (Type::tsize_t, e->arguments->length);
tree var = build_local_temp (tarray);
vec<constructor_elt, va_gc> *elms = NULL;
/* Get the base element type for the array, generating the
initializer for the dims parameter along the way. */
Type *telem = e->newtype->toBasetype ();
- for (size_t i = 0; i < e->arguments->dim; i++)
+ for (size_t i = 0; i < e->arguments->length; i++)
{
Expression *arg = (*e->arguments)[i];
CONSTRUCTOR_APPEND_ELT (elms, size_int (i), build_expr (arg));
tree tinfo = build_typeinfo (e->loc, e->type);
tree dims = d_array_value (build_ctype (Type::tsize_t->arrayOf ()),
- size_int (e->arguments->dim),
+ size_int (e->arguments->length),
build_address (var));
result = build_libcall (libcall, tb, 2, tinfo, dims);
tree arg = build_typeinfo (e->loc, e->newtype);
result = build_libcall (libcall, tb, 1, arg);
- if (e->arguments && e->arguments->dim == 1)
+ if (e->arguments && e->arguments->length == 1)
{
result = d_save_expr (result);
tree init = modify_expr (build_deref (result),
if (e->e0)
result = build_expr (e->e0);
- for (size_t i = 0; i < e->exps->dim; ++i)
+ for (size_t i = 0; i < e->exps->length; ++i)
{
Expression *exp = (*e->exps)[i];
result = compound_expr (result, build_expr (exp));
gcc_assert (tb->ty == Tarray || tb->ty == Tsarray || tb->ty == Tpointer);
/* Handle empty array literals. */
- if (e->elements->dim == 0)
+ if (e->elements->length == 0)
{
if (tb->ty == Tarray)
this->result_ = d_array_value (build_ctype (e->type),
/* Build an expression that assigns the expressions in ELEMENTS to
a constructor. */
vec<constructor_elt, va_gc> *elms = NULL;
- vec_safe_reserve (elms, e->elements->dim);
+ vec_safe_reserve (elms, e->elements->length);
bool constant_p = true;
tree saved_elems = NULL_TREE;
Type *etype = tb->nextOf ();
- tree satype = make_array_type (etype, e->elements->dim);
+ tree satype = make_array_type (etype, e->elements->length);
- for (size_t i = 0; i < e->elements->dim; i++)
+ for (size_t i = 0; i < e->elements->length; i++)
{
Expression *expr = e->getElement (i);
tree value = build_expr (expr, this->constp_);
tree decl = build_artificial_decl (TREE_TYPE (ctor), ctor, "A");
ctor = build_address (decl);
if (tb->ty == Tarray)
- ctor = d_array_value (type, size_int (e->elements->dim), ctor);
+ ctor = d_array_value (type, size_int (e->elements->length), ctor);
d_pushdecl (decl);
rest_of_decl_compilation (decl, 1, 0);
tree mem = build_libcall (LIBCALL_ARRAYLITERALTX,
etype->pointerTo (), 2,
build_typeinfo (e->loc, etype->arrayOf ()),
- size_int (e->elements->dim));
+ size_int (e->elements->length));
mem = d_save_expr (mem);
/* Now copy the constructor into memory. */
tree tmemcpy = builtin_decl_explicit (BUILT_IN_MEMCPY);
- tree size = size_mult_expr (size_int (e->elements->dim),
+ tree size = size_mult_expr (size_int (e->elements->length),
size_int (tb->nextOf ()->size ()));
tree result = build_call_expr (tmemcpy, 3, mem,
result = compound_expr (result, mem);
if (tb->ty == Tarray)
- result = d_array_value (type, size_int (e->elements->dim), result);
+ result = d_array_value (type, size_int (e->elements->length), result);
this->result_ = compound_expr (saved_elems, result);
}
/* Handle empty assoc array literals. */
TypeAArray *ta = (TypeAArray *) tb;
- if (e->keys->dim == 0)
+ if (e->keys->length == 0)
{
this->result_ = build_constructor (build_ctype (ta), NULL);
return;
/* Build an expression that assigns all expressions in KEYS
to a constructor. */
vec<constructor_elt, va_gc> *kelts = NULL;
- vec_safe_reserve (kelts, e->keys->dim);
- for (size_t i = 0; i < e->keys->dim; i++)
+ vec_safe_reserve (kelts, e->keys->length);
+ for (size_t i = 0; i < e->keys->length; i++)
{
Expression *key = (*e->keys)[i];
tree t = build_expr (key);
CONSTRUCTOR_APPEND_ELT (kelts, size_int (i),
convert_expr (t, key->type, ta->index));
}
- tree tkeys = make_array_type (ta->index, e->keys->dim);
+ tree tkeys = make_array_type (ta->index, e->keys->length);
tree akeys = build_constructor (tkeys, kelts);
/* Do the same with all expressions in VALUES. */
vec<constructor_elt, va_gc> *velts = NULL;
- vec_safe_reserve (velts, e->values->dim);
- for (size_t i = 0; i < e->values->dim; i++)
+ vec_safe_reserve (velts, e->values->length);
+ for (size_t i = 0; i < e->values->length; i++)
{
Expression *value = (*e->values)[i];
tree t = build_expr (value);
CONSTRUCTOR_APPEND_ELT (velts, size_int (i),
convert_expr (t, value->type, ta->next));
}
- tree tvals = make_array_type (ta->next, e->values->dim);
+ tree tvals = make_array_type (ta->next, e->values->length);
tree avals = build_constructor (tvals, velts);
/* Generate: _d_assocarrayliteralTX (ti, keys, vals); */
tree keys = d_array_value (build_ctype (ta->index->arrayOf ()),
- size_int (e->keys->dim), build_address (akeys));
+ size_int (e->keys->length), build_address (akeys));
tree vals = d_array_value (build_ctype (ta->next->arrayOf ()),
- size_int (e->values->dim),
+ size_int (e->values->length),
build_address (avals));
tree mem = build_libcall (LIBCALL_ASSOCARRAYLITERALTX, Type::tvoidptr, 3,
void visit (StructLiteralExp *e)
{
/* Handle empty struct literals. */
- if (e->elements == NULL || e->sd->fields.dim == 0)
+ if (e->elements == NULL || e->sd->fields.length == 0)
{
this->result_ = build_constructor (build_ctype (e->type), NULL);
return;
tree saved_elems = NULL_TREE;
/* CTFE may fill the hidden pointer by NullExp. */
- gcc_assert (e->elements->dim <= e->sd->fields.dim);
+ gcc_assert (e->elements->length <= e->sd->fields.length);
Type *tb = e->type->toBasetype ();
gcc_assert (tb->ty == Tstruct);
- for (size_t i = 0; i < e->elements->dim; i++)
+ for (size_t i = 0; i < e->elements->length; i++)
{
Expression *exp = (*e->elements)[i];
if (!exp)
}
/* Maybe setup hidden pointer to outer scope context. */
- if (e->sd->isNested () && e->elements->dim != e->sd->fields.dim
+ if (e->sd->isNested () && e->elements->length != e->sd->fields.length
&& this->constp_ == false)
{
tree field = get_symbol_decl (e->sd->vthis);
vec<constructor_elt, va_gc> *elms = NULL;
bool constant_p = true;
- vec_safe_reserve (elms, ale->elements->dim);
- for (size_t i = 0; i < ale->elements->dim; i++)
+ vec_safe_reserve (elms, ale->elements->length);
+ for (size_t i = 0; i < ale->elements->length; i++)
{
Expression *expr = ale->getElement (i);
tree value = d_convert (etype, build_expr (expr, this->constp_));
/* Array of module imports is laid out as a length field, followed by
a static array of ModuleInfo pointers. */
- size_t aimports_dim = decl->aimports.dim;
- for (size_t i = 0; i < decl->aimports.dim; i++)
+ size_t aimports_dim = decl->aimports.length;
+ for (size_t i = 0; i < decl->aimports.length; i++)
{
Module *mi = decl->aimports[i];
if (!mi->needmoduleinfo)
/* Array of local ClassInfo decls are laid out in the same way. */
ClassDeclarations aclasses;
- for (size_t i = 0; i < decl->members->dim; i++)
+ for (size_t i = 0; i < decl->members->length; i++)
{
Dsymbol *member = (*decl->members)[i];
member->addLocalClass (&aclasses);
}
- if (aclasses.dim)
+ if (aclasses.length)
{
layout_moduleinfo_field (size_type_node, type, offset);
- layout_moduleinfo_field (make_array_type (Type::tvoidptr, aclasses.dim),
+ layout_moduleinfo_field (make_array_type (Type::tvoidptr,
+ aclasses.length),
type, offset);
}
ClassDeclarations aclasses;
FuncDeclaration *sgetmembers;
- for (size_t i = 0; i < decl->members->dim; i++)
+ for (size_t i = 0; i < decl->members->length; i++)
{
Dsymbol *member = (*decl->members)[i];
member->addLocalClass (&aclasses);
}
- size_t aimports_dim = decl->aimports.dim;
- for (size_t i = 0; i < decl->aimports.dim; i++)
+ size_t aimports_dim = decl->aimports.length;
+ for (size_t i = 0; i < decl->aimports.length; i++)
{
Module *mi = decl->aimports[i];
if (!mi->needmoduleinfo)
flags |= MIunitTest;
if (aimports_dim)
flags |= MIimportedModules;
- if (aclasses.dim)
+ if (aclasses.length)
flags |= MIlocalClasses;
if (!decl->needmoduleinfo)
flags |= MIstandalone;
tree satype = make_array_type (Type::tvoidptr, aimports_dim);
size_t idx = 0;
- for (size_t i = 0; i < decl->aimports.dim; i++)
+ for (size_t i = 0; i < decl->aimports.length; i++)
{
Module *mi = decl->aimports[i];
if (mi->needmoduleinfo)
if (flags & MIlocalClasses)
{
vec<constructor_elt, va_gc> *elms = NULL;
- tree satype = make_array_type (Type::tvoidptr, aclasses.dim);
+ tree satype = make_array_type (Type::tvoidptr, aclasses.length);
- for (size_t i = 0; i < aclasses.dim; i++)
+ for (size_t i = 0; i < aclasses.length; i++)
{
ClassDeclaration *cd = aclasses[i];
CONSTRUCTOR_APPEND_ELT (elms, size_int (i),
build_address (get_classinfo_decl (cd)));
}
- CONSTRUCTOR_APPEND_ELT (minit, NULL_TREE, size_int (aclasses.dim));
+ CONSTRUCTOR_APPEND_ELT (minit, NULL_TREE, size_int (aclasses.length));
CONSTRUCTOR_APPEND_ELT (minit, NULL_TREE,
build_constructor (satype, elms));
}
/* Layout module members. */
if (decl->members)
{
- for (size_t i = 0; i < decl->members->dim; i++)
+ for (size_t i = 0; i < decl->members->length; i++)
{
Dsymbol *s = (*decl->members)[i];
build_decl_tree (s);
/* Apparently the backend is supposed to sort and set the indexes
on the case array, have to change them to be usable. */
- Type *satype = condtype->sarrayOf (s->cases->dim);
+ Type *satype = condtype->sarrayOf (s->cases->length);
vec<constructor_elt, va_gc> *elms = NULL;
s->cases->sort ();
- for (size_t i = 0; i < s->cases->dim; i++)
+ for (size_t i = 0; i < s->cases->length; i++)
{
CaseStatement *cs = (*s->cases)[i];
cs->index = i;
/* Pass it as a dynamic array. */
decl = d_array_value (build_ctype (condtype->arrayOf ()),
- size_int (s->cases->dim),
+ size_int (s->cases->length),
build_address (decl));
condition = build_libcall (libcall, Type::tint32, 2, decl, condition);
Also checking the jump from the switch to the label is allowed. */
if (s->cases)
{
- for (size_t i = 0; i < s->cases->dim; i++)
+ for (size_t i = 0; i < s->cases->length; i++)
{
CaseStatement *cs = (*s->cases)[i];
tree caselabel = this->lookup_label (cs);
if (s->statements == NULL)
return;
- for (size_t i = 0; i < s->statements->dim; i++)
+ for (size_t i = 0; i < s->statements->length; i++)
{
Statement *statement = (*s->statements)[i];
tree lbreak = this->push_break_label (s);
this->start_scope (level_loop);
- for (size_t i = 0; i < s->statements->dim; i++)
+ for (size_t i = 0; i < s->statements->length; i++)
{
Statement *statement = (*s->statements)[i];
if (s->catches)
{
- for (size_t i = 0; i < s->catches->dim; i++)
+ for (size_t i = 0; i < s->catches->length; i++)
{
Catch *vcatch = (*s->catches)[i];
/* Collect all arguments, which may be input or output operands. */
if (s->args)
{
- for (size_t i = 0; i < s->args->dim; i++)
+ for (size_t i = 0; i < s->args->length; i++)
{
Identifier *name = (*s->names)[i];
const char *sname = name ? name->toChars () : NULL;
/* Collect all clobber arguments. */
if (s->clobbers)
{
- for (size_t i = 0; i < s->clobbers->dim; i++)
+ for (size_t i = 0; i < s->clobbers->length; i++)
{
StringExp *clobber = (StringExp *)(*s->clobbers)[i];
const char *cstring = (const char *)(clobber->len
by the front-end, so pass down the label symbol to the back-end. */
if (s->labels)
{
- for (size_t i = 0; i < s->labels->dim; i++)
+ for (size_t i = 0; i < s->labels->length; i++)
{
Identifier *ident = (*s->labels)[i];
GotoStatement *gs = (*s->gotos)[i];
if (s->args)
{
unsigned noutputs = s->outputargs;
- unsigned ninputs = (s->args->dim - noutputs);
+ unsigned ninputs = (s->args->length - noutputs);
const char **oconstraints = XALLOCAVEC (const char *, noutputs);
bool allows_mem, allows_reg, is_inout;
size_t i;
if (s->imports == NULL)
return;
- for (size_t i = 0; i < s->imports->dim; i++)
+ for (size_t i = 0; i < s->imports->length; i++)
{
Dsymbol *dsym = (*s->imports)[i];
/* Put out the offset to where vtblInterfaces are written. */
tree value = d_array_value (array_type_node,
- size_int (cd->vtblInterfaces->dim),
+ size_int (cd->vtblInterfaces->length),
build_offset (csym, size_int (offset)));
this->layout_field (value);
size_t offset; */
vec<constructor_elt, va_gc> *elms = NULL;
- for (size_t i = 0; i < cd->vtblInterfaces->dim; i++)
+ for (size_t i = 0; i < cd->vtblInterfaces->length; i++)
{
BaseClass *b = (*cd->vtblInterfaces)[i];
ClassDeclaration *id = b->sym;
gcc_assert (voffset != 0u);
value = build_offset (csym, size_int (voffset));
- CONSTRUCTOR_APPEND_ELT (v, size_int (1), size_int (id->vtbl.dim));
+ CONSTRUCTOR_APPEND_ELT (v, size_int (1), size_int (id->vtbl.length));
CONSTRUCTOR_APPEND_ELT (v, size_int (2), value);
}
CONSTRUCTOR_APPEND_ELT (elms, size_int (i), value);
}
- tree domain = size_int (cd->vtblInterfaces->dim - 1);
+ tree domain = size_int (cd->vtblInterfaces->length - 1);
tree arrtype = build_array_type (vtbl_interface_type_node,
build_index_type (domain));
return build_constructor (arrtype, elms);
vec<constructor_elt, va_gc> *elms = NULL;
FuncDeclarations bvtbl;
- if (id->vtbl.dim == 0 || base_vtable_offset (cd, bs) == ~0u)
+ if (id->vtbl.length == 0 || base_vtable_offset (cd, bs) == ~0u)
return;
/* Fill bvtbl with the functions we want to put out. */
CONSTRUCTOR_APPEND_ELT (elms, size_zero_node, value);
}
- for (size_t i = id->vtblOffset () ? 1 : 0; i < id->vtbl.dim; i++)
+ for (size_t i = id->vtblOffset () ? 1 : 0; i < id->vtbl.length; i++)
{
FuncDeclaration *fd = (cd == bcd) ? bs->vtbl[i] : bvtbl[i];
if (fd != NULL)
}
}
- tree vtbldomain = build_index_type (size_int (id->vtbl.dim - 1));
+ tree vtbldomain = build_index_type (size_int (id->vtbl.length - 1));
tree vtbltype = build_array_type (vtable_entry_type, vtbldomain);
tree value = build_constructor (vtbltype, elms);
this->layout_field (value);
this->layout_string (name);
/* The vtable of the class declaration. */
- value = d_array_value (array_type_node, size_int (cd->vtbl.dim),
+ value = d_array_value (array_type_node, size_int (cd->vtbl.length),
build_address (get_vtable_decl (cd)));
this->layout_field (value);
/* Array of base interfaces that have their own vtable. */
- if (cd->vtblInterfaces->dim)
+ if (cd->vtblInterfaces->length)
interfaces = this->layout_interfaces (cd);
else
this->layout_field (null_array_node);
if (!bcd->members)
continue;
- for (size_t i = 0; i < bcd->members->dim; i++)
+ for (size_t i = 0; i < bcd->members->length; i++)
{
Dsymbol *sm = (*bcd->members)[i];
if (sm->hasPointers ())
this->layout_field (null_array_node);
/* Array of base interfaces that have their own vtable. */
- if (cd->vtblInterfaces->dim)
+ if (cd->vtblInterfaces->length)
interfaces = this->layout_interfaces (cd);
else
this->layout_field (null_array_node);
if (!cd->isInterfaceDeclaration ())
{
/* Put out this class' interface vtables[]. */
- for (size_t i = 0; i < cd->vtblInterfaces->dim; i++)
+ for (size_t i = 0; i < cd->vtblInterfaces->length; i++)
this->layout_base_vtable (cd, cd, i);
/* Put out the overriding interface vtables[]. */
for (ClassDeclaration *bcd = cd->baseClass; bcd; bcd = bcd->baseClass)
{
- for (size_t i = 0; i < bcd->vtblInterfaces->dim; i++)
+ for (size_t i = 0; i < bcd->vtblInterfaces->length; i++)
this->layout_base_vtable (cd, bcd, i);
}
}
this->layout_base (Type::typeinfotypelist);
/* TypeInfo[] elements; */
- Type *satype = Type::tvoidptr->sarrayOf (ti->arguments->dim);
+ Type *satype = Type::tvoidptr->sarrayOf (ti->arguments->length);
vec<constructor_elt, va_gc> *elms = NULL;
- for (size_t i = 0; i < ti->arguments->dim; i++)
+ for (size_t i = 0; i < ti->arguments->length; i++)
{
Parameter *arg = (*ti->arguments)[i];
CONSTRUCTOR_APPEND_ELT (elms, size_int (i),
tree ctor = build_constructor (build_ctype (satype), elms);
tree decl = this->internal_reference (ctor);
- tree length = size_int (ti->arguments->dim);
+ tree length = size_int (ti->arguments->length);
tree ptr = build_address (decl);
this->layout_field (d_array_value (array_type_node, length, ptr));
tree type = tinfo_types[TK_CLASSINFO_TYPE];
size_t structsize = int_size_in_bytes (type);
- if (decl->vtblInterfaces->dim)
+ if (decl->vtblInterfaces->length)
{
size_t interfacesize = int_size_in_bytes (vtbl_interface_type_node);
tree field;
/* First layout the static array of Interface, which provides information
about the vtables that follow. */
- tree domain = size_int (decl->vtblInterfaces->dim - 1);
+ tree domain = size_int (decl->vtblInterfaces->length - 1);
tree arrtype = build_array_type (vtbl_interface_type_node,
build_index_type (domain));
field = create_field_decl (arrtype, NULL, 1, 1);
insert_aggregate_field (type, field, structsize);
- structsize += decl->vtblInterfaces->dim * interfacesize;
+ structsize += decl->vtblInterfaces->length * interfacesize;
/* For each interface, layout each vtable. */
- for (size_t i = 0; i < decl->vtblInterfaces->dim; i++)
+ for (size_t i = 0; i < decl->vtblInterfaces->length; i++)
{
BaseClass *b = (*decl->vtblInterfaces)[i];
ClassDeclaration *id = b->sym;
unsigned offset = base_vtable_offset (decl, b);
- if (id->vtbl.dim && offset != ~0u)
+ if (id->vtbl.length && offset != ~0u)
{
- tree vtbldomain = build_index_type (size_int (id->vtbl.dim - 1));
+ tree vtbldomain = build_index_type (size_int (id->vtbl.length - 1));
tree vtbltype = build_array_type (vtable_entry_type, vtbldomain);
field = create_field_decl (vtbltype, NULL, 1, 1);
insert_aggregate_field (type, field, offset);
- structsize += id->vtbl.dim * Target::ptrsize;
+ structsize += id->vtbl.length * Target::ptrsize;
}
}
}
/* Layout the arrays of overriding interface vtables. */
for (ClassDeclaration *bcd = decl->baseClass; bcd; bcd = bcd->baseClass)
{
- for (size_t i = 0; i < bcd->vtblInterfaces->dim; i++)
+ for (size_t i = 0; i < bcd->vtblInterfaces->length; i++)
{
BaseClass *b = (*bcd->vtblInterfaces)[i];
ClassDeclaration *id = b->sym;
unsigned offset = base_vtable_offset (decl, b);
- if (id->vtbl.dim && offset != ~0u)
+ if (id->vtbl.length && offset != ~0u)
{
if (type == tinfo_types[TK_CLASSINFO_TYPE])
type = copy_aggregate_type (type);
- tree vtbldomain = build_index_type (size_int (id->vtbl.dim - 1));
+ tree vtbldomain = build_index_type (size_int (id->vtbl.length - 1));
tree vtbltype = build_array_type (vtable_entry_type, vtbldomain);
tree field = create_field_decl (vtbltype, NULL, 1, 1);
insert_aggregate_field (type, field, offset);
- structsize += id->vtbl.dim * Target::ptrsize;
+ structsize += id->vtbl.length * Target::ptrsize;
}
}
}
if (!t->arguments)
return;
- for (size_t i = 0; i < t->arguments->dim; i++)
+ for (size_t i = 0; i < t->arguments->length; i++)
{
Type *tprm = (*t->arguments)[i]->type;
if (tprm)
{
size_t fields = 0;
- for (size_t i = 0; i < members->dim; i++)
+ for (size_t i = 0; i < members->length; i++)
{
Dsymbol *sym = (*members)[i];
VarDeclaration *var = sym->isVarDeclaration ();
Dsymbols tmembers;
/* No other way to coerce the underlying type out of the tuple.
Frontend should have already validated this. */
- for (size_t j = 0; j < td->objects->dim; j++)
+ for (size_t j = 0; j < td->objects->length; j++)
{
RootObject *ro = (*td->objects)[j];
gcc_assert (ro->dyncast () == DYNCAST_EXPRESSION);
/* Add the vtable pointer, and optionally the monitor fields. */
InterfaceDeclaration *id = cd->isInterfaceDeclaration ();
- if (!id || id->vtblInterfaces->dim == 0)
+ if (!id || id->vtblInterfaces->length == 0)
{
tree field = create_field_decl (vtbl_ptr_type_node, "__vptr", 1,
inherited_p);
if (cd->vtblInterfaces)
{
- for (size_t i = 0; i < cd->vtblInterfaces->dim; i++)
+ for (size_t i = 0; i < cd->vtblInterfaces->length; i++)
{
BaseClass *bc = (*cd->vtblInterfaces)[i];
tree field = create_field_decl (vtbl_ptr_type_node, NULL, 1, 1);
{
size_t fields = layout_aggregate_members (base->members, type,
inherited_p);
- gcc_assert (fields == base->fields.dim);
+ gcc_assert (fields == base->fields.length);
/* Make sure that all fields have been created. */
if (!inherited_p)
{
- for (size_t i = 0; i < base->fields.dim; i++)
+ for (size_t i = 0; i < base->fields.length; i++)
{
VarDeclaration *var = base->fields[i];
gcc_assert (var->csym != NULL);
tree values = NULL_TREE;
if (t->sym->members)
{
- for (size_t i = 0; i < t->sym->members->dim; i++)
+ for (size_t i = 0; i < t->sym->members->length; i++)
{
EnumMember *member = (*t->sym->members)[i]->isEnumMember ();
/* Templated functions can seep through to the back-end
}
/* Associate all virtual methods with the class too. */
- for (size_t i = 0; i < t->sym->vtbl.dim; i++)
+ for (size_t i = 0; i < t->sym->vtbl.length; i++)
{
FuncDeclaration *fd = t->sym->vtbl[i]->isFuncDeclaration ();
tree method = fd ? get_symbol_decl (fd) : error_mark_node;