private object EvaluteIndexingExpression(IndexingExpression expression, VariableContext context) { object instance = Evaluate(expression.Operand, context); int index = (int)Evaluate(expression.Indexer, context); return(((object[])instance)[index]); }
private void CheckIndexingExpression(IndexingExpression e, TypeCheckingContext context) { PerformTypeChecking(e.Operand, context); PerformTypeChecking(e.Indexer, context); if (!e.Operand.Type.IsArray) { context.ErrorProvider.ThrowException("Only array types can use [] operator.", e); } else if (!ReflectionSnippets.Accepts(typeof(int), e.Indexer.Type)) { context.ErrorProvider.ThrowException("Indexer must be convertiable to int.", e); } else { e.Type = e.Operand.Type.GetElementType(); } }
public virtual TReturn Visit(IndexingExpression node, TParam param) => throw new NotImplementedException();
public virtual TReturn Visit(IndexingExpression node, TParam param) { node.Array.Accept(this, param); node.Index.Accept(this, param); return(DefaultReturn); }