#pragma once #include "repr.h" bool checkStmt( const Stmt & s, std::vector namespaces, std::vector vars) { return true; } bool checkFunction( const Function & f, 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, namespaces, vars)) return false; } return true; } bool checkProgram(const Program & p) { for (auto f : p.functions) { if (!checkFunction(f, p.namespaces, p.variables)) return false; } 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.namespaces, vars)) return false; } } return true; }