コード例 #1
0
ファイル: GeneratedCodeVisitor.cs プロジェクト: yhtsnda/spark
 protected override void Visit(UseMasterChunk chunk)
 {
     //no-op
 }
コード例 #2
0
 protected abstract void Visit(UseMasterChunk chunk);
コード例 #3
0
ファイル: GeneratedCodeVisitor.cs プロジェクト: otac0n/spark
 protected override void Visit(UseMasterChunk chunk)
 {
     //no-op
 }
コード例 #4
0
ファイル: ChunkBuilderVisitor.cs プロジェクト: otac0n/spark
        private void VisitUse(SpecialNode specialNode, SpecialNodeInspector inspector)
        {
            var file = inspector.TakeAttribute("file");
            if (file != null)
            {
                var scope = new ScopeChunk { Position = Locate(inspector.OriginalNode) };
                Chunks.Add(scope);
                using (new Frame(this, scope.Body))
                {
                    foreach (var attr in inspector.Attributes)
                    {
                        Chunks.Add(new LocalVariableChunk { Name = attr.Name, Value = AsCode(attr), Position = Locate(attr) });
                    }

                    var useFileChunk = new RenderPartialChunk { Name = file.Value, Position = Locate(inspector.OriginalNode) };
                    Chunks.Add(useFileChunk);
                    using (new Frame(this, useFileChunk.Body, useFileChunk.Sections))
                    {
                        Accept(inspector.Body);
                    }
                }
            }
            else
            {
                var contentAttr = inspector.TakeAttribute("content");
                var namespaceAttr = inspector.TakeAttribute("namespace");
                var assemblyAttr = inspector.TakeAttribute("assembly");
                var importAttr = inspector.TakeAttribute("import");
                var masterAttr = inspector.TakeAttribute("master");
                var pageBaseTypeAttr = inspector.TakeAttribute("pageBaseType");

                if (contentAttr != null)
                {
                    var useContentChunk = new UseContentChunk { Name = contentAttr.Value, Position = Locate(inspector.OriginalNode) };
                    Chunks.Add(useContentChunk);
                    using (new Frame(this, useContentChunk.Default))
                    {
                        Accept(specialNode.Body);
                    }
                }
                else if (namespaceAttr != null || assemblyAttr != null)
                {
                    if (namespaceAttr != null)
                    {
                        var useNamespaceChunk = new UseNamespaceChunk { Namespace = AsCode(namespaceAttr) };
                        AddUnordered(useNamespaceChunk);
                    }

                    if (assemblyAttr != null)
                    {
                        var useAssemblyChunk = new UseAssemblyChunk { Assembly = assemblyAttr.Value };
                        AddUnordered(useAssemblyChunk);
                    }
                }
                else if (importAttr != null)
                {
                    var useImportChunk = new UseImportChunk { Name = importAttr.Value };
                    AddUnordered(useImportChunk);
                }
                else if (masterAttr != null)
                {
                    var useMasterChunk = new UseMasterChunk { Name = masterAttr.Value };
                    AddUnordered(useMasterChunk);
                }
                else if (pageBaseTypeAttr != null)
                {
                    var usePageBaseTypeChunk = new PageBaseTypeChunk { BaseClass = AsCode(pageBaseTypeAttr) };
                    AddUnordered(usePageBaseTypeChunk);
                }
                else
                {
                    throw new CompilerException("Special node use had no understandable attributes");
                }
            }
        }
コード例 #5
0
 protected abstract void Visit(UseMasterChunk chunk);
