• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2007 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.dx.rop.cst;
18 
19 import com.android.dx.rop.type.Type;
20 import com.android.dx.util.Hex;
21 
22 /**
23  * Constants of type {@code CONSTANT_Long_info}.
24  */
25 public final class CstLong
26         extends CstLiteral64 {
27     /** {@code non-null;} instance representing {@code 0} */
28     public static final CstLong VALUE_0 = make(0);
29 
30     /** {@code non-null;} instance representing {@code 1} */
31     public static final CstLong VALUE_1 = make(1);
32 
33     /**
34      * Makes an instance for the given value. This may (but does not
35      * necessarily) return an already-allocated instance.
36      *
37      * @param value the {@code long} value
38      */
make(long value)39     public static CstLong make(long value) {
40         /*
41          * Note: Javadoc notwithstanding, this implementation always
42          * allocates.
43          */
44         return new CstLong(value);
45     }
46 
47     /**
48      * Constructs an instance. This constructor is private; use {@link #make}.
49      *
50      * @param value the {@code long} value
51      */
CstLong(long value)52     private CstLong(long value) {
53         super(value);
54     }
55 
56     /** {@inheritDoc} */
57     @Override
toString()58     public String toString() {
59         long value = getLongBits();
60         return "long{0x" + Hex.u8(value) + " / " + value + '}';
61     }
62 
63     /** {@inheritDoc} */
getType()64     public Type getType() {
65         return Type.LONG;
66     }
67 
68     /** {@inheritDoc} */
69     @Override
typeName()70     public String typeName() {
71         return "long";
72     }
73 
74     /** {@inheritDoc} */
toHuman()75     public String toHuman() {
76         return Long.toString(getLongBits());
77     }
78 
79     /**
80      * Gets the {@code long} value.
81      *
82      * @return the value
83      */
getValue()84     public long getValue() {
85         return getLongBits();
86     }
87 }
88