-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
35 changed files
with
516 additions
and
212 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
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 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 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 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,75 @@ | ||
#ifndef LANG_CONTROL_FLOW_ANALYZER | ||
#define LANG_CONTROL_FLOW_ANALYZER | ||
|
||
#include "Support/Reporting.h" | ||
|
||
#include "AST/ASTVisitor.h" | ||
|
||
#include <stack> | ||
|
||
namespace lang { | ||
|
||
enum class CFAErrorKind { | ||
EarlyReturnStmt, | ||
InvalidBreakStmt, | ||
}; | ||
|
||
struct CFAError { | ||
CFAErrorKind kind; | ||
std::string_view span; | ||
CFAError(CFAErrorKind kind, std::string_view span) | ||
: kind(kind), span(span) {} | ||
TextError toTextError() const; | ||
JSONError toJSONError() const; | ||
}; | ||
|
||
struct CFAResult { | ||
std::vector<CFAError> errors; | ||
}; | ||
|
||
class CFA : public MutableASTVisitor<CFA> { | ||
friend class ASTVisitor<CFA, false>; | ||
|
||
public: | ||
CFAResult analyzeModuleAST(ModuleAST &module); | ||
|
||
private: | ||
std::stack<StmtAST *> breakableStack; | ||
std::vector<CFAError> errors; | ||
|
||
void visit(FunctionDeclAST &node); | ||
|
||
void visit(ExprStmtAST &node) {} | ||
|
||
void visit(BreakStmtAST &node); | ||
|
||
void visit(ReturnStmtAST &node) {} | ||
|
||
void visit(LocalStmtAST &node) {} | ||
|
||
void visit(AssignStmtAST &node) {} | ||
|
||
void visit(BlockStmtAST &node); | ||
|
||
void visit(IfStmtAST &node); | ||
|
||
void visit(WhileStmtAST &node); | ||
|
||
void visit(IdentifierExprAST &node) {} | ||
|
||
void visit(NumberExprAST &node) {} | ||
|
||
void visit(UnaryExprAST &node) {} | ||
|
||
void visit(BinaryExprAST &node) {} | ||
|
||
void visit(CallExprAST &node) {} | ||
|
||
void visit(IndexExprAST &node) {} | ||
|
||
void visit(GroupedExprAST &node) {} | ||
}; | ||
|
||
} // namespace lang | ||
|
||
#endif // LANG_CONTROL_FLOW_ANALYZER |
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 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 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 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
Oops, something went wrong.