forked from facebook/hermes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheval.js
More file actions
46 lines (42 loc) · 1.32 KB
/
eval.js
File metadata and controls
46 lines (42 loc) · 1.32 KB
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
/**
* 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: %hermesc -O0 -dump-ir %s | %FileCheck --match-full-lines %s
function foo() {
return eval("1 + 1");
}
//CHECK-LABEL:function foo()
//CHECK-NEXT:frame = []
//CHECK-NEXT:%BB0:
//CHECK-NEXT: %0 = DirectEvalInst "1 + 1" : string
//CHECK-NEXT: %1 = ReturnInst %0
//CHECK-NEXT:%BB1:
//CHECK-NEXT: %2 = ReturnInst undefined : undefined
//CHECK-NEXT:function_end
function bar() {
return eval("2 + 2", Math, foo());
}
//CHECK-LABEL:function bar()
//CHECK-NEXT:frame = []
//CHECK-NEXT:%BB0:
//CHECK-NEXT: %0 = TryLoadGlobalPropertyInst globalObject : object, "Math" : string
//CHECK-NEXT: %1 = LoadPropertyInst globalObject : object, "foo" : string
//CHECK-NEXT: %2 = CallInst %1, undefined : undefined
//CHECK-NEXT: %3 = DirectEvalInst "2 + 2" : string
//CHECK-NEXT: %4 = ReturnInst %3
//CHECK-NEXT:%BB1:
//CHECK-NEXT: %5 = ReturnInst undefined : undefined
//CHECK-NEXT:function_end
function baz() {
return eval();
}
//CHECK-LABEL:function baz()
//CHECK-NEXT:frame = []
//CHECK-NEXT:%BB0:
//CHECK-NEXT: %0 = ReturnInst undefined : undefined
//CHECK-NEXT:%BB1:
//CHECK-NEXT: %1 = ReturnInst undefined : undefined
//CHECK-NEXT:function_end