1/* 2 * Copyright (c) 2024 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//aot: [trace] aot inline builtin: Reflect.getPrototypeOf, caller function name:func_main_0@builtinReflectReflect 18print(Reflect.getPrototypeOf({})) //: [object Object] 19try { 20 //aot: [trace] aot inline builtin: Reflect.getPrototypeOf, caller function name:func_main_0@builtinReflectReflect 21 Reflect.getPrototypeOf(1); 22} catch(e) { 23 print(e instanceof TypeError); //: true 24} 25let o = {a:123, b: "abc"}; 26//aot: [trace] aot inline builtin: Reflect.get, caller function name:func_main_0@builtinReflectReflect 27print(Reflect.get(o, "a")); //: 123 28//aot: [trace] aot inline builtin: Reflect.get, caller function name:func_main_0@builtinReflectReflect 29print(Reflect.get(o, "b")); //: abc 30//aot: [trace] aot inline builtin: Reflect.get, caller function name:func_main_0@builtinReflectReflect 31print(Reflect.get(o, "c")); //: undefined 32 33//aot: [trace] aot inline builtin: Reflect.has, caller function name:func_main_0@builtinReflectReflect 34print(Reflect.has(o, "a")); //: true 35//aot: [trace] aot inline builtin: Reflect.has, caller function name:func_main_0@builtinReflectReflect 36print(Reflect.has(o, "c")); //: false 37//aot: [trace] aot inline builtin: Reflect.has, caller function name:func_main_0@builtinReflectReflect 38print(Reflect.has(o, "toString")); //: true 39function foo(a: any, b: any) { 40 return this + a + b; 41} 42//aot: [trace] aot inline builtin: Reflect.apply, caller function name:func_main_0@builtinReflectReflect 43print(Reflect.apply(foo, 1, [2, 3])); //: 6 44class C { 45 x:number; 46 constructor(x: number = 123) { 47 this.x = x; 48 } 49} 50//aot: [trace] aot inline builtin: Reflect.construct, caller function name:func_main_0@builtinReflectReflect 51print(Reflect.construct(C, []).x); //: 123 52print(Reflect.construct(C, [456]).x); //: 456 53