diff options
author | Iain Buclaw <ibuclaw@gdcproject.org> | 2020-06-04 22:36:26 +0200 |
---|---|---|
committer | Iain Buclaw <ibuclaw@gdcproject.org> | 2020-06-04 23:27:12 +0200 |
commit | 2cbc99d18dc411ac3fdef94e22ce86859806e63c (patch) | |
tree | 82939940413c5e726889ccd97fa2afd33e0b06be /gcc/d/dmd/expression.c | |
parent | 4e05c918d28e3fa66f5baaf556f6886447c68c9a (diff) | |
download | gcc-2cbc99d18dc411ac3fdef94e22ce86859806e63c.zip gcc-2cbc99d18dc411ac3fdef94e22ce86859806e63c.tar.gz gcc-2cbc99d18dc411ac3fdef94e22ce86859806e63c.tar.bz2 |
d: Merge upstream dmd 48d704f08
Updates the Array interface in dmd/root/array.h to use a DArray<TYPE>
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.
Diffstat (limited to 'gcc/d/dmd/expression.c')
-rw-r--r-- | gcc/d/dmd/expression.c | 108 |
1 files changed, 54 insertions, 54 deletions
diff --git a/gcc/d/dmd/expression.c b/gcc/d/dmd/expression.c index e4c12e3..0b04273 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; i<td->objects->dim; ++i) + for (size_t i = 0; i<td->objects->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(); |