Package org.trifort.rootbeer.entry

Source Code of org.trifort.rootbeer.entry.KernelEntryPointDetector

/*
* Copyright 2012 Phil Pratt-Szeliga and other contributors
* http://chirrup.org/
*
* See the file LICENSE for copying permission.
*/

package org.trifort.rootbeer.entry;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import soot.SootClass;
import soot.SootMethod;
import soot.rbclassload.HierarchySignature;
import soot.rbclassload.HierarchySootClass;
import soot.rbclassload.HierarchySootMethod;
import soot.rbclassload.MethodTester;

public class KernelEntryPointDetector implements MethodTester {

  private boolean m_runTests;
 
  public KernelEntryPointDetector(boolean run_tests){
    m_runTests = run_tests;
  }
 
  public boolean test(HierarchySootMethod sm) {
    if(sm.getSubSignature().equals("void gpuMethod()") == false){
      return false;
    }
    HierarchySootClass soot_class = sm.getHierarchySootClass();
    if(m_runTests == false){
      if(soot_class.getName().startsWith("org.trifort.rootbeer.testcases.")){
        return false;
      }
    }
    Iterator<String> iter = soot_class.getInterfaces().iterator();
    while(iter.hasNext()){
      String iface = iter.next();
      if(iface.equals("org.trifort.rootbeer.runtime.Kernel")){
        return true;
      }
    }
    return false;
  }

}
TOP

Related Classes of org.trifort.rootbeer.entry.KernelEntryPointDetector

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.