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 18function foo(arg1 : number, arg2 : number) : number { 19 let res = arg1 + arg2; 20 if (res > 0) { 21 return res; 22 } else { 23 return 0; 24 } 25} 26 27function bar(arg1 : number, arg2 : number) : number { 28 return arg1 * arg2; 29} 30 31function calculate(arg1 : number, arg2 : number) : number { 32 let a1 = arg1 + arg2; 33 if (a1 > 0) { 34 a1 = a1 * 2; 35 } else { 36 a1++; 37 } 38 let a2 = arg1 * arg2; 39 if (a2 > 0) { 40 a2 = a2 / 2; 41 } else { 42 a2++; 43 } 44 let a3 = a1 + a2; 45 return a3; 46} 47 48print(foo(1, 2)); 49print(foo(1, -2)); 50 51// inline doesn't support try-catch 52print(bar(7, 8)); 53try { 54 print(bar(7, 8)); 55} catch (e) { 56 print(e); 57} 58 59// large function no inline 60print(calculate(4, 2));