ZeroSizeInsn.java revision 579d7739c53a2707ad711a2d2cae46d7d782f061
146d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)/*
2d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) * Copyright (C) 2007 The Android Open Source Project
3d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) *
4d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) * Licensed under the Apache License, Version 2.0 (the "License");
5d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) * you may not use this file except in compliance with the License.
6d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) * You may obtain a copy of the License at
74e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) *
8d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) *      http://www.apache.org/licenses/LICENSE-2.0
9d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) *
10d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) * Unless required by applicable law or agreed to in writing, software
11d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) * distributed under the License is distributed on an "AS IS" BASIS,
12d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) * See the License for the specific language governing permissions and
14d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) * limitations under the License.
15d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) */
16d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)
17d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)package com.android.dx.dex.code;
184e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)
19d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)import com.android.dx.rop.code.RegisterSpecList;
20d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)import com.android.dx.rop.code.SourcePosition;
214e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)import com.android.dx.util.AnnotatedOutput;
224e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)
234e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)/**
244e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) * Pseudo-instruction base class for zero-size (no code emitted)
254e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) * instructions, which are generally used for tracking metainformation
264e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) * about the code they are adjacent to.
274e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) */
284e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)public abstract class ZeroSizeInsn extends DalvInsn {
294e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)    /**
304e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)     * Constructs an instance. The output address of this instance is initially
314e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)     * unknown ({@code -1}).
324e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)     *
334e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)     * @param position {@code non-null;} source position
344e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)     */
354e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)    public ZeroSizeInsn(SourcePosition position) {
364e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)        super(Dops.SPECIAL_FORMAT, position, RegisterSpecList.EMPTY);
374e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)    }
38d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)
39d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)    /** {@inheritDoc} */
40d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)    @Override
41d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)    public final int codeSize() {
42d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)        return 0;
43d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)    }
44d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)
45d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)    /** {@inheritDoc} */
46d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)    @Override
47d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)    public final void writeTo(AnnotatedOutput out) {
484e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)        // Nothing to do here, for this class.
494e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)    }
50d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)
51d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)    /** {@inheritDoc} */
52d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)    @Override
53d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)    public final DalvInsn withOpcode(Dop opcode) {
54        throw new RuntimeException("unsupported");
55    }
56
57    /** {@inheritDoc} */
58    @Override
59    public DalvInsn withRegisterOffset(int delta) {
60        return withRegisters(getRegisters().withOffset(delta));
61    }
62}
63