2025-10-04 11:02:55 +10:00
|
|
|
#include "evaluate.h"
|
|
|
|
|
#include "../../defs/defs.h"
|
|
|
|
|
#include "../../executor/executor.h"
|
|
|
|
|
#include "../../data/data.h"
|
|
|
|
|
|
|
|
|
|
Value evaluate(Value val) {
|
|
|
|
|
if (val.valtype == ValueType::Processed) {
|
|
|
|
|
if (val.processed) {
|
|
|
|
|
return execute(*val.processed);
|
|
|
|
|
}
|
|
|
|
|
} else if (val.valtype == ValueType::Variable) {
|
|
|
|
|
return data::getValue(val.varName.key);
|
2025-10-04 20:37:55 +10:00
|
|
|
} else if (val.valtype == ValueType::Identifier) {
|
|
|
|
|
// Check if it's a variable that doesn't start with $
|
|
|
|
|
for (auto it = data::scopes.rbegin(); it != data::scopes.rend(); ++it) {
|
|
|
|
|
if (it->count(val.string_val)) {
|
|
|
|
|
return (*it)[val.string_val];
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-10-04 11:02:55 +10:00
|
|
|
}
|
|
|
|
|
return val;
|
|
|
|
|
}
|