• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16declare function print(arg:any):string;
17
18class A {
19    x: number;
20    constructor() {
21        // Mega state
22        this.x = 5;
23    }
24}
25
26class B extends A {
27    constructor() {
28        super();
29    }
30}
31class C extends A {
32    constructor() {
33        super();
34    }
35}
36
37class D extends A {
38    constructor() {
39        super();
40    }
41}
42
43class E extends A {
44    constructor() {
45        super();
46    }
47}
48
49class F extends A {
50    constructor() {
51        super();
52    }
53}
54
55class G {
56    x: number;
57    constructor() {
58        this.x = 5;
59    }
60}
61
62function foo(a) {
63    // Mega state
64    a.x;
65}
66
67function bar(t) {
68    print(t.x);
69}
70
71let a = new A();
72let b = new B();
73let c = new C();
74let d = new D();
75let e = new E();
76let f = new F();
77
78foo(a);
79foo(b);
80for (let i = 0; i < 1000; i++) {
81    foo(c);
82}
83foo(d);
84foo(e);
85foo(f);
86
87bar(b);
88bar(c);
89
90function getPrototypeOf(a)
91{
92    return a.prototype
93}
94
95getPrototypeOf(A);
96getPrototypeOf(B);
97
98A.prototype.foo = function() {
99    print("foo");
100}
101
102a.foo();
103