add gi_c, a minimal C go interpreter POC

This commit is contained in:
Marc Vertes
2018-01-15 23:18:24 +01:00
parent e5d4beaa87
commit 9f5514dd38
5 changed files with 54 additions and 0 deletions

10
.gitignore vendored Normal file
View File

@@ -0,0 +1,10 @@
.*.swp
gi_c/*.o
gi_c/gi
gi_c/loop2
gi_c/l2
gi_c/deps/lightning-*
gi_c/deps/lib
gi_c/deps/include
gi_c/deps/share
gi_c/deps/*.gz

23
gi_c/README.md Normal file
View File

@@ -0,0 +1,23 @@
# gi_c
Proof of concept for a go interpreter, using previous private works
# Install
dependencies: graphviz for AST / CFG visualization
```
make
make test
```
# Notes
Language scope is very limited, just enough to run the demo script `loop2.go`. Interesting enough to get an idea of performances compared with binaries, with or without JIT compilation.
the machine code generator is using GNU-lightning (installed with `make deps`).
Do not expect many improvements here, the real work will take place in Go, and will try to reuse as much as possible existing Go assets.
--
Marc

9
gi_c/l2.go Normal file
View File

@@ -0,0 +1,9 @@
package main
func main() {
for a := 0; a < 20000; a++ {
if (a & 0x8ff) == 0x800 {
println(a)
}
}
}

9
gi_c/loop2.go Normal file
View File

@@ -0,0 +1,9 @@
package main
func main() {
for a := 0; a < 2000000000; a++ {
if (a & 0x8ffff) == 0x80000 {
println(a)
}
}
}

3
gi_c/t1.go Normal file
View File

@@ -0,0 +1,3 @@
a = 1
a++
b--