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

com.google.test.metric.method.BlockDecomposer Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2007 Google Inc.
 *
 * 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.google.test.metric.method;

import static java.util.Arrays.asList;

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.objectweb.asm.Label;

import com.google.test.metric.JavaType;
import com.google.test.metric.Type;
import com.google.test.metric.method.op.stack.JSR;
import com.google.test.metric.method.op.stack.RetSub;
import com.google.test.metric.method.op.stack.Return;
import com.google.test.metric.method.op.stack.StackOperation;
import com.google.test.metric.method.op.stack.Throw;
import com.google.test.metric.method.op.turing.Operation;

/**
 * @author [email protected] 
 */
public class BlockDecomposer {

  /**
   * Method is broken down into one frame per bytecode in order to break it down
   * into blocks
   */
  private static class Frame {

    /**
     * Next frame (ie next bytecode)
     */
    private Frame next;
    /**
     * Operation in this frame
     */
    private final StackOperation operation;
    /**
     * Any label associated with this bytecode
     */
    private Label label;
    /**
     * Block which this bytecode ended up assigned to
     */
    public Block block;
    /**
     * True if this is first bytecode of a block (GOTO). If true then new block
     * will start here.
     */
    public boolean blockStartsHere;
    /**
     * If true then this will be last instruction in block and new block will
     * start on next frame.
     */
    public boolean blockEndsHere;
    /**
     * If not null current block will link with block that this field points to.
     */
    public List




© 2015 - 2024 Weber Informatics LLC | Privacy Policy