-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b3c3b8d
commit 9f1061e
Showing
5 changed files
with
65 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
module; | ||
#include <vector> | ||
export module Managers.StmtManager; | ||
|
||
import Types.Statements; | ||
|
||
export namespace Riddle { | ||
class StmtManager { | ||
std::vector<BaseStmt *> stmts; | ||
|
||
public: | ||
~StmtManager() { | ||
for(const auto stmt: stmts) { | ||
delete stmt; | ||
} | ||
} | ||
BaseStmt *getConstant(const int value) { | ||
const auto ptr = new IntegerStmt(value); | ||
stmts.push_back(ptr); | ||
return ptr; | ||
} | ||
BaseStmt *getConstant(const double value) { | ||
const auto ptr = new DoubleStmt(value); | ||
stmts.push_back(ptr); | ||
return ptr; | ||
} | ||
BaseStmt *getConstant(const float value) { | ||
const auto ptr = new FloatStmt(value); | ||
stmts.push_back(ptr); | ||
return ptr; | ||
} | ||
BaseStmt *getConstant(const bool value) { | ||
const auto ptr = new BoolStmt(value); | ||
stmts.push_back(ptr); | ||
return ptr; | ||
} | ||
BaseStmt *getNull() { | ||
const auto ptr = new NullStmt(); | ||
stmts.push_back(ptr); | ||
return ptr; | ||
} | ||
}; | ||
}// namespace Riddle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include "StmtVisitor.h" | ||
|
||
import Types.Statements; | ||
|
||
namespace Riddle { | ||
std::any StmtVisitor::visitStatement_ed(RiddleParser::Statement_edContext *ctx) { | ||
return visit(ctx->children[0]); | ||
} | ||
|
||
std::any StmtVisitor::visitInteger(RiddleParser::IntegerContext *ctx) { | ||
auto result = IntegerStmt(ctx->value); | ||
return result; | ||
} | ||
std::any StmtVisitor::visitVarDefineStatement(RiddleParser::VarDefineStatementContext *ctx) { | ||
const std::string name = ctx->name->getText(); | ||
return {}; | ||
} | ||
|
||
}// namespace Riddle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters