From 169a587180694c62629ddcfededf396fd891afa5 Mon Sep 17 00:00:00 2001 From: liutao Date: Mon, 6 Jul 2020 21:45:52 +0800 Subject: [PATCH 1/5] finish mem leak fixing --- compiler/main.cpp | 1 + interpreter/main.cpp | 2 ++ parser/ast_token.h | 6 ++---- parser/parser.cpp | 2 -- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/compiler/main.cpp b/compiler/main.cpp index 77e7213..8b872b8 100644 --- a/compiler/main.cpp +++ b/compiler/main.cpp @@ -53,5 +53,6 @@ int main(int argc, char **argv) assembler.do_assemble(); assembler.print_instruction_buf(); + free(buf); return 0; } \ No newline at end of file diff --git a/interpreter/main.cpp b/interpreter/main.cpp index b5295d9..a16beae 100644 --- a/interpreter/main.cpp +++ b/interpreter/main.cpp @@ -31,5 +31,7 @@ int main(int argc, char **argv) simple_interpreter::Interpreter interpreter(parser); interpreter.interprete(); + + free(buf); return 0; } \ No newline at end of file diff --git a/parser/ast_token.h b/parser/ast_token.h index e6335fd..6574971 100644 --- a/parser/ast_token.h +++ b/parser/ast_token.h @@ -164,13 +164,11 @@ class ParentAstToken : public PreAndInfixAstToken { AstToken* led(AstToken* left) { assert(left->peek_type() == IDENTIFIER); child_list.push_back(left); - for (AstToken *token = parser_instance.get_current_token(); - token->peek_value() != ")";) { + while (parser_instance.peek_current_value() != ")") { child_list.push_back(parser_instance.expression(0)); - if (parser_instance.get_current_token()->peek_value() == ")") + if (parser_instance.peek_current_value() == ")") break; parser_instance.advance(","); - token = parser_instance.get_current_token(); } parser_instance.advance(")"); this->set_type(FUNCTION); diff --git a/parser/parser.cpp b/parser/parser.cpp index a75e7b0..52f6d51 100644 --- a/parser/parser.cpp +++ b/parser/parser.cpp @@ -27,7 +27,6 @@ simple_lexser::token_type Parser::peek_current_type() { } AstToken *Parser::get_current_token() { - cout << "\" " << lexser.get_token_by_index(current_lex_index).value << " \"" << endl; return TokenConventor::convert(lexser.get_token_by_index(current_lex_index), *this); } @@ -125,7 +124,6 @@ void Parser::delete_tree(AstToken* root) { delete_tree(*it); it = root->child_list.erase(it); } - cout << "< " << root->peek_value() << " >" << endl; delete(root); root = nullptr; } From a24fced1bd5b46c4549d7bfecd07471038df7368 Mon Sep 17 00:00:00 2001 From: liutgnu Date: Wed, 30 Sep 2020 10:14:14 +0800 Subject: [PATCH 2/5] Create codeql-analysis.yml --- .github/workflows/codeql-analysis.yml | 69 +++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 .github/workflows/codeql-analysis.yml diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 0000000..c2fc2c6 --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,69 @@ +name: "CodeQL" + +on: + push: + branches: [master] + pull_request: + # The branches below must be a subset of the branches above + branches: [master] + schedule: + - cron: '0 16 * * 1' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + # Override automatic language detection by changing the below list + # Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python'] + language: ['cpp'] + # Learn more... + # https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + # We must fetch at least the immediate parents so that if this is + # a pull request then we can checkout the head. + fetch-depth: 2 + + # If this run was triggered by a pull request event, then checkout + # the head of the pull request instead of the merge commit. + - run: git checkout HEAD^2 + if: ${{ github.event_name == 'pull_request' }} + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + # queries: ./path/to/local/query, your-org/your-repo/queries@main + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v1 + + # â„šī¸ Command-line programs to run using the OS shell. + # 📚 https://git.io/JvXDl + + # âœī¸ If the Autobuild fails above, remove it and uncomment the following three lines + # and modify them (or add more) to build your code if your project + # uses a compiled language + + - run: | + cd lexser && make intergrate && cd ~- + cd parser && make intergrate && cd ~- + cd interpreter && make intergrate && cd ~- + cd compiler && make intergrate && cd ~- + cd vm && make intergrate && cd ~- + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 From dca5a5087680785b976666bfad8aab4a8b93f840 Mon Sep 17 00:00:00 2001 From: liutgnu Date: Wed, 30 Sep 2020 10:33:04 +0800 Subject: [PATCH 3/5] Update codeql-analysis.yml remove auto build step --- .github/workflows/codeql-analysis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index c2fc2c6..be684a9 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -48,8 +48,8 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v1 + # - name: Autobuild + # uses: github/codeql-action/autobuild@v1 # â„šī¸ Command-line programs to run using the OS shell. # 📚 https://git.io/JvXDl From 524c8b02cf544657904749d530119dac2c7f6b8f Mon Sep 17 00:00:00 2001 From: liutgnu Date: Wed, 30 Sep 2020 15:05:31 +0800 Subject: [PATCH 4/5] Update codeql-analysis.yml add more queries --- .github/workflows/codeql-analysis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index be684a9..2d3544b 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -44,7 +44,7 @@ jobs: # If you wish to specify custom queries, you can do so here or in a config file. # By default, queries listed here will override any specified in a config file. # Prefix the list here with "+" to use these queries and those in the config file. - # queries: ./path/to/local/query, your-org/your-repo/queries@main + queries: security-extended, security-and-quality, cpp-lgtm # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) From 9fe5f9b46ab533bd7f59b4821b3e80e8756ae16a Mon Sep 17 00:00:00 2001 From: liutgnu Date: Wed, 30 Sep 2020 15:09:21 +0800 Subject: [PATCH 5/5] Update codeql-analysis.yml remove cpp-lgtm query, not supported --- .github/workflows/codeql-analysis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 2d3544b..ad366f6 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -44,7 +44,7 @@ jobs: # If you wish to specify custom queries, you can do so here or in a config file. # By default, queries listed here will override any specified in a config file. # Prefix the list here with "+" to use these queries and those in the config file. - queries: security-extended, security-and-quality, cpp-lgtm + queries: security-extended, security-and-quality # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below)