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

org.pitest.coverage.CodeCoverageStore Maven / Gradle / Ivy

/*
 * Based on http://code.google.com/p/javacoveragent/ by
 * "alex.mq0" and "dmitry.kandalov"
 * 
 * 
 * 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 org.pitest.coverage;

import org.objectweb.asm.Type;
import org.objectweb.asm.commons.Method;
import org.pitest.coverage.execute.InvokeReceiver;

/**
 * @author ivanalx
 * @date 26.01.2009 14:41:04
 */
public final class CodeCoverageStore {
  public static final String        CODE_COVERAGE_CALCULATOR_CLASS_NAME;
  public static final String        CODE_COVERAGE_CALCULATOR_CODE_METHOD_NAME;
  public static final String        CODE_COVERAGE_CALCULATOR_CODE_METHOD_DESC;

  static {
    final Method addCalc = new Method("visitLine", Type.VOID_TYPE, new Type[] {
      Type.INT_TYPE, Type.INT_TYPE });

    CODE_COVERAGE_CALCULATOR_CODE_METHOD_NAME = addCalc.getName();
    CODE_COVERAGE_CALCULATOR_CODE_METHOD_DESC = addCalc.getDescriptor();
    CODE_COVERAGE_CALCULATOR_CLASS_NAME = CodeCoverageStore.class.getName()
        .replace('.', '/');

  }

  private static InvokeReceiver     invokeQueue;
  private static CoverageStatistics invokeStatistics;

  public static void init(final InvokeReceiver invokeQueue,
      final CoverageStatistics invokeStatistics) {
    CodeCoverageStore.invokeQueue = invokeQueue;
    CodeCoverageStore.invokeStatistics = invokeStatistics;
  }

  private CodeCoverageStore() {
  }

  public static void visitLine(final int classId, final int codeLine) { // NO_UCD
    invokeQueue.addCodelineInvoke(classId, codeLine);
  }

  public static int registerClass(final String className) {
    final int id = invokeStatistics.registerClass(className);
    invokeQueue.registerClass(id, className);
    return id;
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy