Created
September 3, 2011 13:34
-
-
Save alexnask/1191189 to your computer and use it in GitHub Desktop.
Kew
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use tcc | |
| import tcc | |
| program := "int function(int n) \ | |
| {\ | |
| printf(\"Hello World! (%d)\\n\",n);\ | |
| doStuff(42); | |
| return 0;\ | |
| }" | |
| tcc := Tcc new() | |
| f: func(a: Int) { a toString() println() } | |
| tcc addSymbol("doStuff",f as Pointer) | |
| tcc setOutputType(OutputType memory) | |
| tcc compileString(program) | |
| size := tcc relocate(null) | |
| mem := gc_malloc(size) | |
| tcc relocate(mem) | |
| entry: Func(Int)->Int | |
| entry as Closure thunk = tcc getSymbol("function") | |
| tcc delete() | |
| entry(42) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment