示例#1
0
 protected override void Visit(AssignVariableChunk chunk)
 {
     CodeIndent(chunk)
     .Write(chunk.Name)
     .Write(" = ")
     .WriteLine(chunk.Value);
     CodeDefault();
 }
示例#2
0
 private void VisitSet(SpecialNodeInspector inspector)
 {
     foreach (AttributeNode node in inspector.Attributes)
     {
         AssignVariableChunk item = new AssignVariableChunk {
             Name     = node.Name,
             Value    = this.AsTextOrientedCode(node),
             Position = this.Locate(node)
         };
         this.Chunks.Add(item);
     }
 }
示例#3
0
        protected override void Visit(AssignVariableChunk chunk)
        {
            if (!_variables.IsDeclared(chunk.Name))
            {
                _variables.Declare(chunk.Name);
            }

            var value = chunk.Value;

            if (Snippets.IsNullOrEmpty(value))
            {
                value = "None";
            }
            _source.Write(chunk.Name).Write("=").WriteLine(value);
        }
示例#4
0
        private void VisitFor(SpecialNode specialNode, SpecialNodeInspector inspector)
        {
            AttributeNode attr = inspector.TakeAttribute("each");
            ForEachChunk  item = new ForEachChunk {
                Code     = this.AsCode(attr),
                Position = this.Locate(specialNode.Element)
            };

            this.Chunks.Add(item);
            using (new Frame(this, item.Body))
            {
                foreach (AttributeNode node2 in inspector.Attributes)
                {
                    AssignVariableChunk chunk2 = new AssignVariableChunk {
                        Name     = node2.Name,
                        Value    = this.AsCode(node2),
                        Position = this.Locate(node2)
                    };
                    this.Chunks.Add(chunk2);
                }
                base.Accept(specialNode.Body);
            }
        }
示例#5
0
 protected override void Visit(AssignVariableChunk chunk)
 {
     Examine(chunk.Value);
 }
 protected override void Visit(AssignVariableChunk chunk)
 {
     chunk.Value = this.Process(chunk, chunk.Value);
     base.Visit(chunk);
 }
示例#7
0
 protected abstract void Visit(AssignVariableChunk chunk);
示例#8
0
        protected override void Visit(AttributeNode attributeNode)
        {
            var accumulatedNodes = new List <Node>();
            var processedNodes   = new List <Node>();

            foreach (var node in attributeNode.Nodes)
            {
                if (node is ConditionNode)
                {
                    // condition nodes take the prior unconditional nodes as content
                    var conditionNode = (ConditionNode)node;
                    MovePriorNodesUnderCondition(conditionNode, accumulatedNodes);

                    // prior nodes and condition are set for output
                    processedNodes.AddRange(accumulatedNodes);
                    processedNodes.Add(conditionNode);

                    accumulatedNodes.Clear();
                }
                else
                {
                    // other types add to the unconditional list
                    accumulatedNodes.Add(node);
                }
            }
            processedNodes.AddRange(accumulatedNodes);

            var allNodesAreConditional = processedNodes.All(node => node is ConditionNode);

            if (allNodesAreConditional == false || processedNodes.Any() == false)
            {
                // This attribute may not disapper - send it literally
                AddLiteral(" " + attributeNode.Name + "=\"");
                foreach (var node in processedNodes)
                {
                    Accept(node);
                }
                AddLiteral("\"");
            }
            else
            {
                var scope = new ScopeChunk();
                scope.Body.Add(new LocalVariableChunk {
                    Name = "__just__once__", Value = new Snippets("0")
                });

                _sendAttributeOnce = new ConditionalChunk {
                    Type = ConditionalType.If, Condition = new Snippets("__just__once__ < 1")
                };
                _sendAttributeOnce.Body.Add(new SendLiteralChunk {
                    Text = " " + attributeNode.Name + "=\""
                });
                _sendAttributeIncrement = new AssignVariableChunk {
                    Name = "__just__once__", Value = "1"
                };


                Chunks.Add(scope);

                using (new Frame(this, scope.Body))
                {
                    foreach (var node in processedNodes)
                    {
                        Accept(node);
                    }
                }
                _sendAttributeOnce      = null;
                _sendAttributeIncrement = null;

                var ifWasSent = new ConditionalChunk {
                    Type = ConditionalType.If, Condition = new Snippets("__just__once__ > 0")
                };
                scope.Body.Add(ifWasSent);
                ifWasSent.Body.Add(new SendLiteralChunk {
                    Text = "\""
                });
            }
        }
 protected override void Visit(AssignVariableChunk chunk)
 {
     chunk.Value = Process(chunk, chunk.Value);
     base.Visit(chunk);
 }
 protected override void Visit(AssignVariableChunk chunk)
 {
     this._source.Append(chunk.Name).Append(" = ").Append((string)chunk.Value).AppendLine(";");
 }
 protected override void Visit(AssignVariableChunk chunk)
 {
     _source.Append(chunk.Name).Append(" = ").Append(chunk.Value).AppendLine(";");
 }
 protected override void Visit(AssignVariableChunk chunk)
 {
     Examine(chunk.Value);
 }
