diff --git a/CMakeLists.txt b/CMakeLists.txt index 0906fb7..d20dfc0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,8 +8,10 @@ add_executable(wcc src/wcc.cpp src/include/wxml.h src/wcc/usage.cpp - src/wxml/compiler.cpp + src/wxml/name_allocator.cpp src/wxml/dom_lib/token.cpp + src/wxml/compiler.cpp + src/wxml/dom_lib/wxml_dom.cpp src/wxml/dom_lib/machine.cpp src/wxml/dom_lib/parser.cpp src/utils/string_utils.cpp diff --git a/src/include/wxml.h b/src/include/wxml.h index 73a7a1c..25a3461 100644 --- a/src/include/wxml.h +++ b/src/include/wxml.h @@ -6,9 +6,24 @@ #include #include #include +#include namespace WXML { + class NameAllocator + { + private: + /* data */ + std::string offset_1; // v5 + std::string offset_7; // v4 + public: + std::string ALPAHBET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; + static int ALPAHBETLEN; + NameAllocator(std::string const&,std::string const&); + ~NameAllocator(); + void GetNextName(std::string &); + }; + namespace DOMLib @@ -43,19 +58,6 @@ namespace WXML */ std::string resolvePath(std::string const& path1, std::string const& path2); - class WXMLDom - { - private: - /* data */ - public: - WXMLDom(/* args */); - ~WXMLDom(); - void Error(); - }; - - - void recurseDependencies(WXML::DOMLib::WXMLDom const&,std::string const&,std::set &); - class Token { @@ -82,6 +84,41 @@ namespace WXML }; + class WXMLDom + { + private: + /* data */ + public: + std::string tag; + std::map offset_12; + WXMLDom(/* args */); + ~WXMLDom(); + void Error(); + // void RenderMeAsFunction( + // std::string const&, + // std::string const&, + // std::string&, + // std::string const&, + // std::stringstream &, + // // WXML::NameAllocator *, + // std::string const&, + // std::string const&, + // std::string const&, + // std::string const&, + // std::string const&, + // char, + // std::string const&, + // bool, + // bool, + // uint, + // std::string const& + // ); + bool operator==(std::string tag); + }; + + + void recurseDependencies(WXML::DOMLib::WXMLDom const&,std::string const&,std::set &); + class Parser { private: diff --git a/src/wxml/compiler.cpp b/src/wxml/compiler.cpp index 73d0ba9..656a7b6 100644 --- a/src/wxml/compiler.cpp +++ b/src/wxml/compiler.cpp @@ -312,6 +312,100 @@ namespace WXML{ } return pResult; } + int RenderDefine( + WXML::DOMLib::WXMLDom & a1, + std::string const& a2, + std::map &a3, + std::string& a4, + std::stringstream & a5, + std::map const& a6, + bool a7, + uint a8, + char a9, + std::string const& a10, + std::string const& a11, + std::string const& a12, + std::string const& a13, + std::string const& a14, + std::string const& a15, + std::string const& a16, + std::string const& a17, + std::string const& a18, + std::string const& a19, + std::string const& a20 + ) + { + try + { + if (a1 == "template") + { + auto it = a1.offset_12.find("name"); + if (it != a1.offset_12.end()) + { + a1.tag.replace(0, a1.tag.size(), "wx-define", 9u); + } + } + if (a1 == "wx-define") + { + auto token = a1.offset_12["name"]; + auto attr = token.ToAttrContent(); + a3[attr].assign(a2); + // WXML::DOMLib::WXMLDom::RenderMeAsFunction( + // a1, + // (int *)a2, + // a14, + // a4, + // (int *)v31, + // a5, + // (int *)v33, + // a10, + // a11, + // a12, + // (int *)v32, // "r" + // a15, + // a9, + // a16, + // 1, + // a7, + // a8, + // a20); + + } + for (int i = 0; i < 6; i++) + { + /* code */ + // WXML::Compiler::RenderDefine( + // v23 + 8 * i, + // a2, + // a3, + // a4, + // a5, + // a6, + // a7, + // a8, + // a9, + // a10, + // a11, + // a12, + // a13, + // a14, + // a15, + // a16, + // a17, + // a18, + // a19, + // a20); + } + + + } + catch(const std::exception& e) + { + std::cerr << e.what() << '\n'; + } + return 0; + + } void WXMLHelperCode(std::string &result) { result.assign(aIfThisThisGUnd); diff --git a/src/wxml/dom_lib/token.cpp b/src/wxml/dom_lib/token.cpp index 141439a..ac5eb6f 100644 --- a/src/wxml/dom_lib/token.cpp +++ b/src/wxml/dom_lib/token.cpp @@ -20,8 +20,12 @@ namespace WXML Token::~Token() { } - - bool IsMatch(char const&) + std::string Token::ToAttrContent() + { + return ""; + } + + bool Token::IsMatch(char const&) { return true; } diff --git a/src/wxml/dom_lib/wxml_dom.cpp b/src/wxml/dom_lib/wxml_dom.cpp index 9e3bcb5..dd86bf9 100644 --- a/src/wxml/dom_lib/wxml_dom.cpp +++ b/src/wxml/dom_lib/wxml_dom.cpp @@ -14,5 +14,9 @@ namespace WXML { WXMLDom::~WXMLDom() { } + bool WXMLDom::operator==(std::string tag) + { + return this->tag.compare(tag) == 0; + } } } \ No newline at end of file diff --git a/src/wxml/name_allocator.cpp b/src/wxml/name_allocator.cpp index 9d98202..03f67d0 100644 --- a/src/wxml/name_allocator.cpp +++ b/src/wxml/name_allocator.cpp @@ -1,4 +1,18 @@ #include "../include/wxml.h" namespace WXML { + int NameAllocator::ALPAHBETLEN = 0; + NameAllocator::NameAllocator(std::string const& a2,std::string const&a3) + { + if (NameAllocator::ALPAHBETLEN == 0) + { + NameAllocator::ALPAHBETLEN = NameAllocator::ALPAHBET.size(); + } + this->offset_1.assign(a2); + this->offset_7.assign(a3); + } + + NameAllocator::~NameAllocator() + { + } } \ No newline at end of file diff --git a/test/wcc.disassembly.cpp b/test/wcc.disassembly.cpp index 6bae365..581e5b6 100644 --- a/test/wcc.disassembly.cpp +++ b/test/wcc.disassembly.cpp @@ -11131,7 +11131,7 @@ struct _Unwind_Exception *__cdecl WXML::Compiler::RenderDefine( a10, a11, a12, - (int *)v32, + (int *)v32, // "r" a15, a9, a16,