Esempio n. 1
0
        public UnaryOperatorNode(NodeType NodeType, Node Argument)
            : base(NodeType, null, false)
        {
            SubNodes.Add(Argument);

            this.DataType = GetResultType(Argument);
        }
Esempio n. 2
0
        public DictionaryNode(BinaryReader bin)
        {
            //Offset = (UInt32)bin.BaseStream.Position;
            NodeType = bin.ReadByte();
            if (NodeType != 0xC1)
            {
                throw new Exception("Not a dictionary node !");
            }
            List <byte> _count = new List <byte>();

            _count.AddRange(bin.ReadBytes(3));
            _count.Add(0x00);
            uint count = BitConverter.ToUInt32(_count.ToArray(), 0);

            if (count == 0)
            {
                return;
            }
            for (int i = 0; i < count; i++)
            {
                //Debug.Print("DICTIONARY SUBNODE AT: " + HelpFunctions.GetHexString((int)bin.BaseStream.Position));
                GenericNode g            = new GenericNode();
                List <byte> _stringIndex = new List <byte>();
                _stringIndex.AddRange(bin.ReadBytes(3));
                _stringIndex.Add(0x00);
                g.StringIndex = BitConverter.ToUInt32(_stringIndex.ToArray(), 0);
                g.NodeType    = bin.ReadByte();
                g.Value       = bin.ReadBytes(4);
                if (g.Value == null)
                {
                    throw new Exception("Value can't be null");
                }
                if (g.NodeType == 0xC1)
                {
                    long OldPos = bin.BaseStream.Position;
                    bin.BaseStream.Position = BitConverter.ToUInt32(g.Value, 0);
                    //Debug.Print(HelpFunctions.GetHexString(NodeType) + " node at: " + HelpFunctions.GetHexString((int)bin.BaseStream.Position));
                    DictionaryNode dict = new DictionaryNode(bin);
                    if (dict.SubNodes.Count != 0)
                    {
                        g.SubNodes = dict.SubNodes;
                    }
                    bin.BaseStream.Position = OldPos;
                }
                else if (g.NodeType == 0xC0)
                {
                    long OldPos = bin.BaseStream.Position;
                    bin.BaseStream.Position = BitConverter.ToUInt32(g.Value, 0);
                    //Debug.Print(HelpFunctions.GetHexString(NodeType) + " node at: " + HelpFunctions.GetHexString((int)bin.BaseStream.Position));
                    ArrayNode arr = new ArrayNode(bin);
                    if (arr.SubNodes.Count != 0)
                    {
                        g.SubNodes = arr.SubNodes;
                    }
                    bin.BaseStream.Position = OldPos;
                }// else Debug.Print(HelpFunctions.GetHexString(NodeType) + " node at: " + HelpFunctions.GetHexString((int)bin.BaseStream.Position));

                SubNodes.Add(g);
            }
        }
Esempio n. 3
0
        public BinaryOperatorNode(NodeType NodeType, Node Left, Node Right)
            : base(NodeType, null, false)
        {
            SubNodes.Add(Left);
            SubNodes.Add(Right);

            this.DataType = GetResultType(Left, Right);
        }
Esempio n. 4
0
File: Node.cs Progetto: p0k0/t-tn
        public virtual void AppendSub(Node newSubNode)
        {
            if (newSubNode == null)
            {
                return;
            }

            newSubNode.Parent = this;
            SubNodes.Add(newSubNode);
        }
Esempio n. 5
0
 public override IASTNode Parse(IASTNodeFactory nodeFactory, IAParser aParser, ATokens tokens)
 {
     while (tokens.CurrentToken != null && !aParser.Acceptable(tokens, ASTEndParenthesesNode.KeyWord) && !aParser.Acceptable(tokens, ASTCommaNode.KeyWord))
     {
         IASTNode node = nodeFactory.CreateNode(tokens.CurrentToken.Text, tokens.CurrentToken.AddSpace);
         node.Parse(nodeFactory, aParser, tokens);
         SubNodes.Add(node);
     }
     return(this);
 }
