Esempio n. 1
0
	public static void main(String[] args) throws IOException {
		boolean ret = true;
		String[] leftedArgs = ginit(args);
		if(leftedArgs.length > 1) System.exit(1);
		else if(leftedArgs.length == 0) interactiveFlag = true;
		
		if(builtinTest != null) {
			System.exit(builtinTest(builtinTest));
		}
		if(testScript != null) {
			System.exit(test(testScript));
		}
		CTX konoha = open();
		if(startupScript != null) {
			startup(konoha, startupScript);
		}
		if(leftedArgs.length == 1) {
			ret = load(konoha, leftedArgs[0]);
		}
		if(ret && (interactiveFlag != false)) {    // TODO interactiveFlag to boolean?
			ret = kShell(konoha);
		}
		close(konoha);
		// MODGC_check_malloced_size()
		System.exit(ret ? assertResult : 1);
	}
Esempio n. 2
0
	public static String[] ginit(String[] args) {
		if (System.getenv("KONOHA_DEBUG") != null) {
			verboseDebug = true;
			verboseGc = true;
			verboseSugar = true;
			verboseCode = true;
		}
		
		CommandLineParser parser = new BasicParser();
		CommandLine commandLine = null;
		try {
			commandLine = parser.parse(longOptions, args);
		} catch (ParseException e) {
			// TODO
		}
		
		if(commandLine.hasOption("verbose")) {
			verboseDebug = true;
			System.out.println("option vervose");
		}
		if(commandLine.hasOption("verbose:gc")) {
			verboseGc = true;
			System.out.println("option vervose:gc");
		}
		if(commandLine.hasOption("verbose:sugar")) {
			verboseSugar = true;
			System.out.println("option vervose:sugar");
		}
		if(commandLine.hasOption("verbose:code")) {
			verboseCode = true;
			System.out.println("option vervose:code");
		}
		if(commandLine.hasOption("interactive")) {
			interactiveFlag = true;
			System.out.println("option interactive");
		}
		if(commandLine.hasOption("typecheck")) {
			compileonlyFlag = true;
			System.out.println("option typecheck");
		}
		if(commandLine.hasOption("start-with")) {
			startupScript = commandLine.getOptionValue("start-with");
			System.out.println("option start-with");
			System.out.println(" with arg " + startupScript);
		}
		if(commandLine.hasOption("test")) {
			testScript = commandLine.getOptionValue("test");
			System.out.println(" with arg " + testScript);
		}
		if(commandLine.hasOption("test-with")) {
			testScript = commandLine.getOptionValue("test");
			System.out.println(" with arg " + testScript);
		}
		if(commandLine.hasOption("builtin-test")) {
			builtinTest = commandLine.getOptionValue("builtin-test");
			System.out.println(" with arg " + builtinTest);
		}
		return commandLine.getArgs();
	}
Esempio n. 3
0
	public static void startup(CTX konoha, String startup_script) {
		String[] buf = new String[256];
		String path = System.getenv("KONOHA_SCRIPTPATH");
		String local = "";
		if (path == null) {
			path = System.getenv("KONOHA_HOME");
			local = "/script";
		}	
		if (path == null) {
			path = System.getenv("HOME");
			local = "/.konoha/script";
		}
		//TODO snprintf(buf, sizeof(buf), "%s%s%s.k", path, local, startup_script);
		if (true /*TODO load(konoha, (const char*)buf)*/ ) {
			System.exit(1);
		}
	}