Skip to content

Commit

Permalink
Fix output code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Willyboar committed May 31, 2023
1 parent b661c33 commit e4c8126
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ QBE Backend can be found [here](https://c9x.me/compile/)

You can find a working example [here](https://github.com/Willyboar/glove_example)

QBE IL Documentation can be found [here](https://c9x.me/compile/doc/il.html)

## Run the tests
```sh
gleam test # Run the tests
Expand Down
3 changes: 2 additions & 1 deletion gleam.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
name = "glove"
version = "0.1.0"
version = "0.2.0"
description = "Gleam QBE IR Generator"
licences = ["MIT"]
repository = { type = "github", user = "Willyboar", repo = "glove" }

[dependencies]
gleam_stdlib = "~> 0.29"
Expand Down
8 changes: 4 additions & 4 deletions src/glove.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -520,19 +520,19 @@ pub fn display_module(module: Module) -> String {
let functions_str =
module.functions
|> list.map(display_function)
|> string.join("\n\n")
|> string.join("\n")

let types_str =
module.types
|> list.map(display_type_def)
|> string.join("\n\n")
|> string.join("\n")

let data_str =
module.data
|> list.map(display_data_def)
|> string.join("\n\n")
|> string.join("\n")

functions_str <> "\n\n" <> types_str <> "\n\n" <> data_str
functions_str <> types_str <> "\n" <> data_str
}

/// Add function to module
Expand Down
4 changes: 2 additions & 2 deletions test/glove_test.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ pub fn display_module_test() {
let empty_module = glove.Module(functions: [], types: [], data: [])
empty_module
|> glove.display_module
|> should.equal("\n\n\n\n")
|> should.equal("\n")

// Test case with functions, types, and data
let add_func =
Expand Down Expand Up @@ -620,7 +620,7 @@ pub fn display_module_test() {
module
|> glove.display_module
|> should.equal(
"function w $add(w %a, w %b) {\n" <> "@start\n" <> "%c =w add %a, %b\n" <> "ret %c\n}\n\n" <> "export function w $main() {\n" <> "@start\n" <> "%r =w call $add(w 1, w 1)\n" <> "call $printf(l $fmt, w %r)\n" <> "ret 0\n}\n\n\n\n" <> "data $fmt = " <> "{ b \"One and one make %d!\n\", b 0 }",
"function w $add(w %a, w %b) {\n" <> "@start\n" <> "%c =w add %a, %b\n" <> "ret %c\n}\n" <> "export function w $main() {\n" <> "@start\n" <> "%r =w call $add(w 1, w 1)\n" <> "call $printf(l $fmt, w %r)\n" <> "ret 0\n}\n" <> "data $fmt = " <> "{ b \"One and one make %d!\n\", b 0 }",
)
}

Expand Down

0 comments on commit e4c8126

Please sign in to comment.