WARNING! Access to this system is limited to authorised users only.
Unauthorised users may be subject to prosecution.
Unauthorised access to this system is a criminal offence under Australian law (Federal Crimes Act 1914 Part VIA)
It is a criminal offence to:
(1) Obtain access to data without authority. -Penalty 2 years imprisonment.
(2) Damage, delete, alter or insert data without authority. -Penalty 10 years imprisonment.
User activity is monitored and recorded. Anyone using this system expressly consents to such monitoring and recording.

To protect your data, the CISO officer has suggested users to enable 2FA as soon as possible.
Currently 2.6% of users enabled 2FA.

vm_options.rs 1.71 KB
Newer Older
qinsoon's avatar
qinsoon committed
1 2 3 4 5
extern crate rustc_serialize;
extern crate docopt;

use self::docopt::Docopt;

qinsoon's avatar
qinsoon committed
6 7
use std::default::Default;

qinsoon's avatar
qinsoon committed
8 9 10 11 12 13 14 15 16
const USAGE: &'static str = "
zebu (mu implementation). Pass arguments as a strings to init it.

Usage:
  init_mu [options]

VM:
  --log-level=<level>               logging level: none, error, warn, info, debug, trace [default: trace]

17 18 19 20
Compiler:
  --allow-inline=<flag>             allow compiler inlining functions on its decision [default: true]

AOT Compiler:
qinsoon's avatar
qinsoon committed
21 22 23 24 25 26 27 28 29
  --aot-emit-dir=<dir>              the emit directory for ahead-of-time compiling [default: emit]

Garbage Collection:
  --gc-immixspace-size=<kb>         immix space size (default 65536kb = 64mb) [default: 65536]
  --gc-lospace-size=<kb>            large object space size (default 65536kb = 64mb) [default: 65536]
  --gc-nthreads=<n>                 number of threads for parallel gc [default: 8]
";

#[derive(Debug, RustcDecodable, RustcEncodable)]
qinsoon's avatar
qinsoon committed
30
pub struct VMOptions {
qinsoon's avatar
qinsoon committed
31
    pub flag_log_level: MuLogLevel,
32
    pub flag_allow_inline: bool,
qinsoon's avatar
qinsoon committed
33 34 35 36
    pub flag_aot_emit_dir: String,
    pub flag_gc_immixspace_size: usize,
    pub flag_gc_lospace_size: usize,
    pub flag_gc_nthreads: usize
qinsoon's avatar
qinsoon committed
37 38
}

qinsoon's avatar
qinsoon committed
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
#[derive(Debug, Clone, Copy, RustcDecodable, RustcEncodable)]
pub enum MuLogLevel {
    None, Error, Warn, Info, Debug, Trace
}

impl VMOptions {
    pub fn init(str: &str) -> VMOptions {
        println!("init vm options with: {:?}", str);

        let ret : VMOptions = Docopt::new(USAGE)
            .and_then(|d| d.argv(str.split_whitespace().into_iter()).parse())
            .unwrap_or_else(|e| e.exit()).decode().unwrap();

        println!("parsed as {:?}", ret);

        ret
    }
}
qinsoon's avatar
qinsoon committed
57 58 59

impl Default for VMOptions {
    fn default() -> VMOptions {
qinsoon's avatar
qinsoon committed
60
        VMOptions::init("")
qinsoon's avatar
qinsoon committed
61
    }
qinsoon's avatar
qinsoon committed
62
}