Exemple #1
0
        protected override void Visit(GlobalVariableChunk chunk)
        {
            if (!_globalSymbols.ContainsKey(chunk.Name))
            {
                _globalSymbols.Add(chunk.Name, null);
            }

            if (_globalAdded.ContainsKey(chunk.Name))
            {
                if (_globalAdded[chunk.Name].Type != chunk.Type ||
                    _globalAdded[chunk.Name].Value != chunk.Value)
                {
                    throw new CompilerException(
                              string.Format(
                                  "The global named {0} cannot be declared repeatedly with different types or values",
                                  chunk.Name));
                }
                return;
            }

            var type = chunk.Type ?? "Object";

            _source.WriteFormat(
                "\r\n    Private _{1} As {0} = {2}" +
                "\r\n    Public Property {1}() As {0}" +
                "\r\n        Get" +
                "\r\n            Return _{1}" +
                "\r\n        End Get" +
                "\r\n        Set(ByVal value as {0})" +
                "\r\n            _{1} = value" +
                "\r\n        End Set" +
                "\r\n    End Property",
                type, chunk.Name, chunk.Value);
            _source.WriteLine();
        }
Exemple #2
0
        protected override void Visit(GlobalVariableChunk chunk)
        {
            if (!_globalSymbols.ContainsKey(chunk.Name))
                _globalSymbols.Add(chunk.Name, null);

            if (_globalAdded.ContainsKey(chunk.Name))
            {
                if (_globalAdded[chunk.Name].Type != chunk.Type ||
                    _globalAdded[chunk.Name].Value != chunk.Value)
                {
                    throw new CompilerException(string.Format("The global named {0} cannot be declared repeatedly with different types or values",
                                                              chunk.Name));
                }
                return;
            }

            var type = chunk.Type ?? "object";
            var typeParts = type.ToString().Split(' ', '\t');
            if (typeParts.Contains("const") || typeParts.Contains("readonly"))
            {
                _source.WriteFormat("\r\n    {0} {1} = {2};",
                                     type, chunk.Name, chunk.Value);
            }
            else
            {
                _source.WriteFormat(
                    "\r\n    {0} _{1} = {2};\r\n    public {0} {1} {{ get {{return _{1};}} set {{_{1} = value;}} }}",
                    type, chunk.Name, chunk.Value);
            }
            _source.WriteLine();
        }
Exemple #3
0
        protected override void Visit(GlobalVariableChunk chunk)
        {
            if (!_globalSymbols.ContainsKey(chunk.Name))
            {
                _globalSymbols.Add(chunk.Name, null);
            }

            if (_globalAdded.ContainsKey(chunk.Name))
            {
                if (_globalAdded[chunk.Name].Type != chunk.Type ||
                    _globalAdded[chunk.Name].Value != chunk.Value)
                {
                    throw new CompilerException(string.Format("The global named {0} cannot be declared repeatedly with different types or values",
                                                              chunk.Name));
                }
                return;
            }

            var type      = chunk.Type ?? "object";
            var typeParts = type.ToString().Split(' ', '\t');

            if (typeParts.Contains("const") || typeParts.Contains("readonly"))
            {
                _source.WriteFormat("\r\n    {0} {1} = {2};",
                                    type, chunk.Name, chunk.Value);
            }
            else
            {
                _source.WriteFormat(
                    "\r\n    {0} _{1} = {2};\r\n    public {0} {1} {{ get {{return _{1};}} set {{_{1} = value;}} }}",
                    type, chunk.Name, chunk.Value);
            }
            _source.WriteLine();
        }
 protected override void Visit(GlobalVariableChunk chunk)
 {
     if (!this._globalSymbols.ContainsKey((string)chunk.Name))
     {
         this._globalSymbols.Add((string)chunk.Name, null);
     }
     if (this._globalAdded.ContainsKey((string)chunk.Name))
     {
         if ((this._globalAdded[(string)chunk.Name].Type != chunk.Type) || (this._globalAdded[(string)chunk.Name].Value != chunk.Value))
         {
             throw new CompilerException(string.Format("The global named {0} cannot be declared repeatedly with different types or values", chunk.Name));
         }
     }
     else
     {
         Snippets snippets = chunk.Type ?? "object";
         string[] source   = snippets.ToString().Split(new char[] { ' ', '\t' });
         if (source.Contains <string>("const") || source.Contains <string>("readonly"))
         {
             this._source.WriteFormat("\r\n    {0} {1} = {2};", new object[] { snippets, chunk.Name, chunk.Value });
         }
         else
         {
             this._source.WriteFormat("\r\n    {0} _{1} = {2};\r\n    public {0} {1} {{ get {{return _{1};}} set {{_{1} = value;}} }}", new object[] { snippets, chunk.Name, chunk.Value });
         }
         this._source.WriteLine();
     }
 }
        protected override void Visit(GlobalVariableChunk chunk)
        {
            if (!_globalSymbols.ContainsKey(chunk.Name))
                _globalSymbols.Add(chunk.Name, null);

            if (_globalAdded.ContainsKey(chunk.Name))
            {
                if (_globalAdded[chunk.Name].Type != chunk.Type ||
                    _globalAdded[chunk.Name].Value != chunk.Value)
                {
                    throw new CompilerException(
                        string.Format(
                            "The global named {0} cannot be declared repeatedly with different types or values",
                            chunk.Name));
                }
                return;
            }

            var type = chunk.Type ?? "Object";
            _source.WriteFormat(
                "\r\n    Private _{1} As {0} = {2}" +
                "\r\n    Public Property {1}() As {0}" +
                "\r\n        Get" +
                "\r\n            Return _{1}" +
                "\r\n        End Get" +
                "\r\n        Set(ByVal value as {0})" +
                "\r\n            _{1} = value" +
                "\r\n        End Set" +
                "\r\n    End Property",
                type, chunk.Name, chunk.Value);
            _source.WriteLine();
        }
 protected override void Visit(GlobalVariableChunk chunk)
 {
     _source
         .Append(chunk.Name)
         .Append(":")
         .Append(chunk.Value)
         .AppendLine(",");
 }
 protected override void Visit(GlobalVariableChunk chunk)
 {
     _source
     .Append(chunk.Name)
     .Append(":")
     .Append(chunk.Value)
     .AppendLine(",");
 }
 protected override void Visit(GlobalVariableChunk chunk)
 {
     _source
         .Append("var ")
         .Append(chunk.Name)
         .Append(" = this.")
         .Append(chunk.Name)
         .AppendLine(";");
 }
        protected override void Visit(GlobalVariableChunk chunk)
        {
            if (!_globals.ContainsKey(chunk.Name))
            {
                _globals.Add(chunk.Name, null);
            }

            _source.Write("attr_accessor :").WriteLine(chunk.Name);
        }
