diff --git a/ets2panda/CMakeLists.txt b/ets2panda/CMakeLists.txt index b37a63a03b022394dbe943a54c8acc39a7fa4249..d32bf55500d8063503c56179c82071ed92f79602 100644 --- a/ets2panda/CMakeLists.txt +++ b/ets2panda/CMakeLists.txt @@ -113,23 +113,6 @@ if(PANDA_WITH_ETS) file(COPY "${GENERATED_DIR}/arktsconfig.json" DESTINATION "${CMAKE_BINARY_DIR}/bin-gtests") endif() -# add check for PANDA_PRODUCT_BUILD after normal version tracking will be implemented -execute_process( - COMMAND date "+%Y-%m-%d_%H:%M:%S" - OUTPUT_VARIABLE CURRENT_DATE - OUTPUT_STRIP_TRAILING_WHITESPACE -) -execute_process( - COMMAND git rev-parse HEAD - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - OUTPUT_VARIABLE LAST_COMMIT_HASH - OUTPUT_STRIP_TRAILING_WHITESPACE -) - -add_definitions(-DES2PANDA_DATE="${CURRENT_DATE}") -add_definitions(-DES2PANDA_HASH="${LAST_COMMIT_HASH}") - - add_custom_command( OUTPUT ${GENERATED_STAMP} COMMAND ${CMAKE_COMMAND} -E make_directory ${OUTPUT_DIR} diff --git a/ets2panda/aot/main.cpp b/ets2panda/aot/main.cpp index 0cf435deac536e5c602846bb7f8bc130965dda52..4db0b8b6332df389b6bbdcb5dfbcc2ff1707e882 100644 --- a/ets2panda/aot/main.cpp +++ b/ets2panda/aot/main.cpp @@ -18,6 +18,7 @@ #include "compiler/compiler_logger.h" #include "libarkbase/mem/arena_allocator.h" #include "libarkbase/mem/pool_manager.h" +#include "libarkbase/mem/mem_config.h" #include "es2panda.h" #include "util/arktsconfig.h" #include "util/diagnosticEngine.h" diff --git a/ets2panda/ast_verifier/ASTVerifier.cpp b/ets2panda/ast_verifier/ASTVerifier.cpp index e55eaac5bb4bfcf16edb00c06b1de418aba183b4..b924a2e2661e780865767b956b4deb0c8cc9ca94 100644 --- a/ets2panda/ast_verifier/ASTVerifier.cpp +++ b/ets2panda/ast_verifier/ASTVerifier.cpp @@ -15,6 +15,8 @@ #include "ASTVerifier.h" +#include "public/public.h" + namespace ark::es2panda::compiler::ast_verifier { using AstToCheck = ArenaMap; @@ -217,6 +219,11 @@ void ASTVerifier::DumpMessages() const } } +const util::Options &ASTVerifier::Options() const +{ + return *context_.config->options; +} + void InvariantMessages::AddCheckMessage(const std::string &cause, const ir::AstNode &node) { messages_.emplace_back(cause.data(), &node); diff --git a/ets2panda/ast_verifier/ASTVerifier.h b/ets2panda/ast_verifier/ASTVerifier.h index 59d8953b3dc2da863b3125ffc0dc3454349807be..3d82ffb1941eb42e0203b71bb87537cc3777a027 100644 --- a/ets2panda/ast_verifier/ASTVerifier.h +++ b/ets2panda/ast_verifier/ASTVerifier.h @@ -50,9 +50,7 @@ #include "parser/program/program.h" #include "util/ustring.h" #include "util/options.h" -#include "libarkbase/utils/arena_containers.h" #include "varbinder/variable.h" -#include "public/public.h" #ifdef ASTV_ENABLE_LOGGING // CC-OFFNXT(G.PRE.02) macro to enable conditionally @@ -179,10 +177,7 @@ private: return enabled_[T::ID] && allowed_[T::ID]; } - const util::Options &Options() const - { - return *context_.config->options; - } + const util::Options &Options() const; public: using SourcePath = std::string_view; diff --git a/ets2panda/ast_verifier/invariants/checkConstProperties.cpp b/ets2panda/ast_verifier/invariants/checkConstProperties.cpp index b35435ee17db49685287dbe29b7d5e09835f4422..c91280cf34e88a56c3b5fecbd70d1988de077356 100644 --- a/ets2panda/ast_verifier/invariants/checkConstProperties.cpp +++ b/ets2panda/ast_verifier/invariants/checkConstProperties.cpp @@ -14,6 +14,7 @@ */ #include "checkConstProperties.h" +#include "ir/base/classDefinition.h" #include "ir/expressions/callExpression.h" #include "ir/expressions/memberExpression.h" #include "checker/types/signature.h" diff --git a/ets2panda/checker/ETSAnalyzer.cpp b/ets2panda/checker/ETSAnalyzer.cpp index 4498536bb1f300d01c8b1a2ba89667e544d50c3f..8f3214161c81004bd49365d49e0c7ee392b0c7cf 100644 --- a/ets2panda/checker/ETSAnalyzer.cpp +++ b/ets2panda/checker/ETSAnalyzer.cpp @@ -16,17 +16,186 @@ #include "ETSAnalyzer.h" #include "checker/ETSchecker.h" -#include "compiler/lowering/util.h" #include "generated/diagnostic.h" #include "checker/types/globalTypesHolder.h" +#include "checker/types/ets/etsFunctionType.h" #include "checker/types/ets/etsTupleType.h" -#include "evaluate/scopedDebugInfoPlugin.h" -#include "types/signature.h" -#include "compiler/lowering/ets/setJumpTarget.h" +#include "checker/types/ets/etsUnionType.h" +#include "checker/types/ets/etsTypeAliasType.h" +#include "checker/types/ets/etsStringType.h" +#include "checker/types/ets/etsBigIntType.h" +#include "checker/types/ets/etsObjectType.h" +#include "checker/types/ets/etsResizableArrayType.h" #include "checker/types/ets/etsAsyncFuncReturnType.h" -#include "types/type.h" #include "checker/types/typeError.h" +#include "types/signature.h" +#include "types/type.h" +#include "evaluate/scopedDebugInfoPlugin.h" +#include "compiler/lowering/ets/setJumpTarget.h" +#include "compiler/lowering/util.h" +#include "ir/brokenTypeNode.h" +#include "ir/opaqueTypeNode.h" +#include "ir/annotationAllowed.h" + +#include "ir/module/exportAllDeclaration.h" +#include "ir/module/exportDefaultDeclaration.h" +#include "ir/module/exportNamedDeclaration.h" +#include "ir/module/exportSpecifier.h" +#include "ir/module/importDefaultSpecifier.h" +#include "ir/module/importNamespaceSpecifier.h" + +#include "ir/ets/etsClassLiteral.h" +#include "ir/ets/etsStructDeclaration.h" +#include "ir/ets/etsIntrinsicNode.h" +#include "ir/ets/etsUnionType.h" +#include "ir/ets/etsStringLiteralType.h" +#include "ir/ets/etsTuple.h" +#include "ir/ets/etsTypeReference.h" +#include "ir/ets/etsTypeReferencePart.h" +#include "ir/ets/etsNeverType.h" +#include "ir/ets/etsNullishTypes.h" +#include "ir/ets/etsReExportDeclaration.h" +#include "ir/ets/etsNewArrayInstanceExpression.h" +#include "ir/ets/etsNewMultiDimArrayInstanceExpression.h" +#include "ir/ets/etsNewClassInstanceExpression.h" +#include "ir/ets/etsFunctionType.h" +#include "ir/ets/etsNonNullishTypeNode.h" +#include "ir/ets/etsPackageDeclaration.h" +#include "ir/ets/etsPrimitiveType.h" +#include "ir/ets/etsWildcardType.h" +#include "ir/ets/etsKeyofType.h" +#include "ir/ets/etsModule.h" + +#include "ir/ts/tsAsExpression.h" +#include "ir/ts/tsEnumDeclaration.h" +#include "ir/ts/tsEnumMember.h" +#include "ir/ts/tsExternalModuleReference.h" +#include "ir/ts/tsNonNullExpression.h" +#include "ir/ts/tsTypeAssertion.h" +#include "ir/ts/tsAnyKeyword.h" +#include "ir/ts/tsArrayType.h" +#include "ir/ts/tsBigintKeyword.h" +#include "ir/ts/tsBooleanKeyword.h" +#include "ir/ts/tsLiteralType.h" +#include "ir/ts/tsNeverKeyword.h" +#include "ir/ts/tsNullKeyword.h" +#include "ir/ts/tsNumberKeyword.h" +#include "ir/ts/tsObjectKeyword.h" +#include "ir/ts/tsParenthesizedType.h" +#include "ir/ts/tsStringKeyword.h" +#include "ir/ts/tsTypeLiteral.h" +#include "ir/ts/tsUndefinedKeyword.h" +#include "ir/ts/tsUnionType.h" +#include "ir/ts/tsUnknownKeyword.h" +#include "ir/ts/tsVoidKeyword.h" +#include "ir/ts/tsConditionalType.h" +#include "ir/ts/tsConstructorType.h" +#include "ir/ts/tsFunctionType.h" +#include "ir/ts/tsImportEqualsDeclaration.h" +#include "ir/ts/tsImportType.h" +#include "ir/ts/tsInferType.h" +#include "ir/ts/tsIntersectionType.h" +#include "ir/ts/tsMappedType.h" +#include "ir/ts/tsModuleBlock.h" +#include "ir/ts/tsModuleDeclaration.h" +#include "ir/ts/tsParameterProperty.h" +#include "ir/ts/tsThisType.h" +#include "ir/ts/tsTypeAliasDeclaration.h" +#include "ir/ts/tsTypeOperator.h" +#include "ir/ts/tsTypeParameter.h" +#include "ir/ts/tsTypeParameterDeclaration.h" +#include "ir/ts/tsTypeParameterInstantiation.h" +#include "ir/ts/tsTypePredicate.h" +#include "ir/ts/tsTypeReference.h" +#include "ir/ts/tsClassImplements.h" +#include "ir/ts/tsIndexedAccessType.h" +#include "ir/ts/tsInterfaceBody.h" +#include "ir/ts/tsInterfaceDeclaration.h" +#include "ir/ts/tsInterfaceHeritage.h" +#include "ir/ts/tsNamedTupleMember.h" +#include "ir/ts/tsQualifiedName.h" +#include "ir/ts/tsTupleType.h" +#include "ir/ts/tsTypeQuery.h" + +#include "ir/base/spreadElement.h" +#include "ir/base/scriptFunction.h" +#include "ir/base/catchClause.h" +#include "ir/base/classDefinition.h" +#include "ir/base/classProperty.h" +#include "ir/base/classStaticBlock.h" +#include "ir/base/decorator.h" +#include "ir/base/methodDefinition.h" +#include "ir/base/metaProperty.h" +#include "ir/base/overloadDeclaration.h" +#include "ir/base/property.h" +#include "ir/base/tsMethodSignature.h" +#include "ir/base/tsPropertySignature.h" +#include "ir/base/tsSignatureDeclaration.h" +#include "ir/base/tsIndexSignature.h" + +#include "ir/expressions/assignmentExpression.h" +#include "ir/expressions/taggedTemplateExpression.h" +#include "ir/expressions/typeofExpression.h" +#include "ir/expressions/unaryExpression.h" +#include "ir/expressions/updateExpression.h" +#include "ir/expressions/yieldExpression.h" + +#include "ir/expressions/arrowFunctionExpression.h" +#include "ir/expressions/arrayExpression.h" +#include "ir/expressions/objectExpression.h" +#include "ir/expressions/sequenceExpression.h" +#include "ir/expressions/templateLiteral.h" +#include "ir/expressions/functionExpression.h" +#include "ir/expressions/awaitExpression.h" +#include "ir/expressions/binaryExpression.h" +#include "ir/expressions/callExpression.h" +#include "ir/expressions/classExpression.h" +#include "ir/expressions/chainExpression.h" +#include "ir/expressions/identifier.h" +#include "ir/expressions/importExpression.h" +#include "ir/expressions/dummyNode.h" +#include "ir/expressions/directEvalExpression.h" +#include "ir/expressions/blockExpression.h" +#include "ir/expressions/conditionalExpression.h" +#include "ir/expressions/thisExpression.h" +#include "ir/expressions/literals/undefinedLiteral.h" +#include "ir/expressions/literals/bigIntLiteral.h" +#include "ir/expressions/literals/booleanLiteral.h" +#include "ir/expressions/literals/charLiteral.h" +#include "ir/expressions/literals/nullLiteral.h" +#include "ir/expressions/literals/numberLiteral.h" +#include "ir/expressions/literals/regExpLiteral.h" +#include "ir/expressions/memberExpression.h" +#include "ir/expressions/newExpression.h" +#include "ir/expressions/omittedExpression.h" +#include "ir/expressions/superExpression.h" + +#include "ir/statements/assertStatement.h" +#include "ir/statements/annotationDeclaration.h" +#include "ir/statements/breakStatement.h" +#include "ir/statements/blockStatement.h" +#include "ir/statements/continueStatement.h" +#include "ir/statements/debuggerStatement.h" +#include "ir/statements/doWhileStatement.h" +#include "ir/statements/emptyStatement.h" +#include "ir/statements/expressionStatement.h" +#include "ir/statements/forInStatement.h" +#include "ir/statements/forOfStatement.h" +#include "ir/statements/forUpdateStatement.h" +#include "ir/statements/labelledStatement.h" +#include "ir/statements/functionDeclaration.h" +#include "ir/statements/ifStatement.h" +#include "ir/statements/variableDeclaration.h" +#include "ir/statements/variableDeclarator.h" +#include "ir/statements/switchCaseStatement.h" +#include "ir/statements/switchStatement.h" +#include "ir/statements/tryStatement.h" +#include "ir/statements/throwStatement.h" +#include "ir/statements/whileStatement.h" + +#include "ir/as/namedType.h" +#include "ir/as/prefixAssertionExpression.h" #include namespace ark::es2panda::checker { @@ -575,6 +744,11 @@ checker::Type *ETSAnalyzer::Check(ir::ETSNewArrayInstanceExpression *expr) const return expr->TsType(); } +static bool TypeIsAllowedForInstantiation(checker::Type *type) +{ + return !(type->IsETSNullType() || type->IsETSUndefinedType() || type->IsETSNeverType() || type->IsETSVoidType()); +} + static checker::Type *CheckInstantiatedNewType(ETSChecker *checker, ir::ETSNewClassInstanceExpression *expr) { auto calleeType = expr->GetTypeRef()->Check(checker); @@ -583,7 +757,7 @@ static checker::Type *CheckInstantiatedNewType(ETSChecker *checker, ir::ETSNewCl if (calleeType->IsETSUnionType()) { return checker->TypeError(expr->GetTypeRef(), diagnostic::UNION_NONCONSTRUCTIBLE, expr->Start()); } - if (!ir::ETSNewClassInstanceExpression::TypeIsAllowedForInstantiation(calleeType)) { + if (!TypeIsAllowedForInstantiation(calleeType)) { return checker->TypeError(expr->GetTypeRef(), diagnostic::CALLEE_NONCONSTRUCTIBLE, {calleeType}, expr->Start()); } if (!calleeType->IsETSObjectType()) { @@ -4207,3 +4381,1006 @@ checker::Type *ETSAnalyzer::ReturnTypeForStatement([[maybe_unused]] const ir::St } } // namespace ark::es2panda::checker + +namespace ark::es2panda::ir { + +checker::VerifiedType PrefixAssertionExpression::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType NamedType::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType ClassStaticBlock::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType Decorator::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType ETSFunctionType::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType ETSUnionType::Check(checker::ETSChecker *checker) +{ + for (auto *it : Types()) { + it->Check(checker); + } + + return {this, GetType(checker)}; +} + +checker::VerifiedType ETSPackageDeclaration::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType ETSNewClassInstanceExpression::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType ETSClassLiteral::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType ETSTypeReferencePart::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType ETSPrimitiveType::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType ETSTypeReference::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType ETSNewMultiDimArrayInstanceExpression::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType ETSWildcardType::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType ETSNewArrayInstanceExpression::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TSUndefinedKeyword::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TSBooleanKeyword::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TSExternalModuleReference::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TSEnumMember::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TSStringKeyword::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TSNonNullExpression::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TSQualifiedName::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TSInterfaceDeclaration::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TSAnyKeyword::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TSVoidKeyword::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TSNumberKeyword::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TSUnknownKeyword::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TSArrayType::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType ImportDeclaration::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType ExportSpecifier::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType ImportDefaultSpecifier::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType ExportAllDeclaration::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType ExportDefaultDeclaration::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType ExportNamedDeclaration::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType ImportSpecifier::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType ImportNamespaceSpecifier::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType ThisExpression::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType ObjectExpression::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType BlockExpression::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType OmittedExpression::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType ChainExpression::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType ArrayExpression::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType MemberExpression::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType UpdateExpression::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType DirectEvalExpression::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType DummyNode::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType ClassExpression::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType AwaitExpression::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType BinaryExpression::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType ImportExpression::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType UnaryExpression::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType Identifier::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType SequenceExpression::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType UndefinedLiteral::Check(checker::ETSChecker *checker) +{ + SetTsType(checker->GlobalETSUndefinedType()); + return {this, TsType()}; +} + +checker::VerifiedType NumberLiteral::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType StringLiteral::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType NullLiteral::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType RegExpLiteral::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TypeofExpression::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType NewExpression::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType CallExpression::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType ArrowFunctionExpression::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType ConditionalExpression::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType CatchClause::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType ClassDefinition::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TSSignatureDeclaration::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TSMethodSignature::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType MetaProperty::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType ClassProperty::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType Property::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType SwitchStatement::Check(checker::ETSChecker *const checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TSAsExpression::Check(checker::ETSChecker *const checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TSEnumDeclaration::Check(checker::ETSChecker *const checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TSPropertySignature::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TSIndexSignature::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TemplateElement::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType MethodDefinition::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType ScriptFunction::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType ReturnStatement::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType FunctionDeclaration::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType AnnotationUsage::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType AnnotationDeclaration::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType ForUpdateStatement::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType LabelledStatement::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType ExpressionStatement::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType EmptyStatement::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType DebuggerStatement::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType ForOfStatement::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType ForInStatement::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType ContinueStatement::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType SwitchCaseStatement::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType VariableDeclarator::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType DoWhileStatement::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType ClassDeclaration::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType BreakStatement::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType ETSStructDeclaration::Check(checker::ETSChecker *checker) +{ + ES2PANDA_ASSERT(checker->IsAnyError()); + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType ETSNeverType::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType ETSUndefinedType::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType ETSNullType::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType ETSNonNullishTypeNode::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType ETSStringLiteralType::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType ETSKeyofType::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TSConditionalType::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TSMappedType::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TSTypePredicate::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TSTypeAssertion::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TSParenthesizedType::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TSTypeParameter::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TSTypeParameterDeclaration::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TSTypeAliasDeclaration::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TSInterfaceBody::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TSThisType::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TSConstructorType::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TSIndexedAccessType::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TSTypeOperator::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TSParameterProperty::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TSInferType::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TSTypeLiteral::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TSTypeReference::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TSBigintKeyword::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TSModuleBlock::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TSNullKeyword::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TSTypeParameterInstantiation::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TSTupleType::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TSLiteralType::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TSNamedTupleMember::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TSNeverKeyword::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TSObjectKeyword::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TSImportEqualsDeclaration::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TSInterfaceHeritage::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TSTypeQuery::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TSFunctionType::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TSIntersectionType::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TSModuleDeclaration::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TSClassImplements::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TSUnionType::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TSImportType::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType BrokenTypeNode::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType AssignmentExpression::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType FunctionExpression::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType YieldExpression::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TemplateLiteral::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType SuperExpression::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TaggedTemplateExpression::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType BooleanLiteral::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType BigIntLiteral::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType CharLiteral::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType SpreadElement::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType OverloadDeclaration::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType VariableDeclaration::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType AssertStatement::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType TryStatement::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType WhileStatement::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType BlockStatement::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType ThrowStatement::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType LoopStatement::Check([[maybe_unused]] checker::ETSChecker *checker) +{ + ES2PANDA_UNREACHABLE(); +} + +checker::VerifiedType IfStatement::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType OpaqueTypeNode::Check(checker::ETSChecker *checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +checker::VerifiedType ETSParameterExpression::Check(checker::ETSChecker *const checker) +{ + return {this, checker->GetAnalyzer()->Check(this)}; +} + +// NOTE(dkofanov): 'GetType' methods should be removed: + +checker::Type *ETSNonNullishTypeNode::GetType(checker::ETSChecker *checker) +{ + return TsType() != nullptr ? TsType() : Check(checker); +} + +checker::Type *ETSWildcardType::GetType([[maybe_unused]] checker::ETSChecker *checker) +{ + return checker->GlobalWildcardType(); +} + +checker::Type *BrokenTypeNode::GetType([[maybe_unused]] checker::ETSChecker *checker) +{ + return checker->GlobalTypeError(); +} + +checker::Type *OpaqueTypeNode::GetType([[maybe_unused]] checker::ETSChecker *checker) +{ + return TsType(); +} + +checker::Type *ETSFunctionType::GetType(checker::ETSChecker *checker) +{ + return Check(checker); +} + +checker::Type *ETSPrimitiveType::GetType([[maybe_unused]] checker::ETSChecker *checker) +{ + switch (GetPrimitiveType()) { + case PrimitiveType::BYTE: { + SetTsType(checker->GlobalByteBuiltinType()); + return TsType(); + } + case PrimitiveType::SHORT: { + SetTsType(checker->GlobalShortBuiltinType()); + return TsType(); + } + case PrimitiveType::INT: { + SetTsType(checker->GlobalIntBuiltinType()); + return TsType(); + } + case PrimitiveType::LONG: { + SetTsType(checker->GlobalLongBuiltinType()); + return TsType(); + } + case PrimitiveType::FLOAT: { + SetTsType(checker->GlobalFloatBuiltinType()); + return TsType(); + } + case PrimitiveType::DOUBLE: { + SetTsType(checker->GlobalDoubleBuiltinType()); + return TsType(); + } + case PrimitiveType::BOOLEAN: { + SetTsType(checker->GlobalETSBooleanBuiltinType()); + return TsType(); + } + case PrimitiveType::CHAR: { + SetTsType(checker->GlobalCharBuiltinType()); + return TsType(); + } + case PrimitiveType::VOID: { + if (LIKELY(checker->CheckVoidAnnotation(this))) { + SetTsType(checker->GlobalVoidType()); + return TsType(); + } + + return checker->InvalidateType(this); + } + default: { + ES2PANDA_UNREACHABLE(); + } + } +} + +checker::Type *TSArrayType::GetType(checker::ETSChecker *checker) +{ + checker::Type *type = checker->CreateETSArrayType(elementType_->GetType(checker), IsReadonlyType()); + if (IsReadonlyType()) { + type = checker->GetReadonlyType(type); + } + SetTsType(type); + return type; +} + +checker::Type *TSIntersectionType::GetType([[maybe_unused]] checker::ETSChecker *checker) +{ + // NOTE: validate + return checker->GlobalETSObjectType(); +} + +checker::Type *TSThisType::GetType([[maybe_unused]] checker::ETSChecker *checker) +{ + auto *containingClass = checker->Context().ContainingClass(); + if (containingClass == nullptr) { + return checker->GlobalTypeError(); + } + return containingClass; +} + +checker::Type *ETSKeyofType::GetType(checker::ETSChecker *checker) +{ + if (TsType() != nullptr) { + return TsType(); + } + + auto *typeReference = type_->GetType(checker); + ES2PANDA_ASSERT(typeReference); + + if (typeReference->IsETSPrimitiveType()) { + typeReference = checker->MaybeBoxType(typeReference); + } + + if (!typeReference->IsETSObjectType()) { + checker->LogError(diagnostic::KEYOF_REFERENCE_TYPE, {}, Start()); + SetTsType(checker->GlobalTypeError()); + return checker->GlobalTypeError(); + } + + checker::TypeStackElement tse(checker, GetHistoryNode(), {{diagnostic::CYCLIC_TYPE_OF, {}}}, Start()); + if (tse.HasTypeError()) { + return checker->GlobalTypeError(); + } + + SetTsType(checker->CreateUnionFromKeyofType(typeReference->AsETSObjectType())); + return TsType(); +} + +checker::Type *ETSUndefinedType::GetType([[maybe_unused]] checker::ETSChecker *checker) +{ + SetTsType(checker->GlobalETSUndefinedType()); + return TsType(); +} + +checker::Type *ETSNullType::GetType([[maybe_unused]] checker::ETSChecker *checker) +{ + SetTsType(checker->GlobalETSNullType()); + return TsType(); +} + +checker::Type *ETSTypeReference::GetType(checker::ETSChecker *checker) +{ + if (TsType() != nullptr) { + return TsType(); + } + auto *type = Part()->GetType(checker); + if (IsReadonlyType()) { + type = checker->GetReadonlyType(type); + } + return SetTsType(type); +} + +static bool CheckConstituentTypesValid(ArenaVector const &constituentTypes) +{ + for (auto &it : constituentTypes) { + if (it->IsTypeError()) { + return false; + } + } + return true; +} + +checker::Type *ETSUnionType::GetType(checker::ETSChecker *checker) +{ + if (TsType() != nullptr) { + return TsType(); + } + checker->CheckAnnotations(this); + + ArenaVector types(checker->Allocator()->Adapter()); + + for (auto *it : Types()) { + types.push_back(it->GetType(checker)); + } + + checker->Relation()->SetNode(this); + if (!CheckConstituentTypesValid(types)) { + SetTsType(checker->GlobalTypeError()); + } else { + SetTsType(checker->CreateETSUnionType(std::move(types))); + } + checker->Relation()->SetNode(nullptr); + return TsType(); +} + +checker::Type *ETSStringLiteralType::GetType([[maybe_unused]] checker::ETSChecker *checker) +{ + SetTsType(checker->CreateETSStringLiteralType(value_)); + return TsType(); +} + +checker::Type *ETSNeverType::GetType([[maybe_unused]] checker::ETSChecker *checker) +{ + SetTsType(checker->GlobalETSNeverType()); + return TsType(); +} + +} // namespace ark::es2panda::ir diff --git a/ets2panda/checker/ETSAnalyzerHelpers.cpp b/ets2panda/checker/ETSAnalyzerHelpers.cpp index 7df2adc15cb3d0a2748d41d6fe5004e0b19b16ec..8e3115bdd5cf1aae3e63a97c0d2b755defdd79cd 100644 --- a/ets2panda/checker/ETSAnalyzerHelpers.cpp +++ b/ets2panda/checker/ETSAnalyzerHelpers.cpp @@ -15,8 +15,34 @@ #include "ETSAnalyzerHelpers.h" #include "checker/types/ets/etsAsyncFuncReturnType.h" +#include "checker/types/ets/etsFunctionType.h" +#include "checker/types/ets/etsTypeParameter.h" +#include "checker/types/ets/etsUnionType.h" +#include "checker/types/ets/etsExtensionFuncHelperType.h" #include "checker/types/typeError.h" +#include "ir/typeNode.h" +#include "ir/base/methodDefinition.h" +#include "ir/base/classProperty.h" + +#include "ir/expressions/assignmentExpression.h" +#include "ir/expressions/callExpression.h" +#include "ir/expressions/unaryExpression.h" +#include "ir/expressions/memberExpression.h" +#include "ir/expressions/objectExpression.h" +#include "ir/expressions/literals/booleanLiteral.h" +#include "ir/expressions/literals/bigIntLiteral.h" +#include "ir/expressions/literals/charLiteral.h" +#include "ir/expressions/literals/numberLiteral.h" + +#include "ir/statements/forOfStatement.h" +#include "ir/statements/variableDeclaration.h" +#include "ir/statements/variableDeclarator.h" + +#include "ir/ets/etsTypeReference.h" +#include "ir/ets/etsTypeReferencePart.h" +#include "ir/ets/etsModule.h" + namespace ark::es2panda::checker { static bool IsValidReceiverParameter(Type *const thisType) diff --git a/ets2panda/checker/ETSAnalyzerUnreachable.cpp b/ets2panda/checker/ETSAnalyzerUnreachable.cpp index f0c54c5924a652d64c423ffd410dab66ffa7ed0d..c917d664d08aa09b94bf6307ada6a911c400db27 100644 --- a/ets2panda/checker/ETSAnalyzerUnreachable.cpp +++ b/ets2panda/checker/ETSAnalyzerUnreachable.cpp @@ -15,6 +15,10 @@ #include "ETSAnalyzer.h" +#include "ir/statements/forInStatement.h" + +#include "ir/ts/tsThisType.h" + namespace ark::es2panda::checker { // from as folder diff --git a/ets2panda/checker/ETSchecker.cpp b/ets2panda/checker/ETSchecker.cpp index 826fef60b2566d14fc5fb7724748855104fe9776..c1489dc70f9fdd1ee7e8ac91f8c4554591663ac3 100644 --- a/ets2panda/checker/ETSchecker.cpp +++ b/ets2panda/checker/ETSchecker.cpp @@ -20,23 +20,24 @@ #include "ETSchecker.h" #include "es2panda.h" +#include "ir/base/property.h" #include "ir/base/classDefinition.h" #include "ir/expression.h" #include "ir/expressions/callExpression.h" #include "ir/ts/tsInterfaceDeclaration.h" #include "ir/statements/blockStatement.h" #include "types/type.h" -#include "libarkbase/utils/arena_containers.h" #include "varbinder/ETSBinder.h" #include "parser/program/program.h" #include "checker/ets/aliveAnalyzer.h" #include "checker/ets/assignAnalyzer.h" #include "checker/ets/etsWarningAnalyzer.h" #include "checker/types/globalTypesHolder.h" +#include "checker/types/ets/etsObjectType.h" +#include "checker/types/ets/etsTupleType.h" #include "ir/base/scriptFunction.h" #include "util/helpers.h" #include "evaluate/scopedDebugInfoPlugin.h" -#include "checker/types/ets/etsTupleType.h" namespace ark::es2panda::checker { diff --git a/ets2panda/checker/ETSchecker.h b/ets2panda/checker/ETSchecker.h index 621a001d0b3e89e9c4912388f6d2b08e55743dad..1bcc0b08c2e4be1ddeed46ab3ef71ac9073b5efd 100644 --- a/ets2panda/checker/ETSchecker.h +++ b/ets2panda/checker/ETSchecker.h @@ -16,18 +16,22 @@ #ifndef ES2PANDA_CHECKER_ETS_CHECKER_H #define ES2PANDA_CHECKER_ETS_CHECKER_H -#include #include +#include #include "checker/checker.h" #include "checker/types/globalTypesHolder.h" -#include "checker/types/ets/etsResizableArrayType.h" +#include "checker/types/ets/etsObjectTypeConstants.h" #include "checker/types/ets/types.h" #include "checker/resolveResult.h" #include "ir/visitor/AstVisitor.h" +#include "ir/annotationAllowed.h" #include "types/type.h" #include "util/helpers.h" +#include "libarkbase/utils/arena_unordered_map.h" +#include "libarkbase/utils/arena_unordered_set.h" +#include "libarkbase/utils/arena_set.h" namespace ark::es2panda::varbinder { class VarBinder; diff --git a/ets2panda/checker/SemanticAnalyzer.h b/ets2panda/checker/SemanticAnalyzer.h index 1126ba93c03b19140c9f8c2a5b66671fcfd2a0d1..a373385b117a5d437e196152383e94c0fec4e4bd 100644 --- a/ets2panda/checker/SemanticAnalyzer.h +++ b/ets2panda/checker/SemanticAnalyzer.h @@ -17,160 +17,8 @@ #define ES2PANDA_CHECKER_SEMANTICANALYZER_H #include "compiler/core/dynamicContext.h" -#include "ir/opaqueTypeNode.h" -#include "ir/as/namedType.h" -#include "ir/as/prefixAssertionExpression.h" -#include "ir/base/catchClause.h" -#include "ir/base/classDefinition.h" -#include "ir/base/classProperty.h" -#include "ir/base/classStaticBlock.h" -#include "ir/base/decorator.h" -#include "ir/base/metaProperty.h" -#include "ir/base/methodDefinition.h" -#include "ir/base/overloadDeclaration.h" -#include "ir/base/property.h" -#include "ir/base/scriptFunction.h" -#include "ir/base/spreadElement.h" -#include "ir/base/templateElement.h" -#include "ir/base/tsIndexSignature.h" -#include "ir/base/tsMethodSignature.h" -#include "ir/base/tsPropertySignature.h" -#include "ir/base/tsSignatureDeclaration.h" -#include "ir/ets/etsClassLiteral.h" -#include "ir/ets/etsFunctionType.h" -#include "ir/ets/etsIntrinsicNode.h" -#include "ir/ets/etsImportDeclaration.h" -#include "ir/ets/etsKeyofType.h" -#include "ir/ets/etsNewArrayInstanceExpression.h" -#include "ir/ets/etsNewClassInstanceExpression.h" -#include "ir/ets/etsNewMultiDimArrayInstanceExpression.h" -#include "ir/ets/etsPackageDeclaration.h" -#include "ir/ets/etsParameterExpression.h" -#include "ir/ets/etsPrimitiveType.h" -#include "ir/ets/etsModule.h" -#include "ir/ets/etsStringLiteralType.h" -#include "ir/ets/etsNeverType.h" -#include "ir/ets/etsNonNullishTypeNode.h" -#include "ir/ets/etsNullishTypes.h" -#include "ir/ets/etsStructDeclaration.h" -#include "ir/ets/etsTypeReference.h" -#include "ir/ets/etsTypeReferencePart.h" -#include "ir/ets/etsWildcardType.h" -#include "ir/expressions/arrayExpression.h" -#include "ir/expressions/arrowFunctionExpression.h" -#include "ir/expressions/assignmentExpression.h" -#include "ir/expressions/awaitExpression.h" -#include "ir/expressions/binaryExpression.h" -#include "ir/expressions/blockExpression.h" -#include "ir/expressions/callExpression.h" -#include "ir/expressions/chainExpression.h" -#include "ir/expressions/classExpression.h" -#include "ir/expressions/conditionalExpression.h" -#include "ir/expressions/directEvalExpression.h" -#include "ir/expressions/functionExpression.h" -#include "ir/expressions/identifier.h" -#include "ir/expressions/importExpression.h" -#include "ir/expressions/memberExpression.h" -#include "ir/expressions/newExpression.h" -#include "ir/expressions/objectExpression.h" -#include "ir/expressions/omittedExpression.h" -#include "ir/expressions/sequenceExpression.h" -#include "ir/expressions/superExpression.h" -#include "ir/expressions/taggedTemplateExpression.h" -#include "ir/expressions/templateLiteral.h" -#include "ir/expressions/thisExpression.h" -#include "ir/expressions/typeofExpression.h" -#include "ir/expressions/unaryExpression.h" -#include "ir/expressions/updateExpression.h" -#include "ir/expressions/yieldExpression.h" -#include "ir/expressions/literals/bigIntLiteral.h" -#include "ir/expressions/literals/booleanLiteral.h" -#include "ir/expressions/literals/charLiteral.h" -#include "ir/expressions/literals/nullLiteral.h" -#include "ir/expressions/literals/numberLiteral.h" -#include "ir/expressions/literals/regExpLiteral.h" -#include "ir/expressions/literals/stringLiteral.h" -#include "ir/module/exportAllDeclaration.h" -#include "ir/module/exportDefaultDeclaration.h" -#include "ir/module/exportNamedDeclaration.h" -#include "ir/module/exportSpecifier.h" -#include "ir/module/importDeclaration.h" -#include "ir/module/importDefaultSpecifier.h" -#include "ir/module/importNamespaceSpecifier.h" -#include "ir/module/importSpecifier.h" -#include "ir/statements/assertStatement.h" -#include "ir/statements/blockStatement.h" -#include "ir/statements/breakStatement.h" -#include "ir/statements/classDeclaration.h" -#include "ir/statements/continueStatement.h" -#include "ir/statements/debuggerStatement.h" -#include "ir/statements/doWhileStatement.h" -#include "ir/statements/emptyStatement.h" -#include "ir/statements/expressionStatement.h" -#include "ir/statements/forInStatement.h" -#include "ir/statements/forOfStatement.h" -#include "ir/statements/forUpdateStatement.h" -#include "ir/statements/functionDeclaration.h" -#include "ir/statements/ifStatement.h" -#include "ir/statements/labelledStatement.h" -#include "ir/statements/returnStatement.h" -#include "ir/statements/switchCaseStatement.h" -#include "ir/statements/switchStatement.h" -#include "ir/statements/throwStatement.h" -#include "ir/statements/tryStatement.h" -#include "ir/statements/variableDeclaration.h" -#include "ir/statements/variableDeclarator.h" -#include "ir/statements/whileStatement.h" -#include "ir/ts/tsAnyKeyword.h" -#include "ir/ts/tsArrayType.h" -#include "ir/ts/tsAsExpression.h" -#include "ir/ts/tsBigintKeyword.h" -#include "ir/ts/tsBooleanKeyword.h" -#include "ir/ts/tsClassImplements.h" -#include "ir/ts/tsConditionalType.h" -#include "ir/ts/tsConstructorType.h" -#include "ir/ts/tsEnumDeclaration.h" -#include "ir/ts/tsEnumMember.h" -#include "ir/ts/tsExternalModuleReference.h" -#include "ir/ts/tsFunctionType.h" -#include "ir/ts/tsImportEqualsDeclaration.h" -#include "ir/ts/tsImportType.h" -#include "ir/ts/tsIndexedAccessType.h" -#include "ir/ts/tsInferType.h" -#include "ir/ts/tsInterfaceBody.h" -#include "ir/ts/tsInterfaceDeclaration.h" -#include "ir/ts/tsInterfaceHeritage.h" -#include "ir/ts/tsIntersectionType.h" -#include "ir/ts/tsLiteralType.h" -#include "ir/ts/tsMappedType.h" -#include "ir/ts/tsModuleBlock.h" -#include "ir/ts/tsModuleDeclaration.h" -#include "ir/ts/tsNamedTupleMember.h" -#include "ir/ts/tsNeverKeyword.h" -#include "ir/ts/tsNonNullExpression.h" -#include "ir/ts/tsNullKeyword.h" -#include "ir/ts/tsNumberKeyword.h" -#include "ir/ts/tsObjectKeyword.h" -#include "ir/ts/tsParameterProperty.h" -#include "ir/ts/tsParenthesizedType.h" -#include "ir/ts/tsQualifiedName.h" -#include "ir/ts/tsStringKeyword.h" -#include "ir/ts/tsThisType.h" -#include "ir/ts/tsTupleType.h" -#include "ir/ts/tsTypeAliasDeclaration.h" -#include "ir/ts/tsTypeAssertion.h" -#include "ir/ts/tsTypeLiteral.h" -#include "ir/ts/tsTypeOperator.h" -#include "ir/ts/tsTypeParameterDeclaration.h" -#include "ir/ts/tsTypeParameter.h" -#include "ir/ts/tsTypeParameterInstantiation.h" -#include "ir/ts/tsTypePredicate.h" -#include "ir/ts/tsTypeQuery.h" -#include "ir/ts/tsTypeReference.h" -#include "ir/ts/tsUndefinedKeyword.h" -#include "ir/ts/tsUnionType.h" -#include "ir/ts/tsUnknownKeyword.h" -#include "ir/ts/tsVoidKeyword.h" +#include "ir/astNodeMapping.h" +#include "checker/types/ets/types.h" namespace ark::es2panda::checker { class Checker; diff --git a/ets2panda/checker/TSAnalyzer.cpp b/ets2panda/checker/TSAnalyzer.cpp index 655c154d5f62250d0c9fb34c1864a88a80a7bb09..61ec23860b6f2f6fcfebb9454213a52e861685f9 100644 --- a/ets2panda/checker/TSAnalyzer.cpp +++ b/ets2panda/checker/TSAnalyzer.cpp @@ -18,6 +18,169 @@ #include "checker/TSchecker.h" #include "checker/ts/destructuringContext.h" +#include "ir/brokenTypeNode.h" +#include "ir/opaqueTypeNode.h" +#include "ir/annotationAllowed.h" + +#include "ir/module/exportAllDeclaration.h" +#include "ir/module/exportDefaultDeclaration.h" +#include "ir/module/exportNamedDeclaration.h" +#include "ir/module/exportSpecifier.h" +#include "ir/module/importDefaultSpecifier.h" +#include "ir/module/importNamespaceSpecifier.h" + +#include "ir/ets/etsClassLiteral.h" +#include "ir/ets/etsStructDeclaration.h" +#include "ir/ets/etsIntrinsicNode.h" +#include "ir/ets/etsUnionType.h" +#include "ir/ets/etsStringLiteralType.h" +#include "ir/ets/etsTuple.h" +#include "ir/ets/etsTypeReference.h" +#include "ir/ets/etsTypeReferencePart.h" +#include "ir/ets/etsNeverType.h" +#include "ir/ets/etsNullishTypes.h" +#include "ir/ets/etsReExportDeclaration.h" +#include "ir/ets/etsNewArrayInstanceExpression.h" +#include "ir/ets/etsNewMultiDimArrayInstanceExpression.h" +#include "ir/ets/etsNewClassInstanceExpression.h" +#include "ir/ets/etsFunctionType.h" +#include "ir/ets/etsNonNullishTypeNode.h" +#include "ir/ets/etsPackageDeclaration.h" +#include "ir/ets/etsPrimitiveType.h" +#include "ir/ets/etsWildcardType.h" +#include "ir/ets/etsKeyofType.h" +#include "ir/ets/etsModule.h" + +#include "ir/ts/tsAsExpression.h" +#include "ir/ts/tsEnumDeclaration.h" +#include "ir/ts/tsEnumMember.h" +#include "ir/ts/tsExternalModuleReference.h" +#include "ir/ts/tsNonNullExpression.h" +#include "ir/ts/tsTypeAssertion.h" +#include "ir/ts/tsAnyKeyword.h" +#include "ir/ts/tsArrayType.h" +#include "ir/ts/tsBigintKeyword.h" +#include "ir/ts/tsBooleanKeyword.h" +#include "ir/ts/tsLiteralType.h" +#include "ir/ts/tsNeverKeyword.h" +#include "ir/ts/tsNullKeyword.h" +#include "ir/ts/tsNumberKeyword.h" +#include "ir/ts/tsObjectKeyword.h" +#include "ir/ts/tsParenthesizedType.h" +#include "ir/ts/tsStringKeyword.h" +#include "ir/ts/tsTypeLiteral.h" +#include "ir/ts/tsUndefinedKeyword.h" +#include "ir/ts/tsUnionType.h" +#include "ir/ts/tsUnknownKeyword.h" +#include "ir/ts/tsVoidKeyword.h" +#include "ir/ts/tsConditionalType.h" +#include "ir/ts/tsConstructorType.h" +#include "ir/ts/tsFunctionType.h" +#include "ir/ts/tsImportEqualsDeclaration.h" +#include "ir/ts/tsImportType.h" +#include "ir/ts/tsInferType.h" +#include "ir/ts/tsIntersectionType.h" +#include "ir/ts/tsMappedType.h" +#include "ir/ts/tsModuleBlock.h" +#include "ir/ts/tsModuleDeclaration.h" +#include "ir/ts/tsParameterProperty.h" +#include "ir/ts/tsThisType.h" +#include "ir/ts/tsTypeAliasDeclaration.h" +#include "ir/ts/tsTypeOperator.h" +#include "ir/ts/tsTypeParameter.h" +#include "ir/ts/tsTypeParameterDeclaration.h" +#include "ir/ts/tsTypeParameterInstantiation.h" +#include "ir/ts/tsTypePredicate.h" +#include "ir/ts/tsTypeReference.h" +#include "ir/ts/tsClassImplements.h" +#include "ir/ts/tsIndexedAccessType.h" +#include "ir/ts/tsInterfaceBody.h" +#include "ir/ts/tsInterfaceDeclaration.h" +#include "ir/ts/tsInterfaceHeritage.h" +#include "ir/ts/tsNamedTupleMember.h" +#include "ir/ts/tsQualifiedName.h" +#include "ir/ts/tsTupleType.h" +#include "ir/ts/tsTypeQuery.h" + +#include "ir/base/spreadElement.h" +#include "ir/base/scriptFunction.h" +#include "ir/base/catchClause.h" +#include "ir/base/classDefinition.h" +#include "ir/base/classProperty.h" +#include "ir/base/classStaticBlock.h" +#include "ir/base/decorator.h" +#include "ir/base/methodDefinition.h" +#include "ir/base/metaProperty.h" +#include "ir/base/overloadDeclaration.h" +#include "ir/base/property.h" +#include "ir/base/tsMethodSignature.h" +#include "ir/base/tsPropertySignature.h" +#include "ir/base/tsSignatureDeclaration.h" +#include "ir/base/tsIndexSignature.h" + +#include "ir/expressions/assignmentExpression.h" +#include "ir/expressions/taggedTemplateExpression.h" +#include "ir/expressions/typeofExpression.h" +#include "ir/expressions/unaryExpression.h" +#include "ir/expressions/updateExpression.h" +#include "ir/expressions/yieldExpression.h" + +#include "ir/expressions/arrowFunctionExpression.h" +#include "ir/expressions/arrayExpression.h" +#include "ir/expressions/objectExpression.h" +#include "ir/expressions/sequenceExpression.h" +#include "ir/expressions/templateLiteral.h" +#include "ir/expressions/functionExpression.h" +#include "ir/expressions/awaitExpression.h" +#include "ir/expressions/binaryExpression.h" +#include "ir/expressions/callExpression.h" +#include "ir/expressions/classExpression.h" +#include "ir/expressions/chainExpression.h" +#include "ir/expressions/identifier.h" +#include "ir/expressions/importExpression.h" +#include "ir/expressions/dummyNode.h" +#include "ir/expressions/directEvalExpression.h" +#include "ir/expressions/blockExpression.h" +#include "ir/expressions/conditionalExpression.h" +#include "ir/expressions/thisExpression.h" +#include "ir/expressions/literals/undefinedLiteral.h" +#include "ir/expressions/literals/bigIntLiteral.h" +#include "ir/expressions/literals/booleanLiteral.h" +#include "ir/expressions/literals/charLiteral.h" +#include "ir/expressions/literals/nullLiteral.h" +#include "ir/expressions/literals/numberLiteral.h" +#include "ir/expressions/literals/regExpLiteral.h" +#include "ir/expressions/memberExpression.h" +#include "ir/expressions/newExpression.h" +#include "ir/expressions/omittedExpression.h" +#include "ir/expressions/superExpression.h" + +#include "ir/statements/assertStatement.h" +#include "ir/statements/annotationDeclaration.h" +#include "ir/statements/breakStatement.h" +#include "ir/statements/blockStatement.h" +#include "ir/statements/continueStatement.h" +#include "ir/statements/debuggerStatement.h" +#include "ir/statements/doWhileStatement.h" +#include "ir/statements/emptyStatement.h" +#include "ir/statements/expressionStatement.h" +#include "ir/statements/forInStatement.h" +#include "ir/statements/forOfStatement.h" +#include "ir/statements/forUpdateStatement.h" +#include "ir/statements/labelledStatement.h" +#include "ir/statements/functionDeclaration.h" +#include "ir/statements/ifStatement.h" +#include "ir/statements/variableDeclaration.h" +#include "ir/statements/variableDeclarator.h" +#include "ir/statements/switchCaseStatement.h" +#include "ir/statements/switchStatement.h" +#include "ir/statements/tryStatement.h" +#include "ir/statements/throwStatement.h" +#include "ir/statements/whileStatement.h" + +#include "ir/as/namedType.h" +#include "ir/as/prefixAssertionExpression.h" + namespace ark::es2panda::checker { TSChecker *TSAnalyzer::GetTSChecker() const @@ -2123,4 +2286,973 @@ checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::TSVoidKeyword *node) const { return nullptr; } + } // namespace ark::es2panda::checker + +namespace ark::es2panda::ir { + +checker::Type *PrefixAssertionExpression::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *NamedType::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *ETSIntrinsicNode::Check([[maybe_unused]] checker::TSChecker *checker) +{ + return nullptr; +} + +checker::Type *ETSFunctionType::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *ETSUnionType::Check([[maybe_unused]] checker::TSChecker *checker) +{ + return nullptr; +} + +checker::Type *ETSPackageDeclaration::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *ETSNewClassInstanceExpression::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *ETSClassLiteral::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *ETSStructDeclaration::Check([[maybe_unused]] checker::TSChecker *checker) +{ + ES2PANDA_UNREACHABLE(); +} + +checker::Type *ETSNeverType::Check([[maybe_unused]] checker::TSChecker *checker) +{ + ES2PANDA_UNREACHABLE(); +} + +checker::Type *ETSUndefinedType::Check([[maybe_unused]] checker::TSChecker *checker) +{ + ES2PANDA_UNREACHABLE(); +} + +checker::Type *ETSNullType::Check([[maybe_unused]] checker::TSChecker *checker) +{ + ES2PANDA_UNREACHABLE(); +} + +checker::Type *ETSTypeReferencePart::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *ETSPrimitiveType::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *ETSTypeReference::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *ETSNewMultiDimArrayInstanceExpression::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *ETSWildcardType::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *ETSNonNullishTypeNode::Check([[maybe_unused]] checker::TSChecker *checker) +{ + ES2PANDA_UNREACHABLE(); +} + +checker::Type *ETSStringLiteralType::Check([[maybe_unused]] checker::TSChecker *checker) +{ + ES2PANDA_UNREACHABLE(); +} + +checker::Type *ETSNewArrayInstanceExpression::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *ETSKeyofType::Check([[maybe_unused]] checker::TSChecker *checker) +{ + return nullptr; +} + +checker::Type *TSUndefinedKeyword::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TSBooleanKeyword::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TSConditionalType::Check([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TSExternalModuleReference::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TSMappedType::Check([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TSTypePredicate::Check([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TSTypeAssertion::Check([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TSParenthesizedType::Check([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TSTypeParameter::Check([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TSEnumMember::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TSTypeParameterDeclaration::Check([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TSStringKeyword::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TSTypeAliasDeclaration::Check([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TSNonNullExpression::Check([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TSInterfaceBody::Check([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TSThisType::Check([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TSConstructorType::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TSIndexedAccessType::Check([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TSEnumDeclaration::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TSTypeOperator::Check([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TSParameterProperty::Check([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TSQualifiedName::Check([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TSInterfaceDeclaration::Check([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TSInferType::Check([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TSTypeLiteral::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TSTypeReference::Check([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TSAnyKeyword::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TSBigintKeyword::Check([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TSModuleBlock::Check([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TSNullKeyword::Check([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TSTypeParameterInstantiation::Check([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TSTupleType::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TSVoidKeyword::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TSLiteralType::Check([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TSNamedTupleMember::Check([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TSAsExpression::Check([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TSNeverKeyword::Check([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TSObjectKeyword::Check([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TSImportEqualsDeclaration::Check([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TSInterfaceHeritage::Check([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TSTypeQuery::Check([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TSFunctionType::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TSIntersectionType::Check([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TSNumberKeyword::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TSModuleDeclaration::Check([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TSClassImplements::Check([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TSUnionType::Check([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TSUnknownKeyword::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TSArrayType::Check([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TSImportType::Check([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *ImportDeclaration::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *ExportSpecifier::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *ImportDefaultSpecifier::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *ExportAllDeclaration::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *ExportDefaultDeclaration::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *ExportNamedDeclaration::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *ImportSpecifier::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *ImportNamespaceSpecifier::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *BrokenTypeNode::Check([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *ThisExpression::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *AssignmentExpression::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *ObjectExpression::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *FunctionExpression::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *BlockExpression::Check([[maybe_unused]] checker::TSChecker *checker) +{ + ES2PANDA_UNREACHABLE(); +} + +checker::Type *OmittedExpression::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *ChainExpression::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *ArrayExpression::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *MemberExpression::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *UpdateExpression::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *DirectEvalExpression::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *DummyNode::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *YieldExpression::Check([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *ClassExpression::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TemplateLiteral::Check([[maybe_unused]] checker::TSChecker *checker) +{ + // NOTE: aszilagyi. + return checker->GlobalAnyType(); +} + +checker::Type *AwaitExpression::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *BinaryExpression::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *SuperExpression::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *ImportExpression::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TaggedTemplateExpression::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *UnaryExpression::Check([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *Identifier::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *SequenceExpression::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *BooleanLiteral::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *UndefinedLiteral::Check(checker::TSChecker *checker) +{ + return checker->GlobalUndefinedType(); +} + +checker::Type *NumberLiteral::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *StringLiteral::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *BigIntLiteral::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *CharLiteral::Check([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *NullLiteral::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *RegExpLiteral::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TypeofExpression::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *NewExpression::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *CallExpression::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *ArrowFunctionExpression::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *ConditionalExpression::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *CatchClause::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *ClassDefinition::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TSSignatureDeclaration::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TSMethodSignature::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *SpreadElement::Check([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *Decorator::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *MetaProperty::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *ClassStaticBlock::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *OverloadDeclaration::Check([[maybe_unused]] checker::TSChecker *checker) +{ + return nullptr; +} + +checker::Type *ClassProperty::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *Property::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TSPropertySignature::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TSIndexSignature::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TemplateElement::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *MethodDefinition::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *ScriptFunction::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *ReturnStatement::Check([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *FunctionDeclaration::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *VariableDeclaration::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *SwitchStatement::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *AssertStatement::Check([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TryStatement::Check([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *AnnotationUsage::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *AnnotationDeclaration::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *ForUpdateStatement::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *LabelledStatement::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *ExpressionStatement::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *WhileStatement::Check([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *BlockStatement::Check([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *ThrowStatement::Check([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *EmptyStatement::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *DebuggerStatement::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *IfStatement::Check([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *ForOfStatement::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *ForInStatement::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *ContinueStatement::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *SwitchCaseStatement::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *VariableDeclarator::Check([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *DoWhileStatement::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *ClassDeclaration::Check(checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *BreakStatement::Check([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *OpaqueTypeNode::Check([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *ETSParameterExpression::Check(checker::TSChecker *const checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +// NOTE(dkofanov): 'GetType' methods should be removed: + +checker::Type *ETSPrimitiveType::GetType([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GlobalAnyType(); +} + +checker::Type *TSAnyKeyword::GetType([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GlobalAnyType(); +} + +checker::Type *TSArrayType::GetType([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->Allocator()->New(elementType_->GetType(checker)); +} + +checker::Type *TSBigintKeyword::GetType([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GlobalBigintType(); +} + +checker::Type *TSBooleanKeyword::GetType([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GlobalBooleanType(); +} + +checker::Type *TSIndexedAccessType::GetType([[maybe_unused]] checker::TSChecker *checker) +{ + if (TsType() != nullptr) { + return TsType(); + } + + checker::Type *baseType = objectType_->GetType(checker); + checker::Type *indexType = indexType_->GetType(checker); + checker::Type *resolved = checker->GetPropertyTypeForIndexType(baseType, indexType); + + SetTsType(resolved); + return TsType(); +} + +checker::Type *TSLiteralType::GetType([[maybe_unused]] checker::TSChecker *checker) +{ + if (TsType() != nullptr) { + return TsType(); + } + + SetTsType(literal_->Check(checker)); + return TsType(); +} + +checker::Type *TSNeverKeyword::GetType([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GlobalNeverType(); +} + +checker::Type *TSNullKeyword::GetType([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GlobalNullType(); +} + +checker::Type *TSNumberKeyword::GetType([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GlobalNumberType(); +} + +checker::Type *TSObjectKeyword::GetType([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GlobalNonPrimitiveType(); +} + +checker::Type *TSParenthesizedType::GetType([[maybe_unused]] checker::TSChecker *checker) +{ + if (TsType() != nullptr) { + return TsType(); + } + + SetTsType(type_->GetType(checker)); + return TsType(); +} + +checker::Type *TSStringKeyword::GetType([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GlobalStringType(); +} + +checker::Type *TSVoidKeyword::GetType([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GlobalVoidType(); +} + +checker::Type *TSTypeReference::GetType([[maybe_unused]] checker::TSChecker *checker) +{ + if (TsType() != nullptr) { + return TsType(); + } + + if (typeName_->IsTSQualifiedName()) { + return checker->GlobalAnyType(); + } + + ES2PANDA_ASSERT(typeName_->IsIdentifier()); + varbinder::Variable *var = typeName_->AsIdentifier()->Variable(); + + if (var == nullptr) { + checker->ThrowTypeError({"Cannot find name ", typeName_->AsIdentifier()->Name()}, Start()); + } + + SetTsType(checker->GetTypeReferenceType(this, var)); + return TsType(); +} + +checker::Type *TSUndefinedKeyword::GetType([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GlobalUndefinedType(); +} + +checker::Type *TSUnknownKeyword::GetType([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GlobalUnknownType(); +} + +checker::Type *TSTypeQuery::GetType([[maybe_unused]] checker::TSChecker *checker) +{ + return checker->GetAnalyzer()->Check(this); +} + +checker::Type *TSTypeLiteral::GetType(checker::TSChecker *checker) +{ + if (TsType() != nullptr) { + return TsType(); + } + + checker::ObjectDescriptor *desc = checker->Allocator()->New(checker->Allocator()); + checker::Type *type = checker->Allocator()->New(desc); + ES2PANDA_ASSERT(type != nullptr); + type->SetVariable(Variable()); + + SetTsType(type); + return TsType(); +} + +checker::Type *TSConstructorType::GetType(checker::TSChecker *checker) +{ + return checker->CheckTypeCached(this); +} + +checker::Type *TSUnionType::GetType(checker::TSChecker *checker) +{ + if (TsType() != nullptr) { + return TsType(); + } + + ArenaVector types(checker->Allocator()->Adapter()); + + for (auto *it : types_) { + types.push_back(it->GetType(checker)); + } + + SetTsType(checker->CreateUnionType(std::move(types))); + return TsType(); +} + +checker::Type *TSFunctionType::GetType(checker::TSChecker *checker) +{ + return checker->CheckTypeCached(this); +} + +} // namespace ark::es2panda::ir diff --git a/ets2panda/checker/checker.cpp b/ets2panda/checker/checker.cpp index ab4e17a2e079d1182cf78b6a0e32ecc6eedbaa1d..e55943e9ee099b574403fe7a07693835784438f2 100644 --- a/ets2panda/checker/checker.cpp +++ b/ets2panda/checker/checker.cpp @@ -18,6 +18,7 @@ #include "public/public.h" #include "checker/types/globalTypesHolder.h" #include "checker/types/ts/unionType.h" +#include "ir/ets/etsModule.h" namespace ark::es2panda::checker { Checker::Checker(ThreadSafeArenaAllocator *allocator, util::DiagnosticEngine &diagnosticEngine, diff --git a/ets2panda/checker/checker.h b/ets2panda/checker/checker.h index d7466fb0d418ece598f7f6319d2b61f1e64a4e9a..acc2db89b1e70b12e88e830d0b5d7433030f34d8 100644 --- a/ets2panda/checker/checker.h +++ b/ets2panda/checker/checker.h @@ -21,6 +21,8 @@ #include "checker/types/globalTypesHolder.h" #include "util/diagnosticEngine.h" +#include "varbinder/variable.h" + namespace ark::es2panda::util { class Options; } // namespace ark::es2panda::util diff --git a/ets2panda/checker/checkerContext.cpp b/ets2panda/checker/checkerContext.cpp index fa10d82fac4f1bb494e247289620832e0fec818f..a2e07df6a34f8d1b2cb446955fefe90e200f9dac 100644 --- a/ets2panda/checker/checkerContext.cpp +++ b/ets2panda/checker/checkerContext.cpp @@ -14,6 +14,18 @@ */ #include "ETSchecker.h" +#include "checker/types/ets/etsObjectType.h" + +#include "ir/expressions/assignmentExpression.h" +#include "ir/expressions/binaryExpression.h" +#include "ir/expressions/unaryExpression.h" + +#include "ir/statements/loopStatement.h" +#include "ir/statements/labelledStatement.h" +#include "ir/statements/blockStatement.h" +#include "ir/statements/breakStatement.h" +#include "ir/statements/switchStatement.h" +#include "ir/statements/whileStatement.h" namespace ark::es2panda::checker { diff --git a/ets2panda/checker/checkerContext.h b/ets2panda/checker/checkerContext.h index 1c3f8cb59cbc159b26305cd181952b77465ba865..af01cd6f5438821d659ba381bfde9396889ce5e6 100644 --- a/ets2panda/checker/checkerContext.h +++ b/ets2panda/checker/checkerContext.h @@ -20,6 +20,8 @@ #include "generated/tokenType.h" #include "lexer/token/sourceLocation.h" #include "util/enumbitops.h" +#include "libarkbase/utils/arena_map.h" +#include "libarkbase/utils/arena_unordered_map.h" namespace ark::es2panda::ir { class ArrowFunctionExpression; diff --git a/ets2panda/checker/ets/aliveAnalyzer.cpp b/ets2panda/checker/ets/aliveAnalyzer.cpp index e4edb04a7a1eadcccc752a94d25838480119604d..2748b5fd549f42fb9d6220dfd0989bcefe7cdc0e 100644 --- a/ets2panda/checker/ets/aliveAnalyzer.cpp +++ b/ets2panda/checker/ets/aliveAnalyzer.cpp @@ -49,6 +49,7 @@ #include "varbinder/variable.h" #include "varbinder/declaration.h" #include "checker/ETSchecker.h" +#include "checker/types/ets/etsFunctionType.h" #include "ir/base/catchClause.h" namespace ark::es2panda::checker { diff --git a/ets2panda/checker/ets/aliveAnalyzer.h b/ets2panda/checker/ets/aliveAnalyzer.h index 3effefc073a26ce8f7de7ec4429e563c47f3d2d3..088c03729c54996d158a2db673de8d9fe04d94f9 100644 --- a/ets2panda/checker/ets/aliveAnalyzer.h +++ b/ets2panda/checker/ets/aliveAnalyzer.h @@ -19,7 +19,6 @@ #include "checker/ETSchecker.h" #include "checker/ets/baseAnalyzer.h" -#include "libarkbase/utils/arena_containers.h" namespace ark::es2panda::ir { class AstNode; diff --git a/ets2panda/checker/ets/arithmetic.cpp b/ets2panda/checker/ets/arithmetic.cpp index cc7e14a1bbeb453976419d06e0a851947f1647bc..13ec44ef0402a45c7dbb1308f0a3bf904e3e09c9 100644 --- a/ets2panda/checker/ets/arithmetic.cpp +++ b/ets2panda/checker/ets/arithmetic.cpp @@ -17,8 +17,13 @@ #include "checker/types/globalTypesHolder.h" #include "checker/types/typeError.h" +#include "checker/types/ets/etsUnionType.h" #include "lexer/token/token.h" +#include "ir/typeNode.h" +#include "ir/expressions/literals/numberLiteral.h" +#include "ir/expressions/binaryExpression.h" + namespace ark::es2panda::checker { struct BinaryArithmOperands { diff --git a/ets2panda/checker/ets/assignAnalyzer.cpp b/ets2panda/checker/ets/assignAnalyzer.cpp index 2d39801012ab2d928b6e171f2a63d7393f3dfe36..bb0ced99e79e451a25f750387371df804275ea8f 100644 --- a/ets2panda/checker/ets/assignAnalyzer.cpp +++ b/ets2panda/checker/ets/assignAnalyzer.cpp @@ -15,6 +15,8 @@ #include "assignAnalyzer.h" +#include "ir/base/property.h" +#include "ir/base/catchClause.h" #include "ir/base/classDefinition.h" #include "ir/base/classProperty.h" #include "ir/base/classStaticBlock.h" @@ -57,9 +59,9 @@ #include "varbinder/scope.h" #include "varbinder/declaration.h" #include "checker/ETSchecker.h" -#include "ir/base/catchClause.h" +#include "checker/types/ets/etsObjectType.h" +#include "checker/types/ets/etsBooleanType.h" #include "parser/program/program.h" -#include "checker/types/ts/objectType.h" namespace ark::es2panda::checker { diff --git a/ets2panda/checker/ets/assignAnalyzer.h b/ets2panda/checker/ets/assignAnalyzer.h index 2abe70ed91b76cc368592d67bccb317a917cfaff..87215b5bb0a3ed00995823731ad6e247ea53a442 100644 --- a/ets2panda/checker/ets/assignAnalyzer.h +++ b/ets2panda/checker/ets/assignAnalyzer.h @@ -19,7 +19,6 @@ #include "checker/ETSchecker.h" #include "checker/ets/baseAnalyzer.h" -#include "libarkbase/utils/arena_containers.h" namespace ark::es2panda::ir { class AstNode; diff --git a/ets2panda/checker/ets/baseAnalyzer.h b/ets2panda/checker/ets/baseAnalyzer.h index 3a857963f74d5bf92335e19f4c25d1c81b0901ae..11f175a17dd8790e1b7bb09fdd2cd47907e80f83 100644 --- a/ets2panda/checker/ets/baseAnalyzer.h +++ b/ets2panda/checker/ets/baseAnalyzer.h @@ -16,9 +16,12 @@ #ifndef ES2PANDA_COMPILER_CHECKER_ETS_BASE_ANALYZER_H #define ES2PANDA_COMPILER_CHECKER_ETS_BASE_ANALYZER_H -#include "libarkbase/utils/arena_containers.h" +#include "libarkbase/macros.h" #include "util/enumbitops.h" +#include +#include + namespace ark::es2panda::ir { class AstNode; enum class AstNodeType : uint8_t; diff --git a/ets2panda/checker/ets/conversion.cpp b/ets2panda/checker/ets/conversion.cpp index 90c5d2f5be896c9e5a163c814e21236480cb8378..baa4aaa9f23d30e7fd1079e2446d8080c0b97284 100644 --- a/ets2panda/checker/ets/conversion.cpp +++ b/ets2panda/checker/ets/conversion.cpp @@ -20,6 +20,7 @@ #include "checker/ets/wideningConverter.h" #include "checker/types/ets/etsTupleType.h" #include "checker/types/globalTypesHolder.h" +#include "checker/types/ets/etsArrayType.h" namespace ark::es2panda::checker::conversion { void Identity(TypeRelation *const relation, Type *const source, Type *const target) diff --git a/ets2panda/checker/ets/etsWarningAnalyzer.cpp b/ets2panda/checker/ets/etsWarningAnalyzer.cpp index f207387c3f3d1c864cf618001ad783eeda5b3e71..011e8e66e32649b6a882773d59685deea0d335ec 100644 --- a/ets2panda/checker/ets/etsWarningAnalyzer.cpp +++ b/ets2panda/checker/ets/etsWarningAnalyzer.cpp @@ -34,6 +34,9 @@ #include "ir/base/classDefinition.h" #include "ir/statements/forOfStatement.h" #include "ir/statements/variableDeclarator.h" +#include "ir/ts/tsTypeAliasDeclaration.h" + +#include "checker/types/ets/etsObjectType.h" namespace ark::es2panda::checker { diff --git a/ets2panda/checker/ets/function.cpp b/ets2panda/checker/ets/function.cpp index 2643ee7f1b29e25283309e2b118bf9162aa1d565..c211afb7d87898480b9d7a171f538a14802b851b 100644 --- a/ets2panda/checker/ets/function.cpp +++ b/ets2panda/checker/ets/function.cpp @@ -15,8 +15,12 @@ #include +#include "checker/types/ets/etsFunctionType.h" +#include "checker/types/ets/etsReadonlyType.h" #include "checker/types/ets/etsResizableArrayType.h" #include "checker/types/ets/etsTupleType.h" +#include "checker/types/ets/etsUnionType.h" +#include "checker/types/ets/etsNonNullishType.h" #include "generated/signatures.h" #include "checker/ets/wideningConverter.h" #include "ir/astNodeFlags.h" diff --git a/ets2panda/checker/ets/function_helpers.h b/ets2panda/checker/ets/function_helpers.h index 5ed15b1336a4c79b5ed7a65fc168c87745bec14c..fe462e92e39c74f35e4b2f78e796ce43531d466c 100644 --- a/ets2panda/checker/ets/function_helpers.h +++ b/ets2panda/checker/ets/function_helpers.h @@ -18,6 +18,7 @@ #include "checker/ETSchecker.h" #include "checker/ets/typeRelationContext.h" +#include "checker/types/ets/etsTypeParameter.h" #include "checker/types/ets/etsObjectType.h" #include "checker/types/type.h" #include "ir/base/catchClause.h" @@ -30,6 +31,8 @@ #include "ir/expressions/callExpression.h" #include "ir/expressions/functionExpression.h" #include "ir/expressions/memberExpression.h" +#include "ir/expressions/blockExpression.h" + #include "ir/statements/blockStatement.h" #include "ir/statements/doWhileStatement.h" #include "ir/statements/expressionStatement.h" @@ -40,7 +43,6 @@ #include "ir/statements/whileStatement.h" #include "ir/ts/tsTypeParameterInstantiation.h" #include "parser/program/program.h" -#include "libarkbase/utils/arena_containers.h" #include "util/helpers.h" #include "util/language.h" #include "varbinder/declaration.h" diff --git a/ets2panda/checker/ets/helpers.cpp b/ets2panda/checker/ets/helpers.cpp index 8f730c9e1ca764f20d13b5f4ec8e5a4ac7ec48ef..00406f10e3d9f3eb89b109ade57551bd254f33d8 100644 --- a/ets2panda/checker/ets/helpers.cpp +++ b/ets2panda/checker/ets/helpers.cpp @@ -20,10 +20,20 @@ #include "checker/types/globalTypesHolder.h" #include "checker/checkerContext.h" #include "checker/ETSAnalyzerHelpers.h" +#include "checker/types/ets/etsFunctionType.h" +#include "checker/types/ets/etsObjectType.h" +#include "checker/types/ets/etsResizableArrayType.h" #include "checker/types/ets/etsEnumType.h" #include "checker/types/ets/etsTupleType.h" +#include "checker/types/ets/etsUnionType.h" +#include "checker/types/ets/etsTypeParameter.h" +#include "checker/types/ets/etsStringType.h" +#include "checker/types/ets/etsBooleanType.h" #include "checker/ets/typeRelationContext.h" #include "checker/ets/typeConverter.h" + +#include "ir/ets/etsTypeReference.h" + #include "evaluate/scopedDebugInfoPlugin.h" #include "compiler/lowering/scopesInit/scopesInitPhase.h" #include "compiler/lowering/util.h" @@ -32,6 +42,8 @@ #include "util/helpers.h" #include "util/nameMangler.h" +#include "varbinder/variable.h" + namespace ark::es2panda::checker { varbinder::Variable *ETSChecker::FindVariableInFunctionScope(const util::StringView name, diff --git a/ets2panda/checker/ets/object.cpp b/ets2panda/checker/ets/object.cpp index 3ecceeeb9a88f6f8cf7ab052d542fa4205ad545d..5bb3f94106768a3596a4fbde013f870d1cf121c3 100644 --- a/ets2panda/checker/ets/object.cpp +++ b/ets2panda/checker/ets/object.cpp @@ -17,35 +17,64 @@ #include "checker/ETSchecker.h" #include "checker/checkerContext.h" #include "checker/ets/typeRelationContext.h" +#include "checker/types/ets/etsFunctionType.h" #include "checker/types/ets/etsObjectType.h" #include "checker/types/ets/etsTupleType.h" +#include "checker/types/ets/etsUnionType.h" +#include "checker/types/ets/etsTypeAliasType.h" +#include "checker/types/ets/etsReadonlyType.h" #include "checker/types/ets/etsPartialTypeParameter.h" #include "checker/types/ets/etsAwaitedType.h" +#include "checker/types/ets/etsNonNullishType.h" +#include "checker/types/ets/byteType.h" +#include "checker/types/ets/intType.h" +#include "checker/types/ets/longType.h" +#include "checker/types/ets/shortType.h" #include "compiler/lowering/phase.h" -#include "ir/base/classDefinition.h" -#include "ir/base/classElement.h" -#include "ir/base/classProperty.h" -#include "ir/base/classStaticBlock.h" -#include "ir/base/methodDefinition.h" -#include "ir/base/scriptFunction.h" -#include "ir/ets/etsNewClassInstanceExpression.h" -#include "ir/ets/etsTypeReference.h" -#include "ir/ets/etsTypeReferencePart.h" -#include "ir/ets/etsUnionType.h" -#include "ir/expression.h" + +#include "ir/statements/expressionStatement.h" + #include "ir/expressions/assignmentExpression.h" +#include "ir/expressions/arrayExpression.h" +#include "ir/expressions/binaryExpression.h" #include "ir/expressions/callExpression.h" +#include "ir/expressions/conditionalExpression.h" +#include "ir/expressions/typeofExpression.h" +#include "ir/expressions/unaryExpression.h" +#include "ir/expressions/updateExpression.h" +#include "ir/expressions/literals/bigIntLiteral.h" +#include "ir/expressions/literals/numberLiteral.h" +#include "ir/expressions/literals/stringLiteral.h" #include "ir/expressions/functionExpression.h" -#include "ir/expressions/identifier.h" #include "ir/expressions/memberExpression.h" -#include "ir/statements/blockStatement.h" -#include "ir/statements/expressionStatement.h" -#include "ir/statements/variableDeclarator.h" +#include "ir/expressions/objectExpression.h" +#include "ir/expressions/identifier.h" + +#include "ir/base/classProperty.h" +#include "ir/base/property.h" +#include "ir/base/scriptFunction.h" +#include "ir/base/spreadElement.h" +#include "ir/base/tsIndexSignature.h" +#include "ir/base/tsMethodSignature.h" +#include "ir/base/tsPropertySignature.h" +#include "ir/base/tsSignatureDeclaration.h" +#include "ir/base/overloadDeclaration.h" + +#include "ir/ts/tsAsExpression.h" #include "ir/ts/tsClassImplements.h" +#include "ir/ts/tsNonNullExpression.h" +#include "ir/ts/tsTypeAliasDeclaration.h" +#include "ir/ts/tsTypeLiteral.h" #include "ir/ts/tsInterfaceDeclaration.h" #include "ir/ts/tsInterfaceHeritage.h" -#include "ir/ts/tsTypeParameter.h" -#include "ir/ts/tsTypeParameterDeclaration.h" +#include "ir/ts/tsInterfaceBody.h" + +#include "ir/ets/etsTypeReference.h" +#include "ir/ets/etsTypeReferencePart.h" +#include "ir/ets/etsModule.h" +#include "ir/ets/etsUnionType.h" +#include "ir/ets/etsNewClassInstanceExpression.h" + #include "util/diagnostic.h" #include "varbinder/declaration.h" #include "varbinder/variableFlags.h" diff --git a/ets2panda/checker/ets/typeCheckingHelpers.cpp b/ets2panda/checker/ets/typeCheckingHelpers.cpp index a2894f93e9dab21b104b933b552fd15bad16bf04..3146f3535af29f800d9412e7d2f803f582b0fb19 100644 --- a/ets2panda/checker/ets/typeCheckingHelpers.cpp +++ b/ets2panda/checker/ets/typeCheckingHelpers.cpp @@ -17,18 +17,33 @@ #include "checker/checkerContext.h" #include "checker/ets/wideningConverter.h" #include "checker/types/globalTypesHolder.h" +#include "checker/types/ets/etsAnyType.h" +#include "checker/types/ets/etsFunctionType.h" #include "checker/types/ets/etsObjectType.h" +#include "checker/types/ets/etsUnionType.h" +#include "checker/types/ets/etsTypeAliasType.h" #include "checker/types/ets/etsPartialTypeParameter.h" +#include "checker/types/ets/etsNonNullishType.h" +#include "checker/types/ets/etsEnumType.h" +#include "checker/ETSchecker.h" +#include "checker/ets/typeRelationContext.h" +#include "checker/ets/boxingConverter.h" +#include "checker/ets/unboxingConverter.h" + #include "ir/base/catchClause.h" #include "ir/base/scriptFunction.h" #include "ir/base/classProperty.h" #include "ir/base/methodDefinition.h" +#include "ir/base/overloadDeclaration.h" #include "ir/statements/variableDeclarator.h" #include "ir/statements/switchCaseStatement.h" +#include "ir/expressions/literals/numberLiteral.h" +#include "ir/expressions/literals/booleanLiteral.h" #include "ir/expressions/identifier.h" #include "ir/expressions/callExpression.h" #include "ir/expressions/memberExpression.h" #include "ir/expressions/arrowFunctionExpression.h" +#include "ir/expressions/unaryExpression.h" #include "ir/statements/labelledStatement.h" #include "ir/statements/tryStatement.h" #include "ir/ets/etsNewClassInstanceExpression.h" @@ -36,17 +51,21 @@ #include "ir/ts/tsTypeAliasDeclaration.h" #include "ir/ts/tsEnumMember.h" #include "ir/ts/tsTypeParameter.h" +#include "ir/ts/tsTypeParameterInstantiation.h" + +#include "ir/ets/etsFunctionType.h" #include "ir/ets/etsUnionType.h" #include "ir/ets/etsTuple.h" -#include "varbinder/declaration.h" -#include "checker/ETSchecker.h" -#include "varbinder/ETSBinder.h" -#include "checker/ets/typeRelationContext.h" -#include "checker/ets/boxingConverter.h" -#include "checker/ets/unboxingConverter.h" +#include "ir/ets/etsTypeReference.h" +#include "ir/ets/etsTypeReferencePart.h" + #include "util/helpers.h" #include "generated/diagnostic.h" +#include "varbinder/declaration.h" +#include "varbinder/ETSBinder.h" +#include "varbinder/variable.h" + namespace ark::es2panda::checker { void ETSChecker::CheckTruthinessOfType(ir::Expression *expr) diff --git a/ets2panda/checker/ets/typeConverter.h b/ets2panda/checker/ets/typeConverter.h index 46635fdc5d66f58cfaa086f6b093a378a749bac2..5ce937ff49d824338f8ffad6a20e1509a5cca778 100644 --- a/ets2panda/checker/ets/typeConverter.h +++ b/ets2panda/checker/ets/typeConverter.h @@ -18,9 +18,19 @@ #include "checker/types/typeFlag.h" #include "checker/types/ets/types.h" +#include "checker/types/ets/byteType.h" +#include "checker/types/ets/charType.h" +#include "checker/types/ets/doubleType.h" +#include "checker/types/ets/floatType.h" +#include "checker/types/ets/intType.h" +#include "checker/types/ets/longType.h" +#include "checker/types/ets/shortType.h" + +#include namespace ark::es2panda::checker { class ETSChecker; +class Type; class TypeConverter { public: diff --git a/ets2panda/checker/ets/typeCreation.cpp b/ets2panda/checker/ets/typeCreation.cpp index e9fa26308f58a54379107de036c4787763b43164..782ecac88ad2f8b2b68558df4eab9a7781dffd24 100644 --- a/ets2panda/checker/ets/typeCreation.cpp +++ b/ets2panda/checker/ets/typeCreation.cpp @@ -15,14 +15,35 @@ #include "checker/ETSchecker.h" +#include "checker/types/ets/etsFunctionType.h" #include "checker/types/ets/etsAsyncFuncReturnType.h" #include "checker/types/ets/etsEnumType.h" #include "checker/types/ets/etsResizableArrayType.h" +#include "checker/types/ets/etsTypeParameter.h" +#include "checker/types/ets/etsUnionType.h" + +#include "checker/types/ets/etsTypeAliasType.h" +#include "checker/types/ets/etsExtensionFuncHelperType.h" +#include "checker/types/ets/etsStringType.h" +#include "checker/types/ets/etsBooleanType.h" +#include "checker/types/ets/etsBigIntType.h" +#include "checker/types/ets/byteType.h" +#include "checker/types/ets/charType.h" +#include "checker/types/ets/doubleType.h" +#include "checker/types/ets/floatType.h" +#include "checker/types/ets/intType.h" +#include "checker/types/ets/longType.h" +#include "checker/types/ets/shortType.h" #include "checker/types/globalTypesHolder.h" #include "checker/types/type.h" + +#include "ir/base/methodDefinition.h" #include "ir/statements/annotationDeclaration.h" +#include "ir/expressions/callExpression.h" + +#include "compiler/lowering/phase.h" -#include +#include "varbinder/variable.h" namespace ark::es2panda::checker { diff --git a/ets2panda/checker/ets/typeRelationContext.cpp b/ets2panda/checker/ets/typeRelationContext.cpp index fc1e4e72841c8ae88eadd16cde3197184d10802b..d75af40eaeef590e1c4ea2a4d8e6424fd9eb995b 100644 --- a/ets2panda/checker/ets/typeRelationContext.cpp +++ b/ets2panda/checker/ets/typeRelationContext.cpp @@ -14,6 +14,14 @@ */ #include "typeRelationContext.h" +#include "checker/types/ets/etsTypeParameter.h" +#include "checker/types/ets/etsArrayType.h" + +#include "ir/expressions/arrayExpression.h" + +#include "ir/ts/tsTypeParameterInstantiation.h" + +#include "varbinder/variable.h" namespace ark::es2panda::checker { bool AssignmentContext::ValidateArrayTypeInitializerByElement(TypeRelation *relation, ir::ArrayExpression *node, diff --git a/ets2panda/checker/ets/typeRelationContext.h b/ets2panda/checker/ets/typeRelationContext.h index 7ba41f94c85585a2607a67f9da63bea20b07c3ff..2d3d745376399aabec6b084fc69456cda0abc5d2 100644 --- a/ets2panda/checker/ets/typeRelationContext.h +++ b/ets2panda/checker/ets/typeRelationContext.h @@ -17,6 +17,7 @@ #define ES2PANDA_COMPILER_CHECKER_ETS_TYPE_RELATION_CONTEXT_H #include "checker/ETSchecker.h" +#include "checker/types/ets/etsObjectType.h" namespace ark::es2panda::checker { class ETSChecker; diff --git a/ets2panda/checker/ets/utilityTypeHandlers.cpp b/ets2panda/checker/ets/utilityTypeHandlers.cpp index 8b9f73630b7fad2c31ef2f667db6383b3e79f0fa..f9c130f3a7d65fa58ab976bc76a25370ab7e4076 100644 --- a/ets2panda/checker/ets/utilityTypeHandlers.cpp +++ b/ets2panda/checker/ets/utilityTypeHandlers.cpp @@ -21,9 +21,13 @@ #include "ir/ets/etsUnionType.h" #include "ir/expressions/literals/undefinedLiteral.h" #include "varbinder/ETSBinder.h" +#include "checker/types/ets/etsFunctionType.h" +#include "checker/types/ets/etsObjectType.h" #include "checker/types/ets/etsPartialTypeParameter.h" #include "checker/types/ets/etsAwaitedType.h" -#include "compiler/lowering/util.h" +#include "checker/types/ets/etsUnionType.h" +#include "checker/types/ets/etsReadonlyType.h" + #include "util/nameMangler.h" namespace ark::es2panda::checker { diff --git a/ets2panda/checker/ets/validateHelpers.cpp b/ets2panda/checker/ets/validateHelpers.cpp index 2e1632446ccd2a265df631071fd53ee30d801bd7..222a2a98e46fd11a81f0cd0181944f5dd2e2bf41 100644 --- a/ets2panda/checker/ets/validateHelpers.cpp +++ b/ets2panda/checker/ets/validateHelpers.cpp @@ -14,9 +14,27 @@ */ #include "varbinder/variableFlags.h" +#include "checker/types/ets/etsObjectType.h" #include "checker/types/ets/etsTupleType.h" #include "checker/ETSchecker.h" +#include "ir/typeNode.h" + +#include "ir/base/spreadElement.h" + +#include "ir/expressions/arrayExpression.h" +#include "ir/expressions/memberExpression.h" +#include "ir/expressions/assignmentExpression.h" +#include "ir/expressions/binaryExpression.h" +#include "ir/expressions/callExpression.h" + +#include "ir/ets/etsTypeReference.h" +#include "ir/ets/etsTypeReferencePart.h" +#include "ir/ets/etsNewClassInstanceExpression.h" + +#include "ir/ts/tsTypeAliasDeclaration.h" +#include "ir/ts/tsTypeParameterInstantiation.h" + namespace ark::es2panda::checker { void ETSChecker::ValidatePropertyAccess(varbinder::Variable *var, ETSObjectType *obj, const lexer::SourcePosition &pos) { diff --git a/ets2panda/checker/ts/object.cpp b/ets2panda/checker/ts/object.cpp index 0c9e3c25c32a4186ee55c6746a6e212a05cedbc7..01906c82d98e3344f644d8dd8f79159c112ac2f4 100644 --- a/ets2panda/checker/ts/object.cpp +++ b/ets2panda/checker/ts/object.cpp @@ -37,6 +37,8 @@ #include "checker/TSchecker.h" #include "checker/types/ts/indexInfo.h" +#include "varbinder/variable.h" + namespace ark::es2panda::checker { void TSChecker::CheckIndexConstraints(Type *type) { diff --git a/ets2panda/checker/typeChecker/TypeChecker.h b/ets2panda/checker/typeChecker/TypeChecker.h index 864753b273ad8713ffc5957a7b5456f8c59b6881..bb49a3c2d448ff70a68a406df385e5379dbbbf20 100644 --- a/ets2panda/checker/typeChecker/TypeChecker.h +++ b/ets2panda/checker/typeChecker/TypeChecker.h @@ -17,6 +17,7 @@ #define PANDA_TYPECHECKER_H #include "ir/visitor/IterateAstVisitor.h" +#include "checker/checker.h" namespace ark::es2panda::checker { diff --git a/ets2panda/checker/types/ets/charType.cpp b/ets2panda/checker/types/ets/charType.cpp index 43bbec66cd258fa3b35bd307b86ec6a804ea5725..edc87d23c17f4673047e50fab6691df3107f89c1 100644 --- a/ets2panda/checker/types/ets/charType.cpp +++ b/ets2panda/checker/types/ets/charType.cpp @@ -17,6 +17,7 @@ #include "checker/ets/conversion.h" #include "checker/ets/wideningConverter.h" +#include "checker/types/ets/etsObjectType.h" namespace ark::es2panda::checker { void CharType::Identical(TypeRelation *relation, Type *other) diff --git a/ets2panda/checker/types/ets/doubleType.cpp b/ets2panda/checker/types/ets/doubleType.cpp index ad58d7bc8c9a5470fb94e12a8b57660b0dd10813..8d46e5d696720f1ab2877193070380434c8565c6 100644 --- a/ets2panda/checker/types/ets/doubleType.cpp +++ b/ets2panda/checker/types/ets/doubleType.cpp @@ -17,6 +17,7 @@ #include "checker/ets/conversion.h" #include "checker/ets/wideningConverter.h" +#include "checker/types/ets/etsObjectType.h" namespace ark::es2panda::checker { void DoubleType::Identical(TypeRelation *relation, Type *other) diff --git a/ets2panda/checker/types/ets/etsAnyType.cpp b/ets2panda/checker/types/ets/etsAnyType.cpp index c1e5307545c902a90b0062e2aa9fa97ff2b5abda..cec2ca4933b050944bcc762b7744339d4873706b 100644 --- a/ets2panda/checker/types/ets/etsAnyType.cpp +++ b/ets2panda/checker/types/ets/etsAnyType.cpp @@ -18,6 +18,7 @@ #include "checker/ETSchecker.h" #include "checker/ets/conversion.h" +#include "checker/types/ets/etsObjectType.h" #include "etsTypeParameter.h" namespace ark::es2panda::checker { diff --git a/ets2panda/checker/types/ets/etsArrayType.cpp b/ets2panda/checker/types/ets/etsArrayType.cpp index 79d9cc398389767328cfa2ccc2d9a51868e91f81..cccb0ff6cb52e1762ed1cf278d51e29164124f4f 100644 --- a/ets2panda/checker/types/ets/etsArrayType.cpp +++ b/ets2panda/checker/types/ets/etsArrayType.cpp @@ -21,6 +21,7 @@ #include "checker/ets/conversion.h" #include "checker/types/typeRelation.h" #include "checker/types/ets/etsTupleType.h" +#include "checker/types/ets/etsResizableArrayType.h" namespace ark::es2panda::checker { void ETSArrayType::ToString(std::stringstream &ss, bool precise) const diff --git a/ets2panda/checker/types/ets/etsBooleanType.cpp b/ets2panda/checker/types/ets/etsBooleanType.cpp index f19823daa2f3ab0f1dc703ee184a7708609884c5..9ffb7557bd07f434c26b51f23babd519faffe611 100644 --- a/ets2panda/checker/types/ets/etsBooleanType.cpp +++ b/ets2panda/checker/types/ets/etsBooleanType.cpp @@ -17,6 +17,7 @@ #include "checker/ETSchecker.h" #include "checker/ets/conversion.h" +#include "checker/types/ets/etsObjectType.h" namespace ark::es2panda::checker { void ETSBooleanType::Identical(TypeRelation *relation, Type *other) diff --git a/ets2panda/checker/types/ets/etsFunctionType.cpp b/ets2panda/checker/types/ets/etsFunctionType.cpp index aee6b12334076c2b0f9f2512bafcfb7406c5dba8..8730d080c37295871ade9a1789a5c673da5f8488 100644 --- a/ets2panda/checker/types/ets/etsFunctionType.cpp +++ b/ets2panda/checker/types/ets/etsFunctionType.cpp @@ -14,8 +14,13 @@ */ #include "checker/ETSchecker.h" +#include "checker/types/ets/etsFunctionType.h" +#include "checker/types/ets/etsObjectType.h" #include "checker/types/globalTypesHolder.h" #include "checker/types/typeError.h" + +#include "ir/typeNode.h" + #include "compiler/lowering/phase.h" namespace ark::es2panda::checker { diff --git a/ets2panda/checker/types/ets/etsNeverType.cpp b/ets2panda/checker/types/ets/etsNeverType.cpp index 0b5401c3ba54c9e81c5e0428d85d081a23493238..8d96d40cd58e0c064811a89329518adabeb13d5c 100644 --- a/ets2panda/checker/types/ets/etsNeverType.cpp +++ b/ets2panda/checker/types/ets/etsNeverType.cpp @@ -16,6 +16,7 @@ #include "etsNeverType.h" #include "checker/ETSchecker.h" +#include "checker/types/ets/etsObjectType.h" #include "checker/ets/conversion.h" #include "etsTypeParameter.h" diff --git a/ets2panda/checker/types/ets/etsNonNullishType.cpp b/ets2panda/checker/types/ets/etsNonNullishType.cpp index 7eee9243faa5f557ecf58a3de9251d1ccf8b59a6..548d856293a07282a5fcba762918168380a53301 100644 --- a/ets2panda/checker/types/ets/etsNonNullishType.cpp +++ b/ets2panda/checker/types/ets/etsNonNullishType.cpp @@ -18,6 +18,7 @@ #include "ir/expressions/identifier.h" #include "ir/ts/tsTypeParameter.h" #include "checker/ETSchecker.h" +#include "checker/types/ets/etsNonNullishType.h" #include "checker/ets/conversion.h" namespace ark::es2panda::checker { diff --git a/ets2panda/checker/types/ets/etsNullishTypes.cpp b/ets2panda/checker/types/ets/etsNullishTypes.cpp index e9abc5839f4d6d494453c5aa8d7ad9fab029c3b0..c17cf677f309f4d48b42cb9b3c21322ad2e07437 100644 --- a/ets2panda/checker/types/ets/etsNullishTypes.cpp +++ b/ets2panda/checker/types/ets/etsNullishTypes.cpp @@ -18,6 +18,7 @@ #include "ir/expressions/identifier.h" #include "ir/ts/tsTypeParameter.h" #include "checker/ETSchecker.h" +#include "checker/types/ets/etsObjectType.h" #include "checker/ets/conversion.h" namespace ark::es2panda::checker { diff --git a/ets2panda/checker/types/ets/etsObjectType.cpp b/ets2panda/checker/types/ets/etsObjectType.cpp index 4ca73193be78c9e242f7a5217673e0356ad7b9cf..2c761d0d80aad3155646f2a5a2d8d9b01bc1003e 100644 --- a/ets2panda/checker/types/ets/etsObjectType.cpp +++ b/ets2panda/checker/types/ets/etsObjectType.cpp @@ -18,11 +18,18 @@ #include "checker/ETSchecker.h" #include "checker/ets/conversion.h" #include "checker/types/globalTypesHolder.h" +#include "checker/types/ets/etsFunctionType.h" +#include "checker/types/ets/etsTypeParameter.h" #include "checker/types/ets/etsAsyncFuncReturnType.h" +#include "checker/types/ets/etsResizableArrayType.h" #include "checker/types/ets/etsEnumType.h" #include "compiler/lowering/phase.h" -#include "util/nameMangler.h" + +#include "ir/base/overloadDeclaration.h" #include "ir/statements/annotationDeclaration.h" +#include "ir/ts/tsQualifiedName.h" + +#include "util/nameMangler.h" namespace ark::es2panda::checker { diff --git a/ets2panda/checker/types/ets/etsPartialTypeParameter.cpp b/ets2panda/checker/types/ets/etsPartialTypeParameter.cpp index 9333d54633a9c357e64dde7d9bbdc270b617ec4d..db8681428d4737c3022562b8ec26be7e57e57bbc 100644 --- a/ets2panda/checker/types/ets/etsPartialTypeParameter.cpp +++ b/ets2panda/checker/types/ets/etsPartialTypeParameter.cpp @@ -15,6 +15,7 @@ #include "etsPartialTypeParameter.h" #include "checker/ETSchecker.h" +#include "checker/types/ets/etsObjectType.h" namespace ark::es2panda::checker { diff --git a/ets2panda/checker/types/ets/etsTupleType.cpp b/ets2panda/checker/types/ets/etsTupleType.cpp index 38930b20a3a519e024ff6bba7b36b785e0619191..cd219fdf688bf17cf6051e58cb906d506a9cd7f1 100644 --- a/ets2panda/checker/types/ets/etsTupleType.cpp +++ b/ets2panda/checker/types/ets/etsTupleType.cpp @@ -17,6 +17,8 @@ #include "checker/ETSchecker.h" #include "checker/ets/conversion.h" +#include "checker/types/ets/etsObjectType.h" +#include "checker/types/ets/etsArrayType.h" #include "ir/ets/etsTuple.h" namespace ark::es2panda::checker { diff --git a/ets2panda/checker/types/ets/etsTupleType.h b/ets2panda/checker/types/ets/etsTupleType.h index f6a76125a9f8d2032f1526238b5be2e100543fef..5c0c8a4f140680ba19fe896445238ea80978ec6a 100644 --- a/ets2panda/checker/types/ets/etsTupleType.h +++ b/ets2panda/checker/types/ets/etsTupleType.h @@ -30,7 +30,7 @@ public: typeList_(typeList), // NOLINTNEXTLINE(readability-implicit-bool-conversion) wrapperType_(checker->GlobalBuiltinTupleType(typeList_.size()) != nullptr - ? checker->GlobalBuiltinTupleType(typeList_.size())->AsETSObjectType() + ? checker->GlobalBuiltinTupleType(typeList_.size()) : nullptr) { typeFlags_ |= TypeFlag::ETS_TUPLE; diff --git a/ets2panda/checker/types/ets/etsTypeParameter.cpp b/ets2panda/checker/types/ets/etsTypeParameter.cpp index 53c70fcfcc2cc884654aae6c0b78e1453262d4a5..757a32ebddc39f18400a4a11fe4ebf08c8f3a574 100644 --- a/ets2panda/checker/types/ets/etsTypeParameter.cpp +++ b/ets2panda/checker/types/ets/etsTypeParameter.cpp @@ -17,6 +17,7 @@ #include "ir/expressions/identifier.h" #include "ir/ts/tsTypeParameter.h" #include "checker/ETSchecker.h" +#include "checker/types/ets/etsObjectType.h" namespace ark::es2panda::checker { diff --git a/ets2panda/checker/types/ets/etsUnionType.cpp b/ets2panda/checker/types/ets/etsUnionType.cpp index 1fee41b8f8ec7dcaa9700b3aee19b68f4eb6818d..2a4249962a264ad49eb08c0857eb004357517979 100644 --- a/ets2panda/checker/types/ets/etsUnionType.cpp +++ b/ets2panda/checker/types/ets/etsUnionType.cpp @@ -19,6 +19,7 @@ #include "checker/ets/conversion.h" #include "checker/types/ets/etsTupleType.h" #include "checker/types/globalTypesHolder.h" +#include "checker/types/ets/etsTypeParameter.h" #include "checker/ETSchecker.h" namespace ark::es2panda::checker { diff --git a/ets2panda/checker/types/ets/etsUnionType.h b/ets2panda/checker/types/ets/etsUnionType.h index 0ae2e8a38bdf30728e7547aefc0292a7dea020fe..06d2b9c5f8a01d415d262243b6b8a5c91633eab4 100644 --- a/ets2panda/checker/types/ets/etsUnionType.h +++ b/ets2panda/checker/types/ets/etsUnionType.h @@ -17,10 +17,10 @@ #define ES2PANDA_COMPILER_CHECKER_TYPES_ETS_UNION_TYPE_H #include "checker/types/type.h" -#include "checker/types/ets/etsObjectType.h" namespace ark::es2panda::checker { class GlobalTypesHolder; +class ETSObjectType; class ETSUnionType : public Type { public: diff --git a/ets2panda/checker/types/ets/floatType.cpp b/ets2panda/checker/types/ets/floatType.cpp index 958f338480b0afa1b7787edfc1f443222202edb5..1ac8fcbc2682fd03569e7494204943263b9cf1d6 100644 --- a/ets2panda/checker/types/ets/floatType.cpp +++ b/ets2panda/checker/types/ets/floatType.cpp @@ -17,6 +17,7 @@ #include "checker/ets/conversion.h" #include "checker/ets/wideningConverter.h" +#include "checker/types/ets/etsObjectType.h" namespace ark::es2panda::checker { void FloatType::Identical(TypeRelation *relation, Type *other) diff --git a/ets2panda/checker/types/ets/intType.cpp b/ets2panda/checker/types/ets/intType.cpp index 3587ee1bc0b071c21700acadf8ecc3315412f5a6..bc9b42c878849cfb77a3a312c3cb5a1d78bfe4bd 100644 --- a/ets2panda/checker/types/ets/intType.cpp +++ b/ets2panda/checker/types/ets/intType.cpp @@ -17,6 +17,7 @@ #include "checker/ets/conversion.h" #include "checker/ets/wideningConverter.h" +#include "checker/types/ets/etsObjectType.h" namespace ark::es2panda::checker { void IntType::Identical(TypeRelation *relation, Type *other) diff --git a/ets2panda/checker/types/ets/longType.cpp b/ets2panda/checker/types/ets/longType.cpp index 7b8c5b34fae0af6e8144ecc4412a82528e8c93ba..bdd3fcd360e4fdbd69d8063bc346a2bb749f32a6 100644 --- a/ets2panda/checker/types/ets/longType.cpp +++ b/ets2panda/checker/types/ets/longType.cpp @@ -17,6 +17,7 @@ #include "checker/ets/conversion.h" #include "checker/ets/wideningConverter.h" +#include "checker/types/ets/etsObjectType.h" namespace ark::es2panda::checker { void LongType::Identical(TypeRelation *relation, Type *other) diff --git a/ets2panda/checker/types/ets/shortType.cpp b/ets2panda/checker/types/ets/shortType.cpp index c7f79a229ea6be5b256578cf30154725121f5e93..c1eddf97e39e7710f2ce08fd3ab1ef326b318e9a 100644 --- a/ets2panda/checker/types/ets/shortType.cpp +++ b/ets2panda/checker/types/ets/shortType.cpp @@ -17,6 +17,7 @@ #include "checker/ets/conversion.h" #include "checker/ets/wideningConverter.h" +#include "checker/types/ets/etsObjectType.h" namespace ark::es2panda::checker { void ShortType::Identical(TypeRelation *relation, Type *other) diff --git a/ets2panda/checker/types/ets/types.h b/ets2panda/checker/types/ets/types.h index e82a8fa0a503b690ae1cd7a15531ebfa873e4fd8..b1b9b18ffa73b0530aa2108526382080ceda7b48 100644 --- a/ets2panda/checker/types/ets/types.h +++ b/ets2panda/checker/types/ets/types.h @@ -16,31 +16,36 @@ #ifndef ES2PANDA_COMPILER_CHECKER_TYPES_ETS_H #define ES2PANDA_COMPILER_CHECKER_TYPES_ETS_H -#include "byteType.h" -#include "charType.h" -#include "doubleType.h" -#include "floatType.h" -#include "intType.h" -#include "longType.h" -#include "shortType.h" -#include "etsBooleanType.h" -#include "etsExtensionFuncHelperType.h" -#include "etsFunctionType.h" -#include "etsUnionType.h" -#include "etsVoidType.h" -#include "etsStringType.h" -#include "etsBigIntType.h" -#include "etsObjectType.h" -#include "etsTypeAliasType.h" -#include "etsArrayType.h" -#include "wildcardType.h" -#include "etsTypeParameter.h" -#include "etsNonNullishType.h" -#include "etsNullishTypes.h" -#include "checker/types/signature.h" -#include "etsReadonlyType.h" -#include "etsAnyType.h" -#include "etsNeverType.h" -#include "etsEnumType.h" +namespace ark::es2panda::checker { +class ByteType; +class CharType; +class DoubleType; +class FloatType; +class IntType; +class LongType; +class ShortType; +class WildcardType; +class ETSBooleanType; +class ETSExtensionFuncHelperType; +class ETSFunctionType; +class ETSUnionType; +class ETSVoidType; +class ETSStringType; +class ETSBigIntType; +class ETSObjectType; +class ETSTypeAliasType; +class ETSArrayType; +class ETSResizableArrayType; +class ETSTypeParameter; +class ETSNonNullishType; +class ETSNullishTypes; +class ETSReadonlyType; +class ETSAnyType; +class ETSNeverType; +class ETSEnumType; +class Signature; +class SignatureInfo; -#endif /* TYPES_H */ +} // namespace ark::es2panda::checker + +#endif /* ES2PANDA_COMPILER_CHECKER_TYPES_ETS_H */ diff --git a/ets2panda/checker/types/ts/objectDescriptor.h b/ets2panda/checker/types/ts/objectDescriptor.h index 5a126fd4da5fc0bb841c53ed8b661012cd7a924b..9ebad7938a23ab3efae9e7a7377ada74d1438f7e 100644 --- a/ets2panda/checker/types/ts/objectDescriptor.h +++ b/ets2panda/checker/types/ts/objectDescriptor.h @@ -17,7 +17,7 @@ #define ES2PANDA_COMPILER_CHECKER_TYPES_TS_OBJECT_DESCRIPTOR_H #include "util/es2pandaMacros.h" -#include "util/ustring.h" +#include "libarkbase/utils/arena_vector.h" #include namespace ark::es2panda::varbinder { diff --git a/ets2panda/checker/types/ts/unionType.h b/ets2panda/checker/types/ts/unionType.h index 68aa45ba50f95a5d3e16dae9bb60c241a823443e..e9522337bb7294e451b60ab1f8f4fe214ab1a9e0 100644 --- a/ets2panda/checker/types/ts/unionType.h +++ b/ets2panda/checker/types/ts/unionType.h @@ -17,6 +17,7 @@ #define ES2PANDA_COMPILER_CHECKER_TYPES_TS_UNION_TYPE_H #include "checker/types/type.h" +#include "libarkbase/utils/arena_vector.h" namespace ark::es2panda::checker { class GlobalTypesHolder; diff --git a/ets2panda/checker/types/type.h b/ets2panda/checker/types/type.h index 9489e0873ded2c9fe930f13d81da32781485fb06..307c1cd27ae0240067860164cecadaba19c7d410 100644 --- a/ets2panda/checker/types/type.h +++ b/ets2panda/checker/types/type.h @@ -21,6 +21,7 @@ #include "checker/types/typeMapping.h" #include "checker/types/typeRelation.h" #include "checker/types/typeFacts.h" +#include "libarkbase/utils/logger.h" namespace ark::es2panda::varbinder { class Variable; diff --git a/ets2panda/checker/types/typeRelation.cpp b/ets2panda/checker/types/typeRelation.cpp index 8f690add63e9681dab6a7af9941341fdd3c669de..cf4ed4348f5cc7fc56ff978305cf0a6489a3914e 100644 --- a/ets2panda/checker/types/typeRelation.cpp +++ b/ets2panda/checker/types/typeRelation.cpp @@ -19,6 +19,8 @@ #include "checker/ETSchecker.h" #include "checker/types/ts/indexInfo.h" #include "checker/types/signature.h" +#include "checker/types/ets/etsObjectType.h" +#include "checker/types/ets/etsUnionType.h" namespace ark::es2panda::checker { ArenaAllocator *TypeRelation::Allocator() diff --git a/ets2panda/checker/types/typeRelation.h b/ets2panda/checker/types/typeRelation.h index 33c32e789cfada5d83580cd839f5aacf80fa48e5..e5eb4a4ab06d3b3669ff89287f26839b0a9a0f60 100644 --- a/ets2panda/checker/types/typeRelation.h +++ b/ets2panda/checker/types/typeRelation.h @@ -22,6 +22,8 @@ #include "util/ustring.h" #include "util/enumbitops.h" #include "util/diagnosticEngine.h" +#include "libarkbase/utils/arena_unordered_map.h" +#include "libarkbase/utils/arena_map.h" namespace ark::es2panda::ir { class Expression; diff --git a/ets2panda/compiler/base/lreference.cpp b/ets2panda/compiler/base/lreference.cpp index bbd1d69bb6a81706815b77e78a6c6ff6c460ff62..95138f9fd2a7c40264692fac0f951e1b01a3dcb3 100644 --- a/ets2panda/compiler/base/lreference.cpp +++ b/ets2panda/compiler/base/lreference.cpp @@ -21,7 +21,9 @@ #include "compiler/core/function.h" #include "compiler/core/pandagen.h" #include "compiler/core/ETSGen.h" +#include "checker/types/ets/etsFunctionType.h" #include "checker/types/ets/etsTupleType.h" +#include "checker/types/ets/etsResizableArrayType.h" #include "ir/base/spreadElement.h" #include "ir/base/classProperty.h" #include "ir/base/classDefinition.h" diff --git a/ets2panda/compiler/core/ASTCompiler.h b/ets2panda/compiler/core/ASTCompiler.h index d7925c2f4429ed3b8775ea8fc5a2fb778b2330b6..dcc4b7d423276f25064911edf028fe43b6bbb6ed 100644 --- a/ets2panda/compiler/core/ASTCompiler.h +++ b/ets2panda/compiler/core/ASTCompiler.h @@ -60,6 +60,7 @@ #include "ir/expressions/classExpression.h" #include "ir/expressions/conditionalExpression.h" #include "ir/expressions/directEvalExpression.h" +#include "ir/expressions/dummyNode.h" #include "ir/expressions/functionExpression.h" #include "ir/expressions/identifier.h" #include "ir/expressions/importExpression.h" @@ -82,6 +83,7 @@ #include "ir/expressions/literals/numberLiteral.h" #include "ir/expressions/literals/regExpLiteral.h" #include "ir/expressions/literals/stringLiteral.h" +#include "ir/expressions/literals/undefinedLiteral.h" #include "ir/module/exportAllDeclaration.h" #include "ir/module/exportDefaultDeclaration.h" #include "ir/module/exportNamedDeclaration.h" diff --git a/ets2panda/compiler/core/CFG.cpp b/ets2panda/compiler/core/CFG.cpp index 701a766ef76d6906c28549e7b1959abe55aa113f..85a6235290a10ddae288ffa4f73aba364877d113 100644 --- a/ets2panda/compiler/core/CFG.cpp +++ b/ets2panda/compiler/core/CFG.cpp @@ -17,6 +17,42 @@ #include "public/public.h" #include "util/helpers.h" +#include "ir/base/catchClause.h" +#include "ir/base/scriptFunction.h" + +#include "ir/expressions/assignmentExpression.h" +#include "ir/expressions/arrowFunctionExpression.h" +#include "ir/expressions/arrayExpression.h" +#include "ir/expressions/blockExpression.h" +#include "ir/expressions/binaryExpression.h" +#include "ir/expressions/callExpression.h" +#include "ir/expressions/conditionalExpression.h" +#include "ir/expressions/chainExpression.h" +#include "ir/expressions/unaryExpression.h" +#include "ir/expressions/typeofExpression.h" +#include "ir/expressions/updateExpression.h" + +#include "ir/statements/forOfStatement.h" +#include "ir/statements/forUpdateStatement.h" +#include "ir/statements/continueStatement.h" +#include "ir/statements/breakStatement.h" +#include "ir/statements/expressionStatement.h" +#include "ir/statements/switchStatement.h" +#include "ir/statements/switchCaseStatement.h" +#include "ir/statements/throwStatement.h" +#include "ir/statements/tryStatement.h" +#include "ir/statements/whileStatement.h" +#include "ir/statements/doWhileStatement.h" +#include "ir/statements/labelledStatement.h" +#include "ir/statements/ifStatement.h" +#include "ir/statements/variableDeclaration.h" +#include "ir/statements/variableDeclaration.h" + +#include "ir/ets/etsNewClassInstanceExpression.h" + +#include "ir/ts/tsAsExpression.h" +#include "ir/ts/tsNonNullExpression.h" + namespace ark::es2panda::compiler { CFG::BasicBlock::BasicBlock(ArenaAllocator *allocator, size_t index) noexcept diff --git a/ets2panda/compiler/core/CFG.h b/ets2panda/compiler/core/CFG.h index 99a8aff2208287fd34da3f1e53febacb56773880..67bc9c7adec6cb2f2c54783c2d11a0e706ae0ac7 100644 --- a/ets2panda/compiler/core/CFG.h +++ b/ets2panda/compiler/core/CFG.h @@ -18,6 +18,9 @@ #include "ir/astNode.h" #include "ir/expressions/literals/booleanLiteral.h" +#include "libarkbase/utils/arena_set.h" +#include "libarkbase/utils/arena_list.h" +#include "libarkbase/utils/arena_unordered_map.h" namespace ark::es2panda::public_lib { struct Context; diff --git a/ets2panda/compiler/core/ETSCompiler.cpp b/ets2panda/compiler/core/ETSCompiler.cpp index 7f7059aeca6aa6abed070a929196666e520f5724..fa1e12a176dbf5bf665da140c9554f6442c8fed0 100644 --- a/ets2panda/compiler/core/ETSCompiler.cpp +++ b/ets2panda/compiler/core/ETSCompiler.cpp @@ -23,12 +23,41 @@ #include "compiler/core/vReg.h" #include "compiler/function/functionBuilder.h" #include "checker/ETSchecker.h" +#include "checker/types/ets/byteType.h" +#include "checker/types/ets/charType.h" +#include "checker/types/ets/doubleType.h" +#include "checker/types/ets/floatType.h" +#include "checker/types/ets/intType.h" +#include "checker/types/ets/longType.h" +#include "checker/types/ets/shortType.h" +#include "checker/types/ets/etsBooleanType.h" +#include "checker/types/ets/etsExtensionFuncHelperType.h" +#include "checker/types/ets/etsFunctionType.h" +#include "checker/types/ets/etsUnionType.h" #include "checker/types/ets/etsTupleType.h" +#include "checker/types/ets/etsVoidType.h" +#include "checker/types/ets/etsStringType.h" +#include "checker/types/ets/etsBigIntType.h" +#include "checker/types/ets/etsObjectType.h" +#include "checker/types/ets/etsTypeAliasType.h" +#include "checker/types/ets/etsArrayType.h" +#include "checker/types/ets/wildcardType.h" +#include "checker/types/ets/etsTypeParameter.h" +#include "checker/types/ets/etsNonNullishType.h" +#include "checker/types/ets/etsNullishTypes.h" +#include "checker/types/ets/etsReadonlyType.h" +#include "checker/types/ets/etsAnyType.h" +#include "checker/types/ets/etsNeverType.h" +#include "checker/types/ets/etsEnumType.h" + #include "ETSGen-inl.h" #include "generated/signatures.h" #include "util/es2pandaMacros.h" #include "varbinder/ETSBinder.h" +#include "ir/brokenTypeNode.h" +#include "ir/expressions/typeofExpression.h" + namespace ark::es2panda::compiler { ETSGen *ETSCompiler::GetETSGen() const @@ -1661,3 +1690,766 @@ void ETSCompiler::Compile([[maybe_unused]] const ir::TSQualifiedName *expr) cons } } // namespace ark::es2panda::compiler + +namespace ark::es2panda::ir { + +void PrefixAssertionExpression::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void NamedType::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void ETSFunctionType::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void ETSPackageDeclaration::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void ETSNewClassInstanceExpression::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void ETSClassLiteral::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void ETSTypeReferencePart::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void ETSPrimitiveType::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void ETSTypeReference::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void ETSNewMultiDimArrayInstanceExpression::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void ETSWildcardType::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void ETSNewArrayInstanceExpression::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TSUndefinedKeyword::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TSBooleanKeyword::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TSConditionalType::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TSExternalModuleReference::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TSMappedType::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TSTypePredicate::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TSTypeAssertion::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TSParenthesizedType::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TSTypeParameter::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TSEnumMember::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TSTypeParameterDeclaration::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TSStringKeyword::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TSTypeAliasDeclaration::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TSNonNullExpression::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TSInterfaceBody::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TSThisType::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TSConstructorType::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TSIndexedAccessType::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TSEnumDeclaration::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TSTypeOperator::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TSParameterProperty::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TSQualifiedName::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TSInterfaceDeclaration::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TSInferType::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TSTypeLiteral::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TSTypeReference::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TSAnyKeyword::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TSBigintKeyword::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TSModuleBlock::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TSNullKeyword::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TSTypeParameterInstantiation::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TSTupleType::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TSVoidKeyword::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TSLiteralType::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TSNamedTupleMember::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TSAsExpression::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TSNeverKeyword::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TSImportEqualsDeclaration::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TSInterfaceHeritage::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TSTypeQuery::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TSFunctionType::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TSIntersectionType::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TSNumberKeyword::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TSModuleDeclaration::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TSClassImplements::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TSUnionType::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TSUnknownKeyword::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TSArrayType::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TSImportType::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void ImportDeclaration::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void ExportSpecifier::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void ImportDefaultSpecifier::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void ExportAllDeclaration::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void ExportDefaultDeclaration::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void ExportNamedDeclaration::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void ImportSpecifier::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void ImportNamespaceSpecifier::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void ThisExpression::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void AssignmentExpression::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void ObjectExpression::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void FunctionExpression::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void BlockExpression::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void OmittedExpression::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void ChainExpression::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void MemberExpression::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void UpdateExpression::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void DirectEvalExpression::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void DummyNode::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void YieldExpression::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void ClassExpression::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void AwaitExpression::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void BinaryExpression::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void BinaryExpression::CompileOperands(compiler::ETSGen *etsg, compiler::VReg lhs) const +{ + left_->Compile(etsg); + + if (operator_ == lexer::TokenType::KEYW_INSTANCEOF) { + etsg->StoreAccumulator(left_, lhs); + } else { + etsg->ApplyConversionAndStoreAccumulator(left_, lhs, operationType_); + } + + right_->Compile(etsg); + etsg->ApplyConversion(right_, operationType_); +} + +void SuperExpression::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void ImportExpression::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TaggedTemplateExpression::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void Identifier::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void SequenceExpression::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void BooleanLiteral::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void UndefinedLiteral::Compile(compiler::ETSGen *etsg) const +{ + etsg->LoadAccumulatorUndefined(this); +} + +void NumberLiteral::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void StringLiteral::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void BigIntLiteral::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void NullLiteral::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void RegExpLiteral::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TypeofExpression::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void NewExpression::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void CallExpression::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void ArrowFunctionExpression::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void ConditionalExpression::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void CatchClause::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void ClassDefinition::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TSSignatureDeclaration::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TSMethodSignature::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void Decorator::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void MetaProperty::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void ClassStaticBlock::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void ClassProperty::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void Property::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TSPropertySignature::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TSIndexSignature::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TemplateElement::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void MethodDefinition::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void ScriptFunction::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void FunctionDeclaration::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void VariableDeclaration::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void SwitchStatement::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TryStatement::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void AnnotationUsage::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void AnnotationDeclaration::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void ForUpdateStatement::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void LabelledStatement::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void ExpressionStatement::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void EmptyStatement::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void DebuggerStatement::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void IfStatement::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void ForOfStatement::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void ForInStatement::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void ContinueStatement::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void SwitchCaseStatement::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void VariableDeclarator::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void DoWhileStatement::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void ClassDeclaration::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TSObjectKeyword::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void BrokenTypeNode::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void TemplateLiteral::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void UnaryExpression::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void CharLiteral::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void SpreadElement::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void ReturnStatement::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void AssertStatement::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void WhileStatement::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void BlockStatement::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void ThrowStatement::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void BreakStatement::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void OpaqueTypeNode::Compile(compiler::ETSGen *etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void ArrayExpression::Compile(compiler::ETSGen *const etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +void ETSParameterExpression::Compile(compiler::ETSGen *const etsg) const +{ + etsg->GetAstCompiler()->Compile(this); +} + +} // namespace ark::es2panda::ir diff --git a/ets2panda/compiler/core/ETSGen-inl.h b/ets2panda/compiler/core/ETSGen-inl.h index de548d52ede22fed2e87f790b77c79d1b212755d..b30f0bac3e43d397ce35ed3aa1f50fc0c5466bec 100644 --- a/ets2panda/compiler/core/ETSGen-inl.h +++ b/ets2panda/compiler/core/ETSGen-inl.h @@ -18,6 +18,14 @@ #include "ETSGen.h" +#include "checker/types/ets/byteType.h" +#include "checker/types/ets/charType.h" +#include "checker/types/ets/doubleType.h" +#include "checker/types/ets/floatType.h" +#include "checker/types/ets/intType.h" +#include "checker/types/ets/longType.h" +#include "checker/types/ets/shortType.h" + #include "checker/ETSchecker.h" namespace ark::es2panda::compiler { diff --git a/ets2panda/compiler/core/ETSGen.cpp b/ets2panda/compiler/core/ETSGen.cpp index 26331a00c0a27f3b9982e40018c67ba7dee9f0fe..8d7e8155a487be714fcb305ada8308254c2a53ab 100644 --- a/ets2panda/compiler/core/ETSGen.cpp +++ b/ets2panda/compiler/core/ETSGen.cpp @@ -48,9 +48,27 @@ #include "checker/types/signature.h" #include "checker/checker.h" #include "checker/ETSchecker.h" -#include "checker/types/ets/etsObjectType.h" -#include "checker/types/ets/etsTupleType.h" #include "checker/types/ets/etsAsyncFuncReturnType.h" +#include "checker/types/ets/etsBooleanType.h" +#include "checker/types/ets/etsExtensionFuncHelperType.h" +#include "checker/types/ets/etsFunctionType.h" +#include "checker/types/ets/etsUnionType.h" +#include "checker/types/ets/etsTupleType.h" +#include "checker/types/ets/etsVoidType.h" +#include "checker/types/ets/etsStringType.h" +#include "checker/types/ets/etsBigIntType.h" +#include "checker/types/ets/etsObjectType.h" +#include "checker/types/ets/etsTypeAliasType.h" +#include "checker/types/ets/etsArrayType.h" +#include "checker/types/ets/etsResizableArrayType.h" +#include "checker/types/ets/wildcardType.h" +#include "checker/types/ets/etsTypeParameter.h" +#include "checker/types/ets/etsNonNullishType.h" +#include "checker/types/ets/etsNullishTypes.h" +#include "checker/types/ets/etsReadonlyType.h" +#include "checker/types/ets/etsAnyType.h" +#include "checker/types/ets/etsNeverType.h" +#include "checker/types/ets/etsEnumType.h" #include "parser/program/program.h" #include "checker/types/globalTypesHolder.h" #include "public/public.h" @@ -2975,4 +2993,5 @@ void ETSGen::LoadAccumulatorNumber(const ir::AstNode *node, T number, checker::T ApplyConversion(node, targetType_); } } + } // namespace ark::es2panda::compiler diff --git a/ets2panda/compiler/core/ETSGen.h b/ets2panda/compiler/core/ETSGen.h index 79bc976050eafc98b2116210ae330ff20df3063b..2b2fd5dacff6975b81231a3a0c46124c71259b43 100644 --- a/ets2panda/compiler/core/ETSGen.h +++ b/ets2panda/compiler/core/ETSGen.h @@ -27,6 +27,7 @@ #include "compiler/core/ETSfunction.h" #include "compiler/core/targetTypeContext.h" #include "checker/ETSchecker.h" +#include "checker/types/ets/etsObjectType.h" #include "ir/expressions/identifier.h" #include "util/helpers.h" diff --git a/ets2panda/compiler/core/ETSemitter.cpp b/ets2panda/compiler/core/ETSemitter.cpp index e6572e73235bdf14d661d5458e5459ac162c1cff..f1349e31be3f1dd11e76a4ee0706e16acd83044f 100644 --- a/ets2panda/compiler/core/ETSemitter.cpp +++ b/ets2panda/compiler/core/ETSemitter.cpp @@ -26,32 +26,39 @@ #include "annotation.h" #include "compiler/base/catchTable.h" #include "compiler/core/ETSGen.h" -#include "util/es2pandaMacros.h" -#include "varbinder/varbinder.h" -#include "varbinder/ETSBinder.h" + #include "ir/astNode.h" -#include "ir/expressions/identifier.h" +#include "ir/typeNode.h" #include "ir/base/decorator.h" #include "ir/base/methodDefinition.h" #include "ir/base/classDefinition.h" #include "ir/base/scriptFunction.h" #include "ir/base/classProperty.h" +#include "ir/base/overloadDeclaration.h" +#include "ir/expressions/identifier.h" #include "ir/statements/annotationDeclaration.h" #include "ir/ts/tsInterfaceDeclaration.h" #include "ir/ts/tsInterfaceBody.h" #include "ir/ts/tsTypeParameter.h" -#include "ir/typeNode.h" -#include "parser/program/program.h" + #include "checker/checker.h" #include "checker/types/signature.h" #include "checker/ETSchecker.h" #include "checker/types/type.h" #include "checker/types/ets/types.h" #include "checker/types/ets/etsPartialTypeParameter.h" +#include "checker/types/ets/etsNonNullishType.h" + +#include "varbinder/varbinder.h" +#include "varbinder/ETSBinder.h" + #include "public/public.h" + #include "util/nameMangler.h" +#include "util/es2pandaMacros.h" #include "assembly-program.h" +#include "parser/program/program.h" namespace ark::es2panda::compiler { diff --git a/ets2panda/compiler/core/ETSfunction.cpp b/ets2panda/compiler/core/ETSfunction.cpp index 39cc8e6600ec879ace54119b94fdb62ee693296a..186922de828e91c9c369b1293730e7066aedcc4f 100644 --- a/ets2panda/compiler/core/ETSfunction.cpp +++ b/ets2panda/compiler/core/ETSfunction.cpp @@ -33,6 +33,7 @@ #include "ir/ts/tsEnumDeclaration.h" #include "ir/ts/tsEnumMember.h" #include "checker/types/ets/types.h" + namespace ark::es2panda::compiler { // #22952: this should have been done in lowering diff --git a/ets2panda/compiler/core/JSCompiler.cpp b/ets2panda/compiler/core/JSCompiler.cpp index f283dccf564d299d738c7f12bc33b745c5d6b5d4..ae972bc379c40df5ac9b87ca73bf98e39931ec7a 100644 --- a/ets2panda/compiler/core/JSCompiler.cpp +++ b/ets2panda/compiler/core/JSCompiler.cpp @@ -15,6 +15,8 @@ #include "JSCompiler.h" +#include "ir/expressions/typeofExpression.h" + #include "varbinder/varbinder.h" #include "compiler/base/catchTable.h" #include "compiler/base/condition.h" @@ -1740,4 +1742,66 @@ void JSCompiler::Compile(const ir::WhileStatement *st) const PandaGen *pg = GetPandaGen(); CompileImpl(st, pg); } + } // namespace ark::es2panda::compiler + +namespace ark::es2panda::ir { + +void ChainExpression::CompileToReg(compiler::PandaGen *pg, compiler::VReg &objReg) const +{ + compiler::OptionalChain chain(pg, this); + + if (expression_->IsMemberExpression()) { + objReg = pg->AllocReg(); + expression_->AsMemberExpression()->CompileToReg(pg, objReg); + } else { + objReg = compiler::VReg::Invalid(); + expression_->Compile(pg); + } +} + +void MemberExpression::CompileToRegs(compiler::PandaGen *pg, compiler::VReg object, compiler::VReg property) const +{ + object_->Compile(pg); + pg->StoreAccumulator(this, object); + + pg->OptionalChainCheck(IsOptional(), object); + + if (!computed_) { + pg->LoadAccumulatorString(this, property_->AsIdentifier()->Name()); + } else { + property_->Compile(pg); + } + + pg->StoreAccumulator(this, property); +} + +void MemberExpression::CompileToReg(compiler::PandaGen *pg, compiler::VReg objReg) const +{ + object_->Compile(pg); + pg->StoreAccumulator(this, objReg); + pg->OptionalChainCheck(IsOptional(), objReg); + LoadRhs(pg); +} + +void MemberExpression::LoadRhs(compiler::PandaGen *pg) const +{ + compiler::RegScope rs(pg); + bool isSuper = object_->IsSuperExpression(); + compiler::Operand prop = pg->ToPropertyKey(property_, computed_, isSuper); + + if (isSuper) { + pg->LoadSuperProperty(this, prop); + } else if (IsPrivateReference()) { + const auto &name = property_->AsIdentifier()->Name(); + compiler::VReg objReg = pg->AllocReg(); + pg->StoreAccumulator(this, objReg); + compiler::VReg ctor = pg->AllocReg(); + compiler::Function::LoadClassContexts(this, pg, ctor, name); + pg->ClassPrivateFieldGet(this, ctor, objReg, name); + } else { + pg->LoadObjProperty(this, prop); + } +} + +} // namespace ark::es2panda::ir diff --git a/ets2panda/compiler/core/codeGen.h b/ets2panda/compiler/core/codeGen.h index 18ea3b653849dd458964267f5629de224f4fb522..77f98085f7eb31631e364dccfa74242a9cfc4aa6 100644 --- a/ets2panda/compiler/core/codeGen.h +++ b/ets2panda/compiler/core/codeGen.h @@ -20,6 +20,8 @@ #include "compiler/core/ASTCompiler.h" #include "compiler/core/regAllocator.h" #include "compiler/core/regScope.h" +#include "libarkbase/utils/arena_list.h" + namespace ark::es2panda::compiler { class CatchTable; class DynamicContext; diff --git a/ets2panda/compiler/core/compilerImpl.cpp b/ets2panda/compiler/core/compilerImpl.cpp index 5436e1e0b5b84ff71e7eeb4f4b92cc7ba180a8ff..e68623b1217f14284b626e0090d626adc0658de0 100644 --- a/ets2panda/compiler/core/compilerImpl.cpp +++ b/ets2panda/compiler/core/compilerImpl.cpp @@ -49,6 +49,9 @@ #include "varbinder/ASBinder.h" #include "varbinder/TSBinder.h" #include "varbinder/ETSBinder.h" +#include "ir/srcDump.h" + +#include "libarkbase/os/filesystem.h" namespace ark::es2panda::compiler { diff --git a/ets2panda/compiler/core/pandagen.cpp b/ets2panda/compiler/core/pandagen.cpp index d4602f2bea1f95b76eb8524b511ff0543b2329a4..21724d143e5824daf392287357dde226ec68d29e 100644 --- a/ets2panda/compiler/core/pandagen.cpp +++ b/ets2panda/compiler/core/pandagen.cpp @@ -36,10 +36,21 @@ #include "generated/isa.h" #include "ir/base/scriptFunction.h" #include "ir/base/spreadElement.h" +#include "ir/base/overloadDeclaration.h" #include "ir/statement.h" +#include "ir/statements/annotationDeclaration.h" #include "ir/expressions/identifier.h" #include "ir/expressions/literals/numberLiteral.h" #include "ir/expressions/literals/stringLiteral.h" +#include "ir/expressions/typeofExpression.h" +#include "ir/ets/etsUnionType.h" +#include "ir/ets/etsIntrinsicNode.h" +#include "ir/ets/etsNeverType.h" +#include "ir/ets/etsNullishTypes.h" +#include "ir/ets/etsNonNullishTypeNode.h" +#include "ir/ets/etsStringLiteralType.h" +#include "ir/ets/etsKeyofType.h" +#include "ir/brokenTypeNode.h" namespace ark::es2panda::compiler { @@ -1833,3 +1844,785 @@ const checker::Type *PandaGen::GetVRegType(VReg vreg) const } } // namespace ark::es2panda::compiler + +namespace ark::es2panda::ir { + +void PrefixAssertionExpression::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void NamedType::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void ETSFunctionType::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void ETSPackageDeclaration::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void ETSNewClassInstanceExpression::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void ETSClassLiteral::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void ETSTypeReferencePart::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void ETSPrimitiveType::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void ETSTypeReference::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void ETSNewMultiDimArrayInstanceExpression::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void ETSWildcardType::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void ETSNewArrayInstanceExpression::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void TSUndefinedKeyword::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void TSBooleanKeyword::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void TSExternalModuleReference::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void TSEnumMember::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void TSStringKeyword::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void TSEnumDeclaration::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void TSAnyKeyword::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void TSVoidKeyword::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void TSNumberKeyword::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void TSUnknownKeyword::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void ImportDeclaration::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void ExportSpecifier::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void ImportDefaultSpecifier::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void ExportAllDeclaration::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void ExportDefaultDeclaration::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void ExportNamedDeclaration::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void ImportSpecifier::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void ImportNamespaceSpecifier::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void ThisExpression::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void AssignmentExpression::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void FunctionExpression::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void OmittedExpression::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void ChainExpression::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void ArrayExpression::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void MemberExpression::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void UpdateExpression::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void DirectEvalExpression::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void DummyNode::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void ClassExpression::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void AwaitExpression::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void BinaryExpression::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void SuperExpression::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void ImportExpression::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void TaggedTemplateExpression::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void UnaryExpression::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void Identifier::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void SequenceExpression::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void BooleanLiteral::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void UndefinedLiteral::Compile(compiler::PandaGen *pg) const +{ + pg->LoadConst(this, compiler::Constant::JS_UNDEFINED); +} + +void NumberLiteral::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void StringLiteral::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void BigIntLiteral::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void NullLiteral::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void RegExpLiteral::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void TypeofExpression::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void NewExpression::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void CallExpression::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void ArrowFunctionExpression::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void ConditionalExpression::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void CatchClause::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void ClassDefinition::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void TSSignatureDeclaration::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void TSMethodSignature::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void Decorator::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void MetaProperty::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void ClassStaticBlock::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void ClassProperty::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void Property::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void TSPropertySignature::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void TSIndexSignature::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void TemplateElement::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void MethodDefinition::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void ScriptFunction::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void FunctionDeclaration::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void VariableDeclaration::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void SwitchStatement::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void AnnotationUsage::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void AnnotationDeclaration::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void ForUpdateStatement::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void LabelledStatement::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void ExpressionStatement::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void ThrowStatement::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void EmptyStatement::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void DebuggerStatement::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void IfStatement::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void ForOfStatement::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void ForInStatement::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void ContinueStatement::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void SwitchCaseStatement::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void DoWhileStatement::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void ClassDeclaration::Compile(compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void ETSIntrinsicNode::Compile([[maybe_unused]] compiler::PandaGen *pg) const {} + +void ETSUnionType::Compile([[maybe_unused]] compiler::PandaGen *pg) const {} + +void ETSNeverType::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + ES2PANDA_UNREACHABLE(); +} + +void ETSUndefinedType::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + ES2PANDA_UNREACHABLE(); +} + +void ETSNullType::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + ES2PANDA_UNREACHABLE(); +} + +void ETSNonNullishTypeNode::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + ES2PANDA_UNREACHABLE(); +} + +void ETSStringLiteralType::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + ES2PANDA_UNREACHABLE(); +} + +void ETSKeyofType::Compile([[maybe_unused]] compiler::PandaGen *pg) const {} + +void TSConditionalType::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void TSMappedType::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void TSTypePredicate::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void TSTypeAssertion::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void TSParenthesizedType::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void TSTypeParameter::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void TSTypeParameterDeclaration::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void TSTypeAliasDeclaration::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void TSNonNullExpression::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void TSInterfaceBody::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void TSThisType::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void TSConstructorType::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void TSIndexedAccessType::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void TSTypeOperator::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void TSParameterProperty::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void TSQualifiedName::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void TSInterfaceDeclaration::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void TSInferType::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void TSTypeLiteral::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void TSTypeReference::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void TSBigintKeyword::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void TSModuleBlock::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void TSNullKeyword::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void TSTypeParameterInstantiation::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void TSTupleType::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void TSLiteralType::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void TSNamedTupleMember::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void TSAsExpression::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void TSNeverKeyword::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void TSObjectKeyword::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void TSImportEqualsDeclaration::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void TSInterfaceHeritage::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void TSTypeQuery::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void TSFunctionType::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void TSIntersectionType::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void TSModuleDeclaration::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void TSClassImplements::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void TSUnionType::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void TSArrayType::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void TSImportType::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void BrokenTypeNode::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void ObjectExpression::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void BlockExpression::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + ES2PANDA_UNREACHABLE(); +} + +void YieldExpression::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void TemplateLiteral::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void CharLiteral::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void SpreadElement::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void OverloadDeclaration::Compile([[maybe_unused]] compiler::PandaGen *pg) const {} + +void ReturnStatement::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void AssertStatement::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void TryStatement::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void WhileStatement::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void BlockStatement::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void VariableDeclarator::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void BreakStatement::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void OpaqueTypeNode::Compile([[maybe_unused]] compiler::PandaGen *pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +void ETSParameterExpression::Compile(compiler::PandaGen *const pg) const +{ + pg->GetAstCompiler()->Compile(this); +} + +} // namespace ark::es2panda::ir diff --git a/ets2panda/compiler/lowering/ets/ambientLowering.cpp b/ets2panda/compiler/lowering/ets/ambientLowering.cpp index 42a817dfe66ba4d7456c8df16b9c9a9ad682a7c1..5ba41717fdc81494703de34500f81236106de10d 100644 --- a/ets2panda/compiler/lowering/ets/ambientLowering.cpp +++ b/ets2panda/compiler/lowering/ets/ambientLowering.cpp @@ -16,8 +16,12 @@ #include "ambientLowering.h" #include -#include "ir/expressions/dummyNode.h" +#include "ir/typeNode.h" #include "ir/astNode.h" +#include "ir/base/methodDefinition.h" +#include "ir/expressions/dummyNode.h" +#include "ir/ts/tsInterfaceBody.h" + #include "compiler/lowering/util.h" namespace ark::es2panda::compiler { diff --git a/ets2panda/compiler/lowering/ets/annotationCopyLowering.cpp b/ets2panda/compiler/lowering/ets/annotationCopyLowering.cpp index 8735f3483e0ae602d52e55c9299a1b6460758a8e..58542cbf1c00afb5b98a846ca52fece3dced8f6c 100644 --- a/ets2panda/compiler/lowering/ets/annotationCopyLowering.cpp +++ b/ets2panda/compiler/lowering/ets/annotationCopyLowering.cpp @@ -16,6 +16,8 @@ #include "annotationCopyLowering.h" #include "compiler/lowering/util.h" +#include "ir/typeNode.h" +#include "ir/base/classProperty.h" namespace ark::es2panda::compiler { diff --git a/ets2panda/compiler/lowering/ets/annotationCopyPostLowering.cpp b/ets2panda/compiler/lowering/ets/annotationCopyPostLowering.cpp index 4e101eacafda7a37a41a87a6c793afaac0513ce6..32f28222fdb8b62b26ce3202047e6261e1e8372f 100644 --- a/ets2panda/compiler/lowering/ets/annotationCopyPostLowering.cpp +++ b/ets2panda/compiler/lowering/ets/annotationCopyPostLowering.cpp @@ -16,6 +16,7 @@ #include "annotationCopyPostLowering.h" #include "compiler/lowering/util.h" +#include "ir/base/classProperty.h" namespace ark::es2panda::compiler { diff --git a/ets2panda/compiler/lowering/ets/arrayLiteralLowering.cpp b/ets2panda/compiler/lowering/ets/arrayLiteralLowering.cpp index 0018944189b3c2315850bcd3120669953d6e7c0e..1a986127d673c68e08b7111f1e094b0476bf5274 100644 --- a/ets2panda/compiler/lowering/ets/arrayLiteralLowering.cpp +++ b/ets2panda/compiler/lowering/ets/arrayLiteralLowering.cpp @@ -20,11 +20,23 @@ #include "compiler/lowering/util.h" #include "ir/astNode.h" +#include "ir/opaqueTypeNode.h" + #include "ir/expressions/literals/numberLiteral.h" +#include "ir/expressions/arrayExpression.h" +#include "ir/expressions/blockExpression.h" +#include "ir/expressions/memberExpression.h" + +#include "ir/statements/forUpdateStatement.h" + +#include "ir/ets/etsNewMultiDimArrayInstanceExpression.h" + #include "lexer/token/number.h" #include "util/es2pandaMacros.h" #include "checker/ETSchecker.h" -#include "libarkbase/utils/arena_containers.h" + + +#include "varbinder/variable.h" namespace ark::es2panda::compiler { diff --git a/ets2panda/compiler/lowering/ets/arrayLiteralLowering.h b/ets2panda/compiler/lowering/ets/arrayLiteralLowering.h index 9055c2f233301bb80a476cc2a765477d10dffa43..476135e4ab5ade414831ce38319823aaa29e644b 100644 --- a/ets2panda/compiler/lowering/ets/arrayLiteralLowering.h +++ b/ets2panda/compiler/lowering/ets/arrayLiteralLowering.h @@ -22,7 +22,6 @@ #include "ir/ets/etsNewArrayInstanceExpression.h" #include "ir/ts/tsArrayType.h" #include "parser/ETSparser.h" -#include "libarkbase/utils/arena_containers.h" #include "varbinder/ETSBinder.h" namespace ark::es2panda::compiler { diff --git a/ets2panda/compiler/lowering/ets/asyncMethodLowering.cpp b/ets2panda/compiler/lowering/ets/asyncMethodLowering.cpp index 7283b469f5621f520dae3328d144ddd035e214e9..1928f08bf39dd18c27820db56e3e6bf31616052b 100644 --- a/ets2panda/compiler/lowering/ets/asyncMethodLowering.cpp +++ b/ets2panda/compiler/lowering/ets/asyncMethodLowering.cpp @@ -19,6 +19,10 @@ #include "checker/types/ets/etsAsyncFuncReturnType.h" #include "compiler/lowering/util.h" +#include "ir/base/methodDefinition.h" +#include "ir/ets/etsTypeReference.h" +#include "ir/ets/etsTypeReferencePart.h" + namespace ark::es2panda::compiler { std::string_view AsyncMethodLowering::Name() const diff --git a/ets2panda/compiler/lowering/ets/binaryExpressionLowering.cpp b/ets2panda/compiler/lowering/ets/binaryExpressionLowering.cpp index 4662d8a75e519852d0ef84bd30fc52107e802c26..dae6ef98e8a1c2ff3a609dc4ebd00a805f6622d0 100644 --- a/ets2panda/compiler/lowering/ets/binaryExpressionLowering.cpp +++ b/ets2panda/compiler/lowering/ets/binaryExpressionLowering.cpp @@ -17,6 +17,7 @@ #include "binaryExpressionLowering.h" #include "compiler/lowering/util.h" +#include "ir/expressions/binaryExpression.h" namespace ark::es2panda::compiler { diff --git a/ets2panda/compiler/lowering/ets/boxingForLocals.cpp b/ets2panda/compiler/lowering/ets/boxingForLocals.cpp index 74f2bfa462c39cfe282a91eac8d210dfef774860..a25ac58e8cc8ae3b0eef265ea308e9bfaf89a867 100644 --- a/ets2panda/compiler/lowering/ets/boxingForLocals.cpp +++ b/ets2panda/compiler/lowering/ets/boxingForLocals.cpp @@ -18,6 +18,17 @@ #include "compiler/lowering/util.h" #include "checker/ETSchecker.h" +#include "checker/types/ets/etsObjectType.h" + +#include "ir/opaqueTypeNode.h" +#include "ir/expressions/assignmentExpression.h" +#include "ir/expressions/callExpression.h" +#include "ir/expressions/memberExpression.h" +#include "ir/expressions/typeofExpression.h" +#include "ir/statements/variableDeclarator.h" +#include "ir/statements/variableDeclaration.h" +#include "ir/ts/tsAsExpression.h" +#include "ir/ets/etsNewClassInstanceExpression.h" namespace ark::es2panda::compiler { diff --git a/ets2panda/compiler/lowering/ets/capturedVariables.cpp b/ets2panda/compiler/lowering/ets/capturedVariables.cpp index 442e5f55d9e4444c0b8d9a9f3567c2519cfb452c..ee22ac1c30df45f2ad7ab9d6ad1e8c625066e569 100644 --- a/ets2panda/compiler/lowering/ets/capturedVariables.cpp +++ b/ets2panda/compiler/lowering/ets/capturedVariables.cpp @@ -14,6 +14,10 @@ */ #include "capturedVariables.h" + +#include "ir/base/scriptFunction.h" +#include "ir/expressions/assignmentExpression.h" + #include "util/options.h" namespace ark::es2panda::compiler { diff --git a/ets2panda/compiler/lowering/ets/constantExpressionLowering.cpp b/ets2panda/compiler/lowering/ets/constantExpressionLowering.cpp index cdfae6f6df0ab86d61f944fed5e75daa1344d535..c5f99a28de2ebc762c02505054691cab51b2a545 100644 --- a/ets2panda/compiler/lowering/ets/constantExpressionLowering.cpp +++ b/ets2panda/compiler/lowering/ets/constantExpressionLowering.cpp @@ -20,8 +20,12 @@ #include "checker/ETSchecker.h" #include "checker/types/typeError.h" -#include "compiler/lowering/util.h" + #include "ir/expressions/literals/undefinedLiteral.h" +#include "ir/expressions/literals/numberLiteral.h" +#include "ir/expressions/templateLiteral.h" + +#include "compiler/lowering/util.h" #include "compiler/lowering/scopesInit/scopesInitPhase.h" #include "util/helpers.h" #include "libarkbase/utils/small_vector.h" diff --git a/ets2panda/compiler/lowering/ets/constantExpressionLowering.h b/ets2panda/compiler/lowering/ets/constantExpressionLowering.h index 487cbeaa2a01ad947d1c8296de9e156c70383058..6728ea345682ebb1a8432e70b37ea04c3214f5a2 100644 --- a/ets2panda/compiler/lowering/ets/constantExpressionLowering.h +++ b/ets2panda/compiler/lowering/ets/constantExpressionLowering.h @@ -17,6 +17,8 @@ #define ES2PANDA_COMPILER_LOWERING_CONSTANT_EXPRESSION_LOWERING_H #include "compiler/lowering/phase.h" +#include "ir/expressions/literals/numberLiteral.h" +#include "ir/expressions/templateLiteral.h" namespace ark::es2panda::compiler { diff --git a/ets2panda/compiler/lowering/ets/convertPrimitiveCastMethodCall.cpp b/ets2panda/compiler/lowering/ets/convertPrimitiveCastMethodCall.cpp index 0009d6ef8f8b3b5a78edc909e83d3ba7d9bd16ac..a8b54d16be41b3b6061de830d13a974c78251aca 100644 --- a/ets2panda/compiler/lowering/ets/convertPrimitiveCastMethodCall.cpp +++ b/ets2panda/compiler/lowering/ets/convertPrimitiveCastMethodCall.cpp @@ -18,6 +18,13 @@ #include "checker/ETSchecker.h" #include "compiler/lowering/util.h" +#include "ir/opaqueTypeNode.h" + +#include "ir/expressions/callExpression.h" +#include "ir/expressions/memberExpression.h" + +#include "ir/ts/tsAsExpression.h" + namespace ark::es2panda::compiler { std::string_view ConvertPrimitiveCastMethodCall::Name() const diff --git a/ets2panda/compiler/lowering/ets/declGenPhase.cpp b/ets2panda/compiler/lowering/ets/declGenPhase.cpp index 85f273288a08667cd2b208b5f93036f7258049b2..89c82ee5e4eb834a37c8566ae7106d6c764bf0c1 100644 --- a/ets2panda/compiler/lowering/ets/declGenPhase.cpp +++ b/ets2panda/compiler/lowering/ets/declGenPhase.cpp @@ -20,6 +20,8 @@ #include "compiler/lowering/util.h" #include "ir/ets/etsPackageDeclaration.h" +#include "ir/base/classProperty.h" + namespace ark::es2panda::compiler { constexpr std::string_view MODULE_DECLARATION_NAME {"ModuleDeclaration"}; diff --git a/ets2panda/compiler/lowering/ets/declareOverloadLowering.cpp b/ets2panda/compiler/lowering/ets/declareOverloadLowering.cpp index ad3cebeced6a13ed458e27f8656c5ab8b21e2295..cfec769c6837807ca579193421357986cff11990 100644 --- a/ets2panda/compiler/lowering/ets/declareOverloadLowering.cpp +++ b/ets2panda/compiler/lowering/ets/declareOverloadLowering.cpp @@ -14,6 +14,7 @@ */ #include "declareOverloadLowering.h" +#include "checker/types/ets/etsFunctionType.h" #include "compiler/lowering/scopesInit/scopesInitPhase.h" #include "compiler/lowering/util.h" diff --git a/ets2panda/compiler/lowering/ets/defaultParametersInConstructorLowering.cpp b/ets2panda/compiler/lowering/ets/defaultParametersInConstructorLowering.cpp index dca94d1802e80480b9ddc3753b2d5e9dff37eede..398ee68c36e6edc427722a1ff7994a75ea71ee07 100644 --- a/ets2panda/compiler/lowering/ets/defaultParametersInConstructorLowering.cpp +++ b/ets2panda/compiler/lowering/ets/defaultParametersInConstructorLowering.cpp @@ -14,9 +14,25 @@ */ #include "defaultParametersInConstructorLowering.h" -#include "ir/expression.h" + +#include "ir/base/methodDefinition.h" +#include "ir/base/scriptFunction.h" + +#include "ir/statements/expressionStatement.h" + +#include "ir/expressions/callExpression.h" +#include "ir/expressions/functionExpression.h" #include "ir/expressions/literals/undefinedLiteral.h" +#include "ir/expressions/thisExpression.h" + +#include "ir/ts/tsTypeParameter.h" +#include "ir/ts/tsTypeParameterDeclaration.h" +#include "ir/ts/tsTypeParameterInstantiation.h" + +#include "ir/ets/etsTypeReference.h" +#include "ir/ets/etsTypeReferencePart.h" #include "ir/ets/etsUnionType.h" +#include "ir/ets/etsNullishTypes.h" namespace ark::es2panda::compiler { diff --git a/ets2panda/compiler/lowering/ets/defaultParametersLowering.cpp b/ets2panda/compiler/lowering/ets/defaultParametersLowering.cpp index 202af9d21ad15e670bee02185a4e4d9c356198aa..67e048ee51e289e0d7f250dffe6c64cad8658938 100644 --- a/ets2panda/compiler/lowering/ets/defaultParametersLowering.cpp +++ b/ets2panda/compiler/lowering/ets/defaultParametersLowering.cpp @@ -15,6 +15,7 @@ #include "defaultParametersLowering.h" #include "compiler/lowering/util.h" +#include "ir/typeNode.h" namespace ark::es2panda::compiler { diff --git a/ets2panda/compiler/lowering/ets/dynamicImport.cpp b/ets2panda/compiler/lowering/ets/dynamicImport.cpp index 4622facfe7afe2981d358cfd19b5af9328b1d301..9386ca0eb8c40ab376935f13f432db4d3cf380e9 100644 --- a/ets2panda/compiler/lowering/ets/dynamicImport.cpp +++ b/ets2panda/compiler/lowering/ets/dynamicImport.cpp @@ -17,11 +17,14 @@ #include #include #include "checker/ETSchecker.h" +#include "checker/types/ets/etsObjectType.h" #include "ir/astNode.h" #include "compiler/lowering/util.h" #include "compiler/lowering/scopesInit/scopesInitPhase.h" +#include "libarkbase/os/filesystem.h" + namespace ark::es2panda::compiler { using AstNodePtr = ir::AstNode *; diff --git a/ets2panda/compiler/lowering/ets/dynamicImport.h b/ets2panda/compiler/lowering/ets/dynamicImport.h index 2f12f755c6343ac04893da35f413fc3f7fe382a4..4eb6d0353ce4ff38cd9d25b0368ad960840ccd25 100644 --- a/ets2panda/compiler/lowering/ets/dynamicImport.h +++ b/ets2panda/compiler/lowering/ets/dynamicImport.h @@ -17,7 +17,6 @@ #define ES2PANDA_COMPILER_LOWERING_LAZY_IMPORT_OBJECT_H #include "compiler/lowering/phase.h" -#include "libarkbase/utils/arena_containers.h" namespace ark::es2panda::compiler { diff --git a/ets2panda/compiler/lowering/ets/enumLowering.cpp b/ets2panda/compiler/lowering/ets/enumLowering.cpp index d935d7a4dc32347bd979a5f3bda886f69813bed1..9f29f4fad22dc36361bdcd89ddc83ff3810adad1 100644 --- a/ets2panda/compiler/lowering/ets/enumLowering.cpp +++ b/ets2panda/compiler/lowering/ets/enumLowering.cpp @@ -18,7 +18,6 @@ #include #include "checker/ETSchecker.h" -#include "checker/types/ets/etsEnumType.h" #include "checker/types/type.h" #include "compiler/lowering/scopesInit/scopesInitPhase.h" #include "compiler/lowering/util.h" diff --git a/ets2panda/compiler/lowering/ets/enumLowering.h b/ets2panda/compiler/lowering/ets/enumLowering.h index f95443c8ce783deb8a2c3d27d974a2d4dcf85424..602ff2eb7cc1e2cf306eeb8df1e05b469d2781ce 100644 --- a/ets2panda/compiler/lowering/ets/enumLowering.h +++ b/ets2panda/compiler/lowering/ets/enumLowering.h @@ -20,6 +20,9 @@ #include #include "compiler/lowering/phase.h" #include "checker/ETSchecker.h" +#include "checker/types/ets/etsEnumType.h" + +#include "ir/ets/etsPrimitiveType.h" namespace ark::es2panda::compiler { diff --git a/ets2panda/compiler/lowering/ets/enumPostCheckLowering.cpp b/ets2panda/compiler/lowering/ets/enumPostCheckLowering.cpp index 3551988cce23a1d604b5355a6d853d6917efacb1..531abdbcbcdd1179cda78d4421d1dd00da2f4614 100644 --- a/ets2panda/compiler/lowering/ets/enumPostCheckLowering.cpp +++ b/ets2panda/compiler/lowering/ets/enumPostCheckLowering.cpp @@ -19,18 +19,34 @@ #include "checker/ETSchecker.h" #include "checker/types/type.h" #include "checker/types/ets/etsEnumType.h" +#include "checker/types/ets/etsUnionType.h" #include "compiler/lowering/util.h" + #include "ir/astNode.h" -#include "ir/expressions/identifier.h" +#include "ir/typeNode.h" + #include "ir/statements/ifStatement.h" +#include "ir/statements/switchStatement.h" +#include "ir/statements/switchCaseStatement.h" + +#include "ir/expressions/binaryExpression.h" +#include "ir/expressions/blockExpression.h" +#include "ir/expressions/callExpression.h" +#include "ir/expressions/identifier.h" + #include "ir/ts/tsAsExpression.h" -#include "libarkbase/macros.h" + +#include "ir/ets/etsTypeReference.h" +#include "ir/ets/etsTypeReferencePart.h" + #include "parser/ETSparser.h" #include "util.h" #include "util/ustring.h" #include "varbinder/ETSBinder.h" #include "varbinder/variable.h" +#include "libarkbase/macros.h" + namespace ark::es2panda::compiler { static ir::ClassDeclaration *FindEnclosingClass(ir::AstNode *ast) diff --git a/ets2panda/compiler/lowering/ets/expandBrackets.cpp b/ets2panda/compiler/lowering/ets/expandBrackets.cpp index 2f865dca1e7a3cf14adffe94625b949550eab0d7..bc7b60db5ce7af7059db68e483b20dd24abbd98d 100644 --- a/ets2panda/compiler/lowering/ets/expandBrackets.cpp +++ b/ets2panda/compiler/lowering/ets/expandBrackets.cpp @@ -16,6 +16,7 @@ #include "expandBrackets.h" #include "checker/ETSchecker.h" +#include "checker/types/ets/etsObjectType.h" #include "compiler/lowering/util.h" #include "compiler/lowering/scopesInit/scopesInitPhase.h" diff --git a/ets2panda/compiler/lowering/ets/exportAnonymousConst.cpp b/ets2panda/compiler/lowering/ets/exportAnonymousConst.cpp index 3f201ed802f72b4204816e4be3ff7b52fccae095..47822cf38f684b00322c65e0c4ea184fb92dabfb 100644 --- a/ets2panda/compiler/lowering/ets/exportAnonymousConst.cpp +++ b/ets2panda/compiler/lowering/ets/exportAnonymousConst.cpp @@ -13,6 +13,13 @@ * limitations under the License. */ +#include "ir/module/exportNamedDeclaration.h" +#include "ir/module/exportSpecifier.h" + +#include "ir/expressions/blockExpression.h" + +#include "ir/statements/variableDeclaration.h" + #include "compiler/lowering/ets/exportAnonymousConst.h" #include "compiler/lowering/util.h" #include "libarkbase/macros.h" diff --git a/ets2panda/compiler/lowering/ets/expressionLambdaLowering.cpp b/ets2panda/compiler/lowering/ets/expressionLambdaLowering.cpp index e09b2b2af2af853efb2be5e21146110323dafef6..a80bfbdac8cceb0813ba14f4fcd09799a452abdc 100644 --- a/ets2panda/compiler/lowering/ets/expressionLambdaLowering.cpp +++ b/ets2panda/compiler/lowering/ets/expressionLambdaLowering.cpp @@ -16,6 +16,10 @@ #include "expressionLambdaLowering.h" #include "checker/ETSchecker.h" +#include "ir/expressions/arrowFunctionExpression.h" +#include "ir/statements/expressionStatement.h" +#include "ir/ets/etsPrimitiveType.h" + namespace ark::es2panda::compiler { static ir::AstNode *ConvertExpression(public_lib::Context *ctx, ir::ArrowFunctionExpression *const arrow) { diff --git a/ets2panda/compiler/lowering/ets/extensionAccessorLowering.cpp b/ets2panda/compiler/lowering/ets/extensionAccessorLowering.cpp index 0ec34677b128076d59b37fbe0d7286057cef08c1..097065dcc9c85da52ccd8193a7bbb3e65e502fcf 100644 --- a/ets2panda/compiler/lowering/ets/extensionAccessorLowering.cpp +++ b/ets2panda/compiler/lowering/ets/extensionAccessorLowering.cpp @@ -15,6 +15,7 @@ #include "extensionAccessorLowering.h" #include "checker/ETSchecker.h" +#include "checker/types/ets/etsFunctionType.h" #include "compiler/lowering/scopesInit/scopesInitPhase.h" #include "compiler/lowering/util.h" diff --git a/ets2panda/compiler/lowering/ets/genericBridgesLowering.cpp b/ets2panda/compiler/lowering/ets/genericBridgesLowering.cpp index 0fa3241d61db19757895a373c2216c0339a7d6bd..ef227ef0a545f854e7e31697a73bf003f33d8f53 100644 --- a/ets2panda/compiler/lowering/ets/genericBridgesLowering.cpp +++ b/ets2panda/compiler/lowering/ets/genericBridgesLowering.cpp @@ -14,8 +14,12 @@ */ #include "genericBridgesLowering.h" +#include "checker/types/ets/etsFunctionType.h" +#include "checker/types/ets/etsObjectType.h" +#include "checker/types/ets/etsTypeParameter.h" #include "compiler/lowering/scopesInit/scopesInitPhase.h" + #include "compiler/lowering/util.h" #include diff --git a/ets2panda/compiler/lowering/ets/insertOptionalParametersAnnotation.cpp b/ets2panda/compiler/lowering/ets/insertOptionalParametersAnnotation.cpp index a0e812bba6bb0789a1ec512638a812a205c0b73e..dd35923f3b31a227fd26681d714655f5dc2508ec 100644 --- a/ets2panda/compiler/lowering/ets/insertOptionalParametersAnnotation.cpp +++ b/ets2panda/compiler/lowering/ets/insertOptionalParametersAnnotation.cpp @@ -16,6 +16,13 @@ #include "insertOptionalParametersAnnotation.h" #include "compiler/lowering/util.h" +#include "ir/base/classProperty.h" +#include "ir/base/methodDefinition.h" +#include "ir/expressions/literals/numberLiteral.h" +#include "ir/ts/tsQualifiedName.h" +#include "ir/ets/etsTypeReference.h" +#include "ir/ets/etsTypeReferencePart.h" + namespace ark::es2panda::compiler { using UAlloc = util::NodeAllocator; diff --git a/ets2panda/compiler/lowering/ets/interfaceObjectLiteralLowering.cpp b/ets2panda/compiler/lowering/ets/interfaceObjectLiteralLowering.cpp index ee5076286e62c273e3b2ac5adc30c5b076c034a2..b9ac823fc45e8b55cbc9203d1b0c4a2e088e05a3 100644 --- a/ets2panda/compiler/lowering/ets/interfaceObjectLiteralLowering.cpp +++ b/ets2panda/compiler/lowering/ets/interfaceObjectLiteralLowering.cpp @@ -16,9 +16,22 @@ #include "interfaceObjectLiteralLowering.h" #include "checker/ETSchecker.h" #include "checker/ets/typeRelationContext.h" +#include "checker/types/ets/etsFunctionType.h" #include "compiler/lowering/util.h" #include "generated/signatures.h" + +#include "ir/opaqueTypeNode.h" + +#include "ir/base/classProperty.h" +#include "ir/base/methodDefinition.h" + +#include "ir/expressions/arrayExpression.h" #include "ir/expressions/assignmentExpression.h" +#include "ir/expressions/objectExpression.h" + +#include "ir/ts/tsClassImplements.h" +#include "ir/ts/tsInterfaceBody.h" + #include "util/helpers.h" #include "util/nameMangler.h" diff --git a/ets2panda/compiler/lowering/ets/interfacePropertyDeclarations.cpp b/ets2panda/compiler/lowering/ets/interfacePropertyDeclarations.cpp index e3d748001cc78c774362bc78775c9807b715942d..5fa93d0db17a9f82aff53b12a1354566a6b58e20 100644 --- a/ets2panda/compiler/lowering/ets/interfacePropertyDeclarations.cpp +++ b/ets2panda/compiler/lowering/ets/interfacePropertyDeclarations.cpp @@ -17,6 +17,7 @@ #include "checker/ETSchecker.h" #include "checker/types/type.h" +#include "checker/types/ets/etsObjectType.h" #include "compiler/lowering/scopesInit/scopesInitPhase.h" #include "compiler/lowering/util.h" #include "ir/astNode.h" diff --git a/ets2panda/compiler/lowering/ets/lambdaLowering.cpp b/ets2panda/compiler/lowering/ets/lambdaLowering.cpp index 100d4e5cfa0d4fa5241f1b16cff4b9f57e8dc108..c7edbcfbad3e7911653d7de26aa7ea6d27e7f8cc 100644 --- a/ets2panda/compiler/lowering/ets/lambdaLowering.cpp +++ b/ets2panda/compiler/lowering/ets/lambdaLowering.cpp @@ -19,6 +19,8 @@ #include "checker/types/ets/etsTupleType.h" #include "checker/ets/typeRelationContext.h" +#include "checker/types/ets/etsTypeParameter.h" +#include "checker/types/ets/etsFunctionType.h" #include "compiler/lowering/scopesInit/scopesInitPhase.h" #include "compiler/lowering/util.h" #include "ir/astNode.h" diff --git a/ets2panda/compiler/lowering/ets/lateInitialization.cpp b/ets2panda/compiler/lowering/ets/lateInitialization.cpp index 87e878ac135099f51be5e96788c838b633bcc6bc..b354f497c1701bb323d83ab18846fe743f2d55f3 100644 --- a/ets2panda/compiler/lowering/ets/lateInitialization.cpp +++ b/ets2panda/compiler/lowering/ets/lateInitialization.cpp @@ -19,6 +19,13 @@ #include "checker/ETSchecker.h" #include "compiler/lowering/util.h" + +#include "ir/opaqueTypeNode.h" +#include "ir/base/classProperty.h" + +#include "ir/expressions/assignmentExpression.h" +#include "ir/expressions/blockExpression.h" +#include "ir/expressions/memberExpression.h" #include "ir/ets/etsUnionType.h" namespace ark::es2panda::compiler { diff --git a/ets2panda/compiler/lowering/ets/objectIndexAccess.cpp b/ets2panda/compiler/lowering/ets/objectIndexAccess.cpp index bfe3da4967cc6f31694a9c3854d69bbf638bc42c..122eac38a7019e9332c1159594a72dd08d402006 100644 --- a/ets2panda/compiler/lowering/ets/objectIndexAccess.cpp +++ b/ets2panda/compiler/lowering/ets/objectIndexAccess.cpp @@ -27,6 +27,9 @@ #include "compiler/lowering/util.h" #include "parser/ETSparser.h" +#include "ir/expressions/assignmentExpression.h" +#include "ir/expressions/memberExpression.h" + namespace ark::es2panda::compiler { static ir::AstNode *ProcessIndexSetAccess(public_lib::Context *ctx, ir::AssignmentExpression *assignmentExpression) { diff --git a/ets2panda/compiler/lowering/ets/objectIterator.cpp b/ets2panda/compiler/lowering/ets/objectIterator.cpp index 97b55067d982e7073835bd7dd18c985113b4383e..949bd7b63c70705e2c6cada7d061aee4dc1efdd3 100644 --- a/ets2panda/compiler/lowering/ets/objectIterator.cpp +++ b/ets2panda/compiler/lowering/ets/objectIterator.cpp @@ -37,6 +37,9 @@ #include "compiler/lowering/util.h" #include "compiler/lowering/scopesInit/scopesInitPhase.h" #include "checker/ETSchecker.h" +#include "checker/types/ets/etsFunctionType.h" +#include "checker/types/ets/etsObjectType.h" +#include "checker/types/ets/etsUnionType.h" #include "util/options.h" namespace ark::es2panda::compiler { diff --git a/ets2panda/compiler/lowering/ets/objectLiteralLowering.cpp b/ets2panda/compiler/lowering/ets/objectLiteralLowering.cpp index 44908b804d152f93995b8784e68c7581690b6096..5cb28a7485ae2d719c39ea28ce1f6314ea06111f 100644 --- a/ets2panda/compiler/lowering/ets/objectLiteralLowering.cpp +++ b/ets2panda/compiler/lowering/ets/objectLiteralLowering.cpp @@ -15,6 +15,7 @@ #include "objectLiteralLowering.h" #include "checker/ETSchecker.h" +#include "checker/types/ets/etsObjectType.h" #include "compiler/lowering/scopesInit/scopesInitPhase.h" #include "compiler/lowering/util.h" diff --git a/ets2panda/compiler/lowering/ets/opAssignment.cpp b/ets2panda/compiler/lowering/ets/opAssignment.cpp index 44b66ee3d2f22c0e38f59b168e86ef3e95d8f5ad..3343315af5b86498e0f2cb6d7b55a4e1bc1aefa9 100644 --- a/ets2panda/compiler/lowering/ets/opAssignment.cpp +++ b/ets2panda/compiler/lowering/ets/opAssignment.cpp @@ -26,6 +26,8 @@ #include "parser/ETSparser.h" #include "varbinder/ETSBinder.h" #include "checker/ETSchecker.h" +#include "checker/types/ets/etsFunctionType.h" +#include "checker/types/ets/etsObjectType.h" #include "compiler/lowering/util.h" #include "compiler/lowering/scopesInit/scopesInitPhase.h" #include "ir/opaqueTypeNode.h" diff --git a/ets2panda/compiler/lowering/ets/optionalArgumentsLowering.cpp b/ets2panda/compiler/lowering/ets/optionalArgumentsLowering.cpp index c58a3b93f35babb2cac68dabf689fbb6303e6426..5b995fe9522e388d15195d3197ac0cf74f5b8b56 100644 --- a/ets2panda/compiler/lowering/ets/optionalArgumentsLowering.cpp +++ b/ets2panda/compiler/lowering/ets/optionalArgumentsLowering.cpp @@ -16,6 +16,8 @@ #include "optionalArgumentsLowering.h" #include "compiler/lowering/util.h" #include "ir/expressions/literals/undefinedLiteral.h" +#include "ir/expressions/callExpression.h" +#include "ir/ets/etsNewClassInstanceExpression.h" #include "checker/ETSchecker.h" namespace ark::es2panda::compiler { diff --git a/ets2panda/compiler/lowering/ets/overloadMappingLowering.cpp b/ets2panda/compiler/lowering/ets/overloadMappingLowering.cpp index a72a5c6517090a6ecc5faa9b4871714b28856728..532d0c8eb4aa37c3eaf45ff87858effe91103740 100644 --- a/ets2panda/compiler/lowering/ets/overloadMappingLowering.cpp +++ b/ets2panda/compiler/lowering/ets/overloadMappingLowering.cpp @@ -15,6 +15,13 @@ #include "overloadMappingLowering.h" #include "checker/ETSchecker.h" +#include "checker/types/ets/etsFunctionType.h" +#include "checker/types/ets/etsUnionType.h" + +#include "ir/base/methodDefinition.h" +#include "ir/expressions/callExpression.h" +#include "ir/expressions/memberExpression.h" + #include "compiler/lowering/util.h" namespace ark::es2panda::compiler { diff --git a/ets2panda/compiler/lowering/ets/packageImplicitImport.cpp b/ets2panda/compiler/lowering/ets/packageImplicitImport.cpp index 550acfe70304ee28c99440ee24a8549287983357..55d12c8f86201311c89860648912c91375766626 100644 --- a/ets2panda/compiler/lowering/ets/packageImplicitImport.cpp +++ b/ets2panda/compiler/lowering/ets/packageImplicitImport.cpp @@ -16,6 +16,8 @@ #include "packageImplicitImport.h" #include +#include "ir/ets/etsImportDeclaration.h" + namespace ark::es2panda::compiler { static void MergeExternalFilesIntoCompiledProgram(parser::Program *const program, diff --git a/ets2panda/compiler/lowering/ets/partialExportClassGen.cpp b/ets2panda/compiler/lowering/ets/partialExportClassGen.cpp index c5ff7503ad86f4fae165dd7547d3dcee580f28a1..91609617333f6fa41d37279f4995b7b308eb1815 100644 --- a/ets2panda/compiler/lowering/ets/partialExportClassGen.cpp +++ b/ets2panda/compiler/lowering/ets/partialExportClassGen.cpp @@ -15,6 +15,8 @@ #include "partialExportClassGen.h" +#include "ir/ts/tsInterfaceDeclaration.h" + #include "checker/ETSchecker.h" #include "varbinder/ETSBinder.h" diff --git a/ets2panda/compiler/lowering/ets/primitiveConversionPhase.cpp b/ets2panda/compiler/lowering/ets/primitiveConversionPhase.cpp index 5cc70c34e1845053fb67d184be12d8f23ec344f7..17835f49ca13cc5329efd268b1ec94466c4e9e4e 100644 --- a/ets2panda/compiler/lowering/ets/primitiveConversionPhase.cpp +++ b/ets2panda/compiler/lowering/ets/primitiveConversionPhase.cpp @@ -15,6 +15,11 @@ #include "compiler/lowering/util.h" #include "primitiveConversionPhase.h" +#include "checker/types/ets/etsObjectType.h" + +#include "ir/opaqueTypeNode.h" +#include "ir/expressions/memberExpression.h" +#include "ir/expressions/callExpression.h" namespace ark::es2panda::compiler { diff --git a/ets2panda/compiler/lowering/ets/primitiveConversionPhase.h b/ets2panda/compiler/lowering/ets/primitiveConversionPhase.h index 2fdd77510eb20489af22ff65be0ab25014774080..876e7341d93f8275976a049dd31e0f1c03302a3d 100644 --- a/ets2panda/compiler/lowering/ets/primitiveConversionPhase.h +++ b/ets2panda/compiler/lowering/ets/primitiveConversionPhase.h @@ -17,6 +17,7 @@ #define ES2PANDA_COMPILER_LOWERING_PRIMITIVE_CONVERSION_PHASE_H #include "compiler/lowering/phase.h" +#include "checker/types/ets/etsFunctionType.h" namespace ark::es2panda::compiler { diff --git a/ets2panda/compiler/lowering/ets/promiseVoid.cpp b/ets2panda/compiler/lowering/ets/promiseVoid.cpp index 002577cfe512ddad2960f892aaa47cec9801387d..eed4c48b464aa59d842e7ab6f358e62d13acdcb6 100644 --- a/ets2panda/compiler/lowering/ets/promiseVoid.cpp +++ b/ets2panda/compiler/lowering/ets/promiseVoid.cpp @@ -15,6 +15,17 @@ #include "promiseVoid.h" #include "checker/ETSchecker.h" +#include "ir/typeNode.h" + +#include "ir/base/scriptFunction.h" + +#include "ir/statements/returnStatement.h" + +#include "ir/ets/etsTypeReference.h" +#include "ir/ets/etsTypeReferencePart.h" +#include "ir/ets/etsPrimitiveType.h" + +#include "ir/ts/tsTypeParameterInstantiation.h" namespace ark::es2panda::compiler { ir::BlockStatement *PromiseVoidInferencePhase::HandleAsyncScriptFunctionBody(public_lib::Context *ctx, diff --git a/ets2panda/compiler/lowering/ets/recordLowering.cpp b/ets2panda/compiler/lowering/ets/recordLowering.cpp index 8c13718bc00368c3864e7e2578a06a89c88f3fdd..b2de4d39f187ee11ced326451f22f01ca1bcc4ef 100644 --- a/ets2panda/compiler/lowering/ets/recordLowering.cpp +++ b/ets2panda/compiler/lowering/ets/recordLowering.cpp @@ -16,6 +16,16 @@ #include "recordLowering.h" #include "checker/ETSchecker.h" +#include "checker/types/ets/etsTypeParameter.h" +#include "checker/types/ets/etsUnionType.h" +#include "checker/types/ets/byteType.h" +#include "checker/types/ets/charType.h" +#include "checker/types/ets/doubleType.h" +#include "checker/types/ets/floatType.h" +#include "checker/types/ets/intType.h" +#include "checker/types/ets/longType.h" +#include "checker/types/ets/shortType.h" +#include "checker/types/ets/etsStringType.h" #include "checker/types/ets/etsAsyncFuncReturnType.h" #include "compiler/lowering/scopesInit/scopesInitPhase.h" diff --git a/ets2panda/compiler/lowering/ets/relaxedAnyLowering.cpp b/ets2panda/compiler/lowering/ets/relaxedAnyLowering.cpp index 45c06c1cec15a30aef3ae3a4a309806aa903d4c8..54db4b575018b3a88772784dfbb9314ef2359a58 100644 --- a/ets2panda/compiler/lowering/ets/relaxedAnyLowering.cpp +++ b/ets2panda/compiler/lowering/ets/relaxedAnyLowering.cpp @@ -14,7 +14,24 @@ */ #include "relaxedAnyLowering.h" +#include "checker/types/ets/etsFunctionType.h" +#include "checker/types/ets/etsUnionType.h" +#include "checker/types/ets/etsObjectType.h" + +#include "ir/opaqueTypeNode.h" +#include "ir/expressions/assignmentExpression.h" +#include "ir/expressions/binaryExpression.h" +#include "ir/expressions/callExpression.h" #include "ir/expressions/memberExpression.h" +#include "ir/expressions/literals/stringLiteral.h" + +#include "ir/ets/etsTypeReference.h" +#include "ir/ets/etsTypeReferencePart.h" +#include "ir/ets/etsIntrinsicNode.h" +#include "ir/ets/etsNewClassInstanceExpression.h" + +#include "ir/ts/tsAsExpression.h" +#include "ir/ts/tsQualifiedName.h" namespace ark::es2panda::compiler { diff --git a/ets2panda/compiler/lowering/ets/resizableArrayLowering.cpp b/ets2panda/compiler/lowering/ets/resizableArrayLowering.cpp index 1df54ca9304c4c4f4ed0679a8b81a079a95e5ca2..dd5b59b670276be73ff32d671c2a27f38e606c0b 100644 --- a/ets2panda/compiler/lowering/ets/resizableArrayLowering.cpp +++ b/ets2panda/compiler/lowering/ets/resizableArrayLowering.cpp @@ -15,6 +15,8 @@ #include "resizableArrayLowering.h" #include "compiler/lowering/util.h" +#include "ir/typeNode.h" +#include "ir/ts/tsArrayType.h" namespace ark::es2panda::compiler { diff --git a/ets2panda/compiler/lowering/ets/restArgsLowering.cpp b/ets2panda/compiler/lowering/ets/restArgsLowering.cpp index 6872d027f073ab4adb3797e8634392e6e9013a13..ab1a93b743444888b95400ced5a9d0e306d2a176 100644 --- a/ets2panda/compiler/lowering/ets/restArgsLowering.cpp +++ b/ets2panda/compiler/lowering/ets/restArgsLowering.cpp @@ -16,8 +16,16 @@ #include "restArgsLowering.h" #include "compiler/lowering/util.h" #include "ir/astNode.h" +#include "ir/opaqueTypeNode.h" +#include "ir/base/spreadElement.h" #include "ir/expressions/arrayExpression.h" +#include "ir/expressions/blockExpression.h" +#include "ir/expressions/callExpression.h" #include "ir/expressions/literals/undefinedLiteral.h" + +#include "ir/ets/etsTypeReference.h" +#include "ir/ets/etsNewClassInstanceExpression.h" + #include #include #include diff --git a/ets2panda/compiler/lowering/ets/setJumpTarget.cpp b/ets2panda/compiler/lowering/ets/setJumpTarget.cpp index 46b9c961e7287c21d2bc6ece17607110318e202d..7d435409e5e8cfa97f64af30576b5ea8998551f6 100644 --- a/ets2panda/compiler/lowering/ets/setJumpTarget.cpp +++ b/ets2panda/compiler/lowering/ets/setJumpTarget.cpp @@ -17,6 +17,10 @@ #include "checker/types/globalTypesHolder.h" #include "compiler/lowering/util.h" +#include "ir/statements/breakStatement.h" +#include "ir/statements/continueStatement.h" +#include "ir/base/spreadElement.h" + namespace ark::es2panda::compiler { void SetJumpTargetPhase::LogError(const public_lib::Context *ctx, const diagnostic::DiagnosticKind &diagnostic, diff --git a/ets2panda/compiler/lowering/ets/spreadLowering.cpp b/ets2panda/compiler/lowering/ets/spreadLowering.cpp index 7bd611396699f242067a26056e9546a655949d82..98cdd6a2a1d47edcf0720ca28a3c039ba2c7dad1 100644 --- a/ets2panda/compiler/lowering/ets/spreadLowering.cpp +++ b/ets2panda/compiler/lowering/ets/spreadLowering.cpp @@ -16,6 +16,16 @@ #include "spreadLowering.h" #include "checker/ETSchecker.h" #include "checker/types/ets/etsTupleType.h" +#include "checker/types/ets/etsObjectType.h" +#include "checker/types/ets/etsResizableArrayType.h" + +#include "ir/opaqueTypeNode.h" + +#include "ir/base/spreadElement.h" + +#include "ir/expressions/arrayExpression.h" +#include "ir/expressions/blockExpression.h" + #include "compiler/lowering/util.h" namespace ark::es2panda::compiler { diff --git a/ets2panda/compiler/lowering/ets/stringComparison.cpp b/ets2panda/compiler/lowering/ets/stringComparison.cpp index 5a0f721fb2d70ccc764773c3dea5a041ce9843b8..72deceafb9ac3736d77920dfe2b31f31a3ecf017 100644 --- a/ets2panda/compiler/lowering/ets/stringComparison.cpp +++ b/ets2panda/compiler/lowering/ets/stringComparison.cpp @@ -16,8 +16,8 @@ #include "varbinder/ETSBinder.h" #include "stringComparison.h" #include "checker/ETSchecker.h" +#include "checker/types/ets/etsObjectType.h" #include "parser/parserImpl.h" -#include "libarkbase/utils/arena_containers.h" #include "compiler/lowering/scopesInit/scopesInitPhase.h" #include "compiler/lowering/util.h" diff --git a/ets2panda/compiler/lowering/ets/stringConstantsLowering.cpp b/ets2panda/compiler/lowering/ets/stringConstantsLowering.cpp index 9484a991388505b9f88c5a3590e23fe4eb506fa7..55b8585b3d64b50cfb1fe0a13bbb9b2797c9ba5b 100644 --- a/ets2panda/compiler/lowering/ets/stringConstantsLowering.cpp +++ b/ets2panda/compiler/lowering/ets/stringConstantsLowering.cpp @@ -16,6 +16,9 @@ #include "stringConstantsLowering.h" #include "checker/ETSchecker.h" +#include "ir/expressions/binaryExpression.h" +#include "ir/expressions/literals/stringLiteral.h" + namespace ark::es2panda::compiler { std::string_view StringConstantsLowering::Name() const diff --git a/ets2panda/compiler/lowering/ets/topLevelStmts/globalClassHandler.cpp b/ets2panda/compiler/lowering/ets/topLevelStmts/globalClassHandler.cpp index d5d144d6c635e95d0a7c767af633916bb04746ef..8651b3ce25adacb20894016335913b5b177e507a 100644 --- a/ets2panda/compiler/lowering/ets/topLevelStmts/globalClassHandler.cpp +++ b/ets2panda/compiler/lowering/ets/topLevelStmts/globalClassHandler.cpp @@ -33,7 +33,6 @@ #include "ir/statements/expressionStatement.h" #include "util/helpers.h" #include "util/ustring.h" -#include "libarkbase/utils/arena_containers.h" #include "generated/diagnostic.h" namespace ark::es2panda::compiler { diff --git a/ets2panda/compiler/lowering/ets/topLevelStmts/importExportDecls.cpp b/ets2panda/compiler/lowering/ets/topLevelStmts/importExportDecls.cpp index 3a9f9cf97a46b28d8bcbddaab8774aad50d4bada..15539c5f5c14d880459556199aeb87baf1c0a05e 100644 --- a/ets2panda/compiler/lowering/ets/topLevelStmts/importExportDecls.cpp +++ b/ets2panda/compiler/lowering/ets/topLevelStmts/importExportDecls.cpp @@ -16,7 +16,6 @@ #include "compiler/lowering/ets/topLevelStmts/importExportDecls.h" #include "compiler/lowering/util.h" #include "generated/diagnostic.h" -#include "libarkbase/utils/arena_containers.h" namespace ark::es2panda::compiler { diff --git a/ets2panda/compiler/lowering/ets/typeFromLowering.cpp b/ets2panda/compiler/lowering/ets/typeFromLowering.cpp index 31f98cba357c1ae0c9bba133238f47b42d9818f9..ca1492ac573110d0b8430aaafcfac8234d2e8f5e 100644 --- a/ets2panda/compiler/lowering/ets/typeFromLowering.cpp +++ b/ets2panda/compiler/lowering/ets/typeFromLowering.cpp @@ -16,6 +16,7 @@ #include "typeFromLowering.h" #include "checker/ETSchecker.h" +#include "checker/types/ets/etsObjectType.h" #include "checker/types/ets/etsTupleType.h" #include "compiler/lowering/util.h" #include "compiler/lowering/scopesInit/scopesInitPhase.h" diff --git a/ets2panda/compiler/lowering/ets/unboxLowering.cpp b/ets2panda/compiler/lowering/ets/unboxLowering.cpp index 0cf2d12eff6a3e345a513f0cd37bb6cfb7a665e1..20358a17f472e0150a3f6fac0692296c757f3764 100644 --- a/ets2panda/compiler/lowering/ets/unboxLowering.cpp +++ b/ets2panda/compiler/lowering/ets/unboxLowering.cpp @@ -19,7 +19,12 @@ #include "generated/tokenType.h" #include "ir/visitor/IterateAstVisitor.h" #include "checker/ETSchecker.h" +#include "checker/types/ets/etsFunctionType.h" +#include "checker/types/ets/etsObjectType.h" +#include "checker/types/ets/etsResizableArrayType.h" #include "checker/types/ets/etsTupleType.h" +#include "checker/types/ets/etsTypeParameter.h" +#include "checker/types/ets/etsUnionType.h" #include "checker/types/typeFlag.h" #include "checker/types/globalTypesHolder.h" #include "compiler/lowering/util.h" diff --git a/ets2panda/compiler/lowering/ets/unionLowering.cpp b/ets2panda/compiler/lowering/ets/unionLowering.cpp index 2b2bc2713fdbed47e05eae8118dd52a10b1ab2ee..805b3b32d4642032b8cce7a217a010c3f36d8882 100644 --- a/ets2panda/compiler/lowering/ets/unionLowering.cpp +++ b/ets2panda/compiler/lowering/ets/unionLowering.cpp @@ -19,6 +19,8 @@ #include "compiler/lowering/util.h" #include "varbinder/ETSBinder.h" #include "checker/ETSchecker.h" +#include "checker/types/ets/etsUnionType.h" +#include "checker/types/ets/etsFunctionType.h" #include "util/nameMangler.h" namespace ark::es2panda::compiler { diff --git a/ets2panda/compiler/lowering/phase.cpp b/ets2panda/compiler/lowering/phase.cpp index 35d0a0f540ec1fcf9171c5b73b770cbd01222aa8..0ea76df47c04abb62191d44a175f6bc5f607f6ab 100644 --- a/ets2panda/compiler/lowering/phase.cpp +++ b/ets2panda/compiler/lowering/phase.cpp @@ -78,7 +78,6 @@ #include "compiler/lowering/scopesInit/scopesInitPhase.h" #include "generated/diagnostic.h" #include "lexer/token/sourceLocation.h" -#include "public/es2panda_lib.h" #include "util/options.h" namespace ark::es2panda::compiler { diff --git a/ets2panda/compiler/lowering/resolveIdentifiers.cpp b/ets2panda/compiler/lowering/resolveIdentifiers.cpp index 541af34dee0a131f484d6806cbd4eaf7e953ef4b..78651778af3a4a511e80ec52e63c8d7fce213245 100644 --- a/ets2panda/compiler/lowering/resolveIdentifiers.cpp +++ b/ets2panda/compiler/lowering/resolveIdentifiers.cpp @@ -16,6 +16,8 @@ #include "resolveIdentifiers.h" #include "varbinder/ETSBinder.h" +#include "ir/ets/etsModule.h" + #include "util/options.h" namespace ark::es2panda::compiler { diff --git a/ets2panda/declgen_ets2ts/declgenEts2Ts.cpp b/ets2panda/declgen_ets2ts/declgenEts2Ts.cpp index d2187be6e784b683954365914958f3e165adab2e..348f21e2e8ce64229264b472e8ab13d9f0668113 100644 --- a/ets2panda/declgen_ets2ts/declgenEts2Ts.cpp +++ b/ets2panda/declgen_ets2ts/declgenEts2Ts.cpp @@ -16,22 +16,58 @@ #include "declgenEts2Ts.h" #include "isolatedDeclgenChecker.h" +#include "checker/types/ets/etsFunctionType.h" #include "checker/types/ets/etsTupleType.h" +#include "checker/types/ets/etsUnionType.h" +#include "checker/types/ets/etsObjectType.h" +#include "checker/types/ets/etsArrayType.h" + #include "compiler/lowering/phase.h" #include "generated/diagnostic.h" + #include "ir/base/classProperty.h" #include "ir/base/methodDefinition.h" #include "ir/base/scriptFunction.h" + +#include "ir/expressions/arrayExpression.h" +#include "ir/expressions/binaryExpression.h" +#include "ir/expressions/callExpression.h" +#include "ir/expressions/conditionalExpression.h" +#include "ir/expressions/functionExpression.h" +#include "ir/expressions/identifier.h" +#include "ir/expressions/literals/numberLiteral.h" +#include "ir/expressions/literals/booleanLiteral.h" + +#include "ir/statements/classDeclaration.h" +#include "ir/statements/expressionStatement.h" +#include "ir/statements/variableDeclaration.h" +#include "ir/statements/variableDeclarator.h" + +#include "ir/ets/etsFunctionType.h" #include "ir/ets/etsImportDeclaration.h" #include "ir/ets/etsReExportDeclaration.h" #include "ir/ets/etsTuple.h" #include "ir/ets/etsUnionType.h" -#include "ir/expressions/identifier.h" -#include "ir/expressions/literals/numberLiteral.h" -#include "ir/statements/classDeclaration.h" +#include "ir/ets/etsNewClassInstanceExpression.h" +#include "ir/ets/etsTypeReference.h" +#include "ir/ets/etsTypeReferencePart.h" +#include "ir/ets/etsPrimitiveType.h" + +#include "ir/ts/tsArrayType.h" +#include "ir/ts/tsEnumMember.h" +#include "ir/ts/tsQualifiedName.h" +#include "ir/ts/tsClassImplements.h" #include "ir/ts/tsInterfaceBody.h" +#include "ir/ts/tsInterfaceHeritage.h" #include "ir/ts/tsTypeAliasDeclaration.h" #include "ir/ts/tsTypeParameter.h" +#include "ir/ts/tsTypeParameterInstantiation.h" + +#include "ir/module/exportSpecifier.h" +#include "ir/module/exportNamedDeclaration.h" +#include "ir/module/importDefaultSpecifier.h" +#include "ir/module/importNamespaceSpecifier.h" + #include "compiler/lowering/util.h" #define DEBUG_PRINT 0 diff --git a/ets2panda/declgen_ets2ts/declgenEts2Ts.h b/ets2panda/declgen_ets2ts/declgenEts2Ts.h index dcfd80347b7a41aaf7d5fcdd911edb2d90cd48bc..d2cb64c3c09147c5a4d399d0f56505f93a6b34c6 100644 --- a/ets2panda/declgen_ets2ts/declgenEts2Ts.h +++ b/ets2panda/declgen_ets2ts/declgenEts2Ts.h @@ -19,7 +19,6 @@ #include "checker/ETSchecker.h" #include "compiler/lowering/phase.h" #include "libarkbase/os/file.h" -#include "libarkbase/utils/arena_containers.h" #include "parser/program/program.h" #include "util/options.h" #include "util/diagnosticEngine.h" diff --git a/ets2panda/declgen_ets2ts/isolatedDeclgenChecker.cpp b/ets2panda/declgen_ets2ts/isolatedDeclgenChecker.cpp index 34da477bad8a138ecb38c4bf1401e4f697d34d9b..59612fcbaa61b9b4fb110cee407167919541286e 100644 --- a/ets2panda/declgen_ets2ts/isolatedDeclgenChecker.cpp +++ b/ets2panda/declgen_ets2ts/isolatedDeclgenChecker.cpp @@ -19,6 +19,26 @@ #include "libarkbase/clang.h" #include "libarkbase/utils/logger.h" +#include "ir/typeNode.h" + +#include "ir/base/classProperty.h" +#include "ir/base/classDefinition.h" +#include "ir/base/scriptFunction.h" + +#include "ir/expressions/arrayExpression.h" +#include "ir/statements/returnStatement.h" + +#include "ir/ets/etsParameterExpression.h" +#include "ir/ets/etsTypeReference.h" +#include "ir/ets/etsTypeReferencePart.h" +#include "ir/ets/etsNewClassInstanceExpression.h" + +#include "ir/ts/tsQualifiedName.h" + +#include "ir/module/exportDefaultDeclaration.h" + +#include "parser/program/program.h" + namespace ark::es2panda::declgen { using AstNodePtr = ir::AstNode *; diff --git a/ets2panda/evaluate/debugInfoDeserialization/classBuilder.cpp b/ets2panda/evaluate/debugInfoDeserialization/classBuilder.cpp index c2044c593d06299d7881fdf98c21e0335f8d6498..6810c24dc8fef34e6fa7de86d647804373ea0e11 100644 --- a/ets2panda/evaluate/debugInfoDeserialization/classBuilder.cpp +++ b/ets2panda/evaluate/debugInfoDeserialization/classBuilder.cpp @@ -16,8 +16,11 @@ #include "evaluate/debugInfoDeserialization/classBuilder.h" #include "parser/program/program.h" #include "checker/ETSchecker.h" + +#include "ir/base/classProperty.h" #include "ir/statements/classDeclaration.h" #include "ir/expressions/identifier.h" + #include "libarkfile/class_data_accessor-inl.h" #include "libarkfile/file-inl.h" #include "libarkfile/method_data_accessor.h" diff --git a/ets2panda/evaluate/debugInfoDeserialization/classBuilder.h b/ets2panda/evaluate/debugInfoDeserialization/classBuilder.h index de568689f22796d14711a0fb277278873549239a..4d23a741599311909c5548eef384d52b7ad40099 100644 --- a/ets2panda/evaluate/debugInfoDeserialization/classBuilder.h +++ b/ets2panda/evaluate/debugInfoDeserialization/classBuilder.h @@ -18,7 +18,6 @@ #include "ir/base/classDefinition.h" #include "util/ustring.h" -#include "libarkbase/utils/arena_containers.h" namespace ark::panda_file { class ClassDataAccessor; diff --git a/ets2panda/evaluate/debugInfoDeserialization/debugInfoDeserializer.h b/ets2panda/evaluate/debugInfoDeserialization/debugInfoDeserializer.h index 632703e3b95438bb3ffbafe1c7f36d389aa4e997..46adbfae6aaf269c25367e8b5a3c662752236ff2 100644 --- a/ets2panda/evaluate/debugInfoDeserialization/debugInfoDeserializer.h +++ b/ets2panda/evaluate/debugInfoDeserialization/debugInfoDeserializer.h @@ -16,7 +16,6 @@ #ifndef ES2PANDA_EVALUATE_DEBUG_INFO_DESERIALIZER_H #define ES2PANDA_EVALUATE_DEBUG_INFO_DESERIALIZER_H -#include "libarkbase/utils/arena_containers.h" #include "libarkfile/debug_info_extractor.h" #include "libarkfile/file.h" diff --git a/ets2panda/evaluate/debugInfoDeserialization/methodBuilder.cpp b/ets2panda/evaluate/debugInfoDeserialization/methodBuilder.cpp index 574f543e1cccbe251c0156c9992baccd3085d9d3..8aac4fe73fe6a755fe29f11514bf70045359fc5c 100644 --- a/ets2panda/evaluate/debugInfoDeserialization/methodBuilder.cpp +++ b/ets2panda/evaluate/debugInfoDeserialization/methodBuilder.cpp @@ -15,6 +15,23 @@ #include "evaluate/debugInfoDeserialization/methodBuilder.h" #include "checker/ETSchecker.h" + +#include "ir/typeNode.h" + +#include "ir/base/classStaticBlock.h" + +#include "ir/statements/expressionStatement.h" + +#include "ir/expressions/callExpression.h" +#include "ir/expressions/functionExpression.h" +#include "ir/expressions/memberExpression.h" +#include "ir/expressions/superExpression.h" +#include "ir/expressions/literals/numberLiteral.h" + +#include "ir/ets/etsPrimitiveType.h" + +#include "ir/ts/tsAsExpression.h" + #include "libarkfile/file-inl.h" #include "libarkfile/method_data_accessor-inl.h" #include "libarkfile/proto_data_accessor-inl.h" diff --git a/ets2panda/evaluate/debugInfoDeserialization/methodBuilder.h b/ets2panda/evaluate/debugInfoDeserialization/methodBuilder.h index a8e69125459cf88cb1a9192f5b5518ae7e80d18d..96eca9eb5c1069cf81ef21f7af2df699074ab806 100644 --- a/ets2panda/evaluate/debugInfoDeserialization/methodBuilder.h +++ b/ets2panda/evaluate/debugInfoDeserialization/methodBuilder.h @@ -19,7 +19,7 @@ #include "util/ustring.h" #include "ir/astNodeFlags.h" #include "generated/signatures.h" -#include "libarkbase/utils/arena_containers.h" +#include "libarkbase/utils/arena_vector.h" namespace ark::panda_file { class ClassDataAccessor; diff --git a/ets2panda/evaluate/entityDeclarator.h b/ets2panda/evaluate/entityDeclarator.h index 3f1619e03c9465e454ac0edf2a33ff864961ae27..f4264b1b03c2ee6c165059492ede9e8a202b681f 100644 --- a/ets2panda/evaluate/entityDeclarator.h +++ b/ets2panda/evaluate/entityDeclarator.h @@ -19,7 +19,6 @@ #include "checker/ETSchecker.h" #include "evaluate/proxyProgramsCache.h" #include "evaluate/helpers.h" -#include "libarkbase/utils/arena_containers.h" namespace ark::es2panda::parser { class Program; diff --git a/ets2panda/evaluate/evaluateContext.h b/ets2panda/evaluate/evaluateContext.h index 4e6eae1dc31a8d9660f31b869d63b1d8e2c4880c..6a0bb92830a30270bb195516de1208b6f013cdd7 100644 --- a/ets2panda/evaluate/evaluateContext.h +++ b/ets2panda/evaluate/evaluateContext.h @@ -19,7 +19,6 @@ #include "util/ustring.h" #include "util/options.h" -#include "libarkbase/utils/arena_containers.h" #include "libarkfile/debug_info_extractor.h" #include "libarkfile/file.h" diff --git a/ets2panda/evaluate/helpers.cpp b/ets2panda/evaluate/helpers.cpp index 88a631b2f782a80548f9b7e16ad7cd09951a48f8..9dd720e164778126885afcdc7632e90f274f6c0f 100644 --- a/ets2panda/evaluate/helpers.cpp +++ b/ets2panda/evaluate/helpers.cpp @@ -15,13 +15,18 @@ #include "evaluate/helpers.h" #include "checker/types/globalTypesHolder.h" + +#include "ir/typeNode.h" + +#include "ir/base/classProperty.h" + +#include "ir/expressions/identifier.h" +#include "ir/statements/blockStatement.h" + #include "ir/ets/etsPrimitiveType.h" #include "ir/ets/etsTypeReference.h" #include "ir/ets/etsTypeReferencePart.h" -#include "ir/expressions/identifier.h" -#include "ir/statements/blockStatement.h" #include "ir/ts/tsArrayType.h" -#include "ir/typeNode.h" #include "assembler/assembly-type.h" #include "libarkfile/field_data_accessor-inl.h" diff --git a/ets2panda/evaluate/importExportTable.h b/ets2panda/evaluate/importExportTable.h index 025dbe0e49a4e5decaeabd39f3ede41ce5533eec..8e0c6198b1c1b79ce4a53ffbf3aadbd10fdad22c 100644 --- a/ets2panda/evaluate/importExportTable.h +++ b/ets2panda/evaluate/importExportTable.h @@ -16,7 +16,7 @@ #ifndef ES2PANDA_EVALUATE_IMPORT_EXPORT_TABLE_H #define ES2PANDA_EVALUATE_IMPORT_EXPORT_TABLE_H -#include "libarkbase/utils/arena_containers.h" +#include "libarkbase/utils/arena_unordered_map.h" namespace ark::es2panda::evaluate { diff --git a/ets2panda/evaluate/irCheckHelper.h b/ets2panda/evaluate/irCheckHelper.h index 2e248b6432a3879202173001c67a03fbbaaf9d3f..91d5b40f4c735017aec994f521e518f4eaff5739 100644 --- a/ets2panda/evaluate/irCheckHelper.h +++ b/ets2panda/evaluate/irCheckHelper.h @@ -17,7 +17,9 @@ #define ES2PANDA_EVALUATE_NON_RECURSIVE_IR_CHECKER_H #include "libarkbase/mem/arena_allocator.h" -#include "libarkbase/utils/arena_containers.h" + + +#include "libarkbase/utils/arena_list.h" namespace ark::es2panda::checker { class ETSChecker; diff --git a/ets2panda/evaluate/pathResolver.h b/ets2panda/evaluate/pathResolver.h index d7f49bfdd4d6f525b5f63745c70a0195f85a99a8..ae1b0d92cc34ec28067f042cfdf7aa52ec287e33 100644 --- a/ets2panda/evaluate/pathResolver.h +++ b/ets2panda/evaluate/pathResolver.h @@ -16,7 +16,8 @@ #ifndef ES2PANDA_EVALUATE_PATH_RESOLVER_H #define ES2PANDA_EVALUATE_PATH_RESOLVER_H -#include "libarkbase/utils/arena_containers.h" +#include "libarkbase/utils/arena_vector.h" +#include namespace ark::es2panda::evaluate { diff --git a/ets2panda/evaluate/proxyProgramsCache.h b/ets2panda/evaluate/proxyProgramsCache.h index 3d0aa0f3fb210b0c924a6946349340236794d432..3051a9e9cf7fbcd53209a4556e66911433015d8e 100644 --- a/ets2panda/evaluate/proxyProgramsCache.h +++ b/ets2panda/evaluate/proxyProgramsCache.h @@ -17,9 +17,7 @@ #define ES2PANDA_EVALUATE_PROXY_PROGRAMS_MAP_H #include "util/ustring.h" - -#include "libarkbase/mem/arena_allocator.h" -#include "libarkbase/utils/arena_containers.h" +#include "libarkbase/utils/arena_unordered_map.h" namespace ark::es2panda::parser { class Program; diff --git a/ets2panda/evaluate/varbinderScopes.h b/ets2panda/evaluate/varbinderScopes.h index 3ac6d8daf251dc1a606175488667f75c42774466..6fe2da3e462f8c7951a086dcb33fde0dcb18dace 100644 --- a/ets2panda/evaluate/varbinderScopes.h +++ b/ets2panda/evaluate/varbinderScopes.h @@ -16,6 +16,8 @@ #ifndef ES2PANDA_EVALUATE_VARBINDER_SCOPES_H #define ES2PANDA_EVALUATE_VARBINDER_SCOPES_H +#include "ir/ts/tsInterfaceDeclaration.h" + #include "parser/program/program.h" #include "varbinder/ETSBinder.h" #include "varbinder/recordTable.h" diff --git a/ets2panda/ir/annotationAllowed.h b/ets2panda/ir/annotationAllowed.h index d75ec2f1261f30989ab5cab1e26dbd7aa2567dd3..393cfe8ecf194030fe28fd55bbb5aa749a012abc 100644 --- a/ets2panda/ir/annotationAllowed.h +++ b/ets2panda/ir/annotationAllowed.h @@ -80,17 +80,6 @@ public: } } - void DumpAnnotations(ir::SrcDumper *dumper) const - { - auto *node = AstNode::GetHistoryNodeAs>(); - if (node->annotations_ != nullptr && !node->annotations_->empty()) { - auto &annotations = *node->annotations_; - for (auto *anno : annotations) { - anno->Dump(dumper); - } - } - } - [[nodiscard]] ArenaVector &AnnotationsForUpdate() { auto *node = AstNode::GetOrCreateHistoryNodeAs>(); diff --git a/ets2panda/ir/as/namedType.cpp b/ets2panda/ir/as/namedType.cpp index 71eac941cf0e0ff15fc59e7907ec012ba8f81c87..81b7a6ec1085930282e6e66154c562207bb09ab1 100644 --- a/ets2panda/ir/as/namedType.cpp +++ b/ets2panda/ir/as/namedType.cpp @@ -15,13 +15,8 @@ #include "namedType.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" #include "ir/expressions/identifier.h" #include "ir/ts/tsTypeParameterInstantiation.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" namespace ark::es2panda::ir { void NamedType::TransformChildren(const NodeTransformer &cb, std::string_view const transformationName) @@ -63,39 +58,4 @@ void NamedType::Iterate(const NodeTraverser &cb) const IterateAnnotations(cb); } -void NamedType::Dump(AstDumper *dumper) const -{ - dumper->Add({{"type", "NamedType"}, - {"name", name_}, - {"typeParameters", AstDumper::Optional(typeParams_)}, - {"next", AstDumper::Optional(next_)}, - {"isNullable", nullable_}, - {"annotations", AstDumper::Optional(Annotations())}}); -} - -void NamedType::Dump(SrcDumper *dumper) const -{ - DumpAnnotations(dumper); - dumper->Add("NamedType"); -} - -void NamedType::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void NamedType::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *NamedType::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType NamedType::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/as/prefixAssertionExpression.cpp b/ets2panda/ir/as/prefixAssertionExpression.cpp index 544713d799e9cccf830668b77f6c40f31106075c..7e016f5805d68f41c6403f12d97bbf5cc4d52f8b 100644 --- a/ets2panda/ir/as/prefixAssertionExpression.cpp +++ b/ets2panda/ir/as/prefixAssertionExpression.cpp @@ -15,11 +15,6 @@ #include "prefixAssertionExpression.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" #include "ir/typeNode.h" namespace ark::es2panda::ir { @@ -42,33 +37,4 @@ void PrefixAssertionExpression::Iterate(const NodeTraverser &cb) const cb(expr_); } -void PrefixAssertionExpression::Dump(AstDumper *dumper) const -{ - dumper->Add({{"type", "PrefixAssertionExpression"}, {"expression", expr_}, {"type", type_}}); -} - -void PrefixAssertionExpression::Dump(SrcDumper *dumper) const -{ - dumper->Add("PrefixAssertionExpression"); -} - -void PrefixAssertionExpression::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void PrefixAssertionExpression::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *PrefixAssertionExpression::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType PrefixAssertionExpression::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/astDump.cpp b/ets2panda/ir/astDump.cpp index cc850f7341bf43e337371670a4189b4359dbac3d..bf2fa51d2e4f90b29b84b394d60493b5ffe48584 100644 --- a/ets2panda/ir/astDump.cpp +++ b/ets2panda/ir/astDump.cpp @@ -15,7 +15,167 @@ #include "astDump.h" -#include "ir/astNode.h" +#include "ir/brokenTypeNode.h" +#include "ir/opaqueTypeNode.h" + +#include "ir/module/exportAllDeclaration.h" +#include "ir/module/exportDefaultDeclaration.h" +#include "ir/module/exportNamedDeclaration.h" +#include "ir/module/exportSpecifier.h" +#include "ir/module/importDefaultSpecifier.h" +#include "ir/module/importNamespaceSpecifier.h" + +#include "ir/ets/etsClassLiteral.h" +#include "ir/ets/etsStructDeclaration.h" +#include "ir/ets/etsIntrinsicNode.h" +#include "ir/ets/etsUnionType.h" +#include "ir/ets/etsStringLiteralType.h" +#include "ir/ets/etsTuple.h" +#include "ir/ets/etsTypeReference.h" +#include "ir/ets/etsTypeReferencePart.h" +#include "ir/ets/etsNeverType.h" +#include "ir/ets/etsNullishTypes.h" +#include "ir/ets/etsReExportDeclaration.h" +#include "ir/ets/etsNewArrayInstanceExpression.h" +#include "ir/ets/etsNewMultiDimArrayInstanceExpression.h" +#include "ir/ets/etsNewClassInstanceExpression.h" +#include "ir/ets/etsFunctionType.h" +#include "ir/ets/etsNonNullishTypeNode.h" +#include "ir/ets/etsPackageDeclaration.h" +#include "ir/ets/etsPrimitiveType.h" +#include "ir/ets/etsWildcardType.h" +#include "ir/ets/etsKeyofType.h" +#include "ir/ets/etsModule.h" + +#include "ir/ts/tsAsExpression.h" +#include "ir/ts/tsEnumDeclaration.h" +#include "ir/ts/tsEnumMember.h" +#include "ir/ts/tsExternalModuleReference.h" +#include "ir/ts/tsNonNullExpression.h" +#include "ir/ts/tsTypeAssertion.h" +#include "ir/ts/tsAnyKeyword.h" +#include "ir/ts/tsArrayType.h" +#include "ir/ts/tsBigintKeyword.h" +#include "ir/ts/tsBooleanKeyword.h" +#include "ir/ts/tsLiteralType.h" +#include "ir/ts/tsNeverKeyword.h" +#include "ir/ts/tsNullKeyword.h" +#include "ir/ts/tsNumberKeyword.h" +#include "ir/ts/tsObjectKeyword.h" +#include "ir/ts/tsParenthesizedType.h" +#include "ir/ts/tsStringKeyword.h" +#include "ir/ts/tsTypeLiteral.h" +#include "ir/ts/tsUndefinedKeyword.h" +#include "ir/ts/tsUnionType.h" +#include "ir/ts/tsUnknownKeyword.h" +#include "ir/ts/tsVoidKeyword.h" +#include "ir/ts/tsConditionalType.h" +#include "ir/ts/tsConstructorType.h" +#include "ir/ts/tsFunctionType.h" +#include "ir/ts/tsImportEqualsDeclaration.h" +#include "ir/ts/tsImportType.h" +#include "ir/ts/tsInferType.h" +#include "ir/ts/tsIntersectionType.h" +#include "ir/ts/tsMappedType.h" +#include "ir/ts/tsModuleBlock.h" +#include "ir/ts/tsModuleDeclaration.h" +#include "ir/ts/tsParameterProperty.h" +#include "ir/ts/tsThisType.h" +#include "ir/ts/tsTypeAliasDeclaration.h" +#include "ir/ts/tsTypeOperator.h" +#include "ir/ts/tsTypeParameter.h" +#include "ir/ts/tsTypeParameterDeclaration.h" +#include "ir/ts/tsTypeParameterInstantiation.h" +#include "ir/ts/tsTypePredicate.h" +#include "ir/ts/tsTypeReference.h" +#include "ir/ts/tsClassImplements.h" +#include "ir/ts/tsIndexedAccessType.h" +#include "ir/ts/tsInterfaceBody.h" +#include "ir/ts/tsInterfaceDeclaration.h" +#include "ir/ts/tsInterfaceHeritage.h" +#include "ir/ts/tsNamedTupleMember.h" +#include "ir/ts/tsQualifiedName.h" +#include "ir/ts/tsTupleType.h" +#include "ir/ts/tsTypeQuery.h" + +#include "ir/base/spreadElement.h" +#include "ir/base/scriptFunction.h" +#include "ir/base/catchClause.h" +#include "ir/base/classDefinition.h" +#include "ir/base/classProperty.h" +#include "ir/base/classStaticBlock.h" +#include "ir/base/decorator.h" +#include "ir/base/methodDefinition.h" +#include "ir/base/metaProperty.h" +#include "ir/base/overloadDeclaration.h" +#include "ir/base/property.h" +#include "ir/base/tsMethodSignature.h" +#include "ir/base/tsPropertySignature.h" +#include "ir/base/tsSignatureDeclaration.h" +#include "ir/base/tsIndexSignature.h" + +#include "ir/expressions/assignmentExpression.h" +#include "ir/expressions/taggedTemplateExpression.h" +#include "ir/expressions/typeofExpression.h" +#include "ir/expressions/unaryExpression.h" +#include "ir/expressions/updateExpression.h" +#include "ir/expressions/yieldExpression.h" + +#include "ir/expressions/arrowFunctionExpression.h" +#include "ir/expressions/arrayExpression.h" +#include "ir/expressions/objectExpression.h" +#include "ir/expressions/sequenceExpression.h" +#include "ir/expressions/templateLiteral.h" +#include "ir/expressions/functionExpression.h" +#include "ir/expressions/awaitExpression.h" +#include "ir/expressions/binaryExpression.h" +#include "ir/expressions/callExpression.h" +#include "ir/expressions/classExpression.h" +#include "ir/expressions/chainExpression.h" +#include "ir/expressions/identifier.h" +#include "ir/expressions/importExpression.h" +#include "ir/expressions/dummyNode.h" +#include "ir/expressions/directEvalExpression.h" +#include "ir/expressions/blockExpression.h" +#include "ir/expressions/conditionalExpression.h" +#include "ir/expressions/thisExpression.h" +#include "ir/expressions/literals/undefinedLiteral.h" +#include "ir/expressions/literals/bigIntLiteral.h" +#include "ir/expressions/literals/booleanLiteral.h" +#include "ir/expressions/literals/charLiteral.h" +#include "ir/expressions/literals/nullLiteral.h" +#include "ir/expressions/literals/numberLiteral.h" +#include "ir/expressions/literals/regExpLiteral.h" +#include "ir/expressions/newExpression.h" +#include "ir/expressions/omittedExpression.h" +#include "ir/expressions/superExpression.h" + +#include "ir/statements/assertStatement.h" +#include "ir/statements/annotationDeclaration.h" +#include "ir/statements/breakStatement.h" +#include "ir/statements/blockStatement.h" +#include "ir/statements/continueStatement.h" +#include "ir/statements/debuggerStatement.h" +#include "ir/statements/doWhileStatement.h" +#include "ir/statements/emptyStatement.h" +#include "ir/statements/expressionStatement.h" +#include "ir/statements/forInStatement.h" +#include "ir/statements/forOfStatement.h" +#include "ir/statements/forUpdateStatement.h" +#include "ir/statements/labelledStatement.h" +#include "ir/statements/functionDeclaration.h" +#include "ir/statements/ifStatement.h" +#include "ir/statements/variableDeclaration.h" +#include "ir/statements/variableDeclarator.h" +#include "ir/statements/switchCaseStatement.h" +#include "ir/statements/switchStatement.h" +#include "ir/statements/tryStatement.h" +#include "ir/statements/throwStatement.h" +#include "ir/statements/whileStatement.h" + +#include "ir/as/namedType.h" +#include "ir/as/prefixAssertionExpression.h" + #include "util/helpers.h" #include "parser/program/program.h" @@ -23,6 +183,7 @@ #include namespace ark::es2panda::ir { + AstDumper::AstDumper(const ir::AstNode *node, util::StringView sourceCode) : index_(sourceCode) { isSrcEmpty_ = sourceCode.Empty(); @@ -278,4 +439,1042 @@ void AstDumper::Indent() ss_ << " "; } } + +void ETSStringLiteralType::Dump(ir::AstDumper *dumper) const +{ + dumper->Add( + {{"type", "ETSStringLiteralType"}, {"value", value_}, {"annotations", AstDumper::Optional(Annotations())}}); +} +void ETSNewArrayInstanceExpression::Dump(ir::AstDumper *dumper) const +{ + dumper->Add( + {{"type", "ETSNewArrayInstanceExpression"}, {"typeReference", typeReference_}, {"dimension", dimension_}}); +} +void TSInferType::Dump(ir::AstDumper *dumper) const +{ + dumper->Add( + {{"type", "TSInferType"}, {"typeParameter", typeParam_}, {"annotations", AstDumper::Optional(Annotations())}}); +} + +void TSTypeLiteral::Dump(ir::AstDumper *dumper) const +{ + dumper->Add( + {{"type", "TSTypeLiteral"}, {"members", members_}, {"annotations", AstDumper::Optional(Annotations())}}); +} +void TSLiteralType::Dump(ir::AstDumper *dumper) const +{ + dumper->Add( + {{"type", "TSLiteralType"}, {"literal", literal_}, {"annotations", AstDumper::Optional(Annotations())}}); +} +void TSTypeQuery::Dump(ir::AstDumper *dumper) const +{ + dumper->Add( + {{"type", "TSTypeQuery"}, {"exprName", exprName_}, {"annotations", AstDumper::Optional(Annotations())}}); +} +void TSIntersectionType::Dump(ir::AstDumper *dumper) const +{ + dumper->Add( + {{"type", "TSIntersectionType"}, {"types", types_}, {"annotations", AstDumper::Optional(Annotations())}}); +} +void TSModuleDeclaration::Dump(ir::AstDumper *dumper) const +{ + dumper->Add( + {{"type", "TSModuleDeclaration"}, {"id", name_}, {"body", AstDumper::Optional(body_)}, {"global", global_}}); +} +void ExportDefaultDeclaration::Dump(ir::AstDumper *dumper) const +{ + dumper->Add( + {{"type", IsExportEquals() ? "TSExportAssignment" : "ExportDefaultDeclaration"}, {"declaration", decl_}}); +} +void ConditionalExpression::Dump(ir::AstDumper *dumper) const +{ + dumper->Add( + {{"type", "ConditionalExpression"}, {"test", test_}, {"consequent", consequent_}, {"alternate", alternate_}}); +} + +void ETSTuple::Dump(ir::AstDumper *const dumper) const +{ + dumper->Add({{"type", "ETSTuple"}, + {"types", AstDumper::Optional(typeAnnotationList_)}, + {"annotations", AstDumper::Optional(Annotations())}}); +} +void ETSNewMultiDimArrayInstanceExpression::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "ETSNewMultiDimArrayInstanceExpression"}, + {"typeReference", typeReference_}, + {"dimensions", dimensions_}}); +} +void TSParenthesizedType::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "TSParenthesizedType"}, + {"typeAnnotation", type_}, + {"annotations", AstDumper::Optional(Annotations())}}); +} + +void TSTupleType::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "TSTupleType"}, + {"elementTypes", elementTypes_}, + {"annotations", AstDumper::Optional(Annotations())}}); +} +void TSClassImplements::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "TSClassImplements"}, + {"expression", expression_}, + {"typeParameters", AstDumper::Optional(typeParameters_)}}); +} + +void ArrowFunctionExpression::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "ArrowFunctionExpression"}, + {"function", func_}, + {"annotations", AstDumper::Optional(Annotations())}}); +} +void SpreadElement::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", (type_ == AstNodeType::SPREAD_ELEMENT) ? "SpreadElement" : "RestElement"}, + {"argument", argument_}, + {"typeAnnotation", AstDumper::Optional(TypeAnnotation())}}); +} +void FunctionDeclaration::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", Function()->IsOverload() ? "TSDeclareFunction" : "FunctionDeclaration"}, + {"annotations", AstDumper::Optional(Annotations())}, + {"function", Function()}}); +} + +void ETSTypeReferencePart::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "ETSTypeReferencePart"}, + {"name", Name()}, + {"typeParams", AstDumper::Optional(TypeParams())}, + {"previous", AstDumper::Optional(Previous())}}); +} + +void TSIndexedAccessType::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "TSIndexedAccessType"}, + {"objectType", objectType_}, + {"indexType", indexType_}, + {"annotations", AstDumper::Optional(Annotations())}}); +} +void TSTypeOperator::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "TSTypeOperator"}, + {"operator", AstDumper::TypeOperatorToString(operatorType_)}, + {"typeAnnotation", type_}, + {"annotations", AstDumper::Optional(Annotations())}}); +} +void TSTypeReference::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "TSTypeReference"}, + {"typeName", typeName_}, + {"typeParameters", AstDumper::Optional(typeParams_)}, + {"annotations", AstDumper::Optional(Annotations())}}); +} +void TSImportEqualsDeclaration::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "TSImportEqualsDeclaration"}, + {"id", id_}, + {"moduleReference", moduleReference_}, + {"isExport", isExport_}}); +} +void TSInterfaceHeritage::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({ + {"type", "TSInterfaceHeritage"}, + {"expression", expr_}, + }); +} +void ExportNamedDeclaration::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "ExportNamedDeclaration"}, + {"declaration", AstDumper::Nullish(decl_)}, + {"source", AstDumper::Nullish(source_)}, + {"specifiers", specifiers_}}); +} +void ObjectExpression::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", (type_ == AstNodeType::OBJECT_EXPRESSION) ? "ObjectExpression" : "ObjectPattern"}, + {"properties", properties_}, + {"typeAnnotation", AstDumper::Optional(TypeAnnotation())}, + {"optional", AstDumper::Optional(optional_)}}); +} +void ArrayExpression::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", type_ == AstNodeType::ARRAY_EXPRESSION ? "ArrayExpression" : "ArrayPattern"}, + {"elements", elements_}, + {"typeAnnotation", AstDumper::Optional(TypeAnnotation())}, + {"optional", AstDumper::Optional(optional_)}}); +} +void DummyNode::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "DummyNode"}, + {"name", name_}, + {"indexName", indexName_}, + {"returnType", AstDumper::Optional(GetReturnTypeLiteral())}}); +} + +void BinaryExpression::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", IsLogical() ? "LogicalExpression" : "BinaryExpression"}, + {"operator", operator_}, + {"left", left_}, + {"right", right_}}); +} +void TaggedTemplateExpression::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "TaggedTemplateExpression"}, + {"tag", tag_}, + {"quasi", quasi_}, + {"typeParameters", AstDumper::Optional(typeParams_)}}); +} +void Identifier::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", IsPrivateIdent() ? "PrivateIdentifier" : "Identifier"}, + {"name", Name()}, + {"typeAnnotation", AstDumper::Optional(TypeAnnotation())}, + {"optional", AstDumper::Optional(IsOptional())}}); +} +void TSIndexSignature::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "TSIndexSignature"}, + {"parameters", param_}, + {"typeAnnotation", typeAnnotation_}, + {"readonly", readonly_}}); +} +void TemplateElement::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({ + {"type", "TemplateElement"}, + {"value", {{"raw", raw_}, {"cooked", cooked_}}}, + }); +} +void TryStatement::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "TryStatement"}, + {"block", block_}, + {"handler", catchClauses_}, + {"finalizer", AstDumper::Nullish(finalizer_)}}); +} +void IfStatement::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "IfStatement"}, + {"test", test_}, + {"consequent", consequent_}, + {"alternate", AstDumper::Nullish(alternate_)}}); +} + +void ETSFunctionType::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "ETSFunctionType"}, + {"params", Params()}, + {"typeParameters", AstDumper::Optional(TypeParams())}, + {"returnType", ReturnType()}, + {"annotations", AstDumper::Optional(Annotations())}}); +} + +void ETSWildcardType::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "ETSWildcardType"}, + {"typeReference", AstDumper::Optional(typeReference_)}, + {"in", AstDumper::Optional(IsIn())}, + {"out", AstDumper::Optional(IsOut())}, + {"annotations", AstDumper::Optional(Annotations())}}); +} +void TSTypePredicate::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "TSTypePredicate"}, + {"parameterName", parameterName_}, + {"typeAnnotation", AstDumper::Nullish(typeAnnotation_)}, + {"asserts", asserts_}, + {"annotations", AstDumper::Optional(Annotations())}}); +} +void TSTypeAliasDeclaration::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "TSTypeAliasDeclaration"}, + {"annotations", AstDumper::Optional(Annotations())}, + {"id", Id()}, + {"typeAnnotation", AstDumper::Optional(TypeAnnotation())}, + {"typeParameters", AstDumper::Optional(TypeParams())}}); +} +void TSEnumDeclaration::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "TSEnumDeclaration"}, + {"id", Key()}, + {"members", Members()}, + {"const", IsConst()}, + {"declare", IsDeclare()}}); +} +void TSNamedTupleMember::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "TSNamedTupleMember"}, + {"elementType", elementType_}, + {"label", label_}, + {"optional", AstDumper::Optional(optional_)}, + {"annotations", AstDumper::Optional(Annotations())}}); +} + +void AssignmentExpression::Dump(ir::AstDumper *dumper) const +{ + if (type_ == AstNodeType::ASSIGNMENT_EXPRESSION) { + dumper->Add({{"type", "AssignmentExpression"}, {"operator", operator_}, {"left", left_}, {"right", right_}}); + } else { + dumper->Add({{"type", "AssignmentPattern"}, {"left", left_}, {"right", right_}}); + } +} +void MemberExpression::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "MemberExpression"}, + {"object", object_}, + {"property", property_}, + {"computed", computed_}, + {"optional", IsOptional()}}); +} +void OverloadDeclaration::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "OverloadDeclaration"}, + {"key", key_}, + {"optional", AstDumper::Optional(AstDumper::ModifierToString(flags_))}, + {"static", IsStatic()}, + {"overloadedList", overloadedList_}}); +} + +void ForUpdateStatement::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "ForUpdateStatement"}, + {"init", AstDumper::Nullish(init_)}, + {"test", AstDumper::Nullish(test_)}, + {"update", AstDumper::Nullish(update_)}, + {"body", body_}}); +} + +void NamedType::Dump(AstDumper *dumper) const +{ + dumper->Add({{"type", "NamedType"}, + {"name", name_}, + {"typeParameters", AstDumper::Optional(typeParams_)}, + {"next", AstDumper::Optional(next_)}, + {"isNullable", nullable_}, + {"annotations", AstDumper::Optional(Annotations())}}); +} +void TSConditionalType::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "TSConditionalType"}, + {"checkType", checkType_}, + {"extendsType", extendsType_}, + {"trueType", trueType_}, + {"falseType", falseType_}, + {"annotations", AstDumper::Optional(Annotations())}}); +} + +void TSConstructorType::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "TSConstructorType"}, + {"params", signature_.Params()}, + {"typeParameters", AstDumper::Optional(signature_.TypeParams())}, + {"returnType", signature_.ReturnType()}, + {"abstract", AstDumper::Optional(abstract_)}, + {"annotations", AstDumper::Optional(Annotations())}}); +} +void TSInterfaceDeclaration::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "TSInterfaceDeclaration"}, + {"annotations", AstDumper::Optional(Annotations())}, + {"body", Body()}, + {"id", Id()}, + {"extends", Extends()}, + {"typeParameters", AstDumper::Optional(TypeParams())}}); +} +void TSFunctionType::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "TSFunctionType"}, + {"params", signature_.Params()}, + {"typeParameters", AstDumper::Optional(signature_.TypeParams())}, + {"returnType", signature_.ReturnType()}, + {"isNullable", AstDumper::Optional(nullable_)}, + {"annotations", AstDumper::Optional(Annotations())}}); +} +void TSImportType::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "TSImportType"}, + {"parameter", param_}, + {"qualifier", AstDumper::Optional(qualifier_)}, + {"typeParameters", AstDumper::Optional(typeParams_)}, + {"isTypeOf", isTypeof_}, + {"annotations", AstDumper::Optional(Annotations())}}); +} + +void CallExpression::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "CallExpression"}, + {"callee", callee_}, + {"arguments", arguments_}, + {"optional", IsOptional()}, + {"typeParameters", AstDumper::Optional(typeParams_)}}); + // #22953: trailing block is not handled +} +void TSSignatureDeclaration::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", (kind_ == TSSignatureDeclaration::TSSignatureDeclarationKind::CALL_SIGNATURE) + ? "TSCallSignatureDeclaration" + : "TSConstructSignatureDeclaration"}, + {"params", Params()}, + {"typeParameters", AstDumper::Optional(TypeParams())}, + {"returnType", AstDumper::Optional(ReturnTypeAnnotation())}}); +} +void TSPropertySignature::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "TSPropertySignature"}, + {"computed", computed_}, + {"optional", optional_}, + {"readonly", readonly_}, + {"key", key_}, + {"typeAnnotation", AstDumper::Optional(TypeAnnotation())}}); +} + +void TSTypeParameter::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "TSTypeParameter"}, + {"name", Name()}, + {"constraint", AstDumper::Optional(Constraint())}, + {"default", AstDumper::Optional(DefaultType())}, + {"in", AstDumper::Optional(IsIn())}, + {"out", AstDumper::Optional(IsOut())}, + {"annotations", AstDumper::Optional(Annotations())}}); +} + +void TSParameterProperty::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "TSParameterProperty"}, + {"accessibility", accessibility_ == AccessibilityOption::PUBLIC ? "public" + : accessibility_ == AccessibilityOption::PRIVATE ? "private" + : accessibility_ == AccessibilityOption::PROTECTED ? "protected" + : "undefined"}, + {"readonly", readonly_}, + {"static", static_}, + {"export", export_}, + {"parameter", parameter_}}); +} +void TSMethodSignature::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "TSMethodSignature"}, + {"computed", computed_}, + {"optional", optional_}, + {"key", key_}, + {"params", Params()}, + {"typeParameters", AstDumper::Optional(TypeParams())}, + {"typeAnnotation", AstDumper::Optional(ReturnTypeAnnotation())}}); +} +void ETSParameterExpression::Dump(ir::AstDumper *const dumper) const +{ + if (!IsRestParameter()) { + dumper->Add({{"type", "ETSParameterExpression"}, + {"name", Ident()}, + {"initializer", AstDumper::Optional(Initializer())}, + {"annotations", AstDumper::Optional(Annotations())}}); + } else { + dumper->Add({{"type", "ETSParameterExpression"}, + {"rest parameter", Spread()}, + {"annotations", AstDumper::Optional(Annotations())}}); + } +} +void TSMappedType::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "TSMappedType"}, + {"typeParameter", typeParameter_}, + {"typeAnnotation", AstDumper::Optional(typeAnnotation_)}, + {"readonly", readonly_ == MappedOption::NO_OPTS ? AstDumper::Optional(false) + : readonly_ == MappedOption::PLUS ? AstDumper::Optional("+") + : AstDumper::Optional("-")}, + {"optional", optional_ == MappedOption::NO_OPTS ? AstDumper::Optional(false) + : optional_ == MappedOption::PLUS ? AstDumper::Optional("+") + : AstDumper::Optional("-")}, + {"annotations", AstDumper::Optional(Annotations())}}); +} +void ScriptFunction::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "ScriptFunction"}, + {"id", AstDumper::Nullish(Id())}, + {"generator", IsGenerator()}, + {"async", IsAsyncFunc()}, + {"expression", ((Flags() & ir::ScriptFunctionFlags::EXPRESSION) != 0)}, + {"params", Params()}, + {"returnType", AstDumper::Optional(ReturnTypeAnnotation())}, + {"typeParameters", AstDumper::Optional(TypeParams())}, + {"declare", AstDumper::Optional(IsDeclare())}, + {"body", AstDumper::Optional(Body())}, + {"annotations", AstDumper::Optional(Annotations())}}); +} + +void ClassDefinition::Dump(ir::AstDumper *dumper) const +{ + auto propFilter = [](AstNode *prop) -> bool { + return !prop->IsClassStaticBlock() || !prop->AsClassStaticBlock()->Function()->IsHidden(); + }; + auto ctor = GetHistoryNodeAs()->ctor_; + dumper->Add({{"id", AstDumper::Nullish(Ident())}, + {"typeParameters", AstDumper::Optional(TypeParams())}, + {"superClass", AstDumper::Nullish(SuperClass())}, + {"superTypeParameters", AstDumper::Optional(SuperTypeParams())}, + {"implements", Implements()}, + {"annotations", AstDumper::Optional(Annotations())}, + {"constructor", AstDumper::Optional(ctor)}, + {"body", Body(), propFilter}}); +} + +void ClassProperty::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "ClassProperty"}, + {"key", Key()}, + {"value", AstDumper::Optional(Value())}, + {"accessibility", AstDumper::Optional(AstDumper::ModifierToString(Modifiers()))}, + {"static", IsStatic()}, + {"readonly", IsReadonly()}, + {"declare", IsDeclare()}, + {"optional", IsOptionalDeclaration()}, + {"computed", IsComputed()}, + {"typeAnnotation", AstDumper::Optional(TypeAnnotation())}, + {"definite", IsDefinite()}, + {"annotations", AstDumper::Optional(Annotations())}}); +} + +void PrefixAssertionExpression::Dump(AstDumper *dumper) const +{ + dumper->Add({{"type", "PrefixAssertionExpression"}, {"expression", expr_}, {"type", type_}}); +} + +void ETSIntrinsicNode::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "ETSIntrinsicNode"}, {"arguments", arguments_}}); +} +void ETSUnionType::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "ETSUnionType"}, {"types", Types()}, {"annotations", AstDumper::Optional(Annotations())}}); +} +void ETSPackageDeclaration::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "ETSPackageDeclaration"}, {"name", name_}}); +} +void ETSClassLiteral::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "ETSClassLiteral"}}); +} +void ETSStructDeclaration::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "ETSStructDeclaration"}, {"definition", Definition()}}); +} +void ETSNeverType::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "ETSNeverType"}, {"annotations", AstDumper::Optional(Annotations())}}); +} +void ETSUndefinedType::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "ETSUndefinedType"}, {"annotations", AstDumper::Optional(Annotations())}}); +} +void ETSNullType::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "ETSNullType"}, {"annotations", AstDumper::Optional(Annotations())}}); +} +void ETSReExportDeclaration::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "ETSReExportDeclaration"}, {"ets_import_declarations", GetETSImportDeclarations()}}); +} +void ETSPrimitiveType::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "ETSPrimitiveType"}, {"annotations", AstDumper::Optional(Annotations())}}); +} +void ETSTypeReference::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "ETSTypeReference"}, {"part", Part()}, {"annotations", AstDumper::Optional(Annotations())}}); +} +void ETSNonNullishTypeNode::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "ETSNonNullishType"}, {"typeNode", typeNode_}}); +} +void ETSKeyofType::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "ETSKeyofType"}, {"types", type_}, {"annotations", AstDumper::Optional(Annotations())}}); +} +void TSUndefinedKeyword::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "TSUndefinedKeyword"}, {"annotations", AstDumper::Optional(Annotations())}}); +} +void TSBooleanKeyword::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "TSBooleanKeyword"}, {"annotations", AstDumper::Optional(Annotations())}}); +} +void TSExternalModuleReference::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "TSExternalModuleReference"}, {"expression", expr_}}); +} + +void TSTypeAssertion::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "TSTypeAssertion"}, {"typeAnnotation", TypeAnnotation()}, {"expression", expression_}}); +} + +void TSEnumMember::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "TSEnumMember"}, {"id", key_}, {"initializer", AstDumper::Optional(init_)}}); +} +void TSTypeParameterDeclaration::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "TSTypeParameterDeclaration"}, {"params", Params()}}); +} +void TSStringKeyword::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "TSStringKeyword"}, {"annotations", AstDumper::Optional(Annotations())}}); +} +void TSNonNullExpression::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "TSNonNullExpression"}, {"expression", expr_}}); +} +void TSInterfaceBody::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "TSInterfaceBody"}, {"body", body_}}); +} +void TSThisType::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "TSThisType"}}); +} + +void TSQualifiedName::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "TSQualifiedName"}, {"left", left_}, {"right", right_}}); +} +void TSAnyKeyword::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "TSAnyKeyword"}, {"annotations", AstDumper::Optional(Annotations())}}); +} +void TSBigintKeyword::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "TSBigIntKeyword"}, {"annotations", AstDumper::Optional(Annotations())}}); +} +void TSModuleBlock::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "TSModuleBlock"}, {"body", statements_}}); +} + +void TSNullKeyword::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "TSNullKeyword"}, {"annotations", AstDumper::Optional(Annotations())}}); +} +void TSTypeParameterInstantiation::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "TSTypeParameterInstantiation"}, {"params", params_}}); +} +void TSVoidKeyword::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "TSVoidKeyword"}, {"annotations", AstDumper::Optional(Annotations())}}); +} +void TSAsExpression::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "TSAsExpression"}, {"expression", expression_}, {"typeAnnotation", TypeAnnotation()}}); +} +void TSNeverKeyword::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "TSNeverKeyword"}, {"annotations", AstDumper::Optional(Annotations())}}); +} +void TSObjectKeyword::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "TSObjectKeyword"}, {"annotations", AstDumper::Optional(Annotations())}}); +} + +void TSNumberKeyword::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "TSNumberKeyword"}, {"annotations", AstDumper::Optional(Annotations())}}); +} + +void TSUnionType::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "TSUnionType"}, {"types", types_}, {"annotations", AstDumper::Optional(Annotations())}}); +} +void TSUnknownKeyword::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "TSUnknownKeyword"}, {"annotations", AstDumper::Optional(Annotations())}}); +} +void TSArrayType::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "TSArrayType"}, {"elementType", elementType_}, {"annotations", Annotations()}}); +} +void ImportDeclaration::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "ImportDeclaration"}, {"source", Source()}, {"specifiers", Specifiers()}}); +} +void ExportSpecifier::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "ExportSpecifier"}, {"local", local_}, {"exported", exported_}}); +} +void ImportDefaultSpecifier::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "ImportDefaultSpecifier"}, {"local", local_}}); +} + +void ExportAllDeclaration::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "ExportAllDeclaration"}, {"source", source_}, {"exported", AstDumper::Nullish(exported_)}}); +} + +void ImportSpecifier::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "ImportSpecifier"}, {"local", ir::AstDumper::Optional(local_)}, {"imported", imported_}}); +} +void ImportNamespaceSpecifier::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "ImportNamespaceSpecifier"}, {"local", local_}}); +} +void BrokenTypeNode::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "ErrorType"}}); +} + +void ThisExpression::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "ThisExpression"}}); +} +void FunctionExpression::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "FunctionExpression"}, {"function", func_}}); +} + +void ClassExpression::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "ClassExpression"}, {"definition", def_}}); +} +void YieldExpression::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "YieldExpression"}, {"delegate", delegate_}, {"argument", AstDumper::Nullish(argument_)}}); +} +void ChainExpression::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "ChainExpression"}, {"expression", expression_}}); +} +void UpdateExpression::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "UpdateExpression"}, {"operator", operator_}, {"prefix", prefix_}, {"argument", argument_}}); +} + +void BlockExpression::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "BlockExpression"}, {"statements", statements_}}); +} +void OmittedExpression::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "OmittedExpression"}}); +} +void TemplateLiteral::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "TemplateLiteral"}, {"expressions", expressions_}, {"quasis", quasis_}}); +} +void AwaitExpression::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "AwaitExpression"}, {"argument", AstDumper::Nullish(argument_)}}); +} +void SuperExpression::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "Super"}}); +} +void ImportExpression::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "ImportExpression"}, {"source", source_}}); +} +void UnaryExpression::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "UnaryExpression"}, {"operator", operator_}, {"prefix", true}, {"argument", argument_}}); +} +void SequenceExpression::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "SequenceExpression"}, {"expressions", sequence_}}); +} +void BooleanLiteral::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "BooleanLiteral"}, {"value", boolean_}}); +} + +void UndefinedLiteral::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "UndefinedLiteral"}, {"value", AstDumper::Property::Constant::PROP_UNDEFINED}}); +} + +void NumberLiteral::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "NumberLiteral"}, {"value", number_}}); +} +void StringLiteral::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "StringLiteral"}, {"value", str_}}); +} + +void BigIntLiteral::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "BigIntLiteral"}, {"value", src_}}); +} + +void CharLiteral::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "CharLiteral"}, {"value", char_}}); +} + +void NullLiteral::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "NullLiteral"}, {"value", AstDumper::Property::Constant::PROP_NULL}}); +} + +void RegExpLiteral::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "RegExpLiteral"}, {"source", pattern_}, {"flags", flagsStr_}}); +} + +void TypeofExpression::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "TypeofExpression"}, {"argument", argument_}}); +} +void NewExpression::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "NewExpression"}, {"callee", callee_}, {"arguments", arguments_}}); +} + +void CatchClause::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "CatchClause"}, {"body", body_}, {"param", AstDumper::Nullish(param_)}}); +} + +void Decorator::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "Decorator"}, {"expression", expr_}}); +} +void ClassStaticBlock::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "ClassStaticBlock"}, {"value", Value()}}); +} +void ReturnStatement::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "ReturnStatement"}, {"argument", AstDumper::Nullish(argument_)}}); +} +void SwitchStatement::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "SwitchStatement"}, {"discriminant", discriminant_}, {"cases", cases_}}); +} +void AssertStatement::Dump([[maybe_unused]] ir::AstDumper *dumper) const +{ + ES2PANDA_UNREACHABLE(); +} + +void AnnotationUsage::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"expr_", expr_}, {"properties", properties_}}); +} +void AnnotationDeclaration::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"Expr", Expr()}, {"properties", Properties()}, {"annotations", AstDumper::Optional(Annotations())}}); +} +void LabelledStatement::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "LabelledStatement"}, {"label", ident_}, {"body", body_}}); +} +void ExpressionStatement::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "ExpressionStatement"}, {"expression", expression_}}); +} +void WhileStatement::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "WhileStatement"}, {"test", test_}, {"body", body_}}); +} +void BlockStatement::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", IsProgram() ? "Program" : "BlockStatement"}, {"statements", Statements()}}); +} +void ThrowStatement::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "ThrowStatement"}, {"argument", argument_}}); +} +void EmptyStatement::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "EmptyStatement"}}); +} + +void DebuggerStatement::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "DebuggerStatement"}}); +} + +void ForOfStatement::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "ForOfStatement"}, {"await", isAwait_}, {"left", left_}, {"right", right_}, {"body", body_}}); +} +void ForInStatement::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "ForInStatement"}, {"left", left_}, {"right", right_}, {"body", body_}}); +} + +void ContinueStatement::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "ContinueStatement"}, {"label", AstDumper::Nullish(ident_)}}); +} +void SwitchCaseStatement::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "SwitchCase"}, {"test", AstDumper::Nullish(test_)}, {"consequent", consequent_}}); +} +void VariableDeclarator::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "VariableDeclarator"}, {"id", id_}, {"init", AstDumper::Nullish(init_)}}); +} +void DoWhileStatement::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "DoWhileStatement"}, {"body", body_}, {"test", test_}}); +} +void ClassDeclaration::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "ClassDeclaration"}, {"definition", Definition()}}); +} +void BreakStatement::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "BreakStatement"}, {"label", AstDumper::Nullish(ident_)}}); +} +void OpaqueTypeNode::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "OpaqueType"}, {"annotations", AstDumper::Optional(Annotations())}}); +} + +void ETSNewClassInstanceExpression::Dump(ir::AstDumper *dumper) const +{ + dumper->Add( + {{"type", "ETSNewClassInstanceExpression"}, {"typeReference", typeReference_}, {"arguments", arguments_}}); +} + +void MetaProperty::Dump(ir::AstDumper *dumper) const +{ + const char *kind = nullptr; + + switch (kind_) { + case MetaPropertyKind::NEW_TARGET: { + kind = "new.Target"; + break; + } + case MetaPropertyKind::IMPORT_META: { + kind = "import.Meta"; + break; + } + default: { + ES2PANDA_UNREACHABLE(); + } + } + + dumper->Add({{"type", "MetaProperty"}, {"kind", kind}}); +} + +void MethodDefinition::Dump(ir::AstDumper *dumper) const +{ + const char *kind = nullptr; + + switch (Kind()) { + case MethodDefinitionKind::CONSTRUCTOR: { + kind = "constructor"; + break; + } + case MethodDefinitionKind::METHOD: { + kind = "method"; + break; + } + case MethodDefinitionKind::EXTENSION_METHOD: { + kind = "extensionmethod"; + break; + } + case MethodDefinitionKind::GET: { + kind = "get"; + break; + } + case MethodDefinitionKind::SET: { + kind = "set"; + break; + } + case MethodDefinitionKind::EXTENSION_GET: { + kind = "extensionget"; + break; + } + case MethodDefinitionKind::EXTENSION_SET: { + kind = "extensionset"; + break; + } + default: { + ES2PANDA_UNREACHABLE(); + } + } + + dumper->Add({{"type", "MethodDefinition"}, + {"key", Key()}, + {"kind", kind}, + {"accessibility", AstDumper::Optional(AstDumper::ModifierToString(Modifiers()))}, + {"static", IsStatic()}, + {"optional", IsOptionalDeclaration()}, + {"computed", IsComputed()}, + {"value", Value()}, + {"overloads", Overloads()}}); +} + +void Property::Dump(ir::AstDumper *dumper) const +{ + const char *kind = nullptr; + + switch (kind_) { + case PropertyKind::INIT: { + kind = "init"; + break; + } + case PropertyKind::PROTO: { + kind = "proto"; + break; + } + case PropertyKind::GET: { + kind = "get"; + break; + } + case PropertyKind::SET: { + kind = "set"; + break; + } + default: { + ES2PANDA_UNREACHABLE(); + } + } + + dumper->Add({{"type", "Property"}, + {"method", isMethod_}, + {"shorthand", isShorthand_}, + {"computed", isComputed_}, + {"key", key_}, + {"value", value_}, + {"kind", kind}}); +} + +void VariableDeclaration::Dump(ir::AstDumper *dumper) const +{ + const char *kind = nullptr; + + switch (Kind()) { + case VariableDeclarationKind::CONST: { + kind = "const"; + break; + } + case VariableDeclarationKind::LET: { + kind = "let"; + break; + } + case VariableDeclarationKind::VAR: { + kind = "var"; + break; + } + default: { + ES2PANDA_UNREACHABLE(); + } + } + + dumper->Add({{"type", "VariableDeclaration"}, + {"declarations", Declarators()}, + {"kind", kind}, + {"annotations", AstDumper::Optional(Annotations())}, + {"declare", AstDumper::Optional(IsDeclare())}}); +} + } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/astDump.h b/ets2panda/ir/astDump.h index febaf9827013db6cf04b53c63a323ffb4bd72d9c..fb239053fc300f5bf11c2c85f472c0c66a5952bc 100644 --- a/ets2panda/ir/astDump.h +++ b/ets2panda/ir/astDump.h @@ -16,16 +16,21 @@ #ifndef ES2PANDA_IR_AST_DUMP_H #define ES2PANDA_IR_AST_DUMP_H -#include "ir/astNode.h" #include "lexer/token/sourceLocation.h" #include "generated/tokenType.h" #include "lexer/token/number.h" +#include "libarkbase/utils/arena_vector.h" #include "util/ustring.h" #include #include namespace ark::es2panda::ir { + +enum class ModifierFlags : uint32_t; +enum class TSOperatorType; + +class AstNode; class AstDumper { public: class Nullish { @@ -44,7 +49,13 @@ public: class Optional { public: using Val = std::variant>; - explicit Optional(const ir::AstNode *node) : value_(node) {} + + // NOTE: the constructor is declared here with 'T' instead of 'AstNode' due to implicit 'ptr->bool' conversion, + // which allows overload resolution to select the bool-overload if the node class was declared but not defined. + template >> + explicit Optional(const T *node) : value_(node) + { + } explicit Optional(const char *string) : value_(const_cast(string)) {} explicit Optional(bool boolean) : value_(boolean) {} diff --git a/ets2panda/ir/astNode.cpp b/ets2panda/ir/astNode.cpp index 28288b0d25428ac69b7dc67254f32464690b3615..67d8ce13e9f5dc64321ca82ac5cea9aa86e3f739 100644 --- a/ets2panda/ir/astNode.cpp +++ b/ets2panda/ir/astNode.cpp @@ -16,8 +16,8 @@ #include "astNode.h" #include "compiler/lowering/phase.h" #include "ir/astDump.h" -#include "ir/astNodeHistory.h" #include "ir/srcDump.h" +#include "ir/astNodeHistory.h" #include "ir/typed.h" namespace ark::es2panda::ir { diff --git a/ets2panda/ir/astNode.h b/ets2panda/ir/astNode.h index 15dcfc1523636d207579a2c04c87972e5bf33405..5f0a60046515075d0675ba02a333db765133c395 100644 --- a/ets2panda/ir/astNode.h +++ b/ets2panda/ir/astNode.h @@ -21,8 +21,12 @@ #include "astNodeMapping.h" #include "compiler/lowering/phase_id.h" #include "ir/visitor/AstVisitor.h" + #include "lexer/token/sourceLocation.h" #include "util/es2pandaMacros.h" +#include "libarkbase/utils/arena_vector.h" +#include "libarkbase/utils/span.h" +#include "libarkbase/utils/logger.h" namespace ark::es2panda::public_lib { struct Context; @@ -117,9 +121,9 @@ inline std::string_view ToString(AstNodeType nodeType) // Forward declarations class AstNodeHistory; class AstDumper; -class Expression; class SrcDumper; class Declgen; +class Expression; class Statement; class ClassElement; template diff --git a/ets2panda/ir/base/catchClause.cpp b/ets2panda/ir/base/catchClause.cpp index c11433d958f4954e280b5d414698c2ff1e6ec797..ae7ab4480a49a8c03ba539efae54af25fa9a34ef 100644 --- a/ets2panda/ir/base/catchClause.cpp +++ b/ets2panda/ir/base/catchClause.cpp @@ -15,10 +15,9 @@ #include "catchClause.h" -#include "checker/TSchecker.h" -#include "compiler/core/pandagen.h" -#include "compiler/core/ETSGen.h" - +#include "ir/statements/blockStatement.h" +#include "ir/expressions/identifier.h" +#include "ir/typeNode.h" namespace ark::es2panda::ir { void CatchClause::TransformChildren(const NodeTransformer &cb, std::string_view transformationName) { @@ -44,56 +43,11 @@ void CatchClause::Iterate(const NodeTraverser &cb) const cb(body_); } -void CatchClause::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "CatchClause"}, {"body", body_}, {"param", AstDumper::Nullish(param_)}}); -} - -void CatchClause::Dump(ir::SrcDumper *dumper) const -{ - ES2PANDA_ASSERT(body_ != nullptr); - dumper->Add("("); - if (param_ != nullptr) { - param_->Dump(dumper); - if (param_->IsIdentifier() && param_->AsIdentifier()->TypeAnnotation() != nullptr) { - dumper->Add(": "); - param_->AsIdentifier()->TypeAnnotation()->Dump(dumper); - } - } - dumper->Add(") {"); - dumper->IncrIndent(); - dumper->Endl(); - body_->Dump(dumper); - dumper->DecrIndent(); - dumper->Endl(); - dumper->Add("}"); -} - bool CatchClause::IsDefaultCatchClause() const { return param_ != nullptr && param_->AsIdentifier()->TypeAnnotation() == nullptr; } -void CatchClause::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void CatchClause::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *CatchClause::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType CatchClause::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - CatchClause::CatchClause(CatchClause const &other, ArenaAllocator *allocator) : TypedStatement(other) { param_ = nullptr; diff --git a/ets2panda/ir/base/classDefinition.cpp b/ets2panda/ir/base/classDefinition.cpp index 2a61c15828f14ccbd43dc1857dda8e4ecdf23d56..45568910dd5ac29e3b1ca5c1af05a58711f94c5d 100644 --- a/ets2panda/ir/base/classDefinition.cpp +++ b/ets2panda/ir/base/classDefinition.cpp @@ -15,17 +15,17 @@ #include "classDefinition.h" -#include "checker/TSchecker.h" -#include "checker/ETSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" #include "ir/base/classStaticBlock.h" #include "ir/base/methodDefinition.h" #include "ir/base/scriptFunction.h" +#include "ir/expressions/functionExpression.h" +#include "ir/expressions/assignmentExpression.h" #include "ir/expressions/identifier.h" +#include "ir/statements/blockStatement.h" +#include "ir/statements/expressionStatement.h" #include "ir/ts/tsClassImplements.h" +#include "ir/ts/tsTypeParameterDeclaration.h" +#include "ir/ts/tsTypeParameterInstantiation.h" namespace ark::es2panda::ir { @@ -297,197 +297,6 @@ void ClassDefinition::SetIdent(ir::Identifier *ident) noexcept } } -void ClassDefinition::Dump(ir::AstDumper *dumper) const -{ - auto propFilter = [](AstNode *prop) -> bool { - return !prop->IsClassStaticBlock() || !prop->AsClassStaticBlock()->Function()->IsHidden(); - }; - auto ctor = GetHistoryNodeAs()->ctor_; - dumper->Add({{"id", AstDumper::Nullish(Ident())}, - {"typeParameters", AstDumper::Optional(TypeParams())}, - {"superClass", AstDumper::Nullish(SuperClass())}, - {"superTypeParameters", AstDumper::Optional(SuperTypeParams())}, - {"implements", Implements()}, - {"annotations", AstDumper::Optional(Annotations())}, - {"constructor", AstDumper::Optional(ctor)}, - {"body", Body(), propFilter}}); -} - -void ClassDefinition::DumpGlobalClass(ir::SrcDumper *dumper) const -{ - ES2PANDA_ASSERT(IsGlobal()); - ir::ClassStaticBlock *classStaticBlock = nullptr; - for (auto elem : Body()) { - if (elem->IsClassProperty()) { - elem->Dump(dumper); - dumper->Endl(); - } - - if (elem->IsClassStaticBlock()) { - classStaticBlock = elem->AsClassStaticBlock(); - } - } - for (auto elem : Body()) { - if (elem->IsMethodDefinition()) { - elem->Dump(dumper); - dumper->Endl(); - } - } - - if (classStaticBlock == nullptr || dumper->IsDeclgen()) { - return; - } - - auto bodyStmts = - classStaticBlock->Value()->AsFunctionExpression()->Function()->Body()->AsBlockStatement()->Statements(); - for (auto statement : bodyStmts) { - if (statement->IsExpressionStatement() && - statement->AsExpressionStatement()->GetExpression()->IsAssignmentExpression() && - statement->AsExpressionStatement()->GetExpression()->AsAssignmentExpression()->IsIgnoreConstAssign()) { - // skip the dummy assignment expression created for const variable decl in the class static block. - continue; - } - statement->Dump(dumper); - if (statement != bodyStmts.back()) { - dumper->Endl(); - } - } -} - -// This method is needed by OHOS CI code checker -void ClassDefinition::DumpBody(ir::SrcDumper *dumper) const -{ - auto const body = Body(); - dumper->Add(" {"); - if (!body.empty()) { - dumper->IncrIndent(); - dumper->Endl(); - for (auto elem : body) { - elem->Dump(dumper); - if (elem == body.back()) { - dumper->DecrIndent(); - } - dumper->Endl(); - } - } - dumper->Add("}"); -} - -void ClassDefinition::DumpPrefix(ir::SrcDumper *dumper) const -{ - if (IsExported()) { - dumper->Add("export "); - } else if (IsDefaultExported()) { - dumper->Add("export default "); - } - - if (dumper->IsDeclgen()) { - dumper->GetDeclgen()->TryDeclareAmbientContext(dumper); - } else if (IsDeclare()) { - dumper->Add("declare "); - } - - if (IsFinal()) { - dumper->Add("final "); - } - - if (IsAbstract() && !IsNamespaceTransformed()) { - dumper->Add("abstract "); - } - - if (parent_->IsETSStructDeclaration() || IsFromStruct()) { - dumper->Add("struct "); - } else if (IsNamespaceTransformed()) { - dumper->Add("namespace "); - } else { - dumper->Add("class "); - } -} - -bool ClassDefinition::RegisterUnexportedForDeclGen(ir::SrcDumper *dumper) const -{ - ES2PANDA_ASSERT(dumper->IsDeclgen()); - - if (dumper->GetDeclgen()->IsPostDumpIndirectDepsPhase()) { - return false; - } - - if (IsExported() || IsDefaultExported()) { - return false; - } - - const auto className = ident_->Name().Mutf8(); - dumper->GetDeclgen()->AddNode(className, this); - return true; -} - -void ClassDefinition::Dump(ir::SrcDumper *dumper) const -{ - auto guard = dumper->BuildAmbientContextGuard(); - // NOTE: plugin API fails - auto const ident = Ident(); - if ((ident->Name().StartsWith("$dynmodule")) || (ident->Name().StartsWith("$jscall"))) { - return; - } - - if (IsGlobal()) { - DumpGlobalClass(dumper); - return; - } - - ES2PANDA_ASSERT(ident_ != nullptr); - - if (dumper->IsDeclgen() && !IsNamespaceTransformed() && RegisterUnexportedForDeclGen(dumper)) { - return; - } - - DumpAnnotations(dumper); - - DumpPrefix(dumper); - ident_->Dump(dumper); - - if (TypeParams() != nullptr) { - dumper->Add("<"); - TypeParams()->Dump(dumper); - dumper->Add("> "); - } - - if (SuperClass() != nullptr) { - dumper->Add(" extends "); - SuperClass()->Dump(dumper); - } - - DumpItems(dumper, " implements ", Implements()); - - if (!IsDeclare() || !Body().empty()) { - DumpBody(dumper); - } - if (IsLocal()) { - dumper->Add(";"); - } - dumper->Endl(); -} - -void ClassDefinition::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void ClassDefinition::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *ClassDefinition::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType ClassDefinition::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - ClassDefinition *ClassDefinition::Construct(ArenaAllocator *allocator) { ArenaVector body {allocator->Adapter()}; diff --git a/ets2panda/ir/base/classDefinition.h b/ets2panda/ir/base/classDefinition.h index 4425052ca70bc3780384b940cd883d573490071d..f4f682ae9a88ec35188679c433eb661eb70afe94 100644 --- a/ets2panda/ir/base/classDefinition.h +++ b/ets2panda/ir/base/classDefinition.h @@ -18,7 +18,7 @@ #include "varbinder/scope.h" #include "varbinder/variable.h" -#include "ir/srcDump.h" + #include "ir/annotationAllowed.h" #include "ir/astNode.h" #include "ir/astNodeHistory.h" @@ -26,6 +26,7 @@ #include "ir/statements/annotationUsage.h" #include "ir/statements/classDeclaration.h" #include "util/language.h" +#include "libarkbase/utils/arena_set.h" namespace ark::es2panda::ir { class ClassElement; @@ -479,21 +480,6 @@ public: v->Accept(this); } - template - static void DumpItems(ir::SrcDumper *dumper, const std::string &prefix, const ArenaVector &items) - { - if (items.empty()) { - return; - } - dumper->Add(prefix); - for (size_t i = 0; i < items.size(); ++i) { - items[i]->Dump(dumper); - if (i < items.size() - 1) { - dumper->Add(", "); - } - } - } - void CleanUp() override { AstNode::CleanUp(); diff --git a/ets2panda/ir/base/classProperty.cpp b/ets2panda/ir/base/classProperty.cpp index 944a3462d52008b2cb6bf517d211aca844cf8ade..372b6f85da875ca818d937fbfc1edcf8aab7f508 100644 --- a/ets2panda/ir/base/classProperty.cpp +++ b/ets2panda/ir/base/classProperty.cpp @@ -14,13 +14,7 @@ */ #include "classProperty.h" - -#include "checker/ETSchecker.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "compiler/lowering/util.h" -#include "public/public.h" +#include "ir/typeNode.h" namespace ark::es2panda::ir { @@ -80,192 +74,6 @@ void ClassProperty::Iterate(const NodeTraverser &cb) const IterateAnnotations(cb); } -void ClassProperty::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "ClassProperty"}, - {"key", Key()}, - {"value", AstDumper::Optional(Value())}, - {"accessibility", AstDumper::Optional(AstDumper::ModifierToString(Modifiers()))}, - {"static", IsStatic()}, - {"readonly", IsReadonly()}, - {"declare", IsDeclare()}, - {"optional", IsOptionalDeclaration()}, - {"computed", IsComputed()}, - {"typeAnnotation", AstDumper::Optional(TypeAnnotation())}, - {"definite", IsDefinite()}, - {"annotations", AstDumper::Optional(Annotations())}}); -} - -void ClassProperty::DumpModifiers(ir::SrcDumper *dumper) const -{ - ES2PANDA_ASSERT(key_); - - if (compiler::HasGlobalClassParent(this)) { - if (IsExported()) { - dumper->Add("export "); - } - if (dumper->IsDeclgen()) { - dumper->Add("declare "); - } - if (IsConst()) { - dumper->Add("const "); - } else { - dumper->Add("let "); - } - return; - } - - if (Parent() != nullptr && Parent()->IsClassDefinition() && !Parent()->AsClassDefinition()->IsLocal()) { - if (IsPrivate()) { - dumper->Add("private "); - } else if (IsProtected()) { - dumper->Add("protected "); - } else { - dumper->Add("public "); - } - } - - if (IsStatic()) { - dumper->Add("static "); - } - - if (IsReadonly()) { - dumper->Add("readonly "); - } -} - -bool ClassProperty::DumpNamespaceForDeclGen(ir::SrcDumper *dumper) const -{ - if (!dumper->IsDeclgen()) { - return false; - } - - if (Parent() == nullptr) { - return false; - } - - bool isNamespaceTransformed = - Parent()->IsClassDefinition() && Parent()->AsClassDefinition()->IsNamespaceTransformed(); - if (isNamespaceTransformed) { - dumper->Add("let "); - return true; - } - return false; -} - -void ClassProperty::DumpPrefix(ir::SrcDumper *dumper) const -{ - DumpAnnotations(dumper); - if (DumpNamespaceForDeclGen(dumper)) { - return; - } - DumpModifiers(dumper); -} - -void ClassProperty::DumpCheckerTypeForDeclGen(ir::SrcDumper *dumper) const -{ - ES2PANDA_ASSERT(dumper->IsDeclgen()); - - if (TsType() == nullptr) { - return; - } - - dumper->Add(": "); - dumper->GetDeclgen()->Dump(dumper, TsType()); -} - -bool ClassProperty::RegisterUnexportedForDeclGen(ir::SrcDumper *dumper) const -{ - ES2PANDA_ASSERT(key_); - ES2PANDA_ASSERT(dumper->IsDeclgen()); - - auto name = key_->AsIdentifier()->Name().Mutf8(); - if (name.rfind('#', 0) == 0) { - return true; - } - - if (IsPrivate()) { - return true; - } - - if (!compiler::HasGlobalClassParent(this)) { - return false; - } - - if (dumper->GetDeclgen()->IsPostDumpIndirectDepsPhase()) { - return false; - } - - if (key_->Parent()->IsExported() || key_->Parent()->IsDefaultExported()) { - return false; - } - - dumper->GetDeclgen()->AddNode(name, this); - return true; -} - -void ClassProperty::Dump(ir::SrcDumper *dumper) const -{ - bool isNamespaceTransformed = - Parent()->IsClassDefinition() && Parent()->AsClassDefinition()->IsNamespaceTransformed(); - // For declgen dump only if explicitly marked as export or it is public property of class (not namespace or module) - if (dumper->IsDeclgen() && !(IsExported() || IsDefaultExported() || (!isNamespaceTransformed && IsPublic()))) { - return; - } - if (dumper->IsDeclgen() && RegisterUnexportedForDeclGen(dumper)) { - return; - } - DumpPrefix(dumper); - - if (Key() != nullptr) { - Key()->Dump(dumper); - } - - if (IsOptionalDeclaration()) { - dumper->Add("?"); - } - - if (IsDefinite()) { - dumper->Add("!"); - } - - if (typeAnnotation_ != nullptr) { - dumper->Add(": "); - TypeAnnotation()->Dump(dumper); - } else if (dumper->IsDeclgen()) { - DumpCheckerTypeForDeclGen(dumper); - } - - if (value_ != nullptr) { - if (!dumper->IsDeclgen() || Parent()->IsAnnotationDeclaration()) { - dumper->Add(" = "); - Value()->Dump(dumper); - } - } - - dumper->Add(";"); -} - -void ClassProperty::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void ClassProperty::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *ClassProperty::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType ClassProperty::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - ClassProperty *ClassProperty::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto *const key = Key()->Clone(allocator, nullptr)->AsExpression(); diff --git a/ets2panda/ir/base/classStaticBlock.cpp b/ets2panda/ir/base/classStaticBlock.cpp index dffca6bb9cb072b951909353fb8d20bbd3d09b82..11a863483107ead5d0f5acd4a9111430b07a3812 100644 --- a/ets2panda/ir/base/classStaticBlock.cpp +++ b/ets2panda/ir/base/classStaticBlock.cpp @@ -15,12 +15,6 @@ #include "classStaticBlock.h" -#include "checker/ETSchecker.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" #include "ir/base/decorator.h" #include "ir/base/scriptFunction.h" #include "ir/expression.h" @@ -43,51 +37,6 @@ void ClassStaticBlock::Iterate(const NodeTraverser &cb) const cb(value); } -void ClassStaticBlock::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "ClassStaticBlock"}, {"value", Value()}}); -} - -void ClassStaticBlock::Dump(ir::SrcDumper *dumper) const -{ - if (dumper->IsDeclgen()) { - return; - } - - ES2PANDA_ASSERT(value_); - ES2PANDA_ASSERT(value_->IsFunctionExpression()); - ES2PANDA_ASSERT(value_->AsFunctionExpression()->Function()->IsScriptFunction()); - dumper->Add("static {"); - dumper->IncrIndent(); - dumper->Endl(); - const auto *scriptFunc = value_->AsFunctionExpression()->Function()->AsScriptFunction(); - ES2PANDA_ASSERT(scriptFunc->HasBody()); - scriptFunc->Body()->Dump(dumper); - dumper->DecrIndent(); - dumper->Endl(); - dumper->Add("}"); -} - -void ClassStaticBlock::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void ClassStaticBlock::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *ClassStaticBlock::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType ClassStaticBlock::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - ir::ScriptFunction *ClassStaticBlock::Function() { return Value()->AsFunctionExpression()->Function(); diff --git a/ets2panda/ir/base/decorator.cpp b/ets2panda/ir/base/decorator.cpp index 573093d668402ec608935c9a2a7036bbd6641010..755fabf6df1bf453c5c5ce2afd87f616963acc7e 100644 --- a/ets2panda/ir/base/decorator.cpp +++ b/ets2panda/ir/base/decorator.cpp @@ -15,10 +15,7 @@ #include "decorator.h" -#include "checker/ETSchecker.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" +#include "ir/expression.h" namespace ark::es2panda::ir { void Decorator::TransformChildren(const NodeTransformer &cb, std::string_view transformationName) @@ -34,36 +31,6 @@ void Decorator::Iterate(const NodeTraverser &cb) const cb(expr_); } -void Decorator::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "Decorator"}, {"expression", expr_}}); -} - -void Decorator::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add("Decorator"); -} - -void Decorator::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void Decorator::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *Decorator::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType Decorator::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - Decorator *Decorator::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto *const expr = expr_ != nullptr ? expr_->Clone(allocator, nullptr)->AsExpression() : nullptr; diff --git a/ets2panda/ir/base/metaProperty.cpp b/ets2panda/ir/base/metaProperty.cpp index 38bed829d844a75ec6bdcebd8f8d767128a9876a..227597488392a1d4f137424f586b5a4f6c08e13e 100644 --- a/ets2panda/ir/base/metaProperty.cpp +++ b/ets2panda/ir/base/metaProperty.cpp @@ -15,10 +15,6 @@ #include "metaProperty.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" - namespace ark::es2panda::ir { void MetaProperty::TransformChildren([[maybe_unused]] const NodeTransformer &cb, [[maybe_unused]] std::string_view const transformationName) @@ -27,52 +23,6 @@ void MetaProperty::TransformChildren([[maybe_unused]] const NodeTransformer &cb, void MetaProperty::Iterate([[maybe_unused]] const NodeTraverser &cb) const {} -void MetaProperty::Dump(ir::AstDumper *dumper) const -{ - const char *kind = nullptr; - - switch (kind_) { - case MetaPropertyKind::NEW_TARGET: { - kind = "new.Target"; - break; - } - case MetaPropertyKind::IMPORT_META: { - kind = "import.Meta"; - break; - } - default: { - ES2PANDA_UNREACHABLE(); - } - } - - dumper->Add({{"type", "MetaProperty"}, {"kind", kind}}); -} - -void MetaProperty::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void MetaProperty::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add("MetaProperty"); -} - -void MetaProperty::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *MetaProperty::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType MetaProperty::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - MetaProperty *MetaProperty::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto *const clone = allocator->New(kind_); diff --git a/ets2panda/ir/base/methodDefinition.cpp b/ets2panda/ir/base/methodDefinition.cpp index f3eb2b597872e29587ed1c240752a56519e68f19..c324e8fd11063b073a7e510719e0dd345598e90e 100644 --- a/ets2panda/ir/base/methodDefinition.cpp +++ b/ets2panda/ir/base/methodDefinition.cpp @@ -15,12 +15,9 @@ #include "methodDefinition.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" #include "classDefinition.h" #include "ir/ts/tsInterfaceBody.h" -#include "compiler/lowering/util.h" +#include "ir/expressions/functionExpression.h" namespace ark::es2panda::ir { @@ -118,256 +115,6 @@ void MethodDefinition::TransformChildren(const NodeTransformer &cb, std::string_ } } -void MethodDefinition::Dump(ir::AstDumper *dumper) const -{ - const char *kind = nullptr; - - switch (Kind()) { - case MethodDefinitionKind::CONSTRUCTOR: { - kind = "constructor"; - break; - } - case MethodDefinitionKind::METHOD: { - kind = "method"; - break; - } - case MethodDefinitionKind::EXTENSION_METHOD: { - kind = "extensionmethod"; - break; - } - case MethodDefinitionKind::GET: { - kind = "get"; - break; - } - case MethodDefinitionKind::SET: { - kind = "set"; - break; - } - case MethodDefinitionKind::EXTENSION_GET: { - kind = "extensionget"; - break; - } - case MethodDefinitionKind::EXTENSION_SET: { - kind = "extensionset"; - break; - } - default: { - ES2PANDA_UNREACHABLE(); - } - } - - dumper->Add({{"type", "MethodDefinition"}, - {"key", Key()}, - {"kind", kind}, - {"accessibility", AstDumper::Optional(AstDumper::ModifierToString(Modifiers()))}, - {"static", IsStatic()}, - {"optional", IsOptionalDeclaration()}, - {"computed", IsComputed()}, - {"value", Value()}, - {"overloads", Overloads()}}); -} - -static void DumpModifierPrefix(const ir::MethodDefinition *m, ir::SrcDumper *dumper) -{ - ES2PANDA_ASSERT(!compiler::HasGlobalClassParent(m)); - if (m->IsStatic()) { - dumper->Add("static "); - } - - if (m->IsAbstract() && - !(m->Parent()->IsTSInterfaceBody() || - (m->BaseOverloadMethod() != nullptr && m->BaseOverloadMethod()->Parent()->IsTSInterfaceBody()))) { - dumper->Add("abstract "); - } - if (m->IsFinal()) { - dumper->Add("final "); - } - if (m->IsNative()) { - dumper->Add("native "); - } - if (m->IsAsync() && !dumper->IsDeclgen()) { - dumper->Add("async "); - } - if (m->IsOverride()) { - dumper->Add("override "); - } - - if (m->IsGetter()) { - dumper->Add("get "); - } else if (m->IsSetter()) { - dumper->Add("set "); - } -} - -static bool IsNamespaceTransformed(const MethodDefinition *method) -{ - auto *parent = method->Parent(); - if (parent->IsMethodDefinition()) { - // handle overloads - parent = parent->Parent(); - } - return parent->IsClassDefinition() && parent->AsClassDefinition()->IsNamespaceTransformed(); -} - -static void DumpAccessorPrefix(const ir::MethodDefinition *m, ir::SrcDumper *dumper) -{ - // special processing for overloads - auto const *parent = m->Parent(); - if (parent != nullptr && parent->IsMethodDefinition()) { - parent = parent->Parent(); - } - - if (parent == nullptr) { - return; - } - - if (parent->IsClassDefinition() && !parent->AsClassDefinition()->IsLocal()) { - if (m->IsPrivate()) { - dumper->Add("private "); - } else if (m->IsProtected()) { - dumper->Add("protected "); - } else if (!dumper->IsDeclgen()) { - dumper->Add("public "); - } - return; - } - - if (dumper->IsDeclgen() && parent->IsTSInterfaceBody()) { - if (m->Value() != nullptr && m->Value()->IsFunctionExpression() && - m->Value()->AsFunctionExpression()->Function() != nullptr && - m->Value()->AsFunctionExpression()->Function()->HasBody()) { - dumper->Add("default "); - } - } -} - -static void DumpPrefix(const ir::MethodDefinition *m, ir::SrcDumper *dumper) -{ - bool global = compiler::HasGlobalClassParent(m); - if (global || IsNamespaceTransformed(m)) { - if (m->IsExported()) { - dumper->Add("export "); - } - if (m->IsDefaultExported()) { - dumper->Add("export default "); - } - if (dumper->IsDeclgen()) { - if (global) { - dumper->Add("declare "); - } else { - dumper->GetDeclgen()->TryDeclareAmbientContext(dumper); - } - } - dumper->Add("function "); - return; - } - - DumpAccessorPrefix(m, dumper); - DumpModifierPrefix(m, dumper); -} - -bool MethodDefinition::FilterForDeclGen() const -{ - if (key_ == nullptr) { - return false; - } - - if (Function()->IsSynthetic()) { - return true; - } - - if (compiler::HasGlobalClassParent(this) && !key_->Parent()->IsExported() && !key_->Parent()->IsDefaultExported()) { - return true; - } - - ES2PANDA_ASSERT(Id() != nullptr); - auto name = Id()->Name().Mutf8(); - if (name.find("%%async") != std::string::npos || name == compiler::Signatures::INITIALIZER_BLOCK_INIT || - name == compiler::Signatures::INIT_METHOD) { - return true; - } - - if (name.rfind('#', 0) == 0) { - return true; - } - - if (name == compiler::Signatures::CCTOR) { - return true; - } - - return false; -} - -static void DumpSingleOverload(const ir::MethodDefinition *m, ir::SrcDumper *dumper) -{ - if (compiler::HasGlobalClassParent(m) && m->Id() != nullptr && - m->Id()->Name().Is(compiler::Signatures::INIT_METHOD)) { - m->Function()->Body()->Dump(dumper); - return; - } - - auto value = m->Value(); - if (value->AsFunctionExpression()->Function()->HasAnnotations()) { - for (auto *anno : value->AsFunctionExpression()->Function()->Annotations()) { - // NOTE(zhelyapov): workaround, see #26031 - if (anno->GetBaseName()->Name() != compiler::Signatures::DEFAULT_ANNO_FOR_FUNC) { - anno->Dump(dumper); - } - } - } - - DumpPrefix(m, dumper); - - if (m->IsConstructor() && - !(m->Key()->IsIdentifier() && m->Key()->AsIdentifier()->Name().Is(compiler::Signatures::CONSTRUCTOR_NAME))) { - dumper->Add(std::string(compiler::Signatures::CONSTRUCTOR_NAME) + " "); - } - - auto key = m->Key(); - if (key != nullptr) { - key->Dump(dumper); - } - - if (value != nullptr) { - value->Dump(dumper); - } -} - -void MethodDefinition::Dump(ir::SrcDumper *dumper) const -{ - if (dumper->IsDeclgen() && FilterForDeclGen()) { - return; - } - - if (!dumper->IsDeclgen() || !IsPrivate()) { - DumpSingleOverload(this, dumper); - } - - for (auto method : Overloads()) { - method->Dump(dumper); - } -} - -void MethodDefinition::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void MethodDefinition::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *MethodDefinition::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType MethodDefinition::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - MethodDefinition *MethodDefinition::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto *const key = Key()->Clone(allocator, nullptr)->AsExpression(); diff --git a/ets2panda/ir/base/overloadDeclaration.cpp b/ets2panda/ir/base/overloadDeclaration.cpp index 38122f80e32c6516467ef0c2578a17047329f421..c3f3a96b0f6a5de89585b820da28f14870fa6e0a 100644 --- a/ets2panda/ir/base/overloadDeclaration.cpp +++ b/ets2panda/ir/base/overloadDeclaration.cpp @@ -14,8 +14,6 @@ */ #include "overloadDeclaration.h" -#include "checker/ETSchecker.h" -#include "compiler/lowering/util.h" namespace ark::es2panda::ir { PrivateFieldKind OverloadDeclaration::ToPrivateFieldKind(bool const isStatic) const @@ -51,70 +49,6 @@ void OverloadDeclaration::Iterate(const NodeTraverser &cb) const } } -void OverloadDeclaration::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "OverloadDeclaration"}, - {"key", key_}, - {"optional", AstDumper::Optional(AstDumper::ModifierToString(flags_))}, - {"static", IsStatic()}, - {"overloadedList", overloadedList_}}); -} - -void OverloadDeclaration::DumpModifier(ir::SrcDumper *dumper) const -{ - if (compiler::HasGlobalClassParent(this) && !dumper->IsDeclgen()) { - if (IsExported()) { - dumper->Add("export "); - } - } - - if (Parent() != nullptr && Parent()->IsClassDefinition() && !Parent()->AsClassDefinition()->IsLocal() && - !compiler::HasGlobalClassParent(this)) { - if (IsPrivate()) { - dumper->Add("private "); - } else if (IsProtected()) { - dumper->Add("protected "); - } else { - dumper->Add("public "); - } - - if (IsStatic()) { - dumper->Add("static "); - } - } - - if (IsAsync()) { - dumper->Add("async "); - } -} - -void OverloadDeclaration::Dump(ir::SrcDumper *dumper) const -{ - DumpModifier(dumper); - dumper->Add("overload "); - dumper->Add(IsConstructor() ? "constructor " : key_->AsIdentifier()->Name().Mutf8()); - dumper->Add("{"); - for (size_t i = 0; i < overloadedList_.size(); i++) { - if (i != 0) { - dumper->Add(", "); - } - overloadedList_[i]->Dump(dumper); - } - dumper->Add("};"); -} - -void OverloadDeclaration::Compile([[maybe_unused]] compiler::PandaGen *pg) const {} - -checker::Type *OverloadDeclaration::Check([[maybe_unused]] checker::TSChecker *checker) -{ - return nullptr; -} - -checker::VerifiedType OverloadDeclaration::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - OverloadDeclaration *OverloadDeclaration::Construct(ArenaAllocator *allocator) { return allocator->New(nullptr, ModifierFlags::NONE, allocator); diff --git a/ets2panda/ir/base/property.cpp b/ets2panda/ir/base/property.cpp index 6f5387e9dba5f2aad5b22c44690262318261fe8b..68eaca1b54f507ecacbaab0d26a6ca3136810e33 100644 --- a/ets2panda/ir/base/property.cpp +++ b/ets2panda/ir/base/property.cpp @@ -15,9 +15,11 @@ #include "property.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" +#include "ir/expressions/objectExpression.h" +#include "ir/expressions/arrayExpression.h" +#include "ir/expressions/assignmentExpression.h" +#include "ir/expressions/identifier.h" +#include "ir/expressions/literals/stringLiteral.h" namespace ark::es2panda::ir { Property::Property([[maybe_unused]] Tag const tag, Property const &other, Expression *const key, @@ -102,67 +104,4 @@ void Property::Iterate(const NodeTraverser &cb) const cb(value_); } -void Property::Dump(ir::AstDumper *dumper) const -{ - const char *kind = nullptr; - - switch (kind_) { - case PropertyKind::INIT: { - kind = "init"; - break; - } - case PropertyKind::PROTO: { - kind = "proto"; - break; - } - case PropertyKind::GET: { - kind = "get"; - break; - } - case PropertyKind::SET: { - kind = "set"; - break; - } - default: { - ES2PANDA_UNREACHABLE(); - } - } - - dumper->Add({{"type", "Property"}, - {"method", isMethod_}, - {"shorthand", isShorthand_}, - {"computed", isComputed_}, - {"key", key_}, - {"value", value_}, - {"kind", kind}}); -} - -void Property::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void Property::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -void Property::Dump(ir::SrcDumper *dumper) const -{ - if (kind_ == PropertyKind::INIT) { - key_->Dump(dumper); - dumper->Add(": "); - value_->Dump(dumper); - } -} - -checker::Type *Property::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType Property::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/base/scriptFunction.cpp b/ets2panda/ir/base/scriptFunction.cpp index 682c700e7fc86f8043fc45232cfe0ce4511ee64e..9729ca3b9c60d8cb1041151badc533bf5c77d380 100644 --- a/ets2panda/ir/base/scriptFunction.cpp +++ b/ets2panda/ir/base/scriptFunction.cpp @@ -15,14 +15,14 @@ #include "scriptFunction.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" +#include "ir/typeNode.h" +#include "ir/expressions/identifier.h" +#include "ir/statements/blockStatement.h" +#include "ir/ts/tsTypeParameterDeclaration.h" + #include "libarkbase/mem/arena_allocator.h" -#include "libarkbase/utils/arena_containers.h" +#include "util/helpers.h" namespace ark::es2panda::ir { void ScriptFunction::SetBody(AstNode *body) @@ -271,128 +271,6 @@ void ScriptFunction::SetReturnTypeAnnotation(TypeNode *node) noexcept } } -void ScriptFunction::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "ScriptFunction"}, - {"id", AstDumper::Nullish(Id())}, - {"generator", IsGenerator()}, - {"async", IsAsyncFunc()}, - {"expression", ((Flags() & ir::ScriptFunctionFlags::EXPRESSION) != 0)}, - {"params", Params()}, - {"returnType", AstDumper::Optional(ReturnTypeAnnotation())}, - {"typeParameters", AstDumper::Optional(TypeParams())}, - {"declare", AstDumper::Optional(IsDeclare())}, - {"body", AstDumper::Optional(Body())}, - {"annotations", AstDumper::Optional(Annotations())}}); -} - -void ScriptFunction::DumpCheckerTypeForDeclGen(ir::SrcDumper *dumper) const -{ - ES2PANDA_ASSERT(dumper->IsDeclgen()); - - if (IsConstructor()) { - return; - } - - if (IsSetter()) { - return; - } - - if (Signature() == nullptr) { - return; - } - - if (Signature()->ReturnType() == nullptr) { - return; - } - - auto typeStr = Signature()->ReturnType()->ToString(); - dumper->Add(": "); - dumper->Add(typeStr); - - dumper->GetDeclgen()->PushTask([dumper, typeStr] { dumper->GetDeclgen()->DumpNode(dumper, typeStr); }); -} - -void ScriptFunction::Dump(ir::SrcDumper *dumper) const -{ - if (TypeParams() != nullptr) { - dumper->Add("<"); - TypeParams()->Dump(dumper); - dumper->Add(">"); - } - dumper->Add("("); - for (auto param : Params()) { - param->Dump(dumper); - if (param != Params().back()) { - dumper->Add(", "); - } - } - dumper->Add(")"); - if (ReturnTypeAnnotation() != nullptr) { - dumper->Add(": "); - ReturnTypeAnnotation()->Dump(dumper); - } else if (dumper->IsDeclgen()) { - DumpCheckerTypeForDeclGen(dumper); - } - if (dumper->IsDeclgen()) { - dumper->Add(";"); - dumper->Endl(); - return; - } - DumpBody(dumper); -} - -void ScriptFunction::DumpBody(ir::SrcDumper *dumper) const -{ - if (!HasBody()) { - dumper->Endl(); - return; - } - - if (IsArrow()) { - dumper->Add(" =>"); - } - - if (body_->IsBlockStatement()) { - dumper->Add(" {"); - const auto &statements = body_->AsBlockStatement()->Statements(); - if (!statements.empty()) { - dumper->IncrIndent(); - dumper->Endl(); - body_->Dump(dumper); - dumper->DecrIndent(); - dumper->Endl(); - } - dumper->Add("}"); - } else { - dumper->Add(" "); - body_->Dump(dumper); - } - - if (!IsArrow()) { - dumper->Endl(); - } -} - -void ScriptFunction::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} -void ScriptFunction::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *ScriptFunction::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType ScriptFunction::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - ScriptFunction *ScriptFunction::Construct(ArenaAllocator *allocator) { auto adapter = allocator->Adapter(); diff --git a/ets2panda/ir/base/spreadElement.cpp b/ets2panda/ir/base/spreadElement.cpp index 63e63714beb7cf4af9c117d9bb2075d86fa801b8..85bdc5dc7d1d89d8d7b94ade3bbd886f7c203e2f 100644 --- a/ets2panda/ir/base/spreadElement.cpp +++ b/ets2panda/ir/base/spreadElement.cpp @@ -15,9 +15,9 @@ #include "spreadElement.h" -#include "checker/TSchecker.h" -#include "compiler/core/pandagen.h" -#include "compiler/core/ETSGen.h" +#include "ir/expressions/objectExpression.h" +#include "ir/expressions/arrayExpression.h" +#include "ir/typeNode.h" namespace ark::es2panda::ir { SpreadElement::SpreadElement([[maybe_unused]] Tag const tag, SpreadElement const &other, @@ -95,43 +95,6 @@ void SpreadElement::Iterate(const NodeTraverser &cb) const } } -void SpreadElement::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", (type_ == AstNodeType::SPREAD_ELEMENT) ? "SpreadElement" : "RestElement"}, - {"argument", argument_}, - {"typeAnnotation", AstDumper::Optional(TypeAnnotation())}}); -} - -void SpreadElement::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add("..."); - argument_->Dump(dumper); - auto type = TypeAnnotation(); - if (type != nullptr && type->IsValidInCurrentPhase()) { - dumper->Add(": "); - type->Dump(dumper); - } -} - -void SpreadElement::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} -void SpreadElement::Compile([[maybe_unused]] compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *SpreadElement::Check([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType SpreadElement::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - std::string SpreadElement::ToString() const { auto str = Argument()->ToString(); diff --git a/ets2panda/ir/base/templateElement.cpp b/ets2panda/ir/base/templateElement.cpp index 4ba3be396ab3d805729e62709515a8c2a4673c42..f154c5da7db6f105cdad3f34db267daacd3ce93a 100644 --- a/ets2panda/ir/base/templateElement.cpp +++ b/ets2panda/ir/base/templateElement.cpp @@ -15,10 +15,6 @@ #include "templateElement.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" - namespace ark::es2panda::ir { void TemplateElement::TransformChildren([[maybe_unused]] const NodeTransformer &cb, [[maybe_unused]] std::string_view const transformationName) @@ -27,39 +23,6 @@ void TemplateElement::TransformChildren([[maybe_unused]] const NodeTransformer & void TemplateElement::Iterate([[maybe_unused]] const NodeTraverser &cb) const {} -void TemplateElement::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({ - {"type", "TemplateElement"}, - {"value", {{"raw", raw_}, {"cooked", cooked_}}}, - }); -} - -void TemplateElement::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add(std::string(raw_)); -} - -void TemplateElement::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void TemplateElement::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *TemplateElement::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType TemplateElement::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - TemplateElement *TemplateElement::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto *const clone = allocator->New(raw_, cooked_); diff --git a/ets2panda/ir/base/tsIndexSignature.cpp b/ets2panda/ir/base/tsIndexSignature.cpp index 22d8a78b5655f40150fe944aa864d84c5cea1ccc..1695e64fc6479ec5a255f9b3758957cdbe771afc 100644 --- a/ets2panda/ir/base/tsIndexSignature.cpp +++ b/ets2panda/ir/base/tsIndexSignature.cpp @@ -15,9 +15,7 @@ #include "tsIndexSignature.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" +#include "ir/expressions/identifier.h" namespace ark::es2panda::ir { TSIndexSignature::TSIndexSignatureKind TSIndexSignature::Kind() const noexcept @@ -45,39 +43,6 @@ void TSIndexSignature::Iterate(const NodeTraverser &cb) const cb(typeAnnotation_); } -void TSIndexSignature::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "TSIndexSignature"}, - {"parameters", param_}, - {"typeAnnotation", typeAnnotation_}, - {"readonly", readonly_}}); -} - -void TSIndexSignature::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add("TSIndexSignature"); -} - -void TSIndexSignature::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void TSIndexSignature::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *TSIndexSignature::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType TSIndexSignature::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - TSIndexSignature *TSIndexSignature::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto *const param = param_ != nullptr ? param_->Clone(allocator, nullptr)->AsExpression() : nullptr; diff --git a/ets2panda/ir/base/tsMethodSignature.cpp b/ets2panda/ir/base/tsMethodSignature.cpp index de2b99a6a186fff17126ab382bfa9beff3108b51..355a45f6add8e4044027f9436fc0826e2154d075 100644 --- a/ets2panda/ir/base/tsMethodSignature.cpp +++ b/ets2panda/ir/base/tsMethodSignature.cpp @@ -14,11 +14,8 @@ */ #include "tsMethodSignature.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" +#include "ir/ts/tsTypeParameterDeclaration.h" +#include "ir/typeNode.h" namespace ark::es2panda::ir { void TSMethodSignature::TransformChildren(const NodeTransformer &cb, std::string_view const transformationName) @@ -37,39 +34,4 @@ void TSMethodSignature::Iterate(const NodeTraverser &cb) const signature_.Iterate(cb); } -void TSMethodSignature::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "TSMethodSignature"}, - {"computed", computed_}, - {"optional", optional_}, - {"key", key_}, - {"params", Params()}, - {"typeParameters", AstDumper::Optional(TypeParams())}, - {"typeAnnotation", AstDumper::Optional(ReturnTypeAnnotation())}}); -} - -void TSMethodSignature::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add("TSMethodSignature"); -} - -void TSMethodSignature::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void TSMethodSignature::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *TSMethodSignature::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType TSMethodSignature::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/base/tsPropertySignature.cpp b/ets2panda/ir/base/tsPropertySignature.cpp index d1a2bb2ee1c3215b5dc81ee10c79a5a0bd480132..76f7690f683272184a6eec13b44402e680c8a440 100644 --- a/ets2panda/ir/base/tsPropertySignature.cpp +++ b/ets2panda/ir/base/tsPropertySignature.cpp @@ -15,9 +15,7 @@ #include "tsPropertySignature.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" +#include "ir/typeNode.h" namespace ark::es2panda::ir { void TSPropertySignature::TransformChildren(const NodeTransformer &cb, std::string_view const transformationName) @@ -44,41 +42,6 @@ void TSPropertySignature::Iterate(const NodeTraverser &cb) const } } -void TSPropertySignature::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "TSPropertySignature"}, - {"computed", computed_}, - {"optional", optional_}, - {"readonly", readonly_}, - {"key", key_}, - {"typeAnnotation", AstDumper::Optional(TypeAnnotation())}}); -} - -void TSPropertySignature::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add("TSPropertySignature"); -} - -void TSPropertySignature::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void TSPropertySignature::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *TSPropertySignature::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType TSPropertySignature::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - TSPropertySignature *TSPropertySignature::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto *const key = key_ != nullptr ? key_->Clone(allocator, nullptr)->AsExpression() : nullptr; diff --git a/ets2panda/ir/base/tsSignatureDeclaration.cpp b/ets2panda/ir/base/tsSignatureDeclaration.cpp index 141398e53ad54809bf782bb61ef90385914112fb..038c5af3b3d85e3de0a58e7faf5df2cb0a7e1a96 100644 --- a/ets2panda/ir/base/tsSignatureDeclaration.cpp +++ b/ets2panda/ir/base/tsSignatureDeclaration.cpp @@ -15,12 +15,8 @@ #include "tsSignatureDeclaration.h" -#include "checker/ETSchecker.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" +#include "ir/ts/tsTypeParameterDeclaration.h" +#include "ir/typeNode.h" namespace ark::es2panda::ir { void TSSignatureDeclaration::TransformChildren(const NodeTransformer &cb, std::string_view transformationName) @@ -33,38 +29,4 @@ void TSSignatureDeclaration::Iterate(const NodeTraverser &cb) const signature_.Iterate(cb); } -void TSSignatureDeclaration::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", (kind_ == TSSignatureDeclaration::TSSignatureDeclarationKind::CALL_SIGNATURE) - ? "TSCallSignatureDeclaration" - : "TSConstructSignatureDeclaration"}, - {"params", Params()}, - {"typeParameters", AstDumper::Optional(TypeParams())}, - {"returnType", AstDumper::Optional(ReturnTypeAnnotation())}}); -} - -void TSSignatureDeclaration::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add("TSSignatureDeclaration"); -} - -void TSSignatureDeclaration::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void TSSignatureDeclaration::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *TSSignatureDeclaration::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType TSSignatureDeclaration::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/brokenTypeNode.cpp b/ets2panda/ir/brokenTypeNode.cpp index 05ef63679f55f15117eaf0cf22f9f0ef00f2546b..5f4b6135bd5db984dc3ccf86da1453f091796b7f 100644 --- a/ets2panda/ir/brokenTypeNode.cpp +++ b/ets2panda/ir/brokenTypeNode.cpp @@ -14,11 +14,8 @@ */ #include "brokenTypeNode.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" + +#include "checker/ETSchecker.h" namespace ark::es2panda::ir { @@ -29,46 +26,6 @@ void BrokenTypeNode::TransformChildren([[maybe_unused]] const NodeTransformer &c void BrokenTypeNode::Iterate([[maybe_unused]] const NodeTraverser &cb) const {} -void BrokenTypeNode::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "ErrorType"}}); -} - -void BrokenTypeNode::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add(ERROR_TYPE); -} - -void BrokenTypeNode::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void BrokenTypeNode::Compile([[maybe_unused]] compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *BrokenTypeNode::Check([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::Type *BrokenTypeNode::GetType([[maybe_unused]] checker::TSChecker *checker) -{ - return nullptr; -} - -checker::Type *BrokenTypeNode::GetType([[maybe_unused]] checker::ETSChecker *checker) -{ - return checker->GlobalTypeError(); -} - -checker::VerifiedType BrokenTypeNode::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - BrokenTypeNode *BrokenTypeNode::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto *const clone = allocator->New(allocator); diff --git a/ets2panda/ir/brokenTypeNode.h b/ets2panda/ir/brokenTypeNode.h index f4143f6adf0f015b3d33d9b611771d1a789b8dd9..f38e5912894491f4cc30d711a3401a3c158a3e5a 100644 --- a/ets2panda/ir/brokenTypeNode.h +++ b/ets2panda/ir/brokenTypeNode.h @@ -39,7 +39,6 @@ public: void Compile([[maybe_unused]] compiler::PandaGen *pg) const override; void Compile([[maybe_unused]] compiler::ETSGen *etsg) const override; checker::Type *Check([[maybe_unused]] checker::TSChecker *checker) override; - checker::Type *GetType([[maybe_unused]] checker::TSChecker *checker) override; checker::VerifiedType Check([[maybe_unused]] checker::ETSChecker *checker) override; checker::Type *GetType([[maybe_unused]] checker::ETSChecker *checker) override; diff --git a/ets2panda/ir/ets/etsClassLiteral.cpp b/ets2panda/ir/ets/etsClassLiteral.cpp index ba0830fb309dc14f1c0c19e9dd964bb7b1c1fccd..afe940e1e36a66244480d088d91f77fbe664ace3 100644 --- a/ets2panda/ir/ets/etsClassLiteral.cpp +++ b/ets2panda/ir/ets/etsClassLiteral.cpp @@ -15,9 +15,7 @@ #include "etsClassLiteral.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" +#include "ir/typeNode.h" namespace ark::es2panda::ir { void ETSClassLiteral::TransformChildren(const NodeTransformer &cb, std::string_view transformationName) @@ -33,36 +31,6 @@ void ETSClassLiteral::Iterate([[maybe_unused]] const NodeTraverser &cb) const cb(expr_); } -void ETSClassLiteral::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "ETSClassLiteral"}}); -} - -void ETSClassLiteral::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add("ETSClassLiteral"); -} - -void ETSClassLiteral::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void ETSClassLiteral::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *ETSClassLiteral::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType ETSClassLiteral::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - ETSClassLiteral *ETSClassLiteral::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto *const expr = expr_ != nullptr ? expr_->Clone(allocator, nullptr) : nullptr; diff --git a/ets2panda/ir/ets/etsFunctionType.cpp b/ets2panda/ir/ets/etsFunctionType.cpp index 73b0c3bc03ac022d736bf1d97c9b8c89d712ffd6..2f08f8996fa6b851186e728eaaafe303f9622c22 100644 --- a/ets2panda/ir/ets/etsFunctionType.cpp +++ b/ets2panda/ir/ets/etsFunctionType.cpp @@ -15,10 +15,8 @@ #include "etsFunctionType.h" -#include "checker/TSchecker.h" -#include "checker/ETSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" +#include "ir/typeNode.h" +#include "ir/ts/tsTypeParameterDeclaration.h" namespace ark::es2panda::ir { void ETSFunctionType::SetParams(ArenaVector &¶msList) @@ -43,69 +41,6 @@ void ETSFunctionType::Iterate(const NodeTraverser &cb) const IterateAnnotations(cb); } -void ETSFunctionType::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "ETSFunctionType"}, - {"params", Params()}, - {"typeParameters", AstDumper::Optional(TypeParams())}, - {"returnType", ReturnType()}, - {"annotations", AstDumper::Optional(Annotations())}}); -} - -void ETSFunctionType::Dump(ir::SrcDumper *dumper) const -{ - DumpAnnotations(dumper); - dumper->Add("(("); - for (auto *param : Params()) { - param->Dump(dumper); - if (param != Params().back()) { - dumper->Add(", "); - } - } - dumper->Add(")"); - - if (TypeParams() != nullptr) { - TypeParams()->Dump(dumper); - } - - if (ReturnType() != nullptr) { - dumper->Add("=> "); - ReturnType()->Dump(dumper); - } - - dumper->Add(")"); -} - -void ETSFunctionType::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void ETSFunctionType::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *ETSFunctionType::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::Type *ETSFunctionType::GetType([[maybe_unused]] checker::TSChecker *checker) -{ - return nullptr; -} - -checker::VerifiedType ETSFunctionType::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - -checker::Type *ETSFunctionType::GetType(checker::ETSChecker *checker) -{ - return Check(checker); -} - ETSFunctionType *ETSFunctionType::Clone(ArenaAllocator *const allocator, AstNode *const parent) { ArenaVector paramsClone(allocator->Adapter()); diff --git a/ets2panda/ir/ets/etsFunctionType.h b/ets2panda/ir/ets/etsFunctionType.h index 3a1554983583ab8557076efaa4bad337f77da467..cd439123fa397e06405e66dfc2927099183c9b7a 100644 --- a/ets2panda/ir/ets/etsFunctionType.h +++ b/ets2panda/ir/ets/etsFunctionType.h @@ -124,7 +124,6 @@ public: void Compile(compiler::PandaGen *pg) const override; void Compile(compiler::ETSGen *etsg) const override; checker::Type *Check(checker::TSChecker *checker) override; - checker::Type *GetType([[maybe_unused]] checker::TSChecker *checker) override; checker::VerifiedType Check(checker::ETSChecker *checker) override; checker::Type *GetType([[maybe_unused]] checker::ETSChecker *checker) override; diff --git a/ets2panda/ir/ets/etsIntrinsicNode.cpp b/ets2panda/ir/ets/etsIntrinsicNode.cpp index ce5bc58839fcedafb935aee56d525ffaa9f6ff65..27b7b9f3e52884e03c35b0294b3d16995c48b1f5 100644 --- a/ets2panda/ir/ets/etsIntrinsicNode.cpp +++ b/ets2panda/ir/ets/etsIntrinsicNode.cpp @@ -14,8 +14,7 @@ */ #include "etsIntrinsicNode.h" - -#include "checker/ETSchecker.h" +#include "ir/typeNode.h" #include "compiler/core/ETSGen.h" namespace ark::es2panda::ir { @@ -27,25 +26,6 @@ void ETSIntrinsicNode::Iterate(const NodeTraverser &cb) const } } -void ETSIntrinsicNode::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "ETSIntrinsicNode"}, {"arguments", arguments_}}); -} - -void ETSIntrinsicNode::Dump([[maybe_unused]] ir::SrcDumper *dumper) const -{ - dumper->Add("%%intrin%%"); - dumper->Add(Id().Mutf8()); - dumper->Add("("); - for (auto arg : arguments_) { - arg->Dump(dumper); - if (arg != arguments_.back()) { - dumper->Add(", "); - } - } - dumper->Add(")"); -} - EtsIntrinsicInfo const *GetIntrinsicInfoFor(ETSIntrinsicNode const *node) { return node->info_; @@ -121,8 +101,6 @@ private: static const InfosMap INFOS; }; -void ETSIntrinsicNode::Compile([[maybe_unused]] compiler::PandaGen *pg) const {} - void ETSIntrinsicNode::Compile(compiler::ETSGen *etsg) const { if (auto info = GetIntrinsicInfoFor(this); LIKELY(info != nullptr)) { @@ -169,11 +147,6 @@ checker::Type *ETSIntrinsicNode::ExpectedTypeAt(checker::ETSChecker *checker, si return nullptr; } -checker::Type *ETSIntrinsicNode::Check([[maybe_unused]] checker::TSChecker *checker) -{ - return nullptr; -} - checker::VerifiedType ETSIntrinsicNode::Check([[maybe_unused]] checker::ETSChecker *checker) { if (auto info = GetIntrinsicInfoFor(this); LIKELY(info != nullptr)) { diff --git a/ets2panda/ir/ets/etsIntrinsicNode.h b/ets2panda/ir/ets/etsIntrinsicNode.h index 93791abcf8619e79b17fc373777c702a4afeb8e5..910646c00340a74e36d7a431e2d225c8e0bb138f 100644 --- a/ets2panda/ir/ets/etsIntrinsicNode.h +++ b/ets2panda/ir/ets/etsIntrinsicNode.h @@ -18,7 +18,6 @@ #include "ir/expression.h" #include "ir/visitor/AstVisitor.h" -#include "libarkbase/utils/arena_containers.h" namespace ark::es2panda::ir { diff --git a/ets2panda/ir/ets/etsKeyofType.cpp b/ets2panda/ir/ets/etsKeyofType.cpp index 6a319bcadcb7fec3aa25566e740ef8724154fc73..0ae99bbd04986e0ea89a1e53ec6298177b9d9182 100644 --- a/ets2panda/ir/ets/etsKeyofType.cpp +++ b/ets2panda/ir/ets/etsKeyofType.cpp @@ -15,8 +15,6 @@ #include "etsKeyofType.h" -#include "checker/ETSchecker.h" - namespace ark::es2panda::ir { void ETSKeyofType::TransformChildren(const NodeTransformer &cb, std::string_view const transformationName) { @@ -31,58 +29,6 @@ void ETSKeyofType::Iterate(const NodeTraverser &cb) const cb(type_); } -void ETSKeyofType::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "ETSKeyofType"}, {"types", type_}, {"annotations", AstDumper::Optional(Annotations())}}); -} - -void ETSKeyofType::Dump(ir::SrcDumper *dumper) const -{ - DumpAnnotations(dumper); - dumper->Add("keyof "); - type_->Dump(dumper); -} - -void ETSKeyofType::Compile([[maybe_unused]] compiler::PandaGen *pg) const {} - -checker::Type *ETSKeyofType::Check([[maybe_unused]] checker::TSChecker *checker) -{ - return nullptr; -} - -checker::VerifiedType ETSKeyofType::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - -checker::Type *ETSKeyofType::GetType(checker::ETSChecker *checker) -{ - if (TsType() != nullptr) { - return TsType(); - } - - auto *typeReference = type_->GetType(checker); - ES2PANDA_ASSERT(typeReference); - - if (typeReference->IsETSPrimitiveType()) { - typeReference = checker->MaybeBoxType(typeReference); - } - - if (!typeReference->IsETSObjectType()) { - checker->LogError(diagnostic::KEYOF_REFERENCE_TYPE, {}, Start()); - SetTsType(checker->GlobalTypeError()); - return checker->GlobalTypeError(); - } - - checker::TypeStackElement tse(checker, GetHistoryNode(), {{diagnostic::CYCLIC_TYPE_OF, {}}}, Start()); - if (tse.HasTypeError()) { - return checker->GlobalTypeError(); - } - - SetTsType(checker->CreateUnionFromKeyofType(typeReference->AsETSObjectType())); - return TsType(); -} - ETSKeyofType *ETSKeyofType::Clone(ArenaAllocator *const allocator, AstNode *const parent) { TypeNode *type = type_->Clone(allocator, nullptr); diff --git a/ets2panda/ir/ets/etsModule.cpp b/ets2panda/ir/ets/etsModule.cpp index 2546e217425c9c6b0baf13755a355a50e05bb5c6..3036b72fbfa97d80145a6116310c596edf6b0eed 100644 --- a/ets2panda/ir/ets/etsModule.cpp +++ b/ets2panda/ir/ets/etsModule.cpp @@ -14,49 +14,9 @@ */ #include "etsModule.h" -#include "libarkbase/utils/arena_containers.h" namespace ark::es2panda::ir { -void ETSModule::Dump(ir::SrcDumper *dumper) const -{ - if (IsNamespace()) { - if (IsExported()) { - dumper->Add("export "); - } - - if (IsDefaultExported()) { - dumper->Add("export default "); - } - - if (IsDeclare() && !(parent_ != nullptr && parent_->IsDeclare())) { - dumper->Add("declare "); - } - - dumper->Add("namespace "); - Ident()->Dump(dumper); - dumper->Add(" {"); - dumper->IncrIndent(); - } - - if (!Statements().empty()) { - dumper->Endl(); - for (auto elem : Statements()) { - elem->Dump(dumper); - if (elem != Statements().back()) { - dumper->Endl(); - } - } - } - if (IsNamespace()) { - dumper->DecrIndent(); - } - dumper->Endl(); - if (IsNamespace()) { - dumper->Add("}"); - } -} - ETSModule *ETSModule::Construct(ArenaAllocator *allocator) { ArenaVector statementList(allocator->Adapter()); diff --git a/ets2panda/ir/ets/etsModule.h b/ets2panda/ir/ets/etsModule.h index abc2a5eca1b40aa271e3706b1834926fbc9fe88c..a67a558b92645699e350387158a6749279c9fd8a 100644 --- a/ets2panda/ir/ets/etsModule.h +++ b/ets2panda/ir/ets/etsModule.h @@ -19,7 +19,6 @@ #include "ir/statements/blockStatement.h" #include "ir/annotationAllowed.h" #include "ir/expressions/identifier.h" -#include "ir/srcDump.h" namespace ark::es2panda::parser { class Program; diff --git a/ets2panda/ir/ets/etsNeverType.cpp b/ets2panda/ir/ets/etsNeverType.cpp index 527b3d7b35022282a8a9d0deb98ad8317deb7a69..9618d42ce7b668e28826153bfa4426e57fcc8798 100644 --- a/ets2panda/ir/ets/etsNeverType.cpp +++ b/ets2panda/ir/ets/etsNeverType.cpp @@ -15,8 +15,6 @@ #include "etsNeverType.h" -#include "checker/ETSchecker.h" - namespace ark::es2panda::ir { void ETSNeverType::TransformChildren([[maybe_unused]] const NodeTransformer &cb, [[maybe_unused]] std::string_view const transformationName) @@ -29,38 +27,6 @@ void ETSNeverType::Iterate([[maybe_unused]] const NodeTraverser &cb) const IterateAnnotations(cb); } -void ETSNeverType::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "ETSNeverType"}, {"annotations", AstDumper::Optional(Annotations())}}); -} - -void ETSNeverType::Dump(ir::SrcDumper *dumper) const -{ - DumpAnnotations(dumper); - dumper->Add("never"); -} - -void ETSNeverType::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - ES2PANDA_UNREACHABLE(); -} - -checker::Type *ETSNeverType::Check([[maybe_unused]] checker::TSChecker *checker) -{ - ES2PANDA_UNREACHABLE(); -} - -checker::VerifiedType ETSNeverType::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - -checker::Type *ETSNeverType::GetType([[maybe_unused]] checker::ETSChecker *checker) -{ - SetTsType(checker->GlobalETSNeverType()); - return TsType(); -} - ETSNeverType *ETSNeverType::Clone(ArenaAllocator *allocator, AstNode *parent) { auto *const clone = allocator->New(allocator); diff --git a/ets2panda/ir/ets/etsNewArrayInstanceExpression.cpp b/ets2panda/ir/ets/etsNewArrayInstanceExpression.cpp index 6031857627b31719e2fbf5ad4b3cab3c215a10e5..e60a0db4566d7630fbdcdd7fefa43fc4d6223716 100644 --- a/ets2panda/ir/ets/etsNewArrayInstanceExpression.cpp +++ b/ets2panda/ir/ets/etsNewArrayInstanceExpression.cpp @@ -15,11 +15,9 @@ #include "etsNewArrayInstanceExpression.h" -#include "checker/ETSchecker.h" #include "checker/ets/typeRelationContext.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" +#include "checker/types/ets/etsArrayType.h" +#include "ir/typeNode.h" namespace ark::es2panda::ir { void ETSNewArrayInstanceExpression::TransformChildren(const NodeTransformer &cb, @@ -42,42 +40,6 @@ void ETSNewArrayInstanceExpression::Iterate(const NodeTraverser &cb) const cb(dimension_); } -void ETSNewArrayInstanceExpression::Dump(ir::AstDumper *dumper) const -{ - dumper->Add( - {{"type", "ETSNewArrayInstanceExpression"}, {"typeReference", typeReference_}, {"dimension", dimension_}}); -} - -void ETSNewArrayInstanceExpression::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add("new "); - ES2PANDA_ASSERT(typeReference_); - typeReference_->Dump(dumper); - ES2PANDA_ASSERT(dimension_); - dumper->Add("["); - dimension_->Dump(dumper); - dumper->Add("]"); -} - -void ETSNewArrayInstanceExpression::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} -void ETSNewArrayInstanceExpression::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *ETSNewArrayInstanceExpression::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType ETSNewArrayInstanceExpression::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - ETSNewArrayInstanceExpression *ETSNewArrayInstanceExpression::Clone(ArenaAllocator *const allocator, AstNode *const parent) { diff --git a/ets2panda/ir/ets/etsNewClassInstanceExpression.cpp b/ets2panda/ir/ets/etsNewClassInstanceExpression.cpp index 7c0b525c0e0a81f81125ffd054e34218f715914f..c304f244db98a67bfdfd0ab5ac7dd993cd18cb7d 100644 --- a/ets2panda/ir/ets/etsNewClassInstanceExpression.cpp +++ b/ets2panda/ir/ets/etsNewClassInstanceExpression.cpp @@ -15,10 +15,6 @@ #include "etsNewClassInstanceExpression.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "checker/TSchecker.h" - namespace ark::es2panda::ir { void ETSNewClassInstanceExpression::TransformChildren(const NodeTransformer &cb, std::string_view transformationName) { @@ -44,55 +40,6 @@ void ETSNewClassInstanceExpression::Iterate([[maybe_unused]] const NodeTraverser } } -void ETSNewClassInstanceExpression::Dump(ir::AstDumper *dumper) const -{ - dumper->Add( - {{"type", "ETSNewClassInstanceExpression"}, {"typeReference", typeReference_}, {"arguments", arguments_}}); -} - -void ETSNewClassInstanceExpression::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add("new "); - if (typeReference_ != nullptr) { - if (typeReference_->IsETSUnionType()) { - dumper->Add("("); - } - typeReference_->Dump(dumper); - if (typeReference_->IsETSUnionType()) { - dumper->Add(")"); - } - } - - dumper->Add("("); - for (auto argument : arguments_) { - argument->Dump(dumper); - if (argument != arguments_.back()) { - dumper->Add(", "); - } - } - dumper->Add(")"); -} - -void ETSNewClassInstanceExpression::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void ETSNewClassInstanceExpression::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *ETSNewClassInstanceExpression::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType ETSNewClassInstanceExpression::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - ETSNewClassInstanceExpression::ETSNewClassInstanceExpression(ETSNewClassInstanceExpression const &other, ArenaAllocator *const allocator) : Expression(static_cast(other)), arguments_(allocator->Adapter()), signature_(other.signature_) @@ -116,9 +63,4 @@ ETSNewClassInstanceExpression *ETSNewClassInstanceExpression::Clone(ArenaAllocat return clone; } -bool ETSNewClassInstanceExpression::TypeIsAllowedForInstantiation(checker::Type *type) -{ - return !(type->IsETSNullType() || type->IsETSUndefinedType() || type->IsETSNeverType() || type->IsETSVoidType()); -} - } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/ets/etsNewClassInstanceExpression.h b/ets2panda/ir/ets/etsNewClassInstanceExpression.h index c8c614ddc86b574ffac581011d9ba0393d6d93a1..66ddf250c17d5c40bf74c0112b4a1a68c4698081 100644 --- a/ets2panda/ir/ets/etsNewClassInstanceExpression.h +++ b/ets2panda/ir/ets/etsNewClassInstanceExpression.h @@ -99,7 +99,6 @@ public: void Compile(compiler::ETSGen *etsg) const override; checker::Type *Check(checker::TSChecker *checker) override; checker::VerifiedType Check(checker::ETSChecker *checker) override; - static bool TypeIsAllowedForInstantiation(checker::Type *type); void Accept(ASTVisitorT *v) override { diff --git a/ets2panda/ir/ets/etsNewMultiDimArrayInstanceExpression.cpp b/ets2panda/ir/ets/etsNewMultiDimArrayInstanceExpression.cpp index 08ff84bcf44bb3e2a1467e8b3333535c251ea215..c89c471a230e32b508a083449e2181d72d5ca356 100644 --- a/ets2panda/ir/ets/etsNewMultiDimArrayInstanceExpression.cpp +++ b/ets2panda/ir/ets/etsNewMultiDimArrayInstanceExpression.cpp @@ -16,9 +16,8 @@ #include "etsNewMultiDimArrayInstanceExpression.h" #include "checker/ets/typeRelationContext.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" +#include "checker/types/ets/etsArrayType.h" +#include "ir/typeNode.h" namespace ark::es2panda::ir { void ETSNewMultiDimArrayInstanceExpression::TransformChildren(const NodeTransformer &cb, @@ -45,44 +44,6 @@ void ETSNewMultiDimArrayInstanceExpression::Iterate(const NodeTraverser &cb) con } } -void ETSNewMultiDimArrayInstanceExpression::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "ETSNewMultiDimArrayInstanceExpression"}, - {"typeReference", typeReference_}, - {"dimensions", dimensions_}}); -} - -void ETSNewMultiDimArrayInstanceExpression::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add("new "); - ES2PANDA_ASSERT(typeReference_); - typeReference_->Dump(dumper); - for (auto dim : dimensions_) { - dumper->Add("["); - dim->Dump(dumper); - dumper->Add("]"); - } -} - -void ETSNewMultiDimArrayInstanceExpression::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} -void ETSNewMultiDimArrayInstanceExpression::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *ETSNewMultiDimArrayInstanceExpression::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType ETSNewMultiDimArrayInstanceExpression::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - void ETSNewMultiDimArrayInstanceExpression::ClearPreferredType() { SetPreferredType(nullptr); diff --git a/ets2panda/ir/ets/etsNonNullishTypeNode.cpp b/ets2panda/ir/ets/etsNonNullishTypeNode.cpp index ba8b6151771babfd04900a5cb947f214d97d6e1a..aab4820b8b65fb55499de50f90fe8481387f22a3 100644 --- a/ets2panda/ir/ets/etsNonNullishTypeNode.cpp +++ b/ets2panda/ir/ets/etsNonNullishTypeNode.cpp @@ -14,7 +14,6 @@ */ #include "etsNonNullishTypeNode.h" -#include "checker/ETSchecker.h" namespace ark::es2panda::ir { void ETSNonNullishTypeNode::TransformChildren([[maybe_unused]] const NodeTransformer &cb, @@ -31,39 +30,6 @@ void ETSNonNullishTypeNode::Iterate([[maybe_unused]] const NodeTraverser &cb) co cb(typeNode_); } -void ETSNonNullishTypeNode::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "ETSNonNullishType"}, {"typeNode", typeNode_}}); -} - -void ETSNonNullishTypeNode::Dump(ir::SrcDumper *dumper) const -{ - DumpAnnotations(dumper); - dumper->Add("NonNullable<"); - typeNode_->Dump(dumper); - dumper->Add(">"); -} - -void ETSNonNullishTypeNode::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - ES2PANDA_UNREACHABLE(); -} - -checker::Type *ETSNonNullishTypeNode::Check([[maybe_unused]] checker::TSChecker *checker) -{ - ES2PANDA_UNREACHABLE(); -} - -checker::VerifiedType ETSNonNullishTypeNode::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - -checker::Type *ETSNonNullishTypeNode::GetType([[maybe_unused]] checker::ETSChecker *checker) -{ - return TsType() != nullptr ? TsType() : Check(checker); -} - ETSNonNullishTypeNode *ETSNonNullishTypeNode::Clone(ArenaAllocator *allocator, AstNode *parent) { TypeNode *typeNode = typeNode_->Clone(allocator, nullptr); diff --git a/ets2panda/ir/ets/etsNullishTypes.cpp b/ets2panda/ir/ets/etsNullishTypes.cpp index a0ebf975b71ebdf75fbdf6c88fcb8231f7622fbe..9418c2b6e29942df2f34a19476dad8cf04ea7e18 100644 --- a/ets2panda/ir/ets/etsNullishTypes.cpp +++ b/ets2panda/ir/ets/etsNullishTypes.cpp @@ -15,8 +15,6 @@ #include "etsNullishTypes.h" -#include "checker/ETSchecker.h" - namespace ark::es2panda::ir { void ETSUndefinedType::TransformChildren([[maybe_unused]] const NodeTransformer &cb, [[maybe_unused]] std::string_view const transformationName) @@ -29,38 +27,6 @@ void ETSUndefinedType::Iterate(const NodeTraverser &cb) const IterateAnnotations(cb); } -void ETSUndefinedType::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "ETSUndefinedType"}, {"annotations", AstDumper::Optional(Annotations())}}); -} - -void ETSUndefinedType::Dump(ir::SrcDumper *dumper) const -{ - DumpAnnotations(dumper); - dumper->Add("undefined"); -} - -void ETSUndefinedType::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - ES2PANDA_UNREACHABLE(); -} - -checker::Type *ETSUndefinedType::Check([[maybe_unused]] checker::TSChecker *checker) -{ - ES2PANDA_UNREACHABLE(); -} - -checker::VerifiedType ETSUndefinedType::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - -checker::Type *ETSUndefinedType::GetType([[maybe_unused]] checker::ETSChecker *checker) -{ - SetTsType(checker->GlobalETSUndefinedType()); - return TsType(); -} - ETSUndefinedType *ETSUndefinedType::Clone(ArenaAllocator *allocator, AstNode *parent) { auto *const clone = allocator->New(allocator); @@ -88,38 +54,6 @@ void ETSNullType::Iterate(const NodeTraverser &cb) const IterateAnnotations(cb); } -void ETSNullType::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "ETSNullType"}, {"annotations", AstDumper::Optional(Annotations())}}); -} - -void ETSNullType::Dump(ir::SrcDumper *dumper) const -{ - DumpAnnotations(dumper); - dumper->Add("null"); -} - -void ETSNullType::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - ES2PANDA_UNREACHABLE(); -} - -checker::Type *ETSNullType::Check([[maybe_unused]] checker::TSChecker *checker) -{ - ES2PANDA_UNREACHABLE(); -} - -checker::VerifiedType ETSNullType::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - -checker::Type *ETSNullType::GetType([[maybe_unused]] checker::ETSChecker *checker) -{ - SetTsType(checker->GlobalETSNullType()); - return TsType(); -} - ETSNullType *ETSNullType::Clone(ArenaAllocator *allocator, AstNode *parent) { auto *const clone = allocator->New(allocator); diff --git a/ets2panda/ir/ets/etsPackageDeclaration.cpp b/ets2panda/ir/ets/etsPackageDeclaration.cpp index fb8fec13f688de7823ffae75086a6d5510008dcc..01df78251e270e3daf72a0ee8a3178a0653a2cfa 100644 --- a/ets2panda/ir/ets/etsPackageDeclaration.cpp +++ b/ets2panda/ir/ets/etsPackageDeclaration.cpp @@ -15,9 +15,7 @@ #include "etsPackageDeclaration.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" +#include "ir/expression.h" namespace ark::es2panda::ir { void ETSPackageDeclaration::TransformChildren(const NodeTransformer &cb, std::string_view const transformationName) @@ -33,41 +31,6 @@ void ETSPackageDeclaration::Iterate([[maybe_unused]] const NodeTraverser &cb) co cb(name_); } -void ETSPackageDeclaration::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "ETSPackageDeclaration"}, {"name", name_}}); -} - -void ETSPackageDeclaration::Dump(ir::SrcDumper *dumper) const -{ - if (dumper->IsDeclgen()) { - return; - } - dumper->Add("package "); - name_->Dump(dumper); - dumper->Add(";"); - dumper->Endl(); -} - -void ETSPackageDeclaration::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} -void ETSPackageDeclaration::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *ETSPackageDeclaration::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType ETSPackageDeclaration::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - ETSPackageDeclaration *ETSPackageDeclaration::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto const name = name_ != nullptr ? name_->Clone(allocator, nullptr)->AsExpression() : nullptr; diff --git a/ets2panda/ir/ets/etsParameterExpression.cpp b/ets2panda/ir/ets/etsParameterExpression.cpp index c0871a9e77f4050c2234dd46a2267bab80ad11ed..0c2a12d684aed6bd086f23a439c29f727354b99e 100644 --- a/ets2panda/ir/ets/etsParameterExpression.cpp +++ b/ets2panda/ir/ets/etsParameterExpression.cpp @@ -15,10 +15,8 @@ #include "etsParameterExpression.h" -#include "checker/ETSchecker.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" +#include "ir/typeNode.h" +#include "ir/base/spreadElement.h" namespace ark::es2panda::ir { @@ -203,78 +201,6 @@ void ETSParameterExpression::Iterate(const NodeTraverser &cb) const IterateAnnotations(cb); } -void ETSParameterExpression::Dump(ir::AstDumper *const dumper) const -{ - if (!IsRestParameter()) { - dumper->Add({{"type", "ETSParameterExpression"}, - {"name", Ident()}, - {"initializer", AstDumper::Optional(Initializer())}, - {"annotations", AstDumper::Optional(Annotations())}}); - } else { - dumper->Add({{"type", "ETSParameterExpression"}, - {"rest parameter", Spread()}, - {"annotations", AstDumper::Optional(Annotations())}}); - } -} - -void ETSParameterExpression::Dump(ir::SrcDumper *const dumper) const -{ - DumpAnnotations(dumper); - - if (IsRestParameter()) { - Spread()->Dump(dumper); - } else { - ETSParameterExpression const *node = this; - // NOTE (DZ): temporary solution until node history starts working properly - if (dumper->IsDeclgen() && OriginalNode() != nullptr) { - node = OriginalNode()->AsETSParameterExpression(); - } - - auto const ident = node->Ident(); - ES2PANDA_ASSERT(ident != nullptr); - auto const initializer = node->Initializer(); - - ident->Dump(dumper); - if (node->IsOptional() && initializer == nullptr) { - dumper->Add("?"); - } - - auto typeAnnotation = ident->AsAnnotatedExpression()->TypeAnnotation(); - if (typeAnnotation != nullptr) { - if (dumper->IsDeclgen() && typeAnnotation->OriginalNode() != nullptr) { - typeAnnotation = typeAnnotation->OriginalNode()->AsExpression()->AsTypeNode(); - } - dumper->Add(": "); - typeAnnotation->Dump(dumper); - } - - if (initializer != nullptr) { - dumper->Add(" = "); - initializer->Dump(dumper); - } - } -} - -void ETSParameterExpression::Compile(compiler::PandaGen *const pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void ETSParameterExpression::Compile(compiler::ETSGen *const etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *ETSParameterExpression::Check(checker::TSChecker *const checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType ETSParameterExpression::Check(checker::ETSChecker *const checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - ETSParameterExpression *ETSParameterExpression::Clone(ArenaAllocator *const allocator, AstNode *const parent) { AnnotatedExpression *identOrSpread = nullptr; diff --git a/ets2panda/ir/ets/etsPrimitiveType.cpp b/ets2panda/ir/ets/etsPrimitiveType.cpp index 69661b129d8fecc36258d0614b23772f7162ed7e..9266451a89a7a4a70dfe26fe3002d050166e0fa2 100644 --- a/ets2panda/ir/ets/etsPrimitiveType.cpp +++ b/ets2panda/ir/ets/etsPrimitiveType.cpp @@ -15,11 +15,6 @@ #include "etsPrimitiveType.h" -#include "checker/TSchecker.h" -#include "checker/ETSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" - namespace ark::es2panda::ir { void ETSPrimitiveType::TransformChildren([[maybe_unused]] const NodeTransformer &cb, [[maybe_unused]] std::string_view const transformationName) @@ -32,122 +27,6 @@ void ETSPrimitiveType::Iterate(const NodeTraverser &cb) const IterateAnnotations(cb); } -void ETSPrimitiveType::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "ETSPrimitiveType"}, {"annotations", AstDumper::Optional(Annotations())}}); -} - -void ETSPrimitiveType::Dump(ir::SrcDumper *dumper) const -{ - DumpAnnotations(dumper); - - switch (GetPrimitiveType()) { - case PrimitiveType::BYTE: - dumper->Add("byte"); - break; - case PrimitiveType::INT: - dumper->Add("int"); - break; - case PrimitiveType::LONG: - dumper->Add("long"); - break; - case PrimitiveType::SHORT: - dumper->Add("short"); - break; - case PrimitiveType::FLOAT: - dumper->Add("float"); - break; - case PrimitiveType::DOUBLE: - dumper->Add("double"); - break; - case PrimitiveType::BOOLEAN: - dumper->Add("boolean"); - break; - case PrimitiveType::CHAR: - dumper->Add("char"); - break; - case PrimitiveType::VOID: - dumper->Add("void"); - break; - default: - ES2PANDA_UNREACHABLE(); - } -} - -void ETSPrimitiveType::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void ETSPrimitiveType::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *ETSPrimitiveType::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::Type *ETSPrimitiveType::GetType([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GlobalAnyType(); -} - -checker::VerifiedType ETSPrimitiveType::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - -checker::Type *ETSPrimitiveType::GetType([[maybe_unused]] checker::ETSChecker *checker) -{ - switch (GetPrimitiveType()) { - case PrimitiveType::BYTE: { - SetTsType(checker->GlobalByteBuiltinType()); - return TsType(); - } - case PrimitiveType::SHORT: { - SetTsType(checker->GlobalShortBuiltinType()); - return TsType(); - } - case PrimitiveType::INT: { - SetTsType(checker->GlobalIntBuiltinType()); - return TsType(); - } - case PrimitiveType::LONG: { - SetTsType(checker->GlobalLongBuiltinType()); - return TsType(); - } - case PrimitiveType::FLOAT: { - SetTsType(checker->GlobalFloatBuiltinType()); - return TsType(); - } - case PrimitiveType::DOUBLE: { - SetTsType(checker->GlobalDoubleBuiltinType()); - return TsType(); - } - case PrimitiveType::BOOLEAN: { - SetTsType(checker->GlobalETSBooleanBuiltinType()); - return TsType(); - } - case PrimitiveType::CHAR: { - SetTsType(checker->GlobalCharBuiltinType()); - return TsType(); - } - case PrimitiveType::VOID: { - if (LIKELY(checker->CheckVoidAnnotation(this))) { - SetTsType(checker->GlobalVoidType()); - return TsType(); - } - - return checker->InvalidateType(this); - } - default: { - ES2PANDA_UNREACHABLE(); - } - } -} - ETSPrimitiveType *ETSPrimitiveType::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto *const clone = allocator->New(GetPrimitiveType(), allocator); diff --git a/ets2panda/ir/ets/etsReExportDeclaration.cpp b/ets2panda/ir/ets/etsReExportDeclaration.cpp index 4475c8b08ca38e60ee149065501f58154901a988..e09d64139771cf7140771d05d0c039dc1a143567 100644 --- a/ets2panda/ir/ets/etsReExportDeclaration.cpp +++ b/ets2panda/ir/ets/etsReExportDeclaration.cpp @@ -14,7 +14,7 @@ */ #include "ir/ets/etsReExportDeclaration.h" -#include "ir/astDump.h" + #include "checker/checker.h" namespace ark::es2panda::ir { @@ -55,36 +55,6 @@ void ETSReExportDeclaration::Iterate(const NodeTraverser &cb) const GetETSImportDeclarations()->Iterate(cb); } -void ETSReExportDeclaration::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "ETSReExportDeclaration"}, {"ets_import_declarations", GetETSImportDeclarations()}}); -} - -void ETSReExportDeclaration::Dump([[maybe_unused]] ir::SrcDumper *dumper) const -{ - auto importDeclaration = GetETSImportDeclarations(); - const auto &specifiers = importDeclaration->Specifiers(); - dumper->Add("export "); - if (specifiers.size() == 1 && - (specifiers[0]->IsImportNamespaceSpecifier() || specifiers[0]->IsImportDefaultSpecifier())) { - specifiers[0]->Dump(dumper); - } else { - dumper->Add("{ "); - for (auto specifier : specifiers) { - specifier->Dump(dumper); - if (specifier != specifiers.back()) { - dumper->Add(", "); - } - } - dumper->Add(" }"); - } - - dumper->Add(" from "); - importDeclaration->Source()->Dump(dumper); - dumper->Add(";"); - dumper->Endl(); -} - checker::VerifiedType ETSReExportDeclaration::Check(checker::ETSChecker * /*checker*/) { return {this, nullptr}; diff --git a/ets2panda/ir/ets/etsStringLiteralType.cpp b/ets2panda/ir/ets/etsStringLiteralType.cpp index cff8978020f823e0bf68623c60a29ffd726471bc..edf5e5b5171aaf6b9f74ad69991a2932dba5abc8 100644 --- a/ets2panda/ir/ets/etsStringLiteralType.cpp +++ b/ets2panda/ir/ets/etsStringLiteralType.cpp @@ -15,7 +15,7 @@ #include "etsStringLiteralType.h" -#include "checker/ETSchecker.h" +#include "checker/types/ets/etsStringType.h" namespace ark::es2panda::ir { void ETSStringLiteralType::TransformChildren([[maybe_unused]] const NodeTransformer &cb, @@ -29,39 +29,6 @@ void ETSStringLiteralType::Iterate(const NodeTraverser &cb) const IterateAnnotations(cb); } -void ETSStringLiteralType::Dump(ir::AstDumper *dumper) const -{ - dumper->Add( - {{"type", "ETSStringLiteralType"}, {"value", value_}, {"annotations", AstDumper::Optional(Annotations())}}); -} - -void ETSStringLiteralType::Dump(ir::SrcDumper *dumper) const -{ - DumpAnnotations(dumper); - dumper->Add("\"" + value_.Mutf8() + "\""); -} - -void ETSStringLiteralType::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - ES2PANDA_UNREACHABLE(); -} - -checker::Type *ETSStringLiteralType::Check([[maybe_unused]] checker::TSChecker *checker) -{ - ES2PANDA_UNREACHABLE(); -} - -checker::VerifiedType ETSStringLiteralType::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - -checker::Type *ETSStringLiteralType::GetType([[maybe_unused]] checker::ETSChecker *checker) -{ - SetTsType(checker->CreateETSStringLiteralType(value_)); - return TsType(); -} - ETSStringLiteralType *ETSStringLiteralType::Clone(ArenaAllocator *allocator, AstNode *parent) { auto *const clone = allocator->New(value_, allocator); diff --git a/ets2panda/ir/ets/etsStructDeclaration.cpp b/ets2panda/ir/ets/etsStructDeclaration.cpp index efad97ab17ae51df4b10c55a2ff703452519015a..eeae40eefc361e548f7a7d6130e622b1cc3656fd 100644 --- a/ets2panda/ir/ets/etsStructDeclaration.cpp +++ b/ets2panda/ir/ets/etsStructDeclaration.cpp @@ -15,31 +15,8 @@ #include "etsStructDeclaration.h" -#include "checker/TSchecker.h" -#include "compiler/core/pandagen.h" -#include "compiler/core/ETSGen.h" +#include "ir/base/classDefinition.h" namespace ark::es2panda::ir { -void ETSStructDeclaration::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "ETSStructDeclaration"}, {"definition", Definition()}}); -} -void ETSStructDeclaration::Dump(ir::SrcDumper *dumper) const -{ - if (Definition() != nullptr) { - Definition()->Dump(dumper); - } -} - -checker::Type *ETSStructDeclaration::Check([[maybe_unused]] checker::TSChecker *checker) -{ - ES2PANDA_UNREACHABLE(); -} - -checker::VerifiedType ETSStructDeclaration::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - ES2PANDA_ASSERT(checker->IsAnyError()); - return {this, checker->GetAnalyzer()->Check(this)}; -} } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/ets/etsTuple.cpp b/ets2panda/ir/ets/etsTuple.cpp index 3012e89b118d2c08d04028b9c9ba06f00ce84d7d..45b89da743441f93521bba1f2362e2ea755a472a 100644 --- a/ets2panda/ir/ets/etsTuple.cpp +++ b/ets2panda/ir/ets/etsTuple.cpp @@ -15,8 +15,8 @@ #include "etsTuple.h" -#include "checker/ETSchecker.h" #include "checker/types/ets/etsTupleType.h" +#include "checker/types/ets/etsObjectType.h" namespace ark::es2panda::ir { @@ -41,26 +41,6 @@ void ETSTuple::Iterate(const NodeTraverser &cb) const IterateAnnotations(cb); } -void ETSTuple::Dump(ir::AstDumper *const dumper) const -{ - dumper->Add({{"type", "ETSTuple"}, - {"types", AstDumper::Optional(typeAnnotationList_)}, - {"annotations", AstDumper::Optional(Annotations())}}); -} - -void ETSTuple::Dump(ir::SrcDumper *const dumper) const -{ - DumpAnnotations(dumper); - dumper->Add("["); - for (const auto *const typeAnnot : typeAnnotationList_) { - typeAnnot->Dump(dumper); - if (typeAnnot != typeAnnotationList_.back()) { - dumper->Add(", "); - } - } - dumper->Add("]"); -} - void ETSTuple::Compile([[maybe_unused]] compiler::PandaGen *const pg) const {} void ETSTuple::Compile([[maybe_unused]] compiler::ETSGen *const etsg) const {} diff --git a/ets2panda/ir/ets/etsTuple.h b/ets2panda/ir/ets/etsTuple.h index 6039a546e5eaea6cefb1fdb7ebbe710ce2f24c40..a84b34be6bda58293c90c86c1dec85717fb91b92 100644 --- a/ets2panda/ir/ets/etsTuple.h +++ b/ets2panda/ir/ets/etsTuple.h @@ -16,7 +16,6 @@ #ifndef ES2PANDA_IR_ETS_TUPLE_H #define ES2PANDA_IR_ETS_TUPLE_H -#include "checker/ETSchecker.h" #include "ir/typeNode.h" namespace ark::es2panda::ir { diff --git a/ets2panda/ir/ets/etsTypeReference.cpp b/ets2panda/ir/ets/etsTypeReference.cpp index dc213924fba70e2a3af09fa5a49baae1f6fbc510..e9ca2e4ab45d5dd84f578f67da483c7200b03fd5 100644 --- a/ets2panda/ir/ets/etsTypeReference.cpp +++ b/ets2panda/ir/ets/etsTypeReference.cpp @@ -15,10 +15,11 @@ #include "etsTypeReference.h" -#include "checker/ETSchecker.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" +#include "checker/types/ets/etsObjectType.h" + +#include "ir/expressions/memberExpression.h" +#include "ir/ets/etsTypeReferencePart.h" +#include "ir/ts/tsQualifiedName.h" namespace ark::es2panda::ir { @@ -99,48 +100,6 @@ ir::Identifier *ETSTypeReference::BaseName() const return nullptr; } -void ETSTypeReference::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "ETSTypeReference"}, {"part", Part()}, {"annotations", AstDumper::Optional(Annotations())}}); -} - -void ETSTypeReference::Dump(ir::SrcDumper *dumper) const -{ - DumpAnnotations(dumper); - ES2PANDA_ASSERT(Part() != nullptr); - Part()->Dump(dumper); -} - -void ETSTypeReference::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} -void ETSTypeReference::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *ETSTypeReference::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType ETSTypeReference::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} -checker::Type *ETSTypeReference::GetType(checker::ETSChecker *checker) -{ - if (TsType() != nullptr) { - return TsType(); - } - auto *type = Part()->GetType(checker); - if (IsReadonlyType()) { - type = checker->GetReadonlyType(type); - } - return SetTsType(type); -} - ETSTypeReference *ETSTypeReference::Clone(ArenaAllocator *const allocator, AstNode *const parent) { ETSTypeReferencePart *partClone = nullptr; diff --git a/ets2panda/ir/ets/etsTypeReferencePart.cpp b/ets2panda/ir/ets/etsTypeReferencePart.cpp index 0c0ba03bf0c70adf557f798ec5730076bc938437..751abaa9b5d5b78335386c3462d66202cab65d5e 100644 --- a/ets2panda/ir/ets/etsTypeReferencePart.cpp +++ b/ets2panda/ir/ets/etsTypeReferencePart.cpp @@ -15,11 +15,14 @@ #include "etsTypeReferencePart.h" -#include "checker/ETSchecker.h" #include "checker/ets/typeRelationContext.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" +#include "checker/types/ets/etsArrayType.h" + +#include "ir/ets/etsTypeReference.h" + +#include "ir/ts/tsQualifiedName.h" +#include "ir/ts/tsTypeAliasDeclaration.h" +#include "ir/ts/tsTypeParameterInstantiation.h" namespace ark::es2panda::ir { @@ -81,42 +84,6 @@ void ETSTypeReferencePart::Iterate(const NodeTraverser &cb) const } } -void ETSTypeReferencePart::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "ETSTypeReferencePart"}, - {"name", Name()}, - {"typeParams", AstDumper::Optional(TypeParams())}, - {"previous", AstDumper::Optional(Previous())}}); -} - -void ETSTypeReferencePart::Dump(ir::SrcDumper *dumper) const -{ - ES2PANDA_ASSERT(Name() != nullptr); - Name()->Dump(dumper); - if (TypeParams() != nullptr) { - TypeParams()->Dump(dumper); - } -} - -void ETSTypeReferencePart::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} -void ETSTypeReferencePart::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *ETSTypeReferencePart::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType ETSTypeReferencePart::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - static checker::Type *HandleFixedArrayType(checker::ETSChecker *const checker, ETSTypeReferencePart *ref) { auto typeParams = ref->TypeParams(); diff --git a/ets2panda/ir/ets/etsUnionType.cpp b/ets2panda/ir/ets/etsUnionType.cpp index 95f556c907df88cfa9b063707c7bbe3c9c27747d..072040bfff43e28848f1c0116d81ca9fd9358f25 100644 --- a/ets2panda/ir/ets/etsUnionType.cpp +++ b/ets2panda/ir/ets/etsUnionType.cpp @@ -15,7 +15,7 @@ #include "etsUnionType.h" -#include "checker/ETSchecker.h" +#include "checker/types/ets/etsTypeParameter.h" namespace ark::es2panda::ir { void ETSUnionType::TransformChildren(const NodeTransformer &cb, std::string_view const transformationName) @@ -40,73 +40,6 @@ void ETSUnionType::Iterate(const NodeTraverser &cb) const IterateAnnotations(cb); } -void ETSUnionType::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "ETSUnionType"}, {"types", Types()}, {"annotations", AstDumper::Optional(Annotations())}}); -} - -void ETSUnionType::Dump(ir::SrcDumper *dumper) const -{ - DumpAnnotations(dumper); - dumper->Add("("); - for (auto type : Types()) { - type->Dump(dumper); - if (type != Types().back()) { - dumper->Add(" | "); - } - } - dumper->Add(")"); -} - -void ETSUnionType::Compile([[maybe_unused]] compiler::PandaGen *pg) const {} - -checker::Type *ETSUnionType::Check([[maybe_unused]] checker::TSChecker *checker) -{ - return nullptr; -} - -checker::VerifiedType ETSUnionType::Check(checker::ETSChecker *checker) -{ - for (auto *it : Types()) { - it->Check(checker); - } - - return {this, GetType(checker)}; -} - -static bool CheckConstituentTypesValid(ArenaVector const &constituentTypes) -{ - for (auto &it : constituentTypes) { - if (it->IsTypeError()) { - return false; - } - } - return true; -} - -checker::Type *ETSUnionType::GetType(checker::ETSChecker *checker) -{ - if (TsType() != nullptr) { - return TsType(); - } - checker->CheckAnnotations(this); - - ArenaVector types(checker->Allocator()->Adapter()); - - for (auto *it : Types()) { - types.push_back(it->GetType(checker)); - } - - checker->Relation()->SetNode(this); - if (!CheckConstituentTypesValid(types)) { - SetTsType(checker->GlobalTypeError()); - } else { - SetTsType(checker->CreateETSUnionType(std::move(types))); - } - checker->Relation()->SetNode(nullptr); - return TsType(); -} - ETSUnionType *ETSUnionType::Clone(ArenaAllocator *const allocator, AstNode *const parent) { ArenaVector types(allocator->Adapter()); diff --git a/ets2panda/ir/ets/etsWildcardType.cpp b/ets2panda/ir/ets/etsWildcardType.cpp index e021bd39b40d02bd0780a6f1e295d33cd9c56af3..17601b6b30d9448c757a8b092a7c36a029cfd9fa 100644 --- a/ets2panda/ir/ets/etsWildcardType.cpp +++ b/ets2panda/ir/ets/etsWildcardType.cpp @@ -15,12 +15,6 @@ #include "etsWildcardType.h" -#include "checker/ETSchecker.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" #include "ir/ets/etsTypeReference.h" namespace ark::es2panda::ir { @@ -43,48 +37,4 @@ void ETSWildcardType::Iterate(const NodeTraverser &cb) const } } -void ETSWildcardType::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "ETSWildcardType"}, - {"typeReference", AstDumper::Optional(typeReference_)}, - {"in", AstDumper::Optional(IsIn())}, - {"out", AstDumper::Optional(IsOut())}, - {"annotations", AstDumper::Optional(Annotations())}}); -} - -void ETSWildcardType::Dump(ir::SrcDumper *dumper) const -{ - DumpAnnotations(dumper); - dumper->Add("ETSWildcardType"); -} - -void ETSWildcardType::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void ETSWildcardType::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *ETSWildcardType::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::Type *ETSWildcardType::GetType([[maybe_unused]] checker::TSChecker *checker) -{ - return nullptr; -} - -checker::VerifiedType ETSWildcardType::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - -checker::Type *ETSWildcardType::GetType([[maybe_unused]] checker::ETSChecker *checker) -{ - return checker->GlobalWildcardType(); -} } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/ets/etsWildcardType.h b/ets2panda/ir/ets/etsWildcardType.h index d97e155308457adae50a52caf60d728b24a3e15d..f026b00158ac4c1c1748e940367df27d4a13196d 100644 --- a/ets2panda/ir/ets/etsWildcardType.h +++ b/ets2panda/ir/ets/etsWildcardType.h @@ -46,7 +46,6 @@ public: void Compile(compiler::PandaGen *pg) const override; void Compile(compiler::ETSGen *etsg) const override; checker::Type *Check(checker::TSChecker *checker) override; - checker::Type *GetType([[maybe_unused]] checker::TSChecker *checker) override; checker::VerifiedType Check(checker::ETSChecker *checker) override; checker::Type *GetType([[maybe_unused]] checker::ETSChecker *checker) override; diff --git a/ets2panda/ir/expressions/arrayExpression.cpp b/ets2panda/ir/expressions/arrayExpression.cpp index baa2a6f67fbab1cc94f823dbaef856971a5aad18..b1b9590c41edc04ead8cb58f70db1b7ae1fe7d9f 100644 --- a/ets2panda/ir/expressions/arrayExpression.cpp +++ b/ets2panda/ir/expressions/arrayExpression.cpp @@ -16,13 +16,18 @@ #include "arrayExpression.h" #include -#include "checker/ETSchecker.h" -#include "checker/TSchecker.h" #include "checker/ets/typeRelationContext.h" #include "checker/ts/destructuringContext.h" #include "checker/types/ets/etsTupleType.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" +#include "checker/types/ets/etsUnionType.h" +#include "checker/types/ets/etsResizableArrayType.h" + +#include "ir/typeNode.h" +#include "ir/base/spreadElement.h" +#include "ir/expressions/assignmentExpression.h" +#include "ir/expressions/objectExpression.h" + +#include "varbinder/variable.h" namespace ark::es2panda::ir { ArrayExpression::ArrayExpression([[maybe_unused]] Tag const tag, ArrayExpression const &other, @@ -129,41 +134,6 @@ void ArrayExpression::Iterate(const NodeTraverser &cb) const } } -void ArrayExpression::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", type_ == AstNodeType::ARRAY_EXPRESSION ? "ArrayExpression" : "ArrayPattern"}, - {"elements", elements_}, - {"typeAnnotation", AstDumper::Optional(TypeAnnotation())}, - {"optional", AstDumper::Optional(optional_)}}); -} - -void ArrayExpression::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add("["); - for (auto element : elements_) { - element->Dump(dumper); - if (element != elements_.back()) { - dumper->Add(", "); - } - } - dumper->Add("]"); -} - -void ArrayExpression::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void ArrayExpression::Compile(compiler::ETSGen *const etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *ArrayExpression::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - checker::Type *CheckAssignmentPattern(Expression *it, checker::TSChecker *checker, checker::Type *elementType, bool &addOptional, checker::ElementFlags &memberFlag) { @@ -349,11 +319,6 @@ bool ArrayExpression::TrySetPreferredTypeForNestedArrayExpr(checker::ETSChecker return true; } -checker::VerifiedType ArrayExpression::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - std::optional ArrayExpression::ExtractPossiblePreferredType(checker::Type *type) { ES2PANDA_ASSERT(type); diff --git a/ets2panda/ir/expressions/arrowFunctionExpression.cpp b/ets2panda/ir/expressions/arrowFunctionExpression.cpp index 6a735503ace505d16ebbe7342418210e63642f67..f8c7708fe6fd18906fd077564cca6dc61e14d87d 100644 --- a/ets2panda/ir/expressions/arrowFunctionExpression.cpp +++ b/ets2panda/ir/expressions/arrowFunctionExpression.cpp @@ -15,10 +15,8 @@ #include "arrowFunctionExpression.h" -#include "compiler/core/pandagen.h" -#include "compiler/core/ETSGen.h" -#include "checker/ETSchecker.h" -#include "checker/TSchecker.h" +#include "ir/base/scriptFunction.h" +#include "ir/expressions/functionExpression.h" namespace ark::es2panda::ir { void ArrowFunctionExpression::TransformChildren(const NodeTransformer &cb, std::string_view const transformationName) @@ -38,44 +36,6 @@ void ArrowFunctionExpression::Iterate(const NodeTraverser &cb) const IterateAnnotations(cb); } -void ArrowFunctionExpression::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "ArrowFunctionExpression"}, - {"function", func_}, - {"annotations", AstDumper::Optional(Annotations())}}); -} - -void ArrowFunctionExpression::Dump(ir::SrcDumper *dumper) const -{ - DumpAnnotations(dumper); - dumper->Add("("); - if (func_->IsScriptFunction() && func_->AsScriptFunction()->IsAsyncFunc()) { - dumper->Add("async "); - } - func_->Dump(dumper); - dumper->Add(")"); -} - -void ArrowFunctionExpression::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void ArrowFunctionExpression::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *ArrowFunctionExpression::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType ArrowFunctionExpression::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - ArrowFunctionExpression::ArrowFunctionExpression(ArrowFunctionExpression const &other, ArenaAllocator *const allocator) : AnnotationAllowed(static_cast(other), allocator) { @@ -100,54 +60,6 @@ ArrowFunctionExpression *ArrowFunctionExpression::Clone(ArenaAllocator *const al return clone; } -ir::TypeNode *ArrowFunctionExpression::CreateReturnNodeFromType(checker::ETSChecker *checker, checker::Type *returnType) -{ - /* - Construct a synthetic Node with the correct ts_type_. - */ - ES2PANDA_ASSERT(returnType != nullptr); - auto *ident = checker->AllocNode(util::StringView(""), checker->Allocator()); - auto *const part = checker->AllocNode(ident, checker->Allocator()); - auto *returnNode = checker->AllocNode(part, checker->Allocator()); - ES2PANDA_ASSERT(returnNode); - returnNode->SetTsType(returnType); - return returnNode; -} - -ir::TypeNode *ArrowFunctionExpression::CreateTypeAnnotation(checker::ETSChecker *checker) -{ - ir::TypeNode *returnNode = nullptr; - /* - There are two scenarios for lambda type inference: defined or undefined return type. - example code: - ``` - enum Color { Red, Blue} - // has Return Type Color - let x = () : Color => {return Color.Red} - // No Return Type Color - let y = () => {return Color.Red} - ``` - */ - if (Function()->ReturnTypeAnnotation() == nullptr) { - /* - When lambda expression does not declare a return type, we need to construct the - declaration node of lambda according to the Function()->Signature()->ReturnType(). - */ - returnNode = CreateReturnNodeFromType(checker, Function()->Signature()->ReturnType()); - } else { - returnNode = Function()->ReturnTypeAnnotation()->Clone(checker->Allocator(), nullptr); - returnNode->SetTsType(Function()->ReturnTypeAnnotation()->TsType()); - } - - ArenaVector params {checker->Allocator()->Adapter()}; - checker->CopyParams(Function()->Params(), params, nullptr); - - auto signature = ir::FunctionSignature(nullptr, std::move(params), returnNode); - auto *funcType = checker->AllocNode(std::move(signature), ir::ScriptFunctionFlags::NONE, - checker->Allocator()); - return funcType; -} - bool ArrowFunctionExpression::IsVarFromSubscope(const varbinder::Variable *var) const { // The parameter scope's and the function scope's common ancestor lives outside the function, so we have to check diff --git a/ets2panda/ir/expressions/arrowFunctionExpression.h b/ets2panda/ir/expressions/arrowFunctionExpression.h index 2550cc7e0dac82d24970f05ef9e826aaa79a199a..0fe50a886bbd48f648fa478ed3551947916df0a7 100644 --- a/ets2panda/ir/expressions/arrowFunctionExpression.h +++ b/ets2panda/ir/expressions/arrowFunctionExpression.h @@ -71,8 +71,7 @@ public: void Compile(compiler::ETSGen *etsg) const override; checker::Type *Check(checker::TSChecker *checker) override; checker::VerifiedType Check(checker::ETSChecker *checker) override; - ir::TypeNode *CreateTypeAnnotation(checker::ETSChecker *checker); - ir::TypeNode *CreateReturnNodeFromType(checker::ETSChecker *checker, checker::Type *returnType); + bool IsVarFromSubscope(const varbinder::Variable *var) const; void Accept(ASTVisitorT *v) override @@ -80,6 +79,18 @@ public: v->Accept(this); } + ir::TypeNode *CreateTypeAnnotation([[maybe_unused]] checker::ETSChecker *checker) + { + // Unused function, to be removed after the bindings problem solved. + ES2PANDA_UNREACHABLE(); + } + ir::TypeNode *CreateReturnNodeFromType([[maybe_unused]] checker::ETSChecker *checker, + [[maybe_unused]] checker::Type *returnType) + { + // Unused function, to be removed after the bindings problem solved. + ES2PANDA_UNREACHABLE(); + } + private: ScriptFunction *func_; checker::Type *preferredType_ {}; diff --git a/ets2panda/ir/expressions/assignmentExpression.cpp b/ets2panda/ir/expressions/assignmentExpression.cpp index 2505910c5f663426231c9b860261e1ff6eb67cf2..2c6124e2d9cb4e4124e01184253f8aebd93bce72 100644 --- a/ets2panda/ir/expressions/assignmentExpression.cpp +++ b/ets2panda/ir/expressions/assignmentExpression.cpp @@ -16,9 +16,10 @@ #include "assignmentExpression.h" #include "compiler/base/lreference.h" -#include "compiler/core/pandagen.h" -#include "compiler/core/ETSGen.h" -#include "checker/TSchecker.h" + +#include "ir/base/spreadElement.h" +#include "ir/expressions/objectExpression.h" +#include "ir/expressions/arrayExpression.h" namespace ark::es2panda::ir { @@ -101,54 +102,6 @@ void AssignmentExpression::Iterate(const NodeTraverser &cb) const cb(right_); } -void AssignmentExpression::Dump(ir::AstDumper *dumper) const -{ - if (type_ == AstNodeType::ASSIGNMENT_EXPRESSION) { - dumper->Add({{"type", "AssignmentExpression"}, {"operator", operator_}, {"left", left_}, {"right", right_}}); - } else { - dumper->Add({{"type", "AssignmentPattern"}, {"left", left_}, {"right", right_}}); - } -} - -void AssignmentExpression::Dump(ir::SrcDumper *dumper) const -{ - ES2PANDA_ASSERT(left_); - left_->Dump(dumper); - dumper->Add(" "); - dumper->Add(TokenToString(operator_)); - dumper->Add(" "); - ES2PANDA_ASSERT(right_); - right_->Dump(dumper); -} - -void AssignmentExpression::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void AssignmentExpression::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -void AssignmentExpression::CompilePattern(compiler::PandaGen *pg) const -{ - compiler::RegScope rs(pg); - auto lref = compiler::JSLReference::Create(pg, left_, false); - right_->Compile(pg); - lref.SetValue(); -} - -checker::Type *AssignmentExpression::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType AssignmentExpression::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - AssignmentExpression::AssignmentExpression([[maybe_unused]] Tag const tag, AssignmentExpression const &other, Expression *const left, Expression *const right) : AssignmentExpression(other) diff --git a/ets2panda/ir/expressions/assignmentExpression.h b/ets2panda/ir/expressions/assignmentExpression.h index 614ea5d8f69b5df148d1176441b08b01ba409655..df565b8a6a3723b18f6c163622488b8fe1bfe9cb 100644 --- a/ets2panda/ir/expressions/assignmentExpression.h +++ b/ets2panda/ir/expressions/assignmentExpression.h @@ -154,7 +154,6 @@ public: void Dump(ir::SrcDumper *dumper) const override; void Compile(compiler::PandaGen *pg) const override; void Compile(compiler::ETSGen *etsg) const override; - void CompilePattern(compiler::PandaGen *pg) const; checker::Type *Check([[maybe_unused]] checker::TSChecker *checker) override; checker::VerifiedType Check([[maybe_unused]] checker::ETSChecker *checker) override; diff --git a/ets2panda/ir/expressions/awaitExpression.cpp b/ets2panda/ir/expressions/awaitExpression.cpp index d9e6b54668008d143b2a88f3adfde348c52e06dd..419db2492c336d610a81c2a5329d94de1060597a 100644 --- a/ets2panda/ir/expressions/awaitExpression.cpp +++ b/ets2panda/ir/expressions/awaitExpression.cpp @@ -15,10 +15,6 @@ #include "awaitExpression.h" -#include "checker/TSchecker.h" -#include "compiler/core/pandagen.h" -#include "compiler/core/ETSGen.h" - namespace ark::es2panda::ir { void AwaitExpression::TransformChildren(const NodeTransformer &cb, std::string_view transformationName) { @@ -37,39 +33,6 @@ void AwaitExpression::Iterate(const NodeTraverser &cb) const } } -void AwaitExpression::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "AwaitExpression"}, {"argument", AstDumper::Nullish(argument_)}}); -} - -void AwaitExpression::Dump(ir::SrcDumper *dumper) const -{ - if (argument_ != nullptr) { - dumper->Add("await "); - argument_->Dump(dumper); - } -} - -void AwaitExpression::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void AwaitExpression::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *AwaitExpression::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType AwaitExpression::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - AwaitExpression *AwaitExpression::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto *const argument = argument_ != nullptr ? argument_->Clone(allocator, nullptr)->AsExpression() : nullptr; diff --git a/ets2panda/ir/expressions/binaryExpression.cpp b/ets2panda/ir/expressions/binaryExpression.cpp index b7de84484e0bdec1096887ee85f98a272f731918..9074020e198950207b454e8997833c324e89bd15 100644 --- a/ets2panda/ir/expressions/binaryExpression.cpp +++ b/ets2panda/ir/expressions/binaryExpression.cpp @@ -15,10 +15,6 @@ #include "binaryExpression.h" -#include "compiler/core/pandagen.h" -#include "compiler/core/ETSGen.h" -#include "checker/TSchecker.h" - namespace ark::es2panda::ir { void BinaryExpression::TransformChildren(const NodeTransformer &cb, std::string_view const transformationName) { @@ -39,61 +35,6 @@ void BinaryExpression::Iterate(const NodeTraverser &cb) const cb(right_); } -void BinaryExpression::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", IsLogical() ? "LogicalExpression" : "BinaryExpression"}, - {"operator", operator_}, - {"left", left_}, - {"right", right_}}); -} - -void BinaryExpression::Dump(ir::SrcDumper *dumper) const -{ - ES2PANDA_ASSERT(left_ != nullptr); - ES2PANDA_ASSERT(right_ != nullptr); - dumper->Add("(("); - left_->Dump(dumper); - dumper->Add(") "); - dumper->Add(TokenToString(operator_)); - dumper->Add(" ("); - right_->Dump(dumper); - dumper->Add("))"); -} - -void BinaryExpression::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void BinaryExpression::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -void BinaryExpression::CompileOperands(compiler::ETSGen *etsg, compiler::VReg lhs) const -{ - left_->Compile(etsg); - - if (operator_ == lexer::TokenType::KEYW_INSTANCEOF) { - etsg->StoreAccumulator(left_, lhs); - } else { - etsg->ApplyConversionAndStoreAccumulator(left_, lhs, operationType_); - } - - right_->Compile(etsg); - etsg->ApplyConversion(right_, operationType_); -} - -checker::Type *BinaryExpression::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType BinaryExpression::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - BinaryExpression *BinaryExpression::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto *const left = left_ != nullptr ? left_->Clone(allocator, nullptr)->AsExpression() : nullptr; diff --git a/ets2panda/ir/expressions/blockExpression.cpp b/ets2panda/ir/expressions/blockExpression.cpp index 853f4973fc05b72ead4e21d302bcbce5a85f5bc8..7d511f7e6eaf9dc4d0d4635835c312248263adea 100644 --- a/ets2panda/ir/expressions/blockExpression.cpp +++ b/ets2panda/ir/expressions/blockExpression.cpp @@ -15,9 +15,6 @@ #include "blockExpression.h" -#include "compiler/core/ETSGen.h" -#include "checker/ETSchecker.h" - namespace ark::es2panda::ir { BlockExpression::BlockExpression(ArenaVector &&statements) @@ -65,40 +62,4 @@ void BlockExpression::Iterate(const NodeTraverser &cb) const } } -void BlockExpression::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "BlockExpression"}, {"statements", statements_}}); -} - -void BlockExpression::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add("({"); - for (auto *statement : statements_) { - statement->Dump(dumper); - if (statement != statements_.back()) { - dumper->Endl(); - } - } - dumper->Add("})"); -} - -void BlockExpression::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - ES2PANDA_UNREACHABLE(); -} - -void BlockExpression::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *BlockExpression::Check([[maybe_unused]] checker::TSChecker *checker) -{ - ES2PANDA_UNREACHABLE(); -} - -checker::VerifiedType BlockExpression::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/expressions/callExpression.cpp b/ets2panda/ir/expressions/callExpression.cpp index 51a4a751d18c87986f245ca0095bfda1015b4edf..4d51090a894389bd3feb9ee7cc6b03f860822d0a 100644 --- a/ets2panda/ir/expressions/callExpression.cpp +++ b/ets2panda/ir/expressions/callExpression.cpp @@ -15,9 +15,11 @@ #include "callExpression.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" +#include "ir/expressions/memberExpression.h" +#include "ir/expressions/functionExpression.h" +#include "ir/statements/blockStatement.h" + +#include "ir/ts/tsTypeParameterInstantiation.h" namespace ark::es2panda::ir { void CallExpression::SetArguments(ArenaVector &&argumentsList) @@ -76,64 +78,6 @@ void CallExpression::Iterate(const NodeTraverser &cb) const } } -void CallExpression::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "CallExpression"}, - {"callee", callee_}, - {"arguments", arguments_}, - {"optional", IsOptional()}, - {"typeParameters", AstDumper::Optional(typeParams_)}}); - // #22953: trailing block is not handled -} - -void CallExpression::Dump(ir::SrcDumper *dumper) const -{ - ES2PANDA_ASSERT(callee_); - callee_->Dump(dumper); - if (IsOptional()) { - dumper->Add("?."); - } - - if (typeParams_ != nullptr) { - typeParams_->Dump(dumper); - } - - dumper->Add("("); - for (auto arg : arguments_) { - arg->Dump(dumper); - if (arg != arguments_.back()) { - dumper->Add(", "); - } - } - dumper->Add(")"); - if (trailingLambdaInfo_.block != nullptr) { - if (trailingLambdaInfo_.isBlockInNewLine) { - dumper->Endl(); - } - trailingLambdaInfo_.block->Dump(dumper); - } -} - -void CallExpression::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void CallExpression::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *CallExpression::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType CallExpression::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - CallExpression::CallExpression(CallExpression const &other, ArenaAllocator *const allocator) : MaybeOptionalExpression(static_cast(other)), arguments_(allocator->Adapter()), diff --git a/ets2panda/ir/expressions/chainExpression.cpp b/ets2panda/ir/expressions/chainExpression.cpp index 8407013cb3c357ce210e68af58575ea182e3d04b..486890ebd7a26bd86d2011b881e8d402fd32fcae 100644 --- a/ets2panda/ir/expressions/chainExpression.cpp +++ b/ets2panda/ir/expressions/chainExpression.cpp @@ -15,10 +15,6 @@ #include "chainExpression.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" - namespace ark::es2panda::ir { void ChainExpression::TransformChildren(const NodeTransformer &cb, std::string_view transformationName) { @@ -33,51 +29,6 @@ void ChainExpression::Iterate(const NodeTraverser &cb) const cb(expression_); } -void ChainExpression::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "ChainExpression"}, {"expression", expression_}}); -} - -void ChainExpression::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add("("); // affects precedence - expression_->Dump(dumper); - dumper->Add(")"); -} - -void ChainExpression::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void ChainExpression::CompileToReg(compiler::PandaGen *pg, compiler::VReg &objReg) const -{ - compiler::OptionalChain chain(pg, this); - - if (expression_->IsMemberExpression()) { - objReg = pg->AllocReg(); - expression_->AsMemberExpression()->CompileToReg(pg, objReg); - } else { - objReg = compiler::VReg::Invalid(); - expression_->Compile(pg); - } -} - -void ChainExpression::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *ChainExpression::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType ChainExpression::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - ChainExpression *ChainExpression::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto *const expression = expression_ != nullptr ? expression_->Clone(allocator, nullptr)->AsExpression() : nullptr; diff --git a/ets2panda/ir/expressions/chainExpression.h b/ets2panda/ir/expressions/chainExpression.h index 4e2ba3bd8834461ee529b4546c8b84fc15e1507e..3f1951d02e7446b8af8a1bb5155052c8e2b94199 100644 --- a/ets2panda/ir/expressions/chainExpression.h +++ b/ets2panda/ir/expressions/chainExpression.h @@ -16,7 +16,8 @@ #ifndef ES2PANDA_IR_EXPRESSION_CHAIN_EXPRESSION_H #define ES2PANDA_IR_EXPRESSION_CHAIN_EXPRESSION_H -#include "ir/expression.h" +#include "compiler/base/optionalChain.h" +#include "ir/expressions/memberExpression.h" #include "ir/irnode.h" namespace ark::es2panda::checker { diff --git a/ets2panda/ir/expressions/classExpression.cpp b/ets2panda/ir/expressions/classExpression.cpp index 36a0f7fa2e70328bc8cb9955ecf1459440b5b35b..6e6d17a2f4f9de455a64b6265e934d5421e4a3a7 100644 --- a/ets2panda/ir/expressions/classExpression.cpp +++ b/ets2panda/ir/expressions/classExpression.cpp @@ -15,9 +15,7 @@ #include "classExpression.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" +#include "ir/base/classDefinition.h" namespace ark::es2panda::ir { void ClassExpression::TransformChildren(const NodeTransformer &cb, std::string_view const transformationName) @@ -33,36 +31,6 @@ void ClassExpression::Iterate(const NodeTraverser &cb) const cb(def_); } -void ClassExpression::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "ClassExpression"}, {"definition", def_}}); -} - -void ClassExpression::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add("ClassExpression"); -} - -void ClassExpression::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void ClassExpression::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *ClassExpression::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType ClassExpression::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - ClassExpression *ClassExpression::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto *const def = def_ != nullptr ? def_->Clone(allocator, nullptr)->AsClassDefinition() : nullptr; diff --git a/ets2panda/ir/expressions/conditionalExpression.cpp b/ets2panda/ir/expressions/conditionalExpression.cpp index e0db6c2ec31acc059641e691bf94534f20e10b32..4aac2d045c51490f071313fdf6eeea8278832e6d 100644 --- a/ets2panda/ir/expressions/conditionalExpression.cpp +++ b/ets2panda/ir/expressions/conditionalExpression.cpp @@ -15,10 +15,6 @@ #include "conditionalExpression.h" -#include "checker/TSchecker.h" -#include "compiler/core/pandagen.h" -#include "compiler/core/ETSGen.h" - namespace ark::es2panda::ir { void ConditionalExpression::TransformChildren(const NodeTransformer &cb, std::string_view transformationName) { @@ -45,52 +41,6 @@ void ConditionalExpression::Iterate(const NodeTraverser &cb) const cb(alternate_); } -void ConditionalExpression::Dump(ir::AstDumper *dumper) const -{ - dumper->Add( - {{"type", "ConditionalExpression"}, {"test", test_}, {"consequent", consequent_}, {"alternate", alternate_}}); -} - -void ConditionalExpression::Dump(ir::SrcDumper *dumper) const -{ - ES2PANDA_ASSERT(test_ != nullptr); - dumper->Add("("); - test_->Dump(dumper); - dumper->Add(" ? "); - if (consequent_ != nullptr) { - consequent_->Dump(dumper); - } - dumper->Add(" : "); - if (alternate_ != nullptr) { - alternate_->Dump(dumper); - } - dumper->Add(")"); - if ((parent_ != nullptr) && (parent_->IsBlockStatement() || parent_->IsBlockExpression())) { - dumper->Add(";"); - dumper->Endl(); - } -} - -void ConditionalExpression::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void ConditionalExpression::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *ConditionalExpression::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType ConditionalExpression::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - ConditionalExpression *ConditionalExpression::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto *const test = test_->Clone(allocator, nullptr)->AsExpression(); diff --git a/ets2panda/ir/expressions/directEvalExpression.cpp b/ets2panda/ir/expressions/directEvalExpression.cpp index d5a7fdb9684013575053cf065d87526927e64bfb..2d402e602a34fe89e2e142c3f7b04738e6c4c419 100644 --- a/ets2panda/ir/expressions/directEvalExpression.cpp +++ b/ets2panda/ir/expressions/directEvalExpression.cpp @@ -17,29 +17,6 @@ #include "directEvalExpression.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" - namespace ark::es2panda::ir { -void DirectEvalExpression::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void DirectEvalExpression::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *DirectEvalExpression::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType DirectEvalExpression::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/expressions/dummyNode.cpp b/ets2panda/ir/expressions/dummyNode.cpp index bf4b171b8f3b7acb2549a0dd8e722d4bfcdc2d9d..f3753291f1070ce561f2e7e2187d9ad27865c2d9 100644 --- a/ets2panda/ir/expressions/dummyNode.cpp +++ b/ets2panda/ir/expressions/dummyNode.cpp @@ -15,12 +15,7 @@ #include "dummyNode.h" -#include "checker/TSchecker.h" -#include "checker/ETSchecker.h" -#include "compiler/core/pandagen.h" -#include "compiler/core/ETSGen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" +#include "ir/typeNode.h" namespace ark::es2panda::ir { void DummyNode::TransformChildren([[maybe_unused]] const NodeTransformer &cb, @@ -30,36 +25,4 @@ void DummyNode::TransformChildren([[maybe_unused]] const NodeTransformer &cb, void DummyNode::Iterate([[maybe_unused]] const NodeTraverser &cb) const {} -void DummyNode::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "DummyNode"}, - {"name", name_}, - {"indexName", indexName_}, - {"returnType", AstDumper::Optional(GetReturnTypeLiteral())}}); -} - -void DummyNode::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add(std::string(name_)); -} - -void DummyNode::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void DummyNode::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *DummyNode::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType DummyNode::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/expressions/functionExpression.cpp b/ets2panda/ir/expressions/functionExpression.cpp index b5096815fca802dd2449b17f1a44ef188c86fee4..879880ae693c71d47f23119ae0df79f087e040d4 100644 --- a/ets2panda/ir/expressions/functionExpression.cpp +++ b/ets2panda/ir/expressions/functionExpression.cpp @@ -15,9 +15,7 @@ #include "functionExpression.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" +#include "ir/base/scriptFunction.h" namespace ark::es2panda::ir { void FunctionExpression::TransformChildren(const NodeTransformer &cb, std::string_view const transformationName) @@ -33,36 +31,6 @@ void FunctionExpression::Iterate(const NodeTraverser &cb) const cb(func_); } -void FunctionExpression::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "FunctionExpression"}, {"function", func_}}); -} - -void FunctionExpression::Dump(ir::SrcDumper *dumper) const -{ - func_->Dump(dumper); -} - -void FunctionExpression::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void FunctionExpression::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *FunctionExpression::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType FunctionExpression::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - FunctionExpression *FunctionExpression::Clone(ArenaAllocator *const allocator, AstNode *const parent) { ES2PANDA_ASSERT(func_->Clone(allocator, nullptr) != nullptr); diff --git a/ets2panda/ir/expressions/identifier.cpp b/ets2panda/ir/expressions/identifier.cpp index 47662ab57eec7a64d56b1c9a076355cc9acdfac9..d4b4c87119706a49cdbb5425339697bdd4bf9224 100644 --- a/ets2panda/ir/expressions/identifier.cpp +++ b/ets2panda/ir/expressions/identifier.cpp @@ -15,10 +15,13 @@ #include "identifier.h" -#include "checker/ETSchecker.h" -#include "checker/TSchecker.h" -#include "compiler/core/pandagen.h" -#include "compiler/core/ETSGen.h" +#include "ir/base/classDefinition.h" +#include "ir/base/scriptFunction.h" +#include "ir/base/tsPropertySignature.h" +#include "ir/base/classProperty.h" +#include "ir/statements/variableDeclarator.h" +#include "ir/ts/tsEnumMember.h" +#include "ir/typeNode.h" namespace ark::es2panda::ir { Identifier::Identifier([[maybe_unused]] Tag const tag, Identifier const &other, ArenaAllocator *const allocator) @@ -101,61 +104,6 @@ void Identifier::Iterate(const NodeTraverser &cb) const } } -void Identifier::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", IsPrivateIdent() ? "PrivateIdentifier" : "Identifier"}, - {"name", Name()}, - {"typeAnnotation", AstDumper::Optional(TypeAnnotation())}, - {"optional", AstDumper::Optional(IsOptional())}}); -} - -void Identifier::Dump(ir::SrcDumper *dumper) const -{ - if (IsReceiver()) { - dumper->Add("this"); - return; - } - - if (IsPrivateIdent()) { - dumper->Add("private "); - } - - auto name = std::string(Name()); - std::string propertyStr = compiler::Signatures::PROPERTY.data(); - if (UNLIKELY(name.find(propertyStr) != std::string::npos)) { - name.replace(name.find(propertyStr), propertyStr.length(), "_$property$_"); - } - dumper->Add(name); - if (IsOptional()) { - dumper->Add("?"); - } - - if (dumper->IsDeclgen()) { - dumper->GetDeclgen()->PushTask( - [dumper, name = std::string(name_)] { dumper->GetDeclgen()->DumpNode(dumper, name); }); - } -} - -void Identifier::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void Identifier::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *Identifier::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType Identifier::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - bool Identifier::IsDeclaration(ScriptExtension ext) const { // We can determine reference status from parent node diff --git a/ets2panda/ir/expressions/importExpression.cpp b/ets2panda/ir/expressions/importExpression.cpp index fc1c140d4daf9a13d8f7be40e2e5e14bba1c1ac4..c444cbc5b3c3319ffbfe746e10f8d46cbfdaa81e 100644 --- a/ets2panda/ir/expressions/importExpression.cpp +++ b/ets2panda/ir/expressions/importExpression.cpp @@ -15,10 +15,6 @@ #include "importExpression.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" - namespace ark::es2panda::ir { void ImportExpression::TransformChildren(const NodeTransformer &cb, std::string_view const transformationName) { @@ -33,35 +29,6 @@ void ImportExpression::Iterate(const NodeTraverser &cb) const cb(source_); } -void ImportExpression::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "ImportExpression"}, {"source", source_}}); -} - -void ImportExpression::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add("ImportExpression"); -} - -void ImportExpression::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void ImportExpression::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} -checker::Type *ImportExpression::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType ImportExpression::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - ImportExpression *ImportExpression::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto *const source = source_ != nullptr ? source_->Clone(allocator, nullptr)->AsExpression() : nullptr; diff --git a/ets2panda/ir/expressions/literals/bigIntLiteral.cpp b/ets2panda/ir/expressions/literals/bigIntLiteral.cpp index 95cc4f3eaa7531ac60a58ef1d9a3955e2ed62d9a..4ee580d535a150c11588c5da1d68685db39da030 100644 --- a/ets2panda/ir/expressions/literals/bigIntLiteral.cpp +++ b/ets2panda/ir/expressions/literals/bigIntLiteral.cpp @@ -15,11 +15,6 @@ #include "bigIntLiteral.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "checker/ETSchecker.h" - namespace ark::es2panda::ir { void BigIntLiteral::TransformChildren([[maybe_unused]] const NodeTransformer &cb, [[maybe_unused]] std::string_view const transformationName) @@ -28,36 +23,6 @@ void BigIntLiteral::TransformChildren([[maybe_unused]] const NodeTransformer &cb void BigIntLiteral::Iterate([[maybe_unused]] const NodeTraverser &cb) const {} -void BigIntLiteral::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "BigIntLiteral"}, {"value", src_}}); -} - -void BigIntLiteral::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add(std::string(src_) + "n"); -} - -void BigIntLiteral::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void BigIntLiteral::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *BigIntLiteral::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType BigIntLiteral::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - BigIntLiteral *BigIntLiteral::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto *const clone = allocator->New(src_); diff --git a/ets2panda/ir/expressions/literals/bigIntLiteral.h b/ets2panda/ir/expressions/literals/bigIntLiteral.h index 8e34cbf5381edca76a5ae956ab31b01e0ff2354e..c6c20e6f8ce8916a83b1cfc5d53fb9b78d00abfc 100644 --- a/ets2panda/ir/expressions/literals/bigIntLiteral.h +++ b/ets2panda/ir/expressions/literals/bigIntLiteral.h @@ -16,6 +16,7 @@ #ifndef ES2PANDA_IR_EXPRESSION_LITERAL_BIGINT_LITERAL_H #define ES2PANDA_IR_EXPRESSION_LITERAL_BIGINT_LITERAL_H +#include "ir/typeNode.h" #include "ir/expressions/literal.h" #include "util/ustring.h" diff --git a/ets2panda/ir/expressions/literals/booleanLiteral.cpp b/ets2panda/ir/expressions/literals/booleanLiteral.cpp index 01025493fbe35c3d4eebd448b98b6d6fa83a4b28..763f3b94139ab8299f6202b0f9a3cbdb31cc44f1 100644 --- a/ets2panda/ir/expressions/literals/booleanLiteral.cpp +++ b/ets2panda/ir/expressions/literals/booleanLiteral.cpp @@ -15,11 +15,6 @@ #include "booleanLiteral.h" -#include "compiler/core/pandagen.h" -#include "compiler/core/ETSGen.h" -#include "checker/TSchecker.h" -#include "checker/ETSchecker.h" - namespace ark::es2panda::ir { void BooleanLiteral::TransformChildren([[maybe_unused]] const NodeTransformer &cb, [[maybe_unused]] std::string_view const transformationName) @@ -28,36 +23,6 @@ void BooleanLiteral::TransformChildren([[maybe_unused]] const NodeTransformer &c void BooleanLiteral::Iterate([[maybe_unused]] const NodeTraverser &cb) const {} -void BooleanLiteral::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "BooleanLiteral"}, {"value", boolean_}}); -} - -void BooleanLiteral::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add(boolean_ ? "true" : "false"); -} - -void BooleanLiteral::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void BooleanLiteral::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *BooleanLiteral::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType BooleanLiteral::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - BooleanLiteral *BooleanLiteral::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto *const clone = allocator->New(boolean_); diff --git a/ets2panda/ir/expressions/literals/charLiteral.cpp b/ets2panda/ir/expressions/literals/charLiteral.cpp index 3dcd401f22f96dc2f48f27692e4be373ba887452..c3f8b2fa9a3d9b8114b02e8a8996d0bbe03b59fe 100644 --- a/ets2panda/ir/expressions/literals/charLiteral.cpp +++ b/ets2panda/ir/expressions/literals/charLiteral.cpp @@ -15,10 +15,7 @@ #include "charLiteral.h" -#include "checker/TSchecker.h" -#include "compiler/core/pandagen.h" -#include "compiler/core/ETSGen.h" -#include "checker/ETSchecker.h" +#include "util/helpers.h" namespace ark::es2panda::ir { void CharLiteral::TransformChildren([[maybe_unused]] const NodeTransformer &cb, @@ -28,36 +25,6 @@ void CharLiteral::TransformChildren([[maybe_unused]] const NodeTransformer &cb, void CharLiteral::Iterate([[maybe_unused]] const NodeTraverser &cb) const {} -void CharLiteral::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "CharLiteral"}, {"value", char_}}); -} - -void CharLiteral::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add("c\'" + ToString() + "\'"); -} - -void CharLiteral::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void CharLiteral::Compile([[maybe_unused]] compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *CharLiteral::Check([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType CharLiteral::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - CharLiteral *CharLiteral::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto *const clone = allocator->New(char_); diff --git a/ets2panda/ir/expressions/literals/nullLiteral.cpp b/ets2panda/ir/expressions/literals/nullLiteral.cpp index f88e2e85329bb9c8538bd775e9b70ad52b5a185e..7b60c6b48b615fba2606b8b8ce200c96ac491eb3 100644 --- a/ets2panda/ir/expressions/literals/nullLiteral.cpp +++ b/ets2panda/ir/expressions/literals/nullLiteral.cpp @@ -15,10 +15,6 @@ #include "nullLiteral.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" - namespace ark::es2panda::ir { void NullLiteral::TransformChildren([[maybe_unused]] const NodeTransformer &cb, [[maybe_unused]] std::string_view const transformationName) @@ -27,36 +23,6 @@ void NullLiteral::TransformChildren([[maybe_unused]] const NodeTransformer &cb, void NullLiteral::Iterate([[maybe_unused]] const NodeTraverser &cb) const {} -void NullLiteral::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "NullLiteral"}, {"value", AstDumper::Property::Constant::PROP_NULL}}); -} - -void NullLiteral::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add("null"); -} - -void NullLiteral::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void NullLiteral::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *NullLiteral::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType NullLiteral::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - NullLiteral *NullLiteral::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto *const clone = allocator->New(); diff --git a/ets2panda/ir/expressions/literals/numberLiteral.cpp b/ets2panda/ir/expressions/literals/numberLiteral.cpp index d3cf60f0268eb3424cf9edc204521889eb91fdbd..bc7507197fe6ca4f939a12e4c925f175c718af79 100644 --- a/ets2panda/ir/expressions/literals/numberLiteral.cpp +++ b/ets2panda/ir/expressions/literals/numberLiteral.cpp @@ -15,10 +15,10 @@ #include "numberLiteral.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" #include "util/dtoa_helper.h" +#include "libarkbase/utils/bit_helpers.h" + +#include namespace ark::es2panda::ir { @@ -35,67 +35,6 @@ void NumberLiteral::TransformChildren([[maybe_unused]] const NodeTransformer &cb void NumberLiteral::Iterate([[maybe_unused]] const NodeTraverser &cb) const {} -void NumberLiteral::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "NumberLiteral"}, {"value", number_}}); -} - -void NumberLiteral::Dump(ir::SrcDumper *dumper) const -{ - if (std::string(number_.Str()).empty() || (parent_ != nullptr && parent_->IsTSEnumMember())) { - if (number_.IsInt()) { - dumper->Add(number_.GetInt()); - return; - } - - if (number_.IsLong()) { - dumper->Add(number_.GetLong()); - return; - } - - if (number_.IsFloat()) { - dumper->Add(number_.GetFloat()); - return; - } - - if (number_.IsDouble()) { - dumper->Add(number_.GetDouble()); - return; - } - - if (number_.IsShort()) { - dumper->Add(number_.GetShort()); - return; - } - - if (number_.IsByte()) { - dumper->Add(number_.GetByte()); - return; - } - } - dumper->Add(std::string(number_.Str())); -} - -void NumberLiteral::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void NumberLiteral::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *NumberLiteral::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType NumberLiteral::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - NumberLiteral *NumberLiteral::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto *const clone = allocator->New(number_); diff --git a/ets2panda/ir/expressions/literals/regExpLiteral.cpp b/ets2panda/ir/expressions/literals/regExpLiteral.cpp index 71b31dc0c9a39839b7b32cef49a5dd86d057f559..e741143bd5099a0bec04939483c7de17f107e05c 100644 --- a/ets2panda/ir/expressions/literals/regExpLiteral.cpp +++ b/ets2panda/ir/expressions/literals/regExpLiteral.cpp @@ -15,10 +15,7 @@ #include "regExpLiteral.h" -#include "compiler/core/pandagen.h" #include "compiler/core/regScope.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" namespace ark::es2panda::ir { void RegExpLiteral::TransformChildren([[maybe_unused]] const NodeTransformer &cb, @@ -28,36 +25,6 @@ void RegExpLiteral::TransformChildren([[maybe_unused]] const NodeTransformer &cb void RegExpLiteral::Iterate([[maybe_unused]] const NodeTraverser &cb) const {} -void RegExpLiteral::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "RegExpLiteral"}, {"source", pattern_}, {"flags", flagsStr_}}); -} - -void RegExpLiteral::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add(std::string(pattern_)); -} - -void RegExpLiteral::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void RegExpLiteral::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *RegExpLiteral::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType RegExpLiteral::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - RegExpLiteral *RegExpLiteral::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto *const clone = allocator->New(pattern_, flags_, flagsStr_); diff --git a/ets2panda/ir/expressions/literals/stringLiteral.cpp b/ets2panda/ir/expressions/literals/stringLiteral.cpp index 6c6e598e0d7c790cf43a7ca0100f798bc77367f0..c0a66b866a4f87735db611ce71d77268a2af5cd7 100644 --- a/ets2panda/ir/expressions/literals/stringLiteral.cpp +++ b/ets2panda/ir/expressions/literals/stringLiteral.cpp @@ -15,10 +15,6 @@ #include "stringLiteral.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" - namespace ark::es2panda::ir { void StringLiteral::TransformChildren([[maybe_unused]] const NodeTransformer &cb, [[maybe_unused]] std::string_view const transformationName) @@ -27,36 +23,6 @@ void StringLiteral::TransformChildren([[maybe_unused]] const NodeTransformer &cb void StringLiteral::Iterate([[maybe_unused]] const NodeTraverser &cb) const {} -void StringLiteral::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "StringLiteral"}, {"value", str_}}); -} - -void StringLiteral::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add("\"" + util::Helpers::CreateEscapedString(str_.Utf8()) + "\""); -} - -void StringLiteral::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void StringLiteral::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *StringLiteral::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType StringLiteral::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - StringLiteral *StringLiteral::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto *const clone = allocator->New(str_); diff --git a/ets2panda/ir/expressions/literals/stringLiteral.h b/ets2panda/ir/expressions/literals/stringLiteral.h index 0023873e05bc04836829d705d43efdcda2ca5d2a..e8e0dc7bba60f967a2d6de31bc92249f1ef1c147 100644 --- a/ets2panda/ir/expressions/literals/stringLiteral.h +++ b/ets2panda/ir/expressions/literals/stringLiteral.h @@ -18,6 +18,7 @@ #include "ir/expressions/literal.h" #include "util/es2pandaMacros.h" +#include "util/helpers.h" #include "util/ustring.h" namespace ark::es2panda::ir { diff --git a/ets2panda/ir/expressions/literals/undefinedLiteral.cpp b/ets2panda/ir/expressions/literals/undefinedLiteral.cpp index d30067ede8bb0a29ec113eaba38c6f2567dd3418..c96f7d029d91944686858b6493f5f8fdb1376768 100644 --- a/ets2panda/ir/expressions/literals/undefinedLiteral.cpp +++ b/ets2panda/ir/expressions/literals/undefinedLiteral.cpp @@ -15,13 +15,6 @@ #include "undefinedLiteral.h" -#include "compiler/core/pandagen.h" -#include "compiler/core/ETSGen.h" -#include "checker/TSchecker.h" -#include "checker/ETSchecker.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" - namespace ark::es2panda::ir { void UndefinedLiteral::TransformChildren([[maybe_unused]] const NodeTransformer &cb, [[maybe_unused]] std::string_view const transformationName) @@ -30,37 +23,6 @@ void UndefinedLiteral::TransformChildren([[maybe_unused]] const NodeTransformer void UndefinedLiteral::Iterate([[maybe_unused]] const NodeTraverser &cb) const {} -void UndefinedLiteral::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "UndefinedLiteral"}, {"value", AstDumper::Property::Constant::PROP_UNDEFINED}}); -} - -void UndefinedLiteral::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add("undefined"); -} - -void UndefinedLiteral::Compile(compiler::PandaGen *pg) const -{ - pg->LoadConst(this, compiler::Constant::JS_UNDEFINED); -} - -void UndefinedLiteral::Compile(compiler::ETSGen *etsg) const -{ - etsg->LoadAccumulatorUndefined(this); -} - -checker::Type *UndefinedLiteral::Check(checker::TSChecker *checker) -{ - return checker->GlobalUndefinedType(); -} - -checker::VerifiedType UndefinedLiteral::Check(checker::ETSChecker *checker) -{ - SetTsType(checker->GlobalETSUndefinedType()); - return {this, TsType()}; -} - UndefinedLiteral *UndefinedLiteral::Clone(ArenaAllocator *allocator, AstNode *parent) { auto *const clone = allocator->New(); diff --git a/ets2panda/ir/expressions/memberExpression.cpp b/ets2panda/ir/expressions/memberExpression.cpp index 9bd788ce380e17b04d77aaabf94dca4f03ff28bf..173279e6e99dce3366774fb0b04c882befe1f803 100644 --- a/ets2panda/ir/expressions/memberExpression.cpp +++ b/ets2panda/ir/expressions/memberExpression.cpp @@ -15,11 +15,19 @@ #include "memberExpression.h" -#include "checker/TSchecker.h" #include "checker/ets/castingContext.h" +#include "checker/types/ets/etsFunctionType.h" +#include "checker/types/ets/etsObjectType.h" #include "checker/types/ets/etsTupleType.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" +#include "checker/types/ets/etsUnionType.h" +#include "checker/types/ets/etsArrayType.h" +#include "checker/types/ets/etsExtensionFuncHelperType.h" + +#include "ir/expressions/arrayExpression.h" +#include "ir/expressions/assignmentExpression.h" +#include "ir/expressions/callExpression.h" +#include "ir/expressions/literals/numberLiteral.h" + #include "util/diagnostic.h" #include "util/es2pandaMacros.h" @@ -56,100 +64,6 @@ void MemberExpression::Iterate(const NodeTraverser &cb) const cb(property_); } -void MemberExpression::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "MemberExpression"}, - {"object", object_}, - {"property", property_}, - {"computed", computed_}, - {"optional", IsOptional()}}); -} - -void MemberExpression::Dump(ir::SrcDumper *dumper) const -{ - ES2PANDA_ASSERT(object_ != nullptr); - ES2PANDA_ASSERT(property_ != nullptr); - - object_->Dump(dumper); - if (IsOptional()) { - dumper->Add("?"); - if ((MemberExpressionKind::ELEMENT_ACCESS & kind_) != 0U) { - dumper->Add("."); - } - } - if ((MemberExpressionKind::ELEMENT_ACCESS & kind_) != 0U) { - dumper->Add("["); - property_->Dump(dumper); - dumper->Add("]"); - } else { - dumper->Add("."); - property_->Dump(dumper); - } - if ((parent_ != nullptr) && (parent_->IsBlockStatement() || parent_->IsBlockExpression())) { - dumper->Add(";"); - dumper->Endl(); - } -} - -void MemberExpression::LoadRhs(compiler::PandaGen *pg) const -{ - compiler::RegScope rs(pg); - bool isSuper = object_->IsSuperExpression(); - compiler::Operand prop = pg->ToPropertyKey(property_, computed_, isSuper); - - if (isSuper) { - pg->LoadSuperProperty(this, prop); - } else if (IsPrivateReference()) { - const auto &name = property_->AsIdentifier()->Name(); - compiler::VReg objReg = pg->AllocReg(); - pg->StoreAccumulator(this, objReg); - compiler::VReg ctor = pg->AllocReg(); - compiler::Function::LoadClassContexts(this, pg, ctor, name); - pg->ClassPrivateFieldGet(this, ctor, objReg, name); - } else { - pg->LoadObjProperty(this, prop); - } -} - -void MemberExpression::CompileToRegs(compiler::PandaGen *pg, compiler::VReg object, compiler::VReg property) const -{ - object_->Compile(pg); - pg->StoreAccumulator(this, object); - - pg->OptionalChainCheck(IsOptional(), object); - - if (!computed_) { - pg->LoadAccumulatorString(this, property_->AsIdentifier()->Name()); - } else { - property_->Compile(pg); - } - - pg->StoreAccumulator(this, property); -} - -void MemberExpression::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void MemberExpression::CompileToReg(compiler::PandaGen *pg, compiler::VReg objReg) const -{ - object_->Compile(pg); - pg->StoreAccumulator(this, objReg); - pg->OptionalChainCheck(IsOptional(), objReg); - LoadRhs(pg); -} - -void MemberExpression::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *MemberExpression::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - std::pair MemberExpression::ResolveObjectMember( checker::ETSChecker *checker) const { @@ -534,11 +448,6 @@ checker::Type *MemberExpression::CheckComputed(checker::ETSChecker *checker, che return nullptr; } -checker::VerifiedType MemberExpression::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - MemberExpression *MemberExpression::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto *const clone = allocator->New(Tag {}, *this, allocator); diff --git a/ets2panda/ir/expressions/memberExpression.h b/ets2panda/ir/expressions/memberExpression.h index 4906dc35d2e626cb0f2167e051c71fd7247dcb8f..f686cf75215085d7d4103965a8462beeba7ff984 100644 --- a/ets2panda/ir/expressions/memberExpression.h +++ b/ets2panda/ir/expressions/memberExpression.h @@ -17,17 +17,18 @@ #define ES2PANDA_IR_EXPRESSION_MEMBER_EXPRESSION_H #include "checker/checkerContext.h" -#include "checker/types/ets/etsObjectType.h" #include "ir/expression.h" - +#include "varbinder/variable.h" namespace ark::es2panda::compiler { class JSCompiler; class ETSCompiler; } // namespace ark::es2panda::compiler namespace ark::es2panda::checker { -class ETSObjectType; class ETSAnalyzer; +class ETSFunctionType; +class ETSObjectType; +class ETSUnionType; } // namespace ark::es2panda::checker namespace ark::es2panda::ir { diff --git a/ets2panda/ir/expressions/newExpression.cpp b/ets2panda/ir/expressions/newExpression.cpp index 121a9871a1b0a46a0d51d39afa5f7e509dce4f5d..6c486105eb7bec765f82ebd792d748182e391405 100644 --- a/ets2panda/ir/expressions/newExpression.cpp +++ b/ets2panda/ir/expressions/newExpression.cpp @@ -15,10 +15,6 @@ #include "newExpression.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" - namespace ark::es2panda::ir { NewExpression::NewExpression([[maybe_unused]] Tag const tag, NewExpression const &other, ArenaAllocator *const allocator) @@ -68,33 +64,4 @@ void NewExpression::Iterate(const NodeTraverser &cb) const } } -void NewExpression::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "NewExpression"}, {"callee", callee_}, {"arguments", arguments_}}); -} - -void NewExpression::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add("NewExpression"); -} - -void NewExpression::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void NewExpression::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *NewExpression::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType NewExpression::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/expressions/objectExpression.cpp b/ets2panda/ir/expressions/objectExpression.cpp index 9165f2cd3b80d33b41a0b23935808f72ae41a13f..2bbca94bf60f48c87dcc654b40135578dfef0c84 100644 --- a/ets2panda/ir/expressions/objectExpression.cpp +++ b/ets2panda/ir/expressions/objectExpression.cpp @@ -15,10 +15,16 @@ #include "objectExpression.h" -#include "compiler/core/pandagen.h" -#include "compiler/core/ETSGen.h" #include "checker/ts/destructuringContext.h" +#include "ir/typeNode.h" + +#include "ir/base/spreadElement.h" +#include "ir/base/property.h" + +#include "ir/expressions/assignmentExpression.h" +#include "ir/expressions/arrayExpression.h" + namespace ark::es2panda::ir { ObjectExpression::ObjectExpression([[maybe_unused]] Tag const tag, ObjectExpression const &other, ArenaAllocator *const allocator) @@ -137,37 +143,6 @@ void ObjectExpression::Iterate(const NodeTraverser &cb) const } } -void ObjectExpression::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", (type_ == AstNodeType::OBJECT_EXPRESSION) ? "ObjectExpression" : "ObjectPattern"}, - {"properties", properties_}, - {"typeAnnotation", AstDumper::Optional(TypeAnnotation())}, - {"optional", AstDumper::Optional(optional_)}}); -} - -void ObjectExpression::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add("{"); - if (!properties_.empty()) { - dumper->IncrIndent(); - dumper->Endl(); - for (auto property : properties_) { - property->Dump(dumper); - dumper->Add(","); - if (property == properties_.back()) { - dumper->DecrIndent(); - } - dumper->Endl(); - } - } - dumper->Add("}"); -} - -void ObjectExpression::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - // CC-OFFNXT(G.FMT.10-CPP) project code style std::tuple ObjectExpression::CheckPatternIsShorthand(CheckPatternIsShorthandArgs *args) @@ -317,21 +292,6 @@ bool ObjectExpression::CheckAssignmentPattern(Property *prop, varbinder::Variabl return true; } -checker::Type *ObjectExpression::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -void ObjectExpression::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::VerifiedType ObjectExpression::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - void ObjectExpression::CleanCheckInformation() { SetPreferredType(nullptr); diff --git a/ets2panda/ir/expressions/omittedExpression.cpp b/ets2panda/ir/expressions/omittedExpression.cpp index a804144ab34d4a4b8447ef825aa6af03d1d88f1e..676e962ba0838847868093760c81998dedf70e32 100644 --- a/ets2panda/ir/expressions/omittedExpression.cpp +++ b/ets2panda/ir/expressions/omittedExpression.cpp @@ -15,10 +15,6 @@ #include "omittedExpression.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" - namespace ark::es2panda::ir { void OmittedExpression::TransformChildren([[maybe_unused]] const NodeTransformer &cb, [[maybe_unused]] std::string_view const transformationName) @@ -27,36 +23,6 @@ void OmittedExpression::TransformChildren([[maybe_unused]] const NodeTransformer void OmittedExpression::Iterate([[maybe_unused]] const NodeTraverser &cb) const {} -void OmittedExpression::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "OmittedExpression"}}); -} - -void OmittedExpression::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add("OmittedExpression"); -} - -void OmittedExpression::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void OmittedExpression::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *OmittedExpression::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType OmittedExpression::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - OmittedExpression *OmittedExpression::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto *const clone = allocator->New(); diff --git a/ets2panda/ir/expressions/sequenceExpression.cpp b/ets2panda/ir/expressions/sequenceExpression.cpp index f84e542b58ff162ce0752e4b420009f38714304e..0a881de9d56cf5a0d7bea8ecda8dfd520ada46c0 100644 --- a/ets2panda/ir/expressions/sequenceExpression.cpp +++ b/ets2panda/ir/expressions/sequenceExpression.cpp @@ -15,11 +15,6 @@ #include "sequenceExpression.h" -#include "checker/ETSchecker.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" - namespace ark::es2panda::ir { SequenceExpression::SequenceExpression([[maybe_unused]] Tag const tag, SequenceExpression const &other, ArenaAllocator *const allocator) @@ -58,38 +53,4 @@ void SequenceExpression::Iterate(const NodeTraverser &cb) const } } -void SequenceExpression::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "SequenceExpression"}, {"expressions", sequence_}}); -} - -void SequenceExpression::Dump(ir::SrcDumper *dumper) const -{ - for (auto *expr : sequence_) { - expr->Dump(dumper); - if (expr != sequence_.back()) { - dumper->Add(", "); - } - } -} - -void SequenceExpression::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void SequenceExpression::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *SequenceExpression::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType SequenceExpression::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/expressions/superExpression.cpp b/ets2panda/ir/expressions/superExpression.cpp index 027182de8aeb3ebdff9368cd606216e8e6d01e06..131d2d9c40fa97c2e438ed2afed27df74a49ff1c 100644 --- a/ets2panda/ir/expressions/superExpression.cpp +++ b/ets2panda/ir/expressions/superExpression.cpp @@ -15,11 +15,6 @@ #include "superExpression.h" -#include "checker/ETSchecker.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" - namespace ark::es2panda::ir { void SuperExpression::TransformChildren([[maybe_unused]] const NodeTransformer &cb, [[maybe_unused]] std::string_view const transformationName) @@ -28,36 +23,6 @@ void SuperExpression::TransformChildren([[maybe_unused]] const NodeTransformer & void SuperExpression::Iterate([[maybe_unused]] const NodeTraverser &cb) const {} -void SuperExpression::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "Super"}}); -} - -void SuperExpression::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add("super"); -} - -void SuperExpression::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void SuperExpression::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *SuperExpression::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType SuperExpression::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - SuperExpression *SuperExpression::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto *const clone = allocator->New(); diff --git a/ets2panda/ir/expressions/taggedTemplateExpression.cpp b/ets2panda/ir/expressions/taggedTemplateExpression.cpp index 069005b5537a41162c7cb76f4876520a4370e90d..e7e9d3ad9cbffdbc5ec85e3997162dbe519dcae4 100644 --- a/ets2panda/ir/expressions/taggedTemplateExpression.cpp +++ b/ets2panda/ir/expressions/taggedTemplateExpression.cpp @@ -15,9 +15,9 @@ #include "taggedTemplateExpression.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "checker/TSchecker.h" +#include "ir/expressions/identifier.h" +#include "ir/expressions/templateLiteral.h" +#include "ir/ts/tsTypeParameterInstantiation.h" namespace ark::es2panda::ir { void TaggedTemplateExpression::TransformChildren(const NodeTransformer &cb, std::string_view const transformationName) @@ -50,39 +50,6 @@ void TaggedTemplateExpression::Iterate(const NodeTraverser &cb) const cb(quasi_); } -void TaggedTemplateExpression::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "TaggedTemplateExpression"}, - {"tag", tag_}, - {"quasi", quasi_}, - {"typeParameters", AstDumper::Optional(typeParams_)}}); -} - -void TaggedTemplateExpression::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add("TaggedTemplateExpression"); -} - -void TaggedTemplateExpression::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void TaggedTemplateExpression::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *TaggedTemplateExpression::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType TaggedTemplateExpression::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - TaggedTemplateExpression *TaggedTemplateExpression::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto *const tag = tag_ != nullptr ? tag_->Clone(allocator, nullptr)->AsExpression() : nullptr; diff --git a/ets2panda/ir/expressions/templateLiteral.cpp b/ets2panda/ir/expressions/templateLiteral.cpp index 4275fe126a9e65b20a52a4a6d2b8353cfcd72a21..1dcf2c871a1848944a893121fbfef3f69efeabff 100644 --- a/ets2panda/ir/expressions/templateLiteral.cpp +++ b/ets2panda/ir/expressions/templateLiteral.cpp @@ -15,11 +15,6 @@ #include "templateLiteral.h" -#include "compiler/core/pandagen.h" -#include "compiler/core/ETSGen.h" -#include "checker/TSchecker.h" -#include "checker/ETSchecker.h" - namespace ark::es2panda::ir { TemplateLiteral::TemplateLiteral([[maybe_unused]] Tag const tag, TemplateLiteral const &other, ArenaAllocator *const allocator) @@ -77,50 +72,6 @@ void TemplateLiteral::Iterate(const NodeTraverser &cb) const } } -void TemplateLiteral::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "TemplateLiteral"}, {"expressions", expressions_}, {"quasis", quasis_}}); -} - -void TemplateLiteral::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add("`"); - auto const num = std::max(expressions_.size(), quasis_.size()); - - for (std::size_t i = 0U; i < num; i++) { - if (i < quasis_.size()) { - quasis_[i]->Dump(dumper); - } - if (i < expressions_.size()) { - dumper->Add("${"); - expressions_[i]->Dump(dumper); - dumper->Add("}"); - } - } - dumper->Add("`"); -} - -void TemplateLiteral::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -checker::Type *TemplateLiteral::Check([[maybe_unused]] checker::TSChecker *checker) -{ - // NOTE: aszilagyi. - return checker->GlobalAnyType(); -} - -void TemplateLiteral::Compile([[maybe_unused]] compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::VerifiedType TemplateLiteral::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - util::StringView TemplateLiteral::GetMultilineString() const { return multilineString_; diff --git a/ets2panda/ir/expressions/thisExpression.cpp b/ets2panda/ir/expressions/thisExpression.cpp index 269fb8a2224280b46fc9bb42fa48a49c38d08ba3..c4b3fda05b4e67020c44b796e549a4fb79640732 100644 --- a/ets2panda/ir/expressions/thisExpression.cpp +++ b/ets2panda/ir/expressions/thisExpression.cpp @@ -15,11 +15,6 @@ #include "thisExpression.h" -#include "compiler/core/pandagen.h" -#include "compiler/core/ETSGen.h" -#include "checker/TSchecker.h" -#include "checker/ETSchecker.h" - namespace ark::es2panda::ir { void ThisExpression::TransformChildren([[maybe_unused]] const NodeTransformer &cb, [[maybe_unused]] std::string_view const transformationName) @@ -28,36 +23,6 @@ void ThisExpression::TransformChildren([[maybe_unused]] const NodeTransformer &c void ThisExpression::Iterate([[maybe_unused]] const NodeTraverser &cb) const {} -void ThisExpression::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "ThisExpression"}}); -} - -void ThisExpression::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add("this"); -} - -void ThisExpression::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void ThisExpression::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *ThisExpression::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType ThisExpression::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - ThisExpression *ThisExpression::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto *const clone = allocator->New(); diff --git a/ets2panda/ir/expressions/typeofExpression.cpp b/ets2panda/ir/expressions/typeofExpression.cpp index c5d2b5e4d7c87f965a40bd143aa2bb65161f4c78..fb4aec11b8039c4afcfb2925db1c6c18f167fb46 100644 --- a/ets2panda/ir/expressions/typeofExpression.cpp +++ b/ets2panda/ir/expressions/typeofExpression.cpp @@ -15,11 +15,6 @@ #include "typeofExpression.h" -#include "compiler/core/pandagen.h" -#include "compiler/core/ETSGen.h" -#include "checker/TSchecker.h" -#include "checker/ETSchecker.h" - namespace ark::es2panda::ir { void TypeofExpression::TransformChildren(const NodeTransformer &cb, std::string_view const transformationName) { @@ -34,38 +29,6 @@ void TypeofExpression::Iterate([[maybe_unused]] const NodeTraverser &cb) const cb(argument_); } -void TypeofExpression::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "TypeofExpression"}, {"argument", argument_}}); -} - -void TypeofExpression::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add("(typeof "); - argument_->Dump(dumper); - dumper->Add(")"); -} - -void TypeofExpression::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void TypeofExpression::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *TypeofExpression::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType TypeofExpression::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - TypeofExpression *TypeofExpression::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto *const argument = argument_->Clone(allocator, nullptr)->AsExpression(); diff --git a/ets2panda/ir/expressions/unaryExpression.cpp b/ets2panda/ir/expressions/unaryExpression.cpp index 1208f24c21eb357c8c8bab271a1090ca384979a9..f779cf4e8d24ceaca515a57b07696959d8daa277 100644 --- a/ets2panda/ir/expressions/unaryExpression.cpp +++ b/ets2panda/ir/expressions/unaryExpression.cpp @@ -15,11 +15,6 @@ #include "unaryExpression.h" -#include "compiler/core/pandagen.h" -#include "compiler/core/ETSGen.h" -#include "checker/TSchecker.h" -#include "checker/ETSchecker.h" - namespace ark::es2panda::ir { void UnaryExpression::TransformChildren(const NodeTransformer &cb, std::string_view transformationName) { @@ -34,43 +29,6 @@ void UnaryExpression::Iterate(const NodeTraverser &cb) const cb(argument_); } -void UnaryExpression::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "UnaryExpression"}, {"operator", operator_}, {"prefix", true}, {"argument", argument_}}); -} - -void UnaryExpression::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add(TokenToString(operator_)); - if (!argument_->IsIdentifier()) { - dumper->Add("("); - argument_->Dump(dumper); - dumper->Add(")"); - } else { - argument_->Dump(dumper); - } -} - -void UnaryExpression::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void UnaryExpression::Compile([[maybe_unused]] compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *UnaryExpression::Check([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType UnaryExpression::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - UnaryExpression *UnaryExpression::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto *const argument = argument_ != nullptr ? argument_->Clone(allocator, nullptr)->AsExpression() : nullptr; diff --git a/ets2panda/ir/expressions/updateExpression.cpp b/ets2panda/ir/expressions/updateExpression.cpp index 4d8f148bf22d29bfa829adc6495ea60956d674fa..6507384f61a8e9c8c7e13368c6b212c362a1796d 100644 --- a/ets2panda/ir/expressions/updateExpression.cpp +++ b/ets2panda/ir/expressions/updateExpression.cpp @@ -15,11 +15,6 @@ #include "updateExpression.h" -#include "compiler/core/pandagen.h" -#include "compiler/core/ETSGen.h" -#include "checker/TSchecker.h" -#include "checker/ETSchecker.h" - namespace ark::es2panda::ir { void UpdateExpression::TransformChildren(const NodeTransformer &cb, std::string_view transformationName) { @@ -34,45 +29,6 @@ void UpdateExpression::Iterate(const NodeTraverser &cb) const cb(argument_); } -void UpdateExpression::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "UpdateExpression"}, {"operator", operator_}, {"prefix", prefix_}, {"argument", argument_}}); -} - -void UpdateExpression::Dump(ir::SrcDumper *dumper) const -{ - ES2PANDA_ASSERT(argument_); - dumper->Add("("); - if (prefix_) { - dumper->Add(TokenToString(operator_)); - argument_->Dump(dumper); - } else { - argument_->Dump(dumper); - dumper->Add(TokenToString(operator_)); - } - dumper->Add(")"); -} - -void UpdateExpression::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void UpdateExpression::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *UpdateExpression::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType UpdateExpression::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - UpdateExpression *UpdateExpression::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto *const argument = argument_ != nullptr ? argument_->Clone(allocator, nullptr)->AsExpression() : nullptr; diff --git a/ets2panda/ir/expressions/yieldExpression.cpp b/ets2panda/ir/expressions/yieldExpression.cpp index 23e17be10d567ea75d108469b465f571206048d0..2250a44582b68ced7c3ee09ed8236f239ebc8f4c 100644 --- a/ets2panda/ir/expressions/yieldExpression.cpp +++ b/ets2panda/ir/expressions/yieldExpression.cpp @@ -15,10 +15,7 @@ #include "yieldExpression.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" #include "compiler/function/generatorFunctionBuilder.h" -#include "checker/TSchecker.h" namespace ark::es2panda::ir { void YieldExpression::TransformChildren(const NodeTransformer &cb, std::string_view const transformationName) @@ -38,36 +35,6 @@ void YieldExpression::Iterate(const NodeTraverser &cb) const } } -void YieldExpression::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "YieldExpression"}, {"delegate", delegate_}, {"argument", AstDumper::Nullish(argument_)}}); -} - -void YieldExpression::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add("YieldExpression"); -} - -void YieldExpression::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void YieldExpression::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *YieldExpression::Check([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType YieldExpression::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - YieldExpression *YieldExpression::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto *const argument = argument_ != nullptr ? argument_->Clone(allocator, nullptr)->AsExpression() : nullptr; diff --git a/ets2panda/ir/module/exportAllDeclaration.cpp b/ets2panda/ir/module/exportAllDeclaration.cpp index b61b9dd17c3ba42ff5145da53355b414374ab52a..e40c3904dc2b97a0301316c7cf4684b2333a03b1 100644 --- a/ets2panda/ir/module/exportAllDeclaration.cpp +++ b/ets2panda/ir/module/exportAllDeclaration.cpp @@ -15,11 +15,8 @@ #include "exportAllDeclaration.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" +#include "ir/expressions/identifier.h" +#include "ir/expressions/literals/stringLiteral.h" namespace ark::es2panda::ir { void ExportAllDeclaration::TransformChildren(const NodeTransformer &cb, std::string_view const transformationName) @@ -46,33 +43,4 @@ void ExportAllDeclaration::Iterate(const NodeTraverser &cb) const } } -void ExportAllDeclaration::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "ExportAllDeclaration"}, {"source", source_}, {"exported", AstDumper::Nullish(exported_)}}); -} - -void ExportAllDeclaration::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add("ExportAllDeclaration"); -} - -void ExportAllDeclaration::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void ExportAllDeclaration::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *ExportAllDeclaration::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType ExportAllDeclaration::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/module/exportDefaultDeclaration.cpp b/ets2panda/ir/module/exportDefaultDeclaration.cpp index 5d96ad38e2c22aeedb7017a324ab44ce33b8c0fb..043f156bde840aeda486260aad5b59a2f6c71882 100644 --- a/ets2panda/ir/module/exportDefaultDeclaration.cpp +++ b/ets2panda/ir/module/exportDefaultDeclaration.cpp @@ -15,12 +15,6 @@ #include "exportDefaultDeclaration.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" - namespace ark::es2panda::ir { void ExportDefaultDeclaration::TransformChildren(const NodeTransformer &cb, std::string_view const transformationName) { @@ -35,34 +29,4 @@ void ExportDefaultDeclaration::Iterate(const NodeTraverser &cb) const cb(decl_); } -void ExportDefaultDeclaration::Dump(ir::AstDumper *dumper) const -{ - dumper->Add( - {{"type", IsExportEquals() ? "TSExportAssignment" : "ExportDefaultDeclaration"}, {"declaration", decl_}}); -} - -void ExportDefaultDeclaration::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add("ExportDefaultDeclaration"); -} - -void ExportDefaultDeclaration::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void ExportDefaultDeclaration::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *ExportDefaultDeclaration::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType ExportDefaultDeclaration::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/module/exportNamedDeclaration.cpp b/ets2panda/ir/module/exportNamedDeclaration.cpp index e351e25179d431290a36ab8f13c8b4fe39f05faa..b6a5c5e14b2bcddca8d281c9a6a47687fb4b911f 100644 --- a/ets2panda/ir/module/exportNamedDeclaration.cpp +++ b/ets2panda/ir/module/exportNamedDeclaration.cpp @@ -15,11 +15,8 @@ #include "exportNamedDeclaration.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" +#include "ir/expressions/literals/stringLiteral.h" +#include "ir/module/exportSpecifier.h" namespace ark::es2panda::ir { void ExportNamedDeclaration::TransformChildren(const NodeTransformer &cb, std::string_view transformationName) @@ -61,44 +58,4 @@ void ExportNamedDeclaration::Iterate(const NodeTraverser &cb) const } } -void ExportNamedDeclaration::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "ExportNamedDeclaration"}, - {"declaration", AstDumper::Nullish(decl_)}, - {"source", AstDumper::Nullish(source_)}, - {"specifiers", specifiers_}}); -} - -void ExportNamedDeclaration::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add("export { "); - for (const auto *spec : specifiers_) { - spec->Dump(dumper); - - if (spec != specifiers_.back()) { - dumper->Add(", "); - } - } - dumper->Add(" }"); -} - -void ExportNamedDeclaration::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void ExportNamedDeclaration::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *ExportNamedDeclaration::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType ExportNamedDeclaration::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/module/exportSpecifier.cpp b/ets2panda/ir/module/exportSpecifier.cpp index 1c28d57fe53a0f57a6606771288018944388a220..dea756ba1619c2f23acfad62efcf387e49bc3e99 100644 --- a/ets2panda/ir/module/exportSpecifier.cpp +++ b/ets2panda/ir/module/exportSpecifier.cpp @@ -15,11 +15,7 @@ #include "exportSpecifier.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" +#include "ir/expressions/identifier.h" namespace ark::es2panda::ir { void ExportSpecifier::TransformChildren(const NodeTransformer &cb, std::string_view transformationName) @@ -41,44 +37,4 @@ void ExportSpecifier::Iterate(const NodeTraverser &cb) const cb(exported_); } -void ExportSpecifier::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "ExportSpecifier"}, {"local", local_}, {"exported", exported_}}); -} - -void ExportSpecifier::Dump(ir::SrcDumper *dumper) const -{ - if (GetConstantExpression() != nullptr) { - GetConstantExpression()->Dump(dumper); - dumper->Add("as default"); - return; - } - - exported_->Dump(dumper); - - if (local_ != nullptr) { - dumper->Add(" as "); - local_->Dump(dumper); - } -} - -void ExportSpecifier::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void ExportSpecifier::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *ExportSpecifier::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType ExportSpecifier::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/module/importDeclaration.cpp b/ets2panda/ir/module/importDeclaration.cpp index 7819bafe35c6ad0f527f733d31711b5ae644ece0..a2a0b0f5f59e3965d73edbab39955061622ad2f4 100644 --- a/ets2panda/ir/module/importDeclaration.cpp +++ b/ets2panda/ir/module/importDeclaration.cpp @@ -15,12 +15,9 @@ #include "importDeclaration.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" -#include "libarkbase/utils/arena_containers.h" +#include "ir/expressions/literals/stringLiteral.h" + + namespace ark::es2panda::ir { @@ -56,77 +53,6 @@ void ImportDeclaration::Iterate(const NodeTraverser &cb) const } } -void ImportDeclaration::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "ImportDeclaration"}, {"source", Source()}, {"specifiers", Specifiers()}}); -} - -void ImportDeclaration::Dump(ir::SrcDumper *dumper) const -{ - if (dumper->IsDeclgen()) { - dumper->GetDeclgen()->CollectImport(this); - return; - } - dumper->Add("import "); - auto const &specifiers = Specifiers(); - if (specifiers.size() == 1 && - (specifiers[0]->IsImportNamespaceSpecifier() || specifiers[0]->IsImportDefaultSpecifier())) { - specifiers[0]->Dump(dumper); - } else { - dumper->Add("{ "); - for (auto specifier : specifiers) { - specifier->Dump(dumper); - if (specifier != specifiers.back()) { - dumper->Add(", "); - } - } - dumper->Add(" }"); - } - - dumper->Add(" from "); - - if (dumper->IsDeclgen()) { - auto fileName = Source()->Str(); - auto len = fileName.Length(); - if (fileName.EndsWith(".ets")) { - len -= 4U; - fileName = fileName.Substr(0, len); - } - - std::string importFile = '\"' + util::Helpers::CreateEscapedString(fileName.Utf8()); - if (fileName.Utf8().find('.', 1U) == std::string_view::npos) { - importFile += ".d"; - } - importFile += '\"'; - - dumper->Add(importFile); - } else { - Source()->Dump(dumper); - } - dumper->Add(";"); - dumper->Endl(); -} - -void ImportDeclaration::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void ImportDeclaration::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *ImportDeclaration::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType ImportDeclaration::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - ImportDeclaration *ImportDeclaration::Construct(ArenaAllocator *allocator) { ArenaVector specifiers(allocator->Adapter()); diff --git a/ets2panda/ir/module/importDefaultSpecifier.cpp b/ets2panda/ir/module/importDefaultSpecifier.cpp index cd2c11fd56249dc4548f194c0bf11933f8a8dc92..b8102869c5179125fd3a39f46372a2642276690b 100644 --- a/ets2panda/ir/module/importDefaultSpecifier.cpp +++ b/ets2panda/ir/module/importDefaultSpecifier.cpp @@ -15,11 +15,7 @@ #include "importDefaultSpecifier.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" +#include "ir/expressions/identifier.h" namespace ark::es2panda::ir { void ImportDefaultSpecifier::TransformChildren(const NodeTransformer &cb, std::string_view transformationName) @@ -35,33 +31,4 @@ void ImportDefaultSpecifier::Iterate(const NodeTraverser &cb) const cb(local_); } -void ImportDefaultSpecifier::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "ImportDefaultSpecifier"}, {"local", local_}}); -} - -void ImportDefaultSpecifier::Dump(ir::SrcDumper *dumper) const -{ - local_->Dump(dumper); -} - -void ImportDefaultSpecifier::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void ImportDefaultSpecifier::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *ImportDefaultSpecifier::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType ImportDefaultSpecifier::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/module/importNamespaceSpecifier.cpp b/ets2panda/ir/module/importNamespaceSpecifier.cpp index 4425928858b387f96985ba07c33c545128d87639..8a8ccb394c17946aa92739fc467d8ac79f4a1a87 100644 --- a/ets2panda/ir/module/importNamespaceSpecifier.cpp +++ b/ets2panda/ir/module/importNamespaceSpecifier.cpp @@ -15,11 +15,7 @@ #include "importNamespaceSpecifier.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" +#include "ir/expressions/identifier.h" namespace ark::es2panda::ir { void ImportNamespaceSpecifier::TransformChildren(const NodeTransformer &cb, std::string_view transformationName) @@ -35,37 +31,4 @@ void ImportNamespaceSpecifier::Iterate(const NodeTraverser &cb) const cb(local_); } -void ImportNamespaceSpecifier::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "ImportNamespaceSpecifier"}, {"local", local_}}); -} - -void ImportNamespaceSpecifier::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add("* "); - if (!local_->Name().Empty()) { - dumper->Add("as "); - } - local_->Dump(dumper); -} - -void ImportNamespaceSpecifier::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void ImportNamespaceSpecifier::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *ImportNamespaceSpecifier::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType ImportNamespaceSpecifier::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/module/importSpecifier.cpp b/ets2panda/ir/module/importSpecifier.cpp index fd7908212057486147a975439f1721bc1e394c3c..dbe10f96267a53cda205300380af3928d9851400 100644 --- a/ets2panda/ir/module/importSpecifier.cpp +++ b/ets2panda/ir/module/importSpecifier.cpp @@ -15,11 +15,7 @@ #include "importSpecifier.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" +#include "ir/expressions/identifier.h" namespace ark::es2panda::ir { void ImportSpecifier::TransformChildren(const NodeTransformer &cb, std::string_view transformationName) @@ -45,36 +41,4 @@ void ImportSpecifier::Iterate(const NodeTraverser &cb) const cb(imported_); } -void ImportSpecifier::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "ImportSpecifier"}, {"local", ir::AstDumper::Optional(local_)}, {"imported", imported_}}); -} - -void ImportSpecifier::Dump(ir::SrcDumper *dumper) const -{ - imported_->Dump(dumper); - if (local_ != nullptr) { - dumper->Add(" as "); - local_->Dump(dumper); - } -} - -void ImportSpecifier::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} -void ImportSpecifier::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *ImportSpecifier::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType ImportSpecifier::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/opaqueTypeNode.cpp b/ets2panda/ir/opaqueTypeNode.cpp index 0c4ebd8d9cfa46717ada4c45a829ed457798cd06..d1e99ffb1cc34f64d55e9840abbb85486f0135cf 100644 --- a/ets2panda/ir/opaqueTypeNode.cpp +++ b/ets2panda/ir/opaqueTypeNode.cpp @@ -14,11 +14,8 @@ */ #include "opaqueTypeNode.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" + +#include "checker/types/type.h" namespace ark::es2panda::ir { @@ -33,47 +30,6 @@ void OpaqueTypeNode::Iterate([[maybe_unused]] const NodeTraverser &cb) const IterateAnnotations(cb); } -void OpaqueTypeNode::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "OpaqueType"}, {"annotations", AstDumper::Optional(Annotations())}}); -} - -void OpaqueTypeNode::Dump(ir::SrcDumper *dumper) const -{ - DumpAnnotations(dumper); - dumper->Add(TsType()->ToString()); -} - -void OpaqueTypeNode::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void OpaqueTypeNode::Compile([[maybe_unused]] compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *OpaqueTypeNode::Check([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::Type *OpaqueTypeNode::GetType([[maybe_unused]] checker::TSChecker *checker) -{ - return nullptr; -} - -checker::Type *OpaqueTypeNode::GetType([[maybe_unused]] checker::ETSChecker *checker) -{ - return TsType(); -} - -checker::VerifiedType OpaqueTypeNode::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - void OpaqueTypeNode::CleanCheckInformation() {} void OpaqueTypeNode::CleanUp() {} diff --git a/ets2panda/ir/opaqueTypeNode.h b/ets2panda/ir/opaqueTypeNode.h index a5948b290df4d957553d02dc3a509fb0ff5f9ae9..490be304d9accec67f2f01182e9a0a75e33e0fcc 100644 --- a/ets2panda/ir/opaqueTypeNode.h +++ b/ets2panda/ir/opaqueTypeNode.h @@ -45,7 +45,6 @@ public: void Compile([[maybe_unused]] compiler::PandaGen *pg) const override; void Compile([[maybe_unused]] compiler::ETSGen *etsg) const override; checker::Type *Check([[maybe_unused]] checker::TSChecker *checker) override; - checker::Type *GetType([[maybe_unused]] checker::TSChecker *checker) override; checker::VerifiedType Check([[maybe_unused]] checker::ETSChecker *checker) override; checker::Type *GetType([[maybe_unused]] checker::ETSChecker *checker) override; void CleanCheckInformation() override; diff --git a/ets2panda/ir/srcDump.cpp b/ets2panda/ir/srcDump.cpp index 6ea54b653fad7144c7aa58c0343d4566d5b96c45..fc03b3064e6badc254801190ceebdb744975dc4d 100644 --- a/ets2panda/ir/srcDump.cpp +++ b/ets2panda/ir/srcDump.cpp @@ -15,19 +15,183 @@ #include "srcDump.h" -#include -#include -#include -#include -#include -#include -#include +#include "public/public.h" -#include +#include "checker/types/type.h" +#include "checker/types/ets/etsFunctionType.h" +#include "checker/types/ets/etsObjectType.h" #include "util/helpers.h" +#include "ir/brokenTypeNode.h" +#include "ir/opaqueTypeNode.h" +#include "ir/annotationAllowed.h" + +#include "ir/module/exportAllDeclaration.h" +#include "ir/module/exportDefaultDeclaration.h" +#include "ir/module/exportNamedDeclaration.h" +#include "ir/module/exportSpecifier.h" +#include "ir/module/importDefaultSpecifier.h" +#include "ir/module/importNamespaceSpecifier.h" + +#include "ir/ets/etsClassLiteral.h" +#include "ir/ets/etsStructDeclaration.h" +#include "ir/ets/etsIntrinsicNode.h" +#include "ir/ets/etsUnionType.h" +#include "ir/ets/etsStringLiteralType.h" +#include "ir/ets/etsTuple.h" +#include "ir/ets/etsTypeReference.h" +#include "ir/ets/etsTypeReferencePart.h" +#include "ir/ets/etsNeverType.h" +#include "ir/ets/etsNullishTypes.h" +#include "ir/ets/etsReExportDeclaration.h" +#include "ir/ets/etsNewArrayInstanceExpression.h" +#include "ir/ets/etsNewMultiDimArrayInstanceExpression.h" +#include "ir/ets/etsNewClassInstanceExpression.h" +#include "ir/ets/etsFunctionType.h" +#include "ir/ets/etsNonNullishTypeNode.h" +#include "ir/ets/etsPackageDeclaration.h" +#include "ir/ets/etsPrimitiveType.h" +#include "ir/ets/etsWildcardType.h" +#include "ir/ets/etsKeyofType.h" +#include "ir/ets/etsModule.h" +#include "ir/ets/etsImportDeclaration.h" + +#include "ir/ts/tsAsExpression.h" +#include "ir/ts/tsEnumDeclaration.h" +#include "ir/ts/tsEnumMember.h" +#include "ir/ts/tsExternalModuleReference.h" +#include "ir/ts/tsNonNullExpression.h" +#include "ir/ts/tsTypeAssertion.h" +#include "ir/ts/tsAnyKeyword.h" +#include "ir/ts/tsArrayType.h" +#include "ir/ts/tsBigintKeyword.h" +#include "ir/ts/tsBooleanKeyword.h" +#include "ir/ts/tsLiteralType.h" +#include "ir/ts/tsNeverKeyword.h" +#include "ir/ts/tsNullKeyword.h" +#include "ir/ts/tsNumberKeyword.h" +#include "ir/ts/tsObjectKeyword.h" +#include "ir/ts/tsParenthesizedType.h" +#include "ir/ts/tsStringKeyword.h" +#include "ir/ts/tsTypeLiteral.h" +#include "ir/ts/tsUndefinedKeyword.h" +#include "ir/ts/tsUnionType.h" +#include "ir/ts/tsUnknownKeyword.h" +#include "ir/ts/tsVoidKeyword.h" +#include "ir/ts/tsConditionalType.h" +#include "ir/ts/tsConstructorType.h" +#include "ir/ts/tsFunctionType.h" +#include "ir/ts/tsImportEqualsDeclaration.h" +#include "ir/ts/tsImportType.h" +#include "ir/ts/tsInferType.h" +#include "ir/ts/tsIntersectionType.h" +#include "ir/ts/tsMappedType.h" +#include "ir/ts/tsModuleBlock.h" +#include "ir/ts/tsModuleDeclaration.h" +#include "ir/ts/tsParameterProperty.h" +#include "ir/ts/tsThisType.h" +#include "ir/ts/tsTypeAliasDeclaration.h" +#include "ir/ts/tsTypeOperator.h" +#include "ir/ts/tsTypeParameter.h" +#include "ir/ts/tsTypeParameterDeclaration.h" +#include "ir/ts/tsTypeParameterInstantiation.h" +#include "ir/ts/tsTypePredicate.h" +#include "ir/ts/tsTypeReference.h" +#include "ir/ts/tsClassImplements.h" +#include "ir/ts/tsIndexedAccessType.h" +#include "ir/ts/tsInterfaceBody.h" +#include "ir/ts/tsInterfaceDeclaration.h" +#include "ir/ts/tsInterfaceHeritage.h" +#include "ir/ts/tsNamedTupleMember.h" +#include "ir/ts/tsQualifiedName.h" +#include "ir/ts/tsTupleType.h" +#include "ir/ts/tsTypeQuery.h" + +#include "ir/base/spreadElement.h" +#include "ir/base/scriptFunction.h" +#include "ir/base/catchClause.h" +#include "ir/base/classDefinition.h" +#include "ir/base/classProperty.h" +#include "ir/base/classStaticBlock.h" +#include "ir/base/decorator.h" +#include "ir/base/methodDefinition.h" +#include "ir/base/metaProperty.h" +#include "ir/base/overloadDeclaration.h" +#include "ir/base/property.h" +#include "ir/base/tsMethodSignature.h" +#include "ir/base/tsPropertySignature.h" +#include "ir/base/tsSignatureDeclaration.h" +#include "ir/base/tsIndexSignature.h" + +#include "ir/expressions/assignmentExpression.h" +#include "ir/expressions/taggedTemplateExpression.h" +#include "ir/expressions/typeofExpression.h" +#include "ir/expressions/unaryExpression.h" +#include "ir/expressions/updateExpression.h" +#include "ir/expressions/yieldExpression.h" + +#include "ir/expressions/arrowFunctionExpression.h" +#include "ir/expressions/arrayExpression.h" +#include "ir/expressions/objectExpression.h" +#include "ir/expressions/sequenceExpression.h" +#include "ir/expressions/templateLiteral.h" +#include "ir/expressions/functionExpression.h" +#include "ir/expressions/awaitExpression.h" +#include "ir/expressions/binaryExpression.h" +#include "ir/expressions/callExpression.h" +#include "ir/expressions/classExpression.h" +#include "ir/expressions/chainExpression.h" +#include "ir/expressions/identifier.h" +#include "ir/expressions/importExpression.h" +#include "ir/expressions/dummyNode.h" +#include "ir/expressions/directEvalExpression.h" +#include "ir/expressions/blockExpression.h" +#include "ir/expressions/conditionalExpression.h" +#include "ir/expressions/thisExpression.h" +#include "ir/expressions/literals/undefinedLiteral.h" +#include "ir/expressions/literals/bigIntLiteral.h" +#include "ir/expressions/literals/booleanLiteral.h" +#include "ir/expressions/literals/charLiteral.h" +#include "ir/expressions/literals/nullLiteral.h" +#include "ir/expressions/literals/numberLiteral.h" +#include "ir/expressions/literals/stringLiteral.h" +#include "ir/expressions/literals/regExpLiteral.h" +#include "ir/expressions/memberExpression.h" +#include "ir/expressions/newExpression.h" +#include "ir/expressions/omittedExpression.h" +#include "ir/expressions/superExpression.h" + +#include "ir/statements/assertStatement.h" +#include "ir/statements/annotationDeclaration.h" +#include "ir/statements/breakStatement.h" +#include "ir/statements/blockStatement.h" +#include "ir/statements/continueStatement.h" +#include "ir/statements/debuggerStatement.h" +#include "ir/statements/doWhileStatement.h" +#include "ir/statements/emptyStatement.h" +#include "ir/statements/expressionStatement.h" +#include "ir/statements/forInStatement.h" +#include "ir/statements/forOfStatement.h" +#include "ir/statements/forUpdateStatement.h" +#include "ir/statements/labelledStatement.h" +#include "ir/statements/functionDeclaration.h" +#include "ir/statements/ifStatement.h" +#include "ir/statements/variableDeclaration.h" +#include "ir/statements/variableDeclarator.h" +#include "ir/statements/switchCaseStatement.h" +#include "ir/statements/switchStatement.h" +#include "ir/statements/tryStatement.h" +#include "ir/statements/throwStatement.h" +#include "ir/statements/whileStatement.h" + +#include "ir/as/namedType.h" +#include "ir/as/prefixAssertionExpression.h" + +#include "compiler/lowering/util.h" + #include #include + namespace ark::es2panda::ir { SrcDumper::SrcDumper(Declgen *dg) : dg_(dg) {} @@ -298,4 +462,2413 @@ void Declgen::Run() } } +void ImportDefaultSpecifier::Dump(ir::SrcDumper *dumper) const +{ + local_->Dump(dumper); +} +void TSTypeAssertion::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add("TSTypeAssertion"); +} +void TSThisType::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add("this"); +} +void TSIndexedAccessType::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add("TSIndexedAccessType"); +} +void TSParameterProperty::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add("TSParameterProperty"); +} +void TSModuleBlock::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add("TSModuleBlock"); +} +void TSImportEqualsDeclaration::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add("TSImportEqualsDeclaration"); +} +void TSModuleDeclaration::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add("TSModuleDeclaration"); +} +void ExportAllDeclaration::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add("ExportAllDeclaration"); +} +void ExportDefaultDeclaration::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add("ExportDefaultDeclaration"); +} +void BrokenTypeNode::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add(ERROR_TYPE); +} +void ThisExpression::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add("this"); +} +void FunctionExpression::Dump(ir::SrcDumper *dumper) const +{ + func_->Dump(dumper); +} + +void OmittedExpression::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add("OmittedExpression"); +} + +void DummyNode::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add(std::string(name_)); +} + +void YieldExpression::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add("YieldExpression"); +} + +void ClassExpression::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add("ClassExpression"); +} + +void SuperExpression::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add("super"); +} + +void ImportExpression::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add("ImportExpression"); +} +void TaggedTemplateExpression::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add("TaggedTemplateExpression"); +} +void BooleanLiteral::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add(boolean_ ? "true" : "false"); +} +void UndefinedLiteral::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add("undefined"); +} +void StringLiteral::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add("\"" + util::Helpers::CreateEscapedString(str_.Utf8()) + "\""); +} +void BigIntLiteral::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add(std::string(src_) + "n"); +} +void CharLiteral::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add("c\'" + ToString() + "\'"); +} + +void RegExpLiteral::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add(std::string(pattern_)); +} +void NullLiteral::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add("null"); +} +void NewExpression::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add("NewExpression"); +} +void TSSignatureDeclaration::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add("TSSignatureDeclaration"); +} +void TSMethodSignature::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add("TSMethodSignature"); +} + +void Decorator::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add("Decorator"); +} +void MetaProperty::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add("MetaProperty"); +} + +void TSPropertySignature::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add("TSPropertySignature"); +} +void TSIndexSignature::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add("TSIndexSignature"); +} +void TemplateElement::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add(std::string(raw_)); +} +void AssertStatement::Dump([[maybe_unused]] ir::SrcDumper *dumper) const +{ + ES2PANDA_UNREACHABLE(); +} +void EmptyStatement::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add(""); +} +void DebuggerStatement::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add("DebuggerStatement"); +} + +void ForInStatement::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add("ForInStatement"); +} + +template +void DumpAnnotations(const AnnotationAllowed *node, ir::SrcDumper *dumper) +{ + node->IterateAnnotations([dumper](auto *anno) { anno->Dump(dumper); }); +} + +void NamedType::Dump(SrcDumper *dumper) const +{ + DumpAnnotations(this, dumper); + dumper->Add("NamedType"); +} + +void ETSNeverType::Dump(ir::SrcDumper *dumper) const +{ + DumpAnnotations(this, dumper); + dumper->Add("never"); +} +void ETSUndefinedType::Dump(ir::SrcDumper *dumper) const +{ + DumpAnnotations(this, dumper); + dumper->Add("undefined"); +} +void ETSNullType::Dump(ir::SrcDumper *dumper) const +{ + DumpAnnotations(this, dumper); + dumper->Add("null"); +} +void ETSWildcardType::Dump(ir::SrcDumper *dumper) const +{ + DumpAnnotations(this, dumper); + dumper->Add("ETSWildcardType"); +} + +void ETSStringLiteralType::Dump(ir::SrcDumper *dumper) const +{ + DumpAnnotations(this, dumper); + dumper->Add("\"" + value_.Mutf8() + "\""); +} + +void TSUndefinedKeyword::Dump(ir::SrcDumper *dumper) const +{ + DumpAnnotations(this, dumper); + dumper->Add("TSUndefinedKeyword"); +} +void TSBooleanKeyword::Dump(ir::SrcDumper *dumper) const +{ + DumpAnnotations(this, dumper); + dumper->Add("TSBooleanKeyword"); +} +void TSConditionalType::Dump(ir::SrcDumper *dumper) const +{ + DumpAnnotations(this, dumper); + dumper->Add("TSConditionalType"); +} +void TSMappedType::Dump(ir::SrcDumper *dumper) const +{ + DumpAnnotations(this, dumper); + dumper->Add("TSMappedType"); +} +void TSTypePredicate::Dump(ir::SrcDumper *dumper) const +{ + DumpAnnotations(this, dumper); + dumper->Add("TSTypePredicate"); +} +void TSParenthesizedType::Dump(ir::SrcDumper *dumper) const +{ + DumpAnnotations(this, dumper); + dumper->Add("TSParenthesizedType"); +} +void TSStringKeyword::Dump(ir::SrcDumper *dumper) const +{ + DumpAnnotations(this, dumper); + dumper->Add("TSStringKeyword"); +} +void TSConstructorType::Dump(ir::SrcDumper *dumper) const +{ + DumpAnnotations(this, dumper); + dumper->Add("TSConstructorType"); +} +void TSTypeOperator::Dump(ir::SrcDumper *dumper) const +{ + DumpAnnotations(this, dumper); + dumper->Add("TSTypeOperator"); +} + +void TSInferType::Dump(ir::SrcDumper *dumper) const +{ + DumpAnnotations(this, dumper); + dumper->Add("TSInferType"); +} +void TSTypeLiteral::Dump(ir::SrcDumper *dumper) const +{ + DumpAnnotations(this, dumper); + dumper->Add("TSTypeLiteral"); +} +void TSTypeReference::Dump(ir::SrcDumper *dumper) const +{ + DumpAnnotations(this, dumper); + BaseName()->Dump(dumper); +} +void TSAnyKeyword::Dump(ir::SrcDumper *dumper) const +{ + DumpAnnotations(this, dumper); + dumper->Add("TSAnyKeyword"); +} +void TSBigintKeyword::Dump(ir::SrcDumper *dumper) const +{ + DumpAnnotations(this, dumper); + dumper->Add("TSBigintKeyword"); +} +void TSNullKeyword::Dump(ir::SrcDumper *dumper) const +{ + DumpAnnotations(this, dumper); + dumper->Add("TSNullKeyword"); +} +void TSTupleType::Dump(ir::SrcDumper *dumper) const +{ + DumpAnnotations(this, dumper); + dumper->Add("TSTupleType"); +} +void TSVoidKeyword::Dump(ir::SrcDumper *dumper) const +{ + DumpAnnotations(this, dumper); + dumper->Add("TSVoidKeyword"); +} + +void TSLiteralType::Dump(ir::SrcDumper *dumper) const +{ + DumpAnnotations(this, dumper); + dumper->Add("TSLiteralType"); +} +void TSNamedTupleMember::Dump(ir::SrcDumper *dumper) const +{ + DumpAnnotations(this, dumper); + dumper->Add("TSNamedTupleMember"); +} +void TSNeverKeyword::Dump(ir::SrcDumper *dumper) const +{ + DumpAnnotations(this, dumper); + dumper->Add("TSNeverKeyword"); +} +void TSObjectKeyword::Dump(ir::SrcDumper *dumper) const +{ + DumpAnnotations(this, dumper); + dumper->Add("TSObjectKeyword"); +} +void TSInterfaceHeritage::Dump(ir::SrcDumper *dumper) const +{ + ES2PANDA_ASSERT(expr_ != nullptr); + expr_->Dump(dumper); +} + +void TSTypeQuery::Dump(ir::SrcDumper *dumper) const +{ + DumpAnnotations(this, dumper); + dumper->Add("TSTypeQuery"); +} +void TSFunctionType::Dump(ir::SrcDumper *dumper) const +{ + DumpAnnotations(this, dumper); + dumper->Add("TSFunctionType"); +} + +void TSIntersectionType::Dump(ir::SrcDumper *dumper) const +{ + DumpAnnotations(this, dumper); + dumper->Add("TSIntersectionType"); +} +void TSNumberKeyword::Dump(ir::SrcDumper *dumper) const +{ + DumpAnnotations(this, dumper); + dumper->Add("TSNumberKeyword"); +} + +void TSClassImplements::Dump(ir::SrcDumper *dumper) const +{ + expression_->Dump(dumper); + ES2PANDA_ASSERT(typeParameters_ == nullptr); +} +void TSUnionType::Dump(ir::SrcDumper *dumper) const +{ + DumpAnnotations(this, dumper); + dumper->Add("TSUnionType"); +} +void TSUnknownKeyword::Dump(ir::SrcDumper *dumper) const +{ + DumpAnnotations(this, dumper); + dumper->Add("TSUnknownKeyword"); +} +void TSImportType::Dump(ir::SrcDumper *dumper) const +{ + DumpAnnotations(this, dumper); + dumper->Add("TSImportType"); +} + +void OpaqueTypeNode::Dump(ir::SrcDumper *dumper) const +{ + DumpAnnotations(this, dumper); + dumper->Add(TsType()->ToString()); +} + +void ETSStructDeclaration::Dump(ir::SrcDumper *dumper) const +{ + if (Definition() != nullptr) { + Definition()->Dump(dumper); + } +} +void ETSTypeReference::Dump(ir::SrcDumper *dumper) const +{ + DumpAnnotations(this, dumper); + ES2PANDA_ASSERT(Part() != nullptr); + Part()->Dump(dumper); +} + +void ETSKeyofType::Dump(ir::SrcDumper *dumper) const +{ + DumpAnnotations(this, dumper); + dumper->Add("keyof "); + type_->Dump(dumper); +} +void TSNonNullExpression::Dump(ir::SrcDumper *dumper) const +{ + ES2PANDA_ASSERT(expr_ != nullptr); + expr_->Dump(dumper); + dumper->Add("!"); +} +void TSInterfaceBody::Dump(ir::SrcDumper *dumper) const +{ + for (auto b : body_) { + b->Dump(dumper); + } +} +void TSQualifiedName::Dump(ir::SrcDumper *dumper) const +{ + left_->Dump(dumper); + dumper->Add("."); + right_->Dump(dumper); +} +void ChainExpression::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add("("); // affects precedence + expression_->Dump(dumper); + dumper->Add(")"); +} +void TypeofExpression::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add("(typeof "); + argument_->Dump(dumper); + dumper->Add(")"); +} + +void ThrowStatement::Dump(ir::SrcDumper *dumper) const +{ + ES2PANDA_ASSERT(Argument() != nullptr); + dumper->Add("throw "); + Argument()->Dump(dumper); + dumper->Add(";"); +} + +void ETSTypeReferencePart::Dump(ir::SrcDumper *dumper) const +{ + ES2PANDA_ASSERT(Name() != nullptr); + Name()->Dump(dumper); + if (TypeParams() != nullptr) { + TypeParams()->Dump(dumper); + } +} + +void AwaitExpression::Dump(ir::SrcDumper *dumper) const +{ + if (argument_ != nullptr) { + dumper->Add("await "); + argument_->Dump(dumper); + } +} +void ClassDeclaration::Dump(ir::SrcDumper *dumper) const +{ + if (Definition() != nullptr) { + Definition()->Dump(dumper); + } +} + +void ETSPackageDeclaration::Dump(ir::SrcDumper *dumper) const +{ + if (dumper->IsDeclgen()) { + return; + } + dumper->Add("package "); + name_->Dump(dumper); + dumper->Add(";"); + dumper->Endl(); +} + +void ETSNonNullishTypeNode::Dump(ir::SrcDumper *dumper) const +{ + DumpAnnotations(this, dumper); + dumper->Add("NonNullable<"); + typeNode_->Dump(dumper); + dumper->Add(">"); +} +void TSAsExpression::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add("("); + expression_->Dump(dumper); + dumper->Add(" as "); + TypeAnnotation()->Dump(dumper); + dumper->Add(")"); +} +void ImportSpecifier::Dump(ir::SrcDumper *dumper) const +{ + imported_->Dump(dumper); + if (local_ != nullptr) { + dumper->Add(" as "); + local_->Dump(dumper); + } +} +void ImportNamespaceSpecifier::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add("* "); + if (!local_->Name().Empty()) { + dumper->Add("as "); + } + local_->Dump(dumper); +} +void Property::Dump(ir::SrcDumper *dumper) const +{ + if (kind_ == PropertyKind::INIT) { + key_->Dump(dumper); + dumper->Add(": "); + value_->Dump(dumper); + } +} +void LabelledStatement::Dump(ir::SrcDumper *dumper) const +{ + ES2PANDA_ASSERT(ident_ != nullptr); + ident_->Dump(dumper); + dumper->Add(":"); + dumper->Endl(); + body_->Dump(dumper); +} +void ExpressionStatement::Dump(ir::SrcDumper *dumper) const +{ + ES2PANDA_ASSERT(expression_ != nullptr); + expression_->Dump(dumper); + if ((parent_ != nullptr) && (parent_->IsBlockStatement() || parent_->IsSwitchCaseStatement())) { + dumper->Add(";"); + } +} + +void TSEnumMember::Dump(ir::SrcDumper *dumper) const +{ + ES2PANDA_ASSERT(key_ != nullptr); + key_->Dump(dumper); + if (init_ != nullptr) { + dumper->Add(" = "); + init_->Dump(dumper); + } +} +void TSTypeParameterDeclaration::Dump(ir::SrcDumper *dumper) const +{ + for (auto param : Params()) { + param->Dump(dumper); + if (param != Params().back()) { + dumper->Add(", "); + } + } +} +void SequenceExpression::Dump(ir::SrcDumper *dumper) const +{ + for (auto *expr : sequence_) { + expr->Dump(dumper); + if (expr != sequence_.back()) { + dumper->Add(", "); + } + } +} + +void ReturnStatement::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add("return"); + if (argument_ != nullptr) { + dumper->Add(" "); + argument_->Dump(dumper); + } + dumper->Add(";"); +} +void ContinueStatement::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add("continue"); + if (Ident() != nullptr) { + dumper->Add(" "); + Ident()->Dump(dumper); + } + dumper->Add(";"); +} +void BreakStatement::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add("break"); + if (ident_ != nullptr) { + dumper->Add(" "); + ident_->Dump(dumper); + } + dumper->Add(";"); +} + +void ETSNewArrayInstanceExpression::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add("new "); + ES2PANDA_ASSERT(typeReference_); + typeReference_->Dump(dumper); + ES2PANDA_ASSERT(dimension_); + dumper->Add("["); + dimension_->Dump(dumper); + dumper->Add("]"); +} +void AssignmentExpression::Dump(ir::SrcDumper *dumper) const +{ + ES2PANDA_ASSERT(left_); + left_->Dump(dumper); + dumper->Add(" "); + dumper->Add(TokenToString(operator_)); + dumper->Add(" "); + ES2PANDA_ASSERT(right_); + right_->Dump(dumper); +} +void ArrowFunctionExpression::Dump(ir::SrcDumper *dumper) const +{ + DumpAnnotations(this, dumper); + dumper->Add("("); + if (func_->IsScriptFunction() && func_->AsScriptFunction()->IsAsyncFunc()) { + dumper->Add("async "); + } + func_->Dump(dumper); + dumper->Add(")"); +} + +void SpreadElement::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add("..."); + argument_->Dump(dumper); + auto type = TypeAnnotation(); + if (type != nullptr && type->IsValidInCurrentPhase()) { + dumper->Add(": "); + type->Dump(dumper); + } +} + +void ETSNewMultiDimArrayInstanceExpression::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add("new "); + ES2PANDA_ASSERT(typeReference_); + typeReference_->Dump(dumper); + for (auto dim : dimensions_) { + dumper->Add("["); + dim->Dump(dumper); + dumper->Add("]"); + } +} +void TSTypeParameterInstantiation::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add("<"); + for (auto param : params_) { + param->Dump(dumper); + if (param != params_.back()) { + dumper->Add(", "); + } + } + dumper->Add(">"); +} +void BlockExpression::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add("({"); + for (auto *statement : statements_) { + statement->Dump(dumper); + if (statement != statements_.back()) { + dumper->Endl(); + } + } + dumper->Add("})"); +} +void ArrayExpression::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add("["); + for (auto element : elements_) { + element->Dump(dumper); + if (element != elements_.back()) { + dumper->Add(", "); + } + } + dumper->Add("]"); +} +void UnaryExpression::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add(TokenToString(operator_)); + if (!argument_->IsIdentifier()) { + dumper->Add("("); + argument_->Dump(dumper); + dumper->Add(")"); + } else { + argument_->Dump(dumper); + } +} + +// 11 + +void ETSUnionType::Dump(ir::SrcDumper *dumper) const +{ + DumpAnnotations(this, dumper); + dumper->Add("("); + for (auto type : Types()) { + type->Dump(dumper); + if (type != Types().back()) { + dumper->Add(" | "); + } + } + dumper->Add(")"); +} +void ETSTuple::Dump(ir::SrcDumper *const dumper) const +{ + DumpAnnotations(this, dumper); + dumper->Add("["); + for (const auto *const typeAnnot : typeAnnotationList_) { + typeAnnot->Dump(dumper); + if (typeAnnot != typeAnnotationList_.back()) { + dumper->Add(", "); + } + } + dumper->Add("]"); +} + +void BinaryExpression::Dump(ir::SrcDumper *dumper) const +{ + ES2PANDA_ASSERT(left_ != nullptr); + ES2PANDA_ASSERT(right_ != nullptr); + dumper->Add("(("); + left_->Dump(dumper); + dumper->Add(") "); + dumper->Add(TokenToString(operator_)); + dumper->Add(" ("); + right_->Dump(dumper); + dumper->Add("))"); +} + +void ETSIntrinsicNode::Dump([[maybe_unused]] ir::SrcDumper *dumper) const +{ + dumper->Add("%%intrin%%"); + dumper->Add(Id().Mutf8()); + dumper->Add("("); + for (auto arg : arguments_) { + arg->Dump(dumper); + if (arg != arguments_.back()) { + dumper->Add(", "); + } + } + dumper->Add(")"); +} + +void UpdateExpression::Dump(ir::SrcDumper *dumper) const +{ + ES2PANDA_ASSERT(argument_); + dumper->Add("("); + if (prefix_) { + dumper->Add(TokenToString(operator_)); + argument_->Dump(dumper); + } else { + argument_->Dump(dumper); + dumper->Add(TokenToString(operator_)); + } + dumper->Add(")"); +} + +void OverloadDeclaration::DumpModifier(ir::SrcDumper *dumper) const +{ + if (compiler::HasGlobalClassParent(this) && !dumper->IsDeclgen()) { + if (IsExported()) { + dumper->Add("export "); + } + } + + if (Parent() != nullptr && Parent()->IsClassDefinition() && !Parent()->AsClassDefinition()->IsLocal() && + !compiler::HasGlobalClassParent(this)) { + if (IsPrivate()) { + dumper->Add("private "); + } else if (IsProtected()) { + dumper->Add("protected "); + } else { + dumper->Add("public "); + } + + if (IsStatic()) { + dumper->Add("static "); + } + } + + if (IsAsync()) { + dumper->Add("async "); + } +} + +void OverloadDeclaration::Dump(ir::SrcDumper *dumper) const +{ + DumpModifier(dumper); + dumper->Add("overload "); + dumper->Add(IsConstructor() ? "constructor " : key_->AsIdentifier()->Name().Mutf8()); + dumper->Add("{"); + for (size_t i = 0; i < overloadedList_.size(); i++) { + if (i != 0) { + dumper->Add(", "); + } + overloadedList_[i]->Dump(dumper); + } + dumper->Add("};"); +} + +void ClassStaticBlock::Dump(ir::SrcDumper *dumper) const +{ + if (dumper->IsDeclgen()) { + return; + } + + ES2PANDA_ASSERT(value_); + ES2PANDA_ASSERT(value_->IsFunctionExpression()); + ES2PANDA_ASSERT(value_->AsFunctionExpression()->Function()->IsScriptFunction()); + dumper->Add("static {"); + dumper->IncrIndent(); + dumper->Endl(); + const auto *scriptFunc = value_->AsFunctionExpression()->Function()->AsScriptFunction(); + ES2PANDA_ASSERT(scriptFunc->HasBody()); + scriptFunc->Body()->Dump(dumper); + dumper->DecrIndent(); + dumper->Endl(); + dumper->Add("}"); +} + +void WhileStatement::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add("while ("); + if (test_ != nullptr) { + test_->Dump(dumper); + } + dumper->Add(") {"); + if (body_ != nullptr) { + dumper->IncrIndent(); + dumper->Endl(); + body_->Dump(dumper); + dumper->DecrIndent(); + dumper->Endl(); + } + dumper->Add("}"); +} + +bool TSEnumDeclaration::RegisterUnexportedForDeclGen(ir::SrcDumper *dumper) const +{ + ES2PANDA_ASSERT(dumper->IsDeclgen()); + + if (dumper->GetDeclgen()->IsPostDumpIndirectDepsPhase()) { + return false; + } + + if (key_->Parent()->IsDefaultExported() || key_->Parent()->IsExported()) { + return false; + } + + auto name = key_->AsIdentifier()->Name().Mutf8(); + dumper->GetDeclgen()->AddNode(name, this); + return true; +} + +void TSEnumDeclaration::Dump(ir::SrcDumper *dumper) const +{ + auto guard = dumper->BuildAmbientContextGuard(); + ES2PANDA_ASSERT(isConst_ == false); + ES2PANDA_ASSERT(key_ != nullptr); + if (dumper->IsDeclgen() && RegisterUnexportedForDeclGen(dumper)) { + return; + } + if (key_->Parent()->IsExported() && dumper->IsDeclgen()) { + dumper->Add("export "); + } else if (key_->Parent()->IsDefaultExported() && dumper->IsDeclgen()) { + dumper->Add("export default "); + } + if (dumper->IsDeclgen()) { + dumper->GetDeclgen()->TryDeclareAmbientContext(dumper); + } else if (IsDeclare()) { + dumper->Add("declare "); + } + dumper->Add("enum "); + Key()->Dump(dumper); + dumper->Add(" {"); + auto const members = Members(); + if (!members.empty()) { + dumper->IncrIndent(); + dumper->Endl(); + for (auto member : members) { + member->Dump(dumper); + if (member != members.back()) { + dumper->Add(","); + dumper->Endl(); + } + } + dumper->DecrIndent(); + dumper->Endl(); + } + dumper->Add("}"); + dumper->Endl(); +} + +bool TSTypeAliasDeclaration::RegisterUnexportedForDeclGen(ir::SrcDumper *dumper) const +{ + ES2PANDA_ASSERT(dumper->IsDeclgen()); + + if (dumper->GetDeclgen()->IsPostDumpIndirectDepsPhase()) { + return false; + } + + if (id_->Parent()->IsExported() || id_->Parent()->IsDefaultExported()) { + return false; + } + + auto name = id_->Name().Mutf8(); + dumper->GetDeclgen()->AddNode(name, this); + return true; +} + +void TSTypeAliasDeclaration::Dump(ir::SrcDumper *dumper) const +{ + ES2PANDA_ASSERT(id_); + if (dumper->IsDeclgen() && RegisterUnexportedForDeclGen(dumper)) { + return; + } + DumpAnnotations(this, dumper); + if (id_->Parent()->IsExported()) { + dumper->Add("export "); + } + dumper->Add("type "); + Id()->Dump(dumper); + auto const typeParams = TypeParams(); + if (typeParams != nullptr) { + dumper->Add("<"); + typeParams->Dump(dumper); + dumper->Add(">"); + } + dumper->Add(" = "); + if (Id()->IsAnnotatedExpression()) { + auto type = TypeAnnotation(); + ES2PANDA_ASSERT(type); + type->Dump(dumper); + } + dumper->Add(";"); + dumper->Endl(); +} + +void ScriptFunction::DumpCheckerTypeForDeclGen(ir::SrcDumper *dumper) const +{ + ES2PANDA_ASSERT(dumper->IsDeclgen()); + + if (IsConstructor()) { + return; + } + + if (IsSetter()) { + return; + } + + if (Signature() == nullptr) { + return; + } + + if (Signature()->ReturnType() == nullptr) { + return; + } + + auto typeStr = Signature()->ReturnType()->ToString(); + dumper->Add(": "); + dumper->Add(typeStr); + + dumper->GetDeclgen()->PushTask([dumper, typeStr] { dumper->GetDeclgen()->DumpNode(dumper, typeStr); }); +} + +void ScriptFunction::Dump(ir::SrcDumper *dumper) const +{ + if (TypeParams() != nullptr) { + dumper->Add("<"); + TypeParams()->Dump(dumper); + dumper->Add(">"); + } + dumper->Add("("); + for (auto param : Params()) { + param->Dump(dumper); + if (param != Params().back()) { + dumper->Add(", "); + } + } + dumper->Add(")"); + if (ReturnTypeAnnotation() != nullptr) { + dumper->Add(": "); + ReturnTypeAnnotation()->Dump(dumper); + } else if (dumper->IsDeclgen()) { + DumpCheckerTypeForDeclGen(dumper); + } + if (dumper->IsDeclgen()) { + dumper->Add(";"); + dumper->Endl(); + return; + } + DumpBody(dumper); +} + +void ScriptFunction::DumpBody(ir::SrcDumper *dumper) const +{ + if (!HasBody()) { + dumper->Endl(); + return; + } + + if (IsArrow()) { + dumper->Add(" =>"); + } + + if (body_->IsBlockStatement()) { + dumper->Add(" {"); + const auto &statements = body_->AsBlockStatement()->Statements(); + if (!statements.empty()) { + dumper->IncrIndent(); + dumper->Endl(); + body_->Dump(dumper); + dumper->DecrIndent(); + dumper->Endl(); + } + dumper->Add("}"); + } else { + dumper->Add(" "); + body_->Dump(dumper); + } + + if (!IsArrow()) { + dumper->Endl(); + } +} + +void ForUpdateStatement::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add("for "); + dumper->Add("("); + if (init_ != nullptr) { + init_->Dump(dumper); + } + dumper->Add(";"); + if (test_ != nullptr) { + test_->Dump(dumper); + } + dumper->Add(";"); + if (update_ != nullptr) { + update_->Dump(dumper); + } + dumper->Add(") "); + dumper->Add("{"); + if (body_ != nullptr) { + dumper->IncrIndent(); + dumper->Endl(); + body_->Dump(dumper); + dumper->DecrIndent(); + dumper->Endl(); + } + dumper->Add("}"); +} + +void BlockStatement::Dump(ir::SrcDumper *dumper) const +{ + auto const &statements = Statements(); + // NOTE(nsizov): trailing blocks + if (Parent() != nullptr && (Parent()->IsBlockStatement() || Parent()->IsCallExpression())) { + dumper->Add("{"); + if (!statements.empty()) { + dumper->IncrIndent(); + dumper->Endl(); + } + } + for (auto statement : statements) { + statement->Dump(dumper); + if (statement != statements.back()) { + dumper->Endl(); + } + } + if (Parent() != nullptr && (Parent()->IsBlockStatement() || Parent()->IsCallExpression())) { + if (!statements.empty()) { + dumper->DecrIndent(); + dumper->Endl(); + } + dumper->Add("}"); + } +} + +void TryStatement::Dump(ir::SrcDumper *dumper) const +{ + ES2PANDA_ASSERT(block_ != nullptr); + dumper->Add("try {"); + dumper->IncrIndent(); + dumper->Endl(); + block_->Dump(dumper); + dumper->DecrIndent(); + dumper->Endl(); + dumper->Add("}"); + for (auto clause : catchClauses_) { + dumper->Add(" catch "); + clause->Dump(dumper); + } + if (finalizer_ != nullptr) { + dumper->Add(" finally {"); + dumper->IncrIndent(); + dumper->Endl(); + finalizer_->Dump(dumper); + dumper->DecrIndent(); + dumper->Endl(); + dumper->Add("}"); + } +} +void SwitchCaseStatement::Dump(ir::SrcDumper *dumper) const +{ + if (test_ != nullptr) { + dumper->Add("case "); + test_->Dump(dumper); + dumper->Add(":"); + } else { + dumper->Add("default:"); + } + if (!consequent_.empty()) { + dumper->Add(" {"); + dumper->IncrIndent(); + dumper->Endl(); + for (auto cs : consequent_) { + cs->Dump(dumper); + if (!cs->IsBlockStatement() && cs != consequent_.back()) { + dumper->Endl(); + } + } + dumper->DecrIndent(); + dumper->Endl(); + dumper->Add("}"); + } +} + +void IfStatement::Dump(ir::SrcDumper *dumper) const +{ + ES2PANDA_ASSERT(test_); + ES2PANDA_ASSERT(consequent_ != nullptr); + dumper->Add("if ("); + test_->Dump(dumper); + dumper->Add(") {"); + dumper->IncrIndent(); + dumper->Endl(); + consequent_->Dump(dumper); + dumper->DecrIndent(); + dumper->Endl(); + dumper->Add("}"); + if (alternate_ != nullptr) { + dumper->Add(" else {"); + dumper->IncrIndent(); + dumper->Endl(); + alternate_->Dump(dumper); + dumper->DecrIndent(); + dumper->Endl(); + dumper->Add("}"); + } +} + +void ForOfStatement::Dump(ir::SrcDumper *dumper) const +{ + ES2PANDA_ASSERT(left_ != nullptr); + ES2PANDA_ASSERT(right_ != nullptr); + dumper->Add("for "); + if (isAwait_) { + dumper->Add("await "); + } + dumper->Add("("); + left_->Dump(dumper); + dumper->Add(" of "); + right_->Dump(dumper); + dumper->Add(") {"); + if (body_ != nullptr) { + dumper->IncrIndent(); + dumper->Endl(); + body_->Dump(dumper); + dumper->DecrIndent(); + dumper->Endl(); + } + dumper->Add("}"); +} + +void VariableDeclarator::Dump(ir::SrcDumper *dumper) const +{ + if (id_ != nullptr) { + id_->Dump(dumper); + if (id_->IsOptionalDeclaration()) { + dumper->Add("?"); + } + if (id_->IsAnnotatedExpression()) { + auto *type = id_->AsAnnotatedExpression()->TypeAnnotation(); + if (type != nullptr) { + dumper->Add(": "); + type->Dump(dumper); + } + } + } + if (init_ != nullptr) { + dumper->Add(" = "); + init_->Dump(dumper); + } +} + +void ConditionalExpression::Dump(ir::SrcDumper *dumper) const +{ + ES2PANDA_ASSERT(test_ != nullptr); + dumper->Add("("); + test_->Dump(dumper); + dumper->Add(" ? "); + if (consequent_ != nullptr) { + consequent_->Dump(dumper); + } + dumper->Add(" : "); + if (alternate_ != nullptr) { + alternate_->Dump(dumper); + } + dumper->Add(")"); + if ((parent_ != nullptr) && (parent_->IsBlockStatement() || parent_->IsBlockExpression())) { + dumper->Add(";"); + dumper->Endl(); + } +} +void CatchClause::Dump(ir::SrcDumper *dumper) const +{ + ES2PANDA_ASSERT(body_ != nullptr); + dumper->Add("("); + if (param_ != nullptr) { + param_->Dump(dumper); + if (param_->IsIdentifier() && param_->AsIdentifier()->TypeAnnotation() != nullptr) { + dumper->Add(": "); + param_->AsIdentifier()->TypeAnnotation()->Dump(dumper); + } + } + dumper->Add(") {"); + dumper->IncrIndent(); + dumper->Endl(); + body_->Dump(dumper); + dumper->DecrIndent(); + dumper->Endl(); + dumper->Add("}"); +} +void SwitchStatement::Dump(ir::SrcDumper *dumper) const +{ + ES2PANDA_ASSERT(discriminant_); + dumper->Add("switch ("); + discriminant_->Dump(dumper); + dumper->Add(") {"); + if (!cases_.empty()) { + dumper->IncrIndent(); + dumper->Endl(); + for (auto cs : cases_) { + cs->Dump(dumper); + if (cs == cases_.back()) { + dumper->DecrIndent(); + } + dumper->Endl(); + } + } + dumper->Add("}"); +} + +void ObjectExpression::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add("{"); + if (!properties_.empty()) { + dumper->IncrIndent(); + dumper->Endl(); + for (auto property : properties_) { + property->Dump(dumper); + dumper->Add(","); + if (property == properties_.back()) { + dumper->DecrIndent(); + } + dumper->Endl(); + } + } + dumper->Add("}"); +} +void DoWhileStatement::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add("do {"); + if (body_ != nullptr) { + dumper->IncrIndent(); + dumper->Endl(); + body_->Dump(dumper); + dumper->DecrIndent(); + dumper->Endl(); + } + dumper->Add("} while"); + dumper->Add("("); + if (test_ != nullptr) { + test_->Dump(dumper); + } + dumper->Add(")"); +} + +void TSExternalModuleReference::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add("TSExternalModuleReference"); +} + +void PrefixAssertionExpression::Dump(SrcDumper *dumper) const +{ + dumper->Add("PrefixAssertionExpression"); +} + +void ETSClassLiteral::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add("ETSClassLiteral"); +} + +template +void DumpItems(ir::SrcDumper *dumper, const std::string &prefix, const ArenaVector &items) +{ + if (items.empty()) { + return; + } + dumper->Add(prefix); + for (size_t i = 0; i < items.size(); ++i) { + items[i]->Dump(dumper); + if (i < items.size() - 1) { + dumper->Add(", "); + } + } +} +void ClassDefinition::DumpGlobalClass(ir::SrcDumper *dumper) const +{ + ES2PANDA_ASSERT(IsGlobal()); + ir::ClassStaticBlock *classStaticBlock = nullptr; + for (auto elem : Body()) { + if (elem->IsClassProperty()) { + elem->Dump(dumper); + dumper->Endl(); + } + + if (elem->IsClassStaticBlock()) { + classStaticBlock = elem->AsClassStaticBlock(); + } + } + for (auto elem : Body()) { + if (elem->IsMethodDefinition()) { + elem->Dump(dumper); + dumper->Endl(); + } + } + + if (classStaticBlock == nullptr || dumper->IsDeclgen()) { + return; + } + + auto bodyStmts = + classStaticBlock->Value()->AsFunctionExpression()->Function()->Body()->AsBlockStatement()->Statements(); + for (auto statement : bodyStmts) { + if (statement->IsExpressionStatement() && + statement->AsExpressionStatement()->GetExpression()->IsAssignmentExpression() && + statement->AsExpressionStatement()->GetExpression()->AsAssignmentExpression()->IsIgnoreConstAssign()) { + // skip the dummy assignment expression created for const variable decl in the class static block. + continue; + } + statement->Dump(dumper); + if (statement != bodyStmts.back()) { + dumper->Endl(); + } + } +} + +// This method is needed by OHOS CI code checker +void ClassDefinition::DumpBody(ir::SrcDumper *dumper) const +{ + auto const body = Body(); + dumper->Add(" {"); + if (!body.empty()) { + dumper->IncrIndent(); + dumper->Endl(); + for (auto elem : body) { + elem->Dump(dumper); + if (elem == body.back()) { + dumper->DecrIndent(); + } + dumper->Endl(); + } + } + dumper->Add("}"); +} + +void ClassDefinition::DumpPrefix(ir::SrcDumper *dumper) const +{ + if (IsExported()) { + dumper->Add("export "); + } else if (IsDefaultExported()) { + dumper->Add("export default "); + } + + if (dumper->IsDeclgen()) { + dumper->GetDeclgen()->TryDeclareAmbientContext(dumper); + } else if (IsDeclare()) { + dumper->Add("declare "); + } + + if (IsFinal()) { + dumper->Add("final "); + } + + if (IsAbstract() && !IsNamespaceTransformed()) { + dumper->Add("abstract "); + } + + if (parent_->IsETSStructDeclaration() || IsFromStruct()) { + dumper->Add("struct "); + } else if (IsNamespaceTransformed()) { + dumper->Add("namespace "); + } else { + dumper->Add("class "); + } +} + +bool ClassDefinition::RegisterUnexportedForDeclGen(ir::SrcDumper *dumper) const +{ + ES2PANDA_ASSERT(dumper->IsDeclgen()); + + if (dumper->GetDeclgen()->IsPostDumpIndirectDepsPhase()) { + return false; + } + + if (IsExported() || IsDefaultExported()) { + return false; + } + + const auto className = ident_->Name().Mutf8(); + dumper->GetDeclgen()->AddNode(className, this); + return true; +} + +void ClassDefinition::Dump(ir::SrcDumper *dumper) const +{ + auto guard = dumper->BuildAmbientContextGuard(); + // NOTE: plugin API fails + auto const ident = Ident(); + if ((ident->Name().StartsWith("$dynmodule")) || (ident->Name().StartsWith("$jscall"))) { + return; + } + + if (IsGlobal()) { + DumpGlobalClass(dumper); + return; + } + + ES2PANDA_ASSERT(ident_ != nullptr); + + if (dumper->IsDeclgen() && !IsNamespaceTransformed() && RegisterUnexportedForDeclGen(dumper)) { + return; + } + + DumpAnnotations(this, dumper); + + DumpPrefix(dumper); + ident_->Dump(dumper); + + if (TypeParams() != nullptr) { + dumper->Add("<"); + TypeParams()->Dump(dumper); + dumper->Add("> "); + } + + if (SuperClass() != nullptr) { + dumper->Add(" extends "); + SuperClass()->Dump(dumper); + } + + DumpItems(dumper, " implements ", Implements()); + + if (!IsDeclare() || !Body().empty()) { + DumpBody(dumper); + } + if (IsLocal()) { + dumper->Add(";"); + } + dumper->Endl(); +} + +void AnnotationDeclaration::Dump(ir::SrcDumper *dumper) const +{ + auto guard = dumper->BuildAmbientContextGuard(); + DumpAnnotations(this, dumper); + ES2PANDA_ASSERT(Expr() != nullptr); + if (IsExported()) { + dumper->Add("export "); + } + if (dumper->IsDeclgen()) { + dumper->GetDeclgen()->TryDeclareAmbientContext(dumper); + } + dumper->Add("@interface "); + Expr()->Dump(dumper); + dumper->Add(" {"); + + auto const properties = Properties(); + if (!properties.empty()) { + dumper->IncrIndent(); + dumper->Endl(); + for (auto elem : properties) { + elem->Dump(dumper); + if (elem != properties.back()) { + dumper->Endl(); + } + } + dumper->DecrIndent(); + dumper->Endl(); + } + dumper->Add("}"); +} + +void ClassProperty::DumpModifiers(ir::SrcDumper *dumper) const +{ + ES2PANDA_ASSERT(key_); + + if (compiler::HasGlobalClassParent(this)) { + if (IsExported()) { + dumper->Add("export "); + } + if (dumper->IsDeclgen()) { + dumper->Add("declare "); + } + if (IsConst()) { + dumper->Add("const "); + } else { + dumper->Add("let "); + } + return; + } + + if (Parent() != nullptr && Parent()->IsClassDefinition() && !Parent()->AsClassDefinition()->IsLocal()) { + if (IsPrivate()) { + dumper->Add("private "); + } else if (IsProtected()) { + dumper->Add("protected "); + } else { + dumper->Add("public "); + } + } + + if (IsStatic()) { + dumper->Add("static "); + } + + if (IsReadonly()) { + dumper->Add("readonly "); + } +} + +bool ClassProperty::DumpNamespaceForDeclGen(ir::SrcDumper *dumper) const +{ + if (!dumper->IsDeclgen()) { + return false; + } + + if (Parent() == nullptr) { + return false; + } + + bool isNamespaceTransformed = + Parent()->IsClassDefinition() && Parent()->AsClassDefinition()->IsNamespaceTransformed(); + if (isNamespaceTransformed) { + dumper->Add("let "); + return true; + } + return false; +} + +void ClassProperty::DumpPrefix(ir::SrcDumper *dumper) const +{ + DumpAnnotations(this, dumper); + if (DumpNamespaceForDeclGen(dumper)) { + return; + } + DumpModifiers(dumper); +} + +void ClassProperty::DumpCheckerTypeForDeclGen(ir::SrcDumper *dumper) const +{ + ES2PANDA_ASSERT(dumper->IsDeclgen()); + + if (TsType() == nullptr) { + return; + } + + dumper->Add(": "); + dumper->GetDeclgen()->Dump(dumper, TsType()); +} + +bool ClassProperty::RegisterUnexportedForDeclGen(ir::SrcDumper *dumper) const +{ + ES2PANDA_ASSERT(key_); + ES2PANDA_ASSERT(dumper->IsDeclgen()); + + auto name = key_->AsIdentifier()->Name().Mutf8(); + if (name.rfind('#', 0) == 0) { + return true; + } + + if (IsPrivate()) { + return true; + } + + if (!compiler::HasGlobalClassParent(this)) { + return false; + } + + if (dumper->GetDeclgen()->IsPostDumpIndirectDepsPhase()) { + return false; + } + + if (key_->Parent()->IsExported() || key_->Parent()->IsDefaultExported()) { + return false; + } + + dumper->GetDeclgen()->AddNode(name, this); + return true; +} + +void ClassProperty::Dump(ir::SrcDumper *dumper) const +{ + bool isNamespaceTransformed = + Parent()->IsClassDefinition() && Parent()->AsClassDefinition()->IsNamespaceTransformed(); + // For declgen dump only if explicitly marked as export or it is public property of class (not namespace or module) + if (dumper->IsDeclgen() && !(IsExported() || IsDefaultExported() || (!isNamespaceTransformed && IsPublic()))) { + return; + } + if (dumper->IsDeclgen() && RegisterUnexportedForDeclGen(dumper)) { + return; + } + DumpPrefix(dumper); + + if (Key() != nullptr) { + Key()->Dump(dumper); + } + + if (IsOptionalDeclaration()) { + dumper->Add("?"); + } + + if (IsDefinite()) { + dumper->Add("!"); + } + + if (typeAnnotation_ != nullptr) { + dumper->Add(": "); + TypeAnnotation()->Dump(dumper); + } else if (dumper->IsDeclgen()) { + DumpCheckerTypeForDeclGen(dumper); + } + + if (value_ != nullptr) { + if (!dumper->IsDeclgen() || Parent()->IsAnnotationDeclaration()) { + dumper->Add(" = "); + Value()->Dump(dumper); + } + } + + dumper->Add(";"); +} + +static void DumpModifierPrefix(const ir::MethodDefinition *m, ir::SrcDumper *dumper) +{ + ES2PANDA_ASSERT(!compiler::HasGlobalClassParent(m)); + if (m->IsStatic()) { + dumper->Add("static "); + } + + if (m->IsAbstract() && + !(m->Parent()->IsTSInterfaceBody() || + (m->BaseOverloadMethod() != nullptr && m->BaseOverloadMethod()->Parent()->IsTSInterfaceBody()))) { + dumper->Add("abstract "); + } + if (m->IsFinal()) { + dumper->Add("final "); + } + if (m->IsNative()) { + dumper->Add("native "); + } + if (m->IsAsync() && !dumper->IsDeclgen()) { + dumper->Add("async "); + } + if (m->IsOverride()) { + dumper->Add("override "); + } + + if (m->IsGetter()) { + dumper->Add("get "); + } else if (m->IsSetter()) { + dumper->Add("set "); + } +} + +static bool IsNamespaceTransformed(const MethodDefinition *method) +{ + auto *parent = method->Parent(); + if (parent->IsMethodDefinition()) { + // handle overloads + parent = parent->Parent(); + } + return parent->IsClassDefinition() && parent->AsClassDefinition()->IsNamespaceTransformed(); +} + +static void DumpAccessorPrefix(const ir::MethodDefinition *m, ir::SrcDumper *dumper) +{ + // special processing for overloads + auto const *parent = m->Parent(); + if (parent != nullptr && parent->IsMethodDefinition()) { + parent = parent->Parent(); + } + + if (parent == nullptr) { + return; + } + + if (parent->IsClassDefinition() && !parent->AsClassDefinition()->IsLocal()) { + if (m->IsPrivate()) { + dumper->Add("private "); + } else if (m->IsProtected()) { + dumper->Add("protected "); + } else if (!dumper->IsDeclgen()) { + dumper->Add("public "); + } + return; + } + + if (dumper->IsDeclgen() && parent->IsTSInterfaceBody()) { + if (m->Value() != nullptr && m->Value()->IsFunctionExpression() && + m->Value()->AsFunctionExpression()->Function() != nullptr && + m->Value()->AsFunctionExpression()->Function()->HasBody()) { + dumper->Add("default "); + } + } +} + +static void DumpPrefix(const ir::MethodDefinition *m, ir::SrcDumper *dumper) +{ + bool global = compiler::HasGlobalClassParent(m); + if (global || IsNamespaceTransformed(m)) { + if (m->IsExported()) { + dumper->Add("export "); + } + if (m->IsDefaultExported()) { + dumper->Add("export default "); + } + if (dumper->IsDeclgen()) { + if (global) { + dumper->Add("declare "); + } else { + dumper->GetDeclgen()->TryDeclareAmbientContext(dumper); + } + } + dumper->Add("function "); + return; + } + + DumpAccessorPrefix(m, dumper); + DumpModifierPrefix(m, dumper); +} + +bool MethodDefinition::FilterForDeclGen() const +{ + if (key_ == nullptr) { + return false; + } + + if (Function()->IsSynthetic()) { + return true; + } + + if (compiler::HasGlobalClassParent(this) && !key_->Parent()->IsExported() && !key_->Parent()->IsDefaultExported()) { + return true; + } + + ES2PANDA_ASSERT(Id() != nullptr); + auto name = Id()->Name().Mutf8(); + if (name.find("%%async") != std::string::npos || name == compiler::Signatures::INITIALIZER_BLOCK_INIT || + name == compiler::Signatures::INIT_METHOD) { + return true; + } + + if (name.rfind('#', 0) == 0) { + return true; + } + + if (name == compiler::Signatures::CCTOR) { + return true; + } + + return false; +} + +static void DumpSingleOverload(const ir::MethodDefinition *m, ir::SrcDumper *dumper) +{ + if (compiler::HasGlobalClassParent(m) && m->Id() != nullptr && + m->Id()->Name().Is(compiler::Signatures::INIT_METHOD)) { + m->Function()->Body()->Dump(dumper); + return; + } + + auto value = m->Value(); + if (value->AsFunctionExpression()->Function()->HasAnnotations()) { + for (auto *anno : value->AsFunctionExpression()->Function()->Annotations()) { + // NOTE(zhelyapov): workaround, see #26031 + if (anno->GetBaseName()->Name() != compiler::Signatures::DEFAULT_ANNO_FOR_FUNC) { + anno->Dump(dumper); + } + } + } + + DumpPrefix(m, dumper); + + if (m->IsConstructor() && + !(m->Key()->IsIdentifier() && m->Key()->AsIdentifier()->Name().Is(compiler::Signatures::CONSTRUCTOR_NAME))) { + dumper->Add(std::string(compiler::Signatures::CONSTRUCTOR_NAME) + " "); + } + + auto key = m->Key(); + if (key != nullptr) { + key->Dump(dumper); + } + + if (value != nullptr) { + value->Dump(dumper); + } +} + +void MethodDefinition::Dump(ir::SrcDumper *dumper) const +{ + if (dumper->IsDeclgen() && FilterForDeclGen()) { + return; + } + + if (!dumper->IsDeclgen() || !IsPrivate()) { + DumpSingleOverload(this, dumper); + } + + for (auto method : Overloads()) { + method->Dump(dumper); + } +} + +void ETSFunctionType::Dump(ir::SrcDumper *dumper) const +{ + DumpAnnotations(this, dumper); + dumper->Add("(("); + for (auto *param : Params()) { + param->Dump(dumper); + if (param != Params().back()) { + dumper->Add(", "); + } + } + dumper->Add(")"); + + if (TypeParams() != nullptr) { + TypeParams()->Dump(dumper); + } + + if (ReturnType() != nullptr) { + dumper->Add("=> "); + ReturnType()->Dump(dumper); + } + + dumper->Add(")"); +} + +void ETSModule::Dump(ir::SrcDumper *dumper) const +{ + if (IsNamespace()) { + if (IsExported()) { + dumper->Add("export "); + } + + if (IsDefaultExported()) { + dumper->Add("export default "); + } + + if (IsDeclare() && !(parent_ != nullptr && parent_->IsDeclare())) { + dumper->Add("declare "); + } + + dumper->Add("namespace "); + Ident()->Dump(dumper); + dumper->Add(" {"); + dumper->IncrIndent(); + } + + if (!Statements().empty()) { + dumper->Endl(); + for (auto elem : Statements()) { + elem->Dump(dumper); + if (elem != Statements().back()) { + dumper->Endl(); + } + } + } + if (IsNamespace()) { + dumper->DecrIndent(); + } + dumper->Endl(); + if (IsNamespace()) { + dumper->Add("}"); + } +} + +void ETSNewClassInstanceExpression::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add("new "); + if (typeReference_ != nullptr) { + if (typeReference_->IsETSUnionType()) { + dumper->Add("("); + } + typeReference_->Dump(dumper); + if (typeReference_->IsETSUnionType()) { + dumper->Add(")"); + } + } + + dumper->Add("("); + for (auto argument : arguments_) { + argument->Dump(dumper); + if (argument != arguments_.back()) { + dumper->Add(", "); + } + } + dumper->Add(")"); +} + +void ETSParameterExpression::Dump(ir::SrcDumper *const dumper) const +{ + DumpAnnotations(this, dumper); + + if (IsRestParameter()) { + Spread()->Dump(dumper); + } else { + ETSParameterExpression const *node = this; + // NOTE (DZ): temporary solution until node history starts working properly + if (dumper->IsDeclgen() && OriginalNode() != nullptr) { + node = OriginalNode()->AsETSParameterExpression(); + } + + auto const ident = node->Ident(); + ES2PANDA_ASSERT(ident != nullptr); + auto const initializer = node->Initializer(); + + ident->Dump(dumper); + if (node->IsOptional() && initializer == nullptr) { + dumper->Add("?"); + } + + auto typeAnnotation = ident->AsAnnotatedExpression()->TypeAnnotation(); + if (typeAnnotation != nullptr) { + if (dumper->IsDeclgen() && typeAnnotation->OriginalNode() != nullptr) { + typeAnnotation = typeAnnotation->OriginalNode()->AsExpression()->AsTypeNode(); + } + dumper->Add(": "); + typeAnnotation->Dump(dumper); + } + + if (initializer != nullptr) { + dumper->Add(" = "); + initializer->Dump(dumper); + } + } +} + +void ETSPrimitiveType::Dump(ir::SrcDumper *dumper) const +{ + DumpAnnotations(this, dumper); + + switch (GetPrimitiveType()) { + case PrimitiveType::BYTE: + dumper->Add("byte"); + break; + case PrimitiveType::INT: + dumper->Add("int"); + break; + case PrimitiveType::LONG: + dumper->Add("long"); + break; + case PrimitiveType::SHORT: + dumper->Add("short"); + break; + case PrimitiveType::FLOAT: + dumper->Add("float"); + break; + case PrimitiveType::DOUBLE: + dumper->Add("double"); + break; + case PrimitiveType::BOOLEAN: + dumper->Add("boolean"); + break; + case PrimitiveType::CHAR: + dumper->Add("char"); + break; + case PrimitiveType::VOID: + dumper->Add("void"); + break; + default: + ES2PANDA_UNREACHABLE(); + } +} + +void CallExpression::Dump(ir::SrcDumper *dumper) const +{ + ES2PANDA_ASSERT(callee_); + callee_->Dump(dumper); + if (IsOptional()) { + dumper->Add("?."); + } + + if (typeParams_ != nullptr) { + typeParams_->Dump(dumper); + } + + dumper->Add("("); + for (auto arg : arguments_) { + arg->Dump(dumper); + if (arg != arguments_.back()) { + dumper->Add(", "); + } + } + dumper->Add(")"); + if (trailingLambdaInfo_.block != nullptr) { + if (trailingLambdaInfo_.isBlockInNewLine) { + dumper->Endl(); + } + trailingLambdaInfo_.block->Dump(dumper); + } +} + + + +void Identifier::Dump(ir::SrcDumper *dumper) const +{ + if (IsReceiver()) { + dumper->Add("this"); + return; + } + + if (IsPrivateIdent()) { + dumper->Add("private "); + } + + auto name = std::string(Name()); + std::string propertyStr = compiler::Signatures::PROPERTY.data(); + if (UNLIKELY(name.find(propertyStr) != std::string::npos)) { + name.replace(name.find(propertyStr), propertyStr.length(), "_$property$_"); + } + dumper->Add(name); + if (IsOptional()) { + dumper->Add("?"); + } + + if (dumper->IsDeclgen()) { + dumper->GetDeclgen()->PushTask( + [dumper, name = std::string(name_)] { dumper->GetDeclgen()->DumpNode(dumper, name); }); + } +} + +void MemberExpression::Dump(ir::SrcDumper *dumper) const +{ + ES2PANDA_ASSERT(object_ != nullptr); + ES2PANDA_ASSERT(property_ != nullptr); + + object_->Dump(dumper); + if (IsOptional()) { + dumper->Add("?"); + if ((MemberExpressionKind::ELEMENT_ACCESS & kind_) != 0U) { + dumper->Add("."); + } + } + if ((MemberExpressionKind::ELEMENT_ACCESS & kind_) != 0U) { + dumper->Add("["); + property_->Dump(dumper); + dumper->Add("]"); + } else { + dumper->Add("."); + property_->Dump(dumper); + } + if ((parent_ != nullptr) && (parent_->IsBlockStatement() || parent_->IsBlockExpression())) { + dumper->Add(";"); + dumper->Endl(); + } +} + +void TemplateLiteral::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add("`"); + auto const num = std::max(expressions_.size(), quasis_.size()); + + for (std::size_t i = 0U; i < num; i++) { + if (i < quasis_.size()) { + quasis_[i]->Dump(dumper); + } + if (i < expressions_.size()) { + dumper->Add("${"); + expressions_[i]->Dump(dumper); + dumper->Add("}"); + } + } + dumper->Add("`"); +} + +void NumberLiteral::Dump(ir::SrcDumper *dumper) const +{ + if (std::string(number_.Str()).empty() || (parent_ != nullptr && parent_->IsTSEnumMember())) { + if (number_.IsInt()) { + dumper->Add(number_.GetInt()); + return; + } + + if (number_.IsLong()) { + dumper->Add(number_.GetLong()); + return; + } + + if (number_.IsFloat()) { + dumper->Add(number_.GetFloat()); + return; + } + + if (number_.IsDouble()) { + dumper->Add(number_.GetDouble()); + return; + } + + if (number_.IsShort()) { + dumper->Add(number_.GetShort()); + return; + } + + if (number_.IsByte()) { + dumper->Add(number_.GetByte()); + return; + } + } + dumper->Add(std::string(number_.Str())); +} + +void ExportNamedDeclaration::Dump(ir::SrcDumper *dumper) const +{ + dumper->Add("export { "); + for (const auto *spec : specifiers_) { + spec->Dump(dumper); + + if (spec != specifiers_.back()) { + dumper->Add(", "); + } + } + dumper->Add(" }"); +} + +void ExportSpecifier::Dump(ir::SrcDumper *dumper) const +{ + if (GetConstantExpression() != nullptr) { + GetConstantExpression()->Dump(dumper); + dumper->Add("as default"); + return; + } + + exported_->Dump(dumper); + + if (local_ != nullptr) { + dumper->Add(" as "); + local_->Dump(dumper); + } +} + +void ImportDeclaration::Dump(ir::SrcDumper *dumper) const +{ + if (dumper->IsDeclgen()) { + dumper->GetDeclgen()->CollectImport(this); + return; + } + dumper->Add("import "); + auto const &specifiers = Specifiers(); + if (specifiers.size() == 1 && + (specifiers[0]->IsImportNamespaceSpecifier() || specifiers[0]->IsImportDefaultSpecifier())) { + specifiers[0]->Dump(dumper); + } else { + dumper->Add("{ "); + for (auto specifier : specifiers) { + specifier->Dump(dumper); + if (specifier != specifiers.back()) { + dumper->Add(", "); + } + } + dumper->Add(" }"); + } + + dumper->Add(" from "); + + if (dumper->IsDeclgen()) { + auto fileName = Source()->Str(); + auto len = fileName.Length(); + if (fileName.EndsWith(".ets")) { + len -= 4U; + fileName = fileName.Substr(0, len); + } + + std::string importFile = '\"' + util::Helpers::CreateEscapedString(fileName.Utf8()); + if (fileName.Utf8().find('.', 1U) == std::string_view::npos) { + importFile += ".d"; + } + importFile += '\"'; + + dumper->Add(importFile); + } else { + Source()->Dump(dumper); + } + dumper->Add(";"); + dumper->Endl(); +} + +void AnnotationUsage::Dump(ir::SrcDumper *dumper) const +{ + ES2PANDA_ASSERT(expr_ != nullptr); + dumper->Add("@"); + expr_->Dump(dumper); + dumper->Add("("); + + if (!properties_.empty()) { + dumper->Add("{"); + for (auto elem : properties_) { + ES2PANDA_ASSERT(elem->AsClassProperty()->Id() != nullptr); + dumper->Add(elem->AsClassProperty()->Id()->Name().Mutf8()); + dumper->Add(":"); + elem->AsClassProperty()->Value()->Dump(dumper); + if (elem != properties_.back()) { + dumper->Add(","); + } + } + dumper->Add("}"); + } + dumper->Add(") "); +} + +void FunctionDeclaration::Dump(ir::SrcDumper *dumper) const +{ + DumpAnnotations(this, dumper); + auto func = Function(); + if (func->IsNative()) { + dumper->Add("native "); + } + if (IsExported()) { + dumper->Add("export "); + } else if (IsDefaultExported()) { + dumper->Add("export default "); + } + if (func->IsDeclare() && !(parent_ != nullptr && parent_->IsDeclare())) { + dumper->Add("declare "); + } + if (func->IsAsyncFunc()) { + dumper->Add("async "); + } + dumper->Add("function "); + + func->Id()->Dump(dumper); + func->Dump(dumper); +} + +void VariableDeclaration::Dump(ir::SrcDumper *dumper) const +{ + DumpAnnotations(this, dumper); + + if (IsDeclare()) { + dumper->Add("declare "); + } + + switch (Kind()) { + case VariableDeclarationKind::CONST: + dumper->Add("const "); + break; + case VariableDeclarationKind::LET: + dumper->Add("let "); + break; + case VariableDeclarationKind::VAR: + dumper->Add("var "); + break; + default: + ES2PANDA_UNREACHABLE(); + } + + for (auto declarator : Declarators()) { + declarator->Dump(dumper); + if (declarator != Declarators().back()) { + dumper->Add(", "); + } + } + + auto const parent = Parent(); + if ((parent != nullptr) && + (parent->IsBlockStatement() || parent->IsBlockExpression() || parent->IsSwitchCaseStatement())) { + dumper->Add(";"); + } +} + +void TSArrayType::Dump(ir::SrcDumper *dumper) const +{ + DumpAnnotations(this, dumper); + ES2PANDA_ASSERT(elementType_); + if (elementType_->IsETSUnionType()) { + dumper->Add("("); + } + + elementType_->Dump(dumper); + + if (elementType_->IsETSUnionType()) { + dumper->Add(")"); + } + dumper->Add("[]"); +} + +bool TSInterfaceDeclaration::RegisterUnexportedForDeclGen(ir::SrcDumper *dumper) const +{ + // This method isn't used. + ES2PANDA_ASSERT(false); + ES2PANDA_ASSERT(dumper->IsDeclgen()); + + if (dumper->GetDeclgen()->IsPostDumpIndirectDepsPhase()) { + return false; + } + + if (id_->Parent()->IsDefaultExported() || id_->Parent()->IsExported()) { + return false; + } + + auto name = id_->Name().Mutf8(); + dumper->GetDeclgen()->AddNode(name, this); + return true; +} + +void TSInterfaceDeclaration::Dump(ir::SrcDumper *dumper) const +{ + auto guard = dumper->BuildAmbientContextGuard(); + ES2PANDA_ASSERT(id_); + if (!id_->Parent()->IsDefaultExported() && !id_->Parent()->IsExported() && dumper->IsDeclgen() && + !dumper->GetDeclgen()->IsPostDumpIndirectDepsPhase()) { + auto name = id_->Name().Mutf8(); + dumper->GetDeclgen()->AddNode(name, this); + return; + } + DumpAnnotations(this, dumper); + if (id_->Parent()->IsExported()) { + dumper->Add("export "); + } else if (id_->Parent()->IsDefaultExported()) { + dumper->Add("export default "); + } + if (dumper->IsDeclgen()) { + dumper->GetDeclgen()->TryDeclareAmbientContext(dumper); + } else if (IsDeclare()) { + dumper->Add("declare "); + } + dumper->Add("interface "); + Id()->Dump(dumper); + + auto const typeParams = TypeParams(); + if (typeParams != nullptr) { + dumper->Add("<"); + typeParams->Dump(dumper); + dumper->Add(">"); + } + + auto const extends = Extends(); + if (!extends.empty()) { + dumper->Add(" extends "); + for (auto ext : extends) { + ext->Dump(dumper); + if (ext != extends.back()) { + dumper->Add(", "); + } + } + } + + auto body = Body(); + dumper->Add(" {"); + if (body != nullptr) { + dumper->IncrIndent(); + dumper->Endl(); + body->Dump(dumper); + dumper->DecrIndent(); + dumper->Endl(); + } + dumper->Add("}"); + dumper->Endl(); +} + +void TSTypeParameter::Dump(ir::SrcDumper *dumper) const +{ + DumpAnnotations(this, dumper); + if (IsIn()) { + dumper->Add("in "); + } + if (IsOut()) { + dumper->Add("out "); + } + + Name()->Dump(dumper); + + if (DefaultType() != nullptr) { + dumper->Add(" = "); + DefaultType()->Dump(dumper); + } + if (Constraint() != nullptr) { + dumper->Add(" extends "); + Constraint()->Dump(dumper); + } +} + +void ETSReExportDeclaration::Dump([[maybe_unused]] ir::SrcDumper *dumper) const +{ + auto importDeclaration = GetETSImportDeclarations(); + const auto &specifiers = importDeclaration->Specifiers(); + dumper->Add("export "); + if (specifiers.size() == 1 && + (specifiers[0]->IsImportNamespaceSpecifier() || specifiers[0]->IsImportDefaultSpecifier())) { + specifiers[0]->Dump(dumper); + } else { + dumper->Add("{ "); + for (auto specifier : specifiers) { + specifier->Dump(dumper); + if (specifier != specifiers.back()) { + dumper->Add(", "); + } + } + dumper->Add(" }"); + } + + dumper->Add(" from "); + importDeclaration->Source()->Dump(dumper); + dumper->Add(";"); + dumper->Endl(); +} + } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/srcDump.h b/ets2panda/ir/srcDump.h index d48a42604be0eaa9dd457d433fede3df889e6deb..77d0b630c26ad284f4ec8672411b8ee6cd78a6f4 100644 --- a/ets2panda/ir/srcDump.h +++ b/ets2panda/ir/srcDump.h @@ -16,17 +16,20 @@ #ifndef ES2PANDA_IR_SRCDUMP_H #define ES2PANDA_IR_SRCDUMP_H -#include -#include +#include "lexer/token/sourceLocation.h" #include "generated/tokenType.h" -#include +#include "public/public.h" +#include "util/ustring.h" #include #include #include +#include namespace ark::es2panda::ir { +class AstNode; + // Forward declarations class ClassDefinition; class TSTypeAliasDeclaration; diff --git a/ets2panda/ir/statements/annotationDeclaration.cpp b/ets2panda/ir/statements/annotationDeclaration.cpp index d3a4c0e51a09f28cbadc0f24abfed9432d5b81d7..d68297641af31d0859c24243605580294e60af78 100644 --- a/ets2panda/ir/statements/annotationDeclaration.cpp +++ b/ets2panda/ir/statements/annotationDeclaration.cpp @@ -14,11 +14,11 @@ */ #include "annotationDeclaration.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" + +#include "ir/ets/etsTypeReference.h" +#include "ir/ets/etsTypeReferencePart.h" + +#include "ir/ts/tsClassImplements.h" namespace ark::es2panda::ir { @@ -98,61 +98,6 @@ void AnnotationDeclaration::Iterate(const NodeTraverser &cb) const IterateAnnotations(cb); } -void AnnotationDeclaration::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"Expr", Expr()}, {"properties", Properties()}, {"annotations", AstDumper::Optional(Annotations())}}); -} - -void AnnotationDeclaration::Dump(ir::SrcDumper *dumper) const -{ - auto guard = dumper->BuildAmbientContextGuard(); - DumpAnnotations(dumper); - ES2PANDA_ASSERT(Expr() != nullptr); - if (IsExported()) { - dumper->Add("export "); - } - if (dumper->IsDeclgen()) { - dumper->GetDeclgen()->TryDeclareAmbientContext(dumper); - } - dumper->Add("@interface "); - Expr()->Dump(dumper); - dumper->Add(" {"); - - auto const properties = Properties(); - if (!properties.empty()) { - dumper->IncrIndent(); - dumper->Endl(); - for (auto elem : properties) { - elem->Dump(dumper); - if (elem != properties.back()) { - dumper->Endl(); - } - } - dumper->DecrIndent(); - dumper->Endl(); - } - dumper->Add("}"); -} -void AnnotationDeclaration::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void AnnotationDeclaration::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *AnnotationDeclaration::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType AnnotationDeclaration::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - Identifier *AnnotationDeclaration::GetBaseName() const { if (Expr()->IsIdentifier()) { diff --git a/ets2panda/ir/statements/annotationUsage.cpp b/ets2panda/ir/statements/annotationUsage.cpp index 2d22aed190e78bad6be6a27631fd2357ed62daaf..424521992e3710c74be9161a7578eab6455282d9 100644 --- a/ets2panda/ir/statements/annotationUsage.cpp +++ b/ets2panda/ir/statements/annotationUsage.cpp @@ -14,9 +14,11 @@ */ #include "annotationUsage.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" + +#include "ir/base/classProperty.h" +#include "ir/expressions/identifier.h" +#include "ir/ets/etsTypeReference.h" +#include "ir/ets/etsTypeReferencePart.h" namespace ark::es2panda::ir { void AnnotationUsage::TransformChildren(const NodeTransformer &cb, std::string_view const transformationName) @@ -44,33 +46,6 @@ void AnnotationUsage::Iterate(const NodeTraverser &cb) const } } -void AnnotationUsage::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"expr_", expr_}, {"properties", properties_}}); -} -void AnnotationUsage::Dump(ir::SrcDumper *dumper) const -{ - ES2PANDA_ASSERT(expr_ != nullptr); - dumper->Add("@"); - expr_->Dump(dumper); - dumper->Add("("); - - if (!properties_.empty()) { - dumper->Add("{"); - for (auto elem : properties_) { - ES2PANDA_ASSERT(elem->AsClassProperty()->Id() != nullptr); - dumper->Add(elem->AsClassProperty()->Id()->Name().Mutf8()); - dumper->Add(":"); - elem->AsClassProperty()->Value()->Dump(dumper); - if (elem != properties_.back()) { - dumper->Add(","); - } - } - dumper->Add("}"); - } - dumper->Add(") "); -} - AnnotationUsage *AnnotationUsage::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto *const expr = expr_ != nullptr ? expr_->Clone(allocator, nullptr)->AsExpression() : nullptr; @@ -95,26 +70,6 @@ AnnotationUsage *AnnotationUsage::Clone(ArenaAllocator *const allocator, AstNode return clone; } -void AnnotationUsage::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void AnnotationUsage::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *AnnotationUsage::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType AnnotationUsage::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - Identifier *AnnotationUsage::GetBaseName() const { if (expr_->IsIdentifier()) { diff --git a/ets2panda/ir/statements/assertStatement.cpp b/ets2panda/ir/statements/assertStatement.cpp index dce93e657056b3f381b883d7a8905537143edcf9..8dabb1abc5cc625c7bbc340736084782c2e84c5f 100644 --- a/ets2panda/ir/statements/assertStatement.cpp +++ b/ets2panda/ir/statements/assertStatement.cpp @@ -17,12 +17,7 @@ #include "varbinder/ETSBinder.h" #include "compiler/base/condition.h" -#include "compiler/core/pandagen.h" -#include "compiler/core/ETSGen.h" -#include "checker/ETSchecker.h" -#include "checker/TSchecker.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" + #include "ir/expression.h" namespace ark::es2panda::ir { @@ -37,36 +32,6 @@ void AssertStatement::Iterate([[maybe_unused]] const NodeTraverser &cb) const ES2PANDA_UNREACHABLE(); } -void AssertStatement::Dump([[maybe_unused]] ir::AstDumper *dumper) const -{ - ES2PANDA_UNREACHABLE(); -} - -void AssertStatement::Dump([[maybe_unused]] ir::SrcDumper *dumper) const -{ - ES2PANDA_UNREACHABLE(); -} - -void AssertStatement::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void AssertStatement::Compile([[maybe_unused]] compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *AssertStatement::Check([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType AssertStatement::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - AssertStatement *AssertStatement::Clone([[maybe_unused]] ArenaAllocator *const allocator, [[maybe_unused]] AstNode *const parent) { diff --git a/ets2panda/ir/statements/blockStatement.cpp b/ets2panda/ir/statements/blockStatement.cpp index cd0f0740774f064733a64aa1565c6f3dc67c213e..e0955cd85123c2eb7512fb76f232907162d25922 100644 --- a/ets2panda/ir/statements/blockStatement.cpp +++ b/ets2panda/ir/statements/blockStatement.cpp @@ -15,14 +15,10 @@ #include "blockStatement.h" -#include "compiler/core/pandagen.h" #include "compiler/core/regScope.h" -#include "compiler/core/ETSGen.h" -#include "checker/TSchecker.h" -#include "checker/ETSchecker.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" -#include "libarkbase/utils/arena_containers.h" + + +#include "util/helpers.h" namespace ark::es2panda::ir { void BlockStatement::TransformChildren(const NodeTransformer &cb, std::string_view const transformationName) @@ -64,57 +60,6 @@ void BlockStatement::Iterate(const NodeTraverser &cb) const } } -void BlockStatement::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", IsProgram() ? "Program" : "BlockStatement"}, {"statements", Statements()}}); -} - -void BlockStatement::Dump(ir::SrcDumper *dumper) const -{ - auto const &statements = Statements(); - // NOTE(nsizov): trailing blocks - if (Parent() != nullptr && (Parent()->IsBlockStatement() || Parent()->IsCallExpression())) { - dumper->Add("{"); - if (!statements.empty()) { - dumper->IncrIndent(); - dumper->Endl(); - } - } - for (auto statement : statements) { - statement->Dump(dumper); - if (statement != statements.back()) { - dumper->Endl(); - } - } - if (Parent() != nullptr && (Parent()->IsBlockStatement() || Parent()->IsCallExpression())) { - if (!statements.empty()) { - dumper->DecrIndent(); - dumper->Endl(); - } - dumper->Add("}"); - } -} - -void BlockStatement::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void BlockStatement::Compile([[maybe_unused]] compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *BlockStatement::Check([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType BlockStatement::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - BlockStatement *BlockStatement::Construct(ArenaAllocator *allocator) { ArenaVector statementList(allocator->Adapter()); diff --git a/ets2panda/ir/statements/blockStatement.h b/ets2panda/ir/statements/blockStatement.h index 4eedc462a94986bb4a7f3ebdfb15a232167c7687..b006f1c0964da17762bfbbcd26c806f587f75dc3 100644 --- a/ets2panda/ir/statements/blockStatement.h +++ b/ets2panda/ir/statements/blockStatement.h @@ -17,7 +17,7 @@ #define ES2PANDA_IR_STATEMENT_BLOCK_STATEMENT_H #include "ir/statement.h" -#include "libarkbase/utils/arena_containers.h" +#include "libarkbase/utils/arena_unordered_map.h" namespace ark::es2panda::checker { class ETSAnalyzer; diff --git a/ets2panda/ir/statements/breakStatement.cpp b/ets2panda/ir/statements/breakStatement.cpp index afbca163d33206566e70d0df4763dd4b46b38e35..947905a64c58c341f29d7e8a81cb7d8ca0a6ef54 100644 --- a/ets2panda/ir/statements/breakStatement.cpp +++ b/ets2panda/ir/statements/breakStatement.cpp @@ -15,12 +15,9 @@ #include "breakStatement.h" -#include "checker/TSchecker.h" -#include "compiler/core/pandagen.h" -#include "compiler/core/ETSGen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" -#include "checker/ETSchecker.h" +#include "ir/expressions/identifier.h" + +#include "util/helpers.h" namespace ark::es2panda::ir { void BreakStatement::TransformChildren(const NodeTransformer &cb, std::string_view transformationName) @@ -40,41 +37,6 @@ void BreakStatement::Iterate(const NodeTraverser &cb) const } } -void BreakStatement::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "BreakStatement"}, {"label", AstDumper::Nullish(ident_)}}); -} - -void BreakStatement::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add("break"); - if (ident_ != nullptr) { - dumper->Add(" "); - ident_->Dump(dumper); - } - dumper->Add(";"); -} - -void BreakStatement::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void BreakStatement::Compile([[maybe_unused]] compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *BreakStatement::Check([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType BreakStatement::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - BreakStatement *BreakStatement::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto *const ident = ident_ != nullptr ? ident_->Clone(allocator, nullptr) : nullptr; diff --git a/ets2panda/ir/statements/classDeclaration.cpp b/ets2panda/ir/statements/classDeclaration.cpp index 2eb415d04b30694f9532d025ee3cc46a6dba2942..7d3d3d75206e8d80886328cf3009bb149c37ef63 100644 --- a/ets2panda/ir/statements/classDeclaration.cpp +++ b/ets2panda/ir/statements/classDeclaration.cpp @@ -15,11 +15,8 @@ #include "classDeclaration.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" +#include "ir/base/classDefinition.h" + #include namespace ark::es2panda::ir { @@ -58,35 +55,4 @@ void ClassDeclaration::Iterate(const NodeTraverser &cb) const cb(def); } -void ClassDeclaration::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "ClassDeclaration"}, {"definition", Definition()}}); -} - -void ClassDeclaration::Dump(ir::SrcDumper *dumper) const -{ - if (Definition() != nullptr) { - Definition()->Dump(dumper); - } -} - -void ClassDeclaration::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void ClassDeclaration::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *ClassDeclaration::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType ClassDeclaration::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/statements/continueStatement.cpp b/ets2panda/ir/statements/continueStatement.cpp index ab35d97e73d831665c191f4fa47d44d332fa3222..b860800ebcbe1c8296d9c399f79954c25c6110aa 100644 --- a/ets2panda/ir/statements/continueStatement.cpp +++ b/ets2panda/ir/statements/continueStatement.cpp @@ -15,11 +15,7 @@ #include "continueStatement.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" +#include "util/helpers.h" namespace ark::es2panda::ir { void ContinueStatement::TransformChildren(const NodeTransformer &cb, std::string_view transformationName) @@ -39,41 +35,6 @@ void ContinueStatement::Iterate(const NodeTraverser &cb) const } } -void ContinueStatement::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "ContinueStatement"}, {"label", AstDumper::Nullish(ident_)}}); -} - -void ContinueStatement::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add("continue"); - if (Ident() != nullptr) { - dumper->Add(" "); - Ident()->Dump(dumper); - } - dumper->Add(";"); -} - -void ContinueStatement::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void ContinueStatement::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *ContinueStatement::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType ContinueStatement::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - ContinueStatement *ContinueStatement::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto *const ident = ident_ != nullptr ? ident_->Clone(allocator, nullptr) : nullptr; diff --git a/ets2panda/ir/statements/debuggerStatement.cpp b/ets2panda/ir/statements/debuggerStatement.cpp index fa84ad325d541455339e0c7b004ab7ee40919f14..56a8094f2bc78fff646f4dd4c1704cef433490d2 100644 --- a/ets2panda/ir/statements/debuggerStatement.cpp +++ b/ets2panda/ir/statements/debuggerStatement.cpp @@ -15,12 +15,6 @@ #include "debuggerStatement.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" - namespace ark::es2panda::ir { void DebuggerStatement::TransformChildren([[maybe_unused]] const NodeTransformer &cb, [[maybe_unused]] std::string_view const transformationName) @@ -29,33 +23,4 @@ void DebuggerStatement::TransformChildren([[maybe_unused]] const NodeTransformer void DebuggerStatement::Iterate([[maybe_unused]] const NodeTraverser &cb) const {} -void DebuggerStatement::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "DebuggerStatement"}}); -} - -void DebuggerStatement::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add("DebuggerStatement"); -} - -void DebuggerStatement::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void DebuggerStatement::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *DebuggerStatement::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType DebuggerStatement::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/statements/doWhileStatement.cpp b/ets2panda/ir/statements/doWhileStatement.cpp index 58e70f28f5e02b7c4451ebc2e36d8f0c09376e1c..bd4968a135fb95bcd62a4cd8d156ff032ef00519 100644 --- a/ets2panda/ir/statements/doWhileStatement.cpp +++ b/ets2panda/ir/statements/doWhileStatement.cpp @@ -19,11 +19,8 @@ #include "varbinder/scope.h" #include "compiler/base/condition.h" #include "compiler/core/labelTarget.h" -#include "compiler/core/pandagen.h" -#include "compiler/core/ETSGen.h" -#include "checker/TSchecker.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" + +#include "util/helpers.h" namespace ark::es2panda::ir { void DoWhileStatement::TransformChildren(const NodeTransformer &cb, std::string_view const transformationName) @@ -45,49 +42,6 @@ void DoWhileStatement::Iterate(const NodeTraverser &cb) const cb(test_); } -void DoWhileStatement::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "DoWhileStatement"}, {"body", body_}, {"test", test_}}); -} - -void DoWhileStatement::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add("do {"); - if (body_ != nullptr) { - dumper->IncrIndent(); - dumper->Endl(); - body_->Dump(dumper); - dumper->DecrIndent(); - dumper->Endl(); - } - dumper->Add("} while"); - dumper->Add("("); - if (test_ != nullptr) { - test_->Dump(dumper); - } - dumper->Add(")"); -} - -void DoWhileStatement::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void DoWhileStatement::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *DoWhileStatement::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType DoWhileStatement::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - DoWhileStatement *DoWhileStatement::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto *const body = body_->Clone(allocator, nullptr)->AsStatement(); diff --git a/ets2panda/ir/statements/emptyStatement.cpp b/ets2panda/ir/statements/emptyStatement.cpp index e7e6c976b12d586f428dc8c548537b5bfa2ee57b..42abcedf17a8a8fcc01f55e1ee6b6cb936f2ed73 100644 --- a/ets2panda/ir/statements/emptyStatement.cpp +++ b/ets2panda/ir/statements/emptyStatement.cpp @@ -15,12 +15,6 @@ #include "emptyStatement.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" - namespace ark::es2panda::ir { void EmptyStatement::TransformChildren([[maybe_unused]] const NodeTransformer &c, [[maybe_unused]] std::string_view const transformationName) @@ -29,41 +23,11 @@ void EmptyStatement::TransformChildren([[maybe_unused]] const NodeTransformer &c void EmptyStatement::Iterate([[maybe_unused]] const NodeTraverser &cb) const {} -void EmptyStatement::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "EmptyStatement"}}); -} - -void EmptyStatement::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add(""); -} - -void EmptyStatement::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void EmptyStatement::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - bool EmptyStatement::IsBrokenStatement() { return isBrokenStatement_; } -checker::Type *EmptyStatement::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType EmptyStatement::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - [[nodiscard]] EmptyStatement *EmptyStatement::Clone(ArenaAllocator *allocator, AstNode *parent) { EmptyStatement *stmt = allocator->New(IsBrokenStatement()); diff --git a/ets2panda/ir/statements/expressionStatement.cpp b/ets2panda/ir/statements/expressionStatement.cpp index 58cbd0e3d196802c536110aac8c7b3630436d38a..a1ba61883fef6f4ea14c7e5998425c681378dbf1 100644 --- a/ets2panda/ir/statements/expressionStatement.cpp +++ b/ets2panda/ir/statements/expressionStatement.cpp @@ -15,10 +15,6 @@ #include "expressionStatement.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" - namespace ark::es2panda::ir { void ExpressionStatement::TransformChildren(const NodeTransformer &cb, std::string_view transformationName) { @@ -33,20 +29,6 @@ void ExpressionStatement::Iterate(const NodeTraverser &cb) const cb(expression_); } -void ExpressionStatement::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "ExpressionStatement"}, {"expression", expression_}}); -} - -void ExpressionStatement::Dump(ir::SrcDumper *dumper) const -{ - ES2PANDA_ASSERT(expression_ != nullptr); - expression_->Dump(dumper); - if ((parent_ != nullptr) && (parent_->IsBlockStatement() || parent_->IsSwitchCaseStatement())) { - dumper->Add(";"); - } -} - ExpressionStatement *ExpressionStatement::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto *const expression = expression_->Clone(allocator, nullptr)->AsExpression(); @@ -59,23 +41,4 @@ ExpressionStatement *ExpressionStatement::Clone(ArenaAllocator *const allocator, return clone; } -void ExpressionStatement::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void ExpressionStatement::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *ExpressionStatement::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType ExpressionStatement::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/statements/forInStatement.cpp b/ets2panda/ir/statements/forInStatement.cpp index 9436f75696f297a3a274ff248d40a1d1eaefdadc..0f6c55365f04b6a0c1d36d58e29be5cd433f84b7 100644 --- a/ets2panda/ir/statements/forInStatement.cpp +++ b/ets2panda/ir/statements/forInStatement.cpp @@ -18,11 +18,8 @@ #include "varbinder/scope.h" #include "compiler/base/lreference.h" #include "compiler/core/labelTarget.h" -#include "compiler/core/pandagen.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" + +#include "util/helpers.h" namespace ark::es2panda::ir { void ForInStatement::TransformChildren(const NodeTransformer &cb, std::string_view transformationName) @@ -50,36 +47,6 @@ void ForInStatement::Iterate(const NodeTraverser &cb) const cb(body_); } -void ForInStatement::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "ForInStatement"}, {"left", left_}, {"right", right_}, {"body", body_}}); -} - -void ForInStatement::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add("ForInStatement"); -} - -void ForInStatement::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void ForInStatement::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *ForInStatement::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType ForInStatement::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - ForInStatement *ForInStatement::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto *const left = left_->Clone(allocator, nullptr); diff --git a/ets2panda/ir/statements/forOfStatement.cpp b/ets2panda/ir/statements/forOfStatement.cpp index 62926980918b34847ac6a00cbb06d82a2c11a60a..5721e0b1e1b62c71f5b1a3b42d9393e3d21f9786 100644 --- a/ets2panda/ir/statements/forOfStatement.cpp +++ b/ets2panda/ir/statements/forOfStatement.cpp @@ -15,9 +15,13 @@ #include "forOfStatement.h" -#include "checker/TSchecker.h" -#include "compiler/core/pandagen.h" -#include "compiler/core/ETSGen.h" +#include "checker/ETSchecker.h" +#include "checker/types/ets/etsFunctionType.h" +#include "checker/types/ets/etsObjectType.h" +#include "checker/types/ets/etsUnionType.h" +#include "checker/types/ets/etsArrayType.h" + +#include "ir/statements/blockStatement.h" namespace ark::es2panda::ir { @@ -66,54 +70,6 @@ void ForOfStatement::Iterate(const NodeTraverser &cb) const cb(body_); } -void ForOfStatement::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "ForOfStatement"}, {"await", isAwait_}, {"left", left_}, {"right", right_}, {"body", body_}}); -} - -void ForOfStatement::Dump(ir::SrcDumper *dumper) const -{ - ES2PANDA_ASSERT(left_ != nullptr); - ES2PANDA_ASSERT(right_ != nullptr); - dumper->Add("for "); - if (isAwait_) { - dumper->Add("await "); - } - dumper->Add("("); - left_->Dump(dumper); - dumper->Add(" of "); - right_->Dump(dumper); - dumper->Add(") {"); - if (body_ != nullptr) { - dumper->IncrIndent(); - dumper->Endl(); - body_->Dump(dumper); - dumper->DecrIndent(); - dumper->Endl(); - } - dumper->Add("}"); -} - -void ForOfStatement::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void ForOfStatement::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *ForOfStatement::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType ForOfStatement::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - ForOfStatement *ForOfStatement::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto *const left = left_ != nullptr ? left_->Clone(allocator, nullptr) : nullptr; diff --git a/ets2panda/ir/statements/forUpdateStatement.cpp b/ets2panda/ir/statements/forUpdateStatement.cpp index cd0d2d53170af2dffb4c3e54d27d413d90e2b4de..cdb1d75d31a02d770e07c141057a17df6a4b2bf5 100644 --- a/ets2panda/ir/statements/forUpdateStatement.cpp +++ b/ets2panda/ir/statements/forUpdateStatement.cpp @@ -18,11 +18,8 @@ #include "compiler/base/condition.h" #include "compiler/base/lreference.h" #include "compiler/core/labelTarget.h" -#include "compiler/core/pandagen.h" -#include "compiler/core/ETSGen.h" -#include "checker/TSchecker.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" + +#include "util/helpers.h" namespace ark::es2panda::ir { void ForUpdateStatement::TransformChildren(const NodeTransformer &cb, std::string_view transformationName) @@ -69,62 +66,6 @@ void ForUpdateStatement::Iterate(const NodeTraverser &cb) const cb(body_); } -void ForUpdateStatement::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "ForUpdateStatement"}, - {"init", AstDumper::Nullish(init_)}, - {"test", AstDumper::Nullish(test_)}, - {"update", AstDumper::Nullish(update_)}, - {"body", body_}}); -} - -void ForUpdateStatement::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add("for "); - dumper->Add("("); - if (init_ != nullptr) { - init_->Dump(dumper); - } - dumper->Add(";"); - if (test_ != nullptr) { - test_->Dump(dumper); - } - dumper->Add(";"); - if (update_ != nullptr) { - update_->Dump(dumper); - } - dumper->Add(") "); - dumper->Add("{"); - if (body_ != nullptr) { - dumper->IncrIndent(); - dumper->Endl(); - body_->Dump(dumper); - dumper->DecrIndent(); - dumper->Endl(); - } - dumper->Add("}"); -} - -void ForUpdateStatement::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void ForUpdateStatement::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *ForUpdateStatement::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType ForUpdateStatement::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - ForUpdateStatement *ForUpdateStatement::Clone(ArenaAllocator *const allocator, AstNode *const parent) { ir::AstNode *init = nullptr; diff --git a/ets2panda/ir/statements/functionDeclaration.cpp b/ets2panda/ir/statements/functionDeclaration.cpp index a677ab50352d15278caa0e5fe02b578eca1a56cb..1bc214ea0f63b971740ea602eab8092b3c8b1775 100644 --- a/ets2panda/ir/statements/functionDeclaration.cpp +++ b/ets2panda/ir/statements/functionDeclaration.cpp @@ -16,11 +16,6 @@ #include "functionDeclaration.h" #include "varbinder/variable.h" -#include "compiler/core/ETSGen.h" -#include "checker/TSchecker.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" -#include "compiler/core/pandagen.h" namespace ark::es2panda::ir { @@ -48,57 +43,6 @@ void FunctionDeclaration::Iterate(const NodeTraverser &cb) const cb(func); } -void FunctionDeclaration::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", Function()->IsOverload() ? "TSDeclareFunction" : "FunctionDeclaration"}, - {"annotations", AstDumper::Optional(Annotations())}, - {"function", Function()}}); -} - -void FunctionDeclaration::Dump(ir::SrcDumper *dumper) const -{ - DumpAnnotations(dumper); - auto func = Function(); - if (func->IsNative()) { - dumper->Add("native "); - } - if (IsExported()) { - dumper->Add("export "); - } else if (IsDefaultExported()) { - dumper->Add("export default "); - } - if (func->IsDeclare() && !(parent_ != nullptr && parent_->IsDeclare())) { - dumper->Add("declare "); - } - if (func->IsAsyncFunc()) { - dumper->Add("async "); - } - dumper->Add("function "); - - func->Id()->Dump(dumper); - func->Dump(dumper); -} - -void FunctionDeclaration::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void FunctionDeclaration::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *FunctionDeclaration::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType FunctionDeclaration::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - FunctionDeclaration *FunctionDeclaration::Construct(ArenaAllocator *allocator) { return allocator->New(allocator, nullptr); diff --git a/ets2panda/ir/statements/ifStatement.cpp b/ets2panda/ir/statements/ifStatement.cpp index 9b50804416cb282c0d6936ae812cba59b0a9ac60..5c3a2404ce3b19a4c91d3e1381fc9a9d79dd36f3 100644 --- a/ets2panda/ir/statements/ifStatement.cpp +++ b/ets2panda/ir/statements/ifStatement.cpp @@ -15,11 +15,11 @@ #include "ifStatement.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" +#include "util/helpers.h" +#include "ir/expression.h" namespace ark::es2panda::ir { + void IfStatement::TransformChildren(const NodeTransformer &cb, std::string_view transformationName) { if (auto *transformedNode = cb(test_); test_ != transformedNode) { @@ -50,58 +50,6 @@ void IfStatement::Iterate(const NodeTraverser &cb) const } } -void IfStatement::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "IfStatement"}, - {"test", test_}, - {"consequent", consequent_}, - {"alternate", AstDumper::Nullish(alternate_)}}); -} - -void IfStatement::Dump(ir::SrcDumper *dumper) const -{ - ES2PANDA_ASSERT(test_); - ES2PANDA_ASSERT(consequent_ != nullptr); - dumper->Add("if ("); - test_->Dump(dumper); - dumper->Add(") {"); - dumper->IncrIndent(); - dumper->Endl(); - consequent_->Dump(dumper); - dumper->DecrIndent(); - dumper->Endl(); - dumper->Add("}"); - if (alternate_ != nullptr) { - dumper->Add(" else {"); - dumper->IncrIndent(); - dumper->Endl(); - alternate_->Dump(dumper); - dumper->DecrIndent(); - dumper->Endl(); - dumper->Add("}"); - } -} - -void IfStatement::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void IfStatement::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *IfStatement::Check([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType IfStatement::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - IfStatement *IfStatement::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto *const test = test_->Clone(allocator, nullptr)->AsExpression(); diff --git a/ets2panda/ir/statements/labelledStatement.cpp b/ets2panda/ir/statements/labelledStatement.cpp index 0a4f1c2b7fe207b863aa7751fe1b0261b23a880a..8191dc3a5dc85c8cd2d901fb641dab06660fafd3 100644 --- a/ets2panda/ir/statements/labelledStatement.cpp +++ b/ets2panda/ir/statements/labelledStatement.cpp @@ -15,11 +15,9 @@ #include "labelledStatement.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" +#include "ir/expressions/identifier.h" + +#include "util/helpers.h" namespace ark::es2panda::ir { void LabelledStatement::TransformChildren(const NodeTransformer &cb, std::string_view transformationName) @@ -41,20 +39,6 @@ void LabelledStatement::Iterate(const NodeTraverser &cb) const cb(body_); } -void LabelledStatement::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "LabelledStatement"}, {"label", ident_}, {"body", body_}}); -} - -void LabelledStatement::Dump(ir::SrcDumper *dumper) const -{ - ES2PANDA_ASSERT(ident_ != nullptr); - ident_->Dump(dumper); - dumper->Add(":"); - dumper->Endl(); - body_->Dump(dumper); -} - const ir::AstNode *LabelledStatement::GetReferencedStatement() const { const auto *iter = body_; @@ -76,26 +60,6 @@ const ir::AstNode *LabelledStatement::GetReferencedStatement() const } } -void LabelledStatement::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void LabelledStatement::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *LabelledStatement::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType LabelledStatement::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - LabelledStatement *LabelledStatement::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto *const ident = ident_->Clone(allocator, nullptr); diff --git a/ets2panda/ir/statements/loopStatement.cpp b/ets2panda/ir/statements/loopStatement.cpp index 1396aa3bec52ebda32d2c9fb22fb1b7673634b10..31db45e258f7252dc2fc0fd3f517e7fa68c71b0b 100644 --- a/ets2panda/ir/statements/loopStatement.cpp +++ b/ets2panda/ir/statements/loopStatement.cpp @@ -19,9 +19,4 @@ #include "checker/checker.h" namespace ark::es2panda::ir { -checker::VerifiedType LoopStatement::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - ES2PANDA_UNREACHABLE(); - return {this, nullptr}; -} } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/statements/returnStatement.cpp b/ets2panda/ir/statements/returnStatement.cpp index a14d55209022265152bc5a14a5507f8b11834a97..8db15a66e74a3a5a7030399c9eafa2f8a54ff0b9 100644 --- a/ets2panda/ir/statements/returnStatement.cpp +++ b/ets2panda/ir/statements/returnStatement.cpp @@ -15,11 +15,10 @@ #include "returnStatement.h" -#include "checker/TSchecker.h" -#include "compiler/core/pandagen.h" -#include "compiler/core/ETSGen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" +#include "checker/ETSchecker.h" + +#include "ir/base/scriptFunction.h" +#include "varbinder/variable.h" namespace ark::es2panda::ir { void ReturnStatement::TransformChildren(const NodeTransformer &cb, std::string_view transformationName) @@ -39,41 +38,6 @@ void ReturnStatement::Iterate(const NodeTraverser &cb) const } } -void ReturnStatement::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "ReturnStatement"}, {"argument", AstDumper::Nullish(argument_)}}); -} - -void ReturnStatement::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add("return"); - if (argument_ != nullptr) { - dumper->Add(" "); - argument_->Dump(dumper); - } - dumper->Add(";"); -} - -void ReturnStatement::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void ReturnStatement::Compile([[maybe_unused]] compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *ReturnStatement::Check([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType ReturnStatement::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - void ReturnStatement::SetReturnType(checker::ETSChecker *checker, checker::Type *type) { returnType_ = type; diff --git a/ets2panda/ir/statements/switchCaseStatement.cpp b/ets2panda/ir/statements/switchCaseStatement.cpp index 07d1b0d3af4807667dd2e7a6ddbb09ea57b7d4c6..b6c607e477893170f143209347b7a62d6a899aff 100644 --- a/ets2panda/ir/statements/switchCaseStatement.cpp +++ b/ets2panda/ir/statements/switchCaseStatement.cpp @@ -15,12 +15,7 @@ #include "switchCaseStatement.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" #include "checker/ets/typeRelationContext.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" namespace ark::es2panda::ir { void SwitchCaseStatement::TransformChildren(const NodeTransformer &cb, std::string_view transformationName) @@ -51,56 +46,6 @@ void SwitchCaseStatement::Iterate(const NodeTraverser &cb) const } } -void SwitchCaseStatement::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "SwitchCase"}, {"test", AstDumper::Nullish(test_)}, {"consequent", consequent_}}); -} - -void SwitchCaseStatement::Dump(ir::SrcDumper *dumper) const -{ - if (test_ != nullptr) { - dumper->Add("case "); - test_->Dump(dumper); - dumper->Add(":"); - } else { - dumper->Add("default:"); - } - if (!consequent_.empty()) { - dumper->Add(" {"); - dumper->IncrIndent(); - dumper->Endl(); - for (auto cs : consequent_) { - cs->Dump(dumper); - if (!cs->IsBlockStatement() && cs != consequent_.back()) { - dumper->Endl(); - } - } - dumper->DecrIndent(); - dumper->Endl(); - dumper->Add("}"); - } -} - -void SwitchCaseStatement::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void SwitchCaseStatement::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *SwitchCaseStatement::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType SwitchCaseStatement::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - // Auxilary function extracted from the 'Check' method for 'SwitchStatement' to reduce function's size. void SwitchCaseStatement::CheckAndTestCase(checker::ETSChecker *checker, checker::Type *comparedExprType, checker::Type *unboxedDiscType, ir::Expression *node, bool &isDefaultCase) diff --git a/ets2panda/ir/statements/switchStatement.cpp b/ets2panda/ir/statements/switchStatement.cpp index c9bc019eaa8c7d9dbc23c9bbe73a1b066254c22e..f52c41119c263f4b8b15b848149beb9f4701dfae 100644 --- a/ets2panda/ir/statements/switchStatement.cpp +++ b/ets2panda/ir/statements/switchStatement.cpp @@ -14,12 +14,9 @@ */ #include "switchStatement.h" +#include "ir/statements/switchCaseStatement.h" -#include "compiler/core/pandagen.h" -#include "compiler/core/ETSGen.h" -#include "checker/TSchecker.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" +#include "util/helpers.h" namespace ark::es2panda::ir { void SwitchStatement::TransformChildren(const NodeTransformer &cb, std::string_view transformationName) @@ -46,51 +43,6 @@ void SwitchStatement::Iterate(const NodeTraverser &cb) const } } -void SwitchStatement::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "SwitchStatement"}, {"discriminant", discriminant_}, {"cases", cases_}}); -} - -void SwitchStatement::Dump(ir::SrcDumper *dumper) const -{ - ES2PANDA_ASSERT(discriminant_); - dumper->Add("switch ("); - discriminant_->Dump(dumper); - dumper->Add(") {"); - if (!cases_.empty()) { - dumper->IncrIndent(); - dumper->Endl(); - for (auto cs : cases_) { - cs->Dump(dumper); - if (cs == cases_.back()) { - dumper->DecrIndent(); - } - dumper->Endl(); - } - } - dumper->Add("}"); -} - -void SwitchStatement::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void SwitchStatement::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *SwitchStatement::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType SwitchStatement::Check(checker::ETSChecker *const checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - SwitchStatement *SwitchStatement::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto *const discriminant = discriminant_->Clone(allocator, nullptr)->AsExpression(); diff --git a/ets2panda/ir/statements/throwStatement.cpp b/ets2panda/ir/statements/throwStatement.cpp index ee2f446c43799716cd4b22ec33d4e5abe8fd90c4..5a7554ea7fd8827b906f1b52b9616e44bf62d122 100644 --- a/ets2panda/ir/statements/throwStatement.cpp +++ b/ets2panda/ir/statements/throwStatement.cpp @@ -15,9 +15,7 @@ #include "throwStatement.h" -#include "checker/TSchecker.h" -#include "compiler/core/pandagen.h" -#include "compiler/core/ETSGen.h" +#include "ir/expression.h" namespace ark::es2panda::ir { void ThrowStatement::TransformChildren(const NodeTransformer &cb, std::string_view transformationName) @@ -33,39 +31,6 @@ void ThrowStatement::Iterate(const NodeTraverser &cb) const cb(argument_); } -void ThrowStatement::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "ThrowStatement"}, {"argument", argument_}}); -} - -void ThrowStatement::Dump(ir::SrcDumper *dumper) const -{ - ES2PANDA_ASSERT(Argument() != nullptr); - dumper->Add("throw "); - Argument()->Dump(dumper); - dumper->Add(";"); -} - -void ThrowStatement::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void ThrowStatement::Compile([[maybe_unused]] compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *ThrowStatement::Check([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType ThrowStatement::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - ThrowStatement *ThrowStatement::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto *const expression = argument_->Clone(allocator, nullptr)->AsExpression(); diff --git a/ets2panda/ir/statements/tryStatement.cpp b/ets2panda/ir/statements/tryStatement.cpp index acc5b4d085afe04bd1a49cb404958b038ad7b90d..d4ee0622cce751d373ce3ab758592fc411f97826 100644 --- a/ets2panda/ir/statements/tryStatement.cpp +++ b/ets2panda/ir/statements/tryStatement.cpp @@ -15,13 +15,9 @@ #include "tryStatement.h" -#include "checker/TSchecker.h" -#include "compiler/core/pandagen.h" -#include "compiler/core/ETSGen.h" #include "compiler/core/dynamicContext.h" #include "compiler/base/catchTable.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" + #include "ir/base/catchClause.h" #include "ir/statements/blockStatement.h" @@ -61,64 +57,11 @@ void TryStatement::Iterate(const NodeTraverser &cb) const } } -void TryStatement::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "TryStatement"}, - {"block", block_}, - {"handler", catchClauses_}, - {"finalizer", AstDumper::Nullish(finalizer_)}}); -} - -void TryStatement::Dump(ir::SrcDumper *dumper) const -{ - ES2PANDA_ASSERT(block_ != nullptr); - dumper->Add("try {"); - dumper->IncrIndent(); - dumper->Endl(); - block_->Dump(dumper); - dumper->DecrIndent(); - dumper->Endl(); - dumper->Add("}"); - for (auto clause : catchClauses_) { - dumper->Add(" catch "); - clause->Dump(dumper); - } - if (finalizer_ != nullptr) { - dumper->Add(" finally {"); - dumper->IncrIndent(); - dumper->Endl(); - finalizer_->Dump(dumper); - dumper->DecrIndent(); - dumper->Endl(); - dumper->Add("}"); - } -} - bool TryStatement::HasDefaultCatchClause() const { return (!catchClauses_.empty() && catchClauses_.back()->IsDefaultCatchClause()); } -void TryStatement::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void TryStatement::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *TryStatement::Check([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType TryStatement::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - TryStatement::TryStatement(TryStatement const &other, ArenaAllocator *allocator) : Statement(other), catchClauses_(allocator->Adapter()), diff --git a/ets2panda/ir/statements/variableDeclaration.cpp b/ets2panda/ir/statements/variableDeclaration.cpp index 0c1024b7a0a1900c1e65a89cd66c248db0434fad..0c9e5b7d90dc77d68724a19579905f7c36e20624 100644 --- a/ets2panda/ir/statements/variableDeclaration.cpp +++ b/ets2panda/ir/statements/variableDeclaration.cpp @@ -15,11 +15,6 @@ #include "variableDeclaration.h" -#include "checker/TSchecker.h" -#include "checker/ETSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "libarkbase/utils/arena_containers.h" namespace ark::es2panda::ir { @@ -77,71 +72,6 @@ void VariableDeclaration::Iterate(const NodeTraverser &cb) const } } -void VariableDeclaration::Dump(ir::AstDumper *dumper) const -{ - const char *kind = nullptr; - - switch (Kind()) { - case VariableDeclarationKind::CONST: { - kind = "const"; - break; - } - case VariableDeclarationKind::LET: { - kind = "let"; - break; - } - case VariableDeclarationKind::VAR: { - kind = "var"; - break; - } - default: { - ES2PANDA_UNREACHABLE(); - } - } - - dumper->Add({{"type", "VariableDeclaration"}, - {"declarations", Declarators()}, - {"kind", kind}, - {"annotations", AstDumper::Optional(Annotations())}, - {"declare", AstDumper::Optional(IsDeclare())}}); -} - -void VariableDeclaration::Dump(ir::SrcDumper *dumper) const -{ - DumpAnnotations(dumper); - - if (IsDeclare()) { - dumper->Add("declare "); - } - - switch (Kind()) { - case VariableDeclarationKind::CONST: - dumper->Add("const "); - break; - case VariableDeclarationKind::LET: - dumper->Add("let "); - break; - case VariableDeclarationKind::VAR: - dumper->Add("var "); - break; - default: - ES2PANDA_UNREACHABLE(); - } - - for (auto declarator : Declarators()) { - declarator->Dump(dumper); - if (declarator != Declarators().back()) { - dumper->Add(", "); - } - } - - auto const parent = Parent(); - if ((parent != nullptr) && - (parent->IsBlockStatement() || parent->IsBlockExpression() || parent->IsSwitchCaseStatement())) { - dumper->Add(";"); - } -} - VariableDeclaration::VariableDeclaration([[maybe_unused]] Tag const tag, VariableDeclaration const &other, ArenaAllocator *const allocator) : AnnotationAllowed(static_cast const &>(other)), @@ -193,26 +123,6 @@ VariableDeclaration *VariableDeclaration::Clone(ArenaAllocator *const allocator, return clone; } -void VariableDeclaration::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void VariableDeclaration::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *VariableDeclaration::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType VariableDeclaration::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - VariableDeclaration *VariableDeclaration::Construct(ArenaAllocator *allocator) { ArenaVector declarators(allocator->Adapter()); diff --git a/ets2panda/ir/statements/variableDeclarator.cpp b/ets2panda/ir/statements/variableDeclarator.cpp index 621d394dbddd3a6456ace50782677fe4aeaa4011..19a7a6b59c5d9bc12b35bcf32cb63622b88ae393 100644 --- a/ets2panda/ir/statements/variableDeclarator.cpp +++ b/ets2panda/ir/statements/variableDeclarator.cpp @@ -15,10 +15,7 @@ #include "variableDeclarator.h" -#include "compiler/core/pandagen.h" -#include "compiler/core/ETSGen.h" -#include "checker/TSchecker.h" -#include "checker/ETSchecker.h" +#include "ir/typeNode.h" namespace ark::es2panda::ir { void VariableDeclarator::TransformChildren(const NodeTransformer &cb, std::string_view transformationName) @@ -45,32 +42,6 @@ void VariableDeclarator::Iterate(const NodeTraverser &cb) const } } -void VariableDeclarator::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "VariableDeclarator"}, {"id", id_}, {"init", AstDumper::Nullish(init_)}}); -} - -void VariableDeclarator::Dump(ir::SrcDumper *dumper) const -{ - if (id_ != nullptr) { - id_->Dump(dumper); - if (id_->IsOptionalDeclaration()) { - dumper->Add("?"); - } - if (id_->IsAnnotatedExpression()) { - auto *type = id_->AsAnnotatedExpression()->TypeAnnotation(); - if (type != nullptr) { - dumper->Add(": "); - type->Dump(dumper); - } - } - } - if (init_ != nullptr) { - dumper->Add(" = "); - init_->Dump(dumper); - } -} - VariableDeclarator *VariableDeclarator::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto *const id = id_ != nullptr ? id_->Clone(allocator, nullptr)->AsExpression() : nullptr; @@ -94,23 +65,4 @@ VariableDeclarator *VariableDeclarator::Clone(ArenaAllocator *const allocator, A return clone; } -void VariableDeclarator::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void VariableDeclarator::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *VariableDeclarator::Check([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType VariableDeclarator::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/statements/whileStatement.cpp b/ets2panda/ir/statements/whileStatement.cpp index 5bdc886393ced88805b5fd6d7e863bba745f40a8..fa630082f38d820b9cca075365b9041bbca082c4 100644 --- a/ets2panda/ir/statements/whileStatement.cpp +++ b/ets2panda/ir/statements/whileStatement.cpp @@ -17,14 +17,13 @@ #include "compiler/base/condition.h" #include "compiler/core/labelTarget.h" -#include "compiler/core/pandagen.h" -#include "compiler/core/ETSGen.h" + #include "compiler/core/regScope.h" -#include "checker/TSchecker.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" + #include "ir/expression.h" +#include "util/helpers.h" + namespace ark::es2panda::ir { void WhileStatement::TransformChildren(const NodeTransformer &cb, std::string_view transformationName) { @@ -45,48 +44,6 @@ void WhileStatement::Iterate(const NodeTraverser &cb) const cb(body_); } -void WhileStatement::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "WhileStatement"}, {"test", test_}, {"body", body_}}); -} - -void WhileStatement::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add("while ("); - if (test_ != nullptr) { - test_->Dump(dumper); - } - dumper->Add(") {"); - if (body_ != nullptr) { - dumper->IncrIndent(); - dumper->Endl(); - body_->Dump(dumper); - dumper->DecrIndent(); - dumper->Endl(); - } - dumper->Add("}"); -} - -void WhileStatement::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void WhileStatement::Compile([[maybe_unused]] compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *WhileStatement::Check([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType WhileStatement::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - WhileStatement *WhileStatement::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto *const test = test_->Clone(allocator, nullptr)->AsExpression(); diff --git a/ets2panda/ir/ts/tsAnyKeyword.cpp b/ets2panda/ir/ts/tsAnyKeyword.cpp index d2e6f0505768208bc9363d79ce3b6581c1c4f9d5..4c85c469cf7e25ce7d459c3dbf4910f45eb0b3dc 100644 --- a/ets2panda/ir/ts/tsAnyKeyword.cpp +++ b/ets2panda/ir/ts/tsAnyKeyword.cpp @@ -15,12 +15,6 @@ #include "tsAnyKeyword.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" - namespace ark::es2panda::ir { void TSAnyKeyword::TransformChildren([[maybe_unused]] const NodeTransformer &cb, [[maybe_unused]] std::string_view const transformationName) @@ -33,39 +27,4 @@ void TSAnyKeyword::Iterate(const NodeTraverser &cb) const IterateAnnotations(cb); } -void TSAnyKeyword::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "TSAnyKeyword"}, {"annotations", AstDumper::Optional(Annotations())}}); -} - -void TSAnyKeyword::Dump(ir::SrcDumper *dumper) const -{ - DumpAnnotations(dumper); - dumper->Add("TSAnyKeyword"); -} - -void TSAnyKeyword::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void TSAnyKeyword::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *TSAnyKeyword::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::Type *TSAnyKeyword::GetType([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GlobalAnyType(); -} - -checker::VerifiedType TSAnyKeyword::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/ts/tsArrayType.cpp b/ets2panda/ir/ts/tsArrayType.cpp index 970e2762306f8b11ff8a5db72ff2fd899a8a96d8..ba261fac4c23055a82c0246fd7dc4a63f3cf273f 100644 --- a/ets2panda/ir/ts/tsArrayType.cpp +++ b/ets2panda/ir/ts/tsArrayType.cpp @@ -15,11 +15,6 @@ #include "tsArrayType.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "checker/TSchecker.h" -#include "checker/ETSchecker.h" - namespace ark::es2panda::ir { void TSArrayType::TransformChildren(const NodeTransformer &cb, std::string_view transformationName) { @@ -37,62 +32,6 @@ void TSArrayType::Iterate(const NodeTraverser &cb) const IterateAnnotations(cb); } -void TSArrayType::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "TSArrayType"}, {"elementType", elementType_}, {"annotations", Annotations()}}); -} - -void TSArrayType::Dump(ir::SrcDumper *dumper) const -{ - DumpAnnotations(dumper); - ES2PANDA_ASSERT(elementType_); - if (elementType_->IsETSUnionType()) { - dumper->Add("("); - } - - elementType_->Dump(dumper); - - if (elementType_->IsETSUnionType()) { - dumper->Add(")"); - } - dumper->Add("[]"); -} - -void TSArrayType::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void TSArrayType::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *TSArrayType::Check([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::Type *TSArrayType::GetType([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->Allocator()->New(elementType_->GetType(checker)); -} - -checker::VerifiedType TSArrayType::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - -checker::Type *TSArrayType::GetType(checker::ETSChecker *checker) -{ - checker::Type *type = checker->CreateETSArrayType(elementType_->GetType(checker), IsReadonlyType()); - if (IsReadonlyType()) { - type = checker->GetReadonlyType(type); - } - SetTsType(type); - return type; -} - TSArrayType *TSArrayType::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto *const elementTypeClone = elementType_ != nullptr ? elementType_->Clone(allocator, nullptr) : nullptr; diff --git a/ets2panda/ir/ts/tsAsExpression.cpp b/ets2panda/ir/ts/tsAsExpression.cpp index 90f1c4efca62ac78f03fd0faadde2c6154d6b020..fa7c9cbe826ce18a14a858d9cc6a77bd019e2884 100644 --- a/ets2panda/ir/ts/tsAsExpression.cpp +++ b/ets2panda/ir/ts/tsAsExpression.cpp @@ -15,10 +15,9 @@ #include "tsAsExpression.h" -#include "checker/TSchecker.h" -#include "checker/ETSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" +#include "ir/typeNode.h" + +#include "parser/program/program.h" namespace ark::es2panda::ir { Expression *TSAsExpression::Expr() noexcept @@ -56,40 +55,6 @@ void TSAsExpression::Iterate(const NodeTraverser &cb) const cb(TypeAnnotation()); } -void TSAsExpression::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "TSAsExpression"}, {"expression", expression_}, {"typeAnnotation", TypeAnnotation()}}); -} - -void TSAsExpression::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add("("); - expression_->Dump(dumper); - dumper->Add(" as "); - TypeAnnotation()->Dump(dumper); - dumper->Add(")"); -} - -void TSAsExpression::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void TSAsExpression::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *TSAsExpression::Check([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType TSAsExpression::Check(checker::ETSChecker *const checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - TSAsExpression *TSAsExpression::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto *const expression = expression_ != nullptr ? expression_->Clone(allocator, nullptr)->AsExpression() : nullptr; diff --git a/ets2panda/ir/ts/tsAsExpression.h b/ets2panda/ir/ts/tsAsExpression.h index fe62b1594e6f713724bc0b49a24270b0070dc7cd..15c38f4e5ad577672dbfb70f21f9d66246dad82e 100644 --- a/ets2panda/ir/ts/tsAsExpression.h +++ b/ets2panda/ir/ts/tsAsExpression.h @@ -16,8 +16,6 @@ #ifndef ES2PANDA_IR_TS_AS_EXPRESSION_H #define ES2PANDA_IR_TS_AS_EXPRESSION_H -#include "ir/astDump.h" -#include "ir/srcDump.h" #include "ir/expression.h" namespace ark::es2panda::checker { class ETSAnalyzer; diff --git a/ets2panda/ir/ts/tsBigintKeyword.cpp b/ets2panda/ir/ts/tsBigintKeyword.cpp index ce2950480b50f8ec8641043b293d2b4902890b00..f2b29dd423ac3a8969267f07d171bd81c3178ebf 100644 --- a/ets2panda/ir/ts/tsBigintKeyword.cpp +++ b/ets2panda/ir/ts/tsBigintKeyword.cpp @@ -15,13 +15,6 @@ #include "tsBigintKeyword.h" -#include "checker/ETSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" -#include "checker/TSchecker.h" - namespace ark::es2panda::ir { void TSBigintKeyword::TransformChildren([[maybe_unused]] const NodeTransformer &cb, [[maybe_unused]] std::string_view const transformationName) @@ -34,38 +27,4 @@ void TSBigintKeyword::Iterate(const NodeTraverser &cb) const IterateAnnotations(cb); } -void TSBigintKeyword::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "TSBigIntKeyword"}, {"annotations", AstDumper::Optional(Annotations())}}); -} - -void TSBigintKeyword::Dump(ir::SrcDumper *dumper) const -{ - DumpAnnotations(dumper); - dumper->Add("TSBigintKeyword"); -} - -void TSBigintKeyword::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} -void TSBigintKeyword::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *TSBigintKeyword::Check([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::Type *TSBigintKeyword::GetType([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GlobalBigintType(); -} - -checker::VerifiedType TSBigintKeyword::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/ts/tsBooleanKeyword.cpp b/ets2panda/ir/ts/tsBooleanKeyword.cpp index 62244a79bb2ae5e4108c434048849279cffb2a6f..22359c71bca376d746f35e7fe11c3cf638808b62 100644 --- a/ets2panda/ir/ts/tsBooleanKeyword.cpp +++ b/ets2panda/ir/ts/tsBooleanKeyword.cpp @@ -15,12 +15,6 @@ #include "tsBooleanKeyword.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" - namespace ark::es2panda::ir { void TSBooleanKeyword::TransformChildren([[maybe_unused]] const NodeTransformer &cb, [[maybe_unused]] std::string_view const transformationName) @@ -33,42 +27,6 @@ void TSBooleanKeyword::Iterate(const NodeTraverser &cb) const IterateAnnotations(cb); } -void TSBooleanKeyword::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "TSBooleanKeyword"}, {"annotations", AstDumper::Optional(Annotations())}}); -} - -void TSBooleanKeyword::Dump(ir::SrcDumper *dumper) const -{ - DumpAnnotations(dumper); - dumper->Add("TSBooleanKeyword"); -} - -void TSBooleanKeyword::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void TSBooleanKeyword::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *TSBooleanKeyword::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::Type *TSBooleanKeyword::GetType([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GlobalBooleanType(); -} - -checker::VerifiedType TSBooleanKeyword::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - TSBooleanKeyword *TSBooleanKeyword::Clone(ArenaAllocator *allocator, AstNode *parent) { auto *clone = allocator->New(allocator); diff --git a/ets2panda/ir/ts/tsClassImplements.cpp b/ets2panda/ir/ts/tsClassImplements.cpp index dfe2da11dfcbe9f307f31a704ca4c1adc08c5277..5a87db0c15ccc310d4def251796e13352ac64576 100644 --- a/ets2panda/ir/ts/tsClassImplements.cpp +++ b/ets2panda/ir/ts/tsClassImplements.cpp @@ -15,11 +15,6 @@ #include "tsClassImplements.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" #include "ir/ts/tsTypeParameter.h" #include "ir/ts/tsTypeParameterInstantiation.h" @@ -41,36 +36,4 @@ void TSClassImplements::Iterate(const NodeTraverser &cb) const } } -void TSClassImplements::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "TSClassImplements"}, - {"expression", expression_}, - {"typeParameters", AstDumper::Optional(typeParameters_)}}); -} - -void TSClassImplements::Dump(ir::SrcDumper *dumper) const -{ - expression_->Dump(dumper); - ES2PANDA_ASSERT(typeParameters_ == nullptr); -} - -void TSClassImplements::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void TSClassImplements::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *TSClassImplements::Check([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType TSClassImplements::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/ts/tsConditionalType.cpp b/ets2panda/ir/ts/tsConditionalType.cpp index 4e5e61df5205f7cf4bd5083d3c4325caff33a468..c7344ede6813af1be50785d58f733a5f157a5a21 100644 --- a/ets2panda/ir/ts/tsConditionalType.cpp +++ b/ets2panda/ir/ts/tsConditionalType.cpp @@ -15,12 +15,6 @@ #include "tsConditionalType.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" - namespace ark::es2panda::ir { void TSConditionalType::TransformChildren(const NodeTransformer &cb, std::string_view transformationName) { @@ -56,43 +50,4 @@ void TSConditionalType::Iterate(const NodeTraverser &cb) const IterateAnnotations(cb); } -void TSConditionalType::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "TSConditionalType"}, - {"checkType", checkType_}, - {"extendsType", extendsType_}, - {"trueType", trueType_}, - {"falseType", falseType_}, - {"annotations", AstDumper::Optional(Annotations())}}); -} - -void TSConditionalType::Dump(ir::SrcDumper *dumper) const -{ - DumpAnnotations(dumper); - dumper->Add("TSConditionalType"); -} - -void TSConditionalType::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} -void TSConditionalType::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *TSConditionalType::Check([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::Type *TSConditionalType::GetType([[maybe_unused]] checker::TSChecker *checker) -{ - return nullptr; -} - -checker::VerifiedType TSConditionalType::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/ts/tsConditionalType.h b/ets2panda/ir/ts/tsConditionalType.h index 0750383584e62b122b019ba08474b4f3e94321d7..aee95878e4a67de88cad4cc7f633f1025b94ab5f 100644 --- a/ets2panda/ir/ts/tsConditionalType.h +++ b/ets2panda/ir/ts/tsConditionalType.h @@ -58,7 +58,6 @@ public: void Compile([[maybe_unused]] compiler::PandaGen *pg) const override; void Compile(compiler::ETSGen *etsg) const override; checker::Type *Check([[maybe_unused]] checker::TSChecker *checker) override; - checker::Type *GetType([[maybe_unused]] checker::TSChecker *checker) override; checker::VerifiedType Check([[maybe_unused]] checker::ETSChecker *checker) override; void Accept(ASTVisitorT *v) override diff --git a/ets2panda/ir/ts/tsConstructorType.cpp b/ets2panda/ir/ts/tsConstructorType.cpp index 0320d2f8c87a28c3f10d8ab16002b42717bde9a5..203c8c786631167f73d7651a125543e3a23293aa 100644 --- a/ets2panda/ir/ts/tsConstructorType.cpp +++ b/ets2panda/ir/ts/tsConstructorType.cpp @@ -15,12 +15,7 @@ #include "tsConstructorType.h" -#include "checker/TSchecker.h" #include "checker/types/signature.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" namespace ark::es2panda::ir { void TSConstructorType::TransformChildren(const NodeTransformer &cb, std::string_view const transformationName) @@ -35,43 +30,4 @@ void TSConstructorType::Iterate(const NodeTraverser &cb) const IterateAnnotations(cb); } -void TSConstructorType::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "TSConstructorType"}, - {"params", signature_.Params()}, - {"typeParameters", AstDumper::Optional(signature_.TypeParams())}, - {"returnType", signature_.ReturnType()}, - {"abstract", AstDumper::Optional(abstract_)}, - {"annotations", AstDumper::Optional(Annotations())}}); -} - -void TSConstructorType::Dump(ir::SrcDumper *dumper) const -{ - DumpAnnotations(dumper); - dumper->Add("TSConstructorType"); -} - -void TSConstructorType::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} -void TSConstructorType::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *TSConstructorType::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::Type *TSConstructorType::GetType(checker::TSChecker *checker) -{ - return checker->CheckTypeCached(this); -} - -checker::VerifiedType TSConstructorType::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/ts/tsEnumDeclaration.cpp b/ets2panda/ir/ts/tsEnumDeclaration.cpp index 1844877e318427ba647b7dfc8cc5ed75ec0b7ad3..20b833cdd680900b960f9bae641322eedb3650d9 100644 --- a/ets2panda/ir/ts/tsEnumDeclaration.cpp +++ b/ets2panda/ir/ts/tsEnumDeclaration.cpp @@ -16,13 +16,12 @@ #include "tsEnumDeclaration.h" #include -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" #include "util/helpers.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" -#include "libarkbase/utils/arena_containers.h" +#include "ir/expressions/identifier.h" +#include "ir/expressions/memberExpression.h" +#include "ir/expressions/literals/stringLiteral.h" + + namespace ark::es2panda::ir { @@ -68,113 +67,6 @@ void TSEnumDeclaration::Iterate(const NodeTraverser &cb) const } } -void TSEnumDeclaration::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "TSEnumDeclaration"}, - {"id", Key()}, - {"members", Members()}, - {"const", IsConst()}, - {"declare", IsDeclare()}}); -} - -bool TSEnumDeclaration::RegisterUnexportedForDeclGen(ir::SrcDumper *dumper) const -{ - ES2PANDA_ASSERT(dumper->IsDeclgen()); - - if (dumper->GetDeclgen()->IsPostDumpIndirectDepsPhase()) { - return false; - } - - if (key_->Parent()->IsDefaultExported() || key_->Parent()->IsExported()) { - return false; - } - - auto name = key_->AsIdentifier()->Name().Mutf8(); - dumper->GetDeclgen()->AddNode(name, this); - return true; -} - -void TSEnumDeclaration::Dump(ir::SrcDumper *dumper) const -{ - auto guard = dumper->BuildAmbientContextGuard(); - ES2PANDA_ASSERT(isConst_ == false); - ES2PANDA_ASSERT(key_ != nullptr); - if (dumper->IsDeclgen() && RegisterUnexportedForDeclGen(dumper)) { - return; - } - if (key_->Parent()->IsExported() && dumper->IsDeclgen()) { - dumper->Add("export "); - } else if (key_->Parent()->IsDefaultExported() && dumper->IsDeclgen()) { - dumper->Add("export default "); - } - if (dumper->IsDeclgen()) { - dumper->GetDeclgen()->TryDeclareAmbientContext(dumper); - } else if (IsDeclare()) { - dumper->Add("declare "); - } - dumper->Add("enum "); - Key()->Dump(dumper); - dumper->Add(" {"); - auto const members = Members(); - if (!members.empty()) { - dumper->IncrIndent(); - dumper->Endl(); - for (auto member : members) { - member->Dump(dumper); - if (member != members.back()) { - dumper->Add(","); - dumper->Endl(); - } - } - dumper->DecrIndent(); - dumper->Endl(); - } - dumper->Add("}"); - dumper->Endl(); -} - -// NOTE (csabahurton): this method has not been moved to TSAnalyizer.cpp, because it is not used. -varbinder::EnumMemberResult EvaluateMemberExpression(checker::TSChecker *checker, - [[maybe_unused]] varbinder::EnumVariable *enumVar, - ir::MemberExpression *expr) -{ - if (checker::TSChecker::IsConstantMemberAccess(expr->AsExpression())) { - if (expr->Check(checker)->TypeFlags() == checker::TypeFlag::ENUM) { - util::StringView name; - if (!expr->IsComputed()) { - name = expr->Property()->AsIdentifier()->Name(); - } else { - ES2PANDA_ASSERT(checker::TSChecker::IsStringLike(expr->Property())); - name = reinterpret_cast(expr->Property())->Str(); - } - - // NOTE: aszilagyi. - } - } - - return false; -} - -void TSEnumDeclaration::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void TSEnumDeclaration::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *TSEnumDeclaration::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType TSEnumDeclaration::Check(checker::ETSChecker *const checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - TSEnumDeclaration *TSEnumDeclaration::Construct(ArenaAllocator *allocator) { ArenaVector members(allocator->Adapter()); diff --git a/ets2panda/ir/ts/tsEnumMember.cpp b/ets2panda/ir/ts/tsEnumMember.cpp index f4f126095afdeed1b303c2dfceb7b419125489c3..2471c0a1a653e8b2fcc11d2ed346d860013a72b0 100644 --- a/ets2panda/ir/ts/tsEnumMember.cpp +++ b/ets2panda/ir/ts/tsEnumMember.cpp @@ -15,11 +15,8 @@ #include "tsEnumMember.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" +#include "ir/expression.h" +#include "ir/expressions/identifier.h" namespace ark::es2panda::ir { void TSEnumMember::TransformChildren(const NodeTransformer &cb, std::string_view transformationName) @@ -46,44 +43,10 @@ void TSEnumMember::Iterate(const NodeTraverser &cb) const } } -void TSEnumMember::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "TSEnumMember"}, {"id", key_}, {"initializer", AstDumper::Optional(init_)}}); -} - -void TSEnumMember::Dump(ir::SrcDumper *dumper) const -{ - ES2PANDA_ASSERT(key_ != nullptr); - key_->Dump(dumper); - if (init_ != nullptr) { - dumper->Add(" = "); - init_->Dump(dumper); - } -} - util::StringView TSEnumMember::Name() const { ES2PANDA_ASSERT(key_->IsIdentifier()); return key_->AsIdentifier()->Name(); } -void TSEnumMember::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void TSEnumMember::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *TSEnumMember::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType TSEnumMember::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/ts/tsExternalModuleReference.cpp b/ets2panda/ir/ts/tsExternalModuleReference.cpp index 12207c3d4f1c83ee5d547b41505baaa37d5e4100..398ffb5f0350ecea0108cb9b07ef534bd387287c 100644 --- a/ets2panda/ir/ts/tsExternalModuleReference.cpp +++ b/ets2panda/ir/ts/tsExternalModuleReference.cpp @@ -15,12 +15,6 @@ #include "tsExternalModuleReference.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" - namespace ark::es2panda::ir { void TSExternalModuleReference::TransformChildren(const NodeTransformer &cb, std::string_view transformationName) { @@ -35,33 +29,4 @@ void TSExternalModuleReference::Iterate(const NodeTraverser &cb) const cb(expr_); } -void TSExternalModuleReference::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "TSExternalModuleReference"}, {"expression", expr_}}); -} - -void TSExternalModuleReference::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add("TSExternalModuleReference"); -} - -void TSExternalModuleReference::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void TSExternalModuleReference::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *TSExternalModuleReference::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType TSExternalModuleReference::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/ts/tsFunctionType.cpp b/ets2panda/ir/ts/tsFunctionType.cpp index e12589bd31cf2b2adebb5f2848da38ab4939c0d8..a4ee8683e93a66d93714b2596b47fcb835b5e0db 100644 --- a/ets2panda/ir/ts/tsFunctionType.cpp +++ b/ets2panda/ir/ts/tsFunctionType.cpp @@ -15,13 +15,9 @@ #include "tsFunctionType.h" -#include "checker/TSchecker.h" -#include "checker/ETSchecker.h" #include "checker/types/signature.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" + +#include "ir/ts/tsTypeParameterDeclaration.h" namespace ark::es2panda::ir { void TSFunctionType::TransformChildren(const NodeTransformer &cb, std::string_view const transformationName) @@ -35,51 +31,6 @@ void TSFunctionType::Iterate(const NodeTraverser &cb) const signature_.Iterate(cb); } -void TSFunctionType::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "TSFunctionType"}, - {"params", signature_.Params()}, - {"typeParameters", AstDumper::Optional(signature_.TypeParams())}, - {"returnType", signature_.ReturnType()}, - {"isNullable", AstDumper::Optional(nullable_)}, - {"annotations", AstDumper::Optional(Annotations())}}); -} - -void TSFunctionType::Dump(ir::SrcDumper *dumper) const -{ - DumpAnnotations(dumper); - dumper->Add("TSFunctionType"); -} - -void TSFunctionType::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} -void TSFunctionType::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *TSFunctionType::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::Type *TSFunctionType::GetType(checker::TSChecker *checker) -{ - return checker->CheckTypeCached(this); -} - -checker::VerifiedType TSFunctionType::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - -checker::Type *TSFunctionType::GetType([[maybe_unused]] checker::ETSChecker *checker) -{ - return nullptr; -} - TSFunctionType *TSFunctionType::Clone(ArenaAllocator *allocator, AstNode *parent) { // Clone the function signature diff --git a/ets2panda/ir/ts/tsFunctionType.h b/ets2panda/ir/ts/tsFunctionType.h index dcf8375b4c4f1e44f637e203fd3e7da0fb00d4be..33363543a870668faa9e4ede24423df748c3f861 100644 --- a/ets2panda/ir/ts/tsFunctionType.h +++ b/ets2panda/ir/ts/tsFunctionType.h @@ -93,7 +93,6 @@ public: checker::Type *Check([[maybe_unused]] checker::TSChecker *checker) override; checker::Type *GetType([[maybe_unused]] checker::TSChecker *checker) override; checker::VerifiedType Check([[maybe_unused]] checker::ETSChecker *checker) override; - checker::Type *GetType([[maybe_unused]] checker::ETSChecker *checker) override; TSFunctionType *Clone(ArenaAllocator *allocator, AstNode *parent) override; diff --git a/ets2panda/ir/ts/tsImportEqualsDeclaration.cpp b/ets2panda/ir/ts/tsImportEqualsDeclaration.cpp index efaa3883806d54e1b86ff8aa8bf051597ef6a363..54a76a7d302a76f21914f3ad9197159772a730f9 100644 --- a/ets2panda/ir/ts/tsImportEqualsDeclaration.cpp +++ b/ets2panda/ir/ts/tsImportEqualsDeclaration.cpp @@ -15,11 +15,6 @@ #include "tsImportEqualsDeclaration.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" #include "ir/expression.h" #include "ir/expressions/identifier.h" @@ -43,35 +38,4 @@ void TSImportEqualsDeclaration::Iterate(const NodeTraverser &cb) const cb(moduleReference_); } -void TSImportEqualsDeclaration::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "TSImportEqualsDeclaration"}, - {"id", id_}, - {"moduleReference", moduleReference_}, - {"isExport", isExport_}}); -} - -void TSImportEqualsDeclaration::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add("TSImportEqualsDeclaration"); -} - -void TSImportEqualsDeclaration::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} -void TSImportEqualsDeclaration::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *TSImportEqualsDeclaration::Check([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType TSImportEqualsDeclaration::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/ts/tsImportType.cpp b/ets2panda/ir/ts/tsImportType.cpp index 5762b63a592e4c3600a3281991b13981fa20b2fe..00731a74cc08d2df5406738fc0d551f11925ac3d 100644 --- a/ets2panda/ir/ts/tsImportType.cpp +++ b/ets2panda/ir/ts/tsImportType.cpp @@ -15,11 +15,6 @@ #include "tsImportType.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" #include "ir/ts/tsTypeParameter.h" #include "ir/ts/tsTypeParameterInstantiation.h" @@ -63,44 +58,4 @@ void TSImportType::Iterate(const NodeTraverser &cb) const IterateAnnotations(cb); } -void TSImportType::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "TSImportType"}, - {"parameter", param_}, - {"qualifier", AstDumper::Optional(qualifier_)}, - {"typeParameters", AstDumper::Optional(typeParams_)}, - {"isTypeOf", isTypeof_}, - {"annotations", AstDumper::Optional(Annotations())}}); -} - -void TSImportType::Dump(ir::SrcDumper *dumper) const -{ - DumpAnnotations(dumper); - dumper->Add("TSImportType"); -} - -void TSImportType::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void TSImportType::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *TSImportType::Check([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::Type *TSImportType::GetType([[maybe_unused]] checker::TSChecker *checker) -{ - return nullptr; -} - -checker::VerifiedType TSImportType::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/ts/tsImportType.h b/ets2panda/ir/ts/tsImportType.h index f57b659efda5a54a7ccbaf4c81e9745691d62320..fdd2966d800fc820ec198784655e84fc199b84b2 100644 --- a/ets2panda/ir/ts/tsImportType.h +++ b/ets2panda/ir/ts/tsImportType.h @@ -60,7 +60,6 @@ public: void Compile([[maybe_unused]] compiler::PandaGen *pg) const override; void Compile(compiler::ETSGen *etsg) const override; checker::Type *Check([[maybe_unused]] checker::TSChecker *checker) override; - checker::Type *GetType([[maybe_unused]] checker::TSChecker *checker) override; checker::VerifiedType Check([[maybe_unused]] checker::ETSChecker *checker) override; void Accept(ASTVisitorT *v) override diff --git a/ets2panda/ir/ts/tsIndexedAccessType.cpp b/ets2panda/ir/ts/tsIndexedAccessType.cpp index 73270348c9381dcadef467f29937043152d61334..746ff32fefa1a58033c41dd2990770e4f260320f 100644 --- a/ets2panda/ir/ts/tsIndexedAccessType.cpp +++ b/ets2panda/ir/ts/tsIndexedAccessType.cpp @@ -15,13 +15,6 @@ #include "tsIndexedAccessType.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" - -#include "checker/TSchecker.h" - namespace ark::es2panda::ir { void TSIndexedAccessType::TransformChildren(const NodeTransformer &cb, std::string_view transformationName) { @@ -45,52 +38,6 @@ void TSIndexedAccessType::Iterate(const NodeTraverser &cb) const IterateAnnotations(cb); } -void TSIndexedAccessType::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "TSIndexedAccessType"}, - {"objectType", objectType_}, - {"indexType", indexType_}, - {"annotations", AstDumper::Optional(Annotations())}}); -} - -void TSIndexedAccessType::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add("TSIndexedAccessType"); -} - -void TSIndexedAccessType::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} -void TSIndexedAccessType::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *TSIndexedAccessType::Check([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::Type *TSIndexedAccessType::GetType([[maybe_unused]] checker::TSChecker *checker) -{ - if (TsType() != nullptr) { - return TsType(); - } - - checker::Type *baseType = objectType_->GetType(checker); - checker::Type *indexType = indexType_->GetType(checker); - checker::Type *resolved = checker->GetPropertyTypeForIndexType(baseType, indexType); - - SetTsType(resolved); - return TsType(); -} - -checker::VerifiedType TSIndexedAccessType::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - TSIndexedAccessType *TSIndexedAccessType::Clone(ArenaAllocator *allocator, AstNode *parent) { auto *clonedObjectType = objectType_->Clone(allocator, nullptr)->AsTypeNode(); diff --git a/ets2panda/ir/ts/tsInferType.cpp b/ets2panda/ir/ts/tsInferType.cpp index 98d102636eb732ddaf609ae0118548aca8ba274f..92795cc6f07451e1aabd11a2855bd1d521db2369 100644 --- a/ets2panda/ir/ts/tsInferType.cpp +++ b/ets2panda/ir/ts/tsInferType.cpp @@ -15,11 +15,6 @@ #include "tsInferType.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" #include "ir/ts/tsTypeParameter.h" namespace ark::es2panda::ir { @@ -39,39 +34,4 @@ void TSInferType::Iterate(const NodeTraverser &cb) const IterateAnnotations(cb); } -void TSInferType::Dump(ir::AstDumper *dumper) const -{ - dumper->Add( - {{"type", "TSInferType"}, {"typeParameter", typeParam_}, {"annotations", AstDumper::Optional(Annotations())}}); -} - -void TSInferType::Dump(ir::SrcDumper *dumper) const -{ - DumpAnnotations(dumper); - dumper->Add("TSInferType"); -} - -void TSInferType::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} -void TSInferType::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *TSInferType::Check([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::Type *TSInferType::GetType([[maybe_unused]] checker::TSChecker *checker) -{ - return nullptr; -} - -checker::VerifiedType TSInferType::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/ts/tsInferType.h b/ets2panda/ir/ts/tsInferType.h index 64057b5ae8a4d67845ac792cbb6ebfd3f4b30c17..8081d597fe41b896998214a6e843ef5843778dc8 100644 --- a/ets2panda/ir/ts/tsInferType.h +++ b/ets2panda/ir/ts/tsInferType.h @@ -40,7 +40,6 @@ public: void Compile([[maybe_unused]] compiler::PandaGen *pg) const override; void Compile(compiler::ETSGen *etsg) const override; checker::Type *Check([[maybe_unused]] checker::TSChecker *checker) override; - checker::Type *GetType([[maybe_unused]] checker::TSChecker *checker) override; checker::VerifiedType Check([[maybe_unused]] checker::ETSChecker *checker) override; void Accept(ASTVisitorT *v) override diff --git a/ets2panda/ir/ts/tsInterfaceBody.cpp b/ets2panda/ir/ts/tsInterfaceBody.cpp index c98011586e72d10d5c8542bde8639559aae31870..bbeb43deceb74b2bccb3cbbb64a78c13cfffe95d 100644 --- a/ets2panda/ir/ts/tsInterfaceBody.cpp +++ b/ets2panda/ir/ts/tsInterfaceBody.cpp @@ -15,12 +15,6 @@ #include "tsInterfaceBody.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" - namespace ark::es2panda::ir { void TSInterfaceBody::TransformChildren(const NodeTransformer &cb, std::string_view transformationName) { @@ -40,35 +34,4 @@ void TSInterfaceBody::Iterate(const NodeTraverser &cb) const } } -void TSInterfaceBody::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "TSInterfaceBody"}, {"body", body_}}); -} - -void TSInterfaceBody::Dump(ir::SrcDumper *dumper) const -{ - for (auto b : body_) { - b->Dump(dumper); - } -} - -void TSInterfaceBody::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void TSInterfaceBody::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *TSInterfaceBody::Check([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType TSInterfaceBody::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/ts/tsInterfaceDeclaration.cpp b/ets2panda/ir/ts/tsInterfaceDeclaration.cpp index 64b6df20f0e2dc3e410add555fe2a9d302207f28..990fc6de82249930187b09ba1af3fb02dea877af 100644 --- a/ets2panda/ir/ts/tsInterfaceDeclaration.cpp +++ b/ets2panda/ir/ts/tsInterfaceDeclaration.cpp @@ -16,15 +16,8 @@ #include "tsInterfaceDeclaration.h" #include "util/es2pandaMacros.h" -#include "libarkbase/utils/arena_containers.h" #include "varbinder/declaration.h" #include "varbinder/variable.h" -#include "checker/TSchecker.h" -#include "checker/ETSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" #include "ir/expressions/identifier.h" #include "ir/ts/tsInterfaceBody.h" @@ -144,110 +137,6 @@ void TSInterfaceDeclaration::Iterate(const NodeTraverser &cb) const cb(body); } -void TSInterfaceDeclaration::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "TSInterfaceDeclaration"}, - {"annotations", AstDumper::Optional(Annotations())}, - {"body", Body()}, - {"id", Id()}, - {"extends", Extends()}, - {"typeParameters", AstDumper::Optional(TypeParams())}}); -} - -bool TSInterfaceDeclaration::RegisterUnexportedForDeclGen(ir::SrcDumper *dumper) const -{ - // This method isn't used. - ES2PANDA_ASSERT(false); - ES2PANDA_ASSERT(dumper->IsDeclgen()); - - if (dumper->GetDeclgen()->IsPostDumpIndirectDepsPhase()) { - return false; - } - - if (id_->Parent()->IsDefaultExported() || id_->Parent()->IsExported()) { - return false; - } - - auto name = id_->Name().Mutf8(); - dumper->GetDeclgen()->AddNode(name, this); - return true; -} - -void TSInterfaceDeclaration::Dump(ir::SrcDumper *dumper) const -{ - auto guard = dumper->BuildAmbientContextGuard(); - ES2PANDA_ASSERT(id_); - if (!id_->Parent()->IsDefaultExported() && !id_->Parent()->IsExported() && dumper->IsDeclgen() && - !dumper->GetDeclgen()->IsPostDumpIndirectDepsPhase()) { - auto name = id_->Name().Mutf8(); - dumper->GetDeclgen()->AddNode(name, this); - return; - } - DumpAnnotations(dumper); - if (id_->Parent()->IsExported()) { - dumper->Add("export "); - } else if (id_->Parent()->IsDefaultExported()) { - dumper->Add("export default "); - } - if (dumper->IsDeclgen()) { - dumper->GetDeclgen()->TryDeclareAmbientContext(dumper); - } else if (IsDeclare()) { - dumper->Add("declare "); - } - dumper->Add("interface "); - Id()->Dump(dumper); - - auto const typeParams = TypeParams(); - if (typeParams != nullptr) { - dumper->Add("<"); - typeParams->Dump(dumper); - dumper->Add(">"); - } - - auto const extends = Extends(); - if (!extends.empty()) { - dumper->Add(" extends "); - for (auto ext : extends) { - ext->Dump(dumper); - if (ext != extends.back()) { - dumper->Add(", "); - } - } - } - - auto body = Body(); - dumper->Add(" {"); - if (body != nullptr) { - dumper->IncrIndent(); - dumper->Endl(); - body->Dump(dumper); - dumper->DecrIndent(); - dumper->Endl(); - } - dumper->Add("}"); - dumper->Endl(); -} - -void TSInterfaceDeclaration::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void TSInterfaceDeclaration::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *TSInterfaceDeclaration::Check([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType TSInterfaceDeclaration::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - TSInterfaceDeclaration *TSInterfaceDeclaration::Construct(ArenaAllocator *allocator) { ArenaVector extends(allocator->Adapter()); diff --git a/ets2panda/ir/ts/tsInterfaceHeritage.cpp b/ets2panda/ir/ts/tsInterfaceHeritage.cpp index c87aff667f9ba184f0436224eaa38ecae4d0a08a..64f3ff2743214fb02018bba89df4880dec77a8b6 100644 --- a/ets2panda/ir/ts/tsInterfaceHeritage.cpp +++ b/ets2panda/ir/ts/tsInterfaceHeritage.cpp @@ -15,11 +15,7 @@ #include "tsInterfaceHeritage.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" +#include "ir/typeNode.h" namespace ark::es2panda::ir { void TSInterfaceHeritage::TransformChildren(const NodeTransformer &cb, std::string_view transformationName) @@ -35,37 +31,4 @@ void TSInterfaceHeritage::Iterate(const NodeTraverser &cb) const cb(expr_); } -void TSInterfaceHeritage::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({ - {"type", "TSInterfaceHeritage"}, - {"expression", expr_}, - }); -} - -void TSInterfaceHeritage::Dump(ir::SrcDumper *dumper) const -{ - ES2PANDA_ASSERT(expr_ != nullptr); - expr_->Dump(dumper); -} - -void TSInterfaceHeritage::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void TSInterfaceHeritage::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *TSInterfaceHeritage::Check([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType TSInterfaceHeritage::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/ts/tsIntersectionType.cpp b/ets2panda/ir/ts/tsIntersectionType.cpp index 8305344470be121a34397f060e02bcab791398d8..4f50b8740a11a4f4cd0df9225ddfdaeba632dee3 100644 --- a/ets2panda/ir/ts/tsIntersectionType.cpp +++ b/ets2panda/ir/ts/tsIntersectionType.cpp @@ -15,12 +15,7 @@ #include "tsIntersectionType.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" -#include "checker/ETSchecker.h" +#include "checker/types/ets/etsObjectType.h" namespace ark::es2panda::ir { void TSIntersectionType::TransformChildren(const NodeTransformer &cb, std::string_view const transformationName) @@ -44,45 +39,4 @@ void TSIntersectionType::Iterate(const NodeTraverser &cb) const IterateAnnotations(cb); } -void TSIntersectionType::Dump(ir::AstDumper *dumper) const -{ - dumper->Add( - {{"type", "TSIntersectionType"}, {"types", types_}, {"annotations", AstDumper::Optional(Annotations())}}); -} - -void TSIntersectionType::Dump(ir::SrcDumper *dumper) const -{ - DumpAnnotations(dumper); - dumper->Add("TSIntersectionType"); -} - -void TSIntersectionType::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} -void TSIntersectionType::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *TSIntersectionType::Check([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::Type *TSIntersectionType::GetType([[maybe_unused]] checker::TSChecker *checker) -{ - return nullptr; -} - -checker::Type *TSIntersectionType::GetType([[maybe_unused]] checker::ETSChecker *checker) -{ - // NOTE: validate - return checker->GlobalETSObjectType(); -} - -checker::VerifiedType TSIntersectionType::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/ts/tsIntersectionType.h b/ets2panda/ir/ts/tsIntersectionType.h index 11abbca84815504ce0132c45d77edb91bf6c69b0..9ab16d37aa2cf17684d249b1f694bc89b2e1b28e 100644 --- a/ets2panda/ir/ts/tsIntersectionType.h +++ b/ets2panda/ir/ts/tsIntersectionType.h @@ -38,7 +38,6 @@ public: void Compile([[maybe_unused]] compiler::PandaGen *pg) const override; void Compile(compiler::ETSGen *etsg) const override; checker::Type *Check([[maybe_unused]] checker::TSChecker *checker) override; - checker::Type *GetType([[maybe_unused]] checker::TSChecker *checker) override; checker::Type *GetType([[maybe_unused]] checker::ETSChecker *checker) override; checker::VerifiedType Check([[maybe_unused]] checker::ETSChecker *checker) override; diff --git a/ets2panda/ir/ts/tsLiteralType.cpp b/ets2panda/ir/ts/tsLiteralType.cpp index 5ea315e81b81d71dfb0cc126f2521a57a65433ad..fa9481f7de8168ee24cdd22b237e36f7541179f1 100644 --- a/ets2panda/ir/ts/tsLiteralType.cpp +++ b/ets2panda/ir/ts/tsLiteralType.cpp @@ -15,12 +15,6 @@ #include "tsLiteralType.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" -#include "checker/TSchecker.h" - namespace ark::es2panda::ir { void TSLiteralType::TransformChildren(const NodeTransformer &cb, std::string_view transformationName) { @@ -38,48 +32,6 @@ void TSLiteralType::Iterate(const NodeTraverser &cb) const IterateAnnotations(cb); } -void TSLiteralType::Dump(ir::AstDumper *dumper) const -{ - dumper->Add( - {{"type", "TSLiteralType"}, {"literal", literal_}, {"annotations", AstDumper::Optional(Annotations())}}); -} - -void TSLiteralType::Dump(ir::SrcDumper *dumper) const -{ - DumpAnnotations(dumper); - dumper->Add("TSLiteralType"); -} - -void TSLiteralType::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void TSLiteralType::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *TSLiteralType::Check([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::Type *TSLiteralType::GetType([[maybe_unused]] checker::TSChecker *checker) -{ - if (TsType() != nullptr) { - return TsType(); - } - - SetTsType(literal_->Check(checker)); - return TsType(); -} - -checker::VerifiedType TSLiteralType::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - TSLiteralType *TSLiteralType::Clone(ArenaAllocator *allocator, AstNode *parent) { // Clone the literal expression diff --git a/ets2panda/ir/ts/tsMappedType.cpp b/ets2panda/ir/ts/tsMappedType.cpp index 393e8ec921d9ec0b31a214feab072c30f6cf0ca0..3b88a78f8e68b2a24b83f97d45c611ea481969cc 100644 --- a/ets2panda/ir/ts/tsMappedType.cpp +++ b/ets2panda/ir/ts/tsMappedType.cpp @@ -15,11 +15,6 @@ #include "tsMappedType.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" #include "ir/typeNode.h" #include "ir/ts/tsTypeParameter.h" @@ -51,50 +46,6 @@ void TSMappedType::Iterate(const NodeTraverser &cb) const IterateAnnotations(cb); } -void TSMappedType::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "TSMappedType"}, - {"typeParameter", typeParameter_}, - {"typeAnnotation", AstDumper::Optional(typeAnnotation_)}, - {"readonly", readonly_ == MappedOption::NO_OPTS ? AstDumper::Optional(false) - : readonly_ == MappedOption::PLUS ? AstDumper::Optional("+") - : AstDumper::Optional("-")}, - {"optional", optional_ == MappedOption::NO_OPTS ? AstDumper::Optional(false) - : optional_ == MappedOption::PLUS ? AstDumper::Optional("+") - : AstDumper::Optional("-")}, - {"annotations", AstDumper::Optional(Annotations())}}); -} - -void TSMappedType::Dump(ir::SrcDumper *dumper) const -{ - DumpAnnotations(dumper); - dumper->Add("TSMappedType"); -} - -void TSMappedType::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} -void TSMappedType::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *TSMappedType::Check([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::Type *TSMappedType::GetType([[maybe_unused]] checker::TSChecker *checker) -{ - return nullptr; -} - -checker::VerifiedType TSMappedType::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - TSMappedType *TSMappedType::Clone(ArenaAllocator *allocator, AstNode *parent) { auto *clonedTypeParameter = typeParameter_->Clone(allocator, nullptr)->AsTSTypeParameter(); diff --git a/ets2panda/ir/ts/tsMappedType.h b/ets2panda/ir/ts/tsMappedType.h index 0b2faa31d02b5d3e9f608668b7f1c70785e7b45f..e8fbbcf82551594b4b1a7e56f684b8ceb370eef6 100644 --- a/ets2panda/ir/ts/tsMappedType.h +++ b/ets2panda/ir/ts/tsMappedType.h @@ -59,7 +59,6 @@ public: void Compile([[maybe_unused]] compiler::PandaGen *pg) const override; void Compile(compiler::ETSGen *etsg) const override; checker::Type *Check([[maybe_unused]] checker::TSChecker *checker) override; - checker::Type *GetType([[maybe_unused]] checker::TSChecker *checker) override; checker::VerifiedType Check([[maybe_unused]] checker::ETSChecker *checker) override; TSMappedType *Clone(ArenaAllocator *allocator, AstNode *parent) override; diff --git a/ets2panda/ir/ts/tsModuleBlock.cpp b/ets2panda/ir/ts/tsModuleBlock.cpp index db77f5dee40dcd1a0f1810561f10faa36c5f6a97..2098feb04e8857a632ea7830ac08b784a73f6086 100644 --- a/ets2panda/ir/ts/tsModuleBlock.cpp +++ b/ets2panda/ir/ts/tsModuleBlock.cpp @@ -15,12 +15,6 @@ #include "tsModuleBlock.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" - namespace ark::es2panda::ir { void TSModuleBlock::TransformChildren(const NodeTransformer &cb, std::string_view transformationName) { @@ -39,32 +33,4 @@ void TSModuleBlock::Iterate(const NodeTraverser &cb) const } } -void TSModuleBlock::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "TSModuleBlock"}, {"body", statements_}}); -} - -void TSModuleBlock::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add("TSModuleBlock"); -} - -void TSModuleBlock::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} -void TSModuleBlock::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *TSModuleBlock::Check([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType TSModuleBlock::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/ts/tsModuleDeclaration.cpp b/ets2panda/ir/ts/tsModuleDeclaration.cpp index 0f90e8f8e0270ba69bcccf0ab06c0d760487241d..4a4c730b175e5850a5c6bbe8b6813c845281a802 100644 --- a/ets2panda/ir/ts/tsModuleDeclaration.cpp +++ b/ets2panda/ir/ts/tsModuleDeclaration.cpp @@ -15,12 +15,6 @@ #include "tsModuleDeclaration.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" - namespace ark::es2panda::ir { void TSModuleDeclaration::TransformChildren(const NodeTransformer &cb, std::string_view transformationName) { @@ -46,34 +40,4 @@ void TSModuleDeclaration::Iterate(const NodeTraverser &cb) const } } -void TSModuleDeclaration::Dump(ir::AstDumper *dumper) const -{ - dumper->Add( - {{"type", "TSModuleDeclaration"}, {"id", name_}, {"body", AstDumper::Optional(body_)}, {"global", global_}}); -} - -void TSModuleDeclaration::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add("TSModuleDeclaration"); -} - -void TSModuleDeclaration::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void TSModuleDeclaration::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *TSModuleDeclaration::Check([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType TSModuleDeclaration::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/ts/tsNamedTupleMember.cpp b/ets2panda/ir/ts/tsNamedTupleMember.cpp index 26a2ad54af2fea954d164214821c2a52650d5398..ec5f94f8838790679acaa4925503cf07fb57872e 100644 --- a/ets2panda/ir/ts/tsNamedTupleMember.cpp +++ b/ets2panda/ir/ts/tsNamedTupleMember.cpp @@ -15,13 +15,6 @@ #include "tsNamedTupleMember.h" -#include "checker/ETSchecker.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" - namespace ark::es2panda::ir { void TSNamedTupleMember::TransformChildren(const NodeTransformer &cb, std::string_view const transformationName) { @@ -45,38 +38,4 @@ void TSNamedTupleMember::Iterate(const NodeTraverser &cb) const IterateAnnotations(cb); } -void TSNamedTupleMember::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "TSNamedTupleMember"}, - {"elementType", elementType_}, - {"label", label_}, - {"optional", AstDumper::Optional(optional_)}, - {"annotations", AstDumper::Optional(Annotations())}}); -} - -void TSNamedTupleMember::Dump(ir::SrcDumper *dumper) const -{ - DumpAnnotations(dumper); - dumper->Add("TSNamedTupleMember"); -} - -void TSNamedTupleMember::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void TSNamedTupleMember::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *TSNamedTupleMember::Check([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType TSNamedTupleMember::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/ts/tsNeverKeyword.cpp b/ets2panda/ir/ts/tsNeverKeyword.cpp index cca589761049e33c38c419f7aaac3f36115671bc..6446955acebb5aa62be0f8b43686bd5bd273230e 100644 --- a/ets2panda/ir/ts/tsNeverKeyword.cpp +++ b/ets2panda/ir/ts/tsNeverKeyword.cpp @@ -15,12 +15,6 @@ #include "tsNeverKeyword.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" -#include "checker/TSchecker.h" - namespace ark::es2panda::ir { void TSNeverKeyword::TransformChildren([[maybe_unused]] const NodeTransformer &cb, [[maybe_unused]] std::string_view const transformationName) @@ -33,39 +27,4 @@ void TSNeverKeyword::Iterate(const NodeTraverser &cb) const IterateAnnotations(cb); } -void TSNeverKeyword::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "TSNeverKeyword"}, {"annotations", AstDumper::Optional(Annotations())}}); -} - -void TSNeverKeyword::Dump(ir::SrcDumper *dumper) const -{ - DumpAnnotations(dumper); - dumper->Add("TSNeverKeyword"); -} - -void TSNeverKeyword::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void TSNeverKeyword::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *TSNeverKeyword::Check([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::Type *TSNeverKeyword::GetType([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GlobalNeverType(); -} - -checker::VerifiedType TSNeverKeyword::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/ts/tsNonNullExpression.cpp b/ets2panda/ir/ts/tsNonNullExpression.cpp index 61768c5e4cbb21d7e62d5dbb357a3c48cd9d1add..487122eb67449bc90c5e208bdb79f3e03e344a14 100644 --- a/ets2panda/ir/ts/tsNonNullExpression.cpp +++ b/ets2panda/ir/ts/tsNonNullExpression.cpp @@ -15,11 +15,6 @@ #include "tsNonNullExpression.h" -#include "checker/ETSchecker.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" - namespace ark::es2panda::ir { void TSNonNullExpression::TransformChildren(const NodeTransformer &cb, std::string_view transformationName) { @@ -34,38 +29,6 @@ void TSNonNullExpression::Iterate(const NodeTraverser &cb) const cb(expr_); } -void TSNonNullExpression::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "TSNonNullExpression"}, {"expression", expr_}}); -} - -void TSNonNullExpression::Dump(ir::SrcDumper *dumper) const -{ - ES2PANDA_ASSERT(expr_ != nullptr); - expr_->Dump(dumper); - dumper->Add("!"); -} - -void TSNonNullExpression::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void TSNonNullExpression::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *TSNonNullExpression::Check([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType TSNonNullExpression::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - TSNonNullExpression *TSNonNullExpression::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto *const expr = expr_->Clone(allocator, nullptr)->AsExpression(); diff --git a/ets2panda/ir/ts/tsNullKeyword.cpp b/ets2panda/ir/ts/tsNullKeyword.cpp index c8789804e572facb3f2b49989e7bcd51f099a0b0..6ad1bb0c90b1aa97d7f7ad70ef81dee7cbea2ba6 100644 --- a/ets2panda/ir/ts/tsNullKeyword.cpp +++ b/ets2panda/ir/ts/tsNullKeyword.cpp @@ -15,12 +15,6 @@ #include "tsNullKeyword.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" -#include "checker/TSchecker.h" - namespace ark::es2panda::ir { void TSNullKeyword::TransformChildren([[maybe_unused]] const NodeTransformer &cb, [[maybe_unused]] std::string_view const transformationName) @@ -33,38 +27,4 @@ void TSNullKeyword::Iterate(const NodeTraverser &cb) const IterateAnnotations(cb); } -void TSNullKeyword::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "TSNullKeyword"}, {"annotations", AstDumper::Optional(Annotations())}}); -} - -void TSNullKeyword::Dump(ir::SrcDumper *dumper) const -{ - DumpAnnotations(dumper); - dumper->Add("TSNullKeyword"); -} - -void TSNullKeyword::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} -void TSNullKeyword::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *TSNullKeyword::Check([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::Type *TSNullKeyword::GetType([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GlobalNullType(); -} - -checker::VerifiedType TSNullKeyword::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/ts/tsNumberKeyword.cpp b/ets2panda/ir/ts/tsNumberKeyword.cpp index c6752bc8accf7a1b7460f975519ca98c9731633f..89319d941075dea5a65244e8c5c09ad8a0ff9660 100644 --- a/ets2panda/ir/ts/tsNumberKeyword.cpp +++ b/ets2panda/ir/ts/tsNumberKeyword.cpp @@ -15,12 +15,6 @@ #include "tsNumberKeyword.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" - namespace ark::es2panda::ir { void TSNumberKeyword::TransformChildren([[maybe_unused]] const NodeTransformer &cb, [[maybe_unused]] std::string_view const transformationName) @@ -33,42 +27,6 @@ void TSNumberKeyword::Iterate(const NodeTraverser &cb) const IterateAnnotations(cb); } -void TSNumberKeyword::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "TSNumberKeyword"}, {"annotations", AstDumper::Optional(Annotations())}}); -} - -void TSNumberKeyword::Dump(ir::SrcDumper *dumper) const -{ - DumpAnnotations(dumper); - dumper->Add("TSNumberKeyword"); -} - -void TSNumberKeyword::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void TSNumberKeyword::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *TSNumberKeyword::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::Type *TSNumberKeyword::GetType([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GlobalNumberType(); -} - -checker::VerifiedType TSNumberKeyword::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - TSNumberKeyword *TSNumberKeyword::Clone(ArenaAllocator *allocator, AstNode *parent) { auto *clone = allocator->New(allocator); diff --git a/ets2panda/ir/ts/tsObjectKeyword.cpp b/ets2panda/ir/ts/tsObjectKeyword.cpp index 5eacf644625e1a94d6ef014c367282954c197d73..3d6abbdcf8e5ac9c76a27f431dac0d447a490862 100644 --- a/ets2panda/ir/ts/tsObjectKeyword.cpp +++ b/ets2panda/ir/ts/tsObjectKeyword.cpp @@ -15,12 +15,6 @@ #include "tsObjectKeyword.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" - namespace ark::es2panda::ir { void TSObjectKeyword::TransformChildren([[maybe_unused]] const NodeTransformer &cb, [[maybe_unused]] std::string_view const transformationName) @@ -33,39 +27,4 @@ void TSObjectKeyword::Iterate(const NodeTraverser &cb) const IterateAnnotations(cb); } -void TSObjectKeyword::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "TSObjectKeyword"}, {"annotations", AstDumper::Optional(Annotations())}}); -} - -void TSObjectKeyword::Dump(ir::SrcDumper *dumper) const -{ - DumpAnnotations(dumper); - dumper->Add("TSObjectKeyword"); -} - -void TSObjectKeyword::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void TSObjectKeyword::Compile([[maybe_unused]] compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *TSObjectKeyword::Check([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::Type *TSObjectKeyword::GetType([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GlobalNonPrimitiveType(); -} - -checker::VerifiedType TSObjectKeyword::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/ts/tsParameterProperty.cpp b/ets2panda/ir/ts/tsParameterProperty.cpp index 047484053faa822cf6aa5dcee3ec6ea0264975b4..cd6322db2928e34f97ff3a5d0d9af70fd8344193 100644 --- a/ets2panda/ir/ts/tsParameterProperty.cpp +++ b/ets2panda/ir/ts/tsParameterProperty.cpp @@ -15,11 +15,6 @@ #include "tsParameterProperty.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" #include "ir/expression.h" namespace ark::es2panda::ir { @@ -36,40 +31,4 @@ void TSParameterProperty::Iterate(const NodeTraverser &cb) const cb(parameter_); } -void TSParameterProperty::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "TSParameterProperty"}, - {"accessibility", accessibility_ == AccessibilityOption::PUBLIC ? "public" - : accessibility_ == AccessibilityOption::PRIVATE ? "private" - : accessibility_ == AccessibilityOption::PROTECTED ? "protected" - : "undefined"}, - {"readonly", readonly_}, - {"static", static_}, - {"export", export_}, - {"parameter", parameter_}}); -} - -void TSParameterProperty::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add("TSParameterProperty"); -} - -void TSParameterProperty::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} -void TSParameterProperty::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *TSParameterProperty::Check([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType TSParameterProperty::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/ts/tsParenthesizedType.cpp b/ets2panda/ir/ts/tsParenthesizedType.cpp index 5e2ed2f554b5a588b70e1d3069dd7faee4120248..957c4639068b41c4eed375b2508720e5fa3e2091 100644 --- a/ets2panda/ir/ts/tsParenthesizedType.cpp +++ b/ets2panda/ir/ts/tsParenthesizedType.cpp @@ -15,12 +15,6 @@ #include "tsParenthesizedType.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" -#include "checker/TSchecker.h" - namespace ark::es2panda::ir { void TSParenthesizedType::TransformChildren(const NodeTransformer &cb, std::string_view transformationName) { @@ -38,46 +32,4 @@ void TSParenthesizedType::Iterate(const NodeTraverser &cb) const IterateAnnotations(cb); } -void TSParenthesizedType::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "TSParenthesizedType"}, - {"typeAnnotation", type_}, - {"annotations", AstDumper::Optional(Annotations())}}); -} - -void TSParenthesizedType::Dump(ir::SrcDumper *dumper) const -{ - DumpAnnotations(dumper); - dumper->Add("TSParenthesizedType"); -} - -void TSParenthesizedType::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void TSParenthesizedType::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *TSParenthesizedType::Check([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::Type *TSParenthesizedType::GetType([[maybe_unused]] checker::TSChecker *checker) -{ - if (TsType() != nullptr) { - return TsType(); - } - - SetTsType(type_->GetType(checker)); - return TsType(); -} - -checker::VerifiedType TSParenthesizedType::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/ts/tsQualifiedName.cpp b/ets2panda/ir/ts/tsQualifiedName.cpp index f47595f293ee6feb981882c74488d81fe8f534a2..b2771c6b993d629f44f735bba45a8d804c7b5672 100644 --- a/ets2panda/ir/ts/tsQualifiedName.cpp +++ b/ets2panda/ir/ts/tsQualifiedName.cpp @@ -15,10 +15,7 @@ #include "tsQualifiedName.h" -#include "checker/ETSchecker.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" +#include "ir/expressions/identifier.h" namespace ark::es2panda::ir { TSQualifiedName::TSQualifiedName(Expression *left, Identifier *right, ArenaAllocator *allocator) @@ -55,37 +52,6 @@ void TSQualifiedName::TransformChildren(const NodeTransformer &cb, std::string_v } } -void TSQualifiedName::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "TSQualifiedName"}, {"left", left_}, {"right", right_}}); -} - -void TSQualifiedName::Dump(ir::SrcDumper *dumper) const -{ - left_->Dump(dumper); - dumper->Add("."); - right_->Dump(dumper); -} - -void TSQualifiedName::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} -void TSQualifiedName::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *TSQualifiedName::Check([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType TSQualifiedName::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - util::StringView TSQualifiedName::Name() const { util::UString packageName(allocator_); diff --git a/ets2panda/ir/ts/tsStringKeyword.cpp b/ets2panda/ir/ts/tsStringKeyword.cpp index aa9f5fc9f808b55c3a2937e25bec9ad64f775fab..de3eec5570d2900db5848bec3a6dd4b221c552a9 100644 --- a/ets2panda/ir/ts/tsStringKeyword.cpp +++ b/ets2panda/ir/ts/tsStringKeyword.cpp @@ -15,12 +15,6 @@ #include "tsStringKeyword.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" - namespace ark::es2panda::ir { void TSStringKeyword::TransformChildren([[maybe_unused]] const NodeTransformer &cb, [[maybe_unused]] std::string_view const transformationName) @@ -33,42 +27,6 @@ void TSStringKeyword::Iterate(const NodeTraverser &cb) const IterateAnnotations(cb); } -void TSStringKeyword::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "TSStringKeyword"}, {"annotations", AstDumper::Optional(Annotations())}}); -} - -void TSStringKeyword::Dump(ir::SrcDumper *dumper) const -{ - DumpAnnotations(dumper); - dumper->Add("TSStringKeyword"); -} - -void TSStringKeyword::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void TSStringKeyword::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *TSStringKeyword::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::Type *TSStringKeyword::GetType([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GlobalStringType(); -} - -checker::VerifiedType TSStringKeyword::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - TSStringKeyword *TSStringKeyword::Clone(ArenaAllocator *allocator, AstNode *parent) { auto *clone = allocator->New(allocator); diff --git a/ets2panda/ir/ts/tsThisType.cpp b/ets2panda/ir/ts/tsThisType.cpp index ded68e430bc7b7e22b12c7d1f917edb8233bf47d..0a9a5a6ed5019b2d5a06b5b1ba6f8494f36d8bfc 100644 --- a/ets2panda/ir/ts/tsThisType.cpp +++ b/ets2panda/ir/ts/tsThisType.cpp @@ -15,10 +15,7 @@ #include "tsThisType.h" -#include "checker/ETSchecker.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" +#include "checker/types/ets/etsObjectType.h" namespace ark::es2panda::ir { void TSThisType::TransformChildren([[maybe_unused]] const NodeTransformer &cb, @@ -32,49 +29,6 @@ void TSThisType::Iterate(const NodeTraverser &cb) const IterateAnnotations(cb); } -void TSThisType::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "TSThisType"}}); -} - -void TSThisType::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add("this"); -} - -void TSThisType::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} -void TSThisType::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *TSThisType::Check([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::Type *TSThisType::GetType([[maybe_unused]] checker::TSChecker *checker) -{ - return nullptr; -} - -checker::VerifiedType TSThisType::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - -checker::Type *TSThisType::GetType([[maybe_unused]] checker::ETSChecker *checker) -{ - auto *containingClass = checker->Context().ContainingClass(); - if (containingClass == nullptr) { - return checker->GlobalTypeError(); - } - return containingClass; -} - TSThisType *TSThisType::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto *const clone = allocator->New(allocator); diff --git a/ets2panda/ir/ts/tsThisType.h b/ets2panda/ir/ts/tsThisType.h index e5367ce02ff527dec0cfc5903812dfc081c23eef..43e88d8450ee8f16913460d1c166e39f34de105b 100644 --- a/ets2panda/ir/ts/tsThisType.h +++ b/ets2panda/ir/ts/tsThisType.h @@ -30,7 +30,6 @@ public: void Compile([[maybe_unused]] compiler::PandaGen *pg) const override; void Compile(compiler::ETSGen *etsg) const override; checker::Type *Check([[maybe_unused]] checker::TSChecker *checker) override; - checker::Type *GetType([[maybe_unused]] checker::TSChecker *checker) override; checker::VerifiedType Check([[maybe_unused]] checker::ETSChecker *checker) override; checker::Type *GetType([[maybe_unused]] checker::ETSChecker *checker) override; TSThisType *Clone(ArenaAllocator *allocator, AstNode *parent) override; diff --git a/ets2panda/ir/ts/tsTupleType.cpp b/ets2panda/ir/ts/tsTupleType.cpp index 26691a49deb047d007af98d71920d5232cc18fad..c23274b7f6ce2ec8310b07fb1a01c1e086e889cb 100644 --- a/ets2panda/ir/ts/tsTupleType.cpp +++ b/ets2panda/ir/ts/tsTupleType.cpp @@ -15,14 +15,12 @@ #include "tsTupleType.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" #include "util/helpers.h" #include "varbinder/scope.h" + #include "checker/TSchecker.h" #include "checker/types/ts/indexInfo.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" + #include "ir/expressions/identifier.h" #include "ir/ts/tsNamedTupleMember.h" @@ -48,29 +46,6 @@ void TSTupleType::Iterate(const NodeTraverser &cb) const IterateAnnotations(cb); } -void TSTupleType::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "TSTupleType"}, - {"elementTypes", elementTypes_}, - {"annotations", AstDumper::Optional(Annotations())}}); -} - -void TSTupleType::Dump(ir::SrcDumper *dumper) const -{ - DumpAnnotations(dumper); - dumper->Add("TSTupleType"); -} - -void TSTupleType::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void TSTupleType::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - checker::Type *GetNumberIndexType(ArenaVector numberIndexTypes, checker::TSChecker *checker) { checker::Type *numberIndexType = nullptr; @@ -152,16 +127,6 @@ checker::Type *TSTupleType::GetType(checker::TSChecker *checker) return TsType(); } -checker::Type *TSTupleType::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType TSTupleType::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - TSTupleType *TSTupleType::Clone(ArenaAllocator *allocator, AstNode *parent) { ArenaVector clonedElementTypes(allocator->Adapter()); diff --git a/ets2panda/ir/ts/tsTypeAliasDeclaration.cpp b/ets2panda/ir/ts/tsTypeAliasDeclaration.cpp index e56b9057c4dd600bea7381e29f26df90dddf412e..7fae5823c2ede2da659f22599b4503c9a59ae8c9 100644 --- a/ets2panda/ir/ts/tsTypeAliasDeclaration.cpp +++ b/ets2panda/ir/ts/tsTypeAliasDeclaration.cpp @@ -15,11 +15,6 @@ #include "tsTypeAliasDeclaration.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" #include "ir/typeNode.h" #include "ir/expressions/identifier.h" @@ -81,80 +76,6 @@ void TSTypeAliasDeclaration::Iterate(const NodeTraverser &cb) const } } -void TSTypeAliasDeclaration::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "TSTypeAliasDeclaration"}, - {"annotations", AstDumper::Optional(Annotations())}, - {"id", Id()}, - {"typeAnnotation", AstDumper::Optional(TypeAnnotation())}, - {"typeParameters", AstDumper::Optional(TypeParams())}}); -} - -bool TSTypeAliasDeclaration::RegisterUnexportedForDeclGen(ir::SrcDumper *dumper) const -{ - ES2PANDA_ASSERT(dumper->IsDeclgen()); - - if (dumper->GetDeclgen()->IsPostDumpIndirectDepsPhase()) { - return false; - } - - if (id_->Parent()->IsExported() || id_->Parent()->IsDefaultExported()) { - return false; - } - - auto name = id_->Name().Mutf8(); - dumper->GetDeclgen()->AddNode(name, this); - return true; -} - -void TSTypeAliasDeclaration::Dump(ir::SrcDumper *dumper) const -{ - ES2PANDA_ASSERT(id_); - if (dumper->IsDeclgen() && RegisterUnexportedForDeclGen(dumper)) { - return; - } - DumpAnnotations(dumper); - if (id_->Parent()->IsExported()) { - dumper->Add("export "); - } - dumper->Add("type "); - Id()->Dump(dumper); - auto const typeParams = TypeParams(); - if (typeParams != nullptr) { - dumper->Add("<"); - typeParams->Dump(dumper); - dumper->Add(">"); - } - dumper->Add(" = "); - if (Id()->IsAnnotatedExpression()) { - auto type = TypeAnnotation(); - ES2PANDA_ASSERT(type); - type->Dump(dumper); - } - dumper->Add(";"); - dumper->Endl(); -} - -void TSTypeAliasDeclaration::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void TSTypeAliasDeclaration::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *TSTypeAliasDeclaration::Check([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType TSTypeAliasDeclaration::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - TSTypeAliasDeclaration *TSTypeAliasDeclaration::Construct(ArenaAllocator *allocator) { return allocator->New(allocator, nullptr, nullptr, nullptr); diff --git a/ets2panda/ir/ts/tsTypeAssertion.cpp b/ets2panda/ir/ts/tsTypeAssertion.cpp index 64ecd8063413a9b2c65b41d495d41c8125f0a543..ae206cdfbcf2ebaa3b97907792a329a12487ab9c 100644 --- a/ets2panda/ir/ts/tsTypeAssertion.cpp +++ b/ets2panda/ir/ts/tsTypeAssertion.cpp @@ -15,11 +15,6 @@ #include "tsTypeAssertion.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" #include "ir/typeNode.h" namespace ark::es2panda::ir { @@ -44,33 +39,4 @@ void TSTypeAssertion::Iterate(const NodeTraverser &cb) const cb(expression_); } -void TSTypeAssertion::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "TSTypeAssertion"}, {"typeAnnotation", TypeAnnotation()}, {"expression", expression_}}); -} - -void TSTypeAssertion::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add("TSTypeAssertion"); -} - -void TSTypeAssertion::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void TSTypeAssertion::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *TSTypeAssertion::Check([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType TSTypeAssertion::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/ts/tsTypeLiteral.cpp b/ets2panda/ir/ts/tsTypeLiteral.cpp index f79e4e20c3bfc19bfabe29590f3cd0e635c58635..06a84bca95054daf8c1b755dfcce372fed00f3ba 100644 --- a/ets2panda/ir/ts/tsTypeLiteral.cpp +++ b/ets2panda/ir/ts/tsTypeLiteral.cpp @@ -15,14 +15,9 @@ #include "tsTypeLiteral.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" - #include "varbinder/variable.h" #include "varbinder/declaration.h" -#include "checker/TSchecker.h" + #include "checker/types/signature.h" namespace ark::es2panda::ir { @@ -47,53 +42,6 @@ void TSTypeLiteral::Iterate(const NodeTraverser &cb) const IterateAnnotations(cb); } -void TSTypeLiteral::Dump(ir::AstDumper *dumper) const -{ - dumper->Add( - {{"type", "TSTypeLiteral"}, {"members", members_}, {"annotations", AstDumper::Optional(Annotations())}}); -} - -void TSTypeLiteral::Dump(ir::SrcDumper *dumper) const -{ - DumpAnnotations(dumper); - dumper->Add("TSTypeLiteral"); -} - -void TSTypeLiteral::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void TSTypeLiteral::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *TSTypeLiteral::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::Type *TSTypeLiteral::GetType(checker::TSChecker *checker) -{ - if (TsType() != nullptr) { - return TsType(); - } - - checker::ObjectDescriptor *desc = checker->Allocator()->New(checker->Allocator()); - checker::Type *type = checker->Allocator()->New(desc); - ES2PANDA_ASSERT(type != nullptr); - type->SetVariable(Variable()); - - SetTsType(type); - return TsType(); -} - -checker::VerifiedType TSTypeLiteral::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - TSTypeLiteral *TSTypeLiteral::Clone(ArenaAllocator *allocator, AstNode *parent) { ArenaVector clonedMembers(allocator->Adapter()); diff --git a/ets2panda/ir/ts/tsTypeOperator.cpp b/ets2panda/ir/ts/tsTypeOperator.cpp index 345217052f048fbf5e51563d741cb02b3bd1c59d..b0fec26af56d2b4cfb83117b1821b473779a121f 100644 --- a/ets2panda/ir/ts/tsTypeOperator.cpp +++ b/ets2panda/ir/ts/tsTypeOperator.cpp @@ -15,12 +15,6 @@ #include "tsTypeOperator.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" - namespace ark::es2panda::ir { void TSTypeOperator::TransformChildren(const NodeTransformer &cb, std::string_view transformationName) { @@ -39,44 +33,6 @@ void TSTypeOperator::Iterate(const NodeTraverser &cb) const IterateAnnotations(cb); } -void TSTypeOperator::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "TSTypeOperator"}, - {"operator", AstDumper::TypeOperatorToString(operatorType_)}, - {"typeAnnotation", type_}, - {"annotations", AstDumper::Optional(Annotations())}}); -} - -void TSTypeOperator::Dump(ir::SrcDumper *dumper) const -{ - DumpAnnotations(dumper); - dumper->Add("TSTypeOperator"); -} - -void TSTypeOperator::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} -void TSTypeOperator::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *TSTypeOperator::Check([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::Type *TSTypeOperator::GetType([[maybe_unused]] checker::TSChecker *checker) -{ - return nullptr; -} - -checker::VerifiedType TSTypeOperator::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - TSTypeOperator *TSTypeOperator::Clone(ArenaAllocator *allocator, AstNode *parent) { // Clone the type annotation diff --git a/ets2panda/ir/ts/tsTypeOperator.h b/ets2panda/ir/ts/tsTypeOperator.h index 1c8e52791c9003e0a7e0c674b73c172806c55430..61d2996d6406c3621ce0052328fedf740006a7c0 100644 --- a/ets2panda/ir/ts/tsTypeOperator.h +++ b/ets2panda/ir/ts/tsTypeOperator.h @@ -53,7 +53,6 @@ public: void Compile([[maybe_unused]] compiler::PandaGen *pg) const override; void Compile(compiler::ETSGen *etsg) const override; checker::Type *Check([[maybe_unused]] checker::TSChecker *checker) override; - checker::Type *GetType([[maybe_unused]] checker::TSChecker *checker) override; checker::VerifiedType Check([[maybe_unused]] checker::ETSChecker *checker) override; TSTypeOperator *Clone(ArenaAllocator *allocator, AstNode *parent) override; diff --git a/ets2panda/ir/ts/tsTypeParameter.cpp b/ets2panda/ir/ts/tsTypeParameter.cpp index d14c2e2da85ecca081a7aa87d0221e12370a2170..4940017cb6e32da8355a3b3421b57031c73bb015 100644 --- a/ets2panda/ir/ts/tsTypeParameter.cpp +++ b/ets2panda/ir/ts/tsTypeParameter.cpp @@ -15,14 +15,8 @@ #include "tsTypeParameter.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" #include "ir/typeNode.h" #include "ir/expressions/identifier.h" -#include "libarkbase/utils/arena_containers.h" namespace ark::es2panda::ir { @@ -86,58 +80,6 @@ void TSTypeParameter::Iterate(const NodeTraverser &cb) const IterateAnnotations(cb); } -void TSTypeParameter::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "TSTypeParameter"}, - {"name", Name()}, - {"constraint", AstDumper::Optional(Constraint())}, - {"default", AstDumper::Optional(DefaultType())}, - {"in", AstDumper::Optional(IsIn())}, - {"out", AstDumper::Optional(IsOut())}, - {"annotations", AstDumper::Optional(Annotations())}}); -} - -void TSTypeParameter::Dump(ir::SrcDumper *dumper) const -{ - DumpAnnotations(dumper); - if (IsIn()) { - dumper->Add("in "); - } - if (IsOut()) { - dumper->Add("out "); - } - - Name()->Dump(dumper); - - if (DefaultType() != nullptr) { - dumper->Add(" = "); - DefaultType()->Dump(dumper); - } - if (Constraint() != nullptr) { - dumper->Add(" extends "); - Constraint()->Dump(dumper); - } -} - -void TSTypeParameter::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} -void TSTypeParameter::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *TSTypeParameter::Check([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType TSTypeParameter::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - TSTypeParameter *TSTypeParameter::Construct(ArenaAllocator *allocator) { return allocator->New(nullptr, nullptr, nullptr, allocator); diff --git a/ets2panda/ir/ts/tsTypeParameterDeclaration.cpp b/ets2panda/ir/ts/tsTypeParameterDeclaration.cpp index 1ae682e17f96f248d6503893e11c1186593749c5..5c71061db13ef361600bfdcbbec27037136e651d 100644 --- a/ets2panda/ir/ts/tsTypeParameterDeclaration.cpp +++ b/ets2panda/ir/ts/tsTypeParameterDeclaration.cpp @@ -15,11 +15,6 @@ #include "tsTypeParameterDeclaration.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" #include "ir/ts/tsTypeParameter.h" namespace ark::es2panda::ir { @@ -52,40 +47,6 @@ void TSTypeParameterDeclaration::Iterate(const NodeTraverser &cb) const } } -void TSTypeParameterDeclaration::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "TSTypeParameterDeclaration"}, {"params", Params()}}); -} - -void TSTypeParameterDeclaration::Dump(ir::SrcDumper *dumper) const -{ - for (auto param : Params()) { - param->Dump(dumper); - if (param != Params().back()) { - dumper->Add(", "); - } - } -} - -void TSTypeParameterDeclaration::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} -void TSTypeParameterDeclaration::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *TSTypeParameterDeclaration::Check([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType TSTypeParameterDeclaration::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - TSTypeParameterDeclaration *TSTypeParameterDeclaration::Construct(ArenaAllocator *allocator) { ArenaVector params(allocator->Adapter()); diff --git a/ets2panda/ir/ts/tsTypeParameterInstantiation.cpp b/ets2panda/ir/ts/tsTypeParameterInstantiation.cpp index 306816edeac35d1a3b64bd46f231479217d019da..6a9268a1c8370d086660eda6cf005f278d8e87c7 100644 --- a/ets2panda/ir/ts/tsTypeParameterInstantiation.cpp +++ b/ets2panda/ir/ts/tsTypeParameterInstantiation.cpp @@ -15,10 +15,6 @@ #include "tsTypeParameterInstantiation.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" - namespace ark::es2panda::ir { TSTypeParameterInstantiation::TSTypeParameterInstantiation([[maybe_unused]] Tag const tag, TSTypeParameterInstantiation const &other, @@ -58,40 +54,4 @@ void TSTypeParameterInstantiation::Iterate(const NodeTraverser &cb) const } } -void TSTypeParameterInstantiation::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "TSTypeParameterInstantiation"}, {"params", params_}}); -} - -void TSTypeParameterInstantiation::Dump(ir::SrcDumper *dumper) const -{ - dumper->Add("<"); - for (auto param : params_) { - param->Dump(dumper); - if (param != params_.back()) { - dumper->Add(", "); - } - } - dumper->Add(">"); -} - -void TSTypeParameterInstantiation::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} -void TSTypeParameterInstantiation::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *TSTypeParameterInstantiation::Check([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType TSTypeParameterInstantiation::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/ts/tsTypePredicate.cpp b/ets2panda/ir/ts/tsTypePredicate.cpp index 68f10c467bea286af7f5ee9edfd0d86266683d26..108184e6ce16228d77866498aef4de4cf78fb98a 100644 --- a/ets2panda/ir/ts/tsTypePredicate.cpp +++ b/ets2panda/ir/ts/tsTypePredicate.cpp @@ -15,11 +15,6 @@ #include "tsTypePredicate.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" #include "ir/typeNode.h" #include "ir/expression.h" @@ -51,41 +46,4 @@ void TSTypePredicate::Iterate(const NodeTraverser &cb) const IterateAnnotations(cb); } -void TSTypePredicate::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "TSTypePredicate"}, - {"parameterName", parameterName_}, - {"typeAnnotation", AstDumper::Nullish(typeAnnotation_)}, - {"asserts", asserts_}, - {"annotations", AstDumper::Optional(Annotations())}}); -} -void TSTypePredicate::Dump(ir::SrcDumper *dumper) const -{ - DumpAnnotations(dumper); - dumper->Add("TSTypePredicate"); -} - -void TSTypePredicate::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} -void TSTypePredicate::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *TSTypePredicate::Check([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::Type *TSTypePredicate::GetType([[maybe_unused]] checker::TSChecker *checker) -{ - return nullptr; -} - -checker::VerifiedType TSTypePredicate::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/ts/tsTypePredicate.h b/ets2panda/ir/ts/tsTypePredicate.h index 47105611f7e56fd5477038067edd74aaf3ce6e8a..c8f66ffc6ad3ffd24b55cb8bbfdbfedfd7e163e2 100644 --- a/ets2panda/ir/ts/tsTypePredicate.h +++ b/ets2panda/ir/ts/tsTypePredicate.h @@ -52,7 +52,6 @@ public: void Compile([[maybe_unused]] compiler::PandaGen *pg) const override; void Compile(compiler::ETSGen *etsg) const override; checker::Type *Check([[maybe_unused]] checker::TSChecker *checker) override; - checker::Type *GetType([[maybe_unused]] checker::TSChecker *checker) override; checker::VerifiedType Check([[maybe_unused]] checker::ETSChecker *checker) override; void Accept(ASTVisitorT *v) override diff --git a/ets2panda/ir/ts/tsTypeQuery.cpp b/ets2panda/ir/ts/tsTypeQuery.cpp index 8a0018cdc53af38b9ec1956b0f06fb43414cbc4e..4145cbb772e42d16f982c1de6d08d3f7972d36b0 100644 --- a/ets2panda/ir/ts/tsTypeQuery.cpp +++ b/ets2panda/ir/ts/tsTypeQuery.cpp @@ -15,13 +15,6 @@ #include "tsTypeQuery.h" -#include "checker/ETSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" -#include "checker/TSchecker.h" - namespace ark::es2panda::ir { void TSTypeQuery::TransformChildren(const NodeTransformer &cb, std::string_view transformationName) { @@ -39,40 +32,4 @@ void TSTypeQuery::Iterate(const NodeTraverser &cb) const IterateAnnotations(cb); } -void TSTypeQuery::Dump(ir::AstDumper *dumper) const -{ - dumper->Add( - {{"type", "TSTypeQuery"}, {"exprName", exprName_}, {"annotations", AstDumper::Optional(Annotations())}}); -} - -void TSTypeQuery::Dump(ir::SrcDumper *dumper) const -{ - DumpAnnotations(dumper); - dumper->Add("TSTypeQuery"); -} - -void TSTypeQuery::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void TSTypeQuery::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *TSTypeQuery::Check([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::Type *TSTypeQuery::GetType([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType TSTypeQuery::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/ts/tsTypeReference.cpp b/ets2panda/ir/ts/tsTypeReference.cpp index 1618aa19d5cd06dc3aa28d25d80c923f374ba1f0..f8e3e8c8ec691f68384d02a95f8650ee4866ffb1 100644 --- a/ets2panda/ir/ts/tsTypeReference.cpp +++ b/ets2panda/ir/ts/tsTypeReference.cpp @@ -18,12 +18,9 @@ #include "varbinder/declaration.h" #include "varbinder/scope.h" #include "varbinder/variable.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" + #include "ir/expressions/identifier.h" +#include "ir/expressions/memberExpression.h" #include "ir/ts/tsInterfaceDeclaration.h" #include "ir/ts/tsTypeAliasDeclaration.h" #include "ir/ts/tsTypeParameterInstantiation.h" @@ -59,29 +56,6 @@ void TSTypeReference::Iterate(const NodeTraverser &cb) const IterateAnnotations(cb); } -void TSTypeReference::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "TSTypeReference"}, - {"typeName", typeName_}, - {"typeParameters", AstDumper::Optional(typeParams_)}, - {"annotations", AstDumper::Optional(Annotations())}}); -} - -void TSTypeReference::Dump(ir::SrcDumper *dumper) const -{ - DumpAnnotations(dumper); - BaseName()->Dump(dumper); -} - -void TSTypeReference::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} -void TSTypeReference::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - ir::Identifier *TSTypeReference::BaseName() const { if (typeName_->IsIdentifier()) { @@ -103,37 +77,6 @@ ir::Identifier *TSTypeReference::BaseName() const return iter->Property()->AsIdentifier(); } -checker::Type *TSTypeReference::Check([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::Type *TSTypeReference::GetType([[maybe_unused]] checker::TSChecker *checker) -{ - if (TsType() != nullptr) { - return TsType(); - } - - if (typeName_->IsTSQualifiedName()) { - return checker->GlobalAnyType(); - } - - ES2PANDA_ASSERT(typeName_->IsIdentifier()); - varbinder::Variable *var = typeName_->AsIdentifier()->Variable(); - - if (var == nullptr) { - checker->ThrowTypeError({"Cannot find name ", typeName_->AsIdentifier()->Name()}, Start()); - } - - SetTsType(checker->GetTypeReferenceType(this, var)); - return TsType(); -} - -checker::VerifiedType TSTypeReference::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - TSTypeReference *TSTypeReference::Clone(ArenaAllocator *allocator, AstNode *parent) { auto *clonedTypeName = typeName_->Clone(allocator, nullptr)->AsExpression(); diff --git a/ets2panda/ir/ts/tsUndefinedKeyword.cpp b/ets2panda/ir/ts/tsUndefinedKeyword.cpp index fc10fda9073bc3d5e7c3d3989f4b3304200ef7cb..a00522f5b4b3b7c04445674dd34a536eb0aee9a3 100644 --- a/ets2panda/ir/ts/tsUndefinedKeyword.cpp +++ b/ets2panda/ir/ts/tsUndefinedKeyword.cpp @@ -15,12 +15,6 @@ #include "tsUndefinedKeyword.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" - namespace ark::es2panda::ir { void TSUndefinedKeyword::TransformChildren([[maybe_unused]] const NodeTransformer &cb, [[maybe_unused]] std::string_view const transformationName) @@ -33,39 +27,4 @@ void TSUndefinedKeyword::Iterate(const NodeTraverser &cb) const IterateAnnotations(cb); } -void TSUndefinedKeyword::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "TSUndefinedKeyword"}, {"annotations", AstDumper::Optional(Annotations())}}); -} - -void TSUndefinedKeyword::Dump(ir::SrcDumper *dumper) const -{ - DumpAnnotations(dumper); - dumper->Add("TSUndefinedKeyword"); -} - -void TSUndefinedKeyword::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void TSUndefinedKeyword::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *TSUndefinedKeyword::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::Type *TSUndefinedKeyword::GetType([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GlobalUndefinedType(); -} - -checker::VerifiedType TSUndefinedKeyword::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/ts/tsUnionType.cpp b/ets2panda/ir/ts/tsUnionType.cpp index 97cc33ed09177412486d2d12cd0103d5817cc08c..270138e7025e0d2da245da360947877af371d5c9 100644 --- a/ets2panda/ir/ts/tsUnionType.cpp +++ b/ets2panda/ir/ts/tsUnionType.cpp @@ -15,12 +15,6 @@ #include "tsUnionType.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" - namespace ark::es2panda::ir { void TSUnionType::TransformChildren(const NodeTransformer &cb, std::string_view transformationName) { @@ -43,53 +37,6 @@ void TSUnionType::Iterate(const NodeTraverser &cb) const IterateAnnotations(cb); } -void TSUnionType::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "TSUnionType"}, {"types", types_}, {"annotations", AstDumper::Optional(Annotations())}}); -} - -void TSUnionType::Dump(ir::SrcDumper *dumper) const -{ - DumpAnnotations(dumper); - dumper->Add("TSUnionType"); -} - -void TSUnionType::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void TSUnionType::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *TSUnionType::Check([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType TSUnionType::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - -checker::Type *TSUnionType::GetType(checker::TSChecker *checker) -{ - if (TsType() != nullptr) { - return TsType(); - } - - ArenaVector types(checker->Allocator()->Adapter()); - - for (auto *it : types_) { - types.push_back(it->GetType(checker)); - } - - SetTsType(checker->CreateUnionType(std::move(types))); - return TsType(); -} - TSUnionType *TSUnionType::Clone(ArenaAllocator *allocator, AstNode *parent) { // Clone all type nodes in the union diff --git a/ets2panda/ir/ts/tsUnknownKeyword.cpp b/ets2panda/ir/ts/tsUnknownKeyword.cpp index ebd721e2d63c459520f204fc8ca8ce7ab42b0074..54d61d266565b55c28f69f616e312893c853df53 100644 --- a/ets2panda/ir/ts/tsUnknownKeyword.cpp +++ b/ets2panda/ir/ts/tsUnknownKeyword.cpp @@ -15,12 +15,6 @@ #include "tsUnknownKeyword.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" - namespace ark::es2panda::ir { void TSUnknownKeyword::TransformChildren([[maybe_unused]] const NodeTransformer &cb, [[maybe_unused]] std::string_view const transformationName) @@ -33,39 +27,4 @@ void TSUnknownKeyword::Iterate(const NodeTraverser &cb) const IterateAnnotations(cb); } -void TSUnknownKeyword::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "TSUnknownKeyword"}, {"annotations", AstDumper::Optional(Annotations())}}); -} - -void TSUnknownKeyword::Dump(ir::SrcDumper *dumper) const -{ - DumpAnnotations(dumper); - dumper->Add("TSUnknownKeyword"); -} - -void TSUnknownKeyword::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void TSUnknownKeyword::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *TSUnknownKeyword::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::Type *TSUnknownKeyword::GetType([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GlobalUnknownType(); -} - -checker::VerifiedType TSUnknownKeyword::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/ts/tsVoidKeyword.cpp b/ets2panda/ir/ts/tsVoidKeyword.cpp index e938461aa2738bbb5a79cbb291443d1719993eab..2f35e01fcf4799091ced7b8933dfc3f9ede472e1 100644 --- a/ets2panda/ir/ts/tsVoidKeyword.cpp +++ b/ets2panda/ir/ts/tsVoidKeyword.cpp @@ -15,12 +15,6 @@ #include "tsVoidKeyword.h" -#include "checker/TSchecker.h" -#include "compiler/core/ETSGen.h" -#include "compiler/core/pandagen.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" - namespace ark::es2panda::ir { void TSVoidKeyword::TransformChildren([[maybe_unused]] const NodeTransformer &cb, [[maybe_unused]] std::string_view const transformationName) @@ -33,42 +27,6 @@ void TSVoidKeyword::Iterate(const NodeTraverser &cb) const IterateAnnotations(cb); } -void TSVoidKeyword::Dump(ir::AstDumper *dumper) const -{ - dumper->Add({{"type", "TSVoidKeyword"}, {"annotations", AstDumper::Optional(Annotations())}}); -} - -void TSVoidKeyword::Dump(ir::SrcDumper *dumper) const -{ - DumpAnnotations(dumper); - dumper->Add("TSVoidKeyword"); -} - -void TSVoidKeyword::Compile(compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void TSVoidKeyword::Compile(compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *TSVoidKeyword::Check(checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::Type *TSVoidKeyword::GetType([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GlobalVoidType(); -} - -checker::VerifiedType TSVoidKeyword::Check(checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - TSVoidKeyword *TSVoidKeyword::Clone(ArenaAllocator *allocator, AstNode *parent) { auto *clone = allocator->New(allocator); diff --git a/ets2panda/ir/visitor/IterateAstVisitor.h b/ets2panda/ir/visitor/IterateAstVisitor.h index 79274780e6f1b6c15cf870658ff22aef2dad83fd..a5d7a357f65d5f8f6e53013ac55fc81870e09e1c 100644 --- a/ets2panda/ir/visitor/IterateAstVisitor.h +++ b/ets2panda/ir/visitor/IterateAstVisitor.h @@ -16,27 +16,168 @@ #ifndef ES2PANDA_COMPILER_CORE_ITERATE_AST_VISITOR_H #define ES2PANDA_COMPILER_CORE_ITERATE_AST_VISITOR_H -#include "AstVisitor.h" #include "ir/brokenTypeNode.h" -#include "ir/expressions/literals/undefinedLiteral.h" -#include "ir/expressions/blockExpression.h" +#include "ir/opaqueTypeNode.h" + +#include "ir/module/exportAllDeclaration.h" +#include "ir/module/exportDefaultDeclaration.h" +#include "ir/module/exportNamedDeclaration.h" +#include "ir/module/exportSpecifier.h" +#include "ir/module/importDefaultSpecifier.h" +#include "ir/module/importNamespaceSpecifier.h" + +#include "ir/ets/etsClassLiteral.h" +#include "ir/ets/etsStructDeclaration.h" #include "ir/ets/etsIntrinsicNode.h" #include "ir/ets/etsUnionType.h" #include "ir/ets/etsStringLiteralType.h" #include "ir/ets/etsTuple.h" +#include "ir/ets/etsTypeReference.h" +#include "ir/ets/etsTypeReferencePart.h" #include "ir/ets/etsNeverType.h" #include "ir/ets/etsNullishTypes.h" -#include "ir/statements/functionDeclaration.h" -#include "ir/expressions/functionExpression.h" +#include "ir/ets/etsReExportDeclaration.h" +#include "ir/ets/etsNewArrayInstanceExpression.h" +#include "ir/ets/etsNewMultiDimArrayInstanceExpression.h" +#include "ir/ets/etsNewClassInstanceExpression.h" +#include "ir/ets/etsFunctionType.h" +#include "ir/ets/etsNonNullishTypeNode.h" +#include "ir/ets/etsPackageDeclaration.h" +#include "ir/ets/etsPrimitiveType.h" +#include "ir/ets/etsWildcardType.h" +#include "ir/ets/etsKeyofType.h" +#include "ir/ets/etsModule.h" + +#include "ir/ts/tsAsExpression.h" +#include "ir/ts/tsEnumDeclaration.h" +#include "ir/ts/tsEnumMember.h" +#include "ir/ts/tsExternalModuleReference.h" +#include "ir/ts/tsNonNullExpression.h" +#include "ir/ts/tsTypeAssertion.h" +#include "ir/ts/tsAnyKeyword.h" +#include "ir/ts/tsArrayType.h" +#include "ir/ts/tsBigintKeyword.h" +#include "ir/ts/tsBooleanKeyword.h" +#include "ir/ts/tsLiteralType.h" +#include "ir/ts/tsNeverKeyword.h" +#include "ir/ts/tsNullKeyword.h" +#include "ir/ts/tsNumberKeyword.h" +#include "ir/ts/tsObjectKeyword.h" +#include "ir/ts/tsParenthesizedType.h" +#include "ir/ts/tsStringKeyword.h" +#include "ir/ts/tsTypeLiteral.h" +#include "ir/ts/tsUndefinedKeyword.h" +#include "ir/ts/tsUnionType.h" +#include "ir/ts/tsUnknownKeyword.h" +#include "ir/ts/tsVoidKeyword.h" +#include "ir/ts/tsConditionalType.h" +#include "ir/ts/tsConstructorType.h" +#include "ir/ts/tsFunctionType.h" +#include "ir/ts/tsImportEqualsDeclaration.h" +#include "ir/ts/tsImportType.h" +#include "ir/ts/tsInferType.h" +#include "ir/ts/tsIntersectionType.h" +#include "ir/ts/tsMappedType.h" +#include "ir/ts/tsModuleBlock.h" +#include "ir/ts/tsModuleDeclaration.h" +#include "ir/ts/tsParameterProperty.h" +#include "ir/ts/tsThisType.h" +#include "ir/ts/tsTypeAliasDeclaration.h" +#include "ir/ts/tsTypeOperator.h" +#include "ir/ts/tsTypeParameter.h" +#include "ir/ts/tsTypeParameterDeclaration.h" +#include "ir/ts/tsTypeParameterInstantiation.h" +#include "ir/ts/tsTypePredicate.h" +#include "ir/ts/tsTypeReference.h" +#include "ir/ts/tsClassImplements.h" +#include "ir/ts/tsIndexedAccessType.h" +#include "ir/ts/tsInterfaceBody.h" +#include "ir/ts/tsInterfaceDeclaration.h" +#include "ir/ts/tsInterfaceHeritage.h" +#include "ir/ts/tsNamedTupleMember.h" +#include "ir/ts/tsQualifiedName.h" +#include "ir/ts/tsTupleType.h" +#include "ir/ts/tsTypeQuery.h" + +#include "ir/base/spreadElement.h" #include "ir/base/scriptFunction.h" -#include "ir/base/methodDefinition.h" +#include "ir/base/catchClause.h" +#include "ir/base/classDefinition.h" #include "ir/base/classProperty.h" +#include "ir/base/classStaticBlock.h" +#include "ir/base/decorator.h" +#include "ir/base/methodDefinition.h" +#include "ir/base/metaProperty.h" +#include "ir/base/overloadDeclaration.h" +#include "ir/base/property.h" +#include "ir/base/tsMethodSignature.h" +#include "ir/base/tsPropertySignature.h" +#include "ir/base/tsSignatureDeclaration.h" +#include "ir/base/tsIndexSignature.h" + +#include "ir/expressions/assignmentExpression.h" +#include "ir/expressions/taggedTemplateExpression.h" +#include "ir/expressions/typeofExpression.h" +#include "ir/expressions/unaryExpression.h" +#include "ir/expressions/updateExpression.h" +#include "ir/expressions/yieldExpression.h" + +#include "ir/expressions/arrowFunctionExpression.h" +#include "ir/expressions/arrayExpression.h" +#include "ir/expressions/objectExpression.h" +#include "ir/expressions/sequenceExpression.h" +#include "ir/expressions/templateLiteral.h" +#include "ir/expressions/functionExpression.h" +#include "ir/expressions/awaitExpression.h" +#include "ir/expressions/binaryExpression.h" +#include "ir/expressions/callExpression.h" +#include "ir/expressions/classExpression.h" +#include "ir/expressions/chainExpression.h" #include "ir/expressions/identifier.h" +#include "ir/expressions/importExpression.h" #include "ir/expressions/dummyNode.h" -#include "ir/ets/etsReExportDeclaration.h" +#include "ir/expressions/directEvalExpression.h" +#include "ir/expressions/blockExpression.h" +#include "ir/expressions/conditionalExpression.h" +#include "ir/expressions/thisExpression.h" +#include "ir/expressions/literals/undefinedLiteral.h" +#include "ir/expressions/literals/bigIntLiteral.h" +#include "ir/expressions/literals/booleanLiteral.h" +#include "ir/expressions/literals/charLiteral.h" +#include "ir/expressions/literals/nullLiteral.h" +#include "ir/expressions/literals/numberLiteral.h" +#include "ir/expressions/literals/regExpLiteral.h" +#include "ir/expressions/newExpression.h" +#include "ir/expressions/omittedExpression.h" +#include "ir/expressions/superExpression.h" + +#include "ir/statements/assertStatement.h" #include "ir/statements/annotationDeclaration.h" +#include "ir/statements/breakStatement.h" +#include "ir/statements/blockStatement.h" +#include "ir/statements/continueStatement.h" +#include "ir/statements/debuggerStatement.h" +#include "ir/statements/doWhileStatement.h" +#include "ir/statements/emptyStatement.h" +#include "ir/statements/expressionStatement.h" +#include "ir/statements/forInStatement.h" +#include "ir/statements/forOfStatement.h" +#include "ir/statements/forUpdateStatement.h" +#include "ir/statements/labelledStatement.h" +#include "ir/statements/functionDeclaration.h" +#include "ir/statements/ifStatement.h" #include "ir/statements/variableDeclaration.h" #include "ir/statements/variableDeclarator.h" +#include "ir/statements/switchCaseStatement.h" +#include "ir/statements/switchStatement.h" +#include "ir/statements/tryStatement.h" +#include "ir/statements/throwStatement.h" +#include "ir/statements/whileStatement.h" + +#include "ir/as/namedType.h" +#include "ir/as/prefixAssertionExpression.h" + +#include "AstVisitor.h" namespace ark::es2panda::ir::visitor { diff --git a/ets2panda/lsp/include/create_type_help_items.h b/ets2panda/lsp/include/create_type_help_items.h index fe3193a05e088844f561efce299e00cc63e4dabd..ef648041d050b0f2f226d8eeac5abad50873cac2 100644 --- a/ets2panda/lsp/include/create_type_help_items.h +++ b/ets2panda/lsp/include/create_type_help_items.h @@ -20,7 +20,6 @@ #include #include "ir/astNode.h" #include "lexer/token/sourceLocation.h" -#include "libarkbase/utils/arena_containers.h" #include #include #include diff --git a/ets2panda/lsp/include/register_code_fix/add_local_variable.h b/ets2panda/lsp/include/register_code_fix/add_local_variable.h index 79bad1cc4c788812363275998c43fe8d407f1ae5..82ac44908a9f3ef9db6cb5ec7c2b804a60eadc43 100644 --- a/ets2panda/lsp/include/register_code_fix/add_local_variable.h +++ b/ets2panda/lsp/include/register_code_fix/add_local_variable.h @@ -22,6 +22,10 @@ #include "lsp/include/code_fixes/code_fix_types.h" #include "lsp/include/services/text_change/change_tracker.h" #include "lsp/include/types.h" +#include "ir/expressions/arrayExpression.h" +#include "ir/expressions/assignmentExpression.h" +#include "ir/expressions/binaryExpression.h" +#include "ir/expressions/memberExpression.h" namespace ark::es2panda::lsp { diff --git a/ets2panda/lsp/include/register_code_fix/fix_add_function_return_statement.h b/ets2panda/lsp/include/register_code_fix/fix_add_function_return_statement.h index 78afc9e7af67ef9774f5e9927b1d3349a02bd615..65dd41b202cf135842b937e5ed6acb65f50b1d01 100644 --- a/ets2panda/lsp/include/register_code_fix/fix_add_function_return_statement.h +++ b/ets2panda/lsp/include/register_code_fix/fix_add_function_return_statement.h @@ -20,7 +20,9 @@ #include "../services/text_change/change_tracker.h" #include "lsp/include/types.h" #include "lsp/include/code_fixes/code_fix_types.h" -#include "libarkbase/utils/arena_containers.h" + +#include "ir/ets/etsTypeReference.h" +#include "ir/expressions/functionExpression.h" namespace ark::es2panda::lsp { diff --git a/ets2panda/lsp/src/class_hierarchy.cpp b/ets2panda/lsp/src/class_hierarchy.cpp index 0d7462903a014cd71262103376843168097784ab..480ef5ac0f52da982945751dc52a6882f26805b5 100644 --- a/ets2panda/lsp/src/class_hierarchy.cpp +++ b/ets2panda/lsp/src/class_hierarchy.cpp @@ -21,6 +21,13 @@ #include "public/public.h" #include "lsp/include/internal_api.h" #include "lsp/include/completions.h" +#include "ir/base/methodDefinition.h" +#include "ir/ets/etsTypeReference.h" +#include "ir/ets/etsTypeReferencePart.h" +#include "ir/ts/tsClassImplements.h" +#include "ir/ts/tsInterfaceBody.h" +#include "ir/ts/tsInterfaceDeclaration.h" +#include "ir/ts/tsInterfaceHeritage.h" namespace ark::es2panda::lsp { diff --git a/ets2panda/lsp/src/class_hierarchy_info.cpp b/ets2panda/lsp/src/class_hierarchy_info.cpp index 94aa7c9c7aac1905b049b7f48e5abd194bf4850b..51e50de552db0d67036abd6f8e15cc59f9cf2c1e 100644 --- a/ets2panda/lsp/src/class_hierarchy_info.cpp +++ b/ets2panda/lsp/src/class_hierarchy_info.cpp @@ -19,6 +19,13 @@ #include "compiler/lowering/util.h" #include "quick_info.h" +#include "ir/base/classProperty.h" +#include "ir/base/spreadElement.h" +#include "ir/base/methodDefinition.h" +#include "ir/ets/etsNewClassInstanceExpression.h" +#include "ir/ets/etsTypeReference.h" +#include "ir/ets/etsTypeReferencePart.h" + namespace ark::es2panda::lsp { std::string GetNameFromIdentifierNode(const ir::AstNode *node) { diff --git a/ets2panda/lsp/src/classifier.cpp b/ets2panda/lsp/src/classifier.cpp index a3bc6955bb55e71bcfc859be1304848eb059faa2..7f52f35e3fc5bcb58c75b4b4af079feaf96f4ac8 100644 --- a/ets2panda/lsp/src/classifier.cpp +++ b/ets2panda/lsp/src/classifier.cpp @@ -27,8 +27,8 @@ #include "libarkbase/mem/arena_allocator.h" #include "public/es2panda_lib.h" #include "public/public.h" -#include "libarkbase/utils/arena_containers.h" #include "varbinder/declaration.h" +#include "ir/ts/tsEnumDeclaration.h" namespace ark::es2panda::lsp { diff --git a/ets2panda/lsp/src/completions.cpp b/ets2panda/lsp/src/completions.cpp index 9045f7da10c3a2aabc3b3fe3f2599de81d168b32..cec3f283bca97b0c4c03a0db3d401754a5fdb699 100644 --- a/ets2panda/lsp/src/completions.cpp +++ b/ets2panda/lsp/src/completions.cpp @@ -17,6 +17,24 @@ #include "internal_api.h" #include "compiler/lowering/util.h" #include "ir/astNode.h" +#include "ir/base/classProperty.h" +#include "ir/base/methodDefinition.h" +#include "ir/statements/variableDeclaration.h" +#include "ir/expressions/assignmentExpression.h" +#include "ir/expressions/callExpression.h" +#include "ir/expressions/functionExpression.h" +#include "ir/expressions/memberExpression.h" +#include "ir/module/importDefaultSpecifier.h" +#include "ir/ets/etsStructDeclaration.h" +#include "ir/ets/etsTypeReference.h" +#include "ir/ets/etsTypeReferencePart.h" +#include "ir/ts/tsClassImplements.h" +#include "ir/ts/tsEnumDeclaration.h" +#include "ir/ts/tsEnumMember.h" +#include "ir/ts/tsInterfaceBody.h" +#include "ir/ts/tsInterfaceDeclaration.h" +#include "ir/ts/tsInterfaceHeritage.h" +#include "ir/ts/tsQualifiedName.h" #include "public/public.h" #include #include diff --git a/ets2panda/lsp/src/completions_details.cpp b/ets2panda/lsp/src/completions_details.cpp index c2c29da6cc058b5cad1ea902ff97218f66858192..3bfaf96945d94b31e095dbe8710240cde6520f79 100644 --- a/ets2panda/lsp/src/completions_details.cpp +++ b/ets2panda/lsp/src/completions_details.cpp @@ -17,6 +17,8 @@ #include "internal_api.h" #include "compiler/lowering/util.h" #include "ir/astNode.h" +#include "ir/base/classProperty.h" +#include "ir/ts/tsEnumDeclaration.h" #include "public/public.h" #include #include diff --git a/ets2panda/lsp/src/create_type_help_items.cpp b/ets2panda/lsp/src/create_type_help_items.cpp index 59111ce32619b7200723848f7dcc576f23a4892c..df3b07e7d8859c309ad88801ebccdd1bd3d2742c 100644 --- a/ets2panda/lsp/src/create_type_help_items.cpp +++ b/ets2panda/lsp/src/create_type_help_items.cpp @@ -16,7 +16,6 @@ #include "create_type_help_items.h" #include #include -#include "libarkbase/utils/arena_containers.h" namespace ark::es2panda::lsp { diff --git a/ets2panda/lsp/src/find_rename_locations.cpp b/ets2panda/lsp/src/find_rename_locations.cpp index 89c14f2ce95ced85232cc2a77870539b27f8231f..c8ae74e582ba5b5a74d2a5707ad5cbf5d22851b9 100644 --- a/ets2panda/lsp/src/find_rename_locations.cpp +++ b/ets2panda/lsp/src/find_rename_locations.cpp @@ -23,6 +23,7 @@ #include "find_references.h" #include "internal_api.h" #include "public/public.h" +#include "ir/expressions/memberExpression.h" namespace ark::es2panda::lsp { diff --git a/ets2panda/lsp/src/formatting/rules.cpp b/ets2panda/lsp/src/formatting/rules.cpp index e69ebe7aa772032efc84bc7cdf8ccddf73d0a94f..366f262234f9ebd7fb4bc72820359c4622e6023e 100644 --- a/ets2panda/lsp/src/formatting/rules.cpp +++ b/ets2panda/lsp/src/formatting/rules.cpp @@ -18,6 +18,13 @@ #include "formatting/formatting_context.h" #include "generated/tokenType.h" #include "ir/astNode.h" +#include "ir/base/methodDefinition.h" +#include "ir/expressions/memberExpression.h" +#include "ir/expressions/binaryExpression.h" +#include "ir/expressions/yieldExpression.h" +#include "ir/expressions/literals/numberLiteral.h" +#include "ir/module/exportDefaultDeclaration.h" + #include "internal_api.h" namespace ark::es2panda::lsp { diff --git a/ets2panda/lsp/src/generate_constructor.cpp b/ets2panda/lsp/src/generate_constructor.cpp index b78c0c223a369488b744b71284ff3ad28f7db741..6c242c8b1ccca46c6240c0d4939aef27894b532b 100644 --- a/ets2panda/lsp/src/generate_constructor.cpp +++ b/ets2panda/lsp/src/generate_constructor.cpp @@ -20,6 +20,10 @@ #include "class_hierarchy.h" #include "completions.h" #include "quick_info.h" +#include "ir/base/classProperty.h" +#include "ir/base/methodDefinition.h" +#include "ir/expressions/arrowFunctionExpression.h" +#include "ir/expressions/functionExpression.h" namespace ark::es2panda::lsp { diff --git a/ets2panda/lsp/src/get_adjusted_location.cpp b/ets2panda/lsp/src/get_adjusted_location.cpp index 9a8be7c78c0121e45a46a7ac93aee779c1c16041..5ce62a7dcc55b37e8fe0dca98f72b43c0badf506 100644 --- a/ets2panda/lsp/src/get_adjusted_location.cpp +++ b/ets2panda/lsp/src/get_adjusted_location.cpp @@ -19,7 +19,8 @@ #include "ir/astNodeFlags.h" #include "public/es2panda_lib.h" #include "get_adjusted_location.h" -#include "libarkbase/utils/arena_containers.h" + +#include "ir/expressions/callExpression.h" using ark::es2panda::ir::AstNode; using ark::es2panda::ir::AstNodeType; diff --git a/ets2panda/lsp/src/get_class_property_info.cpp b/ets2panda/lsp/src/get_class_property_info.cpp index 4108ace43a73740338e8fbba4432f37972957064..895ce1c86431ee448b13799738edb202f7d9cf95 100644 --- a/ets2panda/lsp/src/get_class_property_info.cpp +++ b/ets2panda/lsp/src/get_class_property_info.cpp @@ -24,7 +24,8 @@ #include "get_class_property_info.h" #include "compiler/lowering/util.h" -#include "libarkbase/macros.h" +#include "macros.h" +#include "ir/base/classProperty.h" namespace ark::es2panda::lsp { diff --git a/ets2panda/lsp/src/get_name_or_dotted_name_span.cpp b/ets2panda/lsp/src/get_name_or_dotted_name_span.cpp index 3d942472a405a23b469d0852b5d75d26113e71aa..b6b7262fae3ad15ab3175e32d3a1fdc2708d7177 100644 --- a/ets2panda/lsp/src/get_name_or_dotted_name_span.cpp +++ b/ets2panda/lsp/src/get_name_or_dotted_name_span.cpp @@ -16,6 +16,11 @@ #include "get_name_or_dotted_name_span.h" #include "get_adjusted_location.h" #include +#include "ir/expressions/callExpression.h" +#include "ir/expressions/identifier.h" +#include "ir/expressions/memberExpression.h" +#include "ir/ts/tsModuleDeclaration.h" +#include "ir/ts/tsQualifiedName.h" namespace ark::es2panda::lsp { bool IsRightSideOfPropertyAccess(ir::AstNode *node) diff --git a/ets2panda/lsp/src/get_safe_delete_info.cpp b/ets2panda/lsp/src/get_safe_delete_info.cpp index ddeeb93ddee4413b46e33d058bf5db65b957aab3..1a30993c8a256ebd1003a8ea1e9f38b85e08f267 100644 --- a/ets2panda/lsp/src/get_safe_delete_info.cpp +++ b/ets2panda/lsp/src/get_safe_delete_info.cpp @@ -19,6 +19,7 @@ #include "compiler/lowering/util.h" #include "get_safe_delete_info.h" #include "ir/astNode.h" +#include "ir/base/methodDefinition.h" #include "internal_api.h" #include "public/public.h" #include "references.h" diff --git a/ets2panda/lsp/src/get_signature.cpp b/ets2panda/lsp/src/get_signature.cpp index 3247ca95ad78697fa2cb63a7c39433cc298f98e0..454784b809e8835899434b688d4c3cc26a652038 100644 --- a/ets2panda/lsp/src/get_signature.cpp +++ b/ets2panda/lsp/src/get_signature.cpp @@ -19,6 +19,8 @@ #include "get_signature.h" #include "internal_api.h" #include "ir/astNode.h" +#include "ir/base/methodDefinition.h" +#include "ir/expressions/callExpression.h" #include "public/es2panda_lib.h" #include "public/public.h" namespace ark::es2panda::lsp { diff --git a/ets2panda/lsp/src/inlay_hints.cpp b/ets2panda/lsp/src/inlay_hints.cpp index 7cb8fef9b68f51f71ded026fe504319f811b2075..bf883c24d1fd5414e8a08a93ec9aa37e318bd7be 100644 --- a/ets2panda/lsp/src/inlay_hints.cpp +++ b/ets2panda/lsp/src/inlay_hints.cpp @@ -20,7 +20,18 @@ #include "compiler/lowering/util.h" #include "inlay_hints.h" #include "public/public.h" -#include "libarkbase/utils/arena_containers.h" + +#include "ir/statements/functionDeclaration.h" +#include "ir/expressions/arrayExpression.h" +#include "ir/expressions/assignmentExpression.h" +#include "ir/expressions/callExpression.h" +#include "ir/expressions/memberExpression.h" +#include "ir/expressions/newExpression.h" +#include "ir/expressions/literals/numberLiteral.h" +#include "ir/base/classProperty.h" +#include "ir/base/methodDefinition.h" +#include "ir/ets/etsTypeReference.h" +#include "ir/ets/etsTypeReferencePart.h" namespace ark::es2panda::lsp { diff --git a/ets2panda/lsp/src/internal_api.cpp b/ets2panda/lsp/src/internal_api.cpp index 7973fe7056506bb71947a58ddf83332d6b7f5dee..5c9946ed7c54a7c2c5b2fc568b8224867cfb6c72 100644 --- a/ets2panda/lsp/src/internal_api.cpp +++ b/ets2panda/lsp/src/internal_api.cpp @@ -23,11 +23,11 @@ #include "code_fixes/code_fix_types.h" #include "compiler/lowering/util.h" #include "ir/astNode.h" +#include "ir/expressions/callExpression.h" #include "lexer/token/sourceLocation.h" #include "libarkbase/macros.h" #include "public/es2panda_lib.h" #include "public/public.h" -#include "libarkbase/utils/arena_containers.h" #include "formatting/formatting.h" #include "code_fix_provider.h" #include "get_class_property_info.h" diff --git a/ets2panda/lsp/src/isolated_declaration.cpp b/ets2panda/lsp/src/isolated_declaration.cpp index 4b4e179d01adc92e2fece7d4f5e2dd90d3fb775f..2b41e5e6bbf63c76b57c485e0a9daafb1d6a7493 100644 --- a/ets2panda/lsp/src/isolated_declaration.cpp +++ b/ets2panda/lsp/src/isolated_declaration.cpp @@ -15,12 +15,17 @@ #include "checker/ETSchecker.h" #include "checker/types/ets/etsFunctionType.h" +#include "checker/types/ets/etsObjectType.h" +#include "checker/types/ets/etsUnionType.h" +#include "checker/types/ets/etsArrayType.h" #include "isolated_declaration.h" #include "compiler/lowering/util.h" #include "ir/astNode.h" +#include "ir/typeNode.h" #include "ir/base/classProperty.h" #include "ir/base/methodDefinition.h" #include "ir/base/scriptFunction.h" +#include "ir/expressions/arrowFunctionExpression.h" #include "ir/ets/etsNewClassInstanceExpression.h" namespace ark::es2panda::lsp { diff --git a/ets2panda/lsp/src/node_matchers.cpp b/ets2panda/lsp/src/node_matchers.cpp index 33ce4f1c868b959b4a031f0bb401f311dbfcde94..225c844d5caceee6af1ee99b30d1c26e80c38b26 100644 --- a/ets2panda/lsp/src/node_matchers.cpp +++ b/ets2panda/lsp/src/node_matchers.cpp @@ -18,9 +18,38 @@ #include "node_matchers.h" #include "public/es2panda_lib.h" #include "public/public.h" +#include "ir/base/classProperty.h" +#include "ir/base/methodDefinition.h" +#include "ir/base/property.h" +#include "ir/base/scriptFunction.h" +#include "ir/base/spreadElement.h" +#include "ir/ets/etsKeyofType.h" +#include "ir/ets/etsNewClassInstanceExpression.h" #include "ir/ets/etsReExportDeclaration.h" +#include "ir/ets/etsStructDeclaration.h" +#include "ir/ets/etsTypeReference.h" +#include "ir/ets/etsTypeReferencePart.h" +#include "ir/ts/tsClassImplements.h" +#include "ir/ts/tsEnumDeclaration.h" +#include "ir/ts/tsEnumMember.h" +#include "ir/ts/tsInterfaceDeclaration.h" +#include "ir/ts/tsTypeAliasDeclaration.h" +#include "ir/ts/tsTypeParameter.h" +#include "ir/ts/tsNonNullExpression.h" #include "ir/statements/annotationDeclaration.h" #include "ir/statements/annotationUsage.h" +#include "ir/statements/functionDeclaration.h" +#include "ir/statements/switchStatement.h" +#include "ir/statements/variableDeclaration.h" +#include "ir/statements/variableDeclarator.h" +#include "ir/expressions/awaitExpression.h" +#include "ir/expressions/callExpression.h" +#include "ir/expressions/memberExpression.h" +#include "ir/expressions/unaryExpression.h" +#include "ir/expressions/superExpression.h" +#include "ir/expressions/literals/bigIntLiteral.h" +#include "ir/module/importDefaultSpecifier.h" +#include "ir/module/importNamespaceSpecifier.h" namespace ark::es2panda::lsp { diff --git a/ets2panda/lsp/src/organize_imports.cpp b/ets2panda/lsp/src/organize_imports.cpp index e0a74cee5cbd2a660225fd04b3fb4cc739088fbd..198b15535ebe9fbfbfb737e0a51a2b81ed2ea945 100644 --- a/ets2panda/lsp/src/organize_imports.cpp +++ b/ets2panda/lsp/src/organize_imports.cpp @@ -20,6 +20,10 @@ #include "internal_api.h" #include "public/public.h" #include "lsp/include/organize_imports.h" +#include "ir/expressions/memberExpression.h" +#include "ir/ts/tsQualifiedName.h" +#include "ir/module/importDefaultSpecifier.h" +#include "ir/module/importNamespaceSpecifier.h" namespace ark::es2panda::lsp { diff --git a/ets2panda/lsp/src/quick_info.cpp b/ets2panda/lsp/src/quick_info.cpp index c7ac6bf677b265b616236d9bb38c3185474bf553..11e7d0a9179af69087ac7e2028407ec7cc47425f 100644 --- a/ets2panda/lsp/src/quick_info.cpp +++ b/ets2panda/lsp/src/quick_info.cpp @@ -17,8 +17,39 @@ #include "internal_api.h" #include "ir/astNode.h" #include "public/public.h" +#include "ir/base/classProperty.h" +#include "ir/base/methodDefinition.h" +#include "ir/base/property.h" +#include "ir/ets/etsFunctionType.h" #include "ir/ets/etsTuple.h" #include "ir/ets/etsUnionType.h" +#include "ir/ets/etsTypeReference.h" +#include "ir/ets/etsTypeReferencePart.h" +#include "ir/ets/etsPrimitiveType.h" +#include "ir/ets/etsStructDeclaration.h" +#include "ir/ets/etsNewClassInstanceExpression.h" +#include "ir/ts/tsArrayType.h" +#include "ir/ts/tsEnumDeclaration.h" +#include "ir/ts/tsEnumMember.h" +#include "ir/ts/tsInterfaceBody.h" +#include "ir/ts/tsInterfaceDeclaration.h" +#include "ir/ts/tsTypeAliasDeclaration.h" +#include "ir/ts/tsTypeParameter.h" +#include "ir/ts/tsTypeParameterDeclaration.h" +#include "ir/ts/tsTypeParameterInstantiation.h" +#include "ir/ts/tsQualifiedName.h" +#include "ir/expressions/assignmentExpression.h" +#include "ir/expressions/classExpression.h" +#include "ir/expressions/functionExpression.h" +#include "ir/expressions/literals/undefinedLiteral.h" +#include "ir/expressions/literals/bigIntLiteral.h" +#include "ir/expressions/literals/stringLiteral.h" +#include "ir/expressions/literals/booleanLiteral.h" +#include "ir/expressions/literals/charLiteral.h" +#include "ir/expressions/literals/nullLiteral.h" +#include "ir/expressions/literals/numberLiteral.h" +#include "ir/expressions/literals/regExpLiteral.h" +#include "ir/module/importDefaultSpecifier.h" #include "api.h" #include "rename.h" #include "isolated_declaration.h" diff --git a/ets2panda/lsp/src/refactors/convert_chain.cpp b/ets2panda/lsp/src/refactors/convert_chain.cpp index 6923a02fe90816753f533564055b1bdbe267d59e..bbd9ae3223035a13a7e4ea36b065de3b1025d298 100644 --- a/ets2panda/lsp/src/refactors/convert_chain.cpp +++ b/ets2panda/lsp/src/refactors/convert_chain.cpp @@ -18,6 +18,9 @@ #include "refactor_provider.h" #include "internal_api.h" #include "public/public.h" +#include "ir/base/scriptFunction.h" +#include "ir/expressions/conditionalExpression.h" +#include "ir/expressions/memberExpression.h" namespace ark::es2panda::lsp { ConvertChainRefactor::ConvertChainRefactor() diff --git a/ets2panda/lsp/src/refactors/convert_function.cpp b/ets2panda/lsp/src/refactors/convert_function.cpp index 097fe6fe6592ba119ee5f0d62bcf054604516b89..3ce2ba2f47314cdc196acc56ee121bba3e6cf8f9 100644 --- a/ets2panda/lsp/src/refactors/convert_function.cpp +++ b/ets2panda/lsp/src/refactors/convert_function.cpp @@ -17,7 +17,10 @@ #include "refactors/convert_function.h" #include "refactor_provider.h" #include "internal_api.h" - +#include "ir/base/classProperty.h" +#include "ir/statements/variableDeclarator.h" +#include "ir/expressions/callExpression.h" +#include "ir/base/methodDefinition.h" namespace ark::es2panda::lsp { ConvertFunctionRefactor::ConvertFunctionRefactor() diff --git a/ets2panda/lsp/src/refactors/convert_import.cpp b/ets2panda/lsp/src/refactors/convert_import.cpp index fbe48a59f99a326a634918e055bca11775e71f7e..16b141888a5f435ceb872a3d9682620375800430 100644 --- a/ets2panda/lsp/src/refactors/convert_import.cpp +++ b/ets2panda/lsp/src/refactors/convert_import.cpp @@ -17,6 +17,7 @@ #include "refactors/convert_import.h" #include "refactor_provider.h" #include "internal_api.h" +#include "ir/ets/etsImportDeclaration.h" namespace ark::es2panda::lsp { diff --git a/ets2panda/lsp/src/references.cpp b/ets2panda/lsp/src/references.cpp index 2370edb0e3cea65ad694452ad4b0c795fd148482..a716c5b54f25476ee00044aa024d27b9c1497aeb 100644 --- a/ets2panda/lsp/src/references.cpp +++ b/ets2panda/lsp/src/references.cpp @@ -18,6 +18,7 @@ #include "api.h" #include "compiler/lowering/util.h" #include "ir/astNode.h" +#include "ir/ets/etsModule.h" #include "public/es2panda_lib.h" #include "public/public.h" diff --git a/ets2panda/lsp/src/register_code_fix/add_missing_new_operator.cpp b/ets2panda/lsp/src/register_code_fix/add_missing_new_operator.cpp index 8c678ce14e1fa1174cc39a274a7dc87584449f63..d1fd728c8b3e28a41aaf232e0de1d24549ce8cb0 100644 --- a/ets2panda/lsp/src/register_code_fix/add_missing_new_operator.cpp +++ b/ets2panda/lsp/src/register_code_fix/add_missing_new_operator.cpp @@ -16,6 +16,7 @@ #include "lsp/include/internal_api.h" #include "lsp/include/code_fix_provider.h" #include "lsp/include/register_code_fix/add_missing_new_operator.h" +#include "ir/expressions/callExpression.h" namespace ark::es2panda::lsp { const int G_ADD_MISSING_NEW_OPERATOR_CODE = 1022; diff --git a/ets2panda/lsp/src/register_code_fix/constructor_for_derived_need_super_call.cpp b/ets2panda/lsp/src/register_code_fix/constructor_for_derived_need_super_call.cpp index 16af499d9d5d94d161c8e659b9c588a3e53a0a88..8150be7e8706def301dfdc3218cbf09e9089027b 100644 --- a/ets2panda/lsp/src/register_code_fix/constructor_for_derived_need_super_call.cpp +++ b/ets2panda/lsp/src/register_code_fix/constructor_for_derived_need_super_call.cpp @@ -17,6 +17,12 @@ #include "generated/code_fix_register.h" #include "lsp/include/code_fix_provider.h" #include "lsp/include/register_code_fix/constructor_for_derived_need_super_call.h" +#include "ir/base/methodDefinition.h" +#include "ir/base/scriptFunction.h" +#include "ir/expressions/callExpression.h" +#include "ir/expressions/functionExpression.h" +#include "ir/statements/expressionStatement.h" +#include "ir/ets/etsStructDeclaration.h" namespace ark::es2panda::lsp { using codefixes::CONSTRUCTOR_DERIVED_NEED_SUPER; diff --git a/ets2panda/lsp/src/register_code_fix/fix_add_function_return_statement.cpp b/ets2panda/lsp/src/register_code_fix/fix_add_function_return_statement.cpp index 51beebf135f06381ca8df9a5ad6711611bc1bba1..8a938556a69beaf58a687af6ba18e8777bda0cef 100644 --- a/ets2panda/lsp/src/register_code_fix/fix_add_function_return_statement.cpp +++ b/ets2panda/lsp/src/register_code_fix/fix_add_function_return_statement.cpp @@ -23,6 +23,9 @@ #include "lsp/include/code_fix_provider.h" #include "lsp/include/internal_api.h" #include "public/es2panda_lib.h" +#include "ir/base/scriptFunction.h" +#include "ir/ets/etsTypeReference.h" +#include "ir/ets/etsTypeReferencePart.h" namespace ark::es2panda::lsp { using codefixes::FIX_ADD_FUNCTION_RETURN_STATEMENT; diff --git a/ets2panda/lsp/src/register_code_fix/fix_class_doesnt_implement_inherited_abstract_member.cpp b/ets2panda/lsp/src/register_code_fix/fix_class_doesnt_implement_inherited_abstract_member.cpp index b8c4fa1f056f272d26198f764c86a8a10e67b561..ccc7b1ba36b8890bd605d562d730642484b35fe0 100644 --- a/ets2panda/lsp/src/register_code_fix/fix_class_doesnt_implement_inherited_abstract_member.cpp +++ b/ets2panda/lsp/src/register_code_fix/fix_class_doesnt_implement_inherited_abstract_member.cpp @@ -20,6 +20,9 @@ #include "internal_api.h" #include "ir/astNode.h" #include "ir/base/classDefinition.h" +#include "ir/base/methodDefinition.h" +#include "ir/ets/etsTypeReference.h" +#include "ir/ets/etsTypeReferencePart.h" #include "public/es2panda_lib.h" #include "register_code_fix/fix_class_doesnt_implement_inherited_abstract_member.h" #include "public/public.h" diff --git a/ets2panda/lsp/src/register_code_fix/fix_class_incorrectly_implements_interface.cpp b/ets2panda/lsp/src/register_code_fix/fix_class_incorrectly_implements_interface.cpp index 43d0d00c45a9e51d24aa7a19bf2403d834611a22..152d9100ca9d226493899892e6aa46546947d9d0 100644 --- a/ets2panda/lsp/src/register_code_fix/fix_class_incorrectly_implements_interface.cpp +++ b/ets2panda/lsp/src/register_code_fix/fix_class_incorrectly_implements_interface.cpp @@ -24,6 +24,8 @@ #include "ir/ts/tsInterfaceBody.h" #include "ir/ts/tsClassImplements.h" #include "ir/base/methodDefinition.h" +#include "ir/ets/etsTypeReference.h" +#include "ir/ets/etsTypeReferencePart.h" namespace ark::es2panda::lsp { using codefixes::FIX_CLASS_INCORRECTLY_IMPLEMENTS_INTERFACE_FOR_GETTER; diff --git a/ets2panda/lsp/src/register_code_fix/fix_class_super_must_precede_this_access.cpp b/ets2panda/lsp/src/register_code_fix/fix_class_super_must_precede_this_access.cpp index 0a28b0bb10dfbeca29a2b35ca3a5d96036b6dfc4..a1ac4e0e7716c605965d872d3ca8a3986a662a5b 100644 --- a/ets2panda/lsp/src/register_code_fix/fix_class_super_must_precede_this_access.cpp +++ b/ets2panda/lsp/src/register_code_fix/fix_class_super_must_precede_this_access.cpp @@ -17,6 +17,7 @@ #include #include +#include "ir/statements/expressionStatement.h" #include "compiler/lowering/util.h" #include "generated/code_fix_register.h" #include "lsp/include/code_fix_provider.h" diff --git a/ets2panda/lsp/src/register_code_fix/fix_nan_equality.cpp b/ets2panda/lsp/src/register_code_fix/fix_nan_equality.cpp index f1040baacc001ff077433096dfc93fe8360c013a..2fa8cf8df641276f2699b64353afaa8424cee469 100644 --- a/ets2panda/lsp/src/register_code_fix/fix_nan_equality.cpp +++ b/ets2panda/lsp/src/register_code_fix/fix_nan_equality.cpp @@ -19,6 +19,7 @@ #include #include "lsp/include/code_fix_provider.h" #include "lsp/include/internal_api.h" +#include "ir/expressions/binaryExpression.h" namespace ark::es2panda::lsp { diff --git a/ets2panda/lsp/src/register_code_fix/fix_return_type_in_async_function.cpp b/ets2panda/lsp/src/register_code_fix/fix_return_type_in_async_function.cpp index f26a16d5b7c08950277c68a4b39d8f98386721bc..bc6a86339a4f9e3a1b2504ba30c72ef99a066b68 100644 --- a/ets2panda/lsp/src/register_code_fix/fix_return_type_in_async_function.cpp +++ b/ets2panda/lsp/src/register_code_fix/fix_return_type_in_async_function.cpp @@ -18,6 +18,9 @@ #include "lsp/include/code_fix_provider.h" #include "lsp/include/internal_api.h" #include "compiler/lowering/util.h" +#include "ir/ets/etsTypeReference.h" +#include "ir/ets/etsTypeReferencePart.h" +#include "ir/ts/tsTypeParameterInstantiation.h" namespace ark::es2panda::lsp { using codefixes::FIX_RETURN_TYPE_IN_ASYNC_FUNCTION; diff --git a/ets2panda/lsp/src/register_code_fix/fix_spelling.cpp b/ets2panda/lsp/src/register_code_fix/fix_spelling.cpp index 2586467028544f60be4b472388a993ede9ac9944..0c9fdab9b8dda06df1e2c0f64b0cc4ea5cf68c1a 100644 --- a/ets2panda/lsp/src/register_code_fix/fix_spelling.cpp +++ b/ets2panda/lsp/src/register_code_fix/fix_spelling.cpp @@ -21,6 +21,8 @@ #include "lsp/include/code_fix_provider.h" #include "lsp/include/internal_api.h" #include "public/es2panda_lib.h" +#include "ir/ets/etsImportDeclaration.h" +#include "ir/expressions/literals/stringLiteral.h" namespace ark::es2panda::lsp { using codefixes::FIX_SPELLING; diff --git a/ets2panda/lsp/src/register_code_fix/fix_unreachable_code.cpp b/ets2panda/lsp/src/register_code_fix/fix_unreachable_code.cpp index 7a999732235500a56a75035c697c92915726091d..f27a68b041024045f226a3d2c183fefdcb4aef87 100644 --- a/ets2panda/lsp/src/register_code_fix/fix_unreachable_code.cpp +++ b/ets2panda/lsp/src/register_code_fix/fix_unreachable_code.cpp @@ -18,7 +18,13 @@ #include "generated/code_fix_register.h" #include "lsp/include/code_fix_provider.h" #include "lsp/include/internal_api.h" - +#include "ir/expressions/literals/stringLiteral.h" +#include "ir/expressions/literals/booleanLiteral.h" +#include "ir/expressions/literals/charLiteral.h" +#include "ir/expressions/literals/numberLiteral.h" +#include "ir/statements/forUpdateStatement.h" +#include "ir/statements/ifStatement.h" +#include "ir/statements/whileStatement.h" namespace ark::es2panda::lsp { using codefixes::FIX_UNREACHABLE_CODE; diff --git a/ets2panda/lsp/src/register_code_fix/remove_accidental_call_parentheses.cpp b/ets2panda/lsp/src/register_code_fix/remove_accidental_call_parentheses.cpp index 62b6cbed0acb5ad4127eb49417ff74bc98207977..79c8313244448ea4cee7e5e5b4bd6c49579f57b4 100644 --- a/ets2panda/lsp/src/register_code_fix/remove_accidental_call_parentheses.cpp +++ b/ets2panda/lsp/src/register_code_fix/remove_accidental_call_parentheses.cpp @@ -17,6 +17,7 @@ #include "generated/code_fix_register.h" #include "lsp/include/code_fix_provider.h" #include "lsp/include/register_code_fix/remove_accidental_call_parentheses.h" +#include "ir/expressions/callExpression.h" namespace ark::es2panda::lsp { using codefixes::REMOVE_ACCIDENTAL_CALL_PARENTHESES; diff --git a/ets2panda/lsp/src/rename.cpp b/ets2panda/lsp/src/rename.cpp index a0baf79c40dc24ba8717571b85245ae338f30fc3..ba051798ca59f96a802014f2ebc4ae87b01380f7 100644 --- a/ets2panda/lsp/src/rename.cpp +++ b/ets2panda/lsp/src/rename.cpp @@ -21,6 +21,14 @@ #include "lexer/token/letters.h" #include "get_adjusted_location.h" #include "compiler/lowering/util.h" +#include "ir/base/methodDefinition.h" +#include "ir/base/property.h" +#include "ir/expressions/binaryExpression.h" +#include "ir/expressions/callExpression.h" +#include "ir/expressions/memberExpression.h" +#include "ir/expressions/literals/numberLiteral.h" +#include "ir/module/exportAllDeclaration.h" +#include "ir/as/namedType.h" namespace ark::es2panda::lsp { constexpr size_t FIRST_CHAR_INDEX = 0; diff --git a/ets2panda/lsp/src/script_element_kind.cpp b/ets2panda/lsp/src/script_element_kind.cpp index f31e8d5e066b6c43362707c8481fa372a02b4f0d..8d65307aeb80da906ba4d378831ed64fb13c353a 100644 --- a/ets2panda/lsp/src/script_element_kind.cpp +++ b/ets2panda/lsp/src/script_element_kind.cpp @@ -18,6 +18,11 @@ #include "public/public.h" #include "script_element_kind.h" #include "compiler/lowering/util.h" +#include "ir/typeNode.h" +#include "ir/base/methodDefinition.h" +#include "ir/ts/tsTypeAliasDeclaration.h" +#include "ir/ets/etsTypeReference.h" +#include "ir/ets/etsTypeReferencePart.h" namespace ark::es2panda::lsp { std::tuple GetTargetTokenKindIfETSType(ir::AstNodeType type) diff --git a/ets2panda/lsp/src/services/text_change/change_tracker.cpp b/ets2panda/lsp/src/services/text_change/change_tracker.cpp index c8500dc10b9b533ccfff029110c152f01bfa4d7a..4641a61e7b35ef9e2c73930383c76b808e7fbc50 100644 --- a/ets2panda/lsp/src/services/text_change/change_tracker.cpp +++ b/ets2panda/lsp/src/services/text_change/change_tracker.cpp @@ -20,6 +20,10 @@ #include #include #include +#include "ir/base/scriptFunction.h" +#include "ir/expressions/functionExpression.h" +#include "ir/expressions/objectExpression.h" +#include "ir/ts/tsTypeParameterDeclaration.h" namespace ark::es2panda::lsp { diff --git a/ets2panda/lsp/src/signature_help.cpp b/ets2panda/lsp/src/signature_help.cpp index 55dabbc1943e89ddaa9b5ae4bd5a269819cdfc3d..b2dc4332efc9aaef5b6f2b2a2e38c0051deb89fe 100644 --- a/ets2panda/lsp/src/signature_help.cpp +++ b/ets2panda/lsp/src/signature_help.cpp @@ -15,7 +15,6 @@ #include "signature_help.h" #include "internal_api.h" -#include "libarkbase/utils/arena_containers.h" #include #include #include diff --git a/ets2panda/lsp/src/signature_help_items.cpp b/ets2panda/lsp/src/signature_help_items.cpp index 9b282fe2e51876ccf9e9825f56826b98e52eaf65..c0e4cfc1567c2ec60348db55bd0c5758c6be2219 100644 --- a/ets2panda/lsp/src/signature_help_items.cpp +++ b/ets2panda/lsp/src/signature_help_items.cpp @@ -17,7 +17,6 @@ #include #include #include -#include "libarkbase/utils/arena_containers.h" namespace ark::es2panda::lsp { diff --git a/ets2panda/lsp/src/string_completions.cpp b/ets2panda/lsp/src/string_completions.cpp index 826271901aba05be98a3d84e5baf9aa114f4dca2..1326e6c4f0c3f7bb913256a29f431a63c712f329 100644 --- a/ets2panda/lsp/src/string_completions.cpp +++ b/ets2panda/lsp/src/string_completions.cpp @@ -20,6 +20,13 @@ #include #include #include "ir/astNode.h" +#include "ir/base/classDefinition.h" +#include "ir/base/classProperty.h" +#include "ir/base/methodDefinition.h" +#include "ir/statements/classDeclaration.h" +#include "ir/ets/etsTypeReferencePart.h" +#include "ir/ts/tsInterfaceBody.h" +#include "ir/ts/tsInterfaceDeclaration.h" namespace ark::es2panda::lsp { ir::AstNode *GetDeclarationFromParent(ir::AstNode *node) diff --git a/ets2panda/lsp/src/suggestion_diagnostics.cpp b/ets2panda/lsp/src/suggestion_diagnostics.cpp index 2ee2d4970e8d2a61aea81b6bfa17b36d66deafac..be1dd8e277098dffe0dcd4f5865475456813e018 100644 --- a/ets2panda/lsp/src/suggestion_diagnostics.cpp +++ b/ets2panda/lsp/src/suggestion_diagnostics.cpp @@ -15,10 +15,10 @@ #include "suggestion_diagnostics.h" #include "internal_api.h" -#include "libarkbase/utils/arena_containers.h" #include #include #include +#include "ir/expressions/callExpression.h" namespace ark::es2panda::lsp { diff --git a/ets2panda/parser/ETSparser.cpp b/ets2panda/parser/ETSparser.cpp index bcaf53d1c5246463dbdcb924cf2d9facfd4196c9..4e5296542dac50f13a3cb34ffa3a2fbc3c611c8c 100644 --- a/ets2panda/parser/ETSparser.cpp +++ b/ets2panda/parser/ETSparser.cpp @@ -24,25 +24,37 @@ #include "util/helpers.h" #include "util/language.h" #include "util/options.h" -#include "libarkbase/utils/arena_containers.h" #include "varbinder/varbinder.h" #include "varbinder/ETSBinder.h" #include "lexer/lexer.h" #include "lexer/ETSLexer.h" + #include "ir/astNode.h" #include "ir/base/decorator.h" #include "ir/base/catchClause.h" #include "ir/base/scriptFunction.h" #include "ir/base/methodDefinition.h" +#include "ir/base/overloadDeclaration.h" #include "ir/base/spreadElement.h" + +#include "ir/expressions/callExpression.h" #include "ir/expressions/identifier.h" #include "ir/expressions/functionExpression.h" #include "ir/expressions/dummyNode.h" +#include "ir/expressions/literals/nullLiteral.h" +#include "ir/expressions/memberExpression.h" + +#include "ir/statements/expressionStatement.h" +#include "ir/statements/functionDeclaration.h" +#include "ir/statements/variableDeclarator.h" + #include "ir/module/importDeclaration.h" #include "ir/module/importDefaultSpecifier.h" #include "ir/module/importSpecifier.h" #include "ir/module/exportSpecifier.h" #include "ir/module/exportNamedDeclaration.h" +#include "ir/module/importNamespaceSpecifier.h" + #include "ir/ets/etsPrimitiveType.h" #include "ir/ets/etsPackageDeclaration.h" #include "ir/ets/etsReExportDeclaration.h" @@ -52,11 +64,12 @@ #include "ir/ets/etsModule.h" #include "ir/ets/etsTypeReference.h" #include "ir/ets/etsTypeReferencePart.h" +#include "ir/ets/etsKeyofType.h" #include "ir/ets/etsNullishTypes.h" #include "ir/ets/etsUnionType.h" #include "ir/ets/etsImportDeclaration.h" #include "ir/ets/etsStructDeclaration.h" -#include "ir/module/importNamespaceSpecifier.h" + #include "ir/ts/tsInterfaceDeclaration.h" #include "ir/ts/tsTypeParameterInstantiation.h" #include "ir/ts/tsInterfaceBody.h" @@ -70,6 +83,7 @@ #include "ir/ts/tsTypeAliasDeclaration.h" #include "ir/ts/tsTypeParameterDeclaration.h" #include "ir/ts/tsThisType.h" + #include "generated/signatures.h" #include "generated/diagnostic.h" diff --git a/ets2panda/parser/ETSparserAnnotations.cpp b/ets2panda/parser/ETSparserAnnotations.cpp index e294a8573baf600112275eb0ac90ec63b0e3fa81..139827b44ccb9dc9b8ebe9269e427db55cc2463b 100644 --- a/ets2panda/parser/ETSparserAnnotations.cpp +++ b/ets2panda/parser/ETSparserAnnotations.cpp @@ -16,11 +16,34 @@ #include "ETSparser.h" #include "generated/diagnostic.h" #include "lexer/lexer.h" +#include "ir/base/classProperty.h" +#include "ir/base/methodDefinition.h" +#include "ir/ets/etsFunctionType.h" #include "ir/ets/etsTuple.h" #include "ir/ets/etsUnionType.h" +#include "ir/ets/etsStructDeclaration.h" +#include "ir/ets/etsStringLiteralType.h" +#include "ir/ets/etsNullishTypes.h" +#include "ir/ets/etsTypeReference.h" +#include "ir/ets/etsTypeReferencePart.h" +#include "ir/ets/etsModule.h" +#include "ir/ts/tsInterfaceDeclaration.h" +#include "ir/ts/tsTypeAliasDeclaration.h" +#include "ir/ts/tsArrayType.h" +#include "ir/ts/tsTypeParameter.h" + +#include "ir/expressions/identifier.h" +#include "ir/expressions/arrayExpression.h" +#include "ir/expressions/arrowFunctionExpression.h" #include "ir/statements/annotationDeclaration.h" +#include "ir/statements/expressionStatement.h" +#include "ir/statements/functionDeclaration.h" +#include "ir/statements/variableDeclaration.h" +#include "ir/statements/variableDeclarator.h" #include "ir/brokenTypeNode.h" +#include "generated/signatures.h" + namespace ark::es2panda::parser { ir::Statement *ETSParser::ParseTopLevelAnnotation(ir::ModifierFlags memberModifiers) diff --git a/ets2panda/parser/ETSparserClasses.cpp b/ets2panda/parser/ETSparserClasses.cpp index 56739714156c2f0b8ce60dc8db31099969c55238..11b35ad6cec4d810a73727623a21490fcd5c5ebc 100644 --- a/ets2panda/parser/ETSparserClasses.cpp +++ b/ets2panda/parser/ETSparserClasses.cpp @@ -22,7 +22,6 @@ #include "parser/parserStatusContext.h" #include "util/helpers.h" #include "util/language.h" -#include "libarkbase/utils/arena_containers.h" #include "varbinder/varbinder.h" #include "varbinder/ETSBinder.h" #include "lexer/lexer.h" @@ -37,6 +36,7 @@ #include "ir/base/methodDefinition.h" #include "ir/base/classStaticBlock.h" #include "ir/base/spreadElement.h" +#include "ir/base/overloadDeclaration.h" #include "ir/expressions/identifier.h" #include "ir/expressions/functionExpression.h" #include "ir/expressions/dummyNode.h" diff --git a/ets2panda/parser/ETSparserEnums.cpp b/ets2panda/parser/ETSparserEnums.cpp index c3d93457c89250665a16bc6a4875ded5dc82a684..9615d4e59a49957b6dc311ea2e1f063f8ab4d659 100644 --- a/ets2panda/parser/ETSparserEnums.cpp +++ b/ets2panda/parser/ETSparserEnums.cpp @@ -22,7 +22,6 @@ #include "parser/parserStatusContext.h" #include "util/helpers.h" #include "util/language.h" -#include "libarkbase/utils/arena_containers.h" #include "varbinder/varbinder.h" #include "varbinder/ETSBinder.h" #include "lexer/lexer.h" @@ -43,6 +42,7 @@ #include "ir/statements/classDeclaration.h" #include "ir/statements/variableDeclarator.h" #include "ir/statements/variableDeclaration.h" +#include "ir/expressions/binaryExpression.h" #include "ir/expressions/dummyNode.h" #include "ir/expressions/callExpression.h" #include "ir/expressions/thisExpression.h" diff --git a/ets2panda/parser/ETSparserExpressions.cpp b/ets2panda/parser/ETSparserExpressions.cpp index 4fd573b45d684582cb2e7e7ad1b1865270dbcfc5..343a24124e3b6dee402dac3d5b35693922353c88 100644 --- a/ets2panda/parser/ETSparserExpressions.cpp +++ b/ets2panda/parser/ETSparserExpressions.cpp @@ -16,8 +16,95 @@ #include "ETSparser.h" #include "lexer/lexer.h" -#include "ir/expressions/literals/undefinedLiteral.h" +#include "ir/brokenTypeNode.h" +#include "ir/ets/etsClassLiteral.h" +#include "ir/ets/etsStructDeclaration.h" +#include "ir/ets/etsIntrinsicNode.h" +#include "ir/ets/etsUnionType.h" +#include "ir/ets/etsStringLiteralType.h" #include "ir/ets/etsTuple.h" +#include "ir/ets/etsTypeReference.h" +#include "ir/ets/etsTypeReferencePart.h" +#include "ir/ets/etsNeverType.h" +#include "ir/ets/etsNullishTypes.h" +#include "ir/ets/etsReExportDeclaration.h" +#include "ir/ets/etsNewArrayInstanceExpression.h" +#include "ir/ets/etsNewMultiDimArrayInstanceExpression.h" +#include "ir/ets/etsNewClassInstanceExpression.h" +#include "ir/ets/etsFunctionType.h" +#include "ir/ets/etsNonNullishTypeNode.h" +#include "ir/ets/etsPackageDeclaration.h" +#include "ir/ets/etsPrimitiveType.h" +#include "ir/ets/etsWildcardType.h" +#include "ir/ets/etsKeyofType.h" +#include "ir/ets/etsModule.h" + +#include "ir/ts/tsAsExpression.h" +#include "ir/ts/tsNonNullExpression.h" +#include "ir/ts/tsTypeAssertion.h" + +#include "ir/base/spreadElement.h" +#include "ir/base/scriptFunction.h" +#include "ir/base/catchClause.h" +#include "ir/base/classDefinition.h" +#include "ir/base/classProperty.h" +#include "ir/base/classStaticBlock.h" +#include "ir/base/decorator.h" +#include "ir/base/methodDefinition.h" +#include "ir/base/metaProperty.h" +#include "ir/base/overloadDeclaration.h" +#include "ir/base/property.h" +#include "ir/base/tsMethodSignature.h" +#include "ir/base/tsPropertySignature.h" +#include "ir/base/tsSignatureDeclaration.h" +#include "ir/base/tsIndexSignature.h" + +#include "ir/expressions/assignmentExpression.h" +#include "ir/expressions/taggedTemplateExpression.h" +#include "ir/expressions/typeofExpression.h" +#include "ir/expressions/unaryExpression.h" +#include "ir/expressions/updateExpression.h" +#include "ir/expressions/yieldExpression.h" +#include "ir/expressions/arrowFunctionExpression.h" +#include "ir/expressions/arrayExpression.h" +#include "ir/expressions/objectExpression.h" +#include "ir/expressions/sequenceExpression.h" +#include "ir/expressions/templateLiteral.h" +#include "ir/expressions/functionExpression.h" +#include "ir/expressions/awaitExpression.h" +#include "ir/expressions/binaryExpression.h" +#include "ir/expressions/callExpression.h" +#include "ir/expressions/classExpression.h" +#include "ir/expressions/chainExpression.h" +#include "ir/expressions/identifier.h" +#include "ir/expressions/importExpression.h" +#include "ir/expressions/dummyNode.h" +#include "ir/expressions/directEvalExpression.h" +#include "ir/expressions/blockExpression.h" +#include "ir/expressions/conditionalExpression.h" +#include "ir/expressions/thisExpression.h" +#include "ir/expressions/literals/undefinedLiteral.h" +#include "ir/expressions/literals/bigIntLiteral.h" +#include "ir/expressions/literals/booleanLiteral.h" +#include "ir/expressions/literals/charLiteral.h" +#include "ir/expressions/literals/nullLiteral.h" +#include "ir/expressions/literals/numberLiteral.h" +#include "ir/expressions/literals/regExpLiteral.h" +#include "ir/expressions/newExpression.h" +#include "ir/expressions/omittedExpression.h" +#include "ir/expressions/superExpression.h" + +#include "ir/statements/assertStatement.h" +#include "ir/statements/annotationDeclaration.h" +#include "ir/statements/breakStatement.h" +#include "ir/statements/blockStatement.h" +#include "ir/statements/continueStatement.h" +#include "ir/statements/debuggerStatement.h" +#include "ir/statements/doWhileStatement.h" +#include "ir/statements/emptyStatement.h" +#include "ir/statements/functionDeclaration.h" +#include "ir/statements/variableDeclaration.h" +#include "ir/statements/variableDeclarator.h" namespace ark::es2panda::parser { class FunctionContext; diff --git a/ets2panda/parser/ETSparserNamespaces.cpp b/ets2panda/parser/ETSparserNamespaces.cpp index a8b869446b566a2f7c443161c263ce7c7b66c9ce..f274f1057378dbcd35ef22d9ac5a320cd47cf933 100644 --- a/ets2panda/parser/ETSparserNamespaces.cpp +++ b/ets2panda/parser/ETSparserNamespaces.cpp @@ -17,7 +17,6 @@ #include "lexer/lexer.h" #include "ir/astNode.h" #include "ir/ets/etsModule.h" -#include "libarkbase/utils/arena_containers.h" #include "util/errorRecovery.h" #include "generated/diagnostic.h" diff --git a/ets2panda/parser/ETSparserStatements.cpp b/ets2panda/parser/ETSparserStatements.cpp index cbca6a63e68817a52a9a426bd719231df2c9c8cd..0f44d7cc762a60e0a95f09a8f5b222698b420725 100644 --- a/ets2panda/parser/ETSparserStatements.cpp +++ b/ets2panda/parser/ETSparserStatements.cpp @@ -21,7 +21,6 @@ #include "util/errorRecovery.h" #include "util/helpers.h" #include "util/importPathManager.h" -#include "libarkbase/utils/arena_containers.h" #include "varbinder/varbinder.h" #include "varbinder/ETSBinder.h" #include "lexer/lexer.h" @@ -34,6 +33,7 @@ #include "ir/base/methodDefinition.h" #include "ir/base/classStaticBlock.h" #include "ir/base/spreadElement.h" +#include "ir/base/overloadDeclaration.h" #include "ir/expressions/identifier.h" #include "ir/expressions/functionExpression.h" #include "ir/statements/functionDeclaration.h" diff --git a/ets2panda/parser/ETSparserTypes.cpp b/ets2panda/parser/ETSparserTypes.cpp index 4a8a90882013802004d6458ef0e6a26946fc38e6..a2b615ab65204c07cd87079799111a80cbf972c2 100644 --- a/ets2panda/parser/ETSparserTypes.cpp +++ b/ets2panda/parser/ETSparserTypes.cpp @@ -21,7 +21,6 @@ #include "parser/parserStatusContext.h" #include "util/helpers.h" #include "util/language.h" -#include "libarkbase/utils/arena_containers.h" #include "varbinder/varbinder.h" #include "varbinder/ETSBinder.h" #include "lexer/lexer.h" @@ -50,6 +49,7 @@ #include "ir/ets/etsStringLiteralType.h" #include "ir/ets/etsTypeReference.h" #include "ir/ets/etsTypeReferencePart.h" +#include "ir/ets/etsNonNullishTypeNode.h" #include "ir/ets/etsNullishTypes.h" #include "ir/ets/etsUnionType.h" #include "ir/ets/etsImportDeclaration.h" diff --git a/ets2panda/parser/JsdocHelper.cpp b/ets2panda/parser/JsdocHelper.cpp index f3e75ea9a63636b99be1890c64367b0846e9a36b..875bff08000c56933ded551e04960049db412da0 100644 --- a/ets2panda/parser/JsdocHelper.cpp +++ b/ets2panda/parser/JsdocHelper.cpp @@ -17,7 +17,19 @@ #include #include "lexer/lexer.h" #include "ir/ets/etsTuple.h" +#include "ir/ets/etsStructDeclaration.h" + +#include "ir/base/classProperty.h" +#include "ir/base/methodDefinition.h" + +#include "ir/expressions/arrowFunctionExpression.h" + #include "ir/statements/annotationDeclaration.h" +#include "ir/statements/functionDeclaration.h" +#include "ir/statements/variableDeclarator.h" +#include "ir/statements/variableDeclaration.h" +#include "ir/ts/tsInterfaceDeclaration.h" +#include "ir/ts/tsTypeAliasDeclaration.h" namespace ark::es2panda::parser { static constexpr std::string_view JSDOC_END = "*/"; diff --git a/ets2panda/parser/program/program.cpp b/ets2panda/parser/program/program.cpp index 54c5b450bd0ce3dbd211c162292634a1d752117e..7e99001b8ee9feb296a415d6ea6a0538d64240ef 100644 --- a/ets2panda/parser/program/program.cpp +++ b/ets2panda/parser/program/program.cpp @@ -24,6 +24,7 @@ #include "ir/astDump.h" #include "ir/base/classDefinition.h" #include "ir/statements/blockStatement.h" +#include "ir/ets/etsModule.h" #include diff --git a/ets2panda/parser/program/program.h b/ets2panda/parser/program/program.h index 62b278ee53af92380510990b37dad285554027ea..b180d2c71569c2974b80919bcd4a1de65417a702 100644 --- a/ets2panda/parser/program/program.h +++ b/ets2panda/parser/program/program.h @@ -17,18 +17,20 @@ #define ES2PANDA_PARSER_INCLUDE_PROGRAM_H #include "util/es2pandaMacros.h" -#include "libarkbase/mem/pool_manager.h" -#include "libarkbase/os/filesystem.h" -#include "util/ustring.h" -#include "util/path.h" -#include "util/importPathManager.h" + #include "varbinder/varbinder.h" #include #include "util/enumbitops.h" - -#include #include +#include "util/ustring.h" +#include "util/path.h" +#include "util/importPathManager.h" +//#include "libarkbase/mem/pool_manager.h" +//#include "libarkbase/os/filesystem.h" +#include "libarkbase/utils/arena_vector.h" +#include "libarkbase/utils/arena_set.h" + namespace ark::es2panda::ir { class BlockStatement; } // namespace ark::es2panda::ir diff --git a/ets2panda/public/CMakeLists.txt b/ets2panda/public/CMakeLists.txt index 965ef9d300021cd9e2b19404ce342b52f5264a4c..132f57aa20efe511dfd11ed5996ef30dce2f03b6 100644 --- a/ets2panda/public/CMakeLists.txt +++ b/ets2panda/public/CMakeLists.txt @@ -632,6 +632,21 @@ add_custom_command( add_custom_target(gen_yamls DEPENDS es2panda_options_gen es2panda_keywords ${ES2PANDA_API_GENERATED} ${HEADERS_PARSER_SOURCES}) +# add check for PANDA_PRODUCT_BUILD after normal version tracking will be implemented +execute_process( + COMMAND date "+%Y-%m-%d_%H:%M:%S" + OUTPUT_VARIABLE CURRENT_DATE + OUTPUT_STRIP_TRAILING_WHITESPACE +) +execute_process( + COMMAND git rev-parse HEAD + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + OUTPUT_VARIABLE LAST_COMMIT_HASH + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +add_definitions(-DES2PANDA_DATE="${CURRENT_DATE}") +add_definitions(-DES2PANDA_HASH="${LAST_COMMIT_HASH}") set(ES2PANDA_PUBLIC_SOURCES ${LIB_NAME}.cpp @@ -647,8 +662,7 @@ if (PANDA_TARGET_WINDOWS) endif() panda_frontend_add_library(es2panda-public ${PANDA_DEFAULT_LIB_TYPE} ${ES2PANDA_PUBLIC_SOURCES}) -add_dependencies(es2panda-lib gen_api) -add_dependencies(es2panda-public es2panda-lib) +add_dependencies(es2panda-public es2panda-lib gen_api) panda_target_include_directories(es2panda-public diff --git a/ets2panda/public/contextState.h b/ets2panda/public/contextState.h new file mode 100644 index 0000000000000000000000000000000000000000..3d79daff572ee2b542bb7e8696c26e07d1ac8b32 --- /dev/null +++ b/ets2panda/public/contextState.h @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2025 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_PUBLIC_CONTEXT_STATE +#define ES2PANDA_PUBLIC_CONTEXT_STATE + +// Switch off the linter for C header +// NOLINTBEGIN +// + +#ifdef __cplusplus +extern "C" { +#endif + +enum es2panda_ContextState { + ES2PANDA_STATE_NEW, + ES2PANDA_STATE_PARSED, + ES2PANDA_STATE_BOUND, + ES2PANDA_STATE_CHECKED, + ES2PANDA_STATE_LOWERED, + ES2PANDA_STATE_ASM_GENERATED, + ES2PANDA_STATE_BIN_GENERATED, + + ES2PANDA_STATE_ERROR +}; + +typedef enum es2panda_ContextState es2panda_ContextState; + +typedef struct es2panda_Context es2panda_Context; + +#ifdef __cplusplus +} +#endif + +// NOLINTEND + +#endif // ES2PANDA_PUBLIC_CONTEXT_STATE diff --git a/ets2panda/public/es2panda_lib.cpp b/ets2panda/public/es2panda_lib.cpp index c43c9865965c26777acaed5a3a02269f9a50dc9f..02ca2f54da5e3747f0b495c3ada6535fc934827b 100644 --- a/ets2panda/public/es2panda_lib.cpp +++ b/ets2panda/public/es2panda_lib.cpp @@ -56,6 +56,7 @@ #include "compiler/lowering/util.h" #include "generated/es2panda_lib/es2panda_lib_include.inc" #include "declgen_ets2ts/declgenEts2Ts.h" +#include "libarkbase/mem/mem_config.h" // NOLINTBEGIN diff --git a/ets2panda/public/es2panda_lib.h b/ets2panda/public/es2panda_lib.h index 992e068bbe718b903d84968d04b6ce26e5312592..ea24dec6cba0d48cb08a37ea4565a197918ff49c 100644 --- a/ets2panda/public/es2panda_lib.h +++ b/ets2panda/public/es2panda_lib.h @@ -22,6 +22,7 @@ // NOLINTBEGIN // +#include "contextState.h" #include #include #include @@ -42,7 +43,6 @@ extern "C" { #endif typedef struct es2panda_Config es2panda_Config; -typedef struct es2panda_Context es2panda_Context; typedef struct es2panda_GlobalContext es2panda_GlobalContext; typedef struct es2panda_variantDoubleCharArrayBool { @@ -129,18 +129,6 @@ typedef struct es2panda_OverloadInfo { bool returnVoid; } es2panda_OverloadInfo; -enum es2panda_ContextState { - ES2PANDA_STATE_NEW, - ES2PANDA_STATE_PARSED, - ES2PANDA_STATE_BOUND, - ES2PANDA_STATE_CHECKED, - ES2PANDA_STATE_LOWERED, - ES2PANDA_STATE_ASM_GENERATED, - ES2PANDA_STATE_BIN_GENERATED, - - ES2PANDA_STATE_ERROR -}; - typedef struct es2panda_SuggestionInfo { const es2panda_DiagnosticKind *kind; const char **args; @@ -167,7 +155,6 @@ typedef enum Es2pandaLanguage { } Es2pandaLanguage; typedef enum es2panda_PluginDiagnosticType es2panda_PluginDiagnosticType; -typedef enum es2panda_ContextState es2panda_ContextState; // CC-OFFNXT(G.INC.08) project code style #include "generated/es2panda_lib/es2panda_lib_enums.inc" diff --git a/ets2panda/public/es2panda_lib_impl.inc.erb b/ets2panda/public/es2panda_lib_impl.inc.erb index 6e6468b21c7f6313f1bfdcd3b5c859facf9d3fb1..eb8e46658ac47aab8faa52c2fb92fca8e31cb1da 100644 --- a/ets2panda/public/es2panda_lib_impl.inc.erb +++ b/ets2panda/public/es2panda_lib_impl.inc.erb @@ -16,7 +16,7 @@ // Autogenerated file -- DO NOT EDIT! // NOLINTBEGIN(cppcoreguidelines-pro-bounds-pointer-arithmetic, readability-non-const-parameter) // NOLINTBEGIN(readability-function-size, readability-magic-numbers) - + % Enums::enums&.each do |name, enum| % if enum.flags&.length > 0 extern "C" __attribute__((unused)) <%= enum.namespace %><%= if enum.parent_class_name then "::" + enum.parent_class_name diff --git a/ets2panda/public/headers_parser/cpp_parser.py b/ets2panda/public/headers_parser/cpp_parser.py index 7d33d64f9814056a0f12da273871a0831d4b31c2..ba673f7677ea25167536c81afbdff3039a4ea8e0 100644 --- a/ets2panda/public/headers_parser/cpp_parser.py +++ b/ets2panda/public/headers_parser/cpp_parser.py @@ -66,7 +66,7 @@ class CppParser: self.it.end, self.parsed = parse_namespace(self.it.data, self.it.start) self.res_update() - elif self.it.is_enum(): + elif self.it.is_enum_def(): self.it.end, self.parsed = parse_enum_class(self.it.data, self.it.start) self.res_append_namespace() diff --git a/ets2panda/public/headers_parser/line_iterator.py b/ets2panda/public/headers_parser/line_iterator.py index 734799fb449982aa0e43caf2d2d6d364bd371b27..9567a28d7c03cdd5b6253c97e8935008bd4d40c4 100644 --- a/ets2panda/public/headers_parser/line_iterator.py +++ b/ets2panda/public/headers_parser/line_iterator.py @@ -73,8 +73,8 @@ class LineIterator: # pylint: disable=C0115 def is_namespace(self) -> bool: return self.current_line.find("namespace") != -1 - def is_enum(self) -> bool: - return self.current_line.find("enum ") != -1 + def is_enum_def(self) -> bool: + return self.current_line.find("enum ") != -1 and self.current_line.find("{") != -1 def is_struct(self) -> bool: return self.current_line.find("struct ") != -1 diff --git a/ets2panda/public/public.cpp b/ets2panda/public/public.cpp index c946299fed9258dbaf13770b1708ef1cd0db42a7..b39533221f31820455364c3d83b19318ee2c4a71 100644 --- a/ets2panda/public/public.cpp +++ b/ets2panda/public/public.cpp @@ -15,6 +15,7 @@ #include "public/public.h" #include "compiler/lowering/phase.h" +#include "libarkbase/os/filesystem.h" namespace ark::es2panda::public_lib { diff --git a/ets2panda/public/public.h b/ets2panda/public/public.h index 1ce750cecf71ba04f1f1b7f3feb50b678fe2f541..c2b90f963d84550e868b16ce14f95638f7fca859 100644 --- a/ets2panda/public/public.h +++ b/ets2panda/public/public.h @@ -17,7 +17,6 @@ #define ES2PANDA_PUBLIC_PUBLIC_H #include -#include "public/es2panda_lib.h" #include "assembler/assembly-program.h" #include "libarkbase/mem/arena_allocator.h" @@ -26,6 +25,7 @@ #include "parser/ETSparser.h" #include "checker/ETSchecker.h" #include "compiler/core/emitter.h" +#include "contextState.h" namespace ark::es2panda::util { class Options; diff --git a/ets2panda/test/unit/any_ins_test/any_ins_test.cpp b/ets2panda/test/unit/any_ins_test/any_ins_test.cpp index 357470258dbc0070928017a7bb44276e387ff7ef..7815f67f2c24d1a1a8f15a3e9c143e1d910fa20b 100644 --- a/ets2panda/test/unit/any_ins_test/any_ins_test.cpp +++ b/ets2panda/test/unit/any_ins_test/any_ins_test.cpp @@ -22,6 +22,8 @@ #include "assembly-parser.h" #include "assembly-program.h" #include "test/utils/checker_test.h" +#include "checker/types/ets/etsFunctionType.h" +#include "compiler/core/ETSGen.h" namespace ark::es2panda::compiler::test { diff --git a/ets2panda/test/unit/ets_specific_optimizer/ets_opt.h b/ets2panda/test/unit/ets_specific_optimizer/ets_opt.h index 6841d5f6c80416e7945c6963c16cf1708402e1da..5114071350718ff69e3615c5178139e51809cde8 100644 --- a/ets2panda/test/unit/ets_specific_optimizer/ets_opt.h +++ b/ets2panda/test/unit/ets_specific_optimizer/ets_opt.h @@ -33,7 +33,7 @@ #include "libarkbase/utils/logger.h" #include "libarkbase/utils/utils.h" #include "libarkbase/mem/arena_allocator.h" -#include "libarkbase/mem/pool_manager.h" +#include "mem/pool_manager.h" #include "optimizer/ir/inst.h" #include "bytecode_optimizer/reg_acc_alloc.h" #include "bytecode_optimizer/optimize_bytecode.h" diff --git a/ets2panda/test/unit/globalETSObjectType_test.cpp b/ets2panda/test/unit/globalETSObjectType_test.cpp index 82e306dff0a493cbb003e52f85bcc7ad5506e63c..8d289d2230a0834052f6d0e57c60e2eb93a2b401 100644 --- a/ets2panda/test/unit/globalETSObjectType_test.cpp +++ b/ets2panda/test/unit/globalETSObjectType_test.cpp @@ -19,7 +19,7 @@ #include "compiler/core/compilerImpl.h" #include "compiler/core/ETSCompiler.h" #include "compiler/core/ETSemitter.h" -#include "compiler/core/ETSGen.h" + #include "compiler/core/regSpiller.h" #include "compiler/lowering/phase.h" #include "es2panda.h" diff --git a/ets2panda/test/unit/lowerings/string_constants.cpp b/ets2panda/test/unit/lowerings/string_constants.cpp index b6e1f22ab155e5b3357d64b2101da5f692e73ba7..05fdc89c2884716d23e693a0e0f61a71ac1cd4a0 100644 --- a/ets2panda/test/unit/lowerings/string_constants.cpp +++ b/ets2panda/test/unit/lowerings/string_constants.cpp @@ -15,6 +15,7 @@ #include "lowering_test.h" #include "compiler/lowering/ets/stringConstantsLowering.h" +#include "ir/expressions/literals/stringLiteral.h" namespace ark::es2panda { diff --git a/ets2panda/test/unit/lsp/change_tracker_test.cpp b/ets2panda/test/unit/lsp/change_tracker_test.cpp index f8903499fe814af4c2578dfba471efc5f7d72323..f97af7e53b318b01dd429be87502a79d7d17bd6c 100644 --- a/ets2panda/test/unit/lsp/change_tracker_test.cpp +++ b/ets2panda/test/unit/lsp/change_tracker_test.cpp @@ -27,6 +27,12 @@ #include "lsp/include/services/text_change/change_tracker.h" #include "public/es2panda_lib.h" #include +#include "ir/statements/variableDeclaration.h" +#include "ir/base/classProperty.h" +#include "ir/base/methodDefinition.h" +#include "ir/base/property.h" +#include "ir/statements/variableDeclaration.h" +#include "ir/expressions/functionExpression.h" namespace { diff --git a/ets2panda/test/unit/lsp/create_type_help_items_test.cpp b/ets2panda/test/unit/lsp/create_type_help_items_test.cpp index 94eb481afe675839c332940e3b71d21b7ad2b35d..9180bb9f15b6c1771177a6cda2e1572a2eb50068 100644 --- a/ets2panda/test/unit/lsp/create_type_help_items_test.cpp +++ b/ets2panda/test/unit/lsp/create_type_help_items_test.cpp @@ -22,7 +22,6 @@ #include "ir/astNode.h" #include "lsp/include/internal_api.h" #include "public/es2panda_lib.h" -#include "libarkbase/utils/arena_containers.h" namespace { diff --git a/ets2panda/test/unit/lsp/fix_add_function_return_statement_test.cpp b/ets2panda/test/unit/lsp/fix_add_function_return_statement_test.cpp index 1fe8540a8ae853336cd6bdb06cd9159e05b94e23..0674b99c4f528b57ebf7d41633e0810705240e25 100644 --- a/ets2panda/test/unit/lsp/fix_add_function_return_statement_test.cpp +++ b/ets2panda/test/unit/lsp/fix_add_function_return_statement_test.cpp @@ -17,6 +17,8 @@ #include #include #include "lsp/include/register_code_fix/fix_add_function_return_statement.h" +#include "ir/statements/expressionStatement.h" +#include "ir/expressions/binaryExpression.h" namespace { class FixAddFunctionReturnStatementTests : public LSPAPITests {}; diff --git a/ets2panda/test/unit/lsp/get_auto_completion_test.cpp b/ets2panda/test/unit/lsp/get_auto_completion_test.cpp index 01466735870874ee004c978e87460c46e2234c02..91fc6a5eebffaac8199bcd9358e6c2ebdd142e02 100644 --- a/ets2panda/test/unit/lsp/get_auto_completion_test.cpp +++ b/ets2panda/test/unit/lsp/get_auto_completion_test.cpp @@ -21,6 +21,7 @@ #include "lsp/include/internal_api.h" #include "ir/astNode.h" #include "lsp/include/completions.h" +#include "ir/ets/etsImportDeclaration.h" using ark::es2panda::lsp::Initializer; diff --git a/ets2panda/test/unit/lsp/get_current_token_value_test.cpp b/ets2panda/test/unit/lsp/get_current_token_value_test.cpp index c3b623a302aded2aef1de94e1fccfcd9dea3c367..00151cb5307028dbe5d6e209739df7d7488f96a5 100644 --- a/ets2panda/test/unit/lsp/get_current_token_value_test.cpp +++ b/ets2panda/test/unit/lsp/get_current_token_value_test.cpp @@ -21,6 +21,7 @@ #include "ir/astNode.h" #include "lsp/include/internal_api.h" #include "public/es2panda_lib.h" +#include "ir/expressions/literals/numberLiteral.h" namespace { diff --git a/ets2panda/test/unit/lsp/get_preceding_token_test.cpp b/ets2panda/test/unit/lsp/get_preceding_token_test.cpp index 5ad66dca25232f64fa2977075784574a3957d2bf..684a025d7e35ef5d9a8339028613d48c36617862 100644 --- a/ets2panda/test/unit/lsp/get_preceding_token_test.cpp +++ b/ets2panda/test/unit/lsp/get_preceding_token_test.cpp @@ -21,6 +21,11 @@ #include "ir/astNode.h" #include "lsp/include/internal_api.h" #include "public/es2panda_lib.h" +#include "ir/base/classProperty.h" +#include "ir/statements/expressionStatement.h" +#include "ir/expressions/assignmentExpression.h" +#include "ir/expressions/literals/stringLiteral.h" +#include "ir/expressions/literals/numberLiteral.h" namespace { diff --git a/ets2panda/test/unit/lsp/lsp_rename_test.cpp b/ets2panda/test/unit/lsp/lsp_rename_test.cpp index 20d592f1a45ea4d0379ae755bca71735932b4352..e6425bc31fa056c0234ed3839f53711f05501a3b 100644 --- a/ets2panda/test/unit/lsp/lsp_rename_test.cpp +++ b/ets2panda/test/unit/lsp/lsp_rename_test.cpp @@ -23,6 +23,9 @@ #include "lsp/include/internal_api.h" #include "lsp_api_test.h" #include "util/path.h" +#include "ir/expressions/literals/numberLiteral.h" +#include "ir/expressions/literals/stringLiteral.h" +#include "ir/ts/tsEnumDeclaration.h" using ark::es2panda::lsp::Initializer; diff --git a/ets2panda/test/unit/lsp/quick_info_test.cpp b/ets2panda/test/unit/lsp/quick_info_test.cpp index b25ff2004ae2523b8c1435276709f7f18fcaf4cc..b788302b2aa36c12dac0bc6e223d9d622817dcaa 100644 --- a/ets2panda/test/unit/lsp/quick_info_test.cpp +++ b/ets2panda/test/unit/lsp/quick_info_test.cpp @@ -17,6 +17,10 @@ #include "lsp_api_test.h" #include "lsp/include/internal_api.h" #include +#include "ir/base/classProperty.h" +#include "ir/base/methodDefinition.h" +#include "ir/ts/tsEnumDeclaration.h" +#include "ir/ts/tsEnumMember.h" namespace { using ark::es2panda::lsp::Initializer; diff --git a/ets2panda/test/unit/lsp/quick_info_test_1.cpp b/ets2panda/test/unit/lsp/quick_info_test_1.cpp index 5312b176b57a7a2d33e3dc3ef74436b039687a39..7ec908596fc4ec2da08407edecd4b6171d59994b 100644 --- a/ets2panda/test/unit/lsp/quick_info_test_1.cpp +++ b/ets2panda/test/unit/lsp/quick_info_test_1.cpp @@ -17,6 +17,10 @@ #include "lsp_api_test.h" #include "lsp/include/internal_api.h" #include +#include "ir/base/classProperty.h" +#include "ir/base/methodDefinition.h" +#include "ir/ts/tsEnumDeclaration.h" + namespace { using ark::es2panda::lsp::Initializer; diff --git a/ets2panda/test/unit/plugin/plugin_proceed_to_state_create_import.cpp b/ets2panda/test/unit/plugin/plugin_proceed_to_state_create_import.cpp index ac36b37ceb63b8c1e3e2cb2a297d6f49981d8cf4..410c6411d78ccfbecd670da93e951c94924d9921 100644 --- a/ets2panda/test/unit/plugin/plugin_proceed_to_state_create_import.cpp +++ b/ets2panda/test/unit/plugin/plugin_proceed_to_state_create_import.cpp @@ -25,7 +25,6 @@ #include "public/es2panda_lib.h" #include "ir/ets/etsImportDeclaration.h" #include "ir/statements/expressionStatement.h" -#include "libarkbase/utils/arena_containers.h" // NOLINTBEGIN diff --git a/ets2panda/test/unit/public/ast_verifier_check_abstract_call_test.cpp b/ets2panda/test/unit/public/ast_verifier_check_abstract_call_test.cpp index 7814d7f261bf2ede5137cefe7217592859b56161..ef013672356637064e8b67d5658834599f002704 100644 --- a/ets2panda/test/unit/public/ast_verifier_check_abstract_call_test.cpp +++ b/ets2panda/test/unit/public/ast_verifier_check_abstract_call_test.cpp @@ -16,6 +16,8 @@ #include "ast_verifier_test.h" #include "ir/astNode.h" #include "ir/expressions/callExpression.h" +#include "ir/expressions/memberExpression.h" +#include "ir/expressions/superExpression.h" #include "checker/ETSchecker.h" #include "checker/types/signature.h" #include "util/diagnosticEngine.h" diff --git a/ets2panda/test/unit/public/ast_verifier_getter_setter_neg_test.cpp b/ets2panda/test/unit/public/ast_verifier_getter_setter_neg_test.cpp index 651b6ab840ed182055a63a6627d43f64c3f841db..1f9efede0534b8b1abeb1601ad2bdf5ff83932fa 100644 --- a/ets2panda/test/unit/public/ast_verifier_getter_setter_neg_test.cpp +++ b/ets2panda/test/unit/public/ast_verifier_getter_setter_neg_test.cpp @@ -16,6 +16,9 @@ #include "ast_verifier_test.h" #include "checker/ETSchecker.h" #include "ir/astNode.h" +#include "ir/typeNode.h" +#include "ir/base/methodDefinition.h" +#include "ir/expressions/functionExpression.h" #include "util/diagnosticEngine.h" #include #include diff --git a/ets2panda/test/unit/public/ast_verifier_private_access_negative_test.cpp b/ets2panda/test/unit/public/ast_verifier_private_access_negative_test.cpp index 27373a490f0062fcf61366aaf6d55358a0db6dcd..c54ffdc4c11e4bd1f261ed1c2daf766089973808 100644 --- a/ets2panda/test/unit/public/ast_verifier_private_access_negative_test.cpp +++ b/ets2panda/test/unit/public/ast_verifier_private_access_negative_test.cpp @@ -15,6 +15,12 @@ #include "ast_verifier_test.h" #include "checker/ETSchecker.h" +#include "ir/base/classProperty.h" +#include "ir/base/scriptFunction.h" +#include "ir/statements/expressionStatement.h" +#include "ir/expressions/callExpression.h" +#include "ir/expressions/functionExpression.h" +#include "ir/ets/etsModule.h" namespace { diff --git a/ets2panda/test/unit/public/ast_verifier_protected_access_correct_test.cpp b/ets2panda/test/unit/public/ast_verifier_protected_access_correct_test.cpp index d1084e4912628f9e21e0c3c55dad2a3000c5808a..22e9c2c350252676093804080c95902cdc2df82b 100644 --- a/ets2panda/test/unit/public/ast_verifier_protected_access_correct_test.cpp +++ b/ets2panda/test/unit/public/ast_verifier_protected_access_correct_test.cpp @@ -15,6 +15,8 @@ #include "ast_verifier_test.h" #include "checker/ETSchecker.h" +#include "ir/base/classProperty.h" +#include "ir/ets/etsModule.h" using ark::es2panda::compiler::ast_verifier::ModifierAccessValid; diff --git a/ets2panda/test/unit/public/ast_verifier_protected_access_negative_test.cpp b/ets2panda/test/unit/public/ast_verifier_protected_access_negative_test.cpp index f2000145e4132087de77467426aaab5e19ead0d8..bf80b16851c5b696aa05b9b32d510be118fbb1a3 100644 --- a/ets2panda/test/unit/public/ast_verifier_protected_access_negative_test.cpp +++ b/ets2panda/test/unit/public/ast_verifier_protected_access_negative_test.cpp @@ -15,6 +15,12 @@ #include "ast_verifier_test.h" #include "checker/ETSchecker.h" +#include "ir/base/classProperty.h" +#include "ir/base/scriptFunction.h" +#include "ir/statements/expressionStatement.h" +#include "ir/expressions/callExpression.h" +#include "ir/expressions/functionExpression.h" +#include "ir/ets/etsModule.h" namespace { diff --git a/ets2panda/test/unit/public/ast_verifier_reference_typeannotation_test.cpp b/ets2panda/test/unit/public/ast_verifier_reference_typeannotation_test.cpp index 06dacb6022891c8ddb831c976b432bcb8a6f67ee..7cc2446633ee70c82eaf541fa0893f996b3c2ad5 100644 --- a/ets2panda/test/unit/public/ast_verifier_reference_typeannotation_test.cpp +++ b/ets2panda/test/unit/public/ast_verifier_reference_typeannotation_test.cpp @@ -18,6 +18,7 @@ #include "ir/expressions/identifier.h" #include "parser/ETSparser.h" #include "ir/astNode.h" +#include "ir/ets/etsPrimitiveType.h" #include diff --git a/ets2panda/test/unit/public/ast_verifier_short_test.cpp b/ets2panda/test/unit/public/ast_verifier_short_test.cpp index 8da55b3b8c83f2622b7e179a00a87355adeea64c..122063fec1959cb705c27b3f819a8b7a7037d7da 100644 --- a/ets2panda/test/unit/public/ast_verifier_short_test.cpp +++ b/ets2panda/test/unit/public/ast_verifier_short_test.cpp @@ -15,12 +15,19 @@ #include "ast_verifier_test.h" #include "checker/ETSchecker.h" +#include "checker/types/ets/etsBooleanType.h" #include "es2panda.h" -#include "ir/expressions/literals/stringLiteral.h" +#include "ir/base/classProperty.h" +#include "ir/statements/variableDeclaration.h" +#include "ir/expressions/binaryExpression.h" #include "ir/expressions/identifier.h" +#include "ir/expressions/sequenceExpression.h" +#include "ir/expressions/functionExpression.h" +#include "ir/expressions/literals/stringLiteral.h" #include "ir/expressions/literals/numberLiteral.h" #include "ir/expressions/literals/booleanLiteral.h" -#include "libarkbase/macros.h" +#include "ir/ets/etsModule.h" +#include "macros.h" #include "varbinder/ETSBinder.h" #include "util/diagnosticEngine.h" diff --git a/ets2panda/test/unit/union_normalization_test_1.cpp b/ets2panda/test/unit/union_normalization_test_1.cpp index 382f620ff09f4908123090ed53f7e5ded17907e2..e07ad33666376ddafe4843e322a5de2b73e538a5 100644 --- a/ets2panda/test/unit/union_normalization_test_1.cpp +++ b/ets2panda/test/unit/union_normalization_test_1.cpp @@ -18,10 +18,11 @@ #include "checker/ETSAnalyzer.h" #include "checker/ETSchecker.h" +#include "checker/types/ets/etsUnionType.h" #include "compiler/core/compilerImpl.h" #include "compiler/core/ETSCompiler.h" #include "compiler/core/ETSemitter.h" -#include "compiler/core/ETSGen.h" + #include "compiler/core/regSpiller.h" #include "compiler/lowering/phase.h" #include "es2panda.h" diff --git a/ets2panda/test/unit/union_normalization_test_2.cpp b/ets2panda/test/unit/union_normalization_test_2.cpp index b5dd23f55eea07081350781547f480421f98f61f..70ca0d20759233e103d86991f2179a326d2246d4 100644 --- a/ets2panda/test/unit/union_normalization_test_2.cpp +++ b/ets2panda/test/unit/union_normalization_test_2.cpp @@ -18,10 +18,12 @@ #include "checker/ETSAnalyzer.h" #include "checker/ETSchecker.h" +#include "checker/types/ets/etsUnionType.h" +#include "checker/types/ets/etsStringType.h" #include "compiler/core/compilerImpl.h" #include "compiler/core/ETSCompiler.h" #include "compiler/core/ETSemitter.h" -#include "compiler/core/ETSGen.h" + #include "compiler/core/regSpiller.h" #include "compiler/lowering/phase.h" #include "es2panda.h" diff --git a/ets2panda/test/utils/ast_verifier_test.h b/ets2panda/test/utils/ast_verifier_test.h index 46d307067ab2ed5078bc40f39b0174be5b5c4acb..8e72b6d11b3933f1721812c54cbefc2b259c2da9 100644 --- a/ets2panda/test/utils/ast_verifier_test.h +++ b/ets2panda/test/utils/ast_verifier_test.h @@ -17,6 +17,7 @@ #define ES2PANDA_TEST_UTILS_AST_VERIFIER_TEST_H #include "ast_verifier/ASTVerifier.h" +#include "public/es2panda_lib.h" #include "panda_executable_path_getter.h" #include "compiler/lowering/phase.h" diff --git a/ets2panda/test/utils/checker_test.h b/ets2panda/test/utils/checker_test.h index 8fb0411c620eb65b788e5ec4a44ecbc37daddc2a..63161e262e4f044e99ff1acf3a88cdbe0a6a9b62 100644 --- a/ets2panda/test/utils/checker_test.h +++ b/ets2panda/test/utils/checker_test.h @@ -22,7 +22,7 @@ #include "compiler/core/regSpiller.h" #include "compiler/core/ETSCompiler.h" #include "compiler/core/ETSemitter.h" -#include "compiler/core/ETSGen.h" + #include "checker/ETSAnalyzer.h" #include "ir/astNode.h" #include "util/options.h" diff --git a/ets2panda/util/arktsconfig.cpp b/ets2panda/util/arktsconfig.cpp index e203987d1424a121194482832e43833f29e4f0c4..af9be01a9dfd1836ce5445bfa82830ebca5d28af 100644 --- a/ets2panda/util/arktsconfig.cpp +++ b/ets2panda/util/arktsconfig.cpp @@ -14,10 +14,11 @@ */ #include "arktsconfig.h" -#include "libarkbase/os/filesystem.h" #include "util/language.h" #include "util/diagnosticEngine.h" #include "generated/signatures.h" +#include "libarkbase/os/filesystem.h" +#include "libarkbase/os/file.h" #include #include diff --git a/ets2panda/util/helpers.cpp b/ets2panda/util/helpers.cpp index 219b36556670c5e91219486758ccf68c53a37ec6..81417ee103251df8c4470b22abd1ed526777c833 100644 --- a/ets2panda/util/helpers.cpp +++ b/ets2panda/util/helpers.cpp @@ -46,10 +46,13 @@ #include "ir/ets/etsImportDeclaration.h" #include "ir/ets/etsParameterExpression.h" +#include "ir/ets/etsTypeReference.h" +#include "ir/ets/etsTypeReferencePart.h" -#include "ir/ts/tsParameterProperty.h" -#include "ir/ts/tsInterfaceDeclaration.h" #include "ir/ts/tsEnumDeclaration.h" +#include "ir/ts/tsTypeAliasDeclaration.h" +#include "ir/ts/tsInterfaceDeclaration.h" +#include "ir/ts/tsParameterProperty.h" #include "libarkbase/utils/utf.h" diff --git a/ets2panda/util/plugin.h b/ets2panda/util/plugin.h index 21acff9ff99123cf48528eae1dd5b2ed272ee372..fce423dda6f495c9fd31c0a7d712bb893c193a4b 100644 --- a/ets2panda/util/plugin.h +++ b/ets2panda/util/plugin.h @@ -16,9 +16,10 @@ #define ES2PANDA_UTIL_PLUGINS_H #include "util/es2pandaMacros.h" -#include "libarkbase/os/library_loader.h" -#include "public/es2panda_lib.h" #include "util/ustring.h" +#include "libarkbase/os/library_loader.h" + +extern "C" struct es2panda_Context; namespace ark::es2panda::util { diff --git a/ets2panda/util/ustring.h b/ets2panda/util/ustring.h index 2a2c3a658a49ae610933dcbdf4f6d95eb1c666ac..848eab9333ed1337fe1a2302e2b8357ae9a69993 100644 --- a/ets2panda/util/ustring.h +++ b/ets2panda/util/ustring.h @@ -17,7 +17,7 @@ #define ES2PANDA_UTIL_INCLUDE_USTRING_H #include "util/es2pandaMacros.h" -#include "libarkbase/utils/arena_containers.h" +#include "libarkbase/utils/arena_string.h" #include #include diff --git a/ets2panda/varbinder/ETSBinder.cpp b/ets2panda/varbinder/ETSBinder.cpp index 75973449a369c61a92240d8a9b30dcc92e058252..d4ce6178d03ec5bcfcd2991605e22f0d2d8f2965 100644 --- a/ets2panda/varbinder/ETSBinder.cpp +++ b/ets2panda/varbinder/ETSBinder.cpp @@ -22,6 +22,33 @@ #include "util/helpers.h" #include "util/nameMangler.h" +#include "ir/base/classElement.h" +#include "ir/base/classProperty.h" +#include "ir/base/property.h" +#include "ir/base/methodDefinition.h" +#include "ir/base/overloadDeclaration.h" + +#include "ir/module/importDefaultSpecifier.h" +#include "ir/module/importNamespaceSpecifier.h" + +#include "ir/expressions/blockExpression.h" +#include "ir/expressions/objectExpression.h" +#include "ir/expressions/memberExpression.h" + +#include "ir/ts/tsClassImplements.h" +#include "ir/ts/tsEnumDeclaration.h" +#include "ir/ts/tsInterfaceBody.h" +#include "ir/ts/tsInterfaceDeclaration.h" +#include "ir/ts/tsInterfaceHeritage.h" +#include "ir/ts/tsTypeParameterDeclaration.h" +#include "ir/ts/tsTypeParameterInstantiation.h" + +#include "ir/ets/etsModule.h" +#include "ir/ets/etsNewClassInstanceExpression.h" +#include "ir/ets/etsTypeReference.h" +#include "ir/ets/etsTypeReferencePart.h" + +#include "libarkbase/os/filesystem.h" namespace ark::es2panda::varbinder { void ETSBinder::IdentifierAnalysis() diff --git a/ets2panda/varbinder/ETSBinder.h b/ets2panda/varbinder/ETSBinder.h index 025f4c30d9c9186f5bf8afde56c5bced090d1890..305b75a2ffd12cf9d2c2b86b2b2179d21ab39814 100644 --- a/ets2panda/varbinder/ETSBinder.h +++ b/ets2panda/varbinder/ETSBinder.h @@ -25,6 +25,8 @@ #include "ir/statements/annotationDeclaration.h" #include "parser/ETSparser.h" +#include "libarkbase/utils/arena_unordered_set.h" + namespace ark::es2panda::ir { class ETSImportDeclaration; class AstNode; diff --git a/ets2panda/varbinder/TypedBinder.cpp b/ets2panda/varbinder/TypedBinder.cpp index 2cf8062201b8ba899049b8b3a0af4152b3cc220c..2b82cfaf2615985d8cbafc932eeee1da08ca82df 100644 --- a/ets2panda/varbinder/TypedBinder.cpp +++ b/ets2panda/varbinder/TypedBinder.cpp @@ -14,6 +14,7 @@ */ #include "TypedBinder.h" + #include "ir/base/tsSignatureDeclaration.h" #include "ir/base/tsMethodSignature.h" #include "ir/ts/tsFunctionType.h" diff --git a/ets2panda/varbinder/declaration.h b/ets2panda/varbinder/declaration.h index 4398773e35519d75d847c32ecd4755b5385d5e70..344bed99b341aa7fd074ca372ac450651ef2e986 100644 --- a/ets2panda/varbinder/declaration.h +++ b/ets2panda/varbinder/declaration.h @@ -20,6 +20,7 @@ #include "util/es2pandaMacros.h" #include "util/diagnosticEngine.h" #include "util/ustring.h" +#include "libarkbase/utils/arena_vector.h" namespace ark::es2panda::ir { class AstNode; diff --git a/ets2panda/varbinder/recordTable.cpp b/ets2panda/varbinder/recordTable.cpp index 6971fd4da368dda3a29bb2a6971890100d899887..df38c689e4889a0a716df46e1fb94b6322575c05 100644 --- a/ets2panda/varbinder/recordTable.cpp +++ b/ets2panda/varbinder/recordTable.cpp @@ -21,7 +21,6 @@ #include "ir/statements/annotationDeclaration.h" #include "ir/ts/tsEnumDeclaration.h" #include "ir/ts/tsInterfaceDeclaration.h" -#include "checker/types/ets/etsObjectType.h" #include "generated/signatures.h" namespace ark::es2panda::varbinder { diff --git a/ets2panda/varbinder/recordTable.h b/ets2panda/varbinder/recordTable.h index ad4df07cffa2efcec240222182bb3d73bb89d84e..3b14c64c8ead8ab15333fe5ef7af8c03103e5d4f 100644 --- a/ets2panda/varbinder/recordTable.h +++ b/ets2panda/varbinder/recordTable.h @@ -16,12 +16,13 @@ #ifndef ES2PANDA_VARBINDER_RECORDTABLE_H #define ES2PANDA_VARBINDER_RECORDTABLE_H +#include "ir/base/scriptFunction.h" + #include "util/es2pandaMacros.h" -#include "libarkbase/utils/arena_containers.h" +#include "libarkbase/utils/arena_set.h" #include "util/ustring.h" #include "util/enumbitops.h" -#include namespace ark::es2panda::parser { class Program; diff --git a/ets2panda/varbinder/scope.cpp b/ets2panda/varbinder/scope.cpp index b911b1ed9d470476cd370b5c599ac0ba7fb7e382..619e944cdc4bda86a730a390ad725f19bcf5a80e 100644 --- a/ets2panda/varbinder/scope.cpp +++ b/ets2panda/varbinder/scope.cpp @@ -19,6 +19,16 @@ #include "varbinder/tsBinding.h" #include "compiler/lowering/util.h" +#include "ir/base/classProperty.h" +#include "ir/base/classElement.h" + +#include "ir/module/exportAllDeclaration.h" +#include "ir/module/exportNamedDeclaration.h" + +#include "ir/ts/tsEnumDeclaration.h" +#include "ir/ts/tsTypeAliasDeclaration.h" +#include "ir/ts/tsInterfaceDeclaration.h" + namespace ark::es2panda::varbinder { VariableScope *Scope::EnclosingVariableScope() noexcept { diff --git a/ets2panda/varbinder/scope.h b/ets2panda/varbinder/scope.h index 7e671e719f56c9e52edea5cba58d5cc7d9e0ea19..e56f1ccf5866a9c9f84af8f3017220178f85077c 100644 --- a/ets2panda/varbinder/scope.h +++ b/ets2panda/varbinder/scope.h @@ -20,6 +20,10 @@ #include "varbinder/declaration.h" #include "varbinder/variable.h" +#include "libarkbase/utils/arena_vector.h" +#include "libarkbase/utils/arena_map.h" +#include "libarkbase/utils/arena_unordered_map.h" + namespace ark::es2panda::public_lib { struct Context; } // namespace ark::es2panda::public_lib diff --git a/ets2panda/varbinder/varbinder.cpp b/ets2panda/varbinder/varbinder.cpp index 73ef1c50e4f1131fe52bf38b672bf29a71ac825e..e250572cb696dfe1af52162db7915ba1163422fd 100644 --- a/ets2panda/varbinder/varbinder.cpp +++ b/ets2panda/varbinder/varbinder.cpp @@ -16,6 +16,31 @@ #include "varbinder.h" #include "public/public.h" +#include "ir/expressions/assignmentExpression.h" +#include "ir/expressions/arrayExpression.h" +#include "ir/expressions/blockExpression.h" +#include "ir/expressions/objectExpression.h" + +#include "ir/statements/doWhileStatement.h" +#include "ir/statements/forInStatement.h" +#include "ir/statements/forOfStatement.h" +#include "ir/statements/forUpdateStatement.h" +#include "ir/statements/variableDeclaration.h" +#include "ir/statements/variableDeclarator.h" +#include "ir/statements/switchStatement.h" +#include "ir/statements/whileStatement.h" + +#include "ir/typeNode.h" +#include "ir/base/catchClause.h" +#include "ir/base/classProperty.h" +#include "ir/base/methodDefinition.h" +#include "ir/base/property.h" +#include "ir/base/spreadElement.h" +#include "ir/base/scriptFunction.h" + +#include "ir/ts/tsTypeAliasDeclaration.h" +#include "ir/ts/tsTypeParameterDeclaration.h" + namespace ark::es2panda::varbinder { void VarBinder::InitTopScope() {