1 /* 2 * Copyright (c) 2021 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_MODULE_JS_MODULE_NAMESPACE_H 17 #define ECMASCRIPT_MODULE_JS_MODULE_NAMESPACE_H 18 19 #include "ecmascript/js_object.h" 20 #include "ecmascript/js_tagged_value.h" 21 22 namespace panda::ecmascript { 23 class ModuleNamespace final : public JSObject { 24 public: 25 CAST_CHECK(ModuleNamespace, IsModuleNamespace); 26 27 // 9.4.6.11ModuleNamespaceCreate ( module, exports ) 28 static JSHandle<ModuleNamespace> ModuleNamespaceCreate(JSThread *thread, const JSHandle<JSTaggedValue> &module, 29 const JSHandle<TaggedArray> &exports); 30 // 9.4.6.1[[SetPrototypeOf]] 31 static bool SetPrototype(const JSHandle<JSTaggedValue> &obj, 32 const JSHandle<JSTaggedValue> &proto); 33 // 9.4.6.3[[PreventExtensions]] 34 static bool PreventExtensions(); 35 // 9.4.6.4[[GetOwnProperty]] 36 static bool GetOwnProperty(JSThread *thread, const JSHandle<JSTaggedValue> &obj, const JSHandle<JSTaggedValue> &key, 37 PropertyDescriptor &desc); 38 // 9.4.6.5[[DefineOwnProperty]] ( P, Desc ) 39 static bool DefineOwnProperty(JSThread *thread, const JSHandle<JSTaggedValue> &obj, 40 const JSHandle<JSTaggedValue> &key, PropertyDescriptor desc); 41 // 9.4.6.6[[HasProperty]] 42 static bool HasProperty(JSThread *thread, const JSHandle<JSTaggedValue> &obj, const JSHandle<JSTaggedValue> &key); 43 // 9.4.6.7[[Get]] ( P, Receiver ) 44 static OperationResult GetProperty(JSThread *thread, const JSHandle<JSTaggedValue> &obj, 45 const JSHandle<JSTaggedValue> &key); 46 // 9.4.6.8[[Set]] ( P, V, Receiver ) 47 static bool SetProperty(JSThread *thread, bool mayThrow); 48 // 9.4.6.9[[Delete]] ( P ) 49 static bool DeleteProperty(JSThread *thread, const JSHandle<JSTaggedValue> &obj, 50 const JSHandle<JSTaggedValue> &key); 51 // 9.4.6.10[[OwnPropertyKeys]] 52 static JSHandle<TaggedArray> OwnPropertyKeys(JSThread *thread, const JSHandle<JSTaggedValue> &proxy); 53 54 bool ValidateKeysAvailable(JSThread *thread, const JSHandle<TaggedArray> &exports); 55 56 static constexpr size_t MODULE_OFFSET = JSObject::SIZE; 57 ACCESSORS(Module, MODULE_OFFSET, EXPORTS_OFFSET) 58 ACCESSORS(Exports, EXPORTS_OFFSET, SIZE) 59 60 DECL_DUMP() 61 DECL_VISIT_OBJECT_FOR_JS_OBJECT(JSObject, MODULE_OFFSET, SIZE) 62 }; 63 } // namespace panda::ecmascript 64 #endif // ECMASCRIPT_MODULE_JS_MODULE_NAMESPACE_H 65