Skip to content

Commit

Permalink
remove Expression.parens
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright authored and dlang-bot committed May 17, 2023
1 parent e60d027 commit 6e604e2
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 14 deletions.
4 changes: 3 additions & 1 deletion compiler/src/dmd/astbase.d
Original file line number Diff line number Diff line change
Expand Up @@ -4536,7 +4536,6 @@ struct ASTBase
{
EXP op;
ubyte size;
ubyte parens;
Type type;
Loc loc;

Expand Down Expand Up @@ -5115,6 +5114,8 @@ struct ASTBase

extern (C++) final class TypeExp : Expression
{
bool parens;

extern (D) this(const ref Loc loc, Type type)
{
super(loc, EXP.type, __traits(classInstanceSize, TypeExp));
Expand Down Expand Up @@ -5147,6 +5148,7 @@ struct ASTBase
extern (C++) class IdentifierExp : Expression
{
Identifier ident;
bool parens;

final extern (D) this(const ref Loc loc, Identifier ident)
{
Expand Down
4 changes: 3 additions & 1 deletion compiler/src/dmd/expression.d
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,6 @@ extern (C++) abstract class Expression : ASTNode
Type type; // !=null means that semantic() has been run
Loc loc; // file location
const EXP op; // to minimize use of dynamic_cast
bool parens; // if this is a parenthesized expression

extern (D) this(const ref Loc loc, EXP op) scope
{
Expand Down Expand Up @@ -2357,6 +2356,7 @@ extern (C++) final class ComplexExp : Expression
extern (C++) class IdentifierExp : Expression
{
Identifier ident;
bool parens; // if it appears as (identifier)

extern (D) this(const ref Loc loc, Identifier ident) scope
{
Expand Down Expand Up @@ -3539,6 +3539,8 @@ extern (C++) final class CompoundLiteralExp : Expression
*/
extern (C++) final class TypeExp : Expression
{
bool parens; // if this is a parenthesized expression

extern (D) this(const ref Loc loc, Type type)
{
super(loc, EXP.type);
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dmd/expression.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ class Expression : public ASTNode
Type *type; // !=NULL means that semantic() has been run
Loc loc; // file location
EXP op; // to minimize use of dynamic_cast
d_bool parens; // if this is a parenthesized expression

size_t size() const;
static void _init();
Expand Down Expand Up @@ -316,6 +315,7 @@ class IdentifierExp : public Expression
{
public:
Identifier *ident;
d_bool parens;

static IdentifierExp *create(const Loc &loc, Identifier *ident);
bool isLvalue() override final;
Expand Down
9 changes: 5 additions & 4 deletions compiler/src/dmd/frontend.h
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,6 @@ class Expression : public ASTNode
Type* type;
Loc loc;
const EXP op;
bool parens;
size_t size() const;
static void _init();
static void deinitialize();
Expand Down Expand Up @@ -7013,9 +7012,9 @@ struct UnionExp final
private:
union __AnonStruct__u
{
char exp[26LLU];
char exp[25LLU];
char integerexp[40LLU];
char errorexp[26LLU];
char errorexp[25LLU];
char realexp[48LLU];
char complexexp[64LLU];
char symoffexp[64LLU];
Expand All @@ -7024,7 +7023,7 @@ struct UnionExp final
char assocarrayliteralexp[48LLU];
char structliteralexp[76LLU];
char compoundliteralexp[40LLU];
char nullexp[26LLU];
char nullexp[25LLU];
char dotvarexp[49LLU];
char addrexp[40LLU];
char indexexp[74LLU];
Expand Down Expand Up @@ -7117,6 +7116,7 @@ class IdentifierExp : public Expression
{
public:
Identifier* ident;
bool parens;
static IdentifierExp* create(const Loc& loc, Identifier* ident);
bool isLvalue() final override;
Expression* toLvalue(Scope* sc, Expression* e) final override;
Expand Down Expand Up @@ -7277,6 +7277,7 @@ class CompoundLiteralExp final : public Expression
class TypeExp final : public Expression
{
public:
bool parens;
TypeExp* syntaxCopy() override;
bool checkType() override;
bool checkValue() override;
Expand Down
7 changes: 4 additions & 3 deletions compiler/src/dmd/importc.d
Original file line number Diff line number Diff line change
Expand Up @@ -237,15 +237,16 @@ Expression castCallAmbiguity(Expression e, Scope* sc)

case EXP.call:
auto ce = (*pe).isCallExp();
if (ce.e1.parens)
auto ie = ce.e1.isIdentifierExp();
if (ie && ie.parens)
{
ce.e1 = expressionSemantic(ce.e1, sc);
ce.e1 = expressionSemantic(ie, sc);
if (ce.e1.op == EXP.type)
{
const numArgs = ce.arguments ? ce.arguments.length : 0;
if (numArgs >= 1)
{
ce.e1.parens = false;
ie.parens = false;
Expression arg;
foreach (a; (*ce.arguments)[])
{
Expand Down
7 changes: 3 additions & 4 deletions compiler/src/dmd/parse.d
Original file line number Diff line number Diff line change
Expand Up @@ -8479,7 +8479,6 @@ LagainStc:
// ( expression )
nextToken();
e = parseExpression();
e.parens = true;
check(loc, TOK.rightParenthesis);
break;
}
Expand Down Expand Up @@ -8800,9 +8799,9 @@ LagainStc:
nextToken();
return AST.ErrorExp.get();
}
e = new AST.TypeExp(loc, t);
e.parens = true;
e = parsePostExp(e);
auto te = new AST.TypeExp(loc, t);
te.parens = true;
e = parsePostExp(te);
}
else
{
Expand Down

0 comments on commit 6e604e2

Please sign in to comment.