Skip to content

Commit

Permalink
Extract loop processing from the StatementVisitor.
Browse files Browse the repository at this point in the history
  • Loading branch information
deadalnix committed Oct 30, 2024
1 parent 9a921db commit 95f50d9
Show file tree
Hide file tree
Showing 2 changed files with 202 additions and 162 deletions.
36 changes: 21 additions & 15 deletions src/d/ast/statement.d
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ class Statement : Node {
}
}

class LoopStatement : Statement {
this(Location location) {
super(location);
}
}

final:

/**
Expand Down Expand Up @@ -102,7 +108,7 @@ class IfStatement : Statement {
/**
* while statements
*/
class WhileStatement : Statement {
class WhileStatement : LoopStatement {
AstExpression condition;
Statement statement;

Expand All @@ -117,7 +123,7 @@ class WhileStatement : Statement {
/**
* do .. while statements
*/
class DoWhileStatement : Statement {
class DoWhileStatement : LoopStatement {
AstExpression condition;
Statement statement;

Expand All @@ -132,7 +138,7 @@ class DoWhileStatement : Statement {
/**
* for statements
*/
class ForStatement : Statement {
class ForStatement : LoopStatement {
Statement initialize;
AstExpression condition;
AstExpression increment;
Expand All @@ -152,7 +158,7 @@ class ForStatement : Statement {
/**
* foreach statements
*/
class ForeachStatement : Statement {
class ForeachStatement : LoopStatement {
ParamDecl[] tupleElements;
AstExpression iterated;
Statement statement;
Expand All @@ -172,7 +178,7 @@ class ForeachStatement : Statement {
/**
* foreach statements
*/
class ForeachRangeStatement : Statement {
class ForeachRangeStatement : LoopStatement {
ParamDecl[] tupleElements;
AstExpression start;
AstExpression stop;
Expand All @@ -192,15 +198,11 @@ class ForeachRangeStatement : Statement {
}

/**
* return statements
* continue statements
*/
class ReturnStatement : Statement {
AstExpression value;

this(Location location, AstExpression value) {
class ContinueStatement : Statement {
this(Location location) {
super(location);

this.value = value;
}
}

Expand Down Expand Up @@ -244,11 +246,15 @@ class BreakStatement : Statement {
}

/**
* continue statements
* return statements
*/
class ContinueStatement : Statement {
this(Location location) {
class ReturnStatement : Statement {
AstExpression value;

this(Location location, AstExpression value) {
super(location);

this.value = value;
}
}

Expand Down
Loading

0 comments on commit 95f50d9

Please sign in to comment.