Skip to content

Commit

Permalink
Pass context by reference
Browse files Browse the repository at this point in the history
Co-authored-by: Jpnock <[email protected]>
  • Loading branch information
Fiwo735 and Jpnock authored Jan 29, 2024
1 parent 4a9d542 commit 060d5db
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion include/ast_direct_declarator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class DirectDeclarator : public Node {
public:
DirectDeclarator(Node* identifier);
~DirectDeclarator() {};
void emitRISC(std::ostream &stream, Context context) const;
void emitRISC(std::ostream &stream, Context &context) const;
};

#endif
2 changes: 1 addition & 1 deletion include/ast_function_definition.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class FunctionDefinition : public Node {
public:
FunctionDefinition(Node* declaration_specifiers, Node* declarator, Node* compound_statement);
~FunctionDefinition() {};
void emitRISC(std::ostream &stream, Context context) const;
void emitRISC(std::ostream &stream, Context &context) const;
};

#endif
2 changes: 1 addition & 1 deletion include/ast_identifier.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Identifier : public Node {
public:
Identifier(std::string* _identifier) : identifier(_identifier) {};
~Identifier() {delete identifier;};
void emitRISC(std::ostream &stream, Context context) const;
void emitRISC(std::ostream &stream, Context &context) const;
};

#endif
2 changes: 1 addition & 1 deletion include/ast_jump_statement.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class JumpStatement : public Node {
public:
JumpStatement() {};
~JumpStatement() {};
void emitRISC(std::ostream &stream, Context context) const;
void emitRISC(std::ostream &stream, Context &context) const;
};

#endif
2 changes: 1 addition & 1 deletion include/ast_node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Node {
public:
Node() {};
virtual ~Node();
virtual void emitRISC(std::ostream &stream, Context context) const = 0;
virtual void emitRISC(std::ostream &stream, Context &context) const = 0;
};

#endif
2 changes: 1 addition & 1 deletion include/ast_type_specifier.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class TypeSpecifier : public Node {
public:
TypeSpecifier(std::string _type) : type(_type) {};
~TypeSpecifier() {};
void emitRISC(std::ostream &stream, Context context) const {};
void emitRISC(std::ostream &stream, Context &context) const {};
};

#endif
2 changes: 1 addition & 1 deletion src/ast_direct_declarator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ DirectDeclarator::DirectDeclarator(Node* identifier) {
branches.insert(branches.end(), {identifier});
}

void DirectDeclarator::emitRISC(std::ostream &stream, Context context) const {
void DirectDeclarator::emitRISC(std::ostream &stream, Context &context) const {
// Emit identifier
branches[0]->emitRISC(stream, context);
stream << ":" << std::endl;
Expand Down
2 changes: 1 addition & 1 deletion src/ast_function_definition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ FunctionDefinition::FunctionDefinition(Node* declaration_specifiers, Node* decla
branches.insert(branches.end(), {declaration_specifiers, declarator, compound_statement});
}

void FunctionDefinition::emitRISC(std::ostream &stream, Context context) const {
void FunctionDefinition::emitRISC(std::ostream &stream, Context &context) const {
// Emit declarator
branches[1]->emitRISC(stream, context);

Expand Down
2 changes: 1 addition & 1 deletion src/ast_identifier.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "ast_identifier.hpp"

void Identifier::emitRISC(std::ostream &stream, Context context) const {
void Identifier::emitRISC(std::ostream &stream, Context &context) const {
stream << *identifier;
}
2 changes: 1 addition & 1 deletion src/ast_jump_statement.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "ast_jump_statement.hpp"

void JumpStatement::emitRISC(std::ostream &stream, Context context) const {
void JumpStatement::emitRISC(std::ostream &stream, Context &context) const {
// TODO these lines are hardcoded for the example test to pass, you have to correct them
stream << "addi t0, zero, 0" << std::endl;
stream << "addi t0, t0, 5" << std::endl;
Expand Down

0 comments on commit 060d5db

Please sign in to comment.