当前位置: 首页>>代码示例>>Java>>正文


Java Options类代码示例

本文整理汇总了Java中natlab.options.Options的典型用法代码示例。如果您正苦于以下问题:Java Options类的具体用法?Java Options怎么用?Java Options使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Options类属于natlab.options包,在下文中一共展示了Options类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: modify

import natlab.options.Options; //导入依赖的package包/类
public static void modify(Options options) {
  Joiner joiner = Joiner.on(PATH_SEPARATOR);
  if (!options.set_matlab_path().isEmpty()){
    setMatlabPath(joiner.join(options.set_matlab_path()));
  }
  if (!options.set_natlab_path().isEmpty()) {
    setNatlabPath(joiner.join(options.set_natlab_path()));
  }
  if (!options.add_natlab_path().isEmpty()) {
    setNatlabPath(joiner.join(
        Arrays.asList(getNatlabPath(), joiner.join(options.add_natlab_path()))));
  }
  if (!options.add_matlab_path().isEmpty()) {
    setMatlabPath(joiner.join(
        Arrays.asList(getMatlabPath(), joiner.join(options.add_matlab_path()))));
  }
}
 
开发者ID:Sable,项目名称:mclab-core,代码行数:18,代码来源:NatlabPreferences.java

示例2: main

import natlab.options.Options; //导入依赖的package包/类
public static void main(Options options) throws IOException {
	Project project = Project.at(Paths.get(options.files().get(0)));
	List<LintAnalysis> analyses = getAllAnalyses(project);
	Lint lint = Lint.create(project, analyses);
	registerBuiltinListeners(lint);
	lint.runAnalyses();
	lint.writeReport(ReportGenerators.plain(), System.out);
	project.write();
}
 
开发者ID:Sable,项目名称:mclab-core,代码行数:10,代码来源:McLint.java

示例3: FlowAnalysisTestTool

import natlab.options.Options; //导入依赖的package包/类
public FlowAnalysisTestTool( String[] args, Class<? extends StructuralAnalysis> analysisType )
    throws NoSuchMethodException, InstantiationException, IllegalAccessException,
           InvocationTargetException, FileNotFoundException, Exception
{

    //Generate the AST
    CompilationUnits cu = new CompilationUnits();
    Options opt = new Options();
    opt.parse( args );
    
    if( opt.files().size() == 0 ){
        throw new Exception( "No files provided" );
    }
    for( Object o : opt.files() ){
        String fName = (String) o;
        ArrayList<CompilationProblem> errList = new ArrayList<CompilationProblem>();
        if( !opt.natlab() ){
            //translate from matlab
            Reader source = Parse.translateFile( fName, errList ).getReader();
            if( source == null )
                throw new Exception( "Error translating file "+ fName +":\n" + 
                    errList.stream().map(Object::toString).collect(Collectors.joining("\n")));
            Program prog = Parse.parseNatlabFile( fName, source, errList );
            if( prog == null )
                throw new Exception( "Error parsing file "+ fName +":\n" +
                    errList.stream().map(Object::toString).collect(Collectors.joining("\n")));
            cu.addProgram( prog );
        }
        else{
            cu.addProgram( parseFile( fName ) );
        }
    }
    
    //create the analysis
    analysis = analysisType.getConstructor( ASTNode.class ).newInstance(cu);
    this.ast = cu;
}
 
开发者ID:Sable,项目名称:mclab-core,代码行数:38,代码来源:FlowAnalysisTestTool.java

示例4: create

import natlab.options.Options; //导入依赖的package包/类
public static NatlabServer create(Options options) {
  int port = SERVER_PORT;
  if (options.sp().length() > 0) {
    port = Integer.parseInt(options.sp());
  }
  return new NatlabServer(port, options.quiet(), options.natlab(), !options.noheart());
}
 
开发者ID:Sable,项目名称:mclab-core,代码行数:8,代码来源:NatlabServer.java

示例5: FileEnvironment

