From 6cc8f789b83930a43e3eecd8de1917f165c77b34 Mon Sep 17 00:00:00 2001 From: jiangkaiwen Date: Mon, 22 Aug 2022 14:30:37 +0800 Subject: [PATCH] fixed eba97c1 from https://gitee.com/jiangkaiwen678217/ark_ts2abc/pulls/452 Fix codecheck warnings 1. Header comments 2. Blank space and blank line questions 3. Const modifies member functions and member variables 4. Python programming specification Issue: #I5NFLA Signed-off-by: jiangkaiwen Change-Id: Ie190f044ea8ddae0e46d3f40cd531ebabf87915d --- es2panda/compiler/core/emitter/commonjs.cpp | 2 +- es2panda/compiler/core/emitter/emitter.h | 2 +- es2panda/compiler/core/emitter/moduleRecordEmitter.cpp | 2 +- es2panda/compiler/core/emitter/moduleRecordEmitter.h | 2 +- es2panda/lexer/keywordsUtil.cpp | 2 +- es2panda/parser/commonjs.cpp | 2 +- es2panda/parser/module/sourceTextModuleRecord.cpp | 2 +- es2panda/parser/module/sourceTextModuleRecord.h | 2 +- es2panda/scripts/generate_js_bytecode.py | 6 +++--- es2panda/util/base64.cpp | 9 +++------ test262/utils.py | 2 ++ ts2panda/ts2abc/ts2abc.cpp | 1 - ts2panda/ts2abc/type_adapter.h | 2 -- 13 files changed, 16 insertions(+), 20 deletions(-) diff --git a/es2panda/compiler/core/emitter/commonjs.cpp b/es2panda/compiler/core/emitter/commonjs.cpp index a623269fa6..aa4a5ce538 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 add3a5ec0b..8c7a865f88 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 cd635669ff..60dcee6e6b 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 7aadbd1ae5..1aac490b91 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 452a122f82..f939f10c57 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 0f41609e7a..110c378c26 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 6a25328bcc..d6af0a9399 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 f4a52bf09d..8b15e3d975 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 6b191694f2..f53c7dd2ad 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 fc9e2caa1a..2e691df234 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 f14e213fb3..fed304f1f6 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 3fcd81f41c..2af75f2967 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 440f977129..35a8ea423d 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", -- Gitee