Esempio n. 6
0
 public override IASTNode Parse(IASTNodeFactory nodeFactory, IAParser aParser, ATokens tokens)
 {
     tokens.GetNextToken();
     while (tokens.CurrentToken != null && !aParser.Acceptable(tokens, ASTEndParenthesesNode.KeyWord))
     {
         IASTNode newNode = aParser.NodeFactory.CreateNode(tokens.CurrentToken.Text, tokens.CurrentToken.AddSpace);
         newNode.Parse(aParser.NodeFactory, aParser, tokens);
         SubNodes.Add(newNode);
     }
     if (!aParser.Acceptable(tokens, ASTEndParenthesesNode.KeyWord))
     {
         throw new AParserException("Didn't find closing parentheses");
     }
     SubNodes.Add(aParser.Accept(tokens, ASTEndParenthesesNode.KeyWord));
     return(this);
 }
Esempio n. 7
0
        protected void ParseParameters(IASTNodeFactory nodeFactory, IAParser aParser, ATokens tokens)
        {
            SubNodes.Add(aParser.Accept(tokens, ASTStartParenthesesNode.KeyWord));

            while (tokens.CurrentToken != null && !aParser.Acceptable(tokens, ASTEndParenthesesNode.KeyWord))
            {
                IASTNode node = nodeFactory.CreateFunctionParameterNode(tokens.CurrentToken.AddSpace);
                node.Parse(nodeFactory, aParser, tokens);
                SubNodes.Add(node);

                if (aParser.Acceptable(tokens, ASTCommaNode.KeyWord))
                {
                    SubNodes.Add(aParser.Accept(tokens, ASTCommaNode.KeyWord));
                }
            }

            SubNodes.Add(aParser.Accept(tokens, ASTEndParenthesesNode.KeyWord));
        }
Esempio n. 8
0
        /// <summary>
        /// Adds a sub category
        /// </summary>
        /// <param name="name">Name of the sub category</param>
        /// <exception cref="ArgumentException">If a category with the specified name already exists</exception>
        /// <exception cref="ArgumentNullException">If name is null</exception>
        public override LanguageNode AddNode(string name)
        {
            if (SubNodes.ContainsKey(name))
            {
                throw new ArgumentException("A category with specified name already exists.", "name");
            }

            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException("name");
            }

            lock (SubNodes)
            {
                SubNodes.Add(name, new MemLanguageNode(DefaultLCID, name));
                SubNodes[name].ParentNode = this;

                return(SubNodes[name]);
            }
        }
Esempio n. 9
0
 public NamedFieldNode(Node InstanceNode, string FieldName, Type FieldType)
     : base(NodeType.NamedField, FieldType, false)
 {
     SubNodes.Add(InstanceNode);
     m_FieldName = FieldName;
 }
