1 /*
2 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
3 * @LastModified: Oct 2017
4 */
5 /*
6 * Licensed to the Apache Software Foundation (ASF) under one or more
7 * contributor license agreements. See the NOTICE file distributed with
8 * this work for additional information regarding copyright ownership.
9 * The ASF licenses this file to You under the Apache License, Version 2.0
10 * (the "License"); you may not use this file except in compliance with
11 * the License. You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 */
21
22 package com.sun.org.apache.bcel.internal.util;
23
49 import com.sun.org.apache.bcel.internal.generic.InstructionHandle;
50 import com.sun.org.apache.bcel.internal.generic.InvokeInstruction;
51 import com.sun.org.apache.bcel.internal.generic.LDC;
52 import com.sun.org.apache.bcel.internal.generic.LDC2_W;
53 import com.sun.org.apache.bcel.internal.generic.LocalVariableInstruction;
54 import com.sun.org.apache.bcel.internal.generic.MULTIANEWARRAY;
55 import com.sun.org.apache.bcel.internal.generic.MethodGen;
56 import com.sun.org.apache.bcel.internal.generic.NEWARRAY;
57 import com.sun.org.apache.bcel.internal.generic.ObjectType;
58 import com.sun.org.apache.bcel.internal.generic.RET;
59 import com.sun.org.apache.bcel.internal.generic.ReturnInstruction;
60 import com.sun.org.apache.bcel.internal.generic.Select;
61 import com.sun.org.apache.bcel.internal.generic.Type;
62
63 /**
64 * Factory creates il.append() statements, and sets instruction targets.
65 * A helper class for BCELifier.
66 *
67 * @see BCELifier
68 * @version $Id: BCELFactory.java 1749603 2016-06-21 20:50:19Z ggregory $
69 */
70 class BCELFactory extends EmptyVisitor {
71
72 private static final String CONSTANT_PREFIX = Const.class.getSimpleName()+".";
73 private final MethodGen _mg;
74 private final PrintWriter _out;
75 private final ConstantPoolGen _cp;
76
77
78 BCELFactory(final MethodGen mg, final PrintWriter out) {
79 _mg = mg;
80 _cp = mg.getConstantPool();
81 _out = out;
82 }
83
84 private final Map<Instruction, InstructionHandle> branch_map = new HashMap<>();
85
86
87 public void start() {
88 if (!_mg.isAbstract() && !_mg.isNative()) {
|
1 /*
2 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
3 */
4 /*
5 * Licensed to the Apache Software Foundation (ASF) under one or more
6 * contributor license agreements. See the NOTICE file distributed with
7 * this work for additional information regarding copyright ownership.
8 * The ASF licenses this file to You under the Apache License, Version 2.0
9 * (the "License"); you may not use this file except in compliance with
10 * the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 */
20
21 package com.sun.org.apache.bcel.internal.util;
22
48 import com.sun.org.apache.bcel.internal.generic.InstructionHandle;
49 import com.sun.org.apache.bcel.internal.generic.InvokeInstruction;
50 import com.sun.org.apache.bcel.internal.generic.LDC;
51 import com.sun.org.apache.bcel.internal.generic.LDC2_W;
52 import com.sun.org.apache.bcel.internal.generic.LocalVariableInstruction;
53 import com.sun.org.apache.bcel.internal.generic.MULTIANEWARRAY;
54 import com.sun.org.apache.bcel.internal.generic.MethodGen;
55 import com.sun.org.apache.bcel.internal.generic.NEWARRAY;
56 import com.sun.org.apache.bcel.internal.generic.ObjectType;
57 import com.sun.org.apache.bcel.internal.generic.RET;
58 import com.sun.org.apache.bcel.internal.generic.ReturnInstruction;
59 import com.sun.org.apache.bcel.internal.generic.Select;
60 import com.sun.org.apache.bcel.internal.generic.Type;
61
62 /**
63 * Factory creates il.append() statements, and sets instruction targets.
64 * A helper class for BCELifier.
65 *
66 * @see BCELifier
67 * @version $Id: BCELFactory.java 1749603 2016-06-21 20:50:19Z ggregory $
68 * @LastModified: Oct 2017
69 */
70 class BCELFactory extends EmptyVisitor {
71
72 private static final String CONSTANT_PREFIX = Const.class.getSimpleName()+".";
73 private final MethodGen _mg;
74 private final PrintWriter _out;
75 private final ConstantPoolGen _cp;
76
77
78 BCELFactory(final MethodGen mg, final PrintWriter out) {
79 _mg = mg;
80 _cp = mg.getConstantPool();
81 _out = out;
82 }
83
84 private final Map<Instruction, InstructionHandle> branch_map = new HashMap<>();
85
86
87 public void start() {
88 if (!_mg.isAbstract() && !_mg.isNative()) {
|