compile_net.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. int compile_udp_poll(int retreg, Cell* args) {
  2. jit_prepare();
  3. jit_finishi(machine_poll_udp);
  4. jit_retval(retreg);
  5. return 1;
  6. }
  7. int compile_udp_send(int retreg, Cell* args) {
  8. jit_prepare();
  9. compile_arg(JIT_R0, car(args), TAG_ANY);
  10. jit_pushargr(JIT_R0);
  11. jit_finishi(machine_send_udp);
  12. jit_retval(retreg);
  13. return 1;
  14. }
  15. int compile_tcp_connect(int retreg, Cell* args) {
  16. // Cell* machine_connect_tcp(Cell* host_cell, Cell* port_cell, Cell* connected_fn_cell, Cell* data_fn_cell);
  17. compile_arg(JIT_R0, car(cdr(cdr(cdr(args)))), TAG_ANY);
  18. stack_push(JIT_R0, &stack_ptr);
  19. compile_arg(JIT_R0, car(cdr(cdr(args))), TAG_ANY);
  20. stack_push(JIT_R0, &stack_ptr);
  21. compile_arg(JIT_R0, car(cdr(args)), TAG_ANY);
  22. stack_push(JIT_R0, &stack_ptr);
  23. compile_arg(JIT_R0, car(args), TAG_ANY);
  24. jit_prepare();
  25. jit_pushargr(JIT_R0);
  26. stack_pop(JIT_R0, &stack_ptr);
  27. jit_pushargr(JIT_R0);
  28. stack_pop(JIT_R0, &stack_ptr);
  29. jit_pushargr(JIT_R0);
  30. stack_pop(JIT_R0, &stack_ptr);
  31. jit_pushargr(JIT_R0);
  32. jit_finishi(machine_connect_tcp);
  33. jit_retval(retreg);
  34. return 1;
  35. }
  36. int compile_tcp_bind(int retreg, Cell* args) {
  37. jit_prepare();
  38. compile_arg(JIT_R0, car(args), TAG_ANY);
  39. jit_pushargr(JIT_R0);
  40. compile_arg(JIT_R0, car(cdr(args)), TAG_ANY);
  41. jit_pushargr(JIT_R0);
  42. jit_finishi(machine_bind_tcp);
  43. jit_retval(retreg);
  44. return 1;
  45. }
  46. int compile_tcp_send(int retreg, Cell* args) {
  47. compile_arg(JIT_R0, car(args), TAG_ANY);
  48. jit_prepare();
  49. jit_pushargr(JIT_R0);
  50. jit_finishi(machine_send_tcp);
  51. jit_retval(retreg);
  52. return 1;
  53. }