import natlab.options.Options; //导入依赖的package包/类
/**
 * builds a file environment by reading the information from an options object.
 * Throws an unsupported operations exception if the options are malformed (i.e. 
 * no main file supplied)
 */
public FileEnvironment(Options options,BuiltinQuery query){
	this.query = query;
	
	//parse main file
	String main = "";
	if (options.main() != null && options.main().length() > 0){
		main = options.main();
	} else {
		List<String> list = options.files();
		if (list != null && list.size() > 0){
			main = list.get(0);
		}
	}
	if (main.length() == 0) throw new UnsupportedOperationException("no main file provided");
	this.main = GenericFile.create(main);
	if (this.main == null || !this.main.exists()){
		throw new UnsupportedOperationException("file "+main+" not found");
	}
	this.pwd = this.main.getParent();
	this.pwdHandler = FolderHandler.getFolderHandler(this.pwd);

	
	//get path
	@SuppressWarnings("unchecked")
	List<String> paths = (List<String>)options.lp();
	if (paths == null || paths.size() == 0){
         this.natlabPath = MatlabPath.getNatlabPath();
         this.matlabPath = MatlabPath.getMatlabPath();
	} else {
	  this.natlabPath = new MatlabPath(paths.stream()
	      .collect(Collectors.joining(StandardSystemProperty.PATH_SEPARATOR.value())));
	}
	this.folderHandlers = getFolderHandlers();
}
 
开发者ID:Sable,项目名称:mclab-core,代码行数:40,代码来源:FileEnvironment.java

示例6: create

import natlab.options.Options; //导入依赖的package包/类
public static NatlabServer create(Options options) {
  int port = SERVER_PORT;
  if (options.sp().length() > 0) {
    port = Integer.parseInt(options.sp());
  }
  return new NatlabServer(port, options.quiet(), options.matlab(), !options.noheart());
}
 
开发者ID:sshrdp,项目名称:mclab,代码行数:8,代码来源:NatlabServer.java

示例7: FileEnvironment

import natlab.options.Options; //导入依赖的package包/类
/**
 * builds a file environment by reading the information from an options object.
 * Throws an unsupported operations exception if the options are malformed (i.e. 
 * no main file supplied)
 */
public FileEnvironment(Options options,BuiltinQuery query){
	this.query = query;
	
	//parse main file
	String main = "";
	if (options.main() != null && options.main().length() > 0){
		main = options.main();
	} else {
		List<String> list = options.getFiles();
		if (list != null && list.size() > 0){
			main = list.get(0);
		}
	}
	if (main.length() == 0) throw new UnsupportedOperationException("no main file provided");
	this.main = GenericFile.create(main);
	if (this.main == null || !this.main.exists()){
		throw new UnsupportedOperationException("file "+main+" not found");
	}
	this.pwd = this.main.getParent();
	this.pwdHandler = FolderHandler.getFolderHandler(this.pwd);

	
	//get path
	@SuppressWarnings("unchecked")
	List<String> paths = (List<String>)options.lp();
	if (paths == null || paths.size() == 0){
         this.natlabPath = MatlabPath.getNatlabPath();
         this.matlabPath = MatlabPath.getMatlabPath();
	} else {
	  this.natlabPath =
	      new MatlabPath(Joiner.on(System.getProperty("path.separator")).join(paths));
	}
	this.folderHandlers = getFolderHandlers();
}
 
开发者ID:sshrdp,项目名称:mclab,代码行数:40,代码来源:FileEnvironment.java

示例8: FlowAnalysisTestTool

