Skip to content

Commit

Permalink
progress - add more content and links to
Browse files Browse the repository at this point in the history
readme
  • Loading branch information
Willyboar committed May 26, 2023
1 parent 9cfd825 commit 9a39b93
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 4 deletions.
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@

<img src="https://github.com/Willyboar/glove/assets/22755228/bfd9673f-a105-4083-82d8-84bf4b0ff071">

## Don't Use it (WIP)
## Don't Use it yet (WIP)

[![Package Version](https://img.shields.io/hexpm/v/glove)](https://hex.pm/packages/glove)
[![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/glove/)


A Gleam library to generate QBE IR code
## About
Glove is a library for working with QBE intermediate representation (IR) in Gleam. Provides utilities and functions to generate QBE code using the Gleam programming language.

## Requirements

To use Glove, you need to have the following dependencies installed:

Gleam programming language - Install instructions can be found [here](https://gleam.run/getting-started/installing/)

QBE Backend can be found [here](https://c9x.me/compile/)


## Quick start
Expand Down
7 changes: 6 additions & 1 deletion src/glove.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,12 @@ pub fn size() -> Int {

/// QBE data definition
pub type DataDef {
DataDef(linkage: Linkage, name: String, align: Int, items: #(Type, DataItem))
DataDef(
linkage: Linkage,
name: String,
align: Int,
items: List(#(Type, DataItem)),
)
}

pub fn new_datadef() -> DataDef {
Expand Down
42 changes: 41 additions & 1 deletion test/glove_test.gleam
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import gleam/option.{None, Some}
import gleam/list
import gleeunit
import gleeunit/should
import glove
Expand Down Expand Up @@ -166,3 +165,44 @@ pub fn display_type_def_test() {
|> should.equal("type :struct = align 4 { w 2, w, w 3 }")
// Add more test cases as needed
}

// Tests for QBE.Types
pub fn display_type_test() {
// Test case 1: Base types
let result1 = glove.Word
result1
|> glove.display_type
|> should.equal("w")

let result2 = glove.Long
result2
|> glove.display_type
|> should.equal("l")

let result3 = glove.Single
result3
|> glove.display_type
|> should.equal("s")

let result4 = glove.Double
result4
|> glove.display_type
|> should.equal("d")

let result5 = glove.Byte
result5
|> glove.display_type
|> should.equal("b")

let result6 = glove.Halfword
result6
|> glove.display_type
|> should.equal("h")

// Test case 2: Extended types
let def1 = glove.TypeDef("myType", None, [#(glove.Word, 1)])
let result5 = glove.Agreegate(def1)
result5
|> glove.display_type
|> should.equal("type :myType = { w }")
}

0 comments on commit 9a39b93

Please sign in to comment.