X-Git-Url: https://gitweb.ps.run/toc/blobdiff_plain/8aeae09e74b46ca52866f22b48f55fecdf27b849..dbc4a22d3c8c4189459f0361cb9da06415ec2dc9:/src/check.h diff --git a/src/check.h b/src/check.h index 9e6797f..091b646 100644 --- a/src/check.h +++ b/src/check.h @@ -4,27 +4,22 @@ bool checkStmt( const Stmt & s, - std::vector structs, - std::vector funcs, + std::vector namespaces, std::vector vars) { - // switch (s.type) { - // case StmtType::Assign: - // if (!checkVar(s._assign.)) - // } return true; } bool checkFunction( const Function & f, - std::vector structs, - std::vector funcs, + std::vector namespaces, std::vector vars) { vars.insert(vars.end(), f.parameters.begin(), f.parameters.end()); vars.insert(vars.end(), f.body.variables.begin(), f.body.variables.end()); - for (auto s : f.body.statements) { - if (!checkStmt(s, structs, funcs, vars)) + for (auto s : f.body.statements) + { + if (!checkStmt(s, namespaces, vars)) return false; } return true; @@ -32,16 +27,19 @@ bool checkFunction( bool checkProgram(const Program & p) { - for (auto f : p.functions) { - if (!checkFunction(f, p.structs, p.functions, p.variables)) + for (auto f : p.functions) + { + if (!checkFunction(f, p.namespaces, p.variables)) return false; } - for (auto s : p.structs) { + for (auto s : p.structs) + { std::vector vars = p.variables; for (auto v : s.members) vars.push_back(v); - for (auto f : s.methods) { - if (!checkFunction(f, p.structs, p.functions, vars)) + for (auto f : s.methods) + { + if (!checkFunction(f, p.namespaces, vars)) return false; } }