import natlab.options.Options; //导入依赖的package包/类
public FlowAnalysisTestTool( String[] args, Class<? extends StructuralAnalysis> analysisType )
    throws NoSuchMethodException, InstantiationException, IllegalAccessException,
           InvocationTargetException, FileNotFoundException, Exception
{

    //Generate the AST
    CompilationUnits cu = new CompilationUnits();
    Options opt = new Options();
    opt.parse( args );
    
    if( opt.getFiles().size() == 0 ){
        throw new Exception( "No files provided" );
    }
    for( Object o : opt.getFiles() ){
        String fName = (String) o;
        ArrayList<CompilationProblem> errList = new ArrayList<CompilationProblem>();
        if( opt.matlab() ){
            //translate from matlab
            Reader source = Parse.translateFile( fName, errList );
            if( source == null )
                throw new Exception( "Error translating file "+ fName +":\n" + CompilationProblem.toStringAll( errList ) );
            Program prog = Parse.parseNatlabFile( fName, source, errList );
            if( prog == null )
                throw new Exception( "Error parsing file "+ fName +":\n" + CompilationProblem.toStringAll( errList ) );
            cu.addProgram( prog );
        }
        else{
            cu.addProgram( parseFile( fName ) );
        }
    }
    
    //create the analysis
    analysis = analysisType.getConstructor( ASTNode.class ).newInstance(cu);
    this.ast = cu;
}
 
开发者ID:sshrdp,项目名称:mclab,代码行数:36,代码来源:FlowAnalysisTestTool.java

示例9: log

import natlab.options.Options; //导入依赖的package包/类
private static void log(Options options, String message) {
	if (!options.quiet()) {
		System.err.println(message);
	}
}
 
开发者ID:Sable,项目名称:mclab-core,代码行数:6,代码来源:McLabCore.java

示例10: main

import natlab.options.Options; //导入依赖的package包/类
/**
 * the entry point coming from natlab.Main - uses the options object to select the proper behavior
 */
public static void main(Options options){
	//** parse args ********
	FileEnvironment fileEnvironment = new FileEnvironment(options); //get path/files
	boolean inline = options.inline(); //get inline
	boolean outputToFile = false; //output TODO

	//arguments - TODO for now just parse them as inputs
	String args = "double"; //start with the default
	if (options.arguments() != null && options.arguments().length() > 0){
		args = options.arguments();
	}
	CP classProp = ClassPropTool.parse(args);
	List<CP> classPropList = new LinkedList<CP>();
	if (classProp instanceof CPChain){
		classPropList = ((CPChain)classProp).asList();
	} else if (classProp instanceof CPBuiltin){
		classPropList.add(classProp);
	} else {
		throw new UnsupportedOperationException("Arguments have to be a list of builtin classes");
	}
	List<PrimitiveClassReference> inputClasses = new LinkedList<PrimitiveClassReference>();
	for (CP element : classPropList){
		if (element instanceof CPBuiltin){
			inputClasses.add(PrimitiveClassReference.valueOf(((CPBuiltin)element).toString().toUpperCase()));
		} else {
			throw new UnsupportedOperationException(
					"Arguments have to be list of builtin classes, received "+element);
		}
	}
	
	
	//** build callgraph *******		
	ArrayList<AggrValue<SimpleMatrixValue>> list = new ArrayList<AggrValue<SimpleMatrixValue>>(inputClasses.size());
	for (PrimitiveClassReference ref : inputClasses){
		list.add(new SimpleMatrixValue(null, ref));
	}
	
	
	Callgraph<SimpleMatrixValue> callgraph = new Callgraph<SimpleMatrixValue>(
			fileEnvironment,
			Args.<AggrValue<SimpleMatrixValue>>newInstance(list),
			new SimpleMatrixValueFactory());
	
	
	//** output info ***********
	System.out.println(callgraph.prettyPrint());
	
}
 
开发者ID:Sable,项目名称:mclab-core,代码行数:52,代码来源:TamerTool.java

示例11: main

import natlab.options.Options; //导入依赖的package包/类
/**
 * compiles matlab files into fortran, using the Options as argument.
 * This is basically the entry point for mc4.
 * @param options A Natlab Options object defines the command line arguments to Mc4
 */
