diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2012-07-11 15:00:40 -0700 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2012-07-17 15:46:43 -0700 |
| commit | db020ab63cd51dd4a25cba2d00117f016128762b (patch) | |
| tree | 2b6f1e99ba4356f3e3bf5338332c278d2a85109b /src/libsyntax/print/pp.rs | |
| parent | b5729bd60095fb5ca884936775e031cf19900760 (diff) | |
| download | rust-db020ab63cd51dd4a25cba2d00117f016128762b.tar.gz rust-db020ab63cd51dd4a25cba2d00117f016128762b.zip | |
rustc: Implement and enforce instance coherence
Diffstat (limited to 'src/libsyntax/print/pp.rs')
| -rw-r--r-- | src/libsyntax/print/pp.rs | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/src/libsyntax/print/pp.rs b/src/libsyntax/print/pp.rs index 1a318d53635..79679279f07 100644 --- a/src/libsyntax/print/pp.rs +++ b/src/libsyntax/print/pp.rs @@ -103,22 +103,22 @@ fn mk_printer(out: io::writer, linewidth: uint) -> printer { let token: ~[mut token] = vec::to_mut(vec::from_elem(n, EOF)); let size: ~[mut int] = vec::to_mut(vec::from_elem(n, 0)); let scan_stack: ~[mut uint] = vec::to_mut(vec::from_elem(n, 0u)); - @{out: out, - buf_len: n, - mut margin: linewidth as int, - mut space: linewidth as int, - mut left: 0u, - mut right: 0u, - token: token, - size: size, - mut left_total: 0, - mut right_total: 0, - mut scan_stack: scan_stack, - mut scan_stack_empty: true, - mut top: 0u, - mut bottom: 0u, - print_stack: dvec(), - mut pending_indentation: 0} + printer_(@{out: out, + buf_len: n, + mut margin: linewidth as int, + mut space: linewidth as int, + mut left: 0u, + mut right: 0u, + token: token, + size: size, + mut left_total: 0, + mut right_total: 0, + mut scan_stack: scan_stack, + mut scan_stack_empty: true, + mut top: 0u, + mut bottom: 0u, + print_stack: dvec(), + mut pending_indentation: 0}) } @@ -199,7 +199,7 @@ fn mk_printer(out: io::writer, linewidth: uint) -> printer { * the method called 'pretty_print', and the 'PRINT' process is the method * called 'print'. */ -type printer = @{ +type printer_ = { out: io::writer, buf_len: uint, mut margin: int, // width of lines we're constrained to @@ -226,6 +226,10 @@ type printer = @{ mut pending_indentation: int }; +enum printer { + printer_(@printer_) +} + impl printer for printer { fn last_token() -> token { self.token[self.right] } // be very careful with this! |
