Skip to main content

CompilerConfig

Struct CompilerConfig 

Source
pub struct CompilerConfig {
    pub java_version: u32,
    pub output_dir: String,
    pub classpath: Vec<String>,
    pub source_files: Vec<String>,
    pub incremental: bool,
}

Fields§

§java_version: u32§output_dir: String§classpath: Vec<String>§source_files: Vec<String>§incremental: bool

Implementations§

Source§

impl CompilerConfig

Source

pub fn new() -> Self

Examples found in repository?
examples/compiler-example.rs (line 46)
3fn main() {
4    let args: Vec<String> = std::env::args().skip(1).collect();
5    if args.is_empty() {
6        print_usage();
7        std::process::exit(2);
8    }
9
10    let mut output_dir = "target/compiler-example".to_string();
11    let mut classpath: Vec<String> = Vec::new();
12    let mut sources: Vec<String> = Vec::new();
13    let mut i = 0;
14    while i < args.len() {
15        match args[i].as_str() {
16            "--output-dir" | "-o" => {
17                i += 1;
18                if i >= args.len() {
19                    eprintln!("error: --output-dir requires a value");
20                    std::process::exit(2);
21                }
22                output_dir = args[i].clone();
23                i += 1;
24            }
25            "--class-path" | "--classpath" | "-classpath" | "-cp" => {
26                i += 1;
27                if i >= args.len() {
28                    eprintln!("error: {} requires a value", args[i - 1]);
29                    std::process::exit(2);
30                }
31                classpath.push(args[i].clone());
32                i += 1;
33            }
34            arg => {
35                sources.push(arg.to_string());
36                i += 1;
37            }
38        }
39    }
40
41    if sources.is_empty() {
42        print_usage();
43        std::process::exit(2);
44    }
45
46    let mut config = CompilerConfig::new();
47    config.output_dir = output_dir;
48    config.classpath = classpath;
49    config.source_files = sources;
50
51    if let Err(errors) = compile(config) {
52        for error in errors {
53            eprintln!("{error}");
54        }
55        std::process::exit(1);
56    }
57}

Trait Implementations§

Source§

impl Default for CompilerConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.