コード例 #6
0
        private void VisitUse(SpecialNode specialNode, SpecialNodeInspector inspector)
        {
            var file = inspector.TakeAttribute("file");

            if (file != null)
            {
                var scope = new ScopeChunk {
                    Position = Locate(inspector.OriginalNode)
                };
                Chunks.Add(scope);
                using (new Frame(this, scope.Body))
                {
                    foreach (var attr in inspector.Attributes)
                    {
                        Chunks.Add(new LocalVariableChunk {
                            Name = attr.Name, Value = AsCode(attr), Position = Locate(attr)
                        });
                    }

                    var useFileChunk = new RenderPartialChunk {
                        Name = file.Value, Position = Locate(inspector.OriginalNode)
                    };
                    Chunks.Add(useFileChunk);
                    using (new Frame(this, useFileChunk.Body, useFileChunk.Sections))
                    {
                        Accept(inspector.Body);
                    }
                }
            }
            else
            {
                var contentAttr      = inspector.TakeAttribute("content");
                var namespaceAttr    = inspector.TakeAttribute("namespace");
                var assemblyAttr     = inspector.TakeAttribute("assembly");
                var importAttr       = inspector.TakeAttribute("import");
                var masterAttr       = inspector.TakeAttribute("master");
                var pageBaseTypeAttr = inspector.TakeAttribute("pageBaseType");

                if (contentAttr != null)
                {
                    var useContentChunk = new UseContentChunk {
                        Name = contentAttr.Value, Position = Locate(inspector.OriginalNode)
                    };
                    Chunks.Add(useContentChunk);
                    using (new Frame(this, useContentChunk.Default))
                    {
                        Accept(specialNode.Body);
                    }
                }
                else if (namespaceAttr != null || assemblyAttr != null)
                {
                    if (namespaceAttr != null)
                    {
                        var useNamespaceChunk = new UseNamespaceChunk {
                            Namespace = AsCode(namespaceAttr)
                        };
                        AddUnordered(useNamespaceChunk);
                    }
                    if (assemblyAttr != null)
                    {
                        var useAssemblyChunk = new UseAssemblyChunk {
                            Assembly = assemblyAttr.Value
                        };
                        AddUnordered(useAssemblyChunk);
                    }
                }
                else if (importAttr != null)
                {
                    var useImportChunk = new UseImportChunk {
                        Name = importAttr.Value
                    };
                    AddUnordered(useImportChunk);
                }
                else if (masterAttr != null)
                {
                    var useMasterChunk = new UseMasterChunk {
                        Name = masterAttr.Value
                    };
                    AddUnordered(useMasterChunk);
                }
                else if (pageBaseTypeAttr != null)
                {
                    var usePageBaseTypeChunk = new PageBaseTypeChunk {
                        BaseClass = AsCode(pageBaseTypeAttr)
                    };
                    AddUnordered(usePageBaseTypeChunk);
                }
                else
                {
                    throw new CompilerException("Special node use had no understandable attributes");
                }
            }
        }
コード例 #7
0
        private void VisitUse(SpecialNode specialNode, SpecialNodeInspector inspector)
        {
            AttributeNode node = inspector.TakeAttribute("file");

            if (node != null)
            {
                ScopeChunk item = new ScopeChunk {
                    Position = this.Locate(inspector.OriginalNode)
                };
                this.Chunks.Add(item);
                using (new Frame(this, item.Body))
                {
                    foreach (AttributeNode node2 in inspector.Attributes)
                    {
                        LocalVariableChunk chunk2 = new LocalVariableChunk {
                            Name     = node2.Name,
                            Value    = this.AsTextOrientedCode(node2),
                            Position = this.Locate(node2)
                        };
                        this.Chunks.Add(chunk2);
                    }
                    RenderPartialChunk chunk3 = new RenderPartialChunk {
                        Name     = node.Value,
                        Position = this.Locate(inspector.OriginalNode)
                    };
                    this.Chunks.Add(chunk3);
                    using (new Frame(this, chunk3.Body, chunk3.Sections))
                    {
                        base.Accept(inspector.Body);
                    }
                    return;
                }
            }
            AttributeNode node3 = inspector.TakeAttribute("content");
            AttributeNode attr  = inspector.TakeAttribute("namespace");
            AttributeNode node5 = inspector.TakeAttribute("assembly");
            AttributeNode node6 = inspector.TakeAttribute("import");
            AttributeNode node7 = inspector.TakeAttribute("master");
            AttributeNode node8 = inspector.TakeAttribute("pageBaseType");

            if (node3 != null)
            {
                UseContentChunk chunk6 = new UseContentChunk {
                    Name     = node3.Value,
                    Position = this.Locate(inspector.OriginalNode)
                };
                this.Chunks.Add(chunk6);
                using (new Frame(this, chunk6.Default))
                {
                    base.Accept(specialNode.Body);
                    return;
                }
            }
            if ((attr != null) || (node5 != null))
            {
                if (attr != null)
                {
                    UseNamespaceChunk chunk = new UseNamespaceChunk {
                        Namespace = this.AsCode(attr)
                    };
                    this.AddUnordered(chunk);
                }
                if (node5 != null)
                {
                    UseAssemblyChunk chunk10 = new UseAssemblyChunk {
                        Assembly = node5.Value
                    };
                    this.AddUnordered(chunk10);
                }
            }
            else if (node6 != null)
            {
                UseImportChunk chunk12 = new UseImportChunk {
                    Name = node6.Value
                };
                this.AddUnordered(chunk12);
            }
            else if (node7 != null)
            {
                UseMasterChunk chunk14 = new UseMasterChunk {
                    Name = node7.Value
                };
                this.AddUnordered(chunk14);
            }
            else
            {
                if (node8 == null)
                {
                    throw new CompilerException("Special node use had no understandable attributes");
                }
                PageBaseTypeChunk chunk16 = new PageBaseTypeChunk {
                    BaseClass = this.AsCode(node8)
                };
                this.AddUnordered(chunk16);
            }
        }