Implements indexing, currently can only be used with strings
This commit is contained in:
@@ -32,6 +32,12 @@ public:
|
||||
shared_ptr<EvalValue> Clone() final{
|
||||
return make_shared<StringEvalValue>(_value);
|
||||
}
|
||||
|
||||
EvalValue* IndexValue(EvalValue* val) final{
|
||||
// Porygon is 1-indexed, so we convert to that.
|
||||
auto l = val->EvaluateInteger() - 1;
|
||||
return new StringEvalValue(string(1, _value[l]));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user