コード例 #1
0
        //=======================

        /// <summary>
        /// Depth first traversal of an AST node
        /// </summary>
        /// <param name="node"></param>

        /// <summary>
        /// These functions emit the DesignScript code on the destination stream
        /// </summary>
        /// <param name="identNode"></param>
        #region ASTNODE_CODE_EMITTERS

        private void EmitArrayIndexerNode(ref ProtoCore.AST.AssociativeAST.ArrayIndexerNode arrIdxNode)
        {
            if (arrIdxNode.Array is ProtoCore.AST.AssociativeAST.IdentifierNode)
            {
                EmitIdentifierNode(ref arrIdxNode.Array);
            }
            else if (arrIdxNode.Array is ProtoCore.AST.AssociativeAST.BinaryExpressionNode)
            {
                ProtoCore.AST.AssociativeAST.AssociativeNode ben = (arrIdxNode.Array as ProtoCore.AST.AssociativeAST.BinaryExpressionNode).LeftNode;
                EmitIdentifierNode(ref ben);
                ProtoCore.AST.AssociativeAST.AssociativeNode rightNode = (arrIdxNode.Array as ProtoCore.AST.AssociativeAST.BinaryExpressionNode).RightNode;
                DFSTraverse(ref rightNode);
            }
        }
コード例 #2
0
        public void DFSTraverse(ref ProtoCore.AST.AssociativeAST.AssociativeNode node)
        {
            if (node is ProtoCore.AST.AssociativeAST.IdentifierNode)
            {
                EmitIdentifierNode(ref node);
            }
            else if (node is ProtoCore.AST.AssociativeAST.IdentifierListNode)
            {
                ProtoCore.AST.AssociativeAST.IdentifierListNode identList = node as ProtoCore.AST.AssociativeAST.IdentifierListNode;
                EmitIdentifierListNode(ref identList);
            }
            else if (node is ProtoCore.AST.AssociativeAST.IntNode)
            {
                ProtoCore.AST.AssociativeAST.IntNode intNode = node as ProtoCore.AST.AssociativeAST.IntNode;
                EmitIntNode(ref intNode);
            }
            else if (node is ProtoCore.AST.AssociativeAST.DoubleNode)
            {
                ProtoCore.AST.AssociativeAST.DoubleNode doubleNode = node as ProtoCore.AST.AssociativeAST.DoubleNode;
                EmitDoubleNode(ref doubleNode);
            }
            else if (node is ProtoCore.AST.AssociativeAST.FunctionCallNode)
            {
                ProtoCore.AST.AssociativeAST.FunctionCallNode funcCallNode = node as ProtoCore.AST.AssociativeAST.FunctionCallNode;
                EmitFunctionCallNode(ref funcCallNode);
            }
            else if (node is ProtoCore.AST.AssociativeAST.FunctionDotCallNode)
            {
                ProtoCore.AST.AssociativeAST.FunctionDotCallNode funcDotCall = node as ProtoCore.AST.AssociativeAST.FunctionDotCallNode;
                EmitFunctionDotCallNode(ref funcDotCall);
            }
            else if (node is ProtoCore.AST.AssociativeAST.BinaryExpressionNode)
            {
                ProtoCore.AST.AssociativeAST.BinaryExpressionNode binaryExpr = node as ProtoCore.AST.AssociativeAST.BinaryExpressionNode;
                if (binaryExpr.Optr != ProtoCore.DSASM.Operator.assign)
                {
                    ;
                }

                EmitBinaryNode(ref binaryExpr);
                if (binaryExpr.Optr == ProtoCore.DSASM.Operator.assign)
                {
                }
                if (binaryExpr.Optr != ProtoCore.DSASM.Operator.assign)
                {
                    ;
                }
            }
            else if (node is ProtoCore.AST.AssociativeAST.FunctionDefinitionNode)
            {
                ProtoCore.AST.AssociativeAST.FunctionDefinitionNode funcDefNode = node as ProtoCore.AST.AssociativeAST.FunctionDefinitionNode;
                EmitFunctionDefNode(ref funcDefNode);
            }
            else if (node is ProtoCore.AST.AssociativeAST.ClassDeclNode)
            {
                ProtoCore.AST.AssociativeAST.ClassDeclNode classDeclNode = node as ProtoCore.AST.AssociativeAST.ClassDeclNode;
                EmitClassDeclNode(ref classDeclNode);
            }
            else if (node is ProtoCore.AST.AssociativeAST.NullNode)
            {
                ProtoCore.AST.AssociativeAST.NullNode nullNode = node as ProtoCore.AST.AssociativeAST.NullNode;
                EmitNullNode(ref nullNode);
            }
            else if (node is ProtoCore.AST.AssociativeAST.ArrayIndexerNode)
            {
                ProtoCore.AST.AssociativeAST.ArrayIndexerNode arrIdxNode = node as ProtoCore.AST.AssociativeAST.ArrayIndexerNode;
                EmitArrayIndexerNode(ref arrIdxNode);
            }
            else if (node is ProtoCore.AST.AssociativeAST.ExprListNode)
            {
                ProtoCore.AST.AssociativeAST.ExprListNode exprListNode = node as ProtoCore.AST.AssociativeAST.ExprListNode;
                EmitExprListNode(ref exprListNode);
            }
        }