Esempio n. 10
0
        public ArrayNode(BinaryReader bin)
        {
            //Offset = (UInt32)bin.BaseStream.Position;
            NodeType = bin.ReadByte();
            if (NodeType != 0xC0)
            {
                throw new Exception("Not an array node !");
            }
            List <byte> _count = new List <byte>();

            _count.AddRange(bin.ReadBytes(3));
            _count.Add(0x00);
            uint Count = BitConverter.ToUInt32(_count.ToArray(), 0);

            if (Count == 0)
            {
                return;
            }
            byte[] NodeTypes;
            NodeTypes = bin.ReadBytes((int)Count);
            if (bin is BigEndianReader)
            {
                Array.Reverse(NodeTypes);
            }
            while ((bin.BaseStream.Position % 4) != 0)
            {
                bin.ReadByte();                                        //Padding
            }
            for (int i = 0; i < Count; i++)
            {
                // Debug.Print("ARRAY SUBNODE AT: " + HelpFunctions.GetHexString((int)bin.BaseStream.Position));
                GenericNode g = new GenericNode();
                g.NodeType = NodeTypes[i];
                g.Value    = bin.ReadBytes(4);
                if (g.NodeType == 0xC1)
                {
                    long OldPos = bin.BaseStream.Position;
                    bin.BaseStream.Position = BitConverter.ToUInt32(g.Value, 0);
                    //Debug.Print(HelpFunctions.GetHexString(NodeType) + " node at: " + HelpFunctions.GetHexString((int)bin.BaseStream.Position));
                    DictionaryNode dict = new DictionaryNode(bin);
                    if (dict.SubNodes.Count != 0)
                    {
                        g.SubNodes = dict.SubNodes;
                    }
                    bin.BaseStream.Position = OldPos;
                }
                else if (g.NodeType == 0xC0)
                {
                    long OldPos = bin.BaseStream.Position;
                    bin.BaseStream.Position = BitConverter.ToUInt32(g.Value, 0);
                    //Debug.Print(HelpFunctions.GetHexString(NodeType) + " node at: " + HelpFunctions.GetHexString((int)bin.BaseStream.Position));
                    ArrayNode Arr = new ArrayNode(bin);
                    if (Arr.SubNodes.Count != 0)
                    {
                        g.SubNodes = Arr.SubNodes;
                    }
                    bin.BaseStream.Position = OldPos;
                }//else Debug.Print(HelpFunctions.GetHexString(NodeType) + " node at: " + HelpFunctions.GetHexString((int)bin.BaseStream.Position));


                SubNodes.Add(g);
            }
        }
Esempio n. 11
0
 public InstanceFieldNode(Node InstanceNode, System.Reflection.FieldInfo FieldInfo)
     : base(NodeType.InstanceField, FieldInfo.FieldType, false)
 {
     SubNodes.Add(InstanceNode);
     m_FieldInfo = FieldInfo;
 }
Esempio n. 12
0
        internal NanoXmlNode(string str, ref int i)
        {
            Name = ParseAttributes(str, ref i, Attributes, '>', '/');

            if (str[i] == '/') // if this node has nothing inside
            {
                i++;           // skip /
                i++;           // skip >
                return;
            }

            i++; // skip >

            // temporary. to include all whitespaces into value, if any
            int tempI = i;

            SkipSpaces(str, ref tempI);

            if (str[tempI] == '<')
            {
                i = tempI;

                while (str[i + 1] != '/') // parse subnodes
                {
                    i++;                  // skip <
                    SubNodes.Add(new NanoXmlNode(str, ref i));

                    SkipSpaces(str, ref i);

                    if (i >= str.Length)
                    {
                        return; // EOF
                    }
                    if (str[i] != '<')
                    {
                        throw new NanoXmlParsingException($"Unexpected token in XML.  Expecting <, but found {str[i]}.");
                    }
                }

                i++; // skip <
            }
            else     // parse value
            {
                Value = GetValue(str, ref i, '<', '\0', false);
                i++; // skip <

                if (str[i] != '/')
                {
                    throw new NanoXmlParsingException("Invalid ending on tag " + Name);
                }
            }

            i++; // skip /
            SkipSpaces(str, ref i);

            string endName = GetValue(str, ref i, '>', '\0', true);

            if (endName != Name)
            {
                throw new NanoXmlParsingException("Start/end tag name mismatch: " + Name + " and " + endName);
            }
            SkipSpaces(str, ref i);

            if (str[i] != '>')
            {
                throw new NanoXmlParsingException("Invalid ending on tag " + Name);
            }

            i++; // skip >
        }
Esempio n. 13
0
 public CastNode(Node Argument, Type Type)
     : base(NodeType.Cast, Type, false)
 {
     m_Type = Type;
     SubNodes.Add(Argument);
 }
Esempio n. 14
0
 public void AddToNode(Node node)
 {
     SubNodes.Add(node);
 }