Beispiel #1
0
        public void execute(StackFrame frame)
        {
            if ( EnterEvent != null) { EnterEvent(classFileName, name.getUTF8String(),descriptor.getUTF8String()); }
            if (! isNative()) {
                Hashtable byteCodes = methodCode.getCode();

                ByteCode bc = null;
                frame.setProgramCounter(0);
                do {
                //foreach (ByteCode bc in byteCode){
                    bc = (ByteCode) byteCodes[frame.getProgramCounter()];
                    if (bc != null){
                        frame.setByteCode(bc);

                        if (log.IsDebugEnabled) log.DebugFormat("{0}: {1}",frame.getProgramCounter(),bc);
                        if (methodCode.hasLineNumbers() && methodCode.getLineNumber((UInt16)frame.getProgramCounter()) != 0){
                            if (log.IsDebugEnabled) log.DebugFormat(classFile.GetName() + ":{0}",methodCode.getLineNumber((UInt16)frame.getProgramCounter()));
                        }
                        if (ByteCodeEnterEvent != null) { ByteCodeEnterEvent(bc.getName()); }
                        bc.execute(frame);
                        if (ByteCodeExitEvent != null) { ByteCodeExitEvent(bc.getName()); }
                        // the instruction might have moved the counter
                        // but it is assumed to not have accounted
                        // for its own length
                        frame.setProgramCounter(frame.getProgramCounter() + bc.getSize());
                    }

                } while (bc != null && ! (bc is ByteCode_areturn ||
                                          bc is ByteCode_ireturn ||
                                          bc is ByteCode_freturn ||
                                          bc is ByteCode_lreturn ||
                                          bc is ByteCode_dreturn ||
                                          bc is ByteCode_return));
            }
            else {
                throw new ToyVMException("Method is native!",frame);
            }
            if (ExitEvent != null) { ExitEvent(classFileName, name.getUTF8String(),descriptor.getUTF8String()); }
        }