Example #1
0
        static int CheckIntConstBlock(byte[] program, int pc)
        {
            int          size   = 1;
            VarintResult result = Uvarint.GetUvarint(JavaHelper <byte> .ArrayCopyRange(program, pc + size, program.Length));

            if (result.length <= 0)
            {
                throw new ArgumentException(string.Format("could not decode int const block at pc=%d", pc));
            }
            else
            {
                size = size + result.length;
                int numInts = result.value;

                for (int i = 0; i < numInts; ++i)
                {
                    if (pc + size >= program.Length)
                    {
                        throw new ArgumentException("int const block exceeds program length");
                    }
                    result = Uvarint.GetUvarint(JavaHelper <byte> .ArrayCopyRange(program, pc + size, program.Length));
                    if (result.length <= 0)
                    {
                        throw new ArgumentException(string.Format("could not decode int const[%d] block at pc=%d", i, pc + size));
                    }

                    size += result.length;
                }
                return(size);
            }
        }