Skip to content

Commit 6372264

Browse files
authored
Merge pull request #127 from LuoZijun/patch-3
add debug for module
2 parents 4b57df4 + 9a2fcd8 commit 6372264

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

ratel-wasm/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ crate-type = ["cdylib"]
1010
serde_json = "1.0"
1111
ratel = { path = "../ratel", version = "0.8.0" }
1212
ratel-codegen = { path = "../ratel-codegen", version = "0.8.0" }
13-
wasm-bindgen = "0.2.29"
13+
wasm-bindgen = "0.2.36"

ratel/src/ast/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ impl<T> Deref for Loc<T> {
8080
}
8181
}
8282

83+
#[derive(Debug, Clone)]
8384
pub struct Program<'ast> {
8485
pub source: &'ast str,
8586
pub body: NodeList<'ast, Statement<'ast>>,

ratel/src/module.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
use toolshed::list::UnsafeList;
22
use toolshed::Arena;
33
use ast::StatementList;
4+
5+
use std::fmt;
46
use std::marker::PhantomData;
57

8+
69
/// A JavaScript module parsed to an AST.
710
pub struct Module<'ast> {
811
body: UnsafeList,
@@ -32,3 +35,13 @@ impl<'ast> Module<'ast> {
3235
&self.arena
3336
}
3437
}
38+
39+
impl<'ast> fmt::Debug for Module<'ast> {
40+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
41+
write!(f, "Module:").unwrap();
42+
for elem in self.body().iter() {
43+
write!(f, "\n\t{:?}", elem).unwrap()
44+
}
45+
Ok(())
46+
}
47+
}

0 commit comments

Comments
 (0)