swissChili | 7babd92 | 2021-12-02 22:46:48 -0800 | [diff] [blame] | 1 | #include "VarContext.h" |
| 2 | |
swissChili | 3e98c06 | 2021-12-04 22:07:38 -0800 | [diff] [blame^] | 3 | void VarContext::add(char t, const QString &name, const Token &value) { |
swissChili | 7babd92 | 2021-12-02 22:46:48 -0800 | [diff] [blame] | 4 | _vars.insert(name, Var{t, value}); |
| 5 | } |
| 6 | |
| 7 | char VarContext::exists(const QString &name) { |
swissChili | 3e98c06 | 2021-12-04 22:07:38 -0800 | [diff] [blame^] | 8 | return _vars.contains(name) ? _vars[name].t : 0; |
swissChili | 7babd92 | 2021-12-02 22:46:48 -0800 | [diff] [blame] | 9 | } |
| 10 | |
swissChili | 3e98c06 | 2021-12-04 22:07:38 -0800 | [diff] [blame^] | 11 | Token VarContext::singleVar(const QString &name) { |
swissChili | 7babd92 | 2021-12-02 22:46:48 -0800 | [diff] [blame] | 12 | return _vars[name].value; |
| 13 | } |
| 14 | |
| 15 | VarContext::VarContext(const VarContext &other) noexcept { |
| 16 | _vars = other._vars; |
| 17 | } |
swissChili | 3e98c06 | 2021-12-04 22:07:38 -0800 | [diff] [blame^] | 18 | |
| 19 | void VarContext::add(char t, const QString &name, const QList<Token> &value) { |
| 20 | _vars.insert(name,Var{t,{},value}); |
| 21 | } |
| 22 | |
| 23 | QList<Token> VarContext::expressionVar(const QString &name) { |
| 24 | return _vars[name].expressionValue; |
| 25 | } |