diff --git a/compiler/src/dmd/astbase.d b/compiler/src/dmd/astbase.d index a2ebd19d40f8..dc388b286321 100644 --- a/compiler/src/dmd/astbase.d +++ b/compiler/src/dmd/astbase.d @@ -2004,18 +2004,18 @@ struct ASTBase extern (C++) final class ForeachRangeStatement : Statement { TOK op; // TOK.foreach_ or TOK.foreach_reverse_ - Parameter prm; // loop index variable + Parameter param; // loop index variable Expression lwr; Expression upr; Statement _body; Loc endloc; // location of closing curly bracket - extern (D) this(const ref Loc loc, TOK op, Parameter prm, Expression lwr, Expression upr, Statement _body, Loc endloc) + extern (D) this(const ref Loc loc, TOK op, Parameter param, Expression lwr, Expression upr, Statement _body, Loc endloc) { super(loc, STMT.ForeachRange); this.op = op; - this.prm = prm; + this.param = param; this.lwr = lwr; this.upr = upr; this._body = _body; @@ -2054,17 +2054,17 @@ struct ASTBase extern (C++) final class IfStatement : Statement { - Parameter prm; + Parameter param; Expression condition; Statement ifbody; Statement elsebody; VarDeclaration match; // for MatchExpression results Loc endloc; // location of closing curly bracket - extern (D) this(const ref Loc loc, Parameter prm, Expression condition, Statement ifbody, Statement elsebody, Loc endloc) + extern (D) this(const ref Loc loc, Parameter param, Expression condition, Statement ifbody, Statement elsebody, Loc endloc) { super(loc, STMT.If); - this.prm = prm; + this.param = param; this.condition = condition; this.ifbody = ifbody; this.elsebody = elsebody; diff --git a/compiler/src/dmd/cond.d b/compiler/src/dmd/cond.d index cffc412367d2..f66f14af5b91 100644 --- a/compiler/src/dmd/cond.d +++ b/compiler/src/dmd/cond.d @@ -322,7 +322,7 @@ extern (C++) final class StaticForeach : RootObject { foreach (params; pparams) { - auto p = aggrfe ? (*aggrfe.parameters)[i] : rangefe.prm; + auto p = aggrfe ? (*aggrfe.parameters)[i] : rangefe.param; params.push(new Parameter(aloc, p.storageClass, p.type, p.ident, null, null)); } } diff --git a/compiler/src/dmd/frontend.h b/compiler/src/dmd/frontend.h index e1daf615fa44..e98c1f64d1e6 100644 --- a/compiler/src/dmd/frontend.h +++ b/compiler/src/dmd/frontend.h @@ -4917,7 +4917,7 @@ class ForeachRangeStatement final : public Statement { public: TOK op; - Parameter* prm; + Parameter* param; Expression* lwr; Expression* upr; Statement* _body; @@ -5007,7 +5007,7 @@ class GotoStatement final : public Statement class IfStatement final : public Statement { public: - Parameter* prm; + Parameter* param; Expression* condition; Statement* ifbody; Statement* elsebody; diff --git a/compiler/src/dmd/hdrgen.d b/compiler/src/dmd/hdrgen.d index cfe4262ce44f..a5e897d62466 100644 --- a/compiler/src/dmd/hdrgen.d +++ b/compiler/src/dmd/hdrgen.d @@ -418,10 +418,10 @@ private void statementToBuffer(Statement s, ref OutBuffer buf, ref HdrGenState h { buf.writestring(Token.toString(s.op)); buf.writestring(" ("); - if (s.prm.type) - typeToBuffer(s.prm.type, s.prm.ident, buf, hgs); + if (s.param.type) + typeToBuffer(s.param.type, s.param.ident, buf, hgs); else - buf.writestring(s.prm.ident.toString()); + buf.writestring(s.param.ident.toString()); buf.writestring("; "); s.lwr.expressionToBuffer(buf, hgs); buf.writestring(" .. "); @@ -465,7 +465,7 @@ private void statementToBuffer(Statement s, ref OutBuffer buf, ref HdrGenState h void visitIf(IfStatement s) { buf.writestring("if ("); - printConditionAssignment(s.prm, s.condition); + printConditionAssignment(s.param, s.condition); buf.writeByte(')'); buf.writenl(); if (s.ifbody.isScopeStatement()) @@ -1168,14 +1168,14 @@ void toCBuffer(Dsymbol s, ref OutBuffer buf, ref HdrGenState hgs) void foreachRangeWithoutBody(ForeachRangeStatement s) { - /* s.op ( prm ; lwr .. upr ) + /* s.op ( param ; lwr .. upr ) */ buf.writestring(Token.toString(s.op)); buf.writestring(" ("); - if (s.prm.type) - typeToBuffer(s.prm.type, s.prm.ident, buf, hgs); + if (s.param.type) + typeToBuffer(s.param.type, s.param.ident, buf, hgs); else - buf.writestring(s.prm.ident.toString()); + buf.writestring(s.param.ident.toString()); buf.writestring("; "); s.lwr.expressionToBuffer(buf, hgs); buf.writestring(" .. "); diff --git a/compiler/src/dmd/inline.d b/compiler/src/dmd/inline.d index 619af342678c..22ef08644f63 100644 --- a/compiler/src/dmd/inline.d +++ b/compiler/src/dmd/inline.d @@ -313,7 +313,7 @@ public: override void visit(IfStatement s) { - assert(!s.prm); + assert(!s.param); auto econd = doInlineAs!Expression(s.condition, ids); assert(econd); @@ -325,7 +325,7 @@ public: static if (asStatements) { - result = new IfStatement(s.loc, s.prm, econd, ifbody, elsebody, s.endloc); + result = new IfStatement(s.loc, s.param, econd, ifbody, elsebody, s.endloc); } else { diff --git a/compiler/src/dmd/inlinecost.d b/compiler/src/dmd/inlinecost.d index c6434d08d5b8..675881eb3ae3 100644 --- a/compiler/src/dmd/inlinecost.d +++ b/compiler/src/dmd/inlinecost.d @@ -213,7 +213,7 @@ public: s3.endsWithReturnStatement() ) { - if (ifs.prm) // if variables are declared + if (ifs.param) // if variables are declared { cost = COST_MAX; return; @@ -258,7 +258,7 @@ public: /* Can't declare variables inside ?: expressions, so * we cannot inline if a variable is declared. */ - if (s.prm) + if (s.param) { cost = COST_MAX; return; diff --git a/compiler/src/dmd/statement.d b/compiler/src/dmd/statement.d index 5c759b088f5d..25c9eefafc4f 100644 --- a/compiler/src/dmd/statement.d +++ b/compiler/src/dmd/statement.d @@ -890,7 +890,7 @@ extern (C++) final class ForeachStatement : Statement extern (C++) final class ForeachRangeStatement : Statement { TOK op; // TOK.foreach_ or TOK.foreach_reverse_ - Parameter prm; // loop index variable + Parameter param; // loop index variable Expression lwr; Expression upr; Statement _body; @@ -898,11 +898,11 @@ extern (C++) final class ForeachRangeStatement : Statement VarDeclaration key; - extern (D) this(const ref Loc loc, TOK op, Parameter prm, Expression lwr, Expression upr, Statement _body, Loc endloc) @safe + extern (D) this(const ref Loc loc, TOK op, Parameter param, Expression lwr, Expression upr, Statement _body, Loc endloc) @safe { super(loc, STMT.ForeachRange); this.op = op; - this.prm = prm; + this.param = param; this.lwr = lwr; this.upr = upr; this._body = _body; @@ -911,7 +911,7 @@ extern (C++) final class ForeachRangeStatement : Statement override ForeachRangeStatement syntaxCopy() { - return new ForeachRangeStatement(loc, op, prm.syntaxCopy(), lwr.syntaxCopy(), upr.syntaxCopy(), _body ? _body.syntaxCopy() : null, endloc); + return new ForeachRangeStatement(loc, op, param.syntaxCopy(), lwr.syntaxCopy(), upr.syntaxCopy(), _body ? _body.syntaxCopy() : null, endloc); } override bool hasBreak() const pure nothrow @@ -935,17 +935,17 @@ extern (C++) final class ForeachRangeStatement : Statement */ extern (C++) final class IfStatement : Statement { - Parameter prm; + Parameter param; Expression condition; Statement ifbody; Statement elsebody; VarDeclaration match; // for MatchExpression results Loc endloc; // location of closing curly bracket - extern (D) this(const ref Loc loc, Parameter prm, Expression condition, Statement ifbody, Statement elsebody, Loc endloc) @safe + extern (D) this(const ref Loc loc, Parameter param, Expression condition, Statement ifbody, Statement elsebody, Loc endloc) @safe { super(loc, STMT.If); - this.prm = prm; + this.param = param; this.condition = condition; this.ifbody = ifbody; this.elsebody = elsebody; @@ -955,7 +955,7 @@ extern (C++) final class IfStatement : Statement override IfStatement syntaxCopy() { return new IfStatement(loc, - prm ? prm.syntaxCopy() : null, + param ? param.syntaxCopy() : null, condition.syntaxCopy(), ifbody ? ifbody.syntaxCopy() : null, elsebody ? elsebody.syntaxCopy() : null, diff --git a/compiler/src/dmd/statement.h b/compiler/src/dmd/statement.h index 943723824fc5..e420cf412cac 100644 --- a/compiler/src/dmd/statement.h +++ b/compiler/src/dmd/statement.h @@ -346,7 +346,7 @@ class ForeachRangeStatement final : public Statement { public: TOK op; // TOKforeach or TOKforeach_reverse - Parameter *prm; // loop index variable + Parameter *param; // loop index variable Expression *lwr; Expression *upr; Statement *_body; @@ -364,7 +364,7 @@ class ForeachRangeStatement final : public Statement class IfStatement final : public Statement { public: - Parameter *prm; + Parameter *param; Expression *condition; Statement *ifbody; Statement *elsebody; diff --git a/compiler/src/dmd/statementsem.d b/compiler/src/dmd/statementsem.d index d259abf47b0e..100e1f310592 100644 --- a/compiler/src/dmd/statementsem.d +++ b/compiler/src/dmd/statementsem.d @@ -1471,25 +1471,25 @@ Statement statementSemanticVisit(Statement s, Scope* sc) return setError(); } - if (fs.prm.type) + if (fs.param.type) { - fs.prm.type = fs.prm.type.typeSemantic(loc, sc); - fs.prm.type = fs.prm.type.addStorageClass(fs.prm.storageClass); - fs.lwr = fs.lwr.implicitCastTo(sc, fs.prm.type); + fs.param.type = fs.param.type.typeSemantic(loc, sc); + fs.param.type = fs.param.type.addStorageClass(fs.param.storageClass); + fs.lwr = fs.lwr.implicitCastTo(sc, fs.param.type); - if (fs.upr.implicitConvTo(fs.prm.type) || (fs.prm.storageClass & STC.ref_)) + if (fs.upr.implicitConvTo(fs.param.type) || (fs.param.storageClass & STC.ref_)) { - fs.upr = fs.upr.implicitCastTo(sc, fs.prm.type); + fs.upr = fs.upr.implicitCastTo(sc, fs.param.type); } else { - // See if upr-1 fits in prm.type + // See if upr-1 fits in param.type Expression limit = new MinExp(loc, fs.upr, IntegerExp.literal!1); limit = limit.expressionSemantic(sc); limit = limit.optimize(WANTvalue); - if (!limit.implicitConvTo(fs.prm.type)) + if (!limit.implicitConvTo(fs.param.type)) { - fs.upr = fs.upr.implicitCastTo(sc, fs.prm.type); + fs.upr = fs.upr.implicitCastTo(sc, fs.param.type); } } } @@ -1502,26 +1502,26 @@ Statement statementSemanticVisit(Statement s, Scope* sc) { /* Just picking the first really isn't good enough. */ - fs.prm.type = fs.lwr.type; + fs.param.type = fs.lwr.type; } else if (fs.lwr.type == fs.upr.type) { /* Same logic as CondExp ?lwr:upr */ - fs.prm.type = fs.lwr.type; + fs.param.type = fs.lwr.type; } else { scope AddExp ea = new AddExp(loc, fs.lwr, fs.upr); if (typeCombine(ea, sc)) return setError(); - fs.prm.type = ea.type; + fs.param.type = ea.type; fs.lwr = ea.e1; fs.upr = ea.e2; } - fs.prm.type = fs.prm.type.addStorageClass(fs.prm.storageClass); + fs.param.type = fs.param.type.addStorageClass(fs.param.storageClass); } - if (fs.prm.type.ty == Terror || fs.lwr.op == EXP.error || fs.upr.op == EXP.error) + if (fs.param.type.ty == Terror || fs.lwr.op == EXP.error || fs.upr.op == EXP.error) { return setError(); } @@ -1566,7 +1566,7 @@ Statement statementSemanticVisit(Statement s, Scope* sc) if (fs.op == TOK.foreach_reverse_) { cond = new PostExp(EXP.minusMinus, loc, new VarExp(loc, fs.key)); - if (fs.prm.type.isScalar()) + if (fs.param.type.isScalar()) { // key-- > tmp cond = new CmpExp(EXP.greaterThan, loc, cond, new VarExp(loc, tmp)); @@ -1579,7 +1579,7 @@ Statement statementSemanticVisit(Statement s, Scope* sc) } else { - if (fs.prm.type.isScalar()) + if (fs.param.type.isScalar()) { // key < tmp cond = new CmpExp(EXP.lessThan, loc, new VarExp(loc, fs.key), new VarExp(loc, tmp)); @@ -1598,30 +1598,30 @@ Statement statementSemanticVisit(Statement s, Scope* sc) //increment = new AddAssignExp(loc, new VarExp(loc, fs.key), IntegerExp.literal!1); increment = new PreExp(EXP.prePlusPlus, loc, new VarExp(loc, fs.key)); } - if ((fs.prm.storageClass & STC.ref_) && fs.prm.type.equals(fs.key.type)) + if ((fs.param.storageClass & STC.ref_) && fs.param.type.equals(fs.key.type)) { fs.key.range = null; - auto v = new AliasDeclaration(loc, fs.prm.ident, fs.key); + auto v = new AliasDeclaration(loc, fs.param.ident, fs.key); fs._body = new CompoundStatement(loc, new ExpStatement(loc, v), fs._body); } else { - ie = new ExpInitializer(loc, new CastExp(loc, new VarExp(loc, fs.key), fs.prm.type)); - auto v = new VarDeclaration(loc, fs.prm.type, fs.prm.ident, ie); - v.storage_class |= STC.temp | STC.foreach_ | (fs.prm.storageClass & STC.ref_); + ie = new ExpInitializer(loc, new CastExp(loc, new VarExp(loc, fs.key), fs.param.type)); + auto v = new VarDeclaration(loc, fs.param.type, fs.param.ident, ie); + v.storage_class |= STC.temp | STC.foreach_ | (fs.param.storageClass & STC.ref_); fs._body = new CompoundStatement(loc, new ExpStatement(loc, v), fs._body); - if (fs.key.range && !fs.prm.type.isMutable()) + if (fs.key.range && !fs.param.type.isMutable()) { /* Limit the range of the key to the specified range */ v.range = new IntRange(fs.key.range.imin, fs.key.range.imax - SignExtendedNumber(1)); } } - if (fs.prm.storageClass & STC.ref_) + if (fs.param.storageClass & STC.ref_) { - if (fs.key.type.constConv(fs.prm.type) == MATCH.nomatch) + if (fs.key.type.constConv(fs.param.type) == MATCH.nomatch) { - error(fs.loc, "argument type mismatch, `%s` to `ref %s`", fs.key.type.toChars(), fs.prm.type.toChars()); + error(fs.loc, "argument type mismatch, `%s` to `ref %s`", fs.key.type.toChars(), fs.param.type.toChars()); return setError(); } } @@ -1644,15 +1644,15 @@ Statement statementSemanticVisit(Statement s, Scope* sc) sym.parent = sc.scopesym; sym.endlinnum = ifs.endloc.linnum; Scope* scd = sc.push(sym); - if (ifs.prm) + if (ifs.param) { - /* Declare prm, which we will set to be the + /* Declare param, which we will set to be the * result of condition. */ auto ei = new ExpInitializer(ifs.loc, ifs.condition); - ifs.match = new VarDeclaration(ifs.loc, ifs.prm.type, ifs.prm.ident, ei); + ifs.match = new VarDeclaration(ifs.loc, ifs.param.type, ifs.param.ident, ei); ifs.match.parent = scd.func; - ifs.match.storage_class |= ifs.prm.storageClass; + ifs.match.storage_class |= ifs.param.storageClass; ifs.match.dsymbolSemantic(scd); auto de = new DeclarationExp(ifs.loc, ifs.match); @@ -1688,8 +1688,8 @@ Statement statementSemanticVisit(Statement s, Scope* sc) if (checkNonAssignmentArrayOp(ifs.condition)) ifs.condition = ErrorExp.get(); - // Convert to boolean after declaring prm so this works: - // if (S prm = S()) {} + // Convert to boolean after declaring param so this works: + // if (S param = S()) {} // where S is a struct that defines opCast!bool. ifs.condition = ifs.condition.toBoolean(scd); @@ -3997,12 +3997,12 @@ private FuncExp foreachBodyToFunction(Scope* sc, ForeachStatement fs, TypeFuncti p.type = p.type.addStorageClass(p.storageClass); if (tfld) { - Parameter prm = tfld.parameterList[i]; - //printf("\tprm = %s%s\n", (prm.storageClass&STC.ref_?"ref ":"").ptr, prm.ident.toChars()); - stc = (prm.storageClass & STC.ref_) | (p.storageClass & STC.scope_); - if ((p.storageClass & STC.ref_) != (prm.storageClass & STC.ref_)) + Parameter param = tfld.parameterList[i]; + //printf("\tparam = %s%s\n", (param.storageClass&STC.ref_?"ref ":"").ptr, param.ident.toChars()); + stc = (param.storageClass & STC.ref_) | (p.storageClass & STC.scope_); + if ((p.storageClass & STC.ref_) != (param.storageClass & STC.ref_)) { - if (!(prm.storageClass & STC.ref_)) + if (!(param.storageClass & STC.ref_)) { error(fs.loc, "`foreach`: cannot make `%s` `ref`", p.ident.toChars()); return null; diff --git a/compiler/src/dmd/visitor/transitive.d b/compiler/src/dmd/visitor/transitive.d index 952460c18cbe..c3ce13e2d40a 100644 --- a/compiler/src/dmd/visitor/transitive.d +++ b/compiler/src/dmd/visitor/transitive.d @@ -153,8 +153,8 @@ package(dmd.visitor) mixin template ParseVisitMethods(AST) override void visit(AST.ForeachRangeStatement s) { //printf("Visiting ForeachRangeStatement\n"); - if (s.prm.type) - visitType(s.prm.type); + if (s.param.type) + visitType(s.param.type); s.lwr.accept(this); s.upr.accept(this); if (s._body) @@ -174,8 +174,8 @@ package(dmd.visitor) mixin template ParseVisitMethods(AST) override void visit(AST.IfStatement s) { //printf("Visiting IfStatement\n"); - if (s.prm && s.prm.type) - visitType(s.prm.type); + if (s.param && s.param.type) + visitType(s.param.type); s.condition.accept(this); s.ifbody.accept(this); if (s.elsebody)