summaryrefslogtreecommitdiff
path: root/TypeManager.hh
diff options
context:
space:
mode:
authorNagi5Yeq <wu@x-nagi.com>2020-05-21 13:32:12 +0800
committerNagi5Yeq <wu@x-nagi.com>2020-05-21 13:32:12 +0800
commit3832be8be4b23fb9e93a3f181e4205eadbdbf4de (patch)
tree0b958eb72400458401be619b04a8a6cf77194255 /TypeManager.hh
parent41f6e75e3f26bdcccfcb3910f202452e14653826 (diff)
binary and unary operations
Diffstat (limited to 'TypeManager.hh')
-rw-r--r--TypeManager.hh24
1 files changed, 24 insertions, 0 deletions
diff --git a/TypeManager.hh b/TypeManager.hh
index 248a53a..35a5d78 100644
--- a/TypeManager.hh
+++ b/TypeManager.hh
@@ -1,15 +1,39 @@
#ifndef PCC_TYPEMANAGER_H
#define PCC_TYPEMANAGER_H
+#include <map>
+#include <memory>
+#include <utility>
+#include <vector>
+
#include "Type.hh"
namespace pcc {
+enum class BuiltinType { BOOLEAN, CHAR, INTEGER, REAL, STRING, BUILTIN_NUMBER };
class TypeManager {
+
public:
TypeManager();
+ std::shared_ptr<Type> GetBuiltinType(BuiltinType type);
+
+ // binary operators may change type
+ std::pair<std::shared_ptr<Type>, Value>
+ CreateOperation(BinaryOperator op, std::shared_ptr<Type> LeftType,
+ std::shared_ptr<Type> RightType, Value left,
+ Value right, Context* context);
+
+ // unary operators never change type
+ Value CreateOperation(UnaryOperator op, std::shared_ptr<Type> type, Value v,
+ Context* context);
private:
+ std::vector<std::shared_ptr<Type>> builtins_;
std::vector<std::shared_ptr<Type>> types_;
+
+ // if we are porting to some 64-bit machines, we can change these types to
+ // 64-bit type, in order to make pointers behave correctly
+ std::shared_ptr<Type> PointerDifferenceType_;
+ std::shared_ptr<Type> PointerIndexType_;
};
} // namespace pcc