Posted to tcl by gps at Mon Mar 02 01:32:51 GMT 2009view raw

  1. struct box {int x; int y; int width; int height};
  2.  
  3. procedure new_box {declare int x; declare int y; declare int width; declare int height} {
  4. declare struct box b;
  5. declare int s;
  6.  
  7. typesize s box;
  8.  
  9. rcall b allocate s;
  10.  
  11. call print_pointer b;
  12.  
  13. -> b.x x;
  14. -> b.y y;
  15. -> b.width width;
  16. -> b.height height;
  17.  
  18. result b;
  19. } {declare struct box};
  20.  
  21. procedure move_box {declare struct box b; declare int x; declare int y} {
  22. declare int var;
  23.  
  24. -> b.x x;
  25. -> b.y y;
  26.  
  27. result b;
  28. } {declare struct box};
  29.  
  30. #I don't have strings yet, so this is what is what the runtime calls so far:
  31. procedure startup {declare int argc;} {
  32. declare struct box b;
  33.  
  34. rcall b new_box 0 0 400 400;
  35. call print_pointer b;
  36. call move_box b 20 20;
  37.  
  38. call say_hello;
  39.  
  40. call print_pointer b;
  41.  
  42. call print_integer b.x;
  43.  
  44. result 0;
  45. } {declare int};
  46.