aboutsummaryrefslogtreecommitdiffstats
path: root/c_compiler/include/type.hpp
diff options
context:
space:
mode:
authorYann Herklotz <ymherklotz@gmail.com>2017-03-21 17:03:38 +0000
committerYann Herklotz <ymherklotz@gmail.com>2017-03-21 17:03:38 +0000
commit190b7a0e5d45367230795ac0bdf6fc2f248ba9e1 (patch)
treedc9a605ced1784faf80d71f7f59e49b79d6bb2c7 /c_compiler/include/type.hpp
parentaf8b76d0a83813b3cebac7468db4bd64e534c235 (diff)
downloadCompiler-190b7a0e5d45367230795ac0bdf6fc2f248ba9e1.tar.gz
Compiler-190b7a0e5d45367230795ac0bdf6fc2f248ba9e1.zip
changed type layout to have all necessary information
Diffstat (limited to 'c_compiler/include/type.hpp')
-rw-r--r--c_compiler/include/type.hpp86
1 files changed, 58 insertions, 28 deletions
diff --git a/c_compiler/include/type.hpp b/c_compiler/include/type.hpp
index 9b9bbba..bd9fd4b 100644
--- a/c_compiler/include/type.hpp
+++ b/c_compiler/include/type.hpp
@@ -8,71 +8,101 @@
#include <string>
class Type;
-
typedef std::shared_ptr<Type> TypePtr;
-
-class Type : public Node {
+class Type : public Node
+{
public:
virtual void print() const;
virtual void printXml() const;
virtual VariableStackBindings printAsm(VariableStackBindings bindings, unsigned& label_count) const;
virtual std::string getType() const = 0;
-};
+ virtual TypePtr type();
+ virtual TypePtr type(Type* type_ptr);
+ virtual TypePtr type(TypePtr type_ptr);
+ virtual void setSigned(bool _signed);
+ virtual void setExtern(bool _extern);
+ virtual void setStatic(bool _static);
+ virtual void setConst(bool _const);
+ virtual void setSize(int size);
+};
-class Specifier : public Type {
+class Array : public Type
+{
public:
- virtual std::string getType() const = 0;
+ Array();
+ virtual std::string getType() const;
};
-
-class Pointer : public Type {
-protected:
- TypePtr pointer_type_;
-
+class Pointer : public Type
+{
public:
- Pointer(Type* pointer_type);
-
+ Pointer();
virtual std::string getType() const;
};
-
-class Array : public Type {
+class TypeContainer : public Type
+{
protected:
- TypePtr array_type_;
- unsigned size_;
+ TypePtr type_;
+ int size_;
+ bool extern_;
+ bool static_;
+ bool const_;
+ bool signed_;
public:
- Array(Type* array_type, unsigned size = 0);
-
+ TypeContainer();
+
virtual std::string getType() const;
+ virtual TypePtr type();
+ virtual TypePtr type(Type* type_ptr);
+ virtual TypePtr type(TypePtr type_ptr);
+ virtual void setSigned(bool _signed);
+ virtual void setExtern(bool _extern);
+ virtual void setStatic(bool _static);
+ virtual void setConst(bool _const);
+ virtual void setSize(int size);
};
-
-class Void : public Specifier {
+class Specifier : public Type
+{
public:
- Void();
-
- virtual std::string getType() const;
+ virtual std::string getType() const = 0;
};
-
-class Int : public Specifier {
+class Int : public Specifier
+{
public:
Int();
virtual std::string getType() const;
};
+class Void : public Specifier
+{
+public:
+ Void();
+
+ virtual std::string getType() const;
+};
-class Char : public Specifier {
+class Char : public Specifier
+{
public:
Char();
- virtual std::string getType() const;
+ virtual std::string getType() const;
};
+class Float : public Specifier
+{
+public:
+ Float();
+
+ virtual std::string getType() const;
+};
#endif