blob: 9bb4e4f65ed8bf74e93854109a47c0312ff98405 [file] [log] [blame]
// Copyright 2018 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use {crate::ast::BanjoAst, crate::backends::Backend, failure::Error, std::io};
pub struct AstBackend<'a, W: io::Write> {
w: &'a mut W,
}
impl<'a, W: io::Write> AstBackend<'a, W> {
pub fn new(w: &'a mut W) -> Self {
AstBackend { w }
}
}
impl<'a, W: io::Write> Backend<'a, W> for AstBackend<'a, W> {
fn codegen(&mut self, ast: BanjoAst) -> Result<(), Error> {
self.w.write_fmt(format_args!("{:#?}\n", ast))?;
Ok(())
}
}