Exemple #1
0
        private RuntimeResult VisitSubscriptNode(SubscriptNode node, Context context)
        {
            RuntimeResult baseResult = Visit(node.BaseNode, context);

            if (baseResult.HasError)
            {
                return(baseResult);
            }
            RuntimeResult indexResult = Visit(node.IndexNode, context);

            if (indexResult.HasError)
            {
                return(indexResult);
            }
            return(baseResult.Value.Subscript(indexResult.Value));
        }
Exemple #2
0
        private RuntimeResult VisitSubscriptAssignNode(SubscriptAssignNode node, Context context)
        {
            SubscriptNode subscript    = (SubscriptNode)node.Target;
            RuntimeResult targetResult = Visit(subscript.BaseNode, context);

            if (targetResult.HasError)
            {
                return(targetResult);
            }
            RuntimeResult indexResult = Visit(subscript.IndexNode, context);

            if (indexResult.HasError)
            {
                return(indexResult);
            }
            RuntimeResult exprResult = Visit(node.Node, context);

            if (exprResult.HasError)
            {
                return(exprResult);
            }
            return(targetResult.Value.SubscriptAssign(indexResult.Value, exprResult.Value));
        }