Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

186 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Wroom 🚗💨

It has absolutly nothing to do with cars or wind's and it's also not fast actually it's a blessing that the compiler even compiles. Inspired by Buzz

⚠️Important⚠️

In favor of a better and more stable IR I decided to put this project on ice until I built a more stable and better IR. After that the IR system will be completely rewritten.

Next Steps

  • Add alignment to IR
  • Split globals and global constants in module
  • Prevent values and enforce types for extern variables
  • Remove global from IRValue
  • Better error messages please
  • Create snippets for error => string formating is ****
  • Bug: You can create void variables implicitly through a function which returns void
  • Constants
  • Different linkages
  • Separate Variable and Function checks from type inference
  • Check if function returns if not void
  • Complain when function return value is not used
  • Remove unnecessary external enum for expressions
  • Add function call as Statement
  • Check function call fits signature
  • SSA not correctly implemented => optimization required
  • Using function parameters results in segmentation fault
  • Leaving the ending brace of a function results in memory leaks and multiple parser errors
  • X-Assigns result in weird IR and memory leak
  • Errors for IRGen
  • Add function body
  • Create Statment tagged union
  • Parse parameters
  • Add void type
  • Add checking for void type
  • [~] Variable shadowing => Implicitly works didn't specifically implement it
  • Return statement
  • Assign to already declared variable
  • Illegal assignment on undeclared variable
  • Fix case where position is 0 because body is empty
  • Costexpr doesn't really allow implicit floats anymore => is actually expected behaviour
  • Fix constant expr on division =>
2 * 5 + 2 * 3 / 2 = 12

truncation happens too early
actual result: 13

DO NOT

  • Binary expressions in global scope with different types. IT WILL TRIGGER THE INCORRECT MATH GODS Fixed somewhat but I wouldn't trust my self with this.

SSA

Simple expressions

Wroom:

let glbl = 123
func main(argc: int) int {
    let locl = 123 * 2 + 1 * glbl
    return locl
}

IR:

@glbl i32 = #123
@main(i32 argc) -> i32 {
entry:
        %0 = alloca i32
        %1 = mul i32 #123, #2
        %2 = load i32, @glbl
        %3 = mul i32 #1, %2
        %4 = add i32 %1, %3
        store i32 %0, %4
        %5 = load i32, %0
        return %5
}

Function calls

Wroom:

func multiply(a: int) int {
    return 2 * a
}

func main() int {
    let wtf = multiply(69420)
    return wtf
}

IR:

@multiply(a i32) -> i32 {
entry:
        %0 = load i32, @a
        %1 = mul i32 #2, %0
        return %1
}
@main() -> i32 {
entry:
        %0 = alloca i32
        %1 = call @multiply(#69420)
        store i32 %0, %1
        %2 = load i32, %0
        return %2
}

About

A programming language... yesss I know... But tbh atleast I'm not questioning my life choices with Zig

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages