public static Tokenizer.StringMaker GetSharedStringMaker()
 {
     Tokenizer.StringMaker maker = null;
     bool lockTaken = false;
     RuntimeHelpers.PrepareConstrainedRegions();
     try
     {
         Monitor.Enter(_sharedStatics, ref lockTaken);
         if (_sharedStatics._maker != null)
         {
             maker = _sharedStatics._maker;
             _sharedStatics._maker = null;
         }
     }
     finally
     {
         if (lockTaken)
         {
             Monitor.Exit(_sharedStatics);
         }
     }
     if (maker == null)
     {
         maker = new Tokenizer.StringMaker();
     }
     return maker;
 }
		public static Tokenizer.StringMaker GetSharedStringMaker()
		{
			Tokenizer.StringMaker stringMaker = null;
			bool flag = false;
			RuntimeHelpers.PrepareConstrainedRegions();
			try
			{
				Monitor.Enter(SharedStatics._sharedStatics, ref flag);
				if (SharedStatics._sharedStatics._maker != null)
				{
					stringMaker = SharedStatics._sharedStatics._maker;
					SharedStatics._sharedStatics._maker = null;
				}
			}
			finally
			{
				if (flag)
				{
					Monitor.Exit(SharedStatics._sharedStatics);
				}
			}
			if (stringMaker == null)
			{
				stringMaker = new Tokenizer.StringMaker();
			}
			return stringMaker;
		}
