コード例 #1
0
        public void AddCount(List <LexTree> _tokenlist, int _i)
        {
            LexTree lexTree = _tokenlist[_i];

            if (lexTree.Text != null)
            {
                VFNode value;
                if (!m_FunctionList.TryGetValue(lexTree.Text, out value))
                {
                    value = new VFNode(lexTree.Text);
                    m_FunctionList.Add(lexTree.Text, value);
                }
                value.Count++;
            }
        }
コード例 #2
0
        private int ParseProtoTypeFunction(List <LexTree> _tokenlist, int _i)
        {
            bool flag  = false;
            bool flag2 = true;

            _i -= 2;
            LexTree lexTree = _tokenlist[_i];

            if (_tokenlist[_i + 1].Token != eLex.Dot || _tokenlist[_i + 2].Text != "prototype" || _tokenlist[_i + 3].Token != eLex.Dot)
            {
                return(_i + 3);
            }
            int     num      = _i;
            LexTree lexTree2 = _tokenlist[_i + 4];

            if (_tokenlist[_i + 5].Token != eLex.Equals || _tokenlist[_i + 6].Text != "function" || _tokenlist[_i + 7].Token != eLex.LeftBracket)
            {
                return(_i + 3);
            }
            lexTree.Name = lexTree2.Text;
            flag         = true;
            flag2        = false;
            lexTree.Used = new Dictionary <string, VFNode>(50);
            VFNode value;

            if (!m_FunctionList.TryGetValue(lexTree2.Text, out value))
            {
                value = new VFNode(lexTree2.Text);
                m_FunctionList.Add(lexTree2.Text, value);
            }
            value.pFunction.Add(lexTree);
            lexTree.Node = value;
            _i          += 8;
            int num2 = 0;

            while (true)
            {
                LexTree lexTree3 = _tokenlist[_i];
                if (lexTree3.Text == "{")
                {
                    num2++;
                }
                if (lexTree3.Text == "}")
                {
                    num2--;
                    if (num2 == 0)
                    {
                        break;
                    }
                }
                if (!flag2 && lexTree3.Token == eLex.ID)
                {
                    VFNode value2;
                    if (!lexTree.Used.TryGetValue(lexTree3.Text, out value2))
                    {
                        if (!m_FunctionList.TryGetValue(lexTree3.Text, out value2))
                        {
                            value2 = new VFNode(lexTree3.Text);
                            m_FunctionList.Add(lexTree3.Text, value2);
                        }
                        lexTree.Used.Add(lexTree3.Text, value2);
                    }
                    value2.Count++;
                }
                else if (lexTree3.Text == "true")
                {
                    lexTree3.Text = "!0";
                }
                else if (lexTree3.Text == "false")
                {
                    lexTree3.Text = "!1";
                }
                _i++;
                if (_i >= _tokenlist.Count)
                {
                    return(_i);
                }
            }
            num2 = _i + 1 - num;
            if (flag)
            {
                List <LexTree> range = _tokenlist.GetRange(num + 1, num2);
                _tokenlist.RemoveRange(num + 1, num2);
                lexTree.Children = new List <LexTree>(num2);
                lexTree.Children.AddRange(range);
                _i = num;
            }
            return(_i);
        }
コード例 #3
0
        private int ParseFunction(List <LexTree> _tokenlist, int _i)
        {
            bool    flag     = false;
            bool    flag2    = true;
            LexTree lexTree  = _tokenlist[_i];
            int     num      = _i;
            LexTree lexTree2 = _tokenlist[_i + 1];

            if (lexTree2.Text != "(" && lexTree2.Token == eLex.ID)
            {
                lexTree.Name = lexTree2.Text;
                flag         = true;
                flag2        = false;
                lexTree.Used = new Dictionary <string, VFNode>(50);
                _i          += 2;
                VFNode value;
                if (!m_FunctionList.TryGetValue(lexTree2.Text, out value))
                {
                    value = new VFNode(lexTree2.Text);
                    m_FunctionList.Add(lexTree2.Text, value);
                }
                value.pFunction.Add(lexTree);
                lexTree.Node = value;
            }
            int  num2  = 0;
            bool flag3 = false;

            while (true)
            {
                LexTree lexTree3 = _tokenlist[_i];
                if (lexTree3.Token == eLex.RightBracket)
                {
                    flag3 = true;
                }
                if (flag3)
                {
                    if (lexTree3.Text == "{")
                    {
                        num2++;
                    }
                    if (lexTree3.Text == "}")
                    {
                        num2--;
                        if (num2 == 0)
                        {
                            break;
                        }
                    }
                }
                if (lexTree3.Text == "function")
                {
                    lexTree3.anon = true;
                }
                if (!flag2 && lexTree3.Token == eLex.ID)
                {
                    VFNode value2;
                    if (!lexTree.Used.TryGetValue(lexTree3.Text, out value2))
                    {
                        if (!m_FunctionList.TryGetValue(lexTree3.Text, out value2))
                        {
                            value2 = new VFNode(lexTree3.Text);
                            m_FunctionList.Add(lexTree3.Text, value2);
                        }
                        lexTree.Used.Add(lexTree3.Text, value2);
                    }
                    value2.Count++;
                }
                else if (lexTree3.Text == "true")
                {
                    lexTree3.Text = "!0";
                }
                else if (lexTree3.Text == "false")
                {
                    lexTree3.Text = "!1";
                }
                _i++;
                if (_i >= _tokenlist.Count)
                {
                    return(_i);
                }
            }
            num2 = _i + 1 - num - 1;
            if (flag)
            {
                List <LexTree> range = _tokenlist.GetRange(num + 1, num2);
                _tokenlist.RemoveRange(num + 1, num2);
                lexTree.Children = new List <LexTree>(num2);
                lexTree.Children.AddRange(range);
                _i = num;
            }
            return(_i);
        }