Beispiel #1
0
        private AbcMethodBody GetMethodBody(AsMethodBodyInfo info)
        {
            var opcodeReader = new Avm2OpcodeReader(this);

            var res = new AbcMethodBody {
                MaxStack       = info.MaxStack,
                LocalCount     = info.LocalCount,
                InitScopeDepth = info.InitScopeDepth,
                MaxScopeDepth  = info.MaxScopeDepth,
            };
            var reader  = new AbcDataReader(new MemoryStream(info.Code));
            var factory = new Avm2OpcodeFactory();

            while (!reader.IsEOF)
            {
                var offset = reader.Position;
                var code   = (Avm2Opcode)reader.ReadU8();
                var opcode = factory.CreateOpcode(code);
                opcode.AcceptVisitor(opcodeReader, reader);
                res.Code.Add(new AbcMethodBodyInstruction {
                    Offset = (uint)offset,
                    Opcode = opcode
                });
            }
            foreach (var exc in info.Exceptions)
            {
                res.Exceptions.Add(GetExceptionBlock(exc));
            }
            return(res);
        }
Beispiel #2
0
        private AbcMethodBody GetMethodBody(AsMethodBodyInfo info)
        {
            var opcodeReader = new Avm2OpcodeReader(this);

            var res = new AbcMethodBody {
                MaxStack = info.MaxStack,
                LocalCount = info.LocalCount,
                InitScopeDepth = info.InitScopeDepth,
                MaxScopeDepth = info.MaxScopeDepth,
            };
            var reader = new AbcDataReader(new MemoryStream(info.Code));
            var factory = new Avm2OpcodeFactory();
            while (!reader.IsEOF) {
                var offset = reader.Position;
                var code = (Avm2Opcode)reader.ReadU8();
                var opcode = factory.CreateOpcode(code);
                opcode.AcceptVisitor(opcodeReader, reader);
                res.Code.Add(new AbcMethodBodyInstruction {
                    Offset = (uint)offset,
                    Opcode = opcode
                });
            }
            foreach (var exc in info.Exceptions) {
                res.Exceptions.Add(GetExceptionBlock(exc));
            }
            return res;
        }