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 #include "ecmascript/compiler/pass.h" 16 #include "ecmascript/compiler/precompile_checker.h" 17 18 namespace panda::ecmascript::kungfu { 19 Run()20bool PreCompileChecker::Run() 21 { 22 if (!HasReturnCheck()) { 23 PrintAbortInfo("HasReturnCheck"); 24 return false; 25 } 26 if (HasDebuggerStmt()) { 27 PrintAbortInfo("HasDebuggerStmt"); 28 return false; 29 } 30 return true; 31 } 32 HasReturnCheck() const33bool PreCompileChecker::HasReturnCheck() const 34 { 35 std::vector<GateRef> returnList; 36 acc_.GetReturnOuts(returnList); 37 return returnList.size() != 0; 38 } 39 HasDebuggerStmt() const40bool PreCompileChecker::HasDebuggerStmt() const 41 { 42 return data_->GetMethodLiteral()->HasDebuggerStmt(); 43 } 44 PrintAbortInfo(const std::string & checkName) const45void PreCompileChecker::PrintAbortInfo(const std::string& checkName) const 46 { 47 if (enableLog_) { 48 LOG_COMPILER(INFO) << checkName << " check failed! Abort compiling method " 49 << methodName_; 50 } 51 } 52 53 } // namespace panda::ecmascript::kungfu