public static void main(Options options){
       //object that resolves function names to files      
    long t = System.currentTimeMillis();
       //System.out.println("time "+(System.currentTimeMillis() - t));
       //System.exit(0);
       
    //collect all needed matlab files
    SimpleFunctionCollection functions = new SimpleFunctionCollection(new FileEnvironment(options));
    allRefs.addAll(functions.getAllFunctionBuiltinReferences());
    //System.out.println(functions);
    
    
    //test intraprocedural class analysis
    try{
    ValueAnalysis<AggrValue<SimpleMatrixValue>> analysis = new ValueAnalysis<AggrValue<SimpleMatrixValue>>(
            functions,
            Args.<AggrValue<SimpleMatrixValue>>newInstance(new SimpleMatrixValue(PrimitiveClassReference.DOUBLE)),
            new SimpleMatrixValueFactory());
       System.out.println(analysis);
       //System.out.println(analysis.getPrettyPrinted());
       //print code
       for (int i = 0; i < analysis.getNodeList().size(); i++){
       	System.out.println(analysis.getNodeList().get(i).getAnalysis().getTree().getPrettyPrinted());        	
       }
       System.out.println("**********************************************************************");
       for (int i = 0; i < analysis.getNodeList().size(); i++){
       	System.out.println(ValueAnalysisPrinter.prettyPrint(
       			analysis.getNodeList().get(i).getAnalysis()));        	
       }

       
       //System.out.println(ValueAnalysisPrinter.prettyPrint(analysis.getMainNode().getAnalysis()));
    //System.exit(0);
    } catch (StackOverflowError e){
        System.err.println("stackoverflow in "+functions.getMain().name);
        e.printStackTrace();
        System.exit(0);
    }
    System.out.println("=> finished "+functions.getMain().name);
    
    
    //FlowAnalysisTestTool test = new FlowAnalysisTestTool(classAnalysis);
    //System.out.println(test.run(true,true));
}
 
开发者ID:sshrdp,项目名称:mclab,代码行数:50,代码来源:Mc4.java

示例12: main

import natlab.options.Options; //导入依赖的package包/类
/**
 * the entry point coming from natlab.Main - uses the options object to select the proper behavior
 */
public static void main(Options options){
	//** parse args ********
	FileEnvironment fileEnvironment = new FileEnvironment(options); //get path/files
	boolean inline = options.inline(); //get inline
	boolean outputToFile = false; //output TODO

	//arguments - TODO for now just parse them as inputs
	String args = "double"; //start with the default
	if (options.arguments() != null && options.arguments().length() > 0){
		args = options.arguments();
	}
	CP classProp = ClassPropTool.parse(args);
	List<CP> classPropList = new LinkedList<CP>();
	if (classProp instanceof CPChain){
		classPropList = ((CPChain)classProp).asList();
	} else if (classProp instanceof CPBuiltin){
		classPropList.add(classProp);
	} else {
		throw new UnsupportedOperationException("Arguments have to be a list of builtin classes");
	}
	List<PrimitiveClassReference> inputClasses = new LinkedList<PrimitiveClassReference>();
	for (CP element : classPropList){
		if (element instanceof CPBuiltin){
			inputClasses.add(PrimitiveClassReference.valueOf(((CPBuiltin)element).toString().toUpperCase()));
		} else {
			throw new UnsupportedOperationException(
					"Arguments have to be list of builtin classes, received "+element);
		}
	}
	
	
	//** build callgraph *******		
	ArrayList<AggrValue<SimpleMatrixValue>> list = new ArrayList<AggrValue<SimpleMatrixValue>>(inputClasses.size());
	for (PrimitiveClassReference ref : inputClasses){
		list.add(new SimpleMatrixValue(ref));
	}
	
	
	Callgraph<SimpleMatrixValue> callgraph = new Callgraph<SimpleMatrixValue>(
			fileEnvironment,
			Args.<AggrValue<SimpleMatrixValue>>newInstance(list),
			new SimpleMatrixValueFactory());
	
	
	//** output info ***********
	System.out.println(callgraph.prettyPrint());
	
}
 
开发者ID:sshrdp,项目名称:mclab,代码行数:52,代码来源:TamerTool.java


注:本文中的natlab.options.Options类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。