aboutsummaryrefslogtreecommitdiffstats
path: root/c_compiler/include/declaration.hpp
diff options
context:
space:
mode:
authorYann Herklotz <ymherklotz@gmail.com>2017-03-24 21:11:52 +0000
committerYann Herklotz <ymherklotz@gmail.com>2017-03-24 21:11:52 +0000
commit42156b87d0bc78eb8bac2c0e1cb41f105bbfc32b (patch)
treec5cc1a33e9393c85de3187c594f3be38bb53a5a4 /c_compiler/include/declaration.hpp
parente539805d39de73e25eeaa48a48730255c4ae695f (diff)
downloadCompiler-42156b87d0bc78eb8bac2c0e1cb41f105bbfc32b.tar.gz
Compiler-42156b87d0bc78eb8bac2c0e1cb41f105bbfc32b.zip
Working on array
Diffstat (limited to 'c_compiler/include/declaration.hpp')
-rw-r--r--c_compiler/include/declaration.hpp31
1 files changed, 22 insertions, 9 deletions
diff --git a/c_compiler/include/declaration.hpp b/c_compiler/include/declaration.hpp
index bcd12a7..b607c3c 100644
--- a/c_compiler/include/declaration.hpp
+++ b/c_compiler/include/declaration.hpp
@@ -13,34 +13,47 @@ typedef std::shared_ptr<Declaration> DeclarationPtr;
class Declaration : public Node {
-private:
+protected:
TypePtr type_;
std::string id_;
ExpressionPtr initializer_;
DeclarationPtr next_declaration_;
DeclarationPtr next_list_declaration_;
bool extern_declaration_;
-
public:
- Declaration(const std::string& id = "", Expression* initializer = nullptr);
+ Declaration(const std::string &id = "", Expression *initializer = nullptr);
+ Declaration(const std::string &id, ExpressionPtr initializer);
virtual void print() const;
virtual void printXml() const;
- virtual VariableStackBindings printAsm(VariableStackBindings bindings, unsigned& label_count) const;
+ virtual VariableStackBindings printAsm(VariableStackBindings bindings, unsigned &label_count) const;
+ virtual VariableStackBindings localAsm(VariableStackBindings bindings, unsigned &label_count) const;
+ virtual void countDeclarations(unsigned &declaration_count) const;
- VariableStackBindings localAsm(VariableStackBindings bindings, unsigned& label_count) const;
-
- void linkDeclaration(Declaration* next_declaration);
- void linkListDeclaration(Declaration* next_list_declaration);
+ void linkDeclaration(Declaration *next_declaration);
+ void linkListDeclaration(Declaration *next_list_declaration);
void setType(TypePtr type);
- void setInitializer(Expression* initializer);
+ void setInitializer(Expression *initializer);
void setExternDeclaration(bool is_extern);
DeclarationPtr getNext() const;
DeclarationPtr getNextListItem() const;
+ ExpressionPtr getInitializer() const;
std::string getId() const;
TypePtr getType() const;
};
+class ArrayDeclaration : public Declaration
+{
+private:
+ unsigned size_;
+public:
+ ArrayDeclaration(const std::string &id = "", ExpressionPtr initializer = nullptr, const unsigned &size = 0);
+
+ virtual VariableStackBindings printAsm(VariableStackBindings bindings, unsigned &label_count) const;
+ virtual VariableStackBindings localAsm(VariableStackBindings bindings, unsigned &label_count) const;
+ virtual void countDeclarations(unsigned &declaration_count) const;
+};
+
#endif