1 /*
2 * Copyright (c) 2017, 2019, 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
47 import com.sun.org.apache.bcel.internal.generic.InstructionConst;
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$
68 * @LastModified: Jun 2019
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, 2020, 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
47 import com.sun.org.apache.bcel.internal.generic.InstructionConst;
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 * @LastModified: Jan 2020
68 */
69 class BCELFactory extends EmptyVisitor {
70
71 private static final String CONSTANT_PREFIX = Const.class.getSimpleName()+".";
72 private final MethodGen _mg;
73 private final PrintWriter _out;
74 private final ConstantPoolGen _cp;
75
76
77 BCELFactory(final MethodGen mg, final PrintWriter out) {
78 _mg = mg;
79 _cp = mg.getConstantPool();
80 _out = out;
81 }
82
83 private final Map<Instruction, InstructionHandle> branch_map = new HashMap<>();
84
85
86 public void start() {
87 if (!_mg.isAbstract() && !_mg.isNative()) {
|