basic support for structures through the IR
This commit is contained in:
@@ -65,11 +65,7 @@ impl TopLevel {
|
||||
TopLevel::Structure(_, name, fields) => allocator
|
||||
.text("struct")
|
||||
.append(allocator.space())
|
||||
.append(
|
||||
name.as_ref()
|
||||
.map(|x| allocator.text(x.to_string()))
|
||||
.unwrap_or_else(|| allocator.nil()),
|
||||
)
|
||||
.append(allocator.text(name.to_string()))
|
||||
.append(allocator.space())
|
||||
.append(allocator.text("{"))
|
||||
.append(allocator.hardline())
|
||||
@@ -224,22 +220,13 @@ impl Type {
|
||||
pub fn pretty<'a>(&self, allocator: &'a Allocator<'a>) -> DocBuilder<'a, Allocator<'a>> {
|
||||
match self {
|
||||
Type::Named(x) => allocator.text(x.to_string()),
|
||||
Type::Struct(name, fields) => allocator
|
||||
Type::Struct(fields) => allocator
|
||||
.text("struct")
|
||||
.append(allocator.space())
|
||||
.append(
|
||||
name.as_ref()
|
||||
.map(|x| allocator.text(x.to_string()))
|
||||
.unwrap_or_else(|| allocator.nil()),
|
||||
)
|
||||
.append(allocator.intersperse(
|
||||
fields.iter().map(|(name, ty)| {
|
||||
allocator
|
||||
.text(
|
||||
name.as_ref()
|
||||
.map(|x| x.to_string())
|
||||
.unwrap_or_else(|| "_".to_string()),
|
||||
)
|
||||
.text(name.to_string())
|
||||
.append(allocator.text(":"))
|
||||
.append(allocator.space())
|
||||
.append(
|
||||
|
||||
Reference in New Issue
Block a user