diff --git a/es2panda/compiler/core/emitter/commonjs.cpp b/es2panda/compiler/core/emitter/commonjs.cpp index a623269fa60c942a4f52cc62aab46c2aab1081c7..aa4a5ce538a9d2ecb9c2f2af5364984785be5f45 100644 --- a/es2panda/compiler/core/emitter/commonjs.cpp +++ b/es2panda/compiler/core/emitter/commonjs.cpp @@ -20,7 +20,7 @@ namespace panda::es2panda::compiler { constexpr const auto LANG_EXT = panda::pandasm::extensions::Language::ECMASCRIPT; -void Emitter::GenCommonjsRecord() +void Emitter::GenCommonjsRecord() const { auto commonjsRecord = panda::pandasm::Record("_CommonJsRecord", LANG_EXT); commonjsRecord.metadata->SetAccessFlags(panda::ACC_PUBLIC); diff --git a/es2panda/compiler/core/emitter/emitter.h b/es2panda/compiler/core/emitter/emitter.h index add3a5ec0b916b92ded73a2d2bb9fa071b7e661b..8c7a865f88ff7ccd4a4dab5b06af3d7f9a38cde0 100644 --- a/es2panda/compiler/core/emitter/emitter.h +++ b/es2panda/compiler/core/emitter/emitter.h @@ -106,7 +106,7 @@ public: private: void GenESAnnoatationRecord(); - void GenCommonjsRecord(); + void GenCommonjsRecord() const; std::mutex m_; panda::pandasm::Program *prog_; diff --git a/es2panda/compiler/core/emitter/moduleRecordEmitter.cpp b/es2panda/compiler/core/emitter/moduleRecordEmitter.cpp index cd635669ffc2b3145ec14974e3429438540de9ab..60dcee6e6b63e708ad2a9fe87514124c1fa2269e 100644 --- a/es2panda/compiler/core/emitter/moduleRecordEmitter.cpp +++ b/es2panda/compiler/core/emitter/moduleRecordEmitter.cpp @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/es2panda/compiler/core/emitter/moduleRecordEmitter.h b/es2panda/compiler/core/emitter/moduleRecordEmitter.h index 7aadbd1ae5dff387a3565d748c9a064e52152aaa..1aac490b91b33303211eaa911bd1cf6045d6efb9 100644 --- a/es2panda/compiler/core/emitter/moduleRecordEmitter.h +++ b/es2panda/compiler/core/emitter/moduleRecordEmitter.h @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2021-2022 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. diff --git a/es2panda/lexer/keywordsUtil.cpp b/es2panda/lexer/keywordsUtil.cpp index 452a122f82fbad5947d1bb8963524b6922849ff5..f939f10c57a3653b2afab759baf7e3b88d2e91b6 100644 --- a/es2panda/lexer/keywordsUtil.cpp +++ b/es2panda/lexer/keywordsUtil.cpp @@ -261,7 +261,7 @@ void KeywordsUtil::ScanIdContinueMaybeKeyword(Span map) const auto &str = lexer_->GetToken().Ident().Utf8(); int start = 0; - int end = map.size(); + int end = static_cast(map.size()); int middle = end / 2; while (true) { diff --git a/es2panda/parser/commonjs.cpp b/es2panda/parser/commonjs.cpp index 0f41609e7a47ef02c4c86fb2a86243200155fcba..110c378c269c441ae10c7a4b9ffb785e3e4466d3 100644 --- a/es2panda/parser/commonjs.cpp +++ b/es2panda/parser/commonjs.cpp @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/es2panda/parser/module/sourceTextModuleRecord.cpp b/es2panda/parser/module/sourceTextModuleRecord.cpp index 6a25328bcc451ef87d5ceb337760eb5fccf653b1..d6af0a9399a9cc2952104eb6c6119b2cc56b5935 100644 --- a/es2panda/parser/module/sourceTextModuleRecord.cpp +++ b/es2panda/parser/module/sourceTextModuleRecord.cpp @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/es2panda/parser/module/sourceTextModuleRecord.h b/es2panda/parser/module/sourceTextModuleRecord.h index f4a52bf09d8216af3dde73c1d3ba1590e33ce347..8b15e3d975cff23650744f54a746fc9154c10562 100644 --- a/es2panda/parser/module/sourceTextModuleRecord.h +++ b/es2panda/parser/module/sourceTextModuleRecord.h @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/es2panda/scripts/generate_js_bytecode.py b/es2panda/scripts/generate_js_bytecode.py index 6b191694f2ea3e1bb1602513b056c8a328cec8a8..f53c7dd2ad81ba8470a8fc18f2aeb6e7b490a8b0 100755 --- a/es2panda/scripts/generate_js_bytecode.py +++ b/es2panda/scripts/generate_js_bytecode.py @@ -27,11 +27,11 @@ import argparse def parse_args(): parser = argparse.ArgumentParser() parser.add_argument('--src-js', - help = 'js source file') + help='js source file') parser.add_argument('--dst-file', - help = 'the converted target file') + help='the converted target file') parser.add_argument('--frontend-tool-path', - help = 'path of the frontend conversion tool') + help='path of the frontend conversion tool') parser.add_argument("--debug", action='store_true', help='whether add debuginfo') parser.add_argument("--module", action='store_true', diff --git a/es2panda/util/base64.cpp b/es2panda/util/base64.cpp index fc9e2caa1a6930c56301f2e272d02390e60a88de..2e691df23482a80963060715f7af1b2e1ad927d1 100644 --- a/es2panda/util/base64.cpp +++ b/es2panda/util/base64.cpp @@ -16,7 +16,6 @@ #include "base64.h" namespace panda::es2panda::util { - std::string Base64Encode(const std::string &inputString) { size_t strLen = inputString.length(); @@ -37,8 +36,7 @@ std::string Base64Encode(const std::string &inputString) // 00 + the last 6 bits of the third char encodedRes[i + 3] = base64CharSet[inputString[j + 2] & 0x3f]; } - switch (strLen % TO_TRANSFORM_CHAR_NUM) - { + switch (strLen % TO_TRANSFORM_CHAR_NUM) { case 1: encodedRes[encodedRes.length() - 2] = '='; encodedRes[encodedRes.length() - 1] = '='; @@ -91,7 +89,7 @@ std::string Base64Decode(const std::string &base64String) } // the last 6 bit of the first char + the 2~3 bit of the second char(first 4 bit - 00) decodedRes[j] = (firstChar << 2) | (secondChar >> 4); - if (j == decodedStrLen-1) { + if (j == decodedStrLen - 1) { break; } if (thirdChar == -1) { @@ -99,7 +97,7 @@ std::string Base64Decode(const std::string &base64String) } // the last 4 bit of the second char + the 2~5 bit of the third char(first 6 bit - 00) decodedRes[j + 1] = (secondChar << 4) | (thirdChar >> 2); - if (j + 1 == decodedStrLen-1) { + if (j + 1 == decodedStrLen - 1) { break; } if (fourthChar == -1) { @@ -110,5 +108,4 @@ std::string Base64Decode(const std::string &base64String) } return decodedRes; } - } // namespace panda::es2panda::util diff --git a/test262/utils.py b/test262/utils.py index f14e213fb36fe978a985dba859092b4c6c0adfd8..fed304f1f61ff0a3071f1e7d7f88fcbcf56d6407 100755 --- a/test262/utils.py +++ b/test262/utils.py @@ -159,12 +159,14 @@ def npm_install(cwd): ret = run_cmd_cwd(cmd, cwd) assert not ret, f"\n error: Failed to 'npm install'" + def search_dependency(file, directory): for root, dirs, files in os.walk(directory, topdown=True): for f in files: if f == file: return os.path.join(root, f) + def collect_module_dependencies(file, directory, traversedDependencies): dependencies = [] traversedDependencies.append(file) diff --git a/ts2panda/ts2abc/ts2abc.cpp b/ts2panda/ts2abc/ts2abc.cpp index 3fcd81f41c322774e8cb30315ba17d7bfd9a0dff..2af75f296740f6861ff439e645e6eb8b77d18761 100644 --- a/ts2panda/ts2abc/ts2abc.cpp +++ b/ts2panda/ts2abc/ts2abc.cpp @@ -782,7 +782,6 @@ static panda::pandasm::Function ParseFunction(const Json::Value &function) pandaFunc.metadata->SetAttribute("external"); } - return pandaFunc; } diff --git a/ts2panda/ts2abc/type_adapter.h b/ts2panda/ts2abc/type_adapter.h index 440f9771299872d30964447a50d4c68824dcade7..35a8ea423dea4d63eb7b6192c5c4ada8f21a4271 100644 --- a/ts2panda/ts2abc/type_adapter.h +++ b/ts2panda/ts2abc/type_adapter.h @@ -20,9 +20,7 @@ #include "assembler/assembly-function.h" namespace ts2abc_type_adapter { - const int builtinTypeOffset = 21; - const std::vector builtinTypes { "Function", "RangeError",