From 2cbc99d18dc411ac3fdef94e22ce86859806e63c Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Thu, 4 Jun 2020 22:36:26 +0200 Subject: [PATCH] d: Merge upstream dmd 48d704f08 Updates the Array interface in dmd/root/array.h to use a DArray internally. Splits out BitArray into a separate header. Reviewed-on: https://github.com/dlang/dmd/pull/11219 gcc/d/ChangeLog: * dmd/MERGE: Merge upstream dmd 48d704f08. * d-attribs.cc (build_attributes): Use new field name. * d-builtins.cc (build_frontend_type): Likewise. (maybe_set_builtin_1): Likewise. (d_maybe_set_builtin): Likewise. * d-codegen.cc (build_interface_binfo): Likewise. (identity_compare_p): Likewise. (lower_struct_comparison): Likewise. (build_struct_comparison): Likewise. (d_build_call): Likewise. (build_frame_type): Likewise. (build_closure): Likewise. * d-compiler.cc (Compiler::paintAsType): Likewise. (Compiler::loadModule): Likewise. * d-incpath.cc (add_globalpaths): Likewise. (add_filepaths): Likewise. (add_import_paths): Likewise. * d-lang.cc (deps_write): Likewise. (d_parse_file): Likewise. * decl.cc (gcc_attribute_p): Likewise. (base_vtable_offset): Likewise. (get_vtable_decl): Likewise. (build_class_instance): Likewise. * expr.cc (class ExprVisitor): Likewise. * modules.cc (layout_moduleinfo_fields): Likewise. (layout_moduleinfo): Likewise. (build_module_tree): Likewise. * toir.cc (class IRVisitor): Likewise. * typeinfo.cc (class TypeInfoVisitor): Likewise. (layout_classinfo_interfaces): Likewise. * types.cc (layout_aggregate_members): Likewise. (layout_aggregate_type): Likewise. --- gcc/d/d-attribs.cc | 4 +- gcc/d/d-builtins.cc | 8 +- gcc/d/d-codegen.cc | 28 +-- gcc/d/d-compiler.cc | 8 +- gcc/d/d-incpath.cc | 10 +- gcc/d/d-lang.cc | 38 ++-- gcc/d/decl.cc | 44 ++-- gcc/d/dmd/MERGE | 2 +- gcc/d/dmd/access.c | 6 +- gcc/d/dmd/apply.c | 2 +- gcc/d/dmd/arrayop.c | 6 +- gcc/d/dmd/arraytypes.h | 3 +- gcc/d/dmd/attrib.c | 90 ++++---- gcc/d/dmd/blockexit.c | 8 +- gcc/d/dmd/canthrow.c | 8 +- gcc/d/dmd/clone.c | 36 +-- gcc/d/dmd/compiler.h | 1 + gcc/d/dmd/cond.c | 8 +- gcc/d/dmd/constfold.c | 56 ++--- gcc/d/dmd/cppmangle.c | 14 +- gcc/d/dmd/ctfeexpr.c | 90 ++++---- gcc/d/dmd/dcast.c | 48 ++-- gcc/d/dmd/dclass.c | 82 +++---- gcc/d/dmd/declaration.c | 62 ++---- gcc/d/dmd/denum.c | 20 +- gcc/d/dmd/dimport.c | 24 +- gcc/d/dmd/dinterpret.c | 170 +++++++-------- gcc/d/dmd/dmangle.c | 6 +- gcc/d/dmd/dmodule.c | 62 +++--- gcc/d/dmd/doc.c | 52 ++--- gcc/d/dmd/dscope.c | 8 +- gcc/d/dmd/dstruct.c | 48 ++-- gcc/d/dmd/dsymbol.c | 40 ++-- gcc/d/dmd/dtemplate.c | 410 +++++++++++++++++------------------ gcc/d/dmd/escape.c | 54 ++--- gcc/d/dmd/expression.c | 108 ++++----- gcc/d/dmd/expressionsem.c | 110 +++++----- gcc/d/dmd/func.c | 96 ++++---- gcc/d/dmd/hdrgen.c | 110 +++++----- gcc/d/dmd/iasmgcc.c | 6 +- gcc/d/dmd/init.c | 30 +-- gcc/d/dmd/initsem.c | 36 +-- gcc/d/dmd/json.c | 34 +-- gcc/d/dmd/mtype.c | 114 +++++----- gcc/d/dmd/mtype.h | 2 +- gcc/d/dmd/nogc.c | 4 +- gcc/d/dmd/nspace.c | 18 +- gcc/d/dmd/opover.c | 40 ++-- gcc/d/dmd/optimize.c | 18 +- gcc/d/dmd/parse.c | 38 ++-- gcc/d/dmd/root/array.h | 227 +++++++++---------- gcc/d/dmd/root/bitarray.h | 32 +++ gcc/d/dmd/root/dcompat.h | 12 + gcc/d/dmd/root/filename.c | 4 +- gcc/d/dmd/root/rmem.h | 11 +- gcc/d/dmd/root/stringtable.h | 2 +- gcc/d/dmd/sapply.c | 6 +- gcc/d/dmd/statement.c | 44 ++-- gcc/d/dmd/statementsem.c | 96 ++++---- gcc/d/dmd/traits.c | 34 +-- gcc/d/dmd/typesem.c | 2 +- gcc/d/expr.cc | 64 +++--- gcc/d/modules.cc | 29 +-- gcc/d/toir.cc | 24 +- gcc/d/typeinfo.cc | 56 ++--- gcc/d/types.cc | 16 +- 66 files changed, 1503 insertions(+), 1476 deletions(-) create mode 100644 gcc/d/dmd/root/bitarray.h diff --git a/gcc/d/d-attribs.cc b/gcc/d/d-attribs.cc index 69434c639e7..b83db95e2a7 100644 --- a/gcc/d/d-attribs.cc +++ b/gcc/d/d-attribs.cc @@ -245,7 +245,7 @@ build_attributes (Expressions *eattrs) 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); @@ -297,7 +297,7 @@ build_attributes (Expressions *eattrs) /* 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; diff --git a/gcc/d/d-builtins.cc b/gcc/d/d-builtins.cc index 1cb5407f8a9..c18287a2025 100644 --- a/gcc/d/d-builtins.cc +++ b/gcc/d/d-builtins.cc @@ -315,7 +315,7 @@ build_frontend_type (tree type) /* 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); @@ -669,9 +669,9 @@ maybe_set_builtin_1 (Dsymbol *d) { /* 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); @@ -708,7 +708,7 @@ d_maybe_set_builtin (Module *m) 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); diff --git a/gcc/d/d-codegen.cc b/gcc/d/d-codegen.cc index 5efd4b9c43c..2337c1dfa3d 100644 --- a/gcc/d/d-codegen.cc +++ b/gcc/d/d-codegen.cc @@ -356,7 +356,7 @@ build_class_binfo (tree super, ClassDeclaration *cd) 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. */ @@ -365,7 +365,7 @@ build_interface_binfo (tree super, ClassDeclaration *cd, unsigned& offset) 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)); @@ -804,7 +804,7 @@ identity_compare_p (StructDeclaration *sd) 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 (); @@ -864,7 +864,7 @@ lower_struct_comparison (tree_code code, StructDeclaration *sd, 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)) @@ -885,7 +885,7 @@ lower_struct_comparison (tree_code code, StructDeclaration *sd, 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 (); @@ -968,7 +968,7 @@ build_struct_comparison (tree_code code, StructDeclaration *sd, 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)) @@ -1869,7 +1869,7 @@ d_build_call (TypeFunction *tf, tree callable, tree object, 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]; @@ -1889,8 +1889,8 @@ d_build_call (TypeFunction *tf, tree callable, tree object, /* 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); @@ -2381,11 +2381,11 @@ build_frame_type (tree ffi, FuncDeclaration *fd) { 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) @@ -2401,7 +2401,7 @@ build_frame_type (tree ffi, FuncDeclaration *fd) /* 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) @@ -2414,7 +2414,7 @@ build_frame_type (tree ffi, FuncDeclaration *fd) } } - 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); @@ -2507,7 +2507,7 @@ build_closure (FuncDeclaration *fd) } /* 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]; diff --git a/gcc/d/d-compiler.cc b/gcc/d/d-compiler.cc index a27261fb94e..a8adb983d06 100644 --- a/gcc/d/d-compiler.cc +++ b/gcc/d/d-compiler.cc @@ -91,8 +91,8 @@ Compiler::paintAsType (UnionExp *, Expression *expr, Type *type) Expressions *elements = ((ArrayLiteralExp *) expr)->elements; vec *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 ()) @@ -167,13 +167,13 @@ Compiler::loadModule (Module *m) 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")) diff --git a/gcc/d/d-incpath.cc b/gcc/d/d-incpath.cc index 54acac8364e..c0dd065d2ca 100644 --- a/gcc/d/d-incpath.cc +++ b/gcc/d/d-incpath.cc @@ -75,7 +75,7 @@ add_globalpaths (Strings *paths) 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); @@ -102,7 +102,7 @@ add_filepaths (Strings *paths) 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); @@ -144,7 +144,7 @@ add_import_paths (const char *iprefix, const char *imultilib, bool stdinc) /* 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) { @@ -173,7 +173,7 @@ add_import_paths (const char *iprefix, const char *imultilib, bool stdinc) /* 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) @@ -184,7 +184,7 @@ add_import_paths (const char *iprefix, const char *imultilib, bool stdinc) /* 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) diff --git a/gcc/d/d-lang.cc b/gcc/d/d-lang.cc index 6848c5e9a1c..35197e97a4c 100644 --- a/gcc/d/d-lang.cc +++ b/gcc/d/d-lang.cc @@ -176,7 +176,7 @@ deps_write (Module *module, OutBuffer *buffer, unsigned colmax = 72) column++; /* Search all modules for file dependencies. */ - while (modlist.dim > 0) + while (modlist.length > 0) { Module *depmod = modlist.pop (); @@ -193,7 +193,7 @@ deps_write (Module *module, OutBuffer *buffer, unsigned colmax = 72) 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); @@ -201,7 +201,7 @@ deps_write (Module *module, OutBuffer *buffer, unsigned colmax = 72) } /* 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]; @@ -998,7 +998,7 @@ d_parse_file (void) { 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 (" "); @@ -1068,14 +1068,14 @@ d_parse_file (void) } /* 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]; @@ -1119,7 +1119,7 @@ d_parse_file (void) /* 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) @@ -1136,7 +1136,7 @@ d_parse_file (void) 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]; @@ -1152,7 +1152,7 @@ d_parse_file (void) /* 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]; @@ -1166,9 +1166,9 @@ d_parse_file (void) 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), @@ -1177,14 +1177,14 @@ d_parse_file (void) } /* 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]; @@ -1200,7 +1200,7 @@ d_parse_file (void) 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]; @@ -1213,7 +1213,7 @@ d_parse_file (void) 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); @@ -1240,7 +1240,7 @@ d_parse_file (void) { 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 overrides -M[M]D. */ @@ -1281,7 +1281,7 @@ d_parse_file (void) /* 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); @@ -1291,7 +1291,7 @@ d_parse_file (void) /* 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; @@ -1302,7 +1302,7 @@ d_parse_file (void) } } - 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) diff --git a/gcc/d/decl.cc b/gcc/d/decl.cc index 7dab5c7e88c..11e66483b8f 100644 --- a/gcc/d/decl.cc +++ b/gcc/d/decl.cc @@ -101,7 +101,7 @@ gcc_attribute_p (Dsymbol *decl) { 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")) @@ -179,7 +179,7 @@ public: 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); @@ -215,7 +215,7 @@ public: 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) @@ -237,7 +237,7 @@ public: 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]); } @@ -285,7 +285,7 @@ public: 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]); } @@ -333,7 +333,7 @@ public: 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]); } @@ -344,7 +344,7 @@ public: 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]); } @@ -392,7 +392,7 @@ public: /* 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. */ @@ -415,7 +415,7 @@ public: 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 (); @@ -433,7 +433,7 @@ public: /* 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; @@ -497,7 +497,7 @@ public: 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 @@ -530,7 +530,7 @@ public: 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 (); @@ -573,7 +573,7 @@ public: 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. */ @@ -906,7 +906,7 @@ public: } /* 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++) { @@ -2013,27 +2013,27 @@ base_vtable_offset (ClassDeclaration *cd, BaseClass *bc) { 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; } } } @@ -2054,7 +2054,7 @@ get_vtable_decl (ClassDeclaration *decl) 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); @@ -2124,7 +2124,7 @@ build_class_instance (ClassReferenceExp *exp) /* 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]; @@ -2151,7 +2151,7 @@ build_class_instance (ClassReferenceExp *exp) /* 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); diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE index 2926fdd8188..a742bd096fa 100644 --- a/gcc/d/dmd/MERGE +++ b/gcc/d/dmd/MERGE @@ -1,4 +1,4 @@ -47ed0330f877897233bcaffd4e206e5f5ab66c98 +48d704f082ebe8b199a9ef7712c223216cd70d3a The first line of this file holds the git revision number of the last merge done from the dlang/dmd repository. diff --git a/gcc/d/dmd/access.c b/gcc/d/dmd/access.c index 103cfd213a8..89ea487b106 100644 --- a/gcc/d/dmd/access.c +++ b/gcc/d/dmd/access.c @@ -52,7 +52,7 @@ Prot getAccess(AggregateDeclaration *ad, Dsymbol *smember) } 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]; @@ -110,7 +110,7 @@ static bool isAccessible( 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); @@ -128,7 +128,7 @@ static bool isAccessible( { 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)) diff --git a/gcc/d/dmd/apply.c b/gcc/d/dmd/apply.c index eda6c522dfd..6f3301ed1df 100644 --- a/gcc/d/dmd/apply.c +++ b/gcc/d/dmd/apply.c @@ -43,7 +43,7 @@ public: { 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; } diff --git a/gcc/d/dmd/arrayop.c b/gcc/d/dmd/arrayop.c index 031291433f6..16ce3a90f37 100644 --- a/gcc/d/dmd/arrayop.c +++ b/gcc/d/dmd/arrayop.c @@ -421,7 +421,7 @@ Expression *buildArrayLoop(Expression *e, Parameters *fparams) 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); @@ -440,7 +440,7 @@ Expression *buildArrayLoop(Expression *e, Parameters *fparams) 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); @@ -450,7 +450,7 @@ Expression *buildArrayLoop(Expression *e, Parameters *fparams) 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); diff --git a/gcc/d/dmd/arraytypes.h b/gcc/d/dmd/arraytypes.h index 4bdc65cd450..ea57214f734 100644 --- a/gcc/d/dmd/arraytypes.h +++ b/gcc/d/dmd/arraytypes.h @@ -10,7 +10,8 @@ #pragma once -#include "root/root.h" +#include "root/array.h" +#include "root/bitarray.h" typedef Array TemplateParameters; diff --git a/gcc/d/dmd/attrib.c b/gcc/d/dmd/attrib.c index d84770f56fb..6f176ef096d 100644 --- a/gcc/d/dmd/attrib.c +++ b/gcc/d/dmd/attrib.c @@ -55,7 +55,7 @@ int AttribDeclaration::apply(Dsymbol_apply_ft_t fp, void *param) 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) @@ -117,7 +117,7 @@ void AttribDeclaration::addMember(Scope *sc, ScopeDsymbol *sds) { 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()); @@ -138,7 +138,7 @@ void AttribDeclaration::setScope(Scope *sc) { 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); @@ -158,7 +158,7 @@ void AttribDeclaration::importAll(Scope *sc) { 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); @@ -181,7 +181,7 @@ void AttribDeclaration::semantic(Scope *sc) { 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); @@ -201,7 +201,7 @@ void AttribDeclaration::semantic2(Scope *sc) { 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); @@ -220,7 +220,7 @@ void AttribDeclaration::semantic3(Scope *sc) { 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); @@ -240,7 +240,7 @@ void AttribDeclaration::addComment(const utf8_t *comment) 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()); @@ -256,7 +256,7 @@ void AttribDeclaration::setFieldOffset(AggregateDeclaration *ad, unsigned *poffs 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); @@ -270,7 +270,7 @@ bool AttribDeclaration::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->hasPointers()) @@ -286,7 +286,7 @@ bool AttribDeclaration::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]; if (s->hasStaticCtorOrDtor()) @@ -314,7 +314,7 @@ void AttribDeclaration::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->checkCtorConstInit(); @@ -331,7 +331,7 @@ void AttribDeclaration::addLocalClass(ClassDeclarations *aclasses) 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); @@ -387,7 +387,7 @@ void StorageClassDeclaration::addMember(Scope *sc, ScopeDsymbol *sds) 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()); @@ -767,7 +767,7 @@ void AnonDeclaration::semantic(Scope *sc) 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); @@ -787,7 +787,7 @@ void AnonDeclaration::setFieldOffset(AggregateDeclaration *ad, unsigned *poffset * 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. @@ -798,7 +798,7 @@ void AnonDeclaration::setFieldOffset(AggregateDeclaration *ad, unsigned *poffset 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); @@ -810,7 +810,7 @@ void AnonDeclaration::setFieldOffset(AggregateDeclaration *ad, unsigned *poffset * 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; @@ -845,7 +845,7 @@ void AnonDeclaration::setFieldOffset(AggregateDeclaration *ad, unsigned *poffset // 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); @@ -883,11 +883,11 @@ Scope *PragmaDeclaration::newScope(Scope *sc) 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(); } @@ -925,8 +925,8 @@ static unsigned setMangleOverride(Dsymbol *s, char *sym) 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; @@ -949,7 +949,7 @@ void PragmaDeclaration::semantic(Scope *sc) { if (args) { - for (size_t i = 0; i < args->dim; i++) + for (size_t i = 0; i < args->length; i++) { Expression *e = (*args)[i]; @@ -980,7 +980,7 @@ void PragmaDeclaration::semantic(Scope *sc) } else if (ident == Id::lib) { - if (!args || args->dim != 1) + if (!args || args->length != 1) error("string expected for library name"); else { @@ -1012,7 +1012,7 @@ void PragmaDeclaration::semantic(Scope *sc) } else if (ident == Id::startaddress) { - if (!args || args->dim != 1) + if (!args || args->length != 1) error("function name expected for start address"); else { @@ -1040,7 +1040,7 @@ void PragmaDeclaration::semantic(Scope *sc) { if (!args) args = new Expressions(); - if (args->dim != 1) + if (args->length != 1) { error("string expected for mangled name"); args->setDim(1); @@ -1113,7 +1113,7 @@ void PragmaDeclaration::semantic(Scope *sc) 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]; @@ -1129,7 +1129,7 @@ void PragmaDeclaration::semantic(Scope *sc) buf.writeByte(','); buf.writestring(e->toChars()); } - if (args->dim) + if (args->length) buf.writeByte(')'); } message("pragma %s", buf.peekString()); @@ -1144,7 +1144,7 @@ Ldecl: { 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]; @@ -1152,7 +1152,7 @@ Ldecl: 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); @@ -1239,7 +1239,7 @@ void ConditionalDeclaration::setScope(Scope *sc) //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); @@ -1263,7 +1263,7 @@ void ConditionalDeclaration::addComment(const utf8_t *comment) { 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()); @@ -1318,14 +1318,14 @@ Dsymbols *StaticIfDeclaration::include(Scope *sc, ScopeDsymbol *) 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); @@ -1449,13 +1449,13 @@ Dsymbols *StaticForeachDeclaration::include(Scope *, ScopeDsymbol *) 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); @@ -1616,7 +1616,7 @@ void CompileDeclaration::semantic(Scope *sc) 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); @@ -1652,7 +1652,7 @@ Dsymbol *UserAttributeDeclaration::syntaxCopy(Dsymbol *s) Scope *UserAttributeDeclaration::newScope(Scope *sc) { Scope *sc2 = sc; - if (atts && atts->dim) + if (atts && atts->length) { // create new one for changes sc2 = sc->copy(); @@ -1681,7 +1681,7 @@ void UserAttributeDeclaration::semantic(Scope *sc) 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) @@ -1701,7 +1701,7 @@ static void udaExpressionEval(Scope *sc, Expressions *exps) void UserAttributeDeclaration::semantic2(Scope *sc) { - if (decl && atts && atts->dim && _scope) + if (decl && atts && atts->length && _scope) { _scope = NULL; udaExpressionEval(sc, atts); @@ -1713,9 +1713,9 @@ void UserAttributeDeclaration::semantic2(Scope *sc) 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 { @@ -1740,7 +1740,7 @@ Expressions *UserAttributeDeclaration::getAttributes() 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; diff --git a/gcc/d/dmd/blockexit.c b/gcc/d/dmd/blockexit.c index f9b46604e24..d4088f5c691 100644 --- a/gcc/d/dmd/blockexit.c +++ b/gcc/d/dmd/blockexit.c @@ -75,10 +75,10 @@ int blockExit(Statement *s, FuncDeclaration *func, bool mustNotThrow) 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) @@ -124,7 +124,7 @@ int blockExit(Statement *s, FuncDeclaration *func, bool mustNotThrow) 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) @@ -356,7 +356,7 @@ int blockExit(Statement *s, FuncDeclaration *func, bool mustNotThrow) 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) diff --git a/gcc/d/dmd/canthrow.c b/gcc/d/dmd/canthrow.c index 611111785cb..1e1fa58703d 100644 --- a/gcc/d/dmd/canthrow.c +++ b/gcc/d/dmd/canthrow.c @@ -251,9 +251,9 @@ bool Dsymbol_canThrow(Dsymbol *s, FuncDeclaration *func, bool mustNotThrow) 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)) @@ -287,7 +287,7 @@ bool Dsymbol_canThrow(Dsymbol *s, FuncDeclaration *func, bool 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)) @@ -297,7 +297,7 @@ bool Dsymbol_canThrow(Dsymbol *s, FuncDeclaration *func, bool 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) diff --git a/gcc/d/dmd/clone.c b/gcc/d/dmd/clone.c index 73c932b6325..7f91a10bbaa 100644 --- a/gcc/d/dmd/clone.c +++ b/gcc/d/dmd/clone.c @@ -119,7 +119,7 @@ FuncDeclaration *hasIdentityOpAssign(AggregateDeclaration *ad, Scope *sc) 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) @@ -153,7 +153,7 @@ bool needOpAssign(StructDeclaration *sd) /* 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) @@ -220,7 +220,7 @@ FuncDeclaration *buildOpAssign(StructDeclaration *sd, Scope *sc) // 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) @@ -294,7 +294,7 @@ FuncDeclaration *buildOpAssign(StructDeclaration *sd, Scope *sc) * 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; @@ -361,7 +361,7 @@ bool needOpEquals(StructDeclaration *sd) /* 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) @@ -666,7 +666,7 @@ bool needToHash(StructDeclaration *sd) /* 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) @@ -785,16 +785,16 @@ FuncDeclaration *buildPostBlit(StructDeclaration *sd, Scope *sc) 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) @@ -918,7 +918,7 @@ FuncDeclaration *buildPostBlit(StructDeclaration *sd, Scope *sc) } // 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); @@ -931,7 +931,7 @@ FuncDeclaration *buildPostBlit(StructDeclaration *sd, Scope *sc) } FuncDeclaration *xpostblit = NULL; - switch (sd->postblits.dim) + switch (sd->postblits.length) { case 0: break; @@ -943,7 +943,7 @@ FuncDeclaration *buildPostBlit(StructDeclaration *sd, Scope *sc) 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); @@ -990,11 +990,11 @@ FuncDeclaration *buildDtor(AggregateDeclaration *ad, Scope *sc) 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) @@ -1078,7 +1078,7 @@ FuncDeclaration *buildDtor(AggregateDeclaration *ad, Scope *sc) } FuncDeclaration *xdtor = NULL; - switch (ad->dtors.dim) + switch (ad->dtors.length) { case 0: break; @@ -1090,7 +1090,7 @@ FuncDeclaration *buildDtor(AggregateDeclaration *ad, Scope *sc) 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); @@ -1138,7 +1138,7 @@ FuncDeclaration *buildInv(AggregateDeclaration *ad, Scope *sc) 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; @@ -1150,7 +1150,7 @@ FuncDeclaration *buildInv(AggregateDeclaration *ad, Scope *sc) 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) diff --git a/gcc/d/dmd/compiler.h b/gcc/d/dmd/compiler.h index 45301fc9458..124829b297d 100644 --- a/gcc/d/dmd/compiler.h +++ b/gcc/d/dmd/compiler.h @@ -11,6 +11,7 @@ #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. diff --git a/gcc/d/dmd/cond.c b/gcc/d/dmd/cond.c index 632c8577329..8c97b2a1b4f 100644 --- a/gcc/d/dmd/cond.c +++ b/gcc/d/dmd/cond.c @@ -33,7 +33,7 @@ int findCondition(Strings *ids, Identifier *ident) { 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]; @@ -152,7 +152,7 @@ static Statement *createForeach(StaticForeach *sfe, Loc loc, Parameters *paramet } 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); @@ -236,7 +236,7 @@ static Expression *createTuple(Loc loc, TypeStruct *type, Expressions *e) 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. @@ -264,7 +264,7 @@ static void lowerNonArrayAggregate(StaticForeach *sfe, Scope *sc) 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)); diff --git a/gcc/d/dmd/constfold.c b/gcc/d/dmd/constfold.c index c3cc58d7b1a..a0364ef8c90 100644 --- a/gcc/d/dmd/constfold.c +++ b/gcc/d/dmd/constfold.c @@ -787,7 +787,7 @@ UnionExp Equal(TOK op, Loc loc, Type *type, Expression *e1, Expression *e2) else if (e2->op == TOKarrayliteral) { ArrayLiteralExp *es2 = (ArrayLiteralExp *)e2; - cmp = !es2->elements || (0 == es2->elements->dim); + cmp = !es2->elements || (0 == es2->elements->length); } else { @@ -805,7 +805,7 @@ UnionExp Equal(TOK op, Loc loc, Type *type, Expression *e1, Expression *e2) else if (e1->op == TOKarrayliteral) { ArrayLiteralExp *es1 = (ArrayLiteralExp *)e1; - cmp = !es1->elements || (0 == es1->elements->dim); + cmp = !es1->elements || (0 == es1->elements->length); } else { @@ -835,16 +835,16 @@ UnionExp Equal(TOK op, Loc loc, Type *type, Expression *e1, Expression *e2) 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); @@ -871,7 +871,7 @@ UnionExp Equal(TOK op, Loc loc, Type *type, Expression *e1, Expression *e2) 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 @@ -899,17 +899,17 @@ UnionExp Equal(TOK op, Loc loc, Type *type, Expression *e1, Expression *e2) 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]; @@ -1235,7 +1235,7 @@ L1: 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; @@ -1276,14 +1276,14 @@ UnionExp ArrayLength(Type *type, Expression *e1) 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); } @@ -1353,9 +1353,9 @@ UnionExp Index(Type *type, Expression *e1, Expression *e2) 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 @@ -1377,7 +1377,7 @@ UnionExp Index(Type *type, Expression *e1, Expression *e2) 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]; @@ -1445,7 +1445,7 @@ UnionExp Slice(Type *type, Expression *e1, Expression *lwr, Expression *upr) 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(); @@ -1496,7 +1496,7 @@ void sliceAssignArrayLiteralFromString(ArrayLiteralExp *existingAE, StringExp *n 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) @@ -1686,16 +1686,16 @@ UnionExp Cat(Type *type, Expression *e1, Expression *e2) // [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; } @@ -1705,10 +1705,10 @@ UnionExp Cat(Type *type, Expression *e1, Expression *e2) // 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); } @@ -1786,7 +1786,7 @@ UnionExp Cat(Type *type, Expression *e1, Expression *e2) 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; @@ -1812,7 +1812,7 @@ UnionExp Cat(Type *type, Expression *e1, Expression *e2) 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; @@ -1832,7 +1832,7 @@ UnionExp Cat(Type *type, Expression *e1, Expression *e2) 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; @@ -1849,7 +1849,7 @@ UnionExp Cat(Type *type, Expression *e1, Expression *e2) 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; diff --git a/gcc/d/dmd/cppmangle.c b/gcc/d/dmd/cppmangle.c index e3307af322e..a50802225aa 100644 --- a/gcc/d/dmd/cppmangle.c +++ b/gcc/d/dmd/cppmangle.c @@ -88,7 +88,7 @@ class CppMangleVisitor : public Visitor 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; @@ -166,7 +166,7 @@ class CppMangleVisitor : public Visitor 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(); @@ -184,7 +184,7 @@ class CppMangleVisitor : public Visitor 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); @@ -365,7 +365,7 @@ class CppMangleVisitor : public Visitor 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]); } /*** @@ -376,7 +376,7 @@ class CppMangleVisitor : public Visitor */ 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])) { @@ -411,7 +411,7 @@ class CppMangleVisitor : public Visitor if (s->ident == Id::basic_string) { // ::std::basic_string, ::std::allocator> - 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])) @@ -491,7 +491,7 @@ class CppMangleVisitor : public Visitor else if (s->ident == Id::basic_string) { // ::std::basic_string, ::std::allocator> - 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])) diff --git a/gcc/d/dmd/ctfeexpr.c b/gcc/d/dmd/ctfeexpr.c index 7605d02a136..16ffede4882 100644 --- a/gcc/d/dmd/ctfeexpr.c +++ b/gcc/d/dmd/ctfeexpr.c @@ -43,18 +43,18 @@ int ClassReferenceExp::getFieldIndex(Type *fieldtype, unsigned fieldoffset) { 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; @@ -66,17 +66,17 @@ int ClassReferenceExp::findFieldIndexByName(VarDeclaration *v) { 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; @@ -100,7 +100,7 @@ const char *VoidInitExp::toChars() // 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; @@ -229,8 +229,8 @@ Expressions *copyLiteralArray(Expressions *oldelems, Expression *basis = NULL) 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) @@ -288,8 +288,8 @@ UnionExp copyLiteral(Expression *e) 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]; @@ -534,12 +534,12 @@ uinteger_t resolveArrayLength(Expression *e) 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; @@ -1314,16 +1314,16 @@ int ctfeRawCmp(Loc loc, Expression *e1, Expression *e2) 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]; @@ -1344,8 +1344,8 @@ int ctfeRawCmp(Loc loc, Expression *e1, Expression *e2) 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); @@ -1459,12 +1459,12 @@ UnionExp ctfeCat(Loc loc, Type *type, Expression *e1, Expression *e2) // [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) @@ -1493,12 +1493,12 @@ UnionExp ctfeCat(Loc loc, Type *type, Expression *e1, Expression *e2) // 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) @@ -1529,7 +1529,7 @@ UnionExp ctfeCat(Loc loc, Type *type, Expression *e1, Expression *e2) 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 && @@ -1557,7 +1557,7 @@ Expression *findKeyInAA(Loc loc, AssocArrayLiteralExp *ae, Expression *e2) { /* 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]; @@ -1591,9 +1591,9 @@ Expression *ctfeIndex(Loc loc, Type *type, Expression *e1, uinteger_t indx) 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]; @@ -1680,7 +1680,7 @@ void assignInPlace(Expression *dest, Expression *src) 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) @@ -1706,9 +1706,9 @@ void assignInPlace(Expression *dest, Expression *src) 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]; @@ -1734,8 +1734,8 @@ Expressions *changeOneElement(Expressions *oldelems, size_t indexToChange, Expre { 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; @@ -1754,7 +1754,7 @@ Expression *assignAssocArrayElement(Loc loc, AssocArrayLiteralExp *aae, 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]; @@ -2027,13 +2027,13 @@ void showCtfeExpr(Expression *e, int level) 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) @@ -2043,17 +2043,17 @@ void showCtfeExpr(Expression *e, int level) } 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) @@ -2109,8 +2109,8 @@ UnionExp voidInitLiteral(Type *t, VarDeclaration *var) { 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(); } diff --git a/gcc/d/dmd/dcast.c b/gcc/d/dmd/dcast.c index 6a6d1b80db9..20e8dc61438 100644 --- a/gcc/d/dmd/dcast.c +++ b/gcc/d/dmd/dcast.c @@ -148,7 +148,7 @@ Expression *implicitCastTo(Expression *e, Scope *sc, Type *t) 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); @@ -515,7 +515,7 @@ MATCH implicitConvTo(Expression *e, Type *t) ((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) @@ -658,12 +658,12 @@ MATCH implicitConvTo(Expression *e, Type *t) 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); @@ -676,7 +676,7 @@ MATCH implicitConvTo(Expression *e, Type *t) 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) @@ -702,7 +702,7 @@ MATCH implicitConvTo(Expression *e, Type *t) 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) { @@ -740,7 +740,7 @@ MATCH implicitConvTo(Expression *e, Type *t) 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); @@ -849,7 +849,7 @@ MATCH implicitConvTo(Expression *e, Type *t) 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(); @@ -895,7 +895,7 @@ MATCH implicitConvTo(Expression *e, Type *t) { 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(); @@ -1126,7 +1126,7 @@ MATCH implicitConvTo(Expression *e, Type *t) 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(); @@ -1156,7 +1156,7 @@ MATCH implicitConvTo(Expression *e, Type *t) */ 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 @@ -1201,7 +1201,7 @@ MATCH implicitConvTo(Expression *e, Type *t) { 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; @@ -1902,7 +1902,7 @@ Expression *castTo(Expression *e, Scope *sc, Type *t) { 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(); @@ -1976,7 +1976,7 @@ Expression *castTo(Expression *e, Scope *sc, Type *t) 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); @@ -2022,7 +2022,7 @@ Expression *castTo(Expression *e, Scope *sc, Type *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; } @@ -2030,7 +2030,7 @@ Expression *castTo(Expression *e, Scope *sc, Type *t) 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) @@ -2059,7 +2059,7 @@ Expression *castTo(Expression *e, Scope *sc, Type *t) 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; @@ -2106,8 +2106,8 @@ Expression *castTo(Expression *e, Scope *sc, Type *t) 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()); @@ -2408,7 +2408,7 @@ Expression *inferType(Expression *e, Type *t, int flag) 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) @@ -2429,7 +2429,7 @@ Expression *inferType(Expression *e, Type *t, int flag) 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) @@ -2438,7 +2438,7 @@ Expression *inferType(Expression *e, Type *t, int flag) (*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) @@ -2552,7 +2552,7 @@ Expression *scaleFactor(BinExp *be, Scope *sc) 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); @@ -2566,7 +2566,7 @@ bool isVoidArrayLiteral(Expression *e, Type *other) 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() diff --git a/gcc/d/dmd/dclass.c b/gcc/d/dmd/dclass.c index 76eb4a252ea..754a996ff50 100644 --- a/gcc/d/dmd/dclass.c +++ b/gcc/d/dmd/dclass.c @@ -62,7 +62,7 @@ ClassDeclaration::ClassDeclaration(Loc loc, Identifier *id, BaseClasses *basecla 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); @@ -261,8 +261,8 @@ Dsymbol *ClassDeclaration::syntaxCopy(Dsymbol *s) 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()); @@ -402,7 +402,7 @@ void ClassDeclaration::semantic(Scope *sc) 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); @@ -433,7 +433,7 @@ void ClassDeclaration::semantic(Scope *sc) } // 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(); @@ -492,7 +492,7 @@ void ClassDeclaration::semantic(Scope *sc) // 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(); @@ -588,7 +588,7 @@ void ClassDeclaration::semantic(Scope *sc) 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++) @@ -625,7 +625,7 @@ Lancestorsdone: * 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); @@ -636,7 +636,7 @@ Lancestorsdone: /* 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); @@ -646,7 +646,7 @@ Lancestorsdone: 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(); @@ -673,14 +673,14 @@ Lancestorsdone: // 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; } @@ -727,14 +727,14 @@ Lancestorsdone: 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); @@ -750,7 +750,7 @@ Lancestorsdone: /* 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(); @@ -783,7 +783,7 @@ Lancestorsdone: 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) @@ -863,7 +863,7 @@ Lancestorsdone: // 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() && @@ -893,7 +893,7 @@ bool ClassDeclaration::isBaseOf2(ClassDeclaration *cd) 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)) @@ -973,7 +973,7 @@ Dsymbol *ClassDeclaration::search(const Loc &loc, Identifier *ident, int flags) { // 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]; @@ -1010,7 +1010,7 @@ Dsymbol *ClassDeclaration::search(const Loc &loc, Identifier *ident, int flags) */ 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(); @@ -1050,7 +1050,7 @@ static unsigned membersPlace(BaseClasses *vtblInterfaces, size_t &bi, ClassDecla 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) { @@ -1121,7 +1121,7 @@ void ClassDeclaration::finalizeSize() 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); @@ -1163,7 +1163,7 @@ bool ClassDeclaration::isFuncHidden(FuncDeclaration *fd) 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(); @@ -1198,7 +1198,7 @@ FuncDeclaration *ClassDeclaration::findFunc(Identifier *ident, TypeFunction *tf) 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) @@ -1336,7 +1336,7 @@ bool ClassDeclaration::isAbstract() } }; - 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)) @@ -1348,7 +1348,7 @@ bool ClassDeclaration::isAbstract() /* 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()); @@ -1490,7 +1490,7 @@ void InterfaceDeclaration::semantic(Scope *sc) 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); @@ -1520,13 +1520,13 @@ void InterfaceDeclaration::semantic(Scope *sc) 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(); @@ -1592,7 +1592,7 @@ void InterfaceDeclaration::semantic(Scope *sc) } baseok = BASEOKdone; - interfaces.length = baseclasses->dim; + interfaces.length = baseclasses->length; interfaces.ptr = baseclasses->tdata(); for (size_t i = 0; i < interfaces.length; i++) @@ -1618,7 +1618,7 @@ Lancestorsdone: 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(); @@ -1660,7 +1660,7 @@ Lancestorsdone: // 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); @@ -1678,7 +1678,7 @@ Lancestorsdone: } } - 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); @@ -1689,20 +1689,20 @@ Lancestorsdone: /* 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); @@ -1867,10 +1867,10 @@ bool BaseClass::fillVtbl(ClassDeclaration *cd, FuncDeclarations *vtbl, int newin //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; @@ -1929,7 +1929,7 @@ void BaseClass::copyBaseInterfaces(BaseClasses *vtblInterfaces) 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 diff --git a/gcc/d/dmd/declaration.c b/gcc/d/dmd/declaration.c index f8e9f2c8eb2..5ae8c06e7ec 100644 --- a/gcc/d/dmd/declaration.c +++ b/gcc/d/dmd/declaration.c @@ -55,7 +55,7 @@ bool checkFrameAccess(Loc loc, Scope *sc, AggregateDeclaration *ad, size_t iStar } 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(); @@ -203,7 +203,7 @@ Type *TupleDeclaration::getType() { /* 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) @@ -217,10 +217,10 @@ Type *TupleDeclaration::getType() */ 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()); @@ -242,7 +242,7 @@ Dsymbol *TupleDeclaration::toAlias2() { //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)) @@ -257,7 +257,7 @@ Dsymbol *TupleDeclaration::toAlias2() 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) @@ -1020,19 +1020,19 @@ void VarDeclaration::semantic(Scope *sc) 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; @@ -1041,7 +1041,7 @@ void VarDeclaration::semantic(Scope *sc) 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); @@ -1060,17 +1060,17 @@ void VarDeclaration::semantic(Scope *sc) (*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)) @@ -1092,7 +1092,7 @@ void VarDeclaration::semantic(Scope *sc) } } } - if (iexps->dim < nelems) + if (iexps->length < nelems) goto Lnomatch; ie = new TupleExp(_init->loc, iexps); @@ -1102,7 +1102,7 @@ Lnomatch: 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); @@ -1493,7 +1493,7 @@ Lnomatch: 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; } @@ -1650,7 +1650,7 @@ void VarDeclaration::semantic2(Scope *sc) { 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)) @@ -1711,7 +1711,7 @@ void VarDeclaration::setFieldOffset(AggregateDeclaration *ad, unsigned *poffset, // 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); @@ -1738,7 +1738,7 @@ void VarDeclaration::setFieldOffset(AggregateDeclaration *ad, unsigned *poffset, *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) { @@ -1901,16 +1901,8 @@ bool VarDeclaration::checkNestedReference(Scope *sc, Loc loc) 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. @@ -1928,16 +1920,10 @@ bool VarDeclaration::checkNestedReference(Scope *sc, Loc loc) } // 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()); diff --git a/gcc/d/dmd/denum.c b/gcc/d/dmd/denum.c index 41af4a9a110..f96380f572a 100644 --- a/gcc/d/dmd/denum.c +++ b/gcc/d/dmd/denum.c @@ -74,7 +74,7 @@ void EnumDeclaration::addMember(Scope *sc, ScopeDsymbol *sds) 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; @@ -172,7 +172,7 @@ void EnumDeclaration::semantic(Scope *sc) 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 @@ -188,7 +188,7 @@ void EnumDeclaration::semantic(Scope *sc) 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; @@ -210,7 +210,7 @@ void EnumDeclaration::semantic(Scope *sc) /* 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) @@ -246,7 +246,7 @@ void EnumDeclaration::semantic(Scope *sc) 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) @@ -257,7 +257,7 @@ void EnumDeclaration::semantic(Scope *sc) } } - 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) @@ -314,7 +314,7 @@ Expression *EnumDeclaration::getMaxMinValue(Loc loc, Identifier *id) 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) @@ -402,7 +402,7 @@ Expression *EnumDeclaration::getDefaultValue(Loc loc) 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) @@ -588,7 +588,7 @@ void EnumMember::semantic(Scope *sc) * 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) @@ -667,7 +667,7 @@ void EnumMember::semantic(Scope *sc) * 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) diff --git a/gcc/d/dmd/dimport.c b/gcc/d/dmd/dimport.c index 5a618558aa4..b176d8cadd0 100644 --- a/gcc/d/dmd/dimport.c +++ b/gcc/d/dmd/dimport.c @@ -45,7 +45,7 @@ Import::Import(Loc loc, Identifiers *packages, Identifier *id, Identifier *alias // import [cstdio] = std.stdio; this->ident = aliasId; } - else if (packages && packages->dim) + else if (packages && packages->length) { // import [std].stdio; this->ident = (*packages)[0]; @@ -85,7 +85,7 @@ Dsymbol *Import::syntaxCopy(Dsymbol *s) 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]); } @@ -186,7 +186,7 @@ void Import::importAll(Scope *sc) if (sc->explicitProtection) protection = sc->protection; - if (!isstatic && !aliasId && !names.dim) + if (!isstatic && !aliasId && !names.length) { sc->scopesym->importScope(mod, protection); } @@ -227,7 +227,7 @@ void Import::semantic(Scope *sc) 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) @@ -253,7 +253,7 @@ void Import::semantic(Scope *sc) // 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); @@ -273,7 +273,7 @@ void Import::semantic(Scope *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]; //printf("\tImport %s alias %s = %s, scope = %p\n", toPrettyChars(), aliases[i]->toChars(), names[i]->toChars(), ad->_scope); @@ -341,7 +341,7 @@ void Import::semantic(Scope *sc) 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()); @@ -356,7 +356,7 @@ void Import::semantic(Scope *sc) 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(':'); @@ -413,7 +413,7 @@ Dsymbol *Import::toAlias() 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) @@ -422,7 +422,7 @@ void Import::addMember(Scope *sc, ScopeDsymbol *sd) /* 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]; @@ -442,14 +442,14 @@ void Import::addMember(Scope *sc, ScopeDsymbol *sd) 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); diff --git a/gcc/d/dmd/dinterpret.c b/gcc/d/dmd/dinterpret.c index c900d9ecc46..7c7238d6b8d 100644 --- a/gcc/d/dmd/dinterpret.c +++ b/gcc/d/dmd/dinterpret.c @@ -129,7 +129,7 @@ CtfeStack::CtfeStack() : framepointer(0), maxStackPointer(0) size_t CtfeStack::stackPointer() { - return values.dim; + return values.length; } Expression *CtfeStack::getThis() @@ -153,12 +153,12 @@ void CtfeStack::startFrame(Expression *thisexp) 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) @@ -173,7 +173,7 @@ Expression *CtfeStack::getValue(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()); @@ -198,7 +198,7 @@ void CtfeStack::push(VarDeclaration *v) return; } savedId.push((void *)(size_t)(v->ctfeAdrOnStack)); - v->ctfeAdrOnStack = (int)values.dim; + v->ctfeAdrOnStack = (int)values.length; vars.push(v); values.push(NULL); } @@ -209,7 +209,7 @@ void CtfeStack::pop(VarDeclaration *v) 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(); @@ -221,8 +221,8 @@ void CtfeStack::popAll(size_t stackpointer) { 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]); @@ -235,7 +235,7 @@ void CtfeStack::popAll(size_t stackpointer) 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); } @@ -342,7 +342,7 @@ struct CompiledCtfeFunction { 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); @@ -406,7 +406,7 @@ public: 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) @@ -416,7 +416,7 @@ public: 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) @@ -481,7 +481,7 @@ public: 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); } @@ -546,7 +546,7 @@ public: { 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) @@ -616,7 +616,7 @@ void ctfeCompile(FuncDeclaration *fd) { 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); @@ -700,7 +700,7 @@ Expression *ctfeInterpretForPragmaMsg(Expression *e) 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; @@ -710,8 +710,8 @@ Expression *ctfeInterpretForPragmaMsg(Expression *e) 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; @@ -761,7 +761,7 @@ static Expression *interpretFunction(UnionExp *pue, FuncDeclaration *fd, InterSt 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; @@ -785,8 +785,8 @@ static Expression *interpretFunction(UnionExp *pue, FuncDeclaration *fd, InterSt // 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[] @@ -1045,7 +1045,7 @@ public: 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]; @@ -1060,7 +1060,7 @@ public: 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]; @@ -1200,7 +1200,7 @@ public: // 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) @@ -1237,7 +1237,7 @@ public: 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. @@ -1470,7 +1470,7 @@ public: 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]; @@ -1585,7 +1585,7 @@ public: { 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; @@ -1605,7 +1605,7 @@ public: 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; @@ -2286,7 +2286,7 @@ public: // 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); @@ -2366,7 +2366,7 @@ public: { // 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() || @@ -2431,7 +2431,7 @@ public: 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); @@ -2482,7 +2482,7 @@ public: 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]; @@ -2521,7 +2521,7 @@ public: { // 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; @@ -2554,7 +2554,7 @@ public: 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]; @@ -2581,7 +2581,7 @@ public: 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; @@ -2590,10 +2590,10 @@ public: /* 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)) @@ -2635,13 +2635,13 @@ public: 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. @@ -2653,7 +2653,7 @@ public: expsx->push(ne); ++dim; } - assert(dim == e->sd->fields.dim); + assert(dim == e->sd->fields.length); for (size_t i = 0; i < dim; i++) { @@ -2693,7 +2693,7 @@ public: 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; @@ -2723,7 +2723,7 @@ public: 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); @@ -2739,7 +2739,7 @@ public: 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(); @@ -2788,11 +2788,11 @@ public: { 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); @@ -2820,14 +2820,14 @@ public: 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) @@ -2891,7 +2891,7 @@ public: 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); @@ -3634,7 +3634,7 @@ public: 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)) @@ -3686,7 +3686,7 @@ public: 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); @@ -3776,10 +3776,10 @@ public: 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]); @@ -3915,7 +3915,7 @@ public: if (e1->op == TOKarrayliteral) { lowerbound = 0; - upperbound = ((ArrayLiteralExp *)e1)->elements->dim; + upperbound = ((ArrayLiteralExp *)e1)->elements->length; } else if (e1->op == TOKstring) { @@ -4126,7 +4126,7 @@ public: 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); @@ -4156,7 +4156,7 @@ public: 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) @@ -4643,7 +4643,7 @@ public: 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) @@ -4918,7 +4918,7 @@ public: // 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) @@ -5506,7 +5506,7 @@ public: 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)) @@ -5614,7 +5614,7 @@ public: 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); @@ -5728,7 +5728,7 @@ public: { 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) @@ -6121,7 +6121,7 @@ public: 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); @@ -6133,8 +6133,8 @@ public: (*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(); } @@ -6311,7 +6311,7 @@ static bool isVoid(Expression *e, bool checkArray = false) // 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, @@ -6325,7 +6325,7 @@ bool isEntirelyVoid(Expressions *elems) // 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, @@ -6421,7 +6421,7 @@ Expression *scrubCacheValue(Expression *e) 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); @@ -6453,7 +6453,7 @@ static Expression *interpret_length(UnionExp *pue, InterState *istate, Expressio 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); @@ -6515,7 +6515,7 @@ Expression *interpret_dup(UnionExp *pue, InterState *istate, Expression *earg) 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; @@ -6551,7 +6551,7 @@ Expression *interpret_aaApply(UnionExp *pue, InterState *istate, Expression *aa, 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); @@ -6561,11 +6561,11 @@ Expression *interpret_aaApply(UnionExp *pue, InterState *istate, Expression *aa, 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]; @@ -6610,7 +6610,7 @@ static Expression *foreachApplyUtf(UnionExp *pue, InterState *istate, Expression 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 @@ -6856,14 +6856,14 @@ Expression *evaluateIfBuiltin(UnionExp *pue, InterState *istate, Loc loc, 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); @@ -6906,9 +6906,9 @@ Expression *evaluateIfBuiltin(UnionExp *pue, InterState *istate, Loc loc, 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]); } } } @@ -6919,8 +6919,8 @@ Expression *evaluateIfBuiltin(UnionExp *pue, InterState *istate, Loc loc, // 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)) @@ -6976,7 +6976,7 @@ Expression *evaluatePostblit(InterState *istate, Expression *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) @@ -7012,7 +7012,7 @@ Expression *evaluateDtor(InterState *istate, Expression *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) diff --git a/gcc/d/dmd/dmangle.c b/gcc/d/dmd/dmangle.c index 1f28543a45e..18bdf27de56 100644 --- a/gcc/d/dmd/dmangle.c +++ b/gcc/d/dmd/dmangle.c @@ -754,7 +754,7 @@ public: 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++) { @@ -764,7 +764,7 @@ public: 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++) { @@ -775,7 +775,7 @@ public: 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++) { diff --git a/gcc/d/dmd/dmodule.c b/gcc/d/dmd/dmodule.c index f251814f913..ba7885e8c76 100644 --- a/gcc/d/dmd/dmodule.c +++ b/gcc/d/dmd/dmodule.c @@ -224,14 +224,14 @@ Module *Module::load(Loc loc, Identifiers *packages, Identifier *ident) // into: // foo\bar\baz const char *filename = ident->toChars(); - if (packages && packages->dim) + if (packages && packages->length) { OutBuffer buf; OutBuffer dotmods; Array *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(); @@ -275,7 +275,7 @@ Module *Module::load(Loc loc, Identifiers *packages, Identifier *ident) 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()); @@ -324,7 +324,7 @@ bool Module::read(Loc loc) */ 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); @@ -679,7 +679,7 @@ void Module::importAll(Scope *) // 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); @@ -690,7 +690,7 @@ void Module::importAll(Scope *) { // 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); @@ -704,13 +704,13 @@ void Module::importAll(Scope *) * 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); @@ -740,7 +740,7 @@ void Module::semantic(Scope *) //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]; @@ -777,7 +777,7 @@ void Module::semantic2(Scope*) //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); @@ -808,7 +808,7 @@ void Module::semantic3(Scope*) //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()); @@ -899,7 +899,7 @@ Dsymbol *Module::symtabInsert(Dsymbol *s) 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; @@ -913,7 +913,7 @@ void Module::clearCache() 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]; @@ -949,14 +949,14 @@ void Module::runDeferredSemantic() 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; @@ -982,12 +982,12 @@ void Module::runDeferredSemantic() 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() @@ -995,7 +995,7 @@ 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()); @@ -1012,7 +1012,7 @@ void Module::runDeferredSemantic3() 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()); @@ -1034,7 +1034,7 @@ void Module::runDeferredSemantic3() 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) @@ -1059,12 +1059,12 @@ bool Module::selfImports() //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; @@ -1079,11 +1079,11 @@ bool Module::rootImports() //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)) @@ -1093,7 +1093,7 @@ bool Module::rootImports() } } - 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; @@ -1119,9 +1119,9 @@ const char *ModuleDeclaration::toChars() { 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()); @@ -1207,7 +1207,7 @@ DsymbolTable *Package::resolve(Identifiers *packages, Dsymbol **pparent, Package 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; @@ -1318,7 +1318,7 @@ const char *lookForSourceFile(const char **path, const char *filename) 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]; diff --git a/gcc/d/dmd/doc.c b/gcc/d/dmd/doc.c index 22814c6d764..a448e342a82 100644 --- a/gcc/d/dmd/doc.c +++ b/gcc/d/dmd/doc.c @@ -124,7 +124,7 @@ int utfStride(const utf8_t *p); // 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) @@ -140,7 +140,7 @@ static Parameter *isFunctionParameter(Dsymbol *s, const utf8_t *p, size_t len) 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) @@ -173,7 +173,7 @@ static Dsymbol *getEponymousMember(TemplateDeclaration *td) */ 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) @@ -354,7 +354,7 @@ void gendocfile(Module *m) 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); @@ -668,7 +668,7 @@ static void expandTemplateMixinComments(TemplateMixin *tm, OutBuffer *buf, Scope 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(); @@ -705,7 +705,7 @@ void emitMemberComments(ScopeDsymbol *sds, OutBuffer *buf, Scope *sc) 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()); @@ -774,7 +774,7 @@ void emitComment(Dsymbol *s, OutBuffer *buf, Scope *sc) { // 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]; @@ -888,7 +888,7 @@ void emitComment(Dsymbol *s, OutBuffer *buf, Scope *sc) 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); @@ -930,7 +930,7 @@ void emitComment(Dsymbol *s, OutBuffer *buf, Scope *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()); @@ -965,7 +965,7 @@ void emitComment(Dsymbol *s, OutBuffer *buf, Scope *sc) * 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); @@ -1067,9 +1067,9 @@ void toDocBuffer(Dsymbol *s, OutBuffer *buf, Scope *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(", "); @@ -1219,7 +1219,7 @@ void toDocBuffer(Dsymbol *s, OutBuffer *buf, Scope *sc) 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]; @@ -1288,7 +1288,7 @@ DocComment *DocComment::parse(Dsymbol *s, const utf8_t *comment) 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]; @@ -1444,7 +1444,7 @@ void DocComment::parseSections(const utf8_t *comment) void DocComment::writeSections(Scope *sc, Dsymbols *a, OutBuffer *buf) { - assert(a->dim); + assert(a->length); //printf("DocComment::writeSections()\n"); Loc loc = (*a)[0]->loc; @@ -1458,7 +1458,7 @@ void DocComment::writeSections(Scope *sc, Dsymbols *a, OutBuffer *buf) 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) @@ -1478,7 +1478,7 @@ void DocComment::writeSections(Scope *sc, Dsymbols *a, OutBuffer *buf) 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)) @@ -1528,7 +1528,7 @@ void DocComment::writeSections(Scope *sc, Dsymbols *a, OutBuffer *buf) void Section::write(Loc loc, DocComment *, Scope *sc, Dsymbols *a, OutBuffer *buf) { - assert(a->dim); + assert(a->length); if (namelen) { @@ -1579,7 +1579,7 @@ void Section::write(Loc loc, DocComment *, Scope *sc, Dsymbols *a, OutBuffer *bu 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; @@ -1730,10 +1730,10 @@ void ParamSection::write(Loc loc, DocComment *, Scope *sc, Dsymbols *a, OutBuffe 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"); @@ -2109,7 +2109,7 @@ Lno: 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) @@ -2156,7 +2156,7 @@ TypeFunction *isTypeFunction(Dsymbol *s) 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) @@ -2172,7 +2172,7 @@ Parameter *isFunctionParameter(Dsymbols *a, const utf8_t *p, size_t len) 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. @@ -2180,7 +2180,7 @@ TemplateParameter *isTemplateParameter(Dsymbols *a, const utf8_t *p, size_t len) 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) @@ -2222,7 +2222,7 @@ bool isReservedName(utf8_t *str, size_t len) 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"); diff --git a/gcc/d/dmd/dscope.c b/gcc/d/dmd/dscope.c index 2900669595b..f1b7f2d9a65 100644 --- a/gcc/d/dmd/dscope.c +++ b/gcc/d/dmd/dscope.c @@ -352,7 +352,7 @@ void Scope::mergeFieldInit(Loc loc, unsigned *fies) 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 || @@ -644,20 +644,20 @@ void Scope::deprecation10378(Loc loc, Dsymbol *sold, Dsymbol *snew) 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 diff --git a/gcc/d/dmd/dstruct.c b/gcc/d/dmd/dstruct.c index 6331c53b710..5af27455724 100644 --- a/gcc/d/dmd/dstruct.c +++ b/gcc/d/dmd/dstruct.c @@ -154,7 +154,7 @@ void semanticTypeInfo(Scope *sc, Type *t) { 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) @@ -261,7 +261,7 @@ void AggregateDeclaration::semantic2(Scope *sc) 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()); @@ -287,7 +287,7 @@ void AggregateDeclaration::semantic3(Scope *sc) 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); @@ -344,7 +344,7 @@ bool AggregateDeclaration::determineFields() 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 @@ -396,7 +396,7 @@ bool AggregateDeclaration::determineFields() 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)) @@ -557,7 +557,7 @@ bool AggregateDeclaration::checkOverlappedFields() { //printf("AggregateDeclaration::checkOverlappedFields() %s\n", toChars()); assert(sizeok == SIZEOKdone); - size_t nfields = fields.dim; + size_t nfields = fields.length; if (isNested()) { ClassDeclaration *cd = isClassDeclaration(); @@ -633,10 +633,10 @@ bool AggregateDeclaration::fill(Loc loc, Expressions *elements, bool ctorinit) //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; @@ -768,7 +768,7 @@ bool AggregateDeclaration::fill(Loc loc, Expressions *elements, bool ctorinit) } } - 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) @@ -967,7 +967,7 @@ Dsymbol *AggregateDeclaration::searchCtor() } }; - 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); @@ -1091,7 +1091,7 @@ void StructDeclaration::semantic(Scope *sc) { 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()); @@ -1104,20 +1104,20 @@ void StructDeclaration::semantic(Scope *sc) /* 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); @@ -1136,7 +1136,7 @@ void StructDeclaration::semantic(Scope *sc) * 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(); @@ -1245,14 +1245,14 @@ void StructDeclaration::finalizeSize() //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); @@ -1277,7 +1277,7 @@ void StructDeclaration::finalizeSize() 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; @@ -1291,7 +1291,7 @@ void StructDeclaration::finalizeSize() // 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) @@ -1308,7 +1308,7 @@ void StructDeclaration::finalizeSize() } 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); @@ -1333,9 +1333,9 @@ bool StructDeclaration::fit(Loc loc, Scope *sc, Expressions *elements, Type *sty 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) @@ -1344,7 +1344,7 @@ bool StructDeclaration::fit(Loc loc, Scope *sc, Expressions *elements, Type *sty 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; @@ -1428,7 +1428,7 @@ bool StructDeclaration::isPOD() 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) diff --git a/gcc/d/dmd/dsymbol.c b/gcc/d/dmd/dsymbol.c index 39c9e5a0b75..f8b063f0318 100644 --- a/gcc/d/dmd/dsymbol.c +++ b/gcc/d/dmd/dsymbol.c @@ -127,12 +127,12 @@ bool Dsymbol::oneMember(Dsymbol **ps, Identifier *) 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); @@ -881,7 +881,7 @@ Dsymbols *Dsymbol::arraySyntaxCopy(Dsymbols *a) 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); } @@ -936,7 +936,7 @@ OverloadSet::OverloadSet(Identifier *ident, OverloadSet *os) { 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]); } @@ -1097,7 +1097,7 @@ Dsymbol *ScopeDsymbol::search(const Loc &loc, Identifier *ident, int flags) 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) @@ -1231,14 +1231,14 @@ OverloadSet *ScopeDsymbol::mergeOverloadSet(Identifier *ident, OverloadSet *os, 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]); } @@ -1250,7 +1250,7 @@ OverloadSet *ScopeDsymbol::mergeOverloadSet(Identifier *ident, OverloadSet *os, /* 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()) @@ -1282,7 +1282,7 @@ void ScopeDsymbol::importScope(Dsymbol *s, Prot protection) 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 @@ -1294,8 +1294,8 @@ void ScopeDsymbol::importScope(Dsymbol *s, Prot protection) } } 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; } } @@ -1346,7 +1346,7 @@ bool ScopeDsymbol::isPackageAccessible(Package *p, Prot protection, int) 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]; @@ -1409,7 +1409,7 @@ bool ScopeDsymbol::hasStaticCtorOrDtor() { 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()) @@ -1484,7 +1484,7 @@ int ScopeDsymbol_foreach(Scope *sc, Dsymbols *members, ForeachDg dg, void *ctx, 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()) @@ -1612,7 +1612,7 @@ Dsymbol *ArrayScopeSymbol::search(const Loc &loc, Identifier *ident, int) /* $ 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); @@ -1624,7 +1624,7 @@ Dsymbol *ArrayScopeSymbol::search(const Loc &loc, Identifier *ident, int) /* $ 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); @@ -1694,7 +1694,7 @@ Dsymbol *ArrayScopeSymbol::search(const Loc &loc, Identifier *ident, int) /* 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; } @@ -1742,7 +1742,7 @@ Dsymbol *ArrayScopeSymbol::search(const Loc &loc, Identifier *ident, int) * 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; diff --git a/gcc/d/dmd/dtemplate.c b/gcc/d/dmd/dtemplate.c index 3a021982051..b126295f07e 100644 --- a/gcc/d/dmd/dtemplate.c +++ b/gcc/d/dmd/dtemplate.c @@ -121,7 +121,7 @@ bool isError(RootObject *o) */ 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)) @@ -370,9 +370,9 @@ int arrayObjectMatch(Objects *oa1, Objects *oa2) { 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]; @@ -423,7 +423,7 @@ static hash_t expressionHash(Expression *e) 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)); @@ -435,7 +435,7 @@ static hash_t expressionHash(Expression *e) { 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; } @@ -444,7 +444,7 @@ static hash_t expressionHash(Expression *e) { 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; @@ -454,7 +454,7 @@ static hash_t expressionHash(Expression *e) { 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); @@ -482,7 +482,7 @@ static hash_t expressionHash(Expression *e) 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() */ @@ -558,8 +558,8 @@ Dsymbol *TemplateDeclaration::syntaxCopy(Dsymbol *) 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, @@ -609,15 +609,15 @@ void TemplateDeclaration::semantic(Scope *sc) 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]; @@ -630,7 +630,7 @@ void TemplateDeclaration::semantic(Scope *sc) { 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; @@ -641,12 +641,12 @@ void TemplateDeclaration::semantic(Scope *sc) */ 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) @@ -798,7 +798,7 @@ bool TemplateDeclaration::evaluateConstraint( 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) @@ -852,24 +852,24 @@ MATCH TemplateDeclaration::matchWithInstance(Scope *sc, TemplateInstance *ti, 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); @@ -918,7 +918,7 @@ MATCH TemplateDeclaration::matchWithInstance(Scope *sc, TemplateInstance *ti, { if (!(*dedtypes)[i]) { - assert(i < ti->tiargs->dim); + assert(i < ti->tiargs->length); (*dedtypes)[i] = (Type *)(*ti->tiargs)[i]; } } @@ -943,7 +943,7 @@ MATCH TemplateDeclaration::matchWithInstance(Scope *sc, TemplateInstance *ti, 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; @@ -995,8 +995,8 @@ MATCH TemplateDeclaration::leastAsSpecialized(Scope *sc, TemplateDeclaration *td // 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) @@ -1010,7 +1010,7 @@ MATCH TemplateDeclaration::leastAsSpecialized(Scope *sc, TemplateDeclaration *td // 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); @@ -1064,7 +1064,7 @@ public: 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); @@ -1122,10 +1122,10 @@ MATCH TemplateDeclaration::deduceFunctionTemplateMatch( 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) @@ -1147,8 +1147,8 @@ MATCH TemplateDeclaration::deduceFunctionTemplateMatch( 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) @@ -1160,11 +1160,11 @@ MATCH TemplateDeclaration::deduceFunctionTemplateMatch( * 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]; } @@ -1178,7 +1178,7 @@ MATCH TemplateDeclaration::deduceFunctionTemplateMatch( 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); @@ -1191,18 +1191,18 @@ MATCH TemplateDeclaration::deduceFunctionTemplateMatch( 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: @@ -1221,7 +1221,7 @@ MATCH TemplateDeclaration::deduceFunctionTemplateMatch( { 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; } @@ -1239,7 +1239,7 @@ MATCH TemplateDeclaration::deduceFunctionTemplateMatch( 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 @@ -1260,7 +1260,7 @@ MATCH TemplateDeclaration::deduceFunctionTemplateMatch( 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) @@ -1314,7 +1314,7 @@ MATCH TemplateDeclaration::deduceFunctionTemplateMatch( // 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 @@ -1340,7 +1340,7 @@ MATCH TemplateDeclaration::deduceFunctionTemplateMatch( * 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) @@ -1352,7 +1352,7 @@ MATCH TemplateDeclaration::deduceFunctionTemplateMatch( 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 { @@ -1363,7 +1363,7 @@ MATCH TemplateDeclaration::deduceFunctionTemplateMatch( 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]; @@ -1407,14 +1407,14 @@ MATCH TemplateDeclaration::deduceFunctionTemplateMatch( { // 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; } @@ -1428,7 +1428,7 @@ MATCH TemplateDeclaration::deduceFunctionTemplateMatch( 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]; @@ -1474,7 +1474,7 @@ MATCH TemplateDeclaration::deduceFunctionTemplateMatch( */ 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) @@ -1484,7 +1484,7 @@ MATCH TemplateDeclaration::deduceFunctionTemplateMatch( delete xt; } } - for (size_t i = ntargs; i < dedargs->dim; i++) + for (size_t i = ntargs; i < dedargs->length; i++) { TemplateParameter *tparam = (*parameters)[i]; @@ -1583,7 +1583,7 @@ MATCH TemplateDeclaration::deduceFunctionTemplateMatch( 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) { @@ -1593,7 +1593,7 @@ MATCH TemplateDeclaration::deduceFunctionTemplateMatch( 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) { @@ -1608,7 +1608,7 @@ MATCH TemplateDeclaration::deduceFunctionTemplateMatch( 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 @@ -1839,7 +1839,7 @@ MATCH TemplateDeclaration::deduceFunctionTemplateMatch( 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) @@ -1853,7 +1853,7 @@ Lmatch: (*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()); @@ -1900,7 +1900,7 @@ Lmatch: // 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(); @@ -1939,11 +1939,11 @@ Lmatch: /* 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); @@ -2093,7 +2093,7 @@ RootObject *TemplateDeclaration::declareParameter(Scope *sc, TemplateParameter * TemplateTupleParameter *isVariadic(TemplateParameters *parameters) { - size_t dim = parameters->dim; + size_t dim = parameters->length; TemplateTupleParameter *tp = NULL; if (dim) @@ -2167,7 +2167,7 @@ void functionResolve(Match *m, Dsymbol *dstart, Loc loc, Scope *sc, 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 @@ -2333,7 +2333,7 @@ void functionResolve(Match *m, Dsymbol *dstart, Loc loc, Scope *sc, 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); @@ -2664,7 +2664,7 @@ FuncDeclaration *TemplateDeclaration::doHeaderInstantiation( { // 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(); @@ -2681,7 +2681,7 @@ FuncDeclaration *TemplateDeclaration::doHeaderInstantiation( 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()) { @@ -2740,7 +2740,7 @@ const char *TemplateDeclaration::toChars() 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) @@ -2786,7 +2786,7 @@ TemplateInstance *TemplateDeclaration::findExistingInstance(TemplateInstance *ti 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) @@ -2823,7 +2823,7 @@ void TemplateDeclaration::removeInstance(TemplateInstance *handle) 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) @@ -2844,7 +2844,7 @@ void TemplateDeclaration::removeInstance(TemplateInstance *handle) 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)) @@ -3189,7 +3189,7 @@ MATCH deduceType(RootObject *o, Scope *sc, Type *tparam, TemplateParameters *par /* Need a loc to go with the semantic routine. */ Loc loc; - if (parameters->dim) + if (parameters->length) { TemplateParameter *tp = (*parameters)[0]; loc = tp->loc; @@ -3207,11 +3207,11 @@ MATCH deduceType(RootObject *o, Scope *sc, Type *tparam, TemplateParameters *par 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) @@ -3364,7 +3364,7 @@ MATCH deduceType(RootObject *o, Scope *sc, Type *tparam, TemplateParameters *par /* Need a loc to go with the semantic routine. */ Loc loc; - if (parameters->dim) + if (parameters->length) { TemplateParameter *tp = (*parameters)[0]; loc = tp->loc; @@ -3570,7 +3570,7 @@ MATCH deduceType(RootObject *o, Scope *sc, Type *tparam, TemplateParameters *par 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 @@ -3578,7 +3578,7 @@ MATCH deduceType(RootObject *o, Scope *sc, Type *tparam, TemplateParameters *par 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(); @@ -3598,7 +3598,7 @@ MATCH deduceType(RootObject *o, Scope *sc, Type *tparam, TemplateParameters *par { // 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; @@ -3659,7 +3659,7 @@ MATCH deduceType(RootObject *o, Scope *sc, Type *tparam, TemplateParameters *par { 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]; @@ -3748,19 +3748,19 @@ MATCH deduceType(RootObject *o, Scope *sc, Type *tparam, TemplateParameters *par { //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())) { @@ -3774,9 +3774,9 @@ MATCH deduceType(RootObject *o, Scope *sc, Type *tparam, TemplateParameters *par 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: @@ -3790,12 +3790,12 @@ MATCH deduceType(RootObject *o, Scope *sc, Type *tparam, TemplateParameters *par */ 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]; @@ -3929,9 +3929,9 @@ MATCH deduceType(RootObject *o, Scope *sc, Type *tparam, TemplateParameters *par * 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(); @@ -3939,9 +3939,9 @@ MATCH deduceType(RootObject *o, Scope *sc, Type *tparam, TemplateParameters *par { /* 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; } } @@ -4014,8 +4014,8 @@ MATCH deduceType(RootObject *o, Scope *sc, Type *tparam, TemplateParameters *par { // 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); @@ -4023,8 +4023,8 @@ MATCH deduceType(RootObject *o, Scope *sc, Type *tparam, TemplateParameters *par { // 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. @@ -4074,9 +4074,9 @@ MATCH deduceType(RootObject *o, Scope *sc, Type *tparam, TemplateParameters *par * 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(); @@ -4084,9 +4084,9 @@ MATCH deduceType(RootObject *o, Scope *sc, Type *tparam, TemplateParameters *par { /* 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; } } @@ -4106,10 +4106,10 @@ MATCH deduceType(RootObject *o, Scope *sc, Type *tparam, TemplateParameters *par // 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], @@ -4133,7 +4133,7 @@ MATCH deduceType(RootObject *o, Scope *sc, Type *tparam, TemplateParameters *par } // 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; } @@ -4159,7 +4159,7 @@ MATCH deduceType(RootObject *o, Scope *sc, Type *tparam, TemplateParameters *par { //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) { @@ -4326,7 +4326,7 @@ MATCH deduceType(RootObject *o, Scope *sc, Type *tparam, TemplateParameters *par 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); @@ -4337,7 +4337,7 @@ MATCH deduceType(RootObject *o, Scope *sc, Type *tparam, TemplateParameters *par 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) { @@ -4346,7 +4346,7 @@ MATCH deduceType(RootObject *o, Scope *sc, Type *tparam, TemplateParameters *par 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; @@ -4356,7 +4356,7 @@ MATCH deduceType(RootObject *o, Scope *sc, Type *tparam, TemplateParameters *par 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; @@ -4374,10 +4374,10 @@ MATCH deduceType(RootObject *o, Scope *sc, Type *tparam, TemplateParameters *par 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); @@ -4385,11 +4385,11 @@ MATCH deduceType(RootObject *o, Scope *sc, Type *tparam, TemplateParameters *par 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) @@ -4429,9 +4429,9 @@ MATCH deduceType(RootObject *o, Scope *sc, Type *tparam, TemplateParameters *par 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; @@ -4498,7 +4498,7 @@ MATCH deduceType(RootObject *o, Scope *sc, Type *tparam, TemplateParameters *par 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)) @@ -4597,7 +4597,7 @@ bool reliesOnTident(Type *t, TemplateParameters *tparams, size_t iStart) 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)) @@ -4613,7 +4613,7 @@ bool reliesOnTident(Type *t, TemplateParameters *tparams, size_t iStart) 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) @@ -4624,7 +4624,7 @@ bool reliesOnTident(Type *t, TemplateParameters *tparams, size_t iStart) } 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) @@ -4646,7 +4646,7 @@ bool reliesOnTident(Type *t, TemplateParameters *tparams, size_t iStart) { 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); @@ -4664,7 +4664,7 @@ bool reliesOnTident(Type *t, TemplateParameters *tparams, size_t iStart) 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) @@ -4680,7 +4680,7 @@ bool reliesOnTident(Type *t, TemplateParameters *tparams, size_t iStart) //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); @@ -4695,7 +4695,7 @@ bool reliesOnTident(Type *t, TemplateParameters *tparams, size_t iStart) //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); @@ -4708,14 +4708,14 @@ bool reliesOnTident(Type *t, TemplateParameters *tparams, size_t iStart) 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); @@ -4729,7 +4729,7 @@ bool reliesOnTident(Type *t, TemplateParameters *tparams, size_t iStart) //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); @@ -4752,7 +4752,7 @@ bool reliesOnTident(Type *t, TemplateParameters *tparams, size_t iStart) 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); @@ -4763,7 +4763,7 @@ bool reliesOnTident(Type *t, TemplateParameters *tparams, size_t iStart) 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); @@ -4799,7 +4799,7 @@ bool reliesOnTident(Type *t, TemplateParameters *tparams, size_t iStart) //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)) @@ -4830,7 +4830,7 @@ bool reliesOnTident(Type *t, TemplateParameters *tparams, size_t iStart) 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)) @@ -4849,7 +4849,7 @@ bool reliesOnTident(Type *t, TemplateParameters *tparams, size_t iStart) 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); @@ -4892,7 +4892,7 @@ bool reliesOnTident(Type *t, TemplateParameters *tparams, size_t iStart) 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); @@ -4975,7 +4975,7 @@ MATCH TemplateParameter::matchArg(Loc instLoc, Scope *sc, Objects *tiargs, { RootObject *oarg; - if (i < tiargs->dim) + if (i < tiargs->length) oarg = (*tiargs)[i]; else { @@ -4983,7 +4983,7 @@ MATCH TemplateParameter::matchArg(Loc instLoc, Scope *sc, Objects *tiargs, 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) @@ -5706,7 +5706,7 @@ MATCH TemplateTupleParameter::matchArg(Loc, Scope *sc, Objects *tiargs, /* 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])) @@ -5714,17 +5714,17 @@ MATCH TemplateTupleParameter::matchArg(Loc, Scope *sc, Objects *tiargs, // 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]; } } @@ -5760,8 +5760,8 @@ void TemplateTupleParameter::print(RootObject *, RootObject *oded) 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(", "); @@ -5873,8 +5873,8 @@ Objects *TemplateInstance::arraySyntaxCopy(Objects *objs) 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; @@ -5901,19 +5901,19 @@ void TemplateInstance::semantic(Scope *sc) 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()); @@ -6124,13 +6124,13 @@ Lerror: // 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; @@ -6171,7 +6171,7 @@ Lerror: // 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); @@ -6181,8 +6181,8 @@ Lerror: * 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) @@ -6224,7 +6224,7 @@ Lerror: /* 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) @@ -6247,7 +6247,7 @@ Lerror: */ { 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(); @@ -6263,7 +6263,7 @@ Lerror: } } } - if (found_deferred_ad || Module::deferred.dim) + if (found_deferred_ad || Module::deferred.length) goto Laftersemantic; } @@ -6295,7 +6295,7 @@ Lerror: //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); @@ -6320,7 +6320,7 @@ Lerror: * 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); @@ -6331,7 +6331,7 @@ Lerror: { 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()) @@ -6365,7 +6365,7 @@ Lerror: //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; @@ -6436,7 +6436,7 @@ Lerror: //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) @@ -6547,7 +6547,7 @@ bool TemplateInstance::findTempDecl(Scope *sc, WithScopeSymbol **pwithsym) }; // 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)) @@ -6581,7 +6581,7 @@ bool TemplateInstance::updateTempDecl(Scope *sc, Dsymbol *s) 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()) @@ -6704,7 +6704,7 @@ bool TemplateInstance::semanticTiargs(Loc loc, Scope *sc, Objects *tiargs, int f 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); @@ -6730,7 +6730,7 @@ bool TemplateInstance::semanticTiargs(Loc loc, Scope *sc, Objects *tiargs, int f { // Expand tuple TypeTuple *tt = (TypeTuple *)ta; - size_t dim = tt->arguments->dim; + size_t dim = tt->arguments->length; tiargs->remove(j); if (dim) { @@ -6798,7 +6798,7 @@ bool TemplateInstance::semanticTiargs(Loc loc, Scope *sc, Objects *tiargs, int f { // Expand tuple TupleExp *te = (TupleExp *)ea; - size_t dim = te->exps->dim; + size_t dim = te->exps->length; tiargs->remove(j); if (dim) { @@ -6925,7 +6925,7 @@ bool TemplateInstance::findBestMatch(Scope *sc, Expressions *fargs) 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"); @@ -6965,13 +6965,13 @@ bool TemplateInstance::findBestMatch(Scope *sc, Expressions *fargs) // 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); @@ -7002,8 +7002,8 @@ bool TemplateInstance::findBestMatch(Scope *sc, Expressions *fargs) 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; } }; @@ -7018,7 +7018,7 @@ bool TemplateInstance::findBestMatch(Scope *sc, Expressions *fargs) 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 @@ -7061,12 +7061,12 @@ bool TemplateInstance::findBestMatch(Scope *sc, Expressions *fargs) * 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) @@ -7076,11 +7076,11 @@ bool TemplateInstance::findBestMatch(Scope *sc, Expressions *fargs) (*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]); } } @@ -7161,7 +7161,7 @@ bool TemplateInstance::needsTypeInference(Scope *sc, int flag) { 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; } @@ -7171,7 +7171,7 @@ bool TemplateInstance::needsTypeInference(Scope *sc, int flag) 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; @@ -7180,18 +7180,18 @@ bool TemplateInstance::needsTypeInference(Scope *sc, int flag) /* 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; @@ -7211,7 +7211,7 @@ bool TemplateInstance::needsTypeInference(Scope *sc, int flag) /* 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) { @@ -7251,7 +7251,7 @@ bool TemplateInstance::needsTypeInference(Scope *sc, int flag) 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++) { @@ -7287,7 +7287,7 @@ bool TemplateInstance::hasNestedArgs(Objects *args, bool isstatic) /* 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); @@ -7492,8 +7492,8 @@ Identifier *TemplateInstance::genIdent(Objects *args) } 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); @@ -7584,7 +7584,7 @@ Identifier *TemplateInstance::genIdent(Objects *args) } 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; } @@ -7620,7 +7620,7 @@ void TemplateInstance::declareParameters(Scope *sc) 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]; @@ -7654,7 +7654,7 @@ void TemplateInstance::semantic2(Scope *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->semantic2(sc); @@ -7709,7 +7709,7 @@ void TemplateInstance::semantic3(Scope *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); @@ -7884,7 +7884,7 @@ int TemplateInstance::compare(RootObject *o) 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) @@ -7913,7 +7913,7 @@ int TemplateInstance::compare(RootObject *o) { if (!fargs) goto Lnotequals; - if (fargs->dim <= j) + if (fargs->length <= j) break; Expression *farg = (*fargs)[j]; if (farg->isLvalue()) @@ -7961,7 +7961,7 @@ void unSpeculative(Scope *sc, RootObject *o) 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]); } @@ -8179,7 +8179,7 @@ bool TemplateInstance::needsCodegen() /* ======================== 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() : ""); @@ -8218,7 +8218,7 @@ bool TemplateMixin::findTempDecl(Scope *sc) 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) @@ -8264,7 +8264,7 @@ bool TemplateMixin::findTempDecl(Scope *sc) }; // 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)) @@ -8356,10 +8356,10 @@ void TemplateMixin::semantic(Scope *sc) /* 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); @@ -8426,7 +8426,7 @@ void TemplateMixin::semantic(Scope *sc) 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); @@ -8436,7 +8436,7 @@ void TemplateMixin::semantic(Scope *sc) // 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); @@ -8447,19 +8447,19 @@ void TemplateMixin::semantic(Scope *sc) 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); @@ -8471,7 +8471,7 @@ void TemplateMixin::semantic(Scope *sc) * 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) @@ -8502,7 +8502,7 @@ void TemplateMixin::semantic2(Scope *sc) 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); @@ -8521,7 +8521,7 @@ void TemplateMixin::semantic3(Scope *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); @@ -8547,7 +8547,7 @@ int TemplateMixin::apply(Dsymbol_apply_ft_t fp, void *param) 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) @@ -8566,7 +8566,7 @@ bool TemplateMixin::hasPointers() 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()); @@ -8586,7 +8586,7 @@ void TemplateMixin::setFieldOffset(AggregateDeclaration *ad, unsigned *poffset, 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()); diff --git a/gcc/d/dmd/escape.c b/gcc/d/dmd/escape.c index c7eb055fe0b..df43a7f84bb 100644 --- a/gcc/d/dmd/escape.c +++ b/gcc/d/dmd/escape.c @@ -74,12 +74,12 @@ bool checkParamArgumentEscape(Scope *sc, FuncDeclaration *fdc, Identifier *par, 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]; @@ -111,7 +111,7 @@ bool checkParamArgumentEscape(Scope *sc, FuncDeclaration *fdc, Identifier *par, } } - 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()) @@ -128,14 +128,14 @@ bool checkParamArgumentEscape(Scope *sc, FuncDeclaration *fdc, Identifier *par, } } - 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()); @@ -153,7 +153,7 @@ bool checkParamArgumentEscape(Scope *sc, FuncDeclaration *fdc, Identifier *par, } } - 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()) @@ -202,7 +202,7 @@ bool checkAssignEscape(Scope *sc, Expression *e, bool gag) 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; @@ -226,7 +226,7 @@ bool checkAssignEscape(Scope *sc, Expression *e, bool gag) 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()); @@ -309,7 +309,7 @@ bool checkAssignEscape(Scope *sc, Expression *e, bool gag) } } - 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()); @@ -352,14 +352,14 @@ bool checkAssignEscape(Scope *sc, Expression *e, bool gag) } } - 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()); @@ -392,7 +392,7 @@ bool checkAssignEscape(Scope *sc, Expression *e, bool gag) } } - 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) @@ -433,11 +433,11 @@ bool checkThrowEscape(Scope *sc, Expression *e, bool gag) 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()); @@ -528,11 +528,11 @@ static bool checkReturnEscapeImpl(Scope *sc, Expression *e, bool refs, bool gag) 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()); @@ -595,7 +595,7 @@ static bool checkReturnEscapeImpl(Scope *sc, Expression *e, bool refs, bool gag) } } - 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()); @@ -665,7 +665,7 @@ static bool checkReturnEscapeImpl(Scope *sc, Expression *e, bool refs, bool gag) } } - 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()); @@ -819,7 +819,7 @@ static void escapeByValue(Expression *e, EscapeByResults *er) { 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) @@ -832,7 +832,7 @@ static void escapeByValue(Expression *e, EscapeByResults *er) { 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) @@ -846,7 +846,7 @@ static void escapeByValue(Expression *e, EscapeByResults *er) 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) @@ -945,13 +945,13 @@ static void escapeByValue(Expression *e, EscapeByResults *er) 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); @@ -1141,14 +1141,14 @@ static void escapeByRef(Expression *e, EscapeByResults *er) 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); @@ -1216,10 +1216,10 @@ void findAllOuterAccessedVariables(FuncDeclaration *fd, VarDeclarations *vars) 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) diff --git a/gcc/d/dmd/expression.c b/gcc/d/dmd/expression.c index e4c12e3566c..0b042732da8 100644 --- a/gcc/d/dmd/expression.c +++ b/gcc/d/dmd/expression.c @@ -277,7 +277,7 @@ Expression *resolvePropertiesX(Scope *sc, Expression *e1, Expression *e2 = NULL) 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) @@ -295,7 +295,7 @@ Expression *resolvePropertiesX(Scope *sc, Expression *e1, Expression *e2 = NULL) } } { - 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) @@ -559,7 +559,7 @@ Expression *resolvePropertiesOnly(Scope *sc, Expression *e1) 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(); @@ -808,7 +808,7 @@ Expression *resolveUFCS(Scope *sc, CallExp *ce) /* 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(); @@ -968,7 +968,7 @@ bool arrayExpressionSemantic(Expressions *exps, Scope *sc, bool preserveErrors) 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) @@ -997,7 +997,7 @@ void expandTuples(Expressions *exps) //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) @@ -1011,10 +1011,10 @@ void expandTuples(Expressions *exps) { 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; @@ -1028,7 +1028,7 @@ void expandTuples(Expressions *exps) 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]; @@ -1072,17 +1072,17 @@ Lagain: 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; iobjects->dim; ++i) + for (size_t i = 0; iobjects->length; ++i) { Expression *e = isExpression((*td->objects)[i]); assert(e); @@ -1127,7 +1127,7 @@ bool arrayExpressionToCommonType(Scope *sc, Expressions *exps, Type **pt) 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) @@ -1190,7 +1190,7 @@ bool arrayExpressionToCommonType(Scope *sc, Expressions *exps, Type **pt) 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) @@ -1384,7 +1384,7 @@ bool functionParameters(Loc loc, Scope *sc, TypeFunction *tf, //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; @@ -1499,7 +1499,7 @@ bool functionParameters(Loc loc, Scope *sc, TypeFunction *tf, 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)) @@ -1947,11 +1947,11 @@ bool functionParameters(Loc loc, Scope *sc, TypeFunction *tf, // 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; @@ -2833,8 +2833,8 @@ Expressions *Expression::arraySyntaxCopy(Expressions *exps) 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; @@ -3790,14 +3790,14 @@ bool ArrayLiteralExp::equals(RootObject *o) ((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]; @@ -3834,9 +3834,9 @@ static void appendArrayLiteral(Expressions *elems, ArrayLiteralExp *ale) { 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) @@ -3876,7 +3876,7 @@ Expressions* ArrayLiteralExp::copyElements(Expression *e1, Expression *e2) 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); } @@ -3885,7 +3885,7 @@ StringExp *ArrayLiteralExp::toStringExp() 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; @@ -3894,7 +3894,7 @@ StringExp *ArrayLiteralExp::toStringExp() 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) @@ -3929,7 +3929,7 @@ AssocArrayLiteralExp::AssocArrayLiteralExp(Loc loc, 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; @@ -3943,12 +3943,12 @@ bool AssocArrayLiteralExp::equals(RootObject *o) ((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])) { @@ -3958,7 +3958,7 @@ bool AssocArrayLiteralExp::equals(RootObject *o) } } } - return count == keys->dim; + return count == keys->length; } return false; } @@ -3971,7 +3971,7 @@ Expression *AssocArrayLiteralExp::syntaxCopy() bool AssocArrayLiteralExp::isBool(bool result) { - size_t dim = keys->dim; + size_t dim = keys->length; return result ? (dim != 0) : (dim == 0); } @@ -4011,9 +4011,9 @@ bool StructLiteralExp::equals(RootObject *o) 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]; @@ -4075,10 +4075,10 @@ Expression *StructLiteralExp::getField(Type *type, unsigned offset) 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) { @@ -4121,9 +4121,9 @@ int StructLiteralExp::getFieldIndex(Type *type, unsigned offset) { /* 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]; @@ -4131,7 +4131,7 @@ int StructLiteralExp::getFieldIndex(Type *type, unsigned offset) 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) @@ -4489,8 +4489,8 @@ TupleExp::TupleExp(Loc loc, TupleDeclaration *tup) 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)) { @@ -4526,11 +4526,11 @@ bool TupleExp::equals(RootObject *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]; @@ -4562,7 +4562,7 @@ FuncExp::FuncExp(Loc loc, Dsymbol *s) 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) @@ -4685,9 +4685,9 @@ MATCH FuncExp::matchType(Type *to, Scope *sc, FuncExp **presult, int flag) 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; @@ -4909,8 +4909,8 @@ Expression *IsExp::syntaxCopy() 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, @@ -5337,7 +5337,7 @@ int modifyFieldVar(Loc loc, Scope *sc, VarDeclaration *var, Expression *e1) 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)) @@ -6808,7 +6808,7 @@ Expression *resolveOpDollar(Scope *sc, ArrayExp *ae, Expression **pe0) 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); @@ -6817,7 +6817,7 @@ Expression *resolveOpDollar(Scope *sc, ArrayExp *ae, Expression **pe0) 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(); diff --git a/gcc/d/dmd/expressionsem.c b/gcc/d/dmd/expressionsem.c index 6e3b10ef878..048752dc23b 100644 --- a/gcc/d/dmd/expressionsem.c +++ b/gcc/d/dmd/expressionsem.c @@ -91,7 +91,7 @@ static bool preFunctionParameters(Scope *sc, Expressions *exps) { expandTuples(exps); - for (size_t i = 0; i < exps->dim; i++) + for (size_t i = 0; i < exps->length; i++) { Expression *arg = (*exps)[i]; @@ -165,7 +165,7 @@ private: 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()) @@ -708,7 +708,7 @@ public: /* 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(); @@ -735,9 +735,9 @@ public: 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(); } @@ -792,7 +792,7 @@ public: 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; @@ -1060,7 +1060,7 @@ public: 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) @@ -1085,7 +1085,7 @@ public: 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()) @@ -1193,7 +1193,7 @@ public: } else { - if (exp->newargs && exp->newargs->dim) + if (exp->newargs && exp->newargs->length) { exp->error("no allocator for %s", cd->toChars()); return setError(); @@ -1233,7 +1233,7 @@ public: // 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 || @@ -1288,7 +1288,7 @@ public: } else { - if (exp->newargs && exp->newargs->dim) + if (exp->newargs && exp->newargs->length) { exp->error("no allocator for %s", sd->toChars()); return setError(); @@ -1315,7 +1315,7 @@ public: 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 @@ -1327,7 +1327,7 @@ public: 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(); } @@ -1507,7 +1507,7 @@ public: // 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); @@ -1568,7 +1568,7 @@ public: //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 @@ -1639,9 +1639,9 @@ public: // 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; @@ -1649,25 +1649,25 @@ public: 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++) @@ -1712,7 +1712,7 @@ public: 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; @@ -1986,10 +1986,10 @@ public: { 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)); @@ -2089,7 +2089,7 @@ public: } 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) @@ -2129,7 +2129,7 @@ public: 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); @@ -2151,7 +2151,7 @@ public: /* 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; @@ -2527,8 +2527,8 @@ public: 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; @@ -2977,13 +2977,13 @@ public: // 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; @@ -3056,11 +3056,11 @@ public: 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); @@ -3122,7 +3122,7 @@ public: 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); @@ -4582,7 +4582,7 @@ public: { te = (TupleExp *)exp->e1; tup = NULL; - length = te->exps->dim; + length = te->exps->length; } else if (exp->e1->op == TOKtype) // slicing a type tuple { @@ -4898,7 +4898,7 @@ public: 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) @@ -4982,7 +4982,7 @@ public: { te = (TupleExp *)exp->e1; tup = NULL; - length = te->exps->dim; + length = te->exps->length; } else if (exp->e1->op == TOKtype) { @@ -5190,10 +5190,10 @@ public: 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]; @@ -5412,11 +5412,11 @@ public: { 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) @@ -5458,13 +5458,13 @@ public: 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()); @@ -5473,7 +5473,7 @@ public: // expand initializer to tuple if (expandAliasThisTuples(iexps, u) != -1) { - if (iexps->dim <= u) + if (iexps->length <= u) break; goto Lexpand; } @@ -5857,7 +5857,7 @@ public: 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) { @@ -6002,7 +6002,7 @@ public: 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) @@ -8283,8 +8283,8 @@ Expression *semanticX(DotIdExp *exp, Scope *sc) */ 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); @@ -8300,7 +8300,7 @@ Expression *semanticX(DotIdExp *exp, Scope *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; } diff --git a/gcc/d/dmd/func.c b/gcc/d/dmd/func.c index ebbe1bb1af5..961e84a010a 100644 --- a/gcc/d/dmd/func.c +++ b/gcc/d/dmd/func.c @@ -74,9 +74,9 @@ public: 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]); @@ -86,9 +86,9 @@ public: 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]); @@ -177,9 +177,9 @@ public: { 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) @@ -815,13 +815,13 @@ void FuncDeclaration::semantic(Scope *sc) 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) @@ -845,7 +845,7 @@ void FuncDeclaration::semantic(Scope *sc) /* 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; @@ -877,7 +877,7 @@ void FuncDeclaration::semantic(Scope *sc) /* 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[] @@ -905,8 +905,8 @@ void FuncDeclaration::semantic(Scope *sc) 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) { @@ -915,7 +915,7 @@ void FuncDeclaration::semantic(Scope *sc) } } // 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); @@ -926,7 +926,7 @@ void FuncDeclaration::semantic(Scope *sc) else { // Append to end of vtbl[] - vi = (int)cd->vtbl.dim; + vi = (int)cd->vtbl.length; cd->vtbl.push(this); vtblIndex = vi; } @@ -977,7 +977,7 @@ void FuncDeclaration::semantic(Scope *sc) } 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", @@ -1045,7 +1045,7 @@ void FuncDeclaration::semantic(Scope *sc) 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: @@ -1106,7 +1106,7 @@ void FuncDeclaration::semantic(Scope *sc) { 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); @@ -1253,7 +1253,7 @@ static bool needsFensure(FuncDeclaration *fd) 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]; @@ -1417,7 +1417,7 @@ void FuncDeclaration::semantic3(Scope *sc) if (frequire) { - for (size_t i = 0; i < foverrides.dim; i++) + for (size_t i = 0; i < foverrides.length; i++) { FuncDeclaration *fdv = foverrides[i]; @@ -1610,7 +1610,7 @@ void FuncDeclaration::semantic3(Scope *sc) // 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]; @@ -1695,8 +1695,8 @@ void FuncDeclaration::semantic3(Scope *sc) */ 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; @@ -1737,7 +1737,7 @@ void FuncDeclaration::semantic3(Scope *sc) 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) @@ -1771,7 +1771,7 @@ void FuncDeclaration::semantic3(Scope *sc) * 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(); @@ -1784,7 +1784,7 @@ void FuncDeclaration::semantic3(Scope *sc) // 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()) @@ -1947,7 +1947,7 @@ void FuncDeclaration::semantic3(Scope *sc) /* 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; @@ -2085,7 +2085,7 @@ void FuncDeclaration::semantic3(Scope *sc) // 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) @@ -2172,7 +2172,7 @@ void FuncDeclaration::semantic3(Scope *sc) */ if (parameters) { - for (size_t i = 0; i < parameters->dim; i++) + for (size_t i = 0; i < parameters->length; i++) { VarDeclaration *v = (*parameters)[i]; @@ -2252,7 +2252,7 @@ void FuncDeclaration::semantic3(Scope *sc) // 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(); } @@ -2314,8 +2314,8 @@ void FuncDeclaration::semantic3(Scope *sc) 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) @@ -2658,7 +2658,7 @@ Statement *FuncDeclaration::mergeFrequire(Statement *sf) * 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]; @@ -2715,7 +2715,7 @@ Statement *FuncDeclaration::mergeFensure(Statement *sf, Identifier *oid) * 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]; @@ -2796,7 +2796,7 @@ int FuncDeclaration::overrides(FuncDeclaration *fd) } /************************************************* - * 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: @@ -2897,7 +2897,7 @@ BaseClass *FuncDeclaration::overrideInterface() 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; } @@ -3790,7 +3790,7 @@ bool FuncDeclaration::isVirtualMethod() 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; } @@ -4006,7 +4006,7 @@ bool traverseIndirections(Type *ta, Type *tb, void *p = NULL, bool reversePass = 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); @@ -4353,7 +4353,7 @@ bool FuncDeclaration::checkNestedReference(Scope *sc, Loc loc) 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; @@ -4386,7 +4386,7 @@ void markAsNeedingClosure(Dsymbol *f, FuncDeclaration *outerFunc) 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. @@ -4419,7 +4419,7 @@ bool checkEscapingSiblings(FuncDeclaration *f, FuncDeclaration *outerFunc, void //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) @@ -4479,12 +4479,12 @@ bool FuncDeclaration::needsClosure() 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); @@ -4561,11 +4561,11 @@ bool FuncDeclaration::checkClosure() } 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); @@ -4585,7 +4585,7 @@ bool FuncDeclaration::checkClosure() 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", @@ -4609,7 +4609,7 @@ bool FuncDeclaration::checkClosure() bool FuncDeclaration::hasNestedFrameRefs() { - if (closureVars.dim) + if (closureVars.length) return true; /* If a virtual function has contracts, assume its variables are referenced @@ -4622,9 +4622,9 @@ bool FuncDeclaration::hasNestedFrameRefs() 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()) diff --git a/gcc/d/dmd/hdrgen.c b/gcc/d/dmd/hdrgen.c index e14d01e51b7..156f4a6df97 100644 --- a/gcc/d/dmd/hdrgen.c +++ b/gcc/d/dmd/hdrgen.c @@ -130,7 +130,7 @@ public: 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) @@ -141,7 +141,7 @@ public: 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; @@ -167,7 +167,7 @@ public: 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) @@ -253,7 +253,7 @@ public: { 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) @@ -412,7 +412,7 @@ public: { 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); @@ -584,7 +584,7 @@ public: 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); @@ -686,7 +686,7 @@ public: 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); @@ -979,7 +979,7 @@ public: 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) @@ -1000,7 +1000,7 @@ public: 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]; @@ -1172,19 +1172,19 @@ public: { 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(", "); @@ -1217,14 +1217,14 @@ public: 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; @@ -1235,7 +1235,7 @@ public: 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); @@ -1326,7 +1326,7 @@ public: 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); @@ -1340,7 +1340,7 @@ public: 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); @@ -1360,7 +1360,7 @@ public: 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); @@ -1376,7 +1376,7 @@ public: 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); @@ -1455,7 +1455,7 @@ public: 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); @@ -1469,7 +1469,7 @@ public: 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]; @@ -1507,7 +1507,7 @@ public: 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); @@ -1555,9 +1555,9 @@ public: } 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) @@ -1621,7 +1621,7 @@ public: return; } - if (ti->tiargs->dim == 1) + if (ti->tiargs->length == 1) { RootObject *oarg = (*ti->tiargs)[0]; if (Type *t = isType(oarg)) @@ -1631,7 +1631,7 @@ public: 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; @@ -1652,7 +1652,7 @@ public: } 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) @@ -1695,7 +1695,7 @@ public: 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) @@ -1739,7 +1739,7 @@ public: 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) @@ -1763,7 +1763,7 @@ public: 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); @@ -1788,7 +1788,7 @@ public: 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); @@ -1813,7 +1813,7 @@ public: 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); @@ -1828,11 +1828,11 @@ public: 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(", "); @@ -2018,7 +2018,7 @@ public: 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; @@ -2141,7 +2141,7 @@ public: { //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(", "); @@ -2159,7 +2159,7 @@ public: 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(", "); @@ -2186,10 +2186,10 @@ public: */ 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) @@ -2277,7 +2277,7 @@ public: 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) @@ -2521,7 +2521,7 @@ public: 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]; @@ -2598,14 +2598,14 @@ public: 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); @@ -2621,14 +2621,14 @@ public: 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); @@ -2717,7 +2717,7 @@ public: 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(", "); @@ -2748,7 +2748,7 @@ public: buf->writestring(" == "); typeToBuffer(e->tspec, NULL); } - if (e->parameters && e->parameters->dim) + if (e->parameters && e->parameters->length) { buf->writestring(", "); visitTemplateParameters(e->parameters); @@ -3158,7 +3158,7 @@ public: } if (varargs) { - if (parameters->dim && varargs == 1) + if (parameters->length && varargs == 1) buf->writestring(", "); buf->writestring("..."); } @@ -3194,7 +3194,7 @@ public: 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); @@ -3433,12 +3433,12 @@ void toCBuffer(Expression *e, OutBuffer *buf, HdrGenState *hgs) */ 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) @@ -3455,12 +3455,12 @@ void toCBuffer(TemplateParameter *tp, OutBuffer *buf, HdrGenState *hgs) 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) diff --git a/gcc/d/dmd/iasmgcc.c b/gcc/d/dmd/iasmgcc.c index 089076f1ab8..5cc9025a7b3 100644 --- a/gcc/d/dmd/iasmgcc.c +++ b/gcc/d/dmd/iasmgcc.c @@ -333,7 +333,7 @@ Statement *gccAsmSemantic(GccAsmStatement *s, Scope *sc) // 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); @@ -354,7 +354,7 @@ Statement *gccAsmSemantic(GccAsmStatement *s, Scope *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); @@ -366,7 +366,7 @@ Statement *gccAsmSemantic(GccAsmStatement *s, Scope *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); diff --git a/gcc/d/dmd/init.c b/gcc/d/dmd/init.c index 1b258ac3ae7..c4a496f8b5d 100644 --- a/gcc/d/dmd/init.c +++ b/gcc/d/dmd/init.c @@ -41,8 +41,8 @@ Initializers *Initializer::arraySyntaxCopy(Initializers *ai) 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; @@ -91,10 +91,10 @@ StructInitializer::StructInitializer(Loc loc) 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(); @@ -123,10 +123,10 @@ Initializer *ArrayInitializer::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(); @@ -144,7 +144,7 @@ void ArrayInitializer::addInit(Expression *index, Initializer *value) 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; @@ -163,11 +163,11 @@ Expression *ArrayInitializer::toAssocArrayLiteral() //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) @@ -274,7 +274,7 @@ bool hasNonConstPointers(Expression *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)) diff --git a/gcc/d/dmd/initsem.c b/gcc/d/dmd/initsem.c index e4d7ad6bb88..b566ec4fa68 100644 --- a/gcc/d/dmd/initsem.c +++ b/gcc/d/dmd/initsem.c @@ -76,19 +76,19 @@ public: 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]) { @@ -177,7 +177,7 @@ public: 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 { } @@ -252,7 +252,7 @@ public: 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) @@ -289,7 +289,7 @@ public: 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); @@ -381,7 +381,7 @@ public: 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()); @@ -482,7 +482,7 @@ public: 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) { @@ -558,11 +558,11 @@ public: 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) @@ -591,10 +591,10 @@ public: 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() @@ -741,7 +741,7 @@ public: 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; @@ -783,8 +783,8 @@ public: } 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]) { @@ -806,7 +806,7 @@ public: 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(); @@ -848,7 +848,7 @@ public: { 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)) diff --git a/gcc/d/dmd/json.c b/gcc/d/dmd/json.c index 9b8b6a66cca..ba0cc6f300a 100644 --- a/gcc/d/dmd/json.c +++ b/gcc/d/dmd/json.c @@ -394,7 +394,7 @@ public: void property(const char *name, Parameters *parameters) { - if (parameters == NULL || parameters->dim == 0) + if (parameters == NULL || parameters->length == 0) return; propertyStart(name); @@ -402,7 +402,7 @@ public: 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(); @@ -512,7 +512,7 @@ public: 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); } @@ -530,9 +530,9 @@ public: 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()); @@ -553,7 +553,7 @@ public: 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) @@ -569,7 +569,7 @@ public: // 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]; @@ -583,7 +583,7 @@ public: // 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()); @@ -600,7 +600,7 @@ public: 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); @@ -660,7 +660,7 @@ public: { 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); @@ -683,11 +683,11 @@ public: 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()); @@ -721,7 +721,7 @@ public: 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(); @@ -786,7 +786,7 @@ public: 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); @@ -802,7 +802,7 @@ public: { 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); @@ -821,7 +821,7 @@ public: { 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); @@ -879,7 +879,7 @@ void json_generate(OutBuffer *buf, Modules *modules) 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) diff --git a/gcc/d/dmd/mtype.c b/gcc/d/dmd/mtype.c index 2edc1dd3bfe..8223d25be6b 100644 --- a/gcc/d/dmd/mtype.c +++ b/gcc/d/dmd/mtype.c @@ -1551,9 +1551,9 @@ Type *stripDefaultArgs(Type *t) 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); @@ -1562,8 +1562,8 @@ Type *stripDefaultArgs(Type *t) 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); @@ -2002,7 +2002,7 @@ Type *TypeFunction::substWildTo(unsigned) 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); @@ -4017,9 +4017,9 @@ void TypeSArray::resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol 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; @@ -4091,8 +4091,8 @@ Type *TypeSArray::semantic(Loc loc, Scope *sc) 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]; @@ -4178,8 +4178,8 @@ Type *TypeSArray::semantic(Loc loc, Scope *sc) 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; @@ -4757,9 +4757,9 @@ Type *TypeAArray::semantic(Loc loc, Scope *sc) 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", @@ -5303,8 +5303,8 @@ int Type::covariant(Type *t, StorageClass *pstc, bool fix17349) } 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; } @@ -5464,7 +5464,7 @@ Type *TypeFunction::semantic(Loc loc, Scope *sc) 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)); @@ -5703,13 +5703,13 @@ Type *TypeFunction::semantic(Loc loc, Scope *sc) * 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++) @@ -5752,7 +5752,7 @@ Type *TypeFunction::semantic(Loc loc, Scope *sc) */ 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()) @@ -5983,7 +5983,7 @@ MATCH TypeFunction::callMatch(Type *tthis, Expressions *args, int flag) } 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) @@ -6634,8 +6634,8 @@ Type *TypeTraits::semantic(Loc, Scope *sc) { 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) @@ -6717,8 +6717,8 @@ TypeQualified::TypeQualified(TY ty, Loc loc) 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) @@ -6817,9 +6817,9 @@ void TypeQualified::resolveTupleIndex(Loc loc, Scope *sc, Dsymbol *s, } 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; } @@ -6860,7 +6860,7 @@ void TypeQualified::resolveHelper(Loc loc, Scope *sc, 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]; @@ -7205,7 +7205,7 @@ const char *TypeInstance::kind() 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; @@ -7394,7 +7394,7 @@ void TypeTypeof::resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol goto Lerr; } } - if (idents.dim == 0) + if (idents.length == 0) *pt = t; else { @@ -7496,7 +7496,7 @@ void TypeReturn::resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol goto Lerr; } } - if (idents.dim == 0) + if (idents.length == 0) *pt = t; else { @@ -7904,8 +7904,8 @@ Expression *TypeStruct::dotExp(Scope *sc, Expression *e, Identifier *ident, int 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; @@ -8115,9 +8115,9 @@ Expression *TypeStruct::defaultInitLiteral(Loc loc) 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; @@ -8176,7 +8176,7 @@ bool TypeStruct::needsNested() 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()) @@ -8193,7 +8193,7 @@ bool TypeStruct::isAssignable() /* 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()); @@ -8227,7 +8227,7 @@ bool TypeStruct::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++) { Declaration *d = s->fields[i]; if (d->storage_class & STCref || d->hasPointers()) @@ -8242,7 +8242,7 @@ bool TypeStruct::hasVoidInitPointers() 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()) @@ -8272,7 +8272,7 @@ MATCH TypeStruct::implicitConvTo(Type *to) * 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) @@ -8465,8 +8465,8 @@ Expression *TypeClass::dotExp(Scope *sc, Expression *e, Identifier *ident, int f 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 @@ -8987,8 +8987,8 @@ TypeTuple::TypeTuple(Expressions *exps) 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"); @@ -9064,9 +9064,9 @@ bool TypeTuple::equals(RootObject *o) 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]; @@ -9085,7 +9085,7 @@ Expression *TypeTuple::getProperty(Loc loc, Identifier *ident, int flag) 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) { @@ -9106,8 +9106,8 @@ Expression *TypeTuple::getProperty(Loc loc, Identifier *ident, int flag) 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); @@ -9165,9 +9165,9 @@ Type *TypeSlice::semantic(Loc loc, Scope *sc) 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; } @@ -9217,15 +9217,15 @@ void TypeSlice::resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol 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; @@ -9236,7 +9236,7 @@ void TypeSlice::resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol */ 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]; } @@ -9341,8 +9341,8 @@ Parameters *Parameter::arraySyntaxCopy(Parameters *parameters) 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; @@ -9443,7 +9443,7 @@ int Parameter_foreach(Parameters *parameters, ForeachDg dg, void *ctx, size_t *p 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(); diff --git a/gcc/d/dmd/mtype.h b/gcc/d/dmd/mtype.h index 1146aaf3f7f..6b5c297348a 100644 --- a/gcc/d/dmd/mtype.h +++ b/gcc/d/dmd/mtype.h @@ -12,7 +12,7 @@ #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" diff --git a/gcc/d/dmd/nogc.c b/gcc/d/dmd/nogc.c index c66b93924a3..1372f4804a4 100644 --- a/gcc/d/dmd/nogc.c +++ b/gcc/d/dmd/nogc.c @@ -78,7 +78,7 @@ public: 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()) @@ -93,7 +93,7 @@ public: void visit(AssocArrayLiteralExp *e) { - if (!e->keys->dim) + if (!e->keys->length) return; if (f->setGC()) diff --git a/gcc/d/dmd/nspace.c b/gcc/d/dmd/nspace.c index 7dafc54a131..bee30e98250 100644 --- a/gcc/d/dmd/nspace.c +++ b/gcc/d/dmd/nspace.c @@ -58,7 +58,7 @@ void Nspace::addMember(Scope *sc, ScopeDsymbol *sds) 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()); @@ -77,7 +77,7 @@ void Nspace::setScope(Scope *sc) 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); @@ -107,13 +107,13 @@ void Nspace::semantic(Scope *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); @@ -133,7 +133,7 @@ void Nspace::semantic2(Scope *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); @@ -151,7 +151,7 @@ void Nspace::semantic3(Scope *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); @@ -189,7 +189,7 @@ int Nspace::apply(Dsymbol_apply_ft_t fp, void *param) { 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) @@ -208,7 +208,7 @@ bool Nspace::hasPointers() 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()); @@ -228,7 +228,7 @@ void Nspace::setFieldOffset(AggregateDeclaration *ad, unsigned *poffset, bool is 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()); diff --git a/gcc/d/dmd/opover.c b/gcc/d/dmd/opover.c index 6cc3051d3e4..21737a3a795 100644 --- a/gcc/d/dmd/opover.c +++ b/gcc/d/dmd/opover.c @@ -239,10 +239,10 @@ Expression *op_overload(Expression *e, Scope *sc) 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]; @@ -397,10 +397,10 @@ Expression *op_overload(Expression *e, Scope *sc) 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]; @@ -439,7 +439,7 @@ Expression *op_overload(Expression *e, Scope *sc) 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); @@ -1079,11 +1079,11 @@ Expression *op_overload(Expression *e, Scope *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; } @@ -1140,10 +1140,10 @@ Expression *op_overload(Expression *e, Scope *sc) 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]; @@ -1704,12 +1704,12 @@ Lerr: 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) @@ -1742,7 +1742,7 @@ bool inferApplyArgTypes(ForeachStatement *fes, Scope *sc, Dsymbol *&sapply) /* 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) @@ -1760,7 +1760,7 @@ bool inferApplyArgTypes(ForeachStatement *fes, Scope *sc, Dsymbol *&sapply) case Tarray: case Tsarray: case Ttuple: - if (fes->parameters->dim == 2) + if (fes->parameters->length == 2) { if (!p->type) { @@ -1780,7 +1780,7 @@ bool inferApplyArgTypes(ForeachStatement *fes, Scope *sc, Dsymbol *&sapply) { TypeAArray *taa = (TypeAArray *)tab; - if (fes->parameters->dim == 2) + if (fes->parameters->length == 2) { if (!p->type) { @@ -1808,7 +1808,7 @@ bool inferApplyArgTypes(ForeachStatement *fes, Scope *sc, Dsymbol *&sapply) goto Laggr; Laggr: - if (fes->parameters->dim == 1) + if (fes->parameters->length == 1) { if (!p->type) { @@ -1937,7 +1937,7 @@ static int inferApplyArgTypesY(TypeFunction *tf, Parameters *parameters, int fla 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++) diff --git a/gcc/d/dmd/optimize.c b/gcc/d/dmd/optimize.c index a79cbf805c7..fa736dc2a75 100644 --- a/gcc/d/dmd/optimize.c +++ b/gcc/d/dmd/optimize.c @@ -242,7 +242,7 @@ Expression *Expression_optimize(Expression *e, int result, bool keepLvalue) 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); } @@ -253,7 +253,7 @@ Expression *Expression_optimize(Expression *e, int result, bool keepLvalue) 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); } @@ -262,8 +262,8 @@ Expression *Expression_optimize(Expression *e, int result, bool keepLvalue) 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); @@ -277,7 +277,7 @@ Expression *Expression_optimize(Expression *e, int result, bool keepLvalue) 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); } @@ -501,7 +501,7 @@ Expression *Expression_optimize(Expression *e, int result, bool keepLvalue) // 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); } @@ -509,7 +509,7 @@ Expression *Expression_optimize(Expression *e, int result, bool keepLvalue) 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); } @@ -529,7 +529,7 @@ Expression *Expression_optimize(Expression *e, int result, bool keepLvalue) 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; @@ -1017,7 +1017,7 @@ Expression *Expression_optimize(Expression *e, int result, bool keepLvalue) 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(); diff --git a/gcc/d/dmd/parse.c b/gcc/d/dmd/parse.c index 4921cf6663c..7d858d715ce 100644 --- a/gcc/d/dmd/parse.c +++ b/gcc/d/dmd/parse.c @@ -354,8 +354,8 @@ Dsymbols *Parser::parseDeclDefs(int once, Dsymbol **pLastDecl, PrefixAttributes 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: @@ -577,8 +577,8 @@ Dsymbols *Parser::parseDeclDefs(int once, Dsymbol **pLastDecl, PrefixAttributes { 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); @@ -596,8 +596,8 @@ Dsymbols *Parser::parseDeclDefs(int once, Dsymbol **pLastDecl, PrefixAttributes ) { 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); @@ -704,8 +704,8 @@ Dsymbols *Parser::parseDeclDefs(int once, Dsymbol **pLastDecl, PrefixAttributes 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) @@ -950,7 +950,7 @@ Dsymbols *Parser::parseDeclDefs(int once, Dsymbol **pLastDecl, PrefixAttributes decldefs->push(s); addComment(s, pAttrs->comment); } - else if (a && a->dim) + else if (a && a->length) { decldefs->append(a); } @@ -3251,10 +3251,10 @@ Type *Parser::parseBasicTypeStartingAt(TypeQualified *tid, bool dontLookDotIdent 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()); } @@ -4820,7 +4820,7 @@ Statement *Parser::parseForeach(Loc loc, bool *isRange, bool isDecl) 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; @@ -5073,11 +5073,11 @@ Statement *Parser::parseStatement(int flags, const utf8_t** endPtr, Loc *pEndloc 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); @@ -5085,7 +5085,7 @@ Statement *Parser::parseStatement(int flags, const utf8_t** endPtr, Loc *pEndloc } s = new CompoundDeclarationStatement(loc, as); } - else if (a->dim == 1) + else if (a->length == 1) { Dsymbol *d = (*a)[0]; s = new ExpStatement(loc, d); @@ -5500,7 +5500,7 @@ Statement *Parser::parseStatement(int flags, const utf8_t** endPtr, Loc *pEndloc */ 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); @@ -5531,7 +5531,7 @@ Statement *Parser::parseStatement(int flags, const utf8_t** endPtr, Loc *pEndloc 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); @@ -7154,7 +7154,7 @@ Expression *Parser::parsePrimaryExp() 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(); diff --git a/gcc/d/dmd/root/array.h b/gcc/d/dmd/root/array.h index 7a02d4e53a9..fb838e69f4b 100644 --- a/gcc/d/dmd/root/array.h +++ b/gcc/d/dmd/root/array.h @@ -9,50 +9,50 @@ #pragma once #include "dsystem.h" +#include "dcompat.h" #include "object.h" #include "rmem.h" template struct Array { - d_size_t dim; - TYPE *data; + d_size_t length; private: - Array(const Array&); - - d_size_t allocdim; + DArray 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++ = ','; @@ -66,164 +66,167 @@ struct Array 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(x); - RootObject *oy = *(RootObject **)const_cast(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(x); + RootObject *oy = *(RootObject **)const_cast(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); + } + } }; + diff --git a/gcc/d/dmd/root/bitarray.h b/gcc/d/dmd/root/bitarray.h new file mode 100644 index 00000000000..fa01dd990d9 --- /dev/null +++ b/gcc/d/dmd/root/bitarray.h @@ -0,0 +1,32 @@ +/* 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&); +}; diff --git a/gcc/d/dmd/root/dcompat.h b/gcc/d/dmd/root/dcompat.h index b3207181907..dc9a7883927 100644 --- a/gcc/d/dmd/root/dcompat.h +++ b/gcc/d/dmd/root/dcompat.h @@ -18,3 +18,15 @@ struct DArray 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 diff --git a/gcc/d/dmd/root/filename.c b/gcc/d/dmd/root/filename.c index 82fcd3c31c7..88391df0f28 100644 --- a/gcc/d/dmd/root/filename.c +++ b/gcc/d/dmd/root/filename.c @@ -425,7 +425,7 @@ const char *FileName::searchPath(Strings *path, const char *name, bool cwd) 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); @@ -492,7 +492,7 @@ const char *FileName::safeSearchPath(Strings *path, const char *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]); diff --git a/gcc/d/dmd/root/rmem.h b/gcc/d/dmd/root/rmem.h index 5771ccea046..7f5e98091e9 100644 --- a/gcc/d/dmd/root/rmem.h +++ b/gcc/d/dmd/root/rmem.h @@ -8,16 +8,7 @@ #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 { diff --git a/gcc/d/dmd/root/stringtable.h b/gcc/d/dmd/root/stringtable.h index 66b62f5c05c..7df5c873c1c 100644 --- a/gcc/d/dmd/root/stringtable.h +++ b/gcc/d/dmd/root/stringtable.h @@ -9,7 +9,7 @@ #pragma once #include "root.h" -#include "rmem.h" // for d_size_t +#include "dcompat.h" // for d_size_t struct StringEntry; diff --git a/gcc/d/dmd/sapply.c b/gcc/d/dmd/sapply.c index 49442d6ea01..b15d2a8dabf 100644 --- a/gcc/d/dmd/sapply.c +++ b/gcc/d/dmd/sapply.c @@ -55,14 +55,14 @@ public: } 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); @@ -124,7 +124,7 @@ public: 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); diff --git a/gcc/d/dmd/statement.c b/gcc/d/dmd/statement.c index effc9c59f41..da305f465c9 100644 --- a/gcc/d/dmd/statement.c +++ b/gcc/d/dmd/statement.c @@ -360,7 +360,7 @@ Statement *toStatement(Dsymbol *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])); } @@ -376,7 +376,7 @@ Statement *toStatement(Dsymbol *s) 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) @@ -561,8 +561,8 @@ CompoundStatement *CompoundStatement::create(Loc loc, Statement *s1, Statement * 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; @@ -579,7 +579,7 @@ ReturnStatement *CompoundStatement::isReturnStatement() { 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) @@ -596,7 +596,7 @@ Statement *CompoundStatement::last() { 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) { @@ -619,8 +619,8 @@ CompoundDeclarationStatement::CompoundDeclarationStatement(Loc loc, Statements * 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; @@ -639,8 +639,8 @@ UnrolledLoopStatement::UnrolledLoopStatement(Loc loc, Statements *s) 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; @@ -747,8 +747,8 @@ Statements *ForwardingStatement::flatten(Scope *sc) 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; @@ -887,7 +887,7 @@ bool ForeachStatement::checkForArgTypes() { 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) @@ -1151,7 +1151,7 @@ bool SwitchStatement::checkLabel() 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)) @@ -1350,8 +1350,8 @@ TryCatchStatement::TryCatchStatement(Loc loc, Statement *body, Catches *catches) 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(); @@ -1515,7 +1515,7 @@ Statements *DebugStatement::flatten(Scope *sc) 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); @@ -1640,7 +1640,7 @@ Statements *LabelStatement::flatten(Scope *sc) a = statement->flatten(sc); if (a) { - if (!a->dim) + if (!a->length) { a->push(new ExpStatement(loc, (Expression *)NULL)); } @@ -1737,8 +1737,8 @@ CompoundAsmStatement::CompoundAsmStatement(Loc loc, Statements *s, StorageClass 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; @@ -1762,8 +1762,8 @@ ImportStatement::ImportStatement(Loc loc, Dsymbols *imports) 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); diff --git a/gcc/d/dmd/statementsem.c b/gcc/d/dmd/statementsem.c index b9aa0c95622..aac1c3094c8 100644 --- a/gcc/d/dmd/statementsem.c +++ b/gcc/d/dmd/statementsem.c @@ -127,7 +127,7 @@ public: 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) @@ -158,7 +158,7 @@ public: sexception = semantic(sexception, sc); if (sexception) { - if (i + 1 == cs->statements->dim && !sfinally) + if (i + 1 == cs->statements->length && !sfinally) { } else @@ -172,7 +172,7 @@ public: * { 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]); } @@ -206,7 +206,7 @@ public: } else if (sfinally) { - if (0 && i + 1 == cs->statements->dim) + if (0 && i + 1 == cs->statements->length) { cs->statements->push(sfinally); } @@ -218,7 +218,7 @@ public: * 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]); } @@ -241,7 +241,7 @@ public: } 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]; @@ -263,12 +263,12 @@ public: { 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; @@ -284,7 +284,7 @@ public: 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) @@ -634,7 +634,7 @@ public: 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 @@ -772,7 +772,7 @@ public: 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"); @@ -795,7 +795,7 @@ public: 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 { @@ -841,7 +841,7 @@ public: 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; @@ -915,7 +915,7 @@ public: } } - //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" : ""; @@ -1128,7 +1128,7 @@ public: !((*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, @@ -1362,17 +1362,17 @@ public: 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; } @@ -1433,7 +1433,7 @@ public: 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) @@ -1507,14 +1507,14 @@ public: 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; } } @@ -1701,7 +1701,7 @@ public: } 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 @@ -1719,7 +1719,7 @@ public: 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); @@ -2054,7 +2054,7 @@ public: { 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]; @@ -2090,7 +2090,7 @@ public: } 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 { @@ -2125,9 +2125,9 @@ public: 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; @@ -2261,7 +2261,7 @@ public: 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]; @@ -2275,7 +2275,7 @@ public: { 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]; @@ -2304,13 +2304,13 @@ public: 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()) || @@ -2459,7 +2459,7 @@ public: } 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]; @@ -2475,7 +2475,7 @@ public: 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]; @@ -2691,7 +2691,7 @@ public: { 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) @@ -2972,8 +2972,8 @@ public: 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); @@ -2997,7 +2997,7 @@ public: // return exp; // to: // vresult = exp; retrun caseDim; - rs->caseDim = sc->fes->cases->dim + 1; + rs->caseDim = sc->fes->cases->length + 1; } } if (rs->exp) @@ -3039,7 +3039,7 @@ public: * 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 @@ -3126,7 +3126,7 @@ public: * 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 @@ -3429,7 +3429,7 @@ public: /* 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); @@ -3480,7 +3480,7 @@ public: 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]; @@ -3496,7 +3496,7 @@ public: } } - if (tcs->catches->dim == 0) + if (tcs->catches->length == 0) { result = tcs->_body->hasCode() ? tcs->_body : NULL; return; @@ -3717,7 +3717,7 @@ public: 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; @@ -3739,11 +3739,11 @@ public: 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]; @@ -3766,7 +3766,7 @@ public: 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]); } diff --git a/gcc/d/dmd/traits.c b/gcc/d/dmd/traits.c index 616597d7e1e..c38a4abdb49 100644 --- a/gcc/d/dmd/traits.c +++ b/gcc/d/dmd/traits.c @@ -97,7 +97,7 @@ static void collectUnitTests(Dsymbols *symbols, AA *uniqueUnitTests, Expressions { 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(); @@ -143,9 +143,9 @@ bool isTypeFinalClass(Type *t) { return t->toBasetype()->ty == Tclass && ( 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)) @@ -163,9 +163,9 @@ bool isFuncOverrideFunction(FuncDeclaration *f) { return f->isOverride(); } 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) @@ -183,9 +183,9 @@ bool isDeclLazy(Declaration *d) { return (d->storage_class & STClazy) != 0; } 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) @@ -309,9 +309,9 @@ bool isTemplate(Dsymbol *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)) @@ -332,7 +332,7 @@ Expression *isSymbolX(TraitsExp *e, bool (*fp)(Dsymbol *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(); @@ -430,7 +430,7 @@ Expression *pointerBitmap(TraitsExp *e) 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; @@ -451,7 +451,7 @@ Expression *pointerBitmap(TraitsExp *e) 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; @@ -497,7 +497,7 @@ Expression *semanticTraits(TraitsExp *e, Scope *sc) 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) { @@ -1242,7 +1242,7 @@ Expression *semanticTraits(TraitsExp *e, Scope *sc) /* 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) @@ -1278,12 +1278,12 @@ Expression *semanticTraits(TraitsExp *e, Scope *sc) { 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); } } @@ -1294,7 +1294,7 @@ Expression *semanticTraits(TraitsExp *e, Scope *sc) // 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(id->toChars())); diff --git a/gcc/d/dmd/typesem.c b/gcc/d/dmd/typesem.c index 2d194736127..2933e983b01 100644 --- a/gcc/d/dmd/typesem.c +++ b/gcc/d/dmd/typesem.c @@ -82,7 +82,7 @@ Expression *typeToExpression(Type *t) 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()); diff --git a/gcc/d/expr.cc b/gcc/d/expr.cc index d1e71f987f7..461124f704e 100644 --- a/gcc/d/expr.cc +++ b/gcc/d/expr.cc @@ -1642,7 +1642,7 @@ public: { 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]; @@ -2439,7 +2439,7 @@ public: { /* 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, @@ -2464,9 +2464,9 @@ public: 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]; @@ -2488,14 +2488,14 @@ public: 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 *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)); @@ -2516,7 +2516,7 @@ public: 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); @@ -2544,7 +2544,7 @@ public: 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), @@ -2661,7 +2661,7 @@ public: 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)); @@ -2688,7 +2688,7 @@ public: 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), @@ -2703,14 +2703,14 @@ public: /* Build an expression that assigns the expressions in ELEMENTS to a constructor. */ vec *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_); @@ -2749,7 +2749,7 @@ public: 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); @@ -2769,12 +2769,12 @@ public: 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, @@ -2784,7 +2784,7 @@ public: 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); } @@ -2802,7 +2802,7 @@ public: /* 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; @@ -2811,35 +2811,35 @@ public: /* Build an expression that assigns all expressions in KEYS to a constructor. */ vec *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 *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, @@ -2859,7 +2859,7 @@ public: 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; @@ -2879,12 +2879,12 @@ public: 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) @@ -2921,7 +2921,7 @@ public: } /* 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); @@ -2989,8 +2989,8 @@ public: vec *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_)); diff --git a/gcc/d/modules.cc b/gcc/d/modules.cc index 4f541905a94..0ff41630f05 100644 --- a/gcc/d/modules.cc +++ b/gcc/d/modules.cc @@ -506,8 +506,8 @@ layout_moduleinfo_fields (Module *decl, tree type) /* 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) @@ -523,16 +523,17 @@ layout_moduleinfo_fields (Module *decl, tree type) /* 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); } @@ -556,14 +557,14 @@ layout_moduleinfo (Module *decl) 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) @@ -589,7 +590,7 @@ layout_moduleinfo (Module *decl) flags |= MIunitTest; if (aimports_dim) flags |= MIimportedModules; - if (aclasses.dim) + if (aclasses.length) flags |= MIlocalClasses; if (!decl->needmoduleinfo) flags |= MIstandalone; @@ -652,7 +653,7 @@ layout_moduleinfo (Module *decl) 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) @@ -671,16 +672,16 @@ layout_moduleinfo (Module *decl) if (flags & MIlocalClasses) { vec *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)); } @@ -722,7 +723,7 @@ build_module_tree (Module *decl) /* 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); diff --git a/gcc/d/toir.cc b/gcc/d/toir.cc index 074cde0e0da..92d0ecdb0a0 100644 --- a/gcc/d/toir.cc +++ b/gcc/d/toir.cc @@ -812,12 +812,12 @@ public: /* 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 *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; @@ -840,7 +840,7 @@ public: /* 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); @@ -858,7 +858,7 @@ public: 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); @@ -1049,7 +1049,7 @@ public: 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]; @@ -1070,7 +1070,7 @@ public: 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]; @@ -1175,7 +1175,7 @@ public: 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]; @@ -1301,7 +1301,7 @@ public: /* 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; @@ -1331,7 +1331,7 @@ public: /* 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 @@ -1346,7 +1346,7 @@ public: 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]; @@ -1372,7 +1372,7 @@ public: 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; @@ -1447,7 +1447,7 @@ public: 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]; diff --git a/gcc/d/typeinfo.cc b/gcc/d/typeinfo.cc index 6aa4f64a713..fdeb70030cb 100644 --- a/gcc/d/typeinfo.cc +++ b/gcc/d/typeinfo.cc @@ -417,7 +417,7 @@ class TypeInfoVisitor : public Visitor /* 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); @@ -430,7 +430,7 @@ class TypeInfoVisitor : public Visitor size_t offset; */ vec *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; @@ -451,7 +451,7 @@ class TypeInfoVisitor : public Visitor 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); } @@ -463,7 +463,7 @@ class TypeInfoVisitor : public Visitor 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); @@ -483,7 +483,7 @@ class TypeInfoVisitor : public Visitor vec *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. */ @@ -500,7 +500,7 @@ class TypeInfoVisitor : public Visitor 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) @@ -510,7 +510,7 @@ class TypeInfoVisitor : public Visitor } } - 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); @@ -827,12 +827,12 @@ public: 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); @@ -884,7 +884,7 @@ public: 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 ()) @@ -933,7 +933,7 @@ public: 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); @@ -974,13 +974,13 @@ public: 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); } } @@ -1134,9 +1134,9 @@ public: this->layout_base (Type::typeinfotypelist); /* TypeInfo[] elements; */ - Type *satype = Type::tvoidptr->sarrayOf (ti->arguments->dim); + Type *satype = Type::tvoidptr->sarrayOf (ti->arguments->length); vec *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), @@ -1145,7 +1145,7 @@ public: 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)); @@ -1193,7 +1193,7 @@ layout_classinfo_interfaces (ClassDeclaration *decl) 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; @@ -1202,28 +1202,28 @@ layout_classinfo_interfaces (ClassDeclaration *decl) /* 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; } } } @@ -1231,23 +1231,23 @@ layout_classinfo_interfaces (ClassDeclaration *decl) /* 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; } } } @@ -1732,7 +1732,7 @@ public: 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) diff --git a/gcc/d/types.cc b/gcc/d/types.cc index 59a90b49243..1f43352885a 100644 --- a/gcc/d/types.cc +++ b/gcc/d/types.cc @@ -268,7 +268,7 @@ layout_aggregate_members (Dsymbols *members, tree context, bool inherited_p) { 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 (); @@ -285,7 +285,7 @@ layout_aggregate_members (Dsymbols *members, tree context, bool inherited_p) 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); @@ -409,7 +409,7 @@ layout_aggregate_type (AggregateDeclaration *decl, tree type, /* 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); @@ -429,7 +429,7 @@ layout_aggregate_type (AggregateDeclaration *decl, tree type, 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); @@ -442,12 +442,12 @@ layout_aggregate_type (AggregateDeclaration *decl, tree type, { 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); @@ -836,7 +836,7 @@ public: 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 @@ -972,7 +972,7 @@ public: } /* 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; -- 2.30.2