-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Comply with Google C++ Style Guide naming conventions
- Loading branch information
Showing
19 changed files
with
152 additions
and
138 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
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 |
---|---|---|
@@ -1,12 +1,12 @@ | ||
#include "ast_direct_declarator.hpp" | ||
|
||
void DirectDeclarator::emitRISC(std::ostream &stream, Context &context) const | ||
void DirectDeclarator::EmitRISC(std::ostream &stream, Context &context) const | ||
{ | ||
identifier->emitRISC(stream, context); | ||
identifier_->EmitRISC(stream, context); | ||
stream << ":" << std::endl; | ||
} | ||
|
||
void DirectDeclarator::print(std::ostream &stream) const | ||
void DirectDeclarator::Print(std::ostream &stream) const | ||
{ | ||
identifier->print(stream); | ||
identifier_->Print(stream); | ||
} |
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 |
---|---|---|
@@ -1,38 +1,38 @@ | ||
#include "ast_function_definition.hpp" | ||
|
||
void FunctionDefinition::emitRISC(std::ostream &stream, Context &context) const | ||
void FunctionDefinition::EmitRISC(std::ostream &stream, Context &context) const | ||
{ | ||
// TODO: this is not complete. | ||
std::cerr << "FunctionDefinition: emitRISC is not fully implemented." << std::endl; | ||
std::cerr << "FunctionDefinition: EmitRISC is not fully implemented." << std::endl; | ||
|
||
// Emit assembler directives. | ||
// TODO: these are just examples ones, make sure you understand | ||
// the concept of directives and correct them. | ||
stream << ".text" << std::endl; | ||
stream << ".globl f" << std::endl; | ||
|
||
this->declarator->emitRISC(stream, context); | ||
declarator_->EmitRISC(stream, context); | ||
|
||
if (this->compoundStatement != nullptr) | ||
if (compound_statement_ != nullptr) | ||
{ | ||
this->compoundStatement->emitRISC(stream, context); | ||
compound_statement_->EmitRISC(stream, context); | ||
} | ||
} | ||
|
||
void FunctionDefinition::print(std::ostream &stream) const | ||
void FunctionDefinition::Print(std::ostream &stream) const | ||
{ | ||
// TODO: this is not complete. | ||
std::cerr << "FunctionDefinition: print is not fully implemented." << std::endl; | ||
std::cerr << "FunctionDefinition: Print is not fully implemented." << std::endl; | ||
|
||
this->declarationSpecifiers->print(stream); | ||
declaration_specifiers_->Print(stream); | ||
stream << " "; | ||
|
||
this->declarator->print(stream); | ||
declarator_->Print(stream); | ||
stream << "() {" << std::endl; | ||
|
||
if (this->compoundStatement != nullptr) | ||
if (compound_statement_ != nullptr) | ||
{ | ||
this->compoundStatement->print(stream); | ||
compound_statement_->Print(stream); | ||
} | ||
stream << "}" << std::endl; | ||
} |
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 |
---|---|---|
@@ -1,6 +1,11 @@ | ||
#include "ast_identifier.hpp" | ||
|
||
void Identifier::emitRISC(std::ostream &stream, Context &context) const | ||
void Identifier::EmitRISC(std::ostream &stream, Context &context) const | ||
{ | ||
stream << identifier; | ||
stream << identifier_; | ||
} | ||
|
||
void Identifier::Print(std::ostream &stream) const | ||
{ | ||
stream << identifier_; | ||
}; |
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 |
---|---|---|
@@ -1,7 +1,38 @@ | ||
#include "ast_node.hpp" | ||
|
||
Node::~Node() { | ||
for (unsigned i = 0; i < branches.size(); i++){ | ||
delete branches[i]; | ||
} | ||
Node::~Node() | ||
{ | ||
for (auto branch : branches_) | ||
{ | ||
delete branch; | ||
} | ||
} | ||
|
||
void NodeList::PushBack(Node *item) | ||
{ | ||
nodes_.push_back(item); | ||
} | ||
|
||
void NodeList::EmitRISC(std::ostream &stream, Context &context) const | ||
{ | ||
for (auto node : nodes_) | ||
{ | ||
if (node == nullptr) | ||
{ | ||
continue; | ||
} | ||
node->EmitRISC(stream, context); | ||
} | ||
} | ||
|
||
void NodeList::Print(std::ostream &stream) const | ||
{ | ||
for (auto node : nodes_) | ||
{ | ||
if (node == nullptr) | ||
{ | ||
continue; | ||
} | ||
node->Print(stream); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,23 +1,23 @@ | ||
#include "ast_statements.hpp" | ||
|
||
void ReturnStatement::emitRISC(std::ostream &stream, Context &context) const | ||
void ReturnStatement::EmitRISC(std::ostream &stream, Context &context) const | ||
{ | ||
// TODO: this implementation is incomplete | ||
std::cerr << "ReturnStatement: emitRISC is not fully implemented." << std::endl; | ||
if (this->expression != nullptr) | ||
std::cerr << "ReturnStatement: EmitRISC is not fully implemented." << std::endl; | ||
if (expression_ != nullptr) | ||
{ | ||
expression->emitRISC(stream, context); | ||
expression_->EmitRISC(stream, context); | ||
} | ||
stream << "ret" << std::endl; | ||
} | ||
|
||
void ReturnStatement::print(std::ostream &stream) const | ||
void ReturnStatement::Print(std::ostream &stream) const | ||
{ | ||
stream << "return"; | ||
if (this->expression != nullptr) | ||
if (expression_ != nullptr) | ||
{ | ||
stream << " "; | ||
expression->print(stream); | ||
expression_->Print(stream); | ||
} | ||
stream << ";" << std::endl; | ||
} |
Oops, something went wrong.