summaryrefslogtreecommitdiff
path: root/test/unit.asm.js
blob: 53e6483ef410243df81319df6bc17739872cad09 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
function asm() {
  "use asm";

  var t = global.NaN, u = global.Infinity;
  var Int = 0;
  var Double = 0.0;
  var Math_fround = global.Math.fround;
  var Math_abs = global.Math.abs;
  var Math_ceil = global.Math.ceil;

  var abort = env.abort;

  function big_negative() {
    var temp = 0.0;
    temp = +-2147483648;
    temp = -2147483648.0;
    temp = -21474836480.0;
    temp = 0.039625;
    temp = -0.039625;
  }
  function importedDoubles() {
    var temp = 0.0;
    temp = t + u + (-u) + (-t);
    if (Int > 0) return -3.4;
    if (Double > 0.0) return 5.6;
    return 1.2;
  }
  function doubleCompares(x, y) {
    x = +x;
    y = +y;
    var t = +0;
    var Int = 0.0, Double = 0; // confusing with globals
    if (x > 0.0) return 1.2;
    if (Int > 0.0) return -3.4;
    if (Double > 0) return 5.6;
    if (x < y) return +x;
    return +y;
  }
  function intOps() {
    var x = 0;
    return !x;
  }
  function conversions() {
    var i = 0, d = 0.0, f = Math_fround(0);
    i = ~~d;
    i = ~~f;
    d = +(i | 0);
    d = +(i >>> 0);
  }
  function seq() {
    var J = 0.0;
    J = (0.1, 5.1) - (3.2, 4.2);
  }
  function switcher(x) {
    x = x | 0;
    switch (x | 0) {
      case 1: return 1;
      case 2: return 2;
    }
    switch (x | 0) {
      case 12: return 121;
      case 5: return 51;
    }
    Lout: switch (x | 0) {
      case 12: break;
      case 10: break Lout;
      case 5: {
        while (1) {
          break;
        }
        break;
      }
      case 2: {
        while (1) {
          break Lout;
        }
        break;
      }
    }
    return 0;
  }
  function blocker() {
    L: {
      break L;
    }
  }
  function frem() {
    return +(5.5 % 1.2);
  }
  function big_uint_div_u() {
    var x = 0;
    x = (4294967295 / 2)&-1;
    return x | 0;
  }
  function fr(x) {
    x = Math_fround(x);
    var y = Math_fround(0), z = 0.0;
    Math_fround(z);
    Math_fround(y);
    Math_fround(5);
    Math_fround(0);
    Math_fround(5.0);
    Math_fround(0.0);
  }
  function negZero() {
    return +-0;
  }
  function abs() {
    var x = 0, y = 0.0, z = Math_fround(0);
    x = Math_abs(0) | 0;
    y = +Math_abs(0.0);
    z = Math_fround(Math_abs(Math_fround(0)));
  }
  function neg() {
    var x = Math_fround(0);
    x = -x;
    FUNCTION_TABLE_c[1 & 7](x);
  }
  function cneg(x) {
    x = Math_fround(x);
    FUNCTION_TABLE_c[1 & 7](x);
  }
  function ___syscall_ret() {
   var $0 = 0;
   ($0>>>0) > 4294963200; // -4096
  }
  function smallCompare() {
    var i = 0, j = 0;
    if ((i | 0) < (j | 0)) i = i + 1 | 0;
    if ((i >>> 0) < (j >>> 0)) i = i + 1 | 0;
    return i | 0;
  }
  function cneg_nosemicolon() {
    FUNCTION_TABLE_c[1 & 7](1) // no semicolon
  }
  function forLoop() {
    var i = 0;
    for (i = 1; (i | 0) < 200; i = i + 1 | 0) {
      h(i | 0);
    }
  }
  function ceiling_32_64(u, B) {
    u = Math_fround(u);
    B = +B;
    var temp = Math_fround(0);
    temp = Math_fround(Math_ceil(B));
    temp = Math_fround(u * Math_fround(Math_ceil(Math_fround(B))));
  }
  function aborts() {
    abort();
    abort(55);
    abort();
  }
  function continues() {
    while (1) {
      print(1);
      do {
        print(5);
        if (check()) continue;
      } while (0);
      print(2);
    }
  }

  function z() {
  }
  function w() {
  }

  var FUNCTION_TABLE_a = [ z, big_negative, z, z ];
  var FUNCTION_TABLE_b = [ w, w, importedDoubles, w ];
  var FUNCTION_TABLE_c = [ z, cneg ];

  return { big_negative: big_negative };
}