示例#13
0
 protected override void Visit(AssignVariableChunk chunk)
 {
 }
示例#14
0
 protected override void Visit(AssignVariableChunk chunk)
 {
     CodeIndent(chunk)
         .Write(chunk.Name)
         .Write(" = ")
         .WriteCode(chunk.Value)
         .WriteLine(";");
     CodeDefault();
 }
 protected override void Visit(AssignVariableChunk chunk)
 {
 }
 protected abstract void Visit(AssignVariableChunk chunk);
示例#17
0
        protected override void Visit(AttributeNode attributeNode)
        {
            List <Node> priorNodes = new List <Node>();
            List <Node> source     = new List <Node>();

            foreach (Node node in attributeNode.Nodes)
            {
                if (node is ConditionNode)
                {
                    ConditionNode condition = (ConditionNode)node;
                    MovePriorNodesUnderCondition(condition, priorNodes);
                    source.AddRange(priorNodes);
                    source.Add(condition);
                    priorNodes.Clear();
                }
                else
                {
                    priorNodes.Add(node);
                }
            }
            source.AddRange(priorNodes);
            if (!source.All <Node>(node => (node is ConditionNode)) || !source.Any <Node>())
            {
                this.AddLiteral(string.Format(" {0}={1}", attributeNode.Name, attributeNode.QuotChar));
                foreach (Node node3 in source)
                {
                    base.Accept(node3);
                }
                this.AddLiteral(attributeNode.QuotChar.ToString());
            }
            else
            {
                ScopeChunk         item   = new ScopeChunk();
                LocalVariableChunk chunk3 = new LocalVariableChunk {
                    Name  = "__just__once__",
                    Value = new Snippets("0")
                };
                item.Body.Add(chunk3);
                ConditionalChunk chunk4 = new ConditionalChunk {
                    Type      = ConditionalType.If,
                    Condition = new Snippets("__just__once__ < 1")
                };
                this._sendAttributeOnce = chunk4;
                SendLiteralChunk chunk5 = new SendLiteralChunk {
                    Text = " " + attributeNode.Name + "=\""
                };
                this._sendAttributeOnce.Body.Add(chunk5);
                AssignVariableChunk chunk6 = new AssignVariableChunk {
                    Name  = "__just__once__",
                    Value = "1"
                };
                this._sendAttributeIncrement = chunk6;
                this.Chunks.Add(item);
                using (new Frame(this, item.Body))
                {
                    foreach (Node node4 in source)
                    {
                        base.Accept(node4);
                    }
                }
                this._sendAttributeOnce      = null;
                this._sendAttributeIncrement = null;
                ConditionalChunk chunk2 = new ConditionalChunk {
                    Type      = ConditionalType.If,
                    Condition = new Snippets("__just__once__ > 0")
                };
                item.Body.Add(chunk2);
                SendLiteralChunk chunk8 = new SendLiteralChunk {
                    Text = "\""
                };
                chunk2.Body.Add(chunk8);
            }
        }