Esempio n. 1
0
        public override CSNode VisitArray_index(CSScriptParser.Array_indexContext context)
        {
            CSArrayIndexNode node = new CSArrayIndexNode(context.Start.Line, context.Start.Column);

            if (context.expression() != null)
            {
                node._children    = new CSNode[1];
                node._children[0] = Visit(context.expression());
            }
            else
            {
                node._children = null;
            }

            return(node);
        }
Esempio n. 2
0
        public override CSNode VisitNewExp(CSScriptParser.NewExpContext context)
        {
            CSOPNewNode node = new CSOPNewNode(context.Start.Line, context.Start.Column);

            node._children = new CSNode[6];

            CSScriptParser.ParametersContext  parameters = context.parameters();
            CSScriptParser.Array_indexContext arrayIndex = context.array_index();

            System.Type currentType;
            string      currentTypeString = VisitTypeElements(context.type_elements(), out currentType);

            if (arrayIndex != null)
            {
                currentTypeString = currentTypeString + "[]";
                currentType       = ReflectionUtil.GetType(currentTypeString);
            }

            if (currentType == null)
            {
                CSLog.E(node, "unknown type: " + currentTypeString);
                return(null);
            }

            CSTypeNode typeNode = new CSTypeNode(context.Start.Line, context.Start.Column);

            typeNode._type         = currentType;
            typeNode._typeString   = currentTypeString;
            typeNode._assemblyName = currentType.Assembly.GetCleanName();

            node._children[0] = typeNode;

            if (parameters != null)
            {
                node._children[1] = Visit(parameters);
            }

            if (arrayIndex != null)
            {
                node._children[2] = Visit(arrayIndex);
            }

            CSScriptParser.InitializerContext initializer = context.initializer();
            if (initializer != null)
            {
                CSScriptParser.Array_initializerContext arrayInitializer = initializer.array_initializer();
                if (arrayInitializer != null)
                {
                    node._children[3] = Visit(arrayInitializer);
                }

                CSScriptParser.Dictionary_initializerContext dictionaryInitializer = initializer.dictionary_initializer();
                if (dictionaryInitializer != null)
                {
                    node._children[4] = Visit(dictionaryInitializer);
                }

                CSScriptParser.Class_initializerContext classInitializer = initializer.class_initializer();
                if (classInitializer != null)
                {
                    node._children[5] = Visit(classInitializer);
                }
            }
            return(node);
        }
 /// <summary>
 /// Visit a parse tree produced by <see cref="CSScriptParser.array_index"/>.
 /// <para>
 /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
 /// on <paramref name="context"/>.
 /// </para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 /// <return>The visitor result.</return>
 public virtual Result VisitArray_index([NotNull] CSScriptParser.Array_indexContext context)
 {
     return(VisitChildren(context));
 }