Rename Id.index to Id.opIndex etc. (#20771)

This commit is contained in:
Dennis 2025-01-24 11:31:25 +01:00 committed by GitHub
parent 3166ce1646
commit e5bd2d06aa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 75 additions and 75 deletions

View file

@ -101,7 +101,7 @@ StorageClass mergeFuncAttrs(StorageClass s1, const FuncDeclaration f) pure @safe
*/
FuncDeclaration hasIdentityOpAssign(AggregateDeclaration ad, Scope* sc)
{
Dsymbol assign = search_function(ad, Id.assign);
Dsymbol assign = search_function(ad, Id.opAssign);
if (!assign)
return null;
@ -303,7 +303,7 @@ FuncDeclaration buildOpAssign(StructDeclaration sd, Scope* sc)
auto fparams = new Parameters();
fparams.push(new Parameter(loc, STC.nodtor, sd.type, Id.p, null, null));
auto tf = new TypeFunction(ParameterList(fparams), sd.handleType(), LINK.d, stc | STC.ref_);
auto fop = new FuncDeclaration(declLoc, Loc.initial, Id.assign, stc, tf);
auto fop = new FuncDeclaration(declLoc, Loc.initial, Id.opAssign, stc, tf);
fop.storage_class |= STC.inference;
fop.isGenerated = true;
Expression e;
@ -482,7 +482,7 @@ bool needOpEquals(StructDeclaration sd)
private FuncDeclaration hasIdentityOpEquals(AggregateDeclaration ad, Scope* sc)
{
FuncDeclaration f;
Dsymbol eq = search_function(ad, Id.eq);
Dsymbol eq = search_function(ad, Id.opEquals);
if (!eq)
return null;
@ -564,7 +564,7 @@ FuncDeclaration buildXopEquals(StructDeclaration sd, Scope* sc)
return null; // bitwise comparison would work
//printf("StructDeclaration::buildXopEquals() %s\n", sd.toChars());
if (Dsymbol eq = search_function(sd, Id.eq))
if (Dsymbol eq = search_function(sd, Id.opEquals))
{
if (FuncDeclaration fd = eq.isFuncDeclaration())
{
@ -639,7 +639,7 @@ FuncDeclaration buildXopEquals(StructDeclaration sd, Scope* sc)
FuncDeclaration buildXopCmp(StructDeclaration sd, Scope* sc)
{
//printf("StructDeclaration::buildXopCmp() %s\n", toChars());
if (Dsymbol cmp = search_function(sd, Id.cmp))
if (Dsymbol cmp = search_function(sd, Id.opCmp))
{
if (FuncDeclaration fd = cmp.isFuncDeclaration())
{
@ -667,7 +667,7 @@ FuncDeclaration buildXopCmp(StructDeclaration sd, Scope* sc)
* Consider 'alias this', but except opDispatch.
*/
Expression e = new DsymbolExp(sd.loc, sd);
e = new DotIdExp(sd.loc, e, Id.cmp);
e = new DotIdExp(sd.loc, e, Id.opCmp);
Scope* sc2 = sc.push();
e = e.trySemantic(sc2);
sc2.pop();
@ -688,7 +688,7 @@ FuncDeclaration buildXopCmp(StructDeclaration sd, Scope* sc)
default:
break;
}
if (!s || s.ident != Id.cmp)
if (!s || s.ident != Id.opCmp)
e = null; // there's no valid member 'opCmp'
}
if (!e)
@ -736,7 +736,7 @@ FuncDeclaration buildXopCmp(StructDeclaration sd, Scope* sc)
fop.parent = sd;
Expression e1 = new IdentifierExp(loc, Id.This);
Expression e2 = new IdentifierExp(loc, Id.p);
Expression e = new CallExp(loc, new DotIdExp(loc, e1, Id.cmp), e2);
Expression e = new CallExp(loc, new DotIdExp(loc, e1, Id.opCmp), e2);
fop.fbody = new ReturnStatement(loc, e);
const errors = global.startGagging(); // Do not report errors
Scope* sc2 = sc.push();

View file

@ -3061,7 +3061,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
if (sd.ctor)
{
Dsymbol scall = sd.search(Loc.initial, Id.call);
Dsymbol scall = sd.search(Loc.initial, Id.opCall);
if (scall)
{
const xerrors = global.startGagging();

View file

@ -663,7 +663,7 @@ Expression resolveOpDollar(Scope* sc, ArrayExp ae, Expression* pe0)
assert(!ae.lengthVar);
*pe0 = null;
AggregateDeclaration ad = isAggregate(ae.e1.type);
Dsymbol slice = search_function(ad, Id.slice);
Dsymbol slice = search_function(ad, Id.opSlice);
//printf("slice = %s %s\n", slice.kind(), slice.toChars());
Expression fallback()
{
@ -6206,7 +6206,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
return;
}
// No constructor, look for overload of opCall
if (search_function(sd, Id.call))
if (search_function(sd, Id.opCall))
goto L1;
// overload of opCall, therefore it's a call
if (exp.e1.op != EXP.type)
@ -6247,7 +6247,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
{
L1:
// Rewrite as e1.call(arguments)
Expression e = new DotIdExp(exp.loc, exp.e1, Id.call);
Expression e = new DotIdExp(exp.loc, exp.e1, Id.opCall);
e = new CallExp(exp.loc, e, exp.arguments, exp.names);
e = e.expressionSemantic(sc);
result = e;
@ -7933,7 +7933,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
{
const callExpIdent = callExpFunc.ident;
isEqualsCallExpression = callExpIdent == Id.__equals ||
callExpIdent == Id.eq;
callExpIdent == Id.opEquals;
}
}
if (op == EXP.equal || op == EXP.notEqual ||
@ -9451,8 +9451,8 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
error(exp.loc, "upper and lower bounds are needed to slice a pointer");
if (auto ad = isAggregate(tp.next.toBasetype()))
{
auto s = search_function(ad, Id.index);
if (!s) s = search_function(ad, Id.slice);
auto s = search_function(ad, Id.opIndex);
if (!s) s = search_function(ad, Id.opSlice);
if (s)
{
auto fd = s.isFuncDeclaration();
@ -10305,7 +10305,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
AggregateDeclaration ad = isAggregate(t1b);
if (!ad)
break;
if (search_function(ad, Id.indexass))
if (search_function(ad, Id.opIndexAssign))
{
// Deal with $
res = resolveOpDollar(sc, ae, &e0);
@ -10324,7 +10324,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
*/
Expressions* a = ae.arguments.copy();
a.insert(0, exp.e2);
res = new DotIdExp(exp.loc, ae.e1, Id.indexass);
res = new DotIdExp(exp.loc, ae.e1, Id.opIndexAssign);
res = new CallExp(exp.loc, res, a);
if (maybeSlice) // a[] = e2 might be: a.opSliceAssign(e2)
res = res.trySemantic(sc);
@ -10335,7 +10335,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
}
Lfallback:
if (maybeSlice && search_function(ad, Id.sliceass))
if (maybeSlice && search_function(ad, Id.opSliceAssign))
{
// Deal with $
res = resolveOpDollar(sc, ae, ie, &e0);
@ -10358,7 +10358,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
a.push(ie.lwr);
a.push(ie.upr);
}
res = new DotIdExp(exp.loc, ae.e1, Id.sliceass);
res = new DotIdExp(exp.loc, ae.e1, Id.opSliceAssign);
res = new CallExp(exp.loc, res, a);
res = res.expressionSemantic(sc);
return setResult(Expression.combine(e0, res));
@ -10893,14 +10893,14 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
result = e;
return;
}
if (search_function(sd, Id.call))
if (search_function(sd, Id.opCall))
{
/* Look for static opCall
* https://issues.dlang.org/show_bug.cgi?id=2702
* Rewrite as:
* e1 = typeof(e1).opCall(arguments)
*/
e2x = typeDotIdExp(e2x.loc, e1x.type, Id.call);
e2x = typeDotIdExp(e2x.loc, e1x.type, Id.opCall);
e2x = new CallExp(exp.loc, e2x, exp.e2);
e2x = e2x.expressionSemantic(sc);
@ -11410,7 +11410,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
if (e2x.op == EXP.error && exp.op == EXP.construct && t1.ty == Tstruct)
{
scope sd = (cast(TypeStruct)t1).sym;
Dsymbol opAssign = search_function(sd, Id.assign);
Dsymbol opAssign = search_function(sd, Id.opAssign);
// and the struct defines an opAssign
if (opAssign)
@ -16359,7 +16359,7 @@ Expression toBoolean(Expression exp, Scope* sc)
/* Don't really need to check for opCast first, but by doing so we
* get better error messages if it isn't there.
*/
if (Dsymbol fd = search_function(ad, Id._cast))
if (Dsymbol fd = search_function(ad, Id.opCast))
{
e = new CastExp(exp.loc, e, Type.tbool);
e = e.expressionSemantic(sc);

View file

@ -8819,15 +8819,15 @@ struct Id final
static Identifier* system;
static Identifier* disable;
static Identifier* _dollar;
static Identifier* eq;
static Identifier* cmp;
static Identifier* assign;
static Identifier* index;
static Identifier* indexass;
static Identifier* slice;
static Identifier* sliceass;
static Identifier* call;
static Identifier* _cast;
static Identifier* opEquals;
static Identifier* opCmp;
static Identifier* opAssign;
static Identifier* opIndex;
static Identifier* opIndexAssign;
static Identifier* opSlice;
static Identifier* opSliceAssign;
static Identifier* opCall;
static Identifier* opCast;
static Identifier* opDot;
static Identifier* opDispatch;
static Identifier* opDollar;

View file

@ -223,15 +223,15 @@ immutable Msgtable[] msgtable =
{ "__LOCAL_SIZE" },
// For operator overloads
{ "eq", "opEquals" },
{ "cmp", "opCmp" },
{ "assign", "opAssign" },
{ "index", "opIndex" },
{ "indexass", "opIndexAssign" },
{ "slice", "opSlice" },
{ "sliceass", "opSliceAssign" },
{ "call", "opCall" },
{ "_cast", "opCast" },
{ "opEquals" },
{ "opCmp" },
{ "opAssign" },
{ "opIndex" },
{ "opIndexAssign" },
{ "opSlice" },
{ "opSliceAssign" },
{ "opCall" },
{ "opCast" },
{ "opDot" },
{ "opDispatch" },
{ "opDollar" },

View file

@ -489,7 +489,7 @@ Initializer initializerSemantic(Initializer init, Scope* sc, ref Type tx, NeedIn
else
i.exp = e.optimize(WANTvalue);
}
else if (search_function(sd, Id.call))
else if (search_function(sd, Id.opCall))
{
/* https://issues.dlang.org/show_bug.cgi?id=1547
*
@ -499,7 +499,7 @@ Initializer initializerSemantic(Initializer init, Scope* sc, ref Type tx, NeedIn
* i.exp = typeof(sd).opCall(arguments)
*/
Expression e = typeDotIdExp(i.loc, sd.type, Id.call);
Expression e = typeDotIdExp(i.loc, sd.type, Id.opCall);
e = new CallExp(i.loc, e, i.exp);
e = e.expressionSemantic(sc);
e = resolveProperties(sc, e);

View file

@ -60,11 +60,11 @@ package CppOperator isCppOperator(const scope Identifier id)
{
with (Id) with (CppOperator)
{
return (id == _cast) ? Cast :
(id == assign) ? Assign :
(id == eq) ? Eq :
(id == index) ? Index :
(id == call) ? Call :
return (id == opCast) ? Cast :
(id == opAssign) ? Assign :
(id == opEquals) ? Eq :
(id == opIndex) ? Index :
(id == opCall) ? Call :
(id == opUnary) ? Unary :
(id == opBinary) ? Binary :
(id == opOpAssign) ? OpAssign :
@ -1102,13 +1102,13 @@ private final class CppMangleVisitor : Visitor
buf.writestring(ctor.isCpCtor ? "C2" : "C1");
else if (d.isAggregateDtor())
buf.writestring("D1");
else if (d.ident && d.ident == Id.assign)
else if (d.ident && d.ident == Id.opAssign)
buf.writestring("aS");
else if (d.ident && d.ident == Id.eq)
else if (d.ident && d.ident == Id.opEquals)
buf.writestring("eq");
else if (d.ident && d.ident == Id.index)
else if (d.ident && d.ident == Id.opIndex)
buf.writestring("ix");
else if (d.ident && d.ident == Id.call)
else if (d.ident && d.ident == Id.opCall)
buf.writestring("cl");
else
source_name(d, true);

View file

@ -1080,13 +1080,13 @@ string mangleSpecialName(Dsymbol sym)
mangle = "?1";
else if (!sym.ident)
return null;
else if (sym.ident == Id.assign)
else if (sym.ident == Id.opAssign)
mangle = "?4";
else if (sym.ident == Id.eq)
else if (sym.ident == Id.opEquals)
mangle = "?8";
else if (sym.ident == Id.index)
else if (sym.ident == Id.opIndex)
mangle = "?A";
else if (sym.ident == Id.call)
else if (sym.ident == Id.opCall)
mangle = "?R";
else if (sym.ident == Id.cppdtor)
mangle = "?_G";

View file

@ -111,10 +111,10 @@ private bool isAssignmentOpId(Identifier id)
{
import dmd.id : Id;
return id == Id.assign
|| id == Id.indexass
|| id == Id.slice
|| id == Id.sliceass
return id == Id.opAssign
|| id == Id.opIndexAssign
|| id == Id.opSlice
|| id == Id.opSliceAssign
|| id == Id.opOpAssign
|| id == Id.opIndexOpAssign
|| id == Id.opSliceOpAssign;

View file

@ -355,7 +355,7 @@ Expression opOverloadArray(ArrayExp ae, Scope* sc)
}
break;
}
if (search_function(ad, Id.index))
if (search_function(ad, Id.opIndex))
{
// Deal with $
result = resolveOpDollar(sc, ae, &e0);
@ -367,7 +367,7 @@ Expression opOverloadArray(ArrayExp ae, Scope* sc)
* e1.opIndex(arguments)
*/
Expressions* a = ae.arguments.copy();
result = new DotIdExp(ae.loc, ae.e1, Id.index);
result = new DotIdExp(ae.loc, ae.e1, Id.opIndex);
result = new CallExp(ae.loc, result, a);
if (maybeSlice) // a[] might be: a.opSlice()
result = result.trySemantic(sc);
@ -386,7 +386,7 @@ Expression opOverloadArray(ArrayExp ae, Scope* sc)
result = Expression.combine(e0, result);
return result;
}
if (maybeSlice && search_function(ad, Id.slice))
if (maybeSlice && search_function(ad, Id.opSlice))
{
// Deal with $
result = resolveOpDollar(sc, ae, ie, &e0);
@ -407,7 +407,7 @@ Expression opOverloadArray(ArrayExp ae, Scope* sc)
a.push(ie.lwr);
a.push(ie.upr);
}
result = new DotIdExp(ae.loc, ae.e1, Id.slice);
result = new DotIdExp(ae.loc, ae.e1, Id.opSlice);
result = new CallExp(ae.loc, result, a);
result = result.expressionSemantic(sc);
result = Expression.combine(e0, result);
@ -444,7 +444,7 @@ Expression opOverloadCast(CastExp e, Scope* sc, Type att = null)
/* Rewrite as:
* e1.opCast!(T)()
*/
fd = search_function(ad, Id._cast);
fd = search_function(ad, Id.opCast);
if (fd)
{
version (all)
@ -554,7 +554,7 @@ Expression opOverloadAssign(AssignExp e, Scope* sc)
return null;
}
}
Dsymbol s = search_function(ad1, Id.assign);
Dsymbol s = search_function(ad1, Id.opAssign);
bool choseReverse;
if (auto result = pickBestBinaryOverload(sc, null, s, null, e, choseReverse))
@ -658,7 +658,7 @@ Expression opOverloadEqual(EqualExp e, Scope* sc)
Expression result = new IdentifierExp(e.loc, Id.empty);
result = new DotIdExp(e.loc, result, Id.object);
result = new DotIdExp(e.loc, result, Id.eq);
result = new DotIdExp(e.loc, result, Id.opEquals);
result = new CallExp(e.loc, result, e1x, e2x);
if (e.op == EXP.notEqual)
result = new NotExp(e.loc, result);
@ -668,7 +668,7 @@ Expression opOverloadEqual(EqualExp e, Scope* sc)
}
EXP cmpOp;
if (Expression result = compare_overload(e, sc, Id.eq, cmpOp))
if (Expression result = compare_overload(e, sc, Id.opEquals, cmpOp))
{
if (lastComma(result).op == EXP.call && e.op == EXP.notEqual)
{
@ -783,7 +783,7 @@ Expression opOverloadCmp(CmpExp exp, Scope* sc)
{
//printf("CmpExp:: () (%s)\n", e.toChars());
EXP cmpOp = exp.op;
auto e = compare_overload(exp, sc, Id.cmp, cmpOp);
auto e = compare_overload(exp, sc, Id.opCmp, cmpOp);
if (!e)
return null;

View file

@ -270,7 +270,7 @@ private extern(C++) final class Semantic3Visitor : Visitor
//{ static int x; if (++x == 2) *(char*)0=0; }
//printf("\tlinkage = %d\n", sc.linkage);
if (funcdecl.ident == Id.assign && !funcdecl.inuse)
if (funcdecl.ident == Id.opAssign && !funcdecl.inuse)
{
if (funcdecl.storage_class & STC.inference)
{

View file

@ -2025,7 +2025,7 @@ Type typeSemantic(Type type, const ref Loc loc, Scope* sc)
}
else if (sd.xeq == sd.xerreq)
{
if (search_function(sd, Id.eq))
if (search_function(sd, Id.opEquals))
{
.error(loc, "%sAA key type `%s` does not have `bool opEquals(ref const %s) const`", s, sd.toChars(), sd.toChars());
}
@ -2037,7 +2037,7 @@ Type typeSemantic(Type type, const ref Loc loc, Scope* sc)
}
else if (!sd.xhash)
{
if (search_function(sd, Id.eq))
if (search_function(sd, Id.opEquals))
{
.error(loc, "%sAA key type `%s` should have `extern (D) size_t toHash() const nothrow @safe` if `opEquals` defined", s, sd.toChars());
}
@ -2075,9 +2075,9 @@ Type typeSemantic(Type type, const ref Loc loc, Scope* sc)
__gshared FuncDeclaration fcmp = null;
__gshared FuncDeclaration fhash = null;
if (!feq)
feq = search_function(ClassDeclaration.object, Id.eq).isFuncDeclaration();
feq = search_function(ClassDeclaration.object, Id.opEquals).isFuncDeclaration();
if (!fcmp)
fcmp = search_function(ClassDeclaration.object, Id.cmp).isFuncDeclaration();
fcmp = search_function(ClassDeclaration.object, Id.opCmp).isFuncDeclaration();
if (!fhash)
fhash = search_function(ClassDeclaration.object, Id.tohash).isFuncDeclaration();
assert(fcmp && feq && fhash);
@ -3417,7 +3417,7 @@ Expression getProperty(Type t, Scope* scope_, const ref Loc loc, Identifier iden
if (s)
error(loc, "no property `%s` for type `%s`, did you mean `%s`?", ident.toChars(), mt.toChars(), s.toPrettyChars());
else if (ident == Id.call && mt.ty == Tclass)
else if (ident == Id.opCall && mt.ty == Tclass)
error(loc, "no property `%s` for type `%s`, did you mean `new %s`?", ident.toChars(), mt.toChars(), mt.toPrettyChars());
else if (const n = importHint(ident.toString()))