forked from facebook/hermes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreturn_stmt.js
143 lines (127 loc) · 3.64 KB
/
return_stmt.js
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
// Copyright (c) Facebook, Inc. and its affiliates.
//
// This source code is licensed under the MIT license found in the LICENSE
// file in the root directory of this source tree.
//
// RUN: %hermes -hermes-parser -dump-ir %s | %FileCheck %s --match-full-lines
// RUN: %hermes -hermes-parser -dump-ir %s -O
//CHECK: function test0(x, y)
//CHECK: frame = [x, y]
//CHECK: %BB0:
//CHECK: %0 = StoreFrameInst %x, [x]
//CHECK: %1 = StoreFrameInst %y, [y]
//CHECK: %2 = LoadFrameInst [x]
//CHECK: %3 = CondBranchInst %2, %BB1, %BB2
//CHECK: %BB1:
//CHECK: %4 = LoadFrameInst [x]
//CHECK: %5 = ReturnInst %4
//CHECK: %BB2:
//CHECK: %6 = LoadFrameInst [y]
//CHECK: %7 = ReturnInst %6
//CHECK: %BB3:
//CHECK: %8 = LoadFrameInst [y]
//CHECK: %9 = ReturnInst %8
//CHECK: %BB4:
//CHECK: %10 = BranchInst %BB3
//CHECK: %BB5:
//CHECK: %11 = BranchInst %BB3
//CHECK: %BB6:
//CHECK: %12 = ReturnInst undefined : undefined
function test0(x, y) {
if (x) { return x; } else { return y; }
return y;
}
//CHECK: function test1(x, y)
//CHECK: frame = [x, y]
//CHECK: %BB0:
//CHECK: %0 = StoreFrameInst %x, [x]
//CHECK: %1 = StoreFrameInst %y, [y]
//CHECK: %2 = LoadFrameInst [x]
//CHECK: %3 = CondBranchInst %2, %BB1, %BB2
//CHECK: %BB1:
//CHECK: %4 = BranchInst %BB3
//CHECK: %BB2:
//CHECK: %5 = LoadFrameInst [y]
//CHECK: %6 = ReturnInst %5
//CHECK: %BB3:
//CHECK: %7 = ReturnInst undefined : undefined
function test1(x, y) {
if (x) { } else { return y; }
}
//CHECK: function test2(x, y)
//CHECK: frame = [x, y]
//CHECK: %BB0:
//CHECK: %0 = StoreFrameInst %x, [x]
//CHECK: %1 = StoreFrameInst %y, [y]
//CHECK: %2 = LoadFrameInst [x]
//CHECK: %3 = CondBranchInst %2, %BB1, %BB2
//CHECK: %BB1:
//CHECK: %4 = LoadFrameInst [x]
//CHECK: %5 = ReturnInst %4
//CHECK: %BB2:
//CHECK: %6 = BranchInst %BB3
//CHECK: %BB3:
//CHECK: %7 = ReturnInst undefined : undefined
//CHECK: %BB4:
//CHECK: %8 = BranchInst %BB3
function test2(x, y) {
if (x) { return x; } else { }
}
//CHECK: function test3(x, y)
//CHECK: frame = [x, y]
//CHECK: %BB0:
//CHECK: %0 = StoreFrameInst %x, [x]
//CHECK: %1 = StoreFrameInst %y, [y]
//CHECK: %2 = LoadFrameInst [x]
//CHECK: %3 = ReturnInst %2
//CHECK: %BB1:
//CHECK: %4 = LoadFrameInst [x]
//CHECK: %5 = CondBranchInst %4, %BB2, %BB3
//CHECK: %BB2:
//CHECK: %6 = LoadFrameInst [x]
//CHECK: %7 = ReturnInst %6
//CHECK: %BB3:
//CHECK: %8 = LoadFrameInst [x]
//CHECK: %9 = ReturnInst %8
//CHECK: %BB4:
//CHECK: %10 = ReturnInst undefined : undefined
//CHECK: %BB5:
//CHECK: %11 = BranchInst %BB4
//CHECK: %BB6:
//CHECK: %12 = BranchInst %BB4
function test3(x, y) {
return x;
if (x) { return x; } else { return x; }
}
//CHECK: function test4(x, y)
//CHECK: frame = [x, y]
//CHECK: %BB0:
//CHECK: %0 = StoreFrameInst %x, [x]
//CHECK: %1 = StoreFrameInst %y, [y]
//CHECK: %2 = LoadFrameInst [x]
//CHECK: %3 = ReturnInst %2
//CHECK: %BB1:
//CHECK: %4 = LoadFrameInst [x]
//CHECK: %5 = CondBranchInst %4, %BB2, %BB3
//CHECK: %BB2:
//CHECK: %6 = LoadFrameInst [x]
//CHECK: %7 = ReturnInst %6
//CHECK: %BB3:
//CHECK: %8 = LoadFrameInst [x]
//CHECK: %9 = ReturnInst %8
//CHECK: %BB4:
//CHECK: %10 = ReturnInst undefined : undefined
//CHECK: %BB5:
//CHECK: %11 = BranchInst %BB4
//CHECK: %BB6:
//CHECK: %12 = BranchInst %BB4
function test4(x, y) {
return x;
if (x) { return x; } else { return x; }
}
//CHECK: function test5()
//CHECK: %BB0:
//CHECK: %0 = ReturnInst undefined : undefined
function test5() {
return;
}