diff options
Diffstat (limited to 'c_compiler/src/type.cpp')
-rw-r--r-- | c_compiler/src/type.cpp | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/c_compiler/src/type.cpp b/c_compiler/src/type.cpp index 6a8f45c..251ebc5 100644 --- a/c_compiler/src/type.cpp +++ b/c_compiler/src/type.cpp @@ -102,6 +102,11 @@ void Array::store(const int ®, const int &position) const type_->store(reg, position); } +int Array::getSize() const +{ + return type_->getSize(); +} + // Pointer definition @@ -169,6 +174,37 @@ void Pointer::store(const int ®, const int &position) const printf("\tsw\t$%d,%d($fp)\n", reg, position); } +int Pointer::getSize() const +{ + return type_->getSize(); +} + +void Pointer::pointerLoad() const +{ + type_->load(); +} + +void Pointer::pointerLoad(const int ®, const int &position) const +{ + type_->load(reg, position); +} + +void Pointer::pointerStore() const +{ + + type_->store(); +} + +void Pointer::pointerStore(const int &position) const +{ + type_->store(position); +} + +void Pointer::pointerStore(const int ®, const int &position) const +{ + type_->store(reg, position); +} + // TypeContainer definition @@ -240,6 +276,11 @@ void TypeContainer::store(const int ®, const int &position) const type_->store(reg, position); } +int TypeContainer::getSize() const +{ + return type_->getSize(); +} + void TypeContainer::setSigned(bool _signed) { signed_ = _signed; @@ -332,6 +373,11 @@ void Int::store(const int ®, const int &position) const printf("\tsw\t$%d,%d($fp)\n", reg, position); } +int Int::getSize() const +{ + return 4; +} + // Void definition @@ -369,6 +415,11 @@ void Void::store(const int &) const void Void::store(const int &, const int &) const {} +int Void::getSize() const +{ + return 0; +} + // Short definition @@ -418,6 +469,11 @@ void Short::store(const int ®, const int &position) const printf("\tsh\t$%d,%d($fp)\n", reg, position); } +int Short::getSize() const +{ + return 2; +} + // Char definition @@ -467,6 +523,11 @@ void Char::store(const int ®, const int &position) const printf("\tsb\t$%d,%d($fp)\n", reg, position); } +int Char::getSize() const +{ + return 1; +} + // Float definition @@ -515,3 +576,8 @@ void Float::store(const int &, const int &) const { throw std::runtime_error("Error : Cannot store float yet"); } + +int Float::getSize() const +{ + return 4; +} |