forked from facebook/hermes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
new_expr.js
42 lines (36 loc) · 1.39 KB
/
new_expr.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
// 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
function Car(model, year) {
this.model = model;
this.year = year;
return "wat";
}
//CHECK-LABEL:function test_simple_new()
//CHECK-NEXT:frame = [ctor]
//CHECK-NEXT:%BB0:
//CHECK-NEXT: %0 = StoreFrameInst undefined : undefined, [ctor]
//CHECK-NEXT: %1 = LoadPropertyInst globalObject : object, "Car" : string
//CHECK-NEXT: %2 = ConstructInst %1, undefined : undefined, "Eagle" : string, 1993 : number
//CHECK-NEXT: %3 = StoreFrameInst %2 : object, [ctor]
//CHECK-NEXT: %4 = ReturnInst undefined : undefined
//CHECK-NEXT:function_end
function test_simple_new() {
var ctor = new Car("Eagle", 1993);
}
//CHECK-LABEL:function test_simple_call()
//CHECK-NEXT:frame = [call]
//CHECK-NEXT: %BB0:
//CHECK-NEXT: %0 = StoreFrameInst undefined : undefined, [call]
//CHECK-NEXT: %1 = LoadPropertyInst globalObject : object, "Car" : string
//CHECK-NEXT: %2 = CallInst %1, undefined : undefined, 1 : number, 2 : number
//CHECK-NEXT: %3 = StoreFrameInst %2, [call]
//CHECK-NEXT: %4 = ReturnInst undefined : undefined
//CHECK-NEXT:function_end
function test_simple_call() {
var call = Car(1,2)
}