Implements indexing with period identifier style (`foo.bar`)
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -135,6 +135,7 @@ shared_ptr<NumericEvalValue> Evaluator::EvaluateIntegerExpression(const BoundExp
|
||||
case BoundExpressionKind::Variable: return dynamic_pointer_cast<NumericEvalValue>(this->GetVariable((BoundVariableExpression*)expression));
|
||||
case BoundExpressionKind ::FunctionCall: return dynamic_pointer_cast<NumericEvalValue>(this->EvaluateFunctionCallExpression(expression));
|
||||
case BoundExpressionKind ::Index: return dynamic_pointer_cast<NumericEvalValue>(this->EvaluateIndexExpression(expression));
|
||||
case BoundExpressionKind ::PeriodIndex: return dynamic_pointer_cast<NumericEvalValue>(this->EvaluatePeriodIndexExpression(expression));
|
||||
|
||||
case BoundExpressionKind ::LiteralString:
|
||||
case BoundExpressionKind ::LiteralBool:
|
||||
@@ -153,6 +154,7 @@ shared_ptr<BooleanEvalValue> Evaluator::EvaluateBoolExpression(const BoundExpres
|
||||
case BoundExpressionKind::Variable: return dynamic_pointer_cast<BooleanEvalValue>(this->GetVariable((BoundVariableExpression*)expression));
|
||||
case BoundExpressionKind ::FunctionCall: return dynamic_pointer_cast<BooleanEvalValue>(this->EvaluateFunctionCallExpression(expression));
|
||||
case BoundExpressionKind ::Index: return dynamic_pointer_cast<BooleanEvalValue>(this->EvaluateIndexExpression(expression));
|
||||
case BoundExpressionKind ::PeriodIndex: return dynamic_pointer_cast<BooleanEvalValue>(this->EvaluatePeriodIndexExpression(expression));
|
||||
|
||||
case BoundExpressionKind::Bad:
|
||||
case BoundExpressionKind::LiteralInteger:
|
||||
@@ -174,6 +176,7 @@ shared_ptr<StringEvalValue> Evaluator::EvaluateStringExpression(const BoundExpre
|
||||
case BoundExpressionKind::Variable: return dynamic_pointer_cast<StringEvalValue>(this->GetVariable((BoundVariableExpression*)expression));
|
||||
case BoundExpressionKind ::FunctionCall: return dynamic_pointer_cast<StringEvalValue>(this->EvaluateFunctionCallExpression(expression));
|
||||
case BoundExpressionKind ::Index: return dynamic_pointer_cast<StringEvalValue>(this->EvaluateIndexExpression(expression));
|
||||
case BoundExpressionKind ::PeriodIndex: return dynamic_pointer_cast<StringEvalValue>(this->EvaluatePeriodIndexExpression(expression));
|
||||
|
||||
case BoundExpressionKind::Bad:
|
||||
case BoundExpressionKind::LiteralInteger:
|
||||
@@ -191,6 +194,7 @@ shared_ptr<EvalValue> Evaluator::EvaluateFunctionExpression(const BoundExpressio
|
||||
switch (expression->GetKind()){
|
||||
case BoundExpressionKind ::Variable: return this->GetVariable((BoundVariableExpression*)expression);
|
||||
case BoundExpressionKind ::Index: return this->EvaluateIndexExpression(expression);
|
||||
case BoundExpressionKind ::PeriodIndex: return this->EvaluatePeriodIndexExpression(expression);
|
||||
default: throw;
|
||||
}
|
||||
}
|
||||
@@ -210,6 +214,7 @@ shared_ptr<EvalValue> Evaluator::EvaluateTableExpression(const BoundExpression *
|
||||
case BoundExpressionKind ::Index: return this->EvaluateIndexExpression(expression);
|
||||
case BoundExpressionKind ::NumericalTable: return this-> EvaluateNumericTableExpression(expression);
|
||||
case BoundExpressionKind ::Table: return this -> EvaluateComplexTableExpression(expression);
|
||||
case BoundExpressionKind ::PeriodIndex: return this->EvaluatePeriodIndexExpression(expression);
|
||||
default:
|
||||
throw;
|
||||
}
|
||||
@@ -276,6 +281,13 @@ shared_ptr<EvalValue> Evaluator::EvaluateIndexExpression(const BoundExpression *
|
||||
return indexable -> IndexValue(index.get()) -> Clone();
|
||||
}
|
||||
|
||||
shared_ptr<EvalValue> Evaluator::EvaluatePeriodIndexExpression(const BoundExpression *expression) {
|
||||
auto indexExpression = (BoundPeriodIndexExpression*)expression;
|
||||
auto index = indexExpression -> GetIndex().GetHash();
|
||||
auto indexable = this -> EvaluateExpression(indexExpression->GetIndexableExpression());
|
||||
return indexable -> IndexValue(index) -> Clone();
|
||||
}
|
||||
|
||||
shared_ptr<EvalValue> Evaluator::EvaluateNumericTableExpression(const BoundExpression *expression) {
|
||||
auto tableExpression = (BoundNumericalTableExpression*)expression;
|
||||
auto valueExpressions = tableExpression->GetExpressions();
|
||||
|
||||
Reference in New Issue
Block a user