Пример #3
0
 internal void BasicInitialization()
 {
     this.LineNo            = 1;
     this._inProcessingTag  = 0;
     this._inSavedCharacter = -1;
     this._inIndex          = 0;
     this._inSize           = 0;
     this._inNestedSize     = 0;
     this._inNestedIndex    = 0;
     this._inTokenSource    = Tokenizer.TokenSource.Other;
     this._maker            = SharedStatics.GetSharedStringMaker();
 }
        // Token: 0x06002BA9 RID: 11177 RVA: 0x000A3D34 File Offset: 0x000A1F34
        internal void GetTokens(TokenizerStream stream, int maxNum, bool endAfterKet)
        {
            while (maxNum == -1 || stream.GetTokenCount() < maxNum)
            {
                int  num   = 0;
                bool flag  = false;
                bool flag2 = false;
                Tokenizer.StringMaker maker = this._maker;
                maker._outStringBuilder = null;
                maker._outIndex         = 0;
                int num2;
                for (;;)
                {
                    if (this._inSavedCharacter != -1)
                    {
                        num2 = this._inSavedCharacter;
                        this._inSavedCharacter = -1;
                    }
                    else
                    {
                        switch (this._inTokenSource)
                        {
                        case Tokenizer.TokenSource.UnicodeByteArray:
                            if (this._inIndex + 1 >= this._inSize)
                            {
                                goto Block_3;
                            }
                            num2           = ((int)this._inBytes[this._inIndex + 1] << 8) + (int)this._inBytes[this._inIndex];
                            this._inIndex += 2;
                            break;

                        case Tokenizer.TokenSource.UTF8ByteArray:
                        {
                            if (this._inIndex >= this._inSize)
                            {
                                goto Block_4;
                            }
                            byte[] inBytes = this._inBytes;
                            int    num3    = this._inIndex;
                            this._inIndex = num3 + 1;
                            num2          = inBytes[num3];
                            if ((num2 & 128) != 0)
                            {
                                switch ((num2 & 240) >> 4)
                                {
                                case 8:
                                case 9:
                                case 10:
                                case 11:
                                    goto IL_12D;

                                case 12:
                                case 13:
                                    num2 &= 31;
                                    num   = 2;
                                    break;

                                case 14:
                                    num2 &= 15;
                                    num   = 3;
                                    break;

                                case 15:
                                    goto IL_14B;
                                }
                                if (this._inIndex >= this._inSize)
                                {
                                    goto Block_7;
                                }
                                byte[] inBytes2 = this._inBytes;
                                num3          = this._inIndex;
                                this._inIndex = num3 + 1;
                                byte b = inBytes2[num3];
                                if ((b & 192) != 128)
                                {
                                    goto Block_8;
                                }
                                num2 = (num2 << 6 | (int)(b & 63));
                                if (num != 2)
                                {
                                    if (this._inIndex >= this._inSize)
                                    {
                                        goto Block_10;
                                    }
                                    byte[] inBytes3 = this._inBytes;
                                    num3          = this._inIndex;
                                    this._inIndex = num3 + 1;
                                    b             = inBytes3[num3];
                                    if ((b & 192) != 128)
                                    {
                                        goto Block_11;
                                    }
                                    num2 = (num2 << 6 | (int)(b & 63));
                                }
                            }
                            break;
                        }

                        case Tokenizer.TokenSource.ASCIIByteArray:
                        {
                            if (this._inIndex >= this._inSize)
                            {
                                goto Block_12;
                            }
                            byte[] inBytes4 = this._inBytes;
                            int    num3     = this._inIndex;
                            this._inIndex = num3 + 1;
                            num2          = inBytes4[num3];
                            break;
                        }

                        case Tokenizer.TokenSource.CharArray:
                        {
                            if (this._inIndex >= this._inSize)
                            {
                                goto Block_13;
                            }
                            char[] inChars = this._inChars;
                            int    num3    = this._inIndex;
                            this._inIndex = num3 + 1;
                            num2          = inChars[num3];
                            break;
                        }

                        case Tokenizer.TokenSource.String:
                        {
                            if (this._inIndex >= this._inSize)
                            {
                                goto Block_14;
                            }
                            string inString = this._inString;
                            int    num3     = this._inIndex;
                            this._inIndex = num3 + 1;
                            num2          = (int)inString[num3];
                            break;
                        }

                        case Tokenizer.TokenSource.NestedStrings:
                        {
                            int num3;
                            if (this._inNestedSize != 0)
                            {
                                if (this._inNestedIndex < this._inNestedSize)
                                {
                                    string inNestedString = this._inNestedString;
                                    num3 = this._inNestedIndex;
                                    this._inNestedIndex = num3 + 1;
                                    num2 = (int)inNestedString[num3];
                                    break;
                                }
                                this._inNestedSize = 0;
                            }
                            if (this._inIndex >= this._inSize)
                            {
                                goto Block_17;
                            }
                            string inString2 = this._inString;
                            num3          = this._inIndex;
                            this._inIndex = num3 + 1;
                            num2          = (int)inString2[num3];
                            if (num2 == 123)
                            {
                                for (int i = 0; i < this._searchStrings.Length; i++)
                                {
                                    if (string.Compare(this._searchStrings[i], 0, this._inString, this._inIndex - 1, this._searchStrings[i].Length, StringComparison.Ordinal) == 0)
                                    {
                                        this._inNestedString = this._replaceStrings[i];
                                        this._inNestedSize   = this._inNestedString.Length;
                                        this._inNestedIndex  = 1;
                                        num2           = (int)this._inNestedString[0];
                                        this._inIndex += this._searchStrings[i].Length - 1;
                                        break;
                                    }
                                }
                            }
                            break;
                        }

                        default:
                            num2 = this._inTokenReader.Read();
                            if (num2 == -1)
                            {
                                goto Block_21;
                            }
                            break;
                        }
                    }
                    if (!flag)
                    {
                        if (num2 <= 34)
                        {
                            switch (num2)
                            {
                            case 9:
                            case 13:
                                continue;

                            case 10:
                                this.LineNo++;
                                continue;

                            case 11:
                            case 12:
                                break;

                            default:
                                switch (num2)
                                {
                                case 32:
                                    continue;

                                case 33:
                                    if (this._inProcessingTag != 0)
                                    {
                                        goto Block_32;
                                    }
                                    break;

                                case 34:
                                    flag  = true;
                                    flag2 = true;
                                    continue;
                                }
                                break;
                            }
                        }
                        else if (num2 != 45)
                        {
                            if (num2 != 47)
                            {
                                switch (num2)
                                {
                                case 60:
                                    goto IL_48A;

                                case 61:
                                    goto IL_4C0;

                                case 62:
                                    goto IL_4A4;

                                case 63:
                                    if (this._inProcessingTag != 0)
                                    {
                                        goto Block_31;
                                    }
                                    break;
                                }
                            }
                            else if (this._inProcessingTag != 0)
                            {
                                goto Block_30;
                            }
                        }
                        else if (this._inProcessingTag != 0)
                        {
                            goto Block_33;
                        }
                    }
                    else if (num2 <= 34)
                    {
                        switch (num2)
                        {
                        case 9:
                        case 13:
                            break;

                        case 10:
                            this.LineNo++;
                            if (!flag2)
                            {
                                goto Block_46;
                            }
                            goto IL_62F;

                        case 11:
                        case 12:
                            goto IL_62F;

                        default:
                            if (num2 != 32)
                            {
                                if (num2 != 34)
                                {
                                    goto IL_62F;
                                }
                                if (flag2)
                                {
                                    goto Block_44;
                                }
                                goto IL_62F;
                            }
                            break;
                        }
                        if (!flag2)
                        {
                            goto Block_45;
                        }
                    }
                    else
                    {
                        if (num2 != 47)
                        {
                            if (num2 != 60)
                            {
                                if (num2 - 61 > 1)
                                {
                                    goto IL_62F;
                                }
                            }
                            else
                            {
                                if (!flag2)
                                {
                                    goto Block_41;
                                }
                                goto IL_62F;
                            }
                        }
                        if (!flag2 && this._inProcessingTag != 0)
                        {
                            goto Block_43;
                        }
                    }
IL_62F:
                    flag = true;
                    if (maker._outIndex < 512)
                    {
                        char[] outChars = maker._outChars;
                        Tokenizer.StringMaker stringMaker = maker;
                        int num3 = stringMaker._outIndex;
                        stringMaker._outIndex = num3 + 1;
                        outChars[num3]        = (ushort)num2;
                    }
                    else
                    {
                        if (maker._outStringBuilder == null)
                        {
                            maker._outStringBuilder = new StringBuilder();
                        }
                        maker._outStringBuilder.Append(maker._outChars, 0, 512);
                        maker._outChars[0] = (char)num2;
                        maker._outIndex    = 1;
                    }
                }
IL_48A:
                this._inProcessingTag++;
                stream.AddToken(0);
                continue;
Block_3:
                stream.AddToken(-1);
                return;

IL_4A4:
                this._inProcessingTag--;
                stream.AddToken(1);
                if (endAfterKet)
                {
                    return;
                }
                continue;
IL_4C0:
                stream.AddToken(4);
                continue;
Block_30:
                stream.AddToken(2);
                continue;
Block_31:
                stream.AddToken(5);
                continue;
Block_32:
                stream.AddToken(6);
                continue;
Block_33:
                stream.AddToken(7);
                continue;
Block_41:
                this._inSavedCharacter = num2;
                stream.AddToken(3);
                stream.AddString(this.GetStringToken());
                continue;
Block_43:
                this._inSavedCharacter = num2;
                stream.AddToken(3);
                stream.AddString(this.GetStringToken());
                continue;
Block_44:
                stream.AddToken(3);
                stream.AddString(this.GetStringToken());
                continue;
Block_45:
                stream.AddToken(3);
                stream.AddString(this.GetStringToken());
                continue;
Block_46:
                stream.AddToken(3);
                stream.AddString(this.GetStringToken());
                continue;
Block_4:
                stream.AddToken(-1);
                return;

IL_12D:
                throw new XmlSyntaxException(this.LineNo);
IL_14B:
                throw new XmlSyntaxException(this.LineNo);
Block_7:
                throw new XmlSyntaxException(this.LineNo, Environment.GetResourceString("XMLSyntax_UnexpectedEndOfFile"));
Block_8:
                throw new XmlSyntaxException(this.LineNo);
Block_10:
                throw new XmlSyntaxException(this.LineNo, Environment.GetResourceString("XMLSyntax_UnexpectedEndOfFile"));
Block_11:
                throw new XmlSyntaxException(this.LineNo);
Block_12:
                stream.AddToken(-1);
                return;

Block_13:
                stream.AddToken(-1);
                return;

Block_14:
                stream.AddToken(-1);
                return;

Block_17:
                stream.AddToken(-1);
                return;

Block_21:
                stream.AddToken(-1);
                return;
            }
        }
		private SharedStatics()
		{
			this._Remoting_Identity_IDGuid = null;
			this._Remoting_Identity_IDSeqNum = 64;
			this._maker = null;
		}
