From 53d8ceacf09ba20ff915e39a08772bf043b572dc Mon Sep 17 00:00:00 2001 From: msojocs Date: Mon, 21 Aug 2023 22:26:05 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=B8=80=E4=BA=9B=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/include/wxss.h | 11 ++++++----- src/wcsc.cpp | 4 ++-- src/wxss/css_tree_lib/css_syntax_tree.cpp | 17 +++++++++++++++++ src/wxss/css_tree_lib/lexical_checker.cpp | 6 +++++- src/wxss/token.cpp | 2 +- src/wxss/x_compiler.cpp | 6 +++--- test/wcsc.disassembly.cpp | 2 +- test/wcsc.sh | 16 ++++++++++++++++ 8 files changed, 51 insertions(+), 13 deletions(-) create mode 100644 test/wcsc.sh diff --git a/src/include/wxss.h b/src/include/wxss.h index 8861ff8..e7f3400 100644 --- a/src/include/wxss.h +++ b/src/include/wxss.h @@ -27,7 +27,7 @@ namespace WXSS size: 92字节 */ public: - int offset_0 = 0; + int offset_0 = 1; std::shared_ptr offset_4; int offset_12 = 0; int offset_16 = 0; @@ -130,20 +130,21 @@ namespace WXSS public: std::string offset_0; WXSS::Token offset_24; - int offset_116; // 类型未确定 + int offset_116 = 1; // 类型未确定 std::vector> offset_120; std::shared_ptr offset_132; // 类型未确定,不是布尔值 std::shared_ptr offset_140; std::shared_ptr offset_148; std::shared_ptr offset_156; - int offset_164; - int offset_168; - int offset_172; // 类型未确定 + int offset_164 = 0; + int offset_168 = 0; + int offset_172 = 0; // 类型未确定 CSSSyntaxTree(/* args */); ~CSSSyntaxTree(); void GetHostRule(std::string &); void Print2Stream(int, std::stringstream &); void RenderCode(std::string &,bool); + CSSSyntaxTree& operator=(CSSSyntaxTree&); }; class Rule { diff --git a/src/wcsc.cpp b/src/wcsc.cpp index d9e9e66..0ff4a00 100644 --- a/src/wcsc.cpp +++ b/src/wcsc.cpp @@ -65,7 +65,7 @@ int main(int argc, const char **argv) { bool v36 = false; bool v37 = false; std::string fileName; - std::string v76; + std::string v76 = "./app.wxss"; for (int i = 0; i < v69.size(); i++) { std::string cur = v69[i]; if (cur[0] != '-') @@ -175,7 +175,7 @@ int main(int argc, const char **argv) { v101.append("./", 2); v101.append(v69[i + 1]); // TODO... 待检验 - v76 = v101; + v76 = v101.append("/app.wxss"); } } // main - 20 diff --git a/src/wxss/css_tree_lib/css_syntax_tree.cpp b/src/wxss/css_tree_lib/css_syntax_tree.cpp index 495ee1e..a0fc94b 100644 --- a/src/wxss/css_tree_lib/css_syntax_tree.cpp +++ b/src/wxss/css_tree_lib/css_syntax_tree.cpp @@ -8,6 +8,7 @@ namespace WXSS { CSSSyntaxTree::CSSSyntaxTree(/* args */) { + this->offset_24.offset_0 = 1; } CSSSyntaxTree::~CSSSyntaxTree() @@ -140,6 +141,22 @@ namespace WXSS } } + + CSSSyntaxTree& CSSSyntaxTree::operator=(CSSSyntaxTree& old) + { + this->offset_0 = old.offset_0; + this->offset_24 = old.offset_24; + this->offset_116 = old.offset_116; + this->offset_120 = old.offset_120; + this->offset_132 = old.offset_132; + this->offset_140 = old.offset_140; + this->offset_148 = old.offset_148; + this->offset_156 = old.offset_156; + this->offset_164 = old.offset_164; + this->offset_168 = old.offset_168; + this->offset_172 = old.offset_172; + return *this; + } } } // namespace WXSS \ No newline at end of file diff --git a/src/wxss/css_tree_lib/lexical_checker.cpp b/src/wxss/css_tree_lib/lexical_checker.cpp index bd0f391..342e998 100644 --- a/src/wxss/css_tree_lib/lexical_checker.cpp +++ b/src/wxss/css_tree_lib/lexical_checker.cpp @@ -252,6 +252,10 @@ namespace WXSS } return 0; } + int off_519B00(std::shared_ptr& a1, std::shared_ptr &a2) + { + throw "not implement"; + } int off_519B40(std::shared_ptr& a1, std::shared_ptr &a2) { // WXSS::CSSTreeLib::AndRules::MarkGood @@ -402,7 +406,7 @@ namespace WXSS v69->offset_4_vecPair.emplace_back("SELECTOR", v77); std::shared_ptr v79(new WXSS::CSSTreeLib::Rule()); - v79->offset_0 = off_519B84; + v79->offset_0 = off_519B00; v77->offset_4_vecPair.emplace_back("$NAME", v79); // Init - 30 std::shared_ptr v81(new WXSS::CSSTreeLib::Rule()); diff --git a/src/wxss/token.cpp b/src/wxss/token.cpp index 536e052..3009153 100644 --- a/src/wxss/token.cpp +++ b/src/wxss/token.cpp @@ -23,7 +23,7 @@ namespace WXSS result = "UNKNOWN"; if (this->offset_4.get()) { - return *this->offset_4.get(); + return *this->offset_4; } } return result; diff --git a/src/wxss/x_compiler.cpp b/src/wxss/x_compiler.cpp index 3935e30..4a5548d 100644 --- a/src/wxss/x_compiler.cpp +++ b/src/wxss/x_compiler.cpp @@ -84,8 +84,8 @@ namespace WXSS } } std::string v74 = v42; - std::shared_ptr v75(new WXSS::CSSTreeLib::CSSSyntaxTree()); - this->offset_32[v74] = v75; + + this->offset_32[v74] = v29.offset_0; } } // end for @@ -502,7 +502,7 @@ namespace WXSS this->offset_152[j->first] = j->first; } } - for (auto k = this->offset_32.rbegin(); k != this->offset_32.rend(); k++) + for (auto k = this->offset_32.begin(); k != this->offset_32.end(); k++) { if (this->offset_128[k->first] > 1) { diff --git a/test/wcsc.disassembly.cpp b/test/wcsc.disassembly.cpp index 382e9eb..3682979 100644 --- a/test/wcsc.disassembly.cpp +++ b/test/wcsc.disassembly.cpp @@ -45132,7 +45132,7 @@ int __fastcall WXSS::CSSTreeLib::CSSSyntaxTree::CSSSyntaxTree(int a1) *(_DWORD *)(a1 + 28) = 0; *(_DWORD *)(a1 + 32) = 0; *(_BYTE *)(a1 + 52) = 0; - *(_DWORD *)(a1 + 24) = 1; + *(_DWORD *)(a1 + 24) = 1; // this->offset_24 *(_DWORD *)(a1 + 36) = 0; *(_DWORD *)(a1 + 40) = 0; *(_DWORD *)(a1 + 44) = 0; diff --git a/test/wcsc.sh b/test/wcsc.sh new file mode 100644 index 0000000..38cd699 --- /dev/null +++ b/test/wcsc.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +root_dir=$(cd `dirname $0`/.. && pwd -P) + +cd /mnt/d/Work/WeChatProjects/miniprogram-demo/miniprogram + +# list="cmd1 cmd2" +# for cmd in $list; +# do +# echo $cmd +# /root/github/wx-compiler/build/wcc "--config-path" "/mnt/d/Work/disassembly/wcc-exec/wcc/config/$cmd.txt" > /root/github/wx-compiler/test/wcc_linux.json +# /mnt/d/Work/disassembly/wcc-exec/wcc/wcc.exe "--config-path" "d:/Work/disassembly/wcc-exec/wcc/config/$cmd.txt" > /root/github/wx-compiler/test/wcc_win.json +# done; +filename="ll1.txt" +/root/github/wx-compiler/build/wcsc "--config-path" "/mnt/d/Work/disassembly/wcc-exec/wcsc/config/$filename" > /root/github/wx-compiler/test/wcsc_linux.json +/mnt/d/Work/disassembly/wcc-exec/wcsc/wcsc.exe "--config-path" "d:/Work/disassembly/wcc-exec/wcsc/config/$filename" > /root/github/wx-compiler/test/wcsc_win.json