コード例 #1
0
        private object EvaluteIndexingExpression(IndexingExpression expression, VariableContext context)
        {
            object instance = Evaluate(expression.Operand, context);
            int    index    = (int)Evaluate(expression.Indexer, context);

            return(((object[])instance)[index]);
        }
コード例 #2
0
        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();
            }
        }
コード例 #3
0
 public virtual TReturn Visit(IndexingExpression node, TParam param) => throw new NotImplementedException();
コード例 #4
0
 public virtual TReturn Visit(IndexingExpression node, TParam param)
 {
     node.Array.Accept(this, param);
     node.Index.Accept(this, param);
     return(DefaultReturn);
 }