Guest User

object_tuple_constructor

a guest
Oct 29th, 2013
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.27 KB | None | 0 0
  1. type Foo1 {.pure.} = object
  2.   x:int
  3.   y:int
  4.  
  5. type Foo2 = tuple [
  6.   x:int;
  7.   y:int;
  8. ]
  9.  
  10. proc newFoo1a(x:int, y:int): Foo1 =
  11.   result = Foo1(x:x, y:y)
  12.  
  13. proc newFoo1b(x:int, y:int): Foo1 =
  14.   result.x = x
  15.   result.y = y
  16.  
  17. proc newFoo2a(x:int, y:int): Foo2 =
  18.   result = (x:x, y:y)
  19.  
  20. proc newFoo2b(x:int, y:int): Foo2 =
  21.   result.x = x
  22.   result.y = y
  23.  
  24. # =====================================================
  25. # Generated code
  26.  
  27. struct foo131003 {
  28. NI X;
  29. NI Y;
  30. };
  31.  
  32. struct foo231008 {
  33. NI Field0;
  34. NI Field1;
  35. };
  36.  
  37. N_NIMCALL(foo131003, newfoo1a_31012)(NI x, NI y) {
  38.     foo131003 result;
  39.     foo131003 LOC1;
  40.     memset((void*)&result, 0, sizeof(result));
  41.     memset((void*)&LOC1, 0, sizeof(LOC1));
  42.     LOC1.X = x;
  43.     LOC1.Y = y;
  44.     result = LOC1;
  45.     return result;
  46. }
  47. N_NIMCALL(foo131003, newfoo1b_31020)(NI x, NI y) {
  48.     foo131003 result;
  49.     memset((void*)&result, 0, sizeof(result));
  50.     result.X = x;
  51.     result.Y = y;
  52.     return result;
  53. }
  54. N_NIMCALL(foo231008, newfoo2a_31027)(NI x, NI y) {
  55.     foo231008 result;
  56.     memset((void*)&result, 0, sizeof(result));
  57.     result.Field0 = x;
  58.     result.Field1 = y;
  59.     return result;
  60. }
  61. N_NIMCALL(foo231008, newfoo2b_31037)(NI x, NI y) {
  62.     foo231008 result;
  63.     memset((void*)&result, 0, sizeof(result));
  64.     result.Field0 = x;
  65.     result.Field1 = y;
  66.     return result;
  67. }
Advertisement
Add Comment
Please, Sign In to add comment