feat: 增加部分函数

This commit is contained in:
msojocs 2023-06-12 22:30:42 +08:00
parent fd6789dd7c
commit e726f77afa
7 changed files with 172 additions and 17 deletions

View File

@ -8,8 +8,10 @@ add_executable(wcc
src/wcc.cpp src/wcc.cpp
src/include/wxml.h src/include/wxml.h
src/wcc/usage.cpp src/wcc/usage.cpp
src/wxml/compiler.cpp src/wxml/name_allocator.cpp
src/wxml/dom_lib/token.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/machine.cpp
src/wxml/dom_lib/parser.cpp src/wxml/dom_lib/parser.cpp
src/utils/string_utils.cpp src/utils/string_utils.cpp

View File

@ -6,9 +6,24 @@
#include <map> #include <map>
#include <set> #include <set>
#include <vector> #include <vector>
#include <cstring>
namespace WXML 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 namespace DOMLib
@ -43,19 +58,6 @@ namespace WXML
*/ */
std::string resolvePath(std::string const& path1, std::string const& path2); 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<std::string> &);
class Token class Token
{ {
@ -82,6 +84,41 @@ namespace WXML
}; };
class WXMLDom
{
private:
/* data */
public:
std::string tag;
std::map<std::string, WXML::DOMLib::Token> 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<std::string> &);
class Parser class Parser
{ {
private: private:

View File

@ -312,6 +312,100 @@ namespace WXML{
} }
return pResult; return pResult;
} }
int RenderDefine(
WXML::DOMLib::WXMLDom & a1,
std::string const& a2,
std::map<std::string,std::string> &a3,
std::string& a4,
std::stringstream & a5,
std::map<std::string,std::string> 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) void WXMLHelperCode(std::string &result)
{ {
result.assign(aIfThisThisGUnd); result.assign(aIfThisThisGUnd);

View File

@ -20,8 +20,12 @@ namespace WXML
Token::~Token() Token::~Token()
{ {
} }
std::string Token::ToAttrContent()
bool IsMatch(char const&) {
return "";
}
bool Token::IsMatch(char const&)
{ {
return true; return true;
} }

View File

@ -14,5 +14,9 @@ namespace WXML {
WXMLDom::~WXMLDom() WXMLDom::~WXMLDom()
{ {
} }
bool WXMLDom::operator==(std::string tag)
{
return this->tag.compare(tag) == 0;
}
} }
} }

View File

@ -1,4 +1,18 @@
#include "../include/wxml.h" #include "../include/wxml.h"
namespace WXML { 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()
{
}
} }

View File

@ -11131,7 +11131,7 @@ struct _Unwind_Exception *__cdecl WXML::Compiler::RenderDefine(
a10, a10,
a11, a11,
a12, a12,
(int *)v32, (int *)v32, // "r"
a15, a15,
a9, a9,
a16, a16,