@@ -87,65 +87,57 @@ public void visit(FieldDeclaration declaration) {}
8787
8888 @ Override
8989 public void visit (ConstructorDeclaration declaration ) {
90- ClassFileConstructorOrMethodDeclaration comd = (ClassFileConstructorOrMethodDeclaration )declaration ;
91- LocalVariableMaker localVariableMaker = new LocalVariableMaker (typeMaker , comd , true , comd .getParameterTypes ());
92-
93- createParametersVariablesAndStatements (comd , localVariableMaker );
90+ createParametersVariablesAndStatements ((ClassFileConstructorOrMethodDeclaration )declaration , true );
9491 }
9592
9693 @ Override
9794 public void visit (MethodDeclaration declaration ) {
98- ClassFileConstructorOrMethodDeclaration comd = (ClassFileConstructorOrMethodDeclaration )declaration ;
99- LocalVariableMaker localVariableMaker = new LocalVariableMaker (typeMaker , comd , false , comd .getParameterTypes ());
100-
101- createParametersVariablesAndStatements (comd , localVariableMaker );
95+ createParametersVariablesAndStatements ((ClassFileConstructorOrMethodDeclaration )declaration , false );
10296 }
10397
10498 @ Override
10599 public void visit (StaticInitializerDeclaration declaration ) {
106- ClassFileConstructorOrMethodDeclaration comd = (ClassFileConstructorOrMethodDeclaration )declaration ;
107- LocalVariableMaker localVariableMaker = new LocalVariableMaker (typeMaker , comd , false , null );
108-
109- createParametersVariablesAndStatements (comd , localVariableMaker );
100+ createParametersVariablesAndStatements ((ClassFileConstructorOrMethodDeclaration )declaration , false );
110101 }
111102
112- protected void createParametersVariablesAndStatements (ClassFileConstructorOrMethodDeclaration comd , LocalVariableMaker localVariableMaker ) {
103+ protected void createParametersVariablesAndStatements (ClassFileConstructorOrMethodDeclaration comd , boolean constructor ) {
113104 ClassFile classFile = comd .getClassFile ();
114- ClassFileBodyDeclaration bodyDeclaration = comd .getBodyDeclaration ();
115105 Method method = comd .getMethod ();
116- StatementMaker statementMaker = new StatementMaker (typeMaker , localVariableMaker , classFile , bodyDeclaration , comd );
106+ AttributeCode attributeCode = method .getAttribute ("Code" );
107+ LocalVariableMaker localVariableMaker = new LocalVariableMaker (typeMaker , comd , constructor );
117108
118- try {
119- ControlFlowGraph cfg = ControlFlowGraphMaker .make (method );
109+ if (attributeCode == null ) {
110+ localVariableMaker .make (false , typeMaker );
111+ } else {
112+ StatementMaker statementMaker = new StatementMaker (typeMaker , localVariableMaker , comd );
113+ boolean containsLineNumber = (attributeCode .getAttribute ("LineNumberTable" ) != null );
120114
121- if (cfg != null ) {
122- ControlFlowGraphGotoReducer .reduce (cfg );
123- ControlFlowGraphLoopReducer .reduce (cfg );
115+ try {
116+ ControlFlowGraph cfg = ControlFlowGraphMaker .make (method );
124117
125- if (ControlFlowGraphReducer .reduce (cfg )) {
126- comd .setStatements (statementMaker .make (cfg ));
127- } else {
128- comd .setStatements (new ByteCodeStatement (ByteCodeWriter .write ("// " , method )));
118+ if (cfg != null ) {
119+ ControlFlowGraphGotoReducer .reduce (cfg );
120+ ControlFlowGraphLoopReducer .reduce (cfg );
121+
122+ if (ControlFlowGraphReducer .reduce (cfg )) {
123+ comd .setStatements (statementMaker .make (cfg ));
124+ } else {
125+ comd .setStatements (new ByteCodeStatement (ByteCodeWriter .write ("// " , method )));
126+ }
129127 }
128+ } catch (Exception e ) {
129+ assert ExceptionUtil .printStackTrace (e );
130+ comd .setStatements (new ByteCodeStatement (ByteCodeWriter .write ("// " , method )));
130131 }
131- } catch (Exception e ) {
132- assert ExceptionUtil .printStackTrace (e );
133- comd .setStatements (new ByteCodeStatement (ByteCodeWriter .write ("// " , method )));
134- }
135132
136- if ((classFile .getAccessFlags () & FLAG_INTERFACE ) != 0 ) {
137- comd .setFlags (comd .getFlags () & ~(FLAG_PUBLIC |FLAG_ABSTRACT ));
133+ localVariableMaker .make (containsLineNumber , typeMaker );
138134 }
139135
140- boolean containsLineNumber = false ;
141- AttributeCode attributeCode = method .getAttribute ("Code" );
136+ comd .setFormalParameters (localVariableMaker .getFormalParameters ());
142137
143- if (attributeCode != null ) {
144- containsLineNumber = ( attributeCode . getAttribute ( "LineNumberTable" ) != null );
138+ if (( classFile . getAccessFlags () & FLAG_INTERFACE ) != 0 ) {
139+ comd . setFlags ( comd . getFlags () & ~( FLAG_PUBLIC | FLAG_ABSTRACT ) );
145140 }
146-
147- localVariableMaker .make (containsLineNumber , typeMaker );
148- comd .setFormalParameters (localVariableMaker .getFormalParameters ());
149141 }
150142
151143 @ Override
0 commit comments