]> gitweb.ps.run Git - toc/blobdiff - src/repr.h
example and todo
[toc] / src / repr.h
index f196427fbe6a9cfae8cf34e6ac95a6d8978caa14..ff54f971c731da26a9f2da64a683c5c86cc01d79 100644 (file)
@@ -37,6 +37,12 @@ struct AssignStmt;
 struct ReturnStmt;\r
 struct Stmt;\r
 \r
+struct Context\r
+{\r
+  std::shared_ptr<Context> parent;\r
+  std::vector<Variable> variables;\r
+};\r
+\r
 enum class TypeModifierType\r
 {\r
   Pointer, Array\r
@@ -55,6 +61,7 @@ struct Type
   std::vector<std::string> namespacePrefixes;\r
   std::string name;\r
   std::vector<TypeModifier> modifiers;\r
+  std::vector<Type> genericInstantiation;\r
 };\r
 \r
 struct Variable\r
@@ -65,15 +72,20 @@ struct Variable
 \r
 struct Body\r
 {\r
-  std::vector<Variable> variables;\r
+  std::shared_ptr<Context> ctx;\r
   std::vector<Stmt> statements;\r
 };\r
 \r
 struct Function\r
 {\r
-  Type returnType;\r
   std::string name;\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
@@ -88,6 +100,8 @@ struct StructMember
 struct Struct\r
 {\r
   std::string name;\r
+  std::vector<std::string> genericTypeNames;\r
+  std::vector<std::vector<Type>> genericInstantiations;\r
   std::vector<StructMember<Variable>> members;\r
   std::vector<StructMember<Function>> methods;\r
 };\r
@@ -95,7 +109,7 @@ struct Struct
 struct Namespace\r
 {\r
   std::string name;\r
-  std::vector<Variable> variables;\r
+  std::shared_ptr<Context> ctx;\r
   std::vector<Struct> structs;\r
   std::vector<Function> functions;\r
   std::vector<Namespace> namespaces;\r
@@ -103,7 +117,7 @@ struct Namespace
 \r
 struct Program\r
 {\r
-  std::vector<Variable> variables;\r
+  std::shared_ptr<Context> ctx;\r
   std::vector<Struct> structs;\r
   std::vector<Function> functions;\r
   std::vector<Namespace> namespaces;\r
@@ -119,6 +133,7 @@ struct FuncExpr
   std::vector<std::string> namespacePrefixes;\r
   std::string functionName;\r
   std::vector<Expr> arguments;\r
+  std::vector<Type> genericInstantiation;\r
 };\r
 \r
 struct MethodExpr\r
@@ -126,6 +141,7 @@ struct MethodExpr
   std::shared_ptr<Expr> expr;\r
   std::string methodName;\r
   std::vector<Expr> arguments;\r
+  std::vector<Type> genericInstantiation;\r
 };\r
 \r
 enum class LitType\r
@@ -150,6 +166,7 @@ struct ParenExpr
 \r
 struct DotExpr\r
 {\r
+  bool isPointer;\r
   std::shared_ptr<Expr> expr;\r
   std::string identifier;\r
 };\r