Esempio n. 1
0
        public void CheckAndSaveFrame(Mono.Cecil.Cil.Instruction inst)
        {
            int offset = inst.Offset;

            if (!catchClauses.TryGetValue(offset, out var catchClause))
            {
                //
                // on every instruction, and in particular on entry to a 'try'
                // block, we want to save the stack frame.
                //
                // - for the 'try' case:  due to possibility of any exception
                // occuring at any point within the try block, exception clauses
                // always roll back to that stack frame at the top of the 'try'.
                //
                // - for any other instruction:  because it may be the target
                // of a backwards jump at the end of a loop.
                //

                stackMap.SaveFrame((ushort)offset, false, CilMain.Where);
            }
            else
            {
                //
                // otherwise this is entry to a catch/filter/finally clause.
                //
                // if this is the first exception in the chain, we would also
                // need to push the exception type into the stack frame,
                // before saving it.
                //

                ExceptionClauseSetup((ushort)offset, catchClause);
            }
        }
Esempio n. 2
0
        void Process(int numCastableInterfaces)
        {
            code = newMethod.Code = new JavaCode(newMethod);
            var oldLabel = code.SetLabel(0xFFFF);

            locals     = new CodeLocals(method, defMethod, code);
            arrays     = new CodeArrays(code, locals);
            exceptions = new CodeExceptions(defMethodBody, code, locals);

            InsertMethodInitCode(numCastableInterfaces);

            code.SetLabel(oldLabel);

            stackMap = code.StackMap;
            stackMap.SaveFrame(0, false, CilMain.Where);

            ProcessInstructions();

            (code.MaxLocals, code.MaxStack) = locals.GetMaxLocalsAndStack();
            locals.TrackUnconditionalBranch(null);
        }