1 /* 2 * Copyright (c) 2022 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 16 #ifndef ECMASCRIPT_COMPILER_STUB_H 17 #define ECMASCRIPT_COMPILER_STUB_H 18 19 #include "ecmascript/compiler/circuit_builder-inl.h" 20 #include "ecmascript/compiler/variable_type.h" 21 #include "ecmascript/compiler/call_signature.h" 22 23 namespace panda::ecmascript::kungfu { 24 class StubBuilder; 25 class Stub { 26 public: 27 explicit Stub(const CallSignature *callSignature, Circuit *circuit); 28 NO_MOVE_SEMANTIC(Stub); 29 NO_COPY_SEMANTIC(Stub); 30 GetEnvironment()31 Environment *GetEnvironment() 32 { 33 return &env_; 34 } GetCallSignature()35 const CallSignature *GetCallSignature() const 36 { 37 return callSignature_; 38 } SetStubBuilder(StubBuilder * stubBuilder)39 void SetStubBuilder(StubBuilder *stubBuilder) 40 { 41 stubBuilder_ = stubBuilder; 42 } GetMethodName()43 const std::string &GetMethodName() const 44 { 45 return callSignature_->GetName(); 46 } 47 void GenerateCircuit(const CompilationConfig *cfg); 48 private: 49 void InitializeArguments(); 50 const CallSignature *callSignature_; 51 CircuitBuilder builder_; 52 GateAccessor acc_; 53 Environment env_; 54 StubBuilder *stubBuilder_ {nullptr}; 55 }; 56 } // namespace panda::ecmascript::kungfu 57 #endif // ECMASCRIPT_COMPILER_STUB_H 58