aboutsummaryrefslogtreecommitdiffstats
path: root/c_compiler
diff options
context:
space:
mode:
authorYann Herklotz <ymherklotz@gmail.com>2017-03-13 19:34:53 +0000
committerYann Herklotz <ymherklotz@gmail.com>2017-03-13 19:34:53 +0000
commit10a1fc0bc485cb0ac20aff586182a66932d3be64 (patch)
treef254672190f29738d34a6db9078388456efb4dac /c_compiler
parent8d3db310926c414d199fca62f0c349a263543096 (diff)
downloadCompiler-10a1fc0bc485cb0ac20aff586182a66932d3be64.tar.gz
Compiler-10a1fc0bc485cb0ac20aff586182a66932d3be64.zip
Reformatted and working
Diffstat (limited to 'c_compiler')
-rw-r--r--c_compiler/src/c_parser.y3
-rw-r--r--c_compiler/src/expression.cpp16
2 files changed, 10 insertions, 9 deletions
diff --git a/c_compiler/src/c_parser.y b/c_compiler/src/c_parser.y
index e87f8f7..ea21879 100644
--- a/c_compiler/src/c_parser.y
+++ b/c_compiler/src/c_parser.y
@@ -100,7 +100,8 @@ FunctionDefinition:
DeclarationSpec T_IDENTIFIER T_LRB ParameterList T_RRB CompoundStatement { $$ = new Function(*$2, $4, $6); delete $2; }
;
-ParameterList:% empty { $$ = new Declaration(); }
+ParameterList:
+ %empty { $$ = new Declaration(); }
| Parameter { $$ = $1; }
| ParameterList T_CMA Parameter { $3->linkDeclaration($$); $$ = $3;}
;
diff --git a/c_compiler/src/expression.cpp b/c_compiler/src/expression.cpp
index 5e15f42..7c0bd8b 100644
--- a/c_compiler/src/expression.cpp
+++ b/c_compiler/src/expression.cpp
@@ -40,17 +40,17 @@ VariableStackBindings AssignmentExpression::printAsm(VariableStackBindings bindi
{
// TODO
// the lhs is forced to have a stack position due to it being a function, array or other type of variable
- /*unsigned current_stack = bindings.currentRegister();
+ // unsigned current_stack = bindings.currentRegister();
// std::cout << "Current Register: " << current_reg << std::endl;
- bindings.increaseRegister();
+ // bindings.increaseRegister();
- int store_stack_position = lhs->getPostfixStackPosition(bindings);
+ int store_stack_position = lhs_->postfixStackPosition(bindings);
- rhs->printAsm(bindings);
+ rhs_->printAsm(bindings);
// we are assigning so we don't have to evaluate the lhs as it will be overwritten anyways
- std::cout << "\tsw\t$" << current_reg << "," << store_stack_position
- << "($fp)" << std::endl; */
+ std::cout << "\tsw\t$" << 2 << "," << store_stack_position
+ << "($fp)" << std::endl;
return bindings;
}
@@ -145,13 +145,13 @@ int Identifier::postfixStackPosition(VariableStackBindings bindings) const
// Constant definition
Constant::Constant(const int32_t& constant)
- : m_constant(constant)
+ : constant_(constant)
{}
VariableStackBindings Constant::printAsm(VariableStackBindings bindings) const
{
// constant only has to load to $2 because the other expression will take care of the rest
- std::cout << "\tli\t$2," << m_constant << std::endl;
+ std::cout << "\tli\t$2," << constant_ << std::endl;
return bindings;
}