A winter times adventure into compilers.
go get github.com/mewmew/skumgummitomte/cmd/sgt
Compile and run examples/hello/hello.go.
$ sgt -o hello.ll examples/hello/hello.go
$ llvm-link -S -o main.ll hello.ll std/builtin.ll
$ lli main.ll
# Output:
#
# hello world
Compile and run examples/locals/main.go.
$ sgt -o locals.ll examples/locals/main.go
$ lli locals.ll ; echo $?
# Output:
#
# 42
Compile and run examples/closures/closures.go.
$ sgt -o closures.ll examples/closures/closures.go
$ llvm-link -S -o main.ll closures.ll std/builtin.ll
$ lli main.ll
# Output:
#
# lol
Compile examples/types/types.go.
$ sgt -o types.ll examples/types/types.go
Compile and run examples/methods/methods.go.
$ sgt -o methods.ll examples/methods/methods.go
$ llvm-link -S -o main.ll methods.ll std/builtin.ll
$ lli main.ll
# Output:
#
# T.M1
# T.M2
Compile and run main
program examples/imports/cmd/foo importing Go package examples/imports/p.
$ sgt -o foo.ll ./examples/imports/cmd/foo
$ sgt -o p.ll ./examples/imports/p
$ llvm-link -S -o main.ll foo.ll p.ll std/builtin.ll
$ lli main.ll
# Output:
#
# p.Foo
Compile and run main
program examples/consts/cmd/foo importing Go package examples/consts/p.
$ sgt -o foo.ll ./examples/consts/cmd/foo
$ sgt -o p.ll ./examples/consts/p
$ llvm-link -S -o main.ll foo.ll p.ll std/builtin.ll
$ lli main.ll
# Output:
#
# test
Compile and run main
program examples/multiple_results.
$ sgt -o multiple_results.ll ./examples/multiple_results
$ llvm-link -S -o main.ll multiple_results.ll std/builtin.ll
$ lli main.ll
# Output:
#
# bar
# foo
Compile and run main
program examples/slices.
$ sgt -o slices.ll ./examples/slices
$ llvm-link -S -o main.ll slices.ll std/builtin.ll
$ lli main.ll
# Output:
#
# qux
# baz
# bar
# foo
Compile and run examples/length/main.go.
$ sgt -o length.ll examples/length/main.go
$ lli length.ll ; echo $?
# Output:
#
# 42
Compile and run examples/string_compare/main.go.
$ sgt -o string_compare.ll examples/string_compare/main.go
$ llvm-link -S -o main.ll string_compare.ll std/builtin.ll
$ lli main.ll
# Output:
#
# x:
# foo
# y:
# foo
# x less than or equal to y
# x greater than or equal to y
# x equal to y
#
# x:
# abc
# y:
# def
# x less than y
# x less than or equal to y
# x not equal to y
#
# x:
# abc
# y:
# abcd
# x less than y
# x less than or equal to y
# x not equal to y
#
# x:
# abcd
# y:
# abc
# x greater than y
# x greater than or equal to y
# x not equal to y
#
# x:
# abx
# y:
# abc
# x greater than y
# x greater than or equal to y
# x not equal to y