All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.reandroid.dex.ins.TryBlock Maven / Gradle / Ivy

The newest version!
/*
 *  Copyright (C) 2022 github.com/REAndroid
 *
 *  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 com.reandroid.dex.ins;

import com.reandroid.arsc.base.Creator;
import com.reandroid.arsc.container.BlockList;
import com.reandroid.arsc.io.BlockReader;
import com.reandroid.arsc.item.ByteArray;
import com.reandroid.dex.base.DexPositionAlign;
import com.reandroid.dex.base.Ule128Item;
import com.reandroid.dex.data.CodeItem;
import com.reandroid.dex.data.FixedDexContainerWithTool;
import com.reandroid.dex.data.InstructionList;
import com.reandroid.dex.smali.model.SmaliCodeTryItem;
import com.reandroid.utils.collection.EmptyIterator;
import com.reandroid.utils.collection.ExpandIterator;

import java.io.IOException;
import java.util.Iterator;
import java.util.Objects;

public class TryBlock extends FixedDexContainerWithTool implements
        Creator, Iterable, LabelsSet {

    private final CodeItem codeItem;
    private HandlerOffsetArray handlerOffsetArray;
    private Ule128Item tryItemsCount;
    private ByteArray unknownBytes;
    private BlockList tryItemArray;
    private DexPositionAlign positionAlign;

    public TryBlock(CodeItem codeItem) {
        super(5);
        this.codeItem = codeItem;
    }

    InstructionList getInstructionList(){
        return getCodeItem().getInstructionList();
    }
    private CodeItem getCodeItem(){
        return codeItem;
    }
    public int getTryItemCount() {
        if(isNull()){
            return 0;
        }
        return tryItemArray.getCount();
    }
    public int getRealTryItemCount(){
        BlockList array = this.tryItemArray;
        if(array == null){
            return 0;
        }
        int count = 0;
        int size = array.size();
        for(int i = 0; i < size; i++){
            TryItem tryItem = array.get(i);
            if(!tryItem.isCopy()){
                count ++;
            }
        }
        return count;
    }
    @Override
    public Iterator




© 2015 - 2025 Weber Informatics LLC | Privacy Policy