Advertisement
Guest User

func_ptr_nim_to_c_2

a guest
Nov 13th, 2015
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 4.42 KB | None | 0 0
  1. /* Generated by Nim Compiler v0.12.1 */
  2. /*   (c) 2015 Andreas Rumpf */
  3. /* The generated code is subject to the original license. */
  4. /* Compiled for: Linux, amd64, gcc */
  5. /* Command for C compiler:
  6.    gcc -c  -w  -I/home/tchen2/.tools/bin/Nim/lib -I/home/tchen2/.tools/include/ -o /proj/hsi/tchen2/nim/nimcache/learn_uv2.o /proj/hsi/tchen2/nim/nimcache/learn_uv2.c */
  7. #define NIM_INTBITS 64
  8.  
  9. #include "nimbase.h"
  10. #include <stdio.h>
  11. #include "uv.h"
  12. #include <string.h>
  13. typedef struct TGenericSeq TGenericSeq;
  14. typedef struct NimStringDesc NimStringDesc;
  15. struct  TGenericSeq  {
  16. NI len;
  17. NI reserved;
  18. };
  19. struct  NimStringDesc  {
  20.   TGenericSeq Sup;
  21. NIM_CHAR data[SEQ_DECL_SIZE];
  22. };
  23. N_NIMCALL(void, waitforawhile_95072)(uv_idle_t* h);
  24. static N_INLINE(NI, addInt)(NI a, NI b);
  25. N_NOINLINE(void, raiseOverflow)(void);
  26. static N_INLINE(void, nimFrame)(TFrame* s);
  27. N_NOINLINE(void, stackoverflow_23601)(void);
  28. static N_INLINE(void, popFrame)(void);
  29. static N_INLINE(void, initStackBottomWith)(void* locals);
  30. N_NOINLINE(void, setStackBottom)(void* thestackbottom);
  31. NIM_EXTERNC N_NOINLINE(void, systemInit000)(void);
  32. NIM_EXTERNC N_NOINLINE(void, systemDatInit000)(void);
  33. NIM_EXTERNC N_NOINLINE(void, learn_uv2Init000)(void);
  34. NIM_EXTERNC N_NOINLINE(void, learn_uv2DatInit000)(void);
  35. STRING_LITERAL(TMP141, "done!", 5);
  36. NI counter_95075;
  37. extern NI counter_95075;
  38. extern TFrame* frameptr_20842;
  39. uv_idle_t idle_95086;
  40. uv_loop_t* ploop_95091;
  41. uv_idle_t* pidle_95099;
  42.  
  43. static N_INLINE(NI, addInt)(NI a, NI b) {
  44.     NI result;
  45. {   result = 0;
  46.     result = (NI)((NU64)(a) + (NU64)(b));
  47.     {
  48.         NIM_BOOL LOC3;
  49.         LOC3 = 0;
  50.         LOC3 = (((NI) 0) <= (NI)(result ^ a));
  51.         if (LOC3) goto LA4;
  52.         LOC3 = (((NI) 0) <= (NI)(result ^ b));
  53.         LA4: ;
  54.         if (!LOC3) goto LA5;
  55.         goto BeforeRet;
  56.     }
  57.     LA5: ;
  58.     raiseOverflow();
  59.     }BeforeRet: ;
  60.     return result;
  61. }
  62.  
  63. static N_INLINE(void, nimFrame)(TFrame* s) {
  64.     NI LOC1;
  65.     LOC1 = 0;
  66.     {
  67.         if (!(frameptr_20842 == NIM_NIL)) goto LA4;
  68.         LOC1 = ((NI) 0);
  69.     }
  70.     goto LA2;
  71.     LA4: ;
  72.     {
  73.         LOC1 = ((NI) ((NI16)((*frameptr_20842).calldepth + ((NI16) 1))));
  74.     }
  75.     LA2: ;
  76.     (*s).calldepth = ((NI16) (LOC1));
  77.     (*s).prev = frameptr_20842;
  78.     frameptr_20842 = s;
  79.     {
  80.         if (!((*s).calldepth == ((NI16) 2000))) goto LA9;
  81.         stackoverflow_23601();
  82.     }
  83.     LA9: ;
  84. }
  85.  
  86. static N_INLINE(void, popFrame)(void) {
  87.     frameptr_20842 = (*frameptr_20842).prev;
  88. }
  89.  
  90. N_NIMCALL(void, waitforawhile_95072)(uv_idle_t* h) {
  91.     NI TMP140;
  92.     nimfr("wait_for_a_while", "learn_uv2.nim")
  93.     nimln(23, "learn_uv2.nim");
  94.     TMP140 = addInt(counter_95075, ((NI) 1));
  95.     counter_95075 = (NI)(TMP140);
  96.     nimln(24, "learn_uv2.nim");
  97.     {
  98.         NI LOC5;
  99.         nimln(353, "system.nim");
  100.         if (!(((NI) 10000) <= counter_95075)) goto LA3;
  101.         nimln(25, "learn_uv2.nim");
  102.         printf("%s\012", ((NimStringDesc*) &TMP141)? (((NimStringDesc*) &TMP141))->data:"nil");
  103.         nimln(26, "learn_uv2.nim");
  104.         LOC5 = 0;
  105.         LOC5 = uv_idle_stop(h);
  106.     }
  107.     LA3: ;
  108.     popFrame();
  109. }
  110.  
  111. static N_INLINE(void, initStackBottomWith)(void* locals) {
  112.     setStackBottom(locals);
  113. }
  114. void PreMainInner() {
  115.     systemInit000();
  116.     learn_uv2DatInit000();
  117. }
  118.  
  119. void PreMain() {
  120.     void (*volatile inner)();
  121.     systemDatInit000();
  122.     inner = PreMainInner;
  123.     initStackBottomWith((void *)&inner);
  124.     (*inner)();
  125. }
  126.  
  127. int cmdCount;
  128. char** cmdLine;
  129. char** gEnv;
  130. N_CDECL(void, NimMainInner)(void) {
  131.     learn_uv2Init000();
  132. }
  133.  
  134. N_CDECL(void, NimMain)(void) {
  135.     void (*volatile inner)();
  136.     PreMain();
  137.     inner = NimMainInner;
  138.     initStackBottomWith((void *)&inner);
  139.     (*inner)();
  140. }
  141.  
  142. int main(int argc, char** args, char** env) {
  143.     cmdLine = args;
  144.     cmdCount = argc;
  145.     gEnv = env;
  146.     NimMain();
  147.     return nim_program_result;
  148. }
  149.  
  150. NIM_EXTERNC N_NOINLINE(void, learn_uv2Init000)(void) {
  151.     NI LOC1;
  152.     uv_idle_cb LOC2;
  153.     NI LOC3;
  154.     NI LOC4;
  155.     nimfr("learn_uv2", "learn_uv2.nim")
  156.     nimln(22, "learn_uv2.nim");
  157.     counter_95075 = ((NI) 0);
  158.     nimln(30, "learn_uv2.nim");
  159.     ploop_95091 = uv_default_loop();
  160.     nimln(31, "learn_uv2.nim");
  161.     pidle_95099 = (&idle_95086);
  162.     nimln(33, "learn_uv2.nim");
  163.     LOC1 = 0;
  164.     LOC1 = uv_idle_init(ploop_95091, pidle_95099);
  165.     nimln(34, "learn_uv2.nim");
  166.     memset((void*)(&LOC2), 0, sizeof(LOC2));
  167.     LOC2.ClPrc = ((TMP142) (waitforawhile_95072)); LOC2.ClEnv = NIM_NIL;
  168.     LOC3 = 0;
  169.     LOC3 = uv_idle_start(pidle_95099, LOC2);
  170.     nimln(35, "learn_uv2.nim");
  171.     LOC4 = 0;
  172.     LOC4 = uv_run(ploop_95091, ((NI32) 0));
  173.     nimln(36, "learn_uv2.nim");
  174.     uv_loop_close(ploop_95091);
  175.     popFrame();
  176. }
  177.  
  178. NIM_EXTERNC N_NOINLINE(void, learn_uv2DatInit000)(void) {
  179. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement