]> gitweb.ps.run Git - toc/blobdiff - src/check.h
pre change
[toc] / src / check.h
index 9e6797fe7c5d6de0646fea83bc53d6634e07d125..091b646edc5953bf0ff9b345dc19bf0823295d8f 100644 (file)
@@ -4,27 +4,22 @@
 \r
 bool checkStmt(\r
   const Stmt & s,\r
 \r
 bool checkStmt(\r
   const Stmt & s,\r
-  std::vector<Struct> structs,\r
-  std::vector<Function> funcs,\r
+  std::vector<Namespace> namespaces,\r
   std::vector<Variable> vars)\r
 {\r
   std::vector<Variable> vars)\r
 {\r
-  // switch (s.type) {\r
-  // case StmtType::Assign:\r
-  //   if (!checkVar(s._assign.))\r
-  // }\r
   return true;\r
 }\r
 \r
 bool checkFunction(\r
   const Function & f,\r
   return true;\r
 }\r
 \r
 bool checkFunction(\r
   const Function & f,\r
-  std::vector<Struct> structs,\r
-  std::vector<Function> funcs,\r
+  std::vector<Namespace> namespaces,\r
   std::vector<Variable> vars)\r
 {\r
   vars.insert(vars.end(), f.parameters.begin(), f.parameters.end());\r
   vars.insert(vars.end(), f.body.variables.begin(), f.body.variables.end());\r
   std::vector<Variable> vars)\r
 {\r
   vars.insert(vars.end(), f.parameters.begin(), f.parameters.end());\r
   vars.insert(vars.end(), f.body.variables.begin(), f.body.variables.end());\r
-  for (auto s : f.body.statements) {\r
-    if (!checkStmt(s, structs, funcs, vars))\r
+  for (auto s : f.body.statements)\r
+  {\r
+    if (!checkStmt(s, namespaces, vars))\r
       return false;\r
   }\r
   return true;\r
       return false;\r
   }\r
   return true;\r
@@ -32,16 +27,19 @@ bool checkFunction(
 \r
 bool checkProgram(const Program & p)\r
 {\r
 \r
 bool checkProgram(const Program & p)\r
 {\r
-  for (auto f : p.functions) {\r
-    if (!checkFunction(f, p.structs, p.functions, p.variables))\r
+  for (auto f : p.functions)\r
+  {\r
+    if (!checkFunction(f, p.namespaces, p.variables))\r
       return false;\r
   }\r
       return false;\r
   }\r
-  for (auto s : p.structs) {\r
+  for (auto s : p.structs)\r
+  {\r
     std::vector<Variable> vars = p.variables;\r
     for (auto v : s.members)\r
       vars.push_back(v);\r
     std::vector<Variable> vars = p.variables;\r
     for (auto v : s.members)\r
       vars.push_back(v);\r
-    for (auto f : s.methods) {\r
-      if (!checkFunction(f, p.structs, p.functions, vars))\r
+    for (auto f : s.methods)\r
+    {\r
+      if (!checkFunction(f, p.namespaces, vars))\r
         return false;\r
     }\r
   }\r
         return false;\r
     }\r
   }\r