From e997a09c6c5dbaa65416050b41e18eea4c6cbfb1 Mon Sep 17 00:00:00 2001 From: Eugene Dar Date: Mon, 28 Nov 2022 23:49:28 +0300 Subject: [PATCH 1/6] copy flag implemented --- .gitignore | 4 +-- project/scripts/download_resources.sh | 3 +++ project/src/transpiler/main.cpp | 39 +++++++++++++++++++-------- 3 files changed, 33 insertions(+), 13 deletions(-) create mode 100644 project/scripts/download_resources.sh diff --git a/.gitignore b/.gitignore index 0ea3ca0f..56579fb5 100644 --- a/.gitignore +++ b/.gitignore @@ -47,8 +47,8 @@ llvm-clang/** **/.idea/** **/cmake-build-debug/** **/CMakeFiles/** -**/build/** -!**/build/.gitkeep +build/** +!build/.gitkeep **/src/result/** *.bak diff --git a/project/scripts/download_resources.sh b/project/scripts/download_resources.sh new file mode 100644 index 00000000..7189574e --- /dev/null +++ b/project/scripts/download_resources.sh @@ -0,0 +1,3 @@ +#wget "https://github.com/polystat/c2eo/tree/master/project/eo-lib" +echo copy eo-lib to "$1" +cp -r ./../eo-lib/ "$1" \ No newline at end of file diff --git a/project/src/transpiler/main.cpp b/project/src/transpiler/main.cpp index 3f9753b5..9859d721 100644 --- a/project/src/transpiler/main.cpp +++ b/project/src/transpiler/main.cpp @@ -24,6 +24,8 @@ #include #include +#include +#include #include "src/transpiler/eo_object.h" #include "src/transpiler/matchers.h" @@ -102,29 +104,44 @@ int main(int argc, const char **argv) { const char **parser_argv = TransformArgv(argv); filename = argv[2]; - if (argc == 4) { - if (std::string("--meta") != argv[3]) { - llvm::errs() - << "exception: incorrect command line format. Necessary: c2eo " - " [--meta]\n"; - return -1; - } - transpiler.GenerateMeta(); - } - package_name = filename.substr(0, filename.size() - 3); if (package_name.rfind('/') != std::string::npos) { package_name = package_name.substr(package_name.rfind('/') + 1); } transpiler.SetPackageName(package_name); - std::string path_name; + std::string path_name = ""; auto pos = filename.rfind('/'); if (pos != std::string::npos) { path_name = filename.substr(0, pos + 1); } transpiler.SetPathName(path_name); + if (argc == 4) { + if (std::string("--copy") == argv[3]) { + auto path = path_name; + if (path == "") { + path = "."; + } + + int sz = path.length(); + + char dest[40 + sz] = "bash ./../scripts/download_resources.sh "; + for (int i = 0;i < sz;++i) { + dest[40 + i] = path[i]; + } + + // run download_resources.sh with argument 'path' + int status = system(dest); + } else if (std::string("--meta") != argv[3]) { + llvm::errs() + << "exception: incorrect command line format. Necessary: c2eo " + " [--meta]\n"; + return -1; + } + transpiler.GenerateMeta(); + } + int parser_argc = parser_arg_count; auto expected_parser = CommonOptionsParser::create( parser_argc, parser_argv, MyToolCategory, llvm::cl::Optional); From 0e08d5c791e2ac3f95e1ab8bef7f0d146057d486 Mon Sep 17 00:00:00 2001 From: Eugene Dar Date: Mon, 9 Jan 2023 21:48:55 +0300 Subject: [PATCH 2/6] downloading puzzle created --- project/scripts/download_resources.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/project/scripts/download_resources.sh b/project/scripts/download_resources.sh index 7189574e..25476f60 100644 --- a/project/scripts/download_resources.sh +++ b/project/scripts/download_resources.sh @@ -1,3 +1,9 @@ #wget "https://github.com/polystat/c2eo/tree/master/project/eo-lib" echo copy eo-lib to "$1" -cp -r ./../eo-lib/ "$1" \ No newline at end of file +cp -r ./../eo-lib/ "$1" + +# @todo #1049:30min In this implementation, we simply +# copy the current implementation, which lies at the +# relative address locally. We have to download the +# current version from the repository. The address +# is given above in the comment. \ No newline at end of file From 9b1b389c113f1f9f0f034731125c6d8d10589c4d Mon Sep 17 00:00:00 2001 From: Eugene Dar Date: Wed, 11 Jan 2023 14:24:42 +0300 Subject: [PATCH 3/6] includes moved --- project/src/transpiler/main.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/project/src/transpiler/main.cpp b/project/src/transpiler/main.cpp index 9859d721..81bfab3b 100644 --- a/project/src/transpiler/main.cpp +++ b/project/src/transpiler/main.cpp @@ -22,10 +22,11 @@ * SOFTWARE. */ -#include -#include #include #include +#include +#include + #include "src/transpiler/eo_object.h" #include "src/transpiler/matchers.h" From 8cdf546560e8a26dc973e811e35b8816fda1e7c0 Mon Sep 17 00:00:00 2001 From: Eugene Dar Date: Wed, 11 Jan 2023 14:26:18 +0300 Subject: [PATCH 4/6] space removed --- project/src/transpiler/main.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/project/src/transpiler/main.cpp b/project/src/transpiler/main.cpp index 81bfab3b..cfc3648c 100644 --- a/project/src/transpiler/main.cpp +++ b/project/src/transpiler/main.cpp @@ -27,7 +27,6 @@ #include #include - #include "src/transpiler/eo_object.h" #include "src/transpiler/matchers.h" #include "src/transpiler/unit_transpiler.h" From 4e8840294130a8f786bfd698ec7e3feb3471ba47 Mon Sep 17 00:00:00 2001 From: Eugene Dar Date: Wed, 11 Jan 2023 14:29:29 +0300 Subject: [PATCH 5/6] tabs changed to spaces --- project/src/transpiler/main.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/project/src/transpiler/main.cpp b/project/src/transpiler/main.cpp index cfc3648c..52a1e2b2 100644 --- a/project/src/transpiler/main.cpp +++ b/project/src/transpiler/main.cpp @@ -126,12 +126,12 @@ int main(int argc, const char **argv) { int sz = path.length(); - char dest[40 + sz] = "bash ./../scripts/download_resources.sh "; - for (int i = 0;i < sz;++i) { - dest[40 + i] = path[i]; - } + char dest[40 + sz] = "bash ./../scripts/download_resources.sh "; + for (int i = 0; i < sz; ++i) { + dest[40 + i] = path[i]; + } - // run download_resources.sh with argument 'path' + // run download_resources.sh with argument 'path' int status = system(dest); } else if (std::string("--meta") != argv[3]) { llvm::errs() From bd3a97793fea412fb24c0e0b46c754df48ce80f3 Mon Sep 17 00:00:00 2001 From: Eugene Dar Date: Wed, 11 Jan 2023 14:33:00 +0300 Subject: [PATCH 6/6] clang formatted --- project/src/transpiler/main.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/project/src/transpiler/main.cpp b/project/src/transpiler/main.cpp index 52a1e2b2..54ec72c5 100644 --- a/project/src/transpiler/main.cpp +++ b/project/src/transpiler/main.cpp @@ -24,6 +24,7 @@ #include #include + #include #include @@ -126,12 +127,12 @@ int main(int argc, const char **argv) { int sz = path.length(); - char dest[40 + sz] = "bash ./../scripts/download_resources.sh "; - for (int i = 0; i < sz; ++i) { - dest[40 + i] = path[i]; - } + char dest[40 + sz] = "bash ./../scripts/download_resources.sh "; + for (int i = 0; i < sz; ++i) { + dest[40 + i] = path[i]; + } - // run download_resources.sh with argument 'path' + // run download_resources.sh with argument 'path' int status = system(dest); } else if (std::string("--meta") != argv[3]) { llvm::errs()