Package bytecodeparser.analysis.stack.StackAnalyzer.Frames

Examples of bytecodeparser.analysis.stack.StackAnalyzer.Frames.FrameIterator


                ctClass.addField(signature);
                // end

                Frames frames = parser.analyze();
                CodeAttribute codeAttribute = behavior.getMethodInfo().getCodeAttribute();
                FrameIterator iterator = frames.iterator();
                while(iterator.hasNext()) {
                    Frame frame = iterator.next();
                    if(!frame.isAccessible) {
                        Logger.debug("WARNING : frame " + frame.index + " is NOT accessible");
                        continue;
                    }
                    if(frame.decodedOp instanceof DecodedMethodInvocationOp) {
                        DecodedMethodInvocationOp dmio = (DecodedMethodInvocationOp) frame.decodedOp;
                        if(!dmio.getDeclaringClassName().equals("org.apache.commons.javaflow.bytecode.StackRecorder") &&
                                !dmio.getDeclaringClassName().startsWith("java.")) { // no need to track non-user method calls
                            MethodParams methodParams = DecodedMethodInvocationOp.resolveParameters(frame);
                           
                            String[] paramsNames = new String[methodParams.params.length + (methodParams.varargs != null ? methodParams.varargs.length : 0)];
                            for(int i = 0; i < methodParams.params.length; i++)
                                if(methodParams.params[i] != null && methodParams.params[i].name != null)
                                    paramsNames[i] = methodParams.params[i].name;
                            if(methodParams.varargs != null)
                                for(int i = 0, j = methodParams.params.length; i < methodParams.varargs.length; i++, j++)
                                    if(methodParams.varargs[i] != null && methodParams.varargs[i].name != null)
                                        paramsNames[j] = methodParams.varargs[i].name;

                            Bytecode b = makeInitMethodCall(behavior, dmio.getName(), dmio.getNbParameters(), methodParams.subject != null ? methodParams.subject.name : null, paramsNames);
                            insert(b, ctClass, behavior, codeAttribute, iterator, frame, false);
                        }
                    }
                    if(frame.decodedOp.op instanceof ExitOpcode) {
                        Bytecode b = makeExitMethod(behavior, ctClass.getName(), behavior.getName(), behavior.getSignature());
                        insert(b, ctClass, behavior, codeAttribute, iterator, frame, false);
                    }
                    if(iterator.isFirst()) {
                        insert(makeEnterMethod(behavior, ctClass.getName(), behavior.getName(), behavior.getSignature()), ctClass, behavior, codeAttribute, iterator, frame, false);
                    }
                }
            } catch(Exception e) {
                throw new UnexpectedException("LVEnhancer: cannot enhance the behavior '" + behavior.getLongName() + "'", e);
View Full Code Here

TOP

Related Classes of bytecodeparser.analysis.stack.StackAnalyzer.Frames.FrameIterator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.