Exemple #10
0
 protected override void Visit(GlobalVariableChunk chunk)
 {
     _source
     .Append("var ")
     .Append(chunk.Name)
     .Append(" = this.")
     .Append(chunk.Name)
     .AppendLine(";");
 }
Exemple #11
0
        private void VisitGlobal(SpecialNode specialNode)
        {
            AttributeNode typeAttr = specialNode.Element.Attributes.FirstOrDefault <AttributeNode>(attr => attr.Name == "type");
            Snippets      snippets = (typeAttr != null) ? this.AsCode(typeAttr) : "object";

            foreach (AttributeNode node in from a in specialNode.Element.Attributes
                     where a != typeAttr
                     select a)
            {
                GlobalVariableChunk chunk = new GlobalVariableChunk {
                    Type  = snippets,
                    Name  = node.Name,
                    Value = this.AsTextOrientedCode(node)
                };
                this.AddUnordered(chunk);
            }
        }
 protected override void Visit(GlobalVariableChunk chunk)
 {
     if (!this._globalSymbols.ContainsKey((string)chunk.Name))
     {
         this._globalSymbols.Add((string)chunk.Name, null);
     }
     if (this._globalAdded.ContainsKey((string)chunk.Name))
     {
         if ((this._globalAdded[(string)chunk.Name].Type != chunk.Type) || (this._globalAdded[(string)chunk.Name].Value != chunk.Value))
         {
             throw new CompilerException(string.Format("The global named {0} cannot be declared repeatedly with different types or values", chunk.Name));
         }
     }
     else
     {
         Snippets snippets = chunk.Type ?? "Object";
         this._source.WriteFormat("\r\n    Private _{1} As {0} = {2}\r\n    Public Property {1}() As {0}\r\n        Get\r\n            Return _{1}\r\n        End Get\r\n        Set(ByVal value as {0})\r\n            _{1} = value\r\n        End Set\r\n    End Property", new object[] { snippets, chunk.Name, chunk.Value });
         this._source.WriteLine();
     }
 }
 protected override void Visit(GlobalVariableChunk chunk)
 {
     chunk.Value = this.Process(chunk, chunk.Value);
     base.Visit(chunk);
 }
 protected override void Visit(GlobalVariableChunk chunk)
 {
     chunk.Value = Process(chunk, chunk.Value);
     base.Visit(chunk);
 }
 protected override void Visit(GlobalVariableChunk chunk)
 {
     this._source.Append("this.").Append((string)chunk.Name).Append(" = ").Append((string)chunk.Name).AppendLine(";");
 }
Exemple #16
0
 protected override void Visit(GlobalVariableChunk chunk)
 {
 }
Exemple #17
0
 protected override void Visit(GlobalVariableChunk chunk)
 {
 }
 protected abstract void Visit(GlobalVariableChunk chunk);
 protected abstract void Visit(GlobalVariableChunk chunk);
 protected override void Visit(GlobalVariableChunk chunk)
 {
     _source.Write("@").Write(chunk.Name).Write("=").WriteLine(chunk.Value);
 }