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
17package com.android.dx.dex.code;
18
19import com.android.dx.rop.code.RegisterSpecList;
20import com.android.dx.rop.code.SourcePosition;
21
22/**
23 * Pseudo-instruction which is used to track an address within a code
24 * array. Instances are used for such things as branch targets and
25 * exception handler ranges. Its code size is zero, and so instances
26 * do not in general directly wind up in any output (either
27 * human-oriented or binary file).
28 */
29public final class CodeAddress extends ZeroSizeInsn {
30    /**
31     * Constructs an instance. The output address of this instance is initially
32     * unknown ({@code -1}).
33     *
34     * @param position {@code non-null;} source position
35     */
36    public CodeAddress(SourcePosition position) {
37        super(position);
38    }
39
40    /** {@inheritDoc} */
41    @Override
42    public final DalvInsn withRegisters(RegisterSpecList registers) {
43        return new CodeAddress(getPosition());
44    }
45
46    /** {@inheritDoc} */
47    @Override
48    protected String argString() {
49        return null;
50    }
51
52    /** {@inheritDoc} */
53    @Override
54    protected String listingString0(boolean noteIndices) {
55        return "code-address";
56    }
57}
58