Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove getter and setter methods from TransformOptions #50

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions arnoldc/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,10 @@ mod tests {
let passes = Passes::from_convert_vec(args.clone());
let mut options = TransformOptions::from_passes(passes.clone());
if args.contains(&"--print-ir-before-all") {
options.set_print_ir_before_all(true);
options.print_ir_before_all = true;
}
if let Some(out) = out {
options.set_writer(out);
options.writer = out;
}
let result = parse_and_transform(input_text, &options)?;
Ok(result)
Expand Down
15 changes: 3 additions & 12 deletions xrcf/src/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ pub struct TransformOptions {
/// would be useful. `print-ir-before-all` is useful to see the IR after
/// parsing, but seeing the IR after the last pass is already the final
/// output.
print_ir_before_all: bool,
writer: Shared<dyn std::io::Write + Send>,
pub print_ir_before_all: bool,
pub writer: Shared<dyn std::io::Write + Send>,
}

impl TransformOptions {
Expand All @@ -125,18 +125,9 @@ impl TransformOptions {
writer: Shared::new(std::io::stderr().into()),
}
}
pub fn print_ir_before_all(&self) -> bool {
self.print_ir_before_all
}
pub fn passes(&self) -> &Passes {
&self.passes
}
pub fn set_print_ir_before_all(&mut self, print_ir_before_all: bool) {
self.print_ir_before_all = print_ir_before_all;
}
pub fn set_writer(&mut self, writer: Shared<dyn std::io::Write + Send>) {
self.writer = writer;
}
}

/// Interface to add custom passes to the compiler.
Expand Down Expand Up @@ -225,7 +216,7 @@ pub fn transform<T: TransformDispatch>(
) -> Result<RewriteResult> {
let mut result = RewriteResult::Unchanged;
for pass in options.passes().vec() {
if options.print_ir_before_all() {
if options.print_ir_before_all {
let op = op.rd();
writeln!(
&mut *options.writer.wr(),
Expand Down
Loading