Search in sources :

Example 1 with JOPModel

use of com.jopdesign.common.processormodel.JOPModel in project jop by jop-devel.

the class AppSetup method initProcessorModel.

private void initProcessorModel(Model model) {
    ProcessorModel pm;
    switch(model) {
        case JOP:
            pm = new JOPModel(config);
            break;
        case jamuth:
            pm = new JamuthModel(config);
            break;
        case allocation:
            pm = new AllocationModel(config);
            break;
        case JVM:
            pm = new JVMModel();
            break;
        default:
            throw new BadConfigurationError("Unknown processor model " + model);
    }
    appInfo.setProcessorModel(pm);
    // load referenced classes as roots
    for (String jvmClass : pm.getJVMClasses()) {
        ClassInfo rootInfo = appInfo.loadClass(jvmClass.replaceAll("/", "."));
        if (rootInfo == null) {
            System.err.println("Error loading JVM class '" + jvmClass + "'.");
            System.exit(4);
        }
    }
    if (appInfo.doLoadNatives()) {
        for (String nativeClass : pm.getNativeClasses()) {
            ClassInfo rootInfo = appInfo.loadClass(nativeClass.replaceAll("/", "."));
            if (rootInfo == null) {
                System.err.println("Error loading Native class '" + nativeClass + "'.");
                System.exit(4);
            }
        }
    }
    // we do not set the JVM and native classes as root anymore, instead we let the PM decide which roots we need
    for (String root : pm.getJVMRoots()) {
        MemberID mID = MemberID.parse(root);
        // make sure the class exists..
        ClassInfo cls = appInfo.loadClass(mID.getClassName());
        // Get the member and add it as root
        if (mID.hasMemberName()) {
            MethodInfo methodInfo = cls.getMethodInfo(mID);
            if (methodInfo == null) {
                System.err.println("Could not find JVM root " + root);
                System.exit(5);
            }
            appInfo.addRoot(methodInfo);
        } else {
            appInfo.addRoot(cls);
        }
    }
}
Also used : MemberID(com.jopdesign.common.type.MemberID) BadConfigurationError(com.jopdesign.common.config.Config.BadConfigurationError) JOPModel(com.jopdesign.common.processormodel.JOPModel) AllocationModel(com.jopdesign.common.processormodel.AllocationModel) ProcessorModel(com.jopdesign.common.processormodel.ProcessorModel) JVMModel(com.jopdesign.common.processormodel.JVMModel) JamuthModel(com.jopdesign.common.processormodel.JamuthModel)

Aggregations

BadConfigurationError (com.jopdesign.common.config.Config.BadConfigurationError)1 AllocationModel (com.jopdesign.common.processormodel.AllocationModel)1 JOPModel (com.jopdesign.common.processormodel.JOPModel)1 JVMModel (com.jopdesign.common.processormodel.JVMModel)1 JamuthModel (com.jopdesign.common.processormodel.JamuthModel)1 ProcessorModel (com.jopdesign.common.processormodel.ProcessorModel)1 MemberID (com.jopdesign.common.type.MemberID)1