Пример #6
0
        internal void GetTokens(TokenizerStream stream, int maxNum, bool endAfterKet)
        {
            while (maxNum == -1 || stream.GetTokenCount() < maxNum)
            {
                int  num1  = 0;
                bool flag1 = false;
                bool flag2 = false;
                Tokenizer.StringMaker stringMaker1 = this._maker;
                stringMaker1._outStringBuilder = (StringBuilder)null;
                stringMaker1._outIndex         = 0;
                int num2;
                while (true)
                {
                    if (this._inSavedCharacter != -1)
                    {
                        num2 = this._inSavedCharacter;
                        this._inSavedCharacter = -1;
                    }
                    else
                    {
                        switch (this._inTokenSource)
                        {
                        case Tokenizer.TokenSource.UnicodeByteArray:
                            if (this._inIndex + 1 < this._inSize)
                            {
                                num2          = ((int)this._inBytes[this._inIndex + 1] << 8) + (int)this._inBytes[this._inIndex];
                                this._inIndex = this._inIndex + 2;
                                break;
                            }
                            goto label_6;

                        case Tokenizer.TokenSource.UTF8ByteArray:
                            if (this._inIndex < this._inSize)
                            {
                                byte[] numArray1 = this._inBytes;
                                int    num3      = this._inIndex;
                                this._inIndex = num3 + 1;
                                int index1 = num3;
                                num2 = (int)numArray1[index1];
                                if ((num2 & 128) != 0)
                                {
                                    switch ((num2 & 240) >> 4)
                                    {
                                    case 8:
                                    case 9:
                                    case 10:
                                    case 11:
                                        goto label_12;

                                    case 12:
                                    case 13:
                                        num2 &= 31;
                                        num1  = 2;
                                        break;

                                    case 14:
                                        num2 &= 15;
                                        num1  = 3;
                                        break;

                                    case 15:
                                        goto label_15;
                                    }
                                    if (this._inIndex < this._inSize)
                                    {
                                        byte[] numArray2 = this._inBytes;
                                        int    num4      = this._inIndex;
                                        this._inIndex = num4 + 1;
                                        int  index2 = num4;
                                        byte num5   = numArray2[index2];
                                        if (((int)num5 & 192) == 128)
                                        {
                                            num2 = num2 << 6 | (int)num5 & 63;
                                            if (num1 != 2)
                                            {
                                                if (this._inIndex < this._inSize)
                                                {
                                                    byte[] numArray3 = this._inBytes;
                                                    int    num6      = this._inIndex;
                                                    this._inIndex = num6 + 1;
                                                    int  index3 = num6;
                                                    byte num7   = numArray3[index3];
                                                    if (((int)num7 & 192) == 128)
                                                    {
                                                        num2 = num2 << 6 | (int)num7 & 63;
                                                        break;
                                                    }
                                                    goto label_24;
                                                }
                                                else
                                                {
                                                    goto label_22;
                                                }
                                            }
                                            else
                                            {
                                                break;
                                            }
                                        }
                                        else
                                        {
                                            goto label_19;
                                        }
                                    }
                                    else
                                    {
                                        goto label_17;
                                    }
                                }
                                else
                                {
                                    break;
                                }
                            }
                            else
                            {
                                goto label_9;
                            }

                        case Tokenizer.TokenSource.ASCIIByteArray:
                            if (this._inIndex < this._inSize)
                            {
                                byte[] numArray = this._inBytes;
                                int    num3     = this._inIndex;
                                this._inIndex = num3 + 1;
                                int index = num3;
                                num2 = (int)numArray[index];
                                break;
                            }
                            goto label_27;

                        case Tokenizer.TokenSource.CharArray:
                            if (this._inIndex < this._inSize)
                            {
                                char[] chArray = this._inChars;
                                int    num3    = this._inIndex;
                                this._inIndex = num3 + 1;
                                int index = num3;
                                num2 = (int)chArray[index];
                                break;
                            }
                            goto label_30;

                        case Tokenizer.TokenSource.String:
                            if (this._inIndex < this._inSize)
                            {
                                string str  = this._inString;
                                int    num3 = this._inIndex;
                                this._inIndex = num3 + 1;
                                int index = num3;
                                num2 = (int)str[index];
                                break;
                            }
                            goto label_33;

                        case Tokenizer.TokenSource.NestedStrings:
                            if (this._inNestedSize != 0)
                            {
                                if (this._inNestedIndex < this._inNestedSize)
                                {
                                    string str  = this._inNestedString;
                                    int    num3 = this._inNestedIndex;
                                    this._inNestedIndex = num3 + 1;
                                    int index = num3;
                                    num2 = (int)str[index];
                                    break;
                                }
                                this._inNestedSize = 0;
                            }
                            if (this._inIndex < this._inSize)
                            {
                                string str  = this._inString;
                                int    num3 = this._inIndex;
                                this._inIndex = num3 + 1;
                                int index1 = num3;
                                num2 = (int)str[index1];
                                if (num2 == 123)
                                {
                                    for (int index2 = 0; index2 < this._searchStrings.Length; ++index2)
                                    {
                                        if (string.Compare(this._searchStrings[index2], 0, this._inString, this._inIndex - 1, this._searchStrings[index2].Length, StringComparison.Ordinal) == 0)
                                        {
                                            this._inNestedString = this._replaceStrings[index2];
                                            this._inNestedSize   = this._inNestedString.Length;
                                            this._inNestedIndex  = 1;
                                            num2          = (int)this._inNestedString[0];
                                            this._inIndex = this._inIndex + (this._searchStrings[index2].Length - 1);
                                            break;
                                        }
                                    }
                                    break;
                                }
                                break;
                            }
                            goto label_40;

                        default:
                            num2 = this._inTokenReader.Read();
                            if (num2 != -1)
                            {
                                break;
                            }
                            goto label_48;
                        }
                    }
                    if (!flag1)
                    {
                        switch (num2)
                        {
                        case 45:
                            if (this._inProcessingTag == 0)
                            {
                                break;
                            }
                            goto label_63;

                        case 47:
                            if (this._inProcessingTag == 0)
                            {
                                break;
                            }
                            goto label_57;

                        case 60:
                            goto label_52;

                        case 61:
                            goto label_55;

                        case 62:
                            goto label_53;

                        case 63:
                            if (this._inProcessingTag == 0)
                            {
                                break;
                            }
                            goto label_59;

                        case 9:
                        case 13:
                        case 32:
                            continue;

                        case 10:
                            this.LineNo = this.LineNo + 1;
                            continue;

                        case 33:
                            if (this._inProcessingTag == 0)
                            {
                                break;
                            }
                            goto label_61;

                        case 34:
                            flag1 = true;
                            flag2 = true;
                            continue;
                        }
                    }
                    else
                    {
                        switch (num2)
                        {
                        case 34:
                            if (!flag2)
                            {
                                break;
                            }
                            goto label_72;

                        case 47:
                        case 61:
                        case 62:
                            if (flag2 || this._inProcessingTag == 0)
                            {
                                break;
                            }
                            goto label_70;

                        case 60:
                            if (flag2)
                            {
                                break;
                            }
                            goto label_68;

                        case 9:
                        case 13:
                        case 32:
                            if (flag2)
                            {
                                break;
                            }
                            goto label_74;

                        case 10:
                            this.LineNo = this.LineNo + 1;
                            if (flag2)
                            {
                                break;
                            }
                            goto label_76;
                        }
                    }
                    flag1 = true;
                    if (stringMaker1._outIndex < 512)
                    {
                        char[] chArray = stringMaker1._outChars;
                        Tokenizer.StringMaker stringMaker2 = stringMaker1;
                        int num3 = stringMaker2._outIndex;
                        int num4 = num3 + 1;
                        stringMaker2._outIndex = num4;
                        int index = num3;
                        int num5  = (int)(ushort)num2;
                        chArray[index] = (char)num5;
                    }
                    else
                    {
                        if (stringMaker1._outStringBuilder == null)
                        {
                            stringMaker1._outStringBuilder = new StringBuilder();
                        }
                        stringMaker1._outStringBuilder.Append(stringMaker1._outChars, 0, 512);
                        stringMaker1._outChars[0] = (char)num2;
                        stringMaker1._outIndex    = 1;
                    }
                }
label_6:
                stream.AddToken((short)-1);
                break;
label_9:
                stream.AddToken((short)-1);
                break;
label_12:
                throw new XmlSyntaxException(this.LineNo);
label_15:
                throw new XmlSyntaxException(this.LineNo);
label_17:
                throw new XmlSyntaxException(this.LineNo, Environment.GetResourceString("XMLSyntax_UnexpectedEndOfFile"));
label_19:
                throw new XmlSyntaxException(this.LineNo);
label_22:
                throw new XmlSyntaxException(this.LineNo, Environment.GetResourceString("XMLSyntax_UnexpectedEndOfFile"));
label_24:
                throw new XmlSyntaxException(this.LineNo);
label_27:
                stream.AddToken((short)-1);
                break;
label_30:
                stream.AddToken((short)-1);
                break;
label_33:
                stream.AddToken((short)-1);
                break;
label_40:
                stream.AddToken((short)-1);
                break;
label_48:
                stream.AddToken((short)-1);
                break;
label_52:
                this._inProcessingTag = this._inProcessingTag + 1;
                stream.AddToken((short)0);
                continue;
label_53:
                this._inProcessingTag = this._inProcessingTag - 1;
                stream.AddToken((short)1);
                if (endAfterKet)
                {
                    break;
                }
                continue;
label_55:
                stream.AddToken((short)4);
                continue;
label_57:
                stream.AddToken((short)2);
                continue;
label_59:
                stream.AddToken((short)5);
                continue;
label_61:
                stream.AddToken((short)6);
                continue;
label_63:
                stream.AddToken((short)7);
                continue;
label_68:
                this._inSavedCharacter = num2;
                stream.AddToken((short)3);
                stream.AddString(this.GetStringToken());
                continue;
label_70:
                this._inSavedCharacter = num2;
                stream.AddToken((short)3);
                stream.AddString(this.GetStringToken());
                continue;
label_72:
                stream.AddToken((short)3);
                stream.AddString(this.GetStringToken());
                continue;
label_74:
                stream.AddToken((short)3);
                stream.AddString(this.GetStringToken());
                continue;
label_76:
                stream.AddToken((short)3);
                stream.AddString(this.GetStringToken());
            }
        }