Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.airlift.bytecode.instruction;
import com.google.common.collect.ImmutableList;
import com.google.common.primitives.Primitives;
import io.airlift.bytecode.BytecodeNode;
import io.airlift.bytecode.BytecodeVisitor;
import io.airlift.bytecode.MethodGenerationContext;
import io.airlift.bytecode.ParameterizedType;
import org.objectweb.asm.ConstantDynamic;
import org.objectweb.asm.Handle;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;
import java.lang.reflect.Method;
import java.util.List;
import static com.google.common.base.MoreObjects.toStringHelper;
import static io.airlift.bytecode.MethodDefinition.methodDescription;
import static io.airlift.bytecode.OpCode.ACONST_NULL;
import static io.airlift.bytecode.OpCode.BIPUSH;
import static io.airlift.bytecode.OpCode.DCONST_0;
import static io.airlift.bytecode.OpCode.DCONST_1;
import static io.airlift.bytecode.OpCode.FCONST_0;
import static io.airlift.bytecode.OpCode.FCONST_1;
import static io.airlift.bytecode.OpCode.FCONST_2;
import static io.airlift.bytecode.OpCode.ICONST_0;
import static io.airlift.bytecode.OpCode.ICONST_1;
import static io.airlift.bytecode.OpCode.ICONST_2;
import static io.airlift.bytecode.OpCode.ICONST_3;
import static io.airlift.bytecode.OpCode.ICONST_4;
import static io.airlift.bytecode.OpCode.ICONST_5;
import static io.airlift.bytecode.OpCode.ICONST_M1;
import static io.airlift.bytecode.OpCode.LCONST_0;
import static io.airlift.bytecode.OpCode.LCONST_1;
import static io.airlift.bytecode.OpCode.SIPUSH;
import static io.airlift.bytecode.ParameterizedType.type;
import static io.airlift.bytecode.instruction.FieldInstruction.getStaticInstruction;
import static io.airlift.bytecode.instruction.InvokeInstruction.invokeStatic;
import static java.util.Objects.requireNonNull;
@SuppressWarnings("UnusedDeclaration")
public abstract class Constant
implements InstructionNode
{
public static Constant loadNull()
{
return new NullConstant();
}
public static Constant loadBoolean(boolean value)
{
return new BooleanConstant(value);
}
public static Constant loadBoxedBoolean(boolean value)
{
return new BoxedBooleanConstant(value);
}
public static Constant loadInt(int value)
{
return new IntConstant(value);
}
public static Constant loadBoxedInt(int value)
{
return new BoxedIntegerConstant(value);
}
public static Constant loadFloat(float value)
{
return new FloatConstant(value);
}
public static Constant loadBoxedFloat(float value)
{
return new BoxedFloatConstant(value);
}
public static Constant loadLong(long value)
{
return new LongConstant(value);
}
public static Constant loadBoxedLong(long value)
{
return new BoxedLongConstant(value);
}
public static Constant loadDouble(double value)
{
return new DoubleConstant(value);
}
public static Constant loadBoxedDouble(double value)
{
return new BoxedDoubleConstant(value);
}
public static Constant loadNumber(Number value)
{
requireNonNull(value, "value is null");
if (value instanceof Byte) {
return loadInt((value).intValue());
}
if (value instanceof Short) {
return loadInt((value).intValue());
}
if (value instanceof Integer) {
return loadInt((Integer) value);
}
if (value instanceof Long) {
return loadLong((Long) value);
}
if (value instanceof Float) {
return loadFloat((Float) value);
}
if (value instanceof Double) {
return loadDouble((Double) value);
}
throw new IllegalStateException("Unsupported number type " + value.getClass().getSimpleName());
}
public static Constant loadString(String value)
{
requireNonNull(value, "value is null");
return new StringConstant(value);
}
public static Constant loadClass(Class> value)
{
requireNonNull(value, "value is null");
return new ClassConstant(type(value));
}
public static Constant loadClass(ParameterizedType value)
{
requireNonNull(value, "value is null");
return new ClassConstant(value);
}
public static Constant loadDynamic(
String name,
ParameterizedType type,
Method bootstrapMethod,
Iterable