changed all prog indices to size_t; added explanatory comments to ivars

This commit is contained in:
Bob Polis 2020-09-22 10:50:07 +02:00
parent ea525575ab
commit 27ad2a900c

View File

@ -32,13 +32,13 @@ class interpreter {
std::string eval(std::istream& in, bool& done); std::string eval(std::istream& in, bool& done);
private: private:
std::vector<std::string> _prog; std::vector<std::string> _prog; // program lines without label defs or comments
std::vector<std::string> _stack; std::vector<std::string> _stack; // value stack
std::map<std::string, int> _labels; std::map<std::string, size_t> _labels; // label name => prog line index
std::map<std::string, std::string> _vars; std::map<std::string, std::string> _vars; // var name => string value
std::vector<int> _calls; std::vector<size_t> _calls; // call stack
std::vector<std::string>::size_type _pc {0}; size_t _pc {0}; // current program counter (index into _prog)
std::vector<size_t> _pc_offsets; std::vector<size_t> _pc_offsets; // removed line indices for prog index => source line
void reset(); void reset();
void exec_instruction(const std::string& code, bool& done); void exec_instruction(const std::string& code, bool& done);