Switch Statement to std::variant (#639)

Aligns Assign/Assignment, If/IfStatement naming to favor the name in the enum.
This commit is contained in:
Jon Meow
2021-07-13 13:54:38 -07:00
committed by GitHub
parent b03d3cdbb0
commit 0960c51d20
5 changed files with 156 additions and 147 deletions
@@ -967,7 +967,7 @@ void StepExp() {
auto IsWhileAct(Action* act) -> bool {
switch (act->tag()) {
case ActionKind::StatementAction:
switch (act->GetStatementAction().stmt->tag) {
switch (act->GetStatementAction().stmt->tag()) {
case StatementKind::While:
return true;
default:
@@ -981,7 +981,7 @@ auto IsWhileAct(Action* act) -> bool {
auto IsBlockAct(Action* act) -> bool {
switch (act->tag()) {
case ActionKind::StatementAction:
switch (act->GetStatementAction().stmt->tag) {
switch (act->GetStatementAction().stmt->tag()) {
case StatementKind::Block:
return true;
default:
@@ -1004,7 +1004,7 @@ void StepStmt() {
PrintStatement(stmt, 1);
std::cout << " --->" << std::endl;
}
switch (stmt->tag) {
switch (stmt->tag()) {
case StatementKind::Match:
if (act->pos == 0) {
// { { (match (e) ...) :: C, E, F} :: S, H}
@@ -1164,7 +1164,8 @@ void StepStmt() {
if (act->pos == 0) {
// { {e :: C, E, F} :: S, H}
// -> { {e :: C, E, F} :: S, H}
frame->todo.Push(Action::MakeExpressionAction(stmt->GetExpression()));
frame->todo.Push(
Action::MakeExpressionAction(stmt->GetExpressionStatement().exp));
act->pos++;
} else {
frame->todo.Pop(1);
@@ -1216,7 +1217,7 @@ void StepStmt() {
if (act->pos == 0) {
// { {return e :: C, E, F} :: S, H}
// -> { {e :: return [] :: C, E, F} :: S, H}
frame->todo.Push(Action::MakeExpressionAction(stmt->GetReturn()));
frame->todo.Push(Action::MakeExpressionAction(stmt->GetReturn().exp));
act->pos++;
} else {
// { {v :: return [] :: C, E, F} :: {C', E', F'} :: S, H}
@@ -1256,7 +1257,7 @@ void StepStmt() {
continuation_frame->continuation = continuation_address;
// Bind the continuation object to the continuation variable
frame->scopes.Top()->values.Set(
*stmt->GetContinuation().continuation_variable, continuation_address);
stmt->GetContinuation().continuation_variable, continuation_address);
// Pop the continuation statement.
frame->todo.Pop();
break;
@@ -1270,9 +1271,10 @@ void StepStmt() {
frame->todo.Pop(1);
// Push an expression statement action to ignore the result
// value from the continuation.
Action* ignore_result = Action::MakeStatementAction(
Statement::MakeExpStmt(stmt->line_num, Expression::MakeTupleLiteral(
stmt->line_num, {})));
Action* ignore_result =
Action::MakeStatementAction(Statement::MakeExpressionStatement(
stmt->line_num,
Expression::MakeTupleLiteral(stmt->line_num, {})));
ignore_result->pos = 0;
frame->todo.Push(ignore_result);
// Push the continuation onto the current stack.