Skip to content

Commit

Permalink
Fix some Errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Willyboar committed May 16, 2023
1 parent db9d365 commit 77288b8
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions src/glove.gleam
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import gleam/int
import gleam/option.{Option}

// QBE Comparison Operators
pub type Comp {
Expand All @@ -16,10 +17,6 @@ pub type Comp {
Ne
}

pub type Option {
Option(Value)
}

// QBE instruction
pub type Inst {
// Adds values
Expand All @@ -41,7 +38,7 @@ pub type Inst {
// Copies either temporary or literal value
Copy(Value)
// Return from a function, optionally with a value
Ret(Option)
Ret(Option(Value))
// Jumps to first label if a value is nonzero or to the second one otherwise
Jnz(Value, String, String)
// Unconditionally jumps to a label
Expand Down Expand Up @@ -104,10 +101,11 @@ pub type Type {
// Extended Types
Byte
Halfword
// Agreegate type with a specified name
Agreegate(TypeDef)
}

// Agreegate type with a specified name
// Agreegate(TypeDef)

// Display Type function
pub fn display_type(ty: Type) -> String {
case ty {
Expand All @@ -117,8 +115,8 @@ pub fn display_type(ty: Type) -> String {
Long -> "l"
Single -> "s"
Double -> "d"
Agreegate(TypeDef) -> display_type_def(TypeDef)
}
//Agreegate(TypeDef) -> display_type_def(TypeDef)
}

// Returns a C ABI type. Extended types are converted to closest base
Expand Down Expand Up @@ -153,7 +151,7 @@ pub fn display_datadef() -> String {

// QBE aggregate type definition
pub type TypeDef {
TypeDef(name: String, align: Option, items: #(Type, Int))
TypeDef(name: String, align: Option(Int), items: #(Type, Int))
}

// Display function for TypeDef
Expand Down Expand Up @@ -218,7 +216,7 @@ pub type Function {
linkage: Linkage,
name: String,
arguments: #(Type, Value),
return_ty: Option(Type),
return_ty: Type,
blocks: #(Block),
)
}
Expand Down Expand Up @@ -276,9 +274,9 @@ pub type Module {
}

// Creates a new module
pub fn new_module() -> Module {
Module(functions: #(), types: #(), data: #())
}
//pub fn new_module() -> Module {
// Module(functions: #(), types: #(), data: #())
//}

// Display function for Module
pub fn display_module(module: Module) -> String {
Expand Down

0 comments on commit 77288b8

Please sign in to comment.