代码拉取完成,页面将自动刷新
同步操作将从 OpenHarmony-SIG/arkcompiler_ets_frontend 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
/**
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ES2PANDA_BINDER_ETS_BINDER_H
#define ES2PANDA_BINDER_ETS_BINDER_H
#include "plugins/ecmascript/es2panda/binder/TypedBinder.h"
#include "plugins/ecmascript/es2panda/binder/recordTable.h"
namespace panda::es2panda::binder {
using ComputedLambdaObjects =
ArenaUnorderedMap<const ir::AstNode *, std::pair<ir::ClassDefinition *, checker::Signature *>>;
class ETSBinder : public TypedBinder {
public:
explicit ETSBinder(ArenaAllocator *allocator)
: TypedBinder(allocator),
global_record_table_(allocator, Program(), RecordTableFlags::NONE),
record_table_(&global_record_table_),
external_record_table_(Allocator()->Adapter()),
default_imports_(Allocator()->Adapter()),
lambda_objects_(Allocator()->Adapter())
{
InitImplicitThisParam();
}
NO_COPY_SEMANTIC(ETSBinder);
NO_MOVE_SEMANTIC(ETSBinder);
~ETSBinder() = default;
ScriptExtension Extension() const override
{
return ScriptExtension::ETS;
}
ResolveBindingOptions BindingOptions() const override
{
return ResolveBindingOptions::BINDINGS;
}
RecordTable *GetRecordTable()
{
return record_table_;
}
const RecordTable *GetRecordTable() const
{
return record_table_;
}
RecordTable *GetGlobalRecordTable()
{
return &global_record_table_;
}
const RecordTable *GetGlobalRecordTable() const
{
return &global_record_table_;
}
ArenaUnorderedMap<parser::Program *, RecordTable *> &GetExternalRecordTable()
{
return external_record_table_;
}
const ArenaUnorderedMap<parser::Program *, RecordTable *> &GetExternalRecordTable() const
{
return external_record_table_;
}
const ComputedLambdaObjects &LambdaObjects() const
{
return lambda_objects_;
}
ComputedLambdaObjects &LambdaObjects()
{
return lambda_objects_;
}
void HandleCustomNodes(ir::AstNode *child_node) override;
void IdentifierAnalysis() override;
void BuildClassDefinition(ir::ClassDefinition *class_def) override;
void BuildClassProperty(const ir::ClassProperty *prop) override;
void LookupIdentReference(ir::Identifier *ident) override;
bool BuildInternalName(ir::ScriptFunction *script_func) override;
void AddCompilableFunction(ir::ScriptFunction *func) override;
void LookupTypeReference(ir::Identifier *ident);
void LookupTypeArgumentReferences(ir::ETSTypeReference *type_ref);
void BuildInterfaceDeclaration(ir::TSInterfaceDeclaration *decl);
void BuildMemberExpression(ir::MemberExpression *member_expr);
void BuildMethodDefinition(ir::MethodDefinition *method_def);
void BuildImportDeclaration(ir::ImportDeclaration *decl);
void BuildETSNewClassInstanceExpression(ir::ETSNewClassInstanceExpression *class_instance);
void BuildMethodReferenceExpression(ir::ETSMethodReferenceExpression *method_ref);
void AddSpecifiersToTopBindings(ir::AstNode *specifier, const ir::StringLiteral *import_path);
void ResolveInterfaceDeclaration(ir::TSInterfaceDeclaration *decl);
void ResolveMethodDefinition(ir::MethodDefinition *method_def);
LocalScope *ResolvePropertyReference(ir::ClassProperty *prop, ClassScope *scope);
void ResolveEnumDeclaration(ir::TSEnumDeclaration *enum_decl);
void InitializeInterfaceIdent(ir::TSInterfaceDeclaration *decl);
void BuildExternalProgram(parser::Program *ext_program);
void BuildProgram();
void BuildFunctionName(const ir::ScriptFunction *func) const;
void BuildFunctionType(ir::ETSFunctionType *func_type);
void BuildProxyMethod(ir::ScriptFunction *func, const util::StringView &containing_class_name, bool is_static);
void BuildLambdaObject(ir::AstNode *ref_node, ir::ClassDefinition *lambda_object, checker::Signature *signature);
void AddLambdaFunctionThisParam(ir::ScriptFunction *func);
void AddInvokeFunctionThisParam(ir::ScriptFunction *func);
void BuildLambdaObjectName(const ir::AstNode *ref_node);
void FormLambdaName(util::UString &name, const util::StringView &signature);
void FormFunctionalInterfaceName(util::UString &name, const util::StringView &signature);
void BuildFunctionalInterfaceName(ir::ETSFunctionType *func_type);
void SetDefaultImports(ArenaVector<ir::ImportDeclaration *> default_imports)
{
default_imports_ = std::move(default_imports);
}
static constexpr std::string_view DEFAULT_IMPORT_SOURCE_FILE = "<default_import>.ets";
static constexpr std::string_view DEFAULT_IMPORT_SOURCE = R"(
import * from "std/core";
import * from "std/math";
import * from "std/containers";
import * from "std/time";
)";
private:
void BuildClassDefinitionImpl(ir::ClassDefinition *class_def);
void InitImplicitThisParam();
void HandleStarImport(ir::TSQualifiedName *import_name, util::StringView full_path);
void ImportGlobalProperties(ir::ClassDefinition *class_def);
RecordTable global_record_table_;
RecordTable *record_table_;
ArenaUnorderedMap<parser::Program *, RecordTable *> external_record_table_;
ArenaVector<ir::ImportDeclaration *> default_imports_;
ComputedLambdaObjects lambda_objects_;
ir::Identifier *this_param_ {};
};
} // namespace panda::es2panda::binder
#endif
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。