diff options
Diffstat (limited to 'c_compiler/src/type.cpp')
-rw-r--r-- | c_compiler/src/type.cpp | 216 |
1 files changed, 108 insertions, 108 deletions
diff --git a/c_compiler/src/type.cpp b/c_compiler/src/type.cpp index 675230c..9432326 100644 --- a/c_compiler/src/type.cpp +++ b/c_compiler/src/type.cpp @@ -8,39 +8,39 @@ void Type::setSigned(bool) { - throw std::runtime_error("Error : cannot set sign"); + throw std::runtime_error("Error : cannot set sign"); } void Type::setExtern(bool) { - throw std::runtime_error("Error : cannot set extern"); + throw std::runtime_error("Error : cannot set extern"); } void Type::setStatic(bool) { - throw std::runtime_error("Error : cannot set static"); + throw std::runtime_error("Error : cannot set static"); } void Type::setConst(bool) { - throw std::runtime_error("Error : cannot set const"); + throw std::runtime_error("Error : cannot set const"); } void Type::setSize(int) { - throw std::runtime_error("Error : cannot set size"); + throw std::runtime_error("Error : cannot set size"); } // Array definition Array::Array(const int &size, TypePtr type) - : size_(size), type_(type) + : size_(size), type_(type) {} void Array::print() const { - printf("Array\n"); + printf("Array\n"); } void Array::printXml() const @@ -48,63 +48,63 @@ void Array::printXml() const Bindings Array::printAsm(Bindings bindings, int &) const { - return bindings; + return bindings; } TypePtr Array::type() { - return type_; + return type_; } TypePtr Array::type(Type *type_ptr) { - TypePtr sh_type_ptr(type_ptr); - type_ = sh_type_ptr; - return type_; + TypePtr sh_type_ptr(type_ptr); + type_ = sh_type_ptr; + return type_; } TypePtr Array::type(TypePtr type_ptr) { - type_ = type_ptr; - return type_; + type_ = type_ptr; + return type_; } void Array::increaseStackPosition(Bindings &bindings) const { - for(int i = 0; i < size_; ++i) - { - type_->increaseStackPosition(bindings); - } + for(int i = 0; i < size_; ++i) + { + type_->increaseStackPosition(bindings); + } } void Array::load() const { - type_->load(); + type_->load(); } void Array::load(const int ®, const int &position) const { - type_->load(reg, position); + type_->load(reg, position); } void Array::store() const { - type_->store(); + type_->store(); } void Array::store(const int &position) const { - type_->store(position); + type_->store(position); } void Array::store(const int ®, const int &position) const { - type_->store(reg, position); + type_->store(reg, position); } int Array::getSize() const { - return type_->getSize(); + return type_->getSize(); } @@ -115,7 +115,7 @@ Pointer::Pointer() void Pointer::print() const { - printf("Pointer\n"); + printf("Pointer\n"); } void Pointer::printXml() const @@ -123,99 +123,99 @@ void Pointer::printXml() const Bindings Pointer::printAsm(Bindings bindings, int &) const { - return bindings; + return bindings; } TypePtr Pointer::type() { - return type_; + return type_; } TypePtr Pointer::type(Type *type_ptr) { - TypePtr sh_type_ptr(type_ptr); - type_ = sh_type_ptr; - return type_; + TypePtr sh_type_ptr(type_ptr); + type_ = sh_type_ptr; + return type_; } TypePtr Pointer::type(TypePtr type_ptr) { - type_ = type_ptr; - return type_; + type_ = type_ptr; + return type_; } void Pointer::increaseStackPosition(Bindings &bindings) const { - bindings.increaseStackPosition(4); + bindings.increaseStackPosition(4); } void Pointer::load() const { - printf("\tlw\t$2,0($t0)\n"); + printf("\tlw\t$2,0($t0)\n"); } void Pointer::load(const int ®, const int &position) const { - printf("\tlw\t$%d,%d($fp)\n", reg, position); + printf("\tlw\t$%d,%d($fp)\n", reg, position); } void Pointer::store() const { - printf("\tsw\t$2,0($t0)\n"); + printf("\tsw\t$2,0($t0)\n"); } void Pointer::store(const int &position) const { - printf("\tsw\t$2,%d($fp)\n", position); + printf("\tsw\t$2,%d($fp)\n", position); } void Pointer::store(const int ®, const int &position) const { - printf("\tsw\t$%d,%d($fp)\n", reg, position); + printf("\tsw\t$%d,%d($fp)\n", reg, position); } int Pointer::getSize() const { - return type_->getSize(); + return type_->getSize(); } void Pointer::pointerLoad() const { - type_->load(); + type_->load(); } void Pointer::pointerLoad(const int ®, const int &position) const { - type_->load(reg, position); + type_->load(reg, position); } void Pointer::pointerStore() const { - type_->store(); + type_->store(); } void Pointer::pointerStore(const int &position) const { - type_->store(position); + type_->store(position); } void Pointer::pointerStore(const int ®, const int &position) const { - type_->store(reg, position); + type_->store(reg, position); } // TypeContainer definition TypeContainer::TypeContainer() - : type_(nullptr), size_(32), extern_(false), static_(false), const_(false), signed_(true) + : type_(nullptr), size_(32), extern_(false), static_(false), const_(false), signed_(true) {} void TypeContainer::print() const { - printf("TypeContainer : "); - type_->print(); + printf("TypeContainer : "); + type_->print(); } void TypeContainer::printXml() const @@ -223,87 +223,87 @@ void TypeContainer::printXml() const Bindings TypeContainer::printAsm(Bindings bindings, int &) const { - return bindings; + return bindings; } TypePtr TypeContainer::type() { - return type_; + return type_; } TypePtr TypeContainer::type(Type *type_ptr) { - TypePtr new_type_ptr(type_ptr); - type_ = new_type_ptr; + TypePtr new_type_ptr(type_ptr); + type_ = new_type_ptr; - return type_; + return type_; } TypePtr TypeContainer::type(TypePtr type_ptr) { - type_ = type_ptr; + type_ = type_ptr; - return type_; + return type_; } void TypeContainer::increaseStackPosition(Bindings &bindings) const { - type_->increaseStackPosition(bindings); + type_->increaseStackPosition(bindings); } void TypeContainer::load() const { - type_->load(); + type_->load(); } void TypeContainer::load(const int ®, const int &position) const { - type_->load(reg, position); + type_->load(reg, position); } void TypeContainer::store() const { - type_->store(); + type_->store(); } void TypeContainer::store(const int &position) const { - type_->store(position); + type_->store(position); } void TypeContainer::store(const int ®, const int &position) const { - type_->store(reg, position); + type_->store(reg, position); } int TypeContainer::getSize() const { - return type_->getSize(); + return type_->getSize(); } void TypeContainer::setSigned(bool _signed) { - signed_ = _signed; + signed_ = _signed; } void TypeContainer::setExtern(bool _extern) { - extern_ = _extern; + extern_ = _extern; } void TypeContainer::setStatic(bool _static) { - static_ = _static; + static_ = _static; } void TypeContainer::setConst(bool _const) { - const_ = _const; + const_ = _const; } void TypeContainer::setSize(int size) { - size_ = size; + size_ = size; } @@ -311,17 +311,17 @@ void TypeContainer::setSize(int size) TypePtr Specifier::type() { - throw std::runtime_error("Error : Cannot get type"); + throw std::runtime_error("Error : Cannot get type"); } TypePtr Specifier::type(Type *) { - throw std::runtime_error("Error : Cannot get type"); + throw std::runtime_error("Error : Cannot get type"); } TypePtr Specifier::type(TypePtr) { - throw std::runtime_error("Error : Cannot get type"); + throw std::runtime_error("Error : Cannot get type"); } @@ -332,7 +332,7 @@ Int::Int() void Int::print() const { - printf("Int\n"); + printf("Int\n"); } void Int::printXml() const @@ -340,42 +340,42 @@ void Int::printXml() const Bindings Int::printAsm(Bindings bindings, int &) const { - return bindings; + return bindings; } void Int::increaseStackPosition(Bindings &bindings) const { - bindings.increaseStackPosition(4); + bindings.increaseStackPosition(4); } void Int::load() const { - printf("\tlw\t$2,0($t0)\n"); + printf("\tlw\t$2,0($t0)\n"); } void Int::load(const int ®, const int &position) const { - printf("\tlw\t$%d,%d($fp)\n", reg, position); + printf("\tlw\t$%d,%d($fp)\n", reg, position); } void Int::store() const { - printf("\tsw\t$2,0($t0)\n"); + printf("\tsw\t$2,0($t0)\n"); } void Int::store(const int &position) const { - printf("\tsw\t$2,%d($fp)\n", position); + printf("\tsw\t$2,%d($fp)\n", position); } void Int::store(const int ®, const int &position) const { - printf("\tsw\t$%d,%d($fp)\n", reg, position); + printf("\tsw\t$%d,%d($fp)\n", reg, position); } int Int::getSize() const { - return 4; + return 4; } @@ -386,7 +386,7 @@ Void::Void() void Void::print() const { - printf("Void\n"); + printf("Void\n"); } void Void::printXml() const @@ -394,7 +394,7 @@ void Void::printXml() const Bindings Void::printAsm(Bindings bindings, int &) const { - return bindings; + return bindings; } void Void::increaseStackPosition(Bindings &) const @@ -417,7 +417,7 @@ void Void::store(const int &, const int &) const int Void::getSize() const { - return 0; + return 0; } @@ -428,7 +428,7 @@ Short::Short() void Short::print() const { - printf("Short\n"); + printf("Short\n"); } void Short::printXml() const @@ -436,42 +436,42 @@ void Short::printXml() const Bindings Short::printAsm(Bindings bindings, int &) const { - return bindings; + return bindings; } void Short::increaseStackPosition(Bindings &bindings) const { - bindings.increaseStackPosition(2); + bindings.increaseStackPosition(2); } void Short::load() const { - printf("\tlhu\t$2,0($t0)\n"); + printf("\tlhu\t$2,0($t0)\n"); } void Short::load(const int ®, const int &position) const { - printf("\tlhu\t$%d,%d($fp)\n", reg, position); + printf("\tlhu\t$%d,%d($fp)\n", reg, position); } void Short::store() const { - printf("\tsh\t$2,0($t0)\n"); + printf("\tsh\t$2,0($t0)\n"); } void Short::store(const int &position) const { - printf("\tsh\t$2,%d($fp)\n", position); + printf("\tsh\t$2,%d($fp)\n", position); } void Short::store(const int ®, const int &position) const { - printf("\tsh\t$%d,%d($fp)\n", reg, position); + printf("\tsh\t$%d,%d($fp)\n", reg, position); } int Short::getSize() const { - return 2; + return 2; } @@ -482,7 +482,7 @@ Char::Char() void Char::print() const { - printf("Char\n"); + printf("Char\n"); } void Char::printXml() const @@ -490,42 +490,42 @@ void Char::printXml() const Bindings Char::printAsm(Bindings bindings, int &) const { - return bindings; + return bindings; } void Char::increaseStackPosition(Bindings &bindings) const { - bindings.increaseStackPosition(1); + bindings.increaseStackPosition(1); } void Char::load() const { - printf("\tlbu\t$2,0($t0)\n"); + printf("\tlbu\t$2,0($t0)\n"); } void Char::load(const int ®, const int &position) const { - printf("\tlbu\t$%d,%d($fp)\n", reg, position); + printf("\tlbu\t$%d,%d($fp)\n", reg, position); } void Char::store() const { - printf("\tsb\t$2,0($t0)\n"); + printf("\tsb\t$2,0($t0)\n"); } void Char::store(const int &position) const { - printf("\tsb\t$2,%d($fp)\n", position); + printf("\tsb\t$2,%d($fp)\n", position); } void Char::store(const int ®, const int &position) const { - printf("\tsb\t$%d,%d($fp)\n", reg, position); + printf("\tsb\t$%d,%d($fp)\n", reg, position); } int Char::getSize() const { - return 1; + return 1; } @@ -536,7 +536,7 @@ Float::Float() void Float::print() const { - printf("Float\n"); + printf("Float\n"); } void Float::printXml() const @@ -544,40 +544,40 @@ void Float::printXml() const Bindings Float::printAsm(Bindings bindings, int &) const { - return bindings; + return bindings; } void Float::increaseStackPosition(Bindings &bindings) const { - bindings.increaseStackPosition(4); + bindings.increaseStackPosition(4); } void Float::load() const { - throw std::runtime_error("Error : Cannot load float yet"); + throw std::runtime_error("Error : Cannot load float yet"); } void Float::load(const int &, const int &) const { - throw std::runtime_error("Error : Cannot load float yet"); + throw std::runtime_error("Error : Cannot load float yet"); } void Float::store() const { - throw std::runtime_error("Error : Cannot store float yet"); + throw std::runtime_error("Error : Cannot store float yet"); } void Float::store(const int &) const { - throw std::runtime_error("Error : Cannot store float yet"); + throw std::runtime_error("Error : Cannot store float yet"); } void Float::store(const int &, const int &) const { - throw std::runtime_error("Error : Cannot store float yet"); + throw std::runtime_error("Error : Cannot store float yet"); } int Float::getSize() const { - return 4; + return 4; } |