Libtcc and gwan

1,378 views

Published on

Published in: Education, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,378
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Libtcc and gwan

  1. 1. libtcc AND GWAN charsyam@naver.com
  2. 2. Language Java JavaScript C Scala
  3. 3. Platform Node.js Django Play
  4. 4. Tcc: Tiny C Compiler 1. C Script Support
  5. 5. C Script #! /usr/bin/tcc -run int main() { printf("Hello Worldn"); return 0; }
  6. 6. Tcc: Tiny C Compiler 2. Dynamic Code Generation
  7. 7. Code Generation int add(int a, int b) { return a + b; } char my_program[] = "int foo(int n)n" "{n" " printf("Hello World!n");n" " printf("fib(%d) = %dn", n, fib(n));n" " printf("add(%d, %d) = %dn", n, 2 * n, add(n, 2 * n));n" " return 0;n" "}n";
  8. 8. Code GenerationTCCState *s;s = tcc_new();tcc_set_output_type(s, TCC_OUTPUT_MEMORY);if (tcc_compile_string(s, my_program) == -1) return 1;tcc_add_symbol(s, "add", add);size = tcc_relocate(s, NULL);if (size == -1) return 1;mem = malloc(size);tcc_relocate(s, mem);func = tcc_get_symbol(s, "foo");if (!func) return 1;tcc_delete(s);func(32);free(mem);
  9. 9. Code Generationcharsyam@charsyam-lv63:~/repo/libtcc$ ./a.outHello World!fib(32) = 2178309add(32, 64) = 96
  10. 10. GWanWeb Application Server
  11. 11. GWanSupport Scripting C Java Object C
  12. 12. GWanwget http://gwan.com/archives/gwan_linux64-bit.tar.bz2tar -xjf gwan_linux64-bit.tar.bz2cd gwan_linux64-bitsudo ./gwan (./gwan -h for help)Need javac, gobjc, gobjc++
  13. 13. GWancharsyam@ubuntu:~/apps/gwan/0.0.0.0_8080/#0.0.0.0/csp/folder$실제 핸들러 위치
  14. 14. Thank You!

×