]> gitweb.ps.run Git - toc/blobdiff - src/repr.h
add generic.h (how did i miss that...)
[toc] / src / repr.h
index b30aecd1a8f15aa1fc9c827804ef6c01693856e8..959e74dfe891873eecfcdbf2671d003497f8bb95 100644 (file)
@@ -39,8 +39,12 @@ struct Stmt;
 \r
 struct Context\r
 {\r
+  std::optional<std::string> name;\r
   std::shared_ptr<Context> parent;\r
   std::vector<Variable> variables;\r
+  std::vector<Function> functions;\r
+  std::vector<Struct> structs;\r
+  std::vector<Namespace> namespaces;\r
 };\r
 \r
 enum class TypeModifierType\r
@@ -62,6 +66,21 @@ struct Type
   std::string name;\r
   std::vector<TypeModifier> modifiers;\r
   std::vector<Type> genericInstantiation;\r
+  \r
+  bool operator!=(const Type & that)\r
+  {\r
+    if (this->name != that.name)\r
+      return true;\r
+\r
+    for (int i = 0; i < this->modifiers.size(); i++)\r
+      if (this->modifiers[i].type != that.modifiers[i].type)\r
+        return true;\r
+\r
+    for (int i = 0; i < this->namespacePrefixes.size(); i++)\r
+      if (this->namespacePrefixes[i] != that.namespacePrefixes[i])\r
+        return true;\r
+    return false;\r
+  }\r
 };\r
 \r
 struct Variable\r
@@ -79,11 +98,13 @@ struct Body
 struct Function\r
 {\r
   std::string name;\r
-  std::vector<std::string> genericTypeNames;\r
-  std::vector<std::vector<Type>> genericInstantiations;\r
   Type returnType;\r
   std::vector<Variable> parameters;\r
   bool defined;\r
+\r
+  std::vector<std::string> genericTypeNames;\r
+  std::vector<std::vector<Type>> genericInstantiations;\r
+\r
   Body body;\r
 };\r
 \r
@@ -108,17 +129,11 @@ struct Namespace
 {\r
   std::string name;\r
   std::shared_ptr<Context> ctx;\r
-  std::vector<Struct> structs;\r
-  std::vector<Function> functions;\r
-  std::vector<Namespace> namespaces;\r
 };\r
 \r
 struct Program\r
 {\r
   std::shared_ptr<Context> ctx;\r
-  std::vector<Struct> structs;\r
-  std::vector<Function> functions;\r
-  std::vector<Namespace> namespaces;\r
 };\r
 \r
 enum class ExprType\r