]> gitweb.ps.run Git - toc/blobdiff - src/repr.h
structs and functions in ctx
[toc] / src / repr.h
index fc77d92b43a8f1815abda6dfe5a802e5424853c6..709528d3c8b55986ea65e73c164ff69f27d95855 100644 (file)
@@ -39,8 +39,11 @@ 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
 };\r
 \r
 enum class TypeModifierType\r
@@ -61,6 +64,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
@@ -77,9 +81,14 @@ struct Body
 \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
@@ -94,6 +103,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
@@ -102,16 +113,12 @@ 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
@@ -125,6 +132,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
@@ -132,6 +140,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
@@ -156,6 +165,7 @@ struct ParenExpr
 \r
 struct DotExpr\r
 {\r
+  bool isPointer;\r
   std::shared_ptr<Expr> expr;\r
   std::string identifier;\r
 };\r