예제 #1
0
        public override bool Equals(object obj)
        {
            ScopedArray rhs = obj as ScopedArray;

            if (((object)rhs) == null)
            {
                return(false);
            }

            return((this.scopeInfo == rhs.scopeInfo) && (this.arrayName == rhs.arrayName));
        }
예제 #2
0
        internal void InsertRootElementType(ScopedArray scopedArray, ArrayElementType rootElement)
        {
            if (null != scopedArray)
            {
                if (null == arrayTypeTable)
                {
                    arrayTypeTable = new Dictionary <ScopedArray, ArrayElementType>();
                }

                arrayTypeTable.Add(scopedArray, rootElement);
            }
        }
예제 #3
0
        protected override void DfsTraverse(ProtoCore.AST.Node pNode, ref ProtoCore.Type inferedType, bool isBooleanOp = false, ProtoCore.AssociativeGraph.GraphNode graphNode = null, ProtoCore.DSASM.AssociativeSubCompilePass subPass = ProtoCore.DSASM.AssociativeSubCompilePass.kNone)
        {
            AssociativeNode node = pNode as AssociativeNode;
            if ((null == node) || node.skipMe)
                return;

            if (node is IdentifierNode)
            {
                EmitIdentifierNode(node, ref inferedType, isBooleanOp, graphNode, subPass);
            }
            else if (node is IntNode)
            {
                EmitIntNode(node, ref inferedType, isBooleanOp, subPass);
            }
            else if (node is DoubleNode)
            {
                EmitDoubleNode(node, ref inferedType, isBooleanOp, subPass);
            }
            else if (node is BooleanNode)
            {
                EmitBooleanNode(node, ref inferedType, subPass);
            }
            else if (node is CharNode)
            {
                EmitCharNode(node, ref inferedType, isBooleanOp, subPass);
            }
            else if (node is StringNode)
            {
                EmitStringNode(node, ref inferedType, subPass);
            }
            else if (node is NullNode)
            {
                EmitNullNode(node, ref inferedType, isBooleanOp, subPass);
            }
            #if ENABLE_INC_DEC_FIX
            else if (node is PostFixNode)
            {
                EmitPostFixNode(node, ref inferedType);
            }
            #endif
            else if (node is ReturnNode)
            {
                EmitReturnNode(node);
            }
            else if (node is RangeExprNode)
            {
                EmitRangeExprNode(node, ref inferedType, subPass);
            }
            else if (node is ForLoopNode)
            {
                EmitForLoopNode(node);
            }
            else if (node is LanguageBlockNode)
            {
                EmitLanguageBlockNode(node, ref inferedType, subPass);
            }
            else if (node is ClassDeclNode)
            {
                EmitClassDeclNode(node, ref inferedType, subPass);
            }
            else if (node is ConstructorDefinitionNode)
            {
                EmitConstructorDefinitionNode(node, ref inferedType, subPass);
            }
            else if (node is FunctionDefinitionNode)
            {
                EmitFunctionDefinitionNode(node, ref inferedType, subPass);
            }
            else if (node is FunctionCallNode)
            {
                EmitFunctionCallNode(node, ref inferedType, isBooleanOp, graphNode, subPass);
            }
            else if (node is ModifierStackNode)
            {
                EmitModifierStackNode(node, ref inferedType);
            }
            else if (node is ExprListNode)
            {
                ScopedArray scopedArray = null;
                ArrayElementType parentElementType = this.arrayElementType;

                // The same code is parsed in multiple passes, don't populate array element type table all
                // the times, we should only do it when all things are parsed.
                bool generateArrayElementTypes = subPass == ProtoCore.DSASM.AssociativeSubCompilePass.kNone;

                if (generateArrayElementTypes && (null != CoreCodeGen.arrayTypeTable))
                {
                    ScopeInfo scopeInfo = new ScopeInfo()
                    {
                        // For global scope, "localProcedure" will be of null value.
                        BlockId = ((null == localProcedure) ? 0 : localProcedure.runtimeIndex),
                        ClassScope = ((null == localProcedure) ? -1 : localProcedure.classScope),
                        FunctionIndex = ((null == localProcedure) ? -1 : localProcedure.procId)
                    };

                    node.Name = node.Name == null ? string.Empty : node.Name;
                    if (null != parentElementType || (!string.IsNullOrEmpty(node.Name)))
                    {
                        scopedArray = new ScopedArray(scopeInfo, node.Name);
                        this.arrayElementType = new ArrayElementType();
                    }
                }

                EmitExprListNode(node, ref inferedType, graphNode, subPass);

                if (generateArrayElementTypes && (null != CoreCodeGen.arrayTypeTable))
                {
                    if (null == parentElementType)
                    {
                        CoreCodeGen.arrayTypeTable.InsertRootElementType(
                            scopedArray, this.arrayElementType);

                        this.arrayElementType = null;
                    }
                    else
                    {
                        parentElementType.AppendChild(this.arrayElementType);
                        this.arrayElementType = parentElementType;
                    }
                }
            }
            else if (node is IdentifierListNode)
            {
                EmitIdentifierListNode(node, ref inferedType, isBooleanOp, graphNode, subPass);
            }
            else if (node is IfStatementNode)
            {
                EmitIfStatementNode(node, ref inferedType);
            }
            else if (node is InlineConditionalNode)
            {
                EmitInlineConditionalNode(node, ref inferedType, graphNode, subPass);
            }
            else if (node is UnaryExpressionNode)
            {
                EmitUnaryExpressionNode(node, ref inferedType, graphNode);
            }
            else if (node is BinaryExpressionNode)
            {
                EmitBinaryExpressionNode(node, ref inferedType, isBooleanOp, graphNode, subPass);
            }
            else if (node is ImportNode)
            {
                EmitImportNode(node, ref inferedType, subPass);
            }
            else if (node is ExceptionHandlingNode)
            {
                EmitExceptionHandlingNode(node, graphNode, subPass);
            }
            else if (node is ThrowNode)
            {
            }
        }
예제 #4
0
        internal void InsertRootElementType(ScopedArray scopedArray, ArrayElementType rootElement)
        {
            if (null != scopedArray)
            {
                if (null == arrayTypeTable)
                    arrayTypeTable = new Dictionary<ScopedArray, ArrayElementType>();

                arrayTypeTable.Add(scopedArray, rootElement);
            }
        }