]> gitweb.ps.run Git - toc/blobdiff - src/repr.h
comments
[toc] / src / repr.h
index 709528d3c8b55986ea65e73c164ff69f27d95855..569411c05db2315e7d1fd18c7b2a74b478ae07f7 100644 (file)
@@ -8,6 +8,8 @@
 \r
 using namespace std;\r
 \r
 \r
 using namespace std;\r
 \r
+// This contains a 1 to 1 representation of the defined language\r
+\r
 struct Type;\r
 struct Variable;\r
 struct Body;\r
 struct Type;\r
 struct Variable;\r
 struct Body;\r
@@ -37,6 +39,9 @@ struct AssignStmt;
 struct ReturnStmt;\r
 struct Stmt;\r
 \r
 struct ReturnStmt;\r
 struct Stmt;\r
 \r
+// Context is a collection of everything that can be defined in a namespace\r
+// that is reused for bodies so that the hierarchy can be walked uniformly\r
+// both up and down using the parent variable\r
 struct Context\r
 {\r
   std::optional<std::string> name;\r
 struct Context\r
 {\r
   std::optional<std::string> name;\r
@@ -44,6 +49,7 @@ struct Context
   std::vector<Variable> variables;\r
   std::vector<Function> functions;\r
   std::vector<Struct> structs;\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
 };\r
 \r
 enum class TypeModifierType\r
@@ -65,6 +71,21 @@ struct Type
   std::string name;\r
   std::vector<TypeModifier> modifiers;\r
   std::vector<Type> genericInstantiation;\r
   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
 };\r
 \r
 struct Variable\r
@@ -113,13 +134,11 @@ struct Namespace
 {\r
   std::string name;\r
   std::shared_ptr<Context> ctx;\r
 {\r
   std::string name;\r
   std::shared_ptr<Context> ctx;\r
-  std::vector<Namespace> namespaces;\r
 };\r
 \r
 struct Program\r
 {\r
   std::shared_ptr<Context> ctx;\r
 };\r
 \r
 struct Program\r
 {\r
   std::shared_ptr<Context> ctx;\r
-  std::vector<Namespace> namespaces;\r
 };\r
 \r
 enum class ExprType\r
 };\r
 \r
 enum class ExprType\r
@@ -170,6 +189,8 @@ struct DotExpr
   std::string identifier;\r
 };\r
 \r
   std::string identifier;\r
 };\r
 \r
+// OperatorType enum with corresponding string array to lookup\r
+// enum from string and the other way round\r
 enum class PrefixOperatorType\r
 {\r
   Plus, Minus, Increment, Decrement,\r
 enum class PrefixOperatorType\r
 {\r
   Plus, Minus, Increment, Decrement,\r