mirror of
https://github.com/msojocs/wx-compiler.git
synced 2025-07-19 00:00:04 +08:00
feat: ast_if
This commit is contained in:
parent
16bcfacd79
commit
9aec5c4130
@ -105,15 +105,18 @@ namespace night
|
||||
)
|
||||
{
|
||||
|
||||
throw "not implement";
|
||||
}
|
||||
|
||||
void readfile(char const*, std::string &)
|
||||
{
|
||||
|
||||
throw "not implement";
|
||||
}
|
||||
|
||||
void writefile(char const*, std::string &)
|
||||
{
|
||||
|
||||
throw "not implement";
|
||||
}
|
||||
}
|
@ -231,7 +231,31 @@ namespace night
|
||||
}
|
||||
night::ns_node *NSASTParse::ast_if()
|
||||
{
|
||||
throw "not implement";
|
||||
this->ignore_buildin_kw("if");
|
||||
auto v2 = this->ast_expression_no_comma();
|
||||
auto v3 = this->ast_expression_no_comma();
|
||||
auto v7 = this->offset_24->gen_son(night::NS_TYPE_IF);
|
||||
v7->offset_204 = v2;
|
||||
v7->offset_208 = v3;
|
||||
v7->offset_212 = nullptr;
|
||||
|
||||
if (night::NS_TYPE_PROG_NO_SEM != v3->offset_0)
|
||||
{
|
||||
if (!this->offset_28->eof())
|
||||
{
|
||||
if (this->is_punctuation(";"))
|
||||
{
|
||||
this->offset_28->next();
|
||||
}
|
||||
}
|
||||
v7->offset_108 = ";";
|
||||
}
|
||||
if (this->is_buildin_keywords("else"))
|
||||
{
|
||||
this->offset_28->next();
|
||||
v7->offset_212 = this->ast_expression_no_comma();
|
||||
}
|
||||
return v7;
|
||||
}
|
||||
night::ns_node *NSASTParse::ast_for()
|
||||
{
|
||||
@ -392,7 +416,7 @@ namespace night
|
||||
auto v11 = this->ast_switch();
|
||||
return this->make_call_or_just_expression(v11);
|
||||
}
|
||||
bool v21 = false;
|
||||
bool v21 = true;
|
||||
if (this->is_buildin_keywords("true"))
|
||||
{
|
||||
}
|
||||
@ -461,6 +485,7 @@ namespace night
|
||||
v21 = this->is_buildin_keywords("continue") != 0;
|
||||
}
|
||||
}
|
||||
// goto LABEL_62;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -476,7 +501,7 @@ namespace night
|
||||
}
|
||||
}
|
||||
} // end check for "true"
|
||||
// v21 = false;
|
||||
// LABEL_62:
|
||||
if (v21)
|
||||
{
|
||||
auto v11 = this->ast_trans_kw();
|
||||
@ -795,10 +820,10 @@ namespace night
|
||||
}
|
||||
return a2;
|
||||
}
|
||||
// int ast_expression_i = 0;
|
||||
int ast_expression_i = 0;
|
||||
night::ns_node *NSASTParse::ast_expression()
|
||||
{
|
||||
// int inner_ast_expression_i = ast_expression_i++;
|
||||
int inner_ast_expression_i = ++ast_expression_i;
|
||||
auto v1 = this->ast_dispatch(false);
|
||||
auto binary_or_just_value = this->make_binary_or_just_value(v1, false);
|
||||
auto result = this->make_call_or_just_expression(binary_or_just_value);
|
||||
@ -1082,20 +1107,20 @@ namespace night
|
||||
auto v25 = this->offset_24->gen_girl(night::std_v_v_n);
|
||||
night::ns_node * lt = this->offset_24->gen_son(night::NS_TYPE_CALL);
|
||||
lt->offset_220 = v21;
|
||||
// lt->offset_224 = v25; // TODO...
|
||||
lt->offset_224 = v25.vecVec;
|
||||
auto v5 = this->offset_28->peek();
|
||||
std::vector<night::ns_node *> * v44;
|
||||
if (v5 && v5->offset_84.find('\n') == -1)
|
||||
{
|
||||
v44 = this->offset_24->gen_girl(night::std_v_n).vec;
|
||||
auto v45 = this->ast_expression(); // TODO...待确认
|
||||
auto v45 = this->ast_expression();
|
||||
v44->emplace_back(v45);
|
||||
}
|
||||
else
|
||||
{
|
||||
v44 = this->offset_24->gen_girl(night::std_v_n).vec;
|
||||
}
|
||||
// v25->push_back(v44);
|
||||
v25.vecVec->push_back(v44);
|
||||
return lt;
|
||||
}
|
||||
if ("typeof" == v43)
|
||||
@ -1504,4 +1529,13 @@ namespace night
|
||||
}
|
||||
this->offset_28->next();
|
||||
}
|
||||
void NSASTParse::ignore_buildin_kw(std::string const& a2)
|
||||
{
|
||||
if (!this->is_buildin_keywords(a2))
|
||||
{
|
||||
std::string msg = "Expected `" + a2 + "`";
|
||||
this->offset_28->err(msg, 0, 0, false);
|
||||
}
|
||||
this->offset_28->next();
|
||||
}
|
||||
}
|
@ -314,7 +314,6 @@ namespace night
|
||||
}
|
||||
std::string NSCompileJs::compile_obj_property(night::ns_node *)
|
||||
{
|
||||
// TODO...
|
||||
throw "not implement";
|
||||
}
|
||||
std::string NSCompileJs::compile_obj_self_op(night::ns_node *a3)
|
||||
@ -492,8 +491,10 @@ namespace night
|
||||
return result;
|
||||
}
|
||||
|
||||
int compile_i = 0;
|
||||
std::string NSCompileJs::compile(night::ns_node * a3)
|
||||
{
|
||||
int inner_compile_i = ++compile_i;
|
||||
if (this->offset_0.size() == 0)
|
||||
{
|
||||
std::string v9 = a3->offset_0;
|
||||
|
@ -26,7 +26,6 @@ namespace night
|
||||
}
|
||||
|
||||
/**
|
||||
* todo...
|
||||
*/
|
||||
int path_combine(std::string const& a1, std::string const& a2, std::string& a3)
|
||||
{
|
||||
|
@ -54,7 +54,7 @@ namespace MMBizWxaAppComm
|
||||
dirList.pop_back();
|
||||
}
|
||||
}
|
||||
else if (v15[i] == ".")
|
||||
else if (v15[i].compare("."))
|
||||
{
|
||||
dirList.push_back(v15[i]);
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ namespace WXML{
|
||||
bool b1, // mark指定运算结果是否非0 a12
|
||||
bool b2) // mark指定运算结果是否非0 a13
|
||||
{
|
||||
// ParseSource - 0
|
||||
int pResult = 0;
|
||||
bool isWxml = filePath.substr(filePath.length() - 5) == ".wxml";
|
||||
if (isWxml)
|
||||
@ -38,6 +39,7 @@ namespace WXML{
|
||||
|
||||
if (parseResult)
|
||||
{
|
||||
// ParseSource - 5
|
||||
// GetParsed
|
||||
std::shared_ptr<WXML::DOMLib::WXMLDom> parseDom = v50.GetParsed();
|
||||
result[filePath] = parseDom;
|
||||
@ -49,9 +51,9 @@ namespace WXML{
|
||||
ss << "']={};";
|
||||
ss << lineEndMark;
|
||||
}
|
||||
// ParseSource - 10
|
||||
for (int i = 0; i < tokenList.size(); i++)
|
||||
{
|
||||
/* code */
|
||||
int dealResult = 0;
|
||||
std::string v74, v76, v79;
|
||||
int v65;
|
||||
@ -141,6 +143,7 @@ namespace WXML{
|
||||
ss << lineEndMark;
|
||||
}
|
||||
}
|
||||
// ParseSource - 15
|
||||
auto v69 = ss.str();
|
||||
if (v69.length() > 0)
|
||||
{
|
||||
@ -149,18 +152,17 @@ namespace WXML{
|
||||
}
|
||||
// LABEL_24:
|
||||
}
|
||||
// ParseSource - 20
|
||||
else if(filePath.substr(filePath.length() - 4) == ".wxs")
|
||||
{
|
||||
std::string v84;
|
||||
std::string v84; // errorMessage
|
||||
std::string p = "p_" + filePath;
|
||||
auto v86 = WXML::Compiler::GetFuncId(a11, p);
|
||||
int compilerResultCode = 0;
|
||||
|
||||
// TODO: compile_ns
|
||||
|
||||
compilerResultCode = night::compile_ns(filePath, v86, content, 1, v84, false);
|
||||
pResult = compilerResultCode;
|
||||
if (compilerResultCode) {
|
||||
errorMessage.assign("error...");
|
||||
throw compilerResultCode;
|
||||
errorMessage.assign(v84);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -367,7 +367,7 @@ namespace WXML
|
||||
}
|
||||
if (bittest(&v46, 0x16u)) // 0x16 -> 22
|
||||
{
|
||||
// TODO:
|
||||
throw "not implement";
|
||||
// WXML::DOMLib::Token token(*(a5.end() - 1));
|
||||
a5.pop_back();
|
||||
|
||||
|
@ -452,7 +452,8 @@ namespace WXML {
|
||||
auto cur = this->offset_72[i];
|
||||
if (cur->offset_0 == "block")
|
||||
{
|
||||
// TODO...
|
||||
// this->offset_72[i]
|
||||
// throw "not implement";
|
||||
}
|
||||
}
|
||||
|
||||
@ -810,6 +811,10 @@ namespace WXML {
|
||||
for (int i = 0; i < v142.size(); i++)
|
||||
{
|
||||
a6 << v142[i].first << ".wxXCkey=" << v142[i].second << a12;
|
||||
// if (v142[i].first == "oVD")
|
||||
// {
|
||||
// printf("\n");
|
||||
// }
|
||||
}
|
||||
|
||||
// RenderChildren - 20
|
||||
@ -829,6 +834,7 @@ namespace WXML {
|
||||
|
||||
}
|
||||
|
||||
// int emplace_back_i = 0;
|
||||
void WXMLDom::RenderNonDefine(
|
||||
std::string const& a2,
|
||||
std::string const& a3,
|
||||
@ -1278,7 +1284,11 @@ namespace WXML {
|
||||
|| v161 != "wx:scope-data")
|
||||
{
|
||||
// pos: 搜索 -> !__stricmp((const char *)v161, "wx:scope-data")
|
||||
|
||||
// ++emplace_back_i;
|
||||
// if (emplace_back_i == 139)
|
||||
// {
|
||||
// printf("\n");
|
||||
// }
|
||||
// WXML::DOMLib::Token token = this.;
|
||||
v324.emplace_back(j->first, j->second);
|
||||
}
|
||||
@ -1305,7 +1315,7 @@ namespace WXML {
|
||||
// {
|
||||
// /* code */
|
||||
// }
|
||||
// TODO...
|
||||
throw "not implement";
|
||||
|
||||
}
|
||||
}
|
||||
@ -1332,11 +1342,12 @@ namespace WXML {
|
||||
}
|
||||
if (!strncmp(&i->first[0], "data-", 5u) || i->first.find(':') != -1)
|
||||
{
|
||||
str.assign(i->first);
|
||||
if (!strncmp(&i->first[0], "generic:", 8u))
|
||||
{
|
||||
a6 << "var $tmp=";
|
||||
// if (i->second.)
|
||||
// TODO...
|
||||
throw "not implement";
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1786,7 +1797,7 @@ namespace WXML {
|
||||
// 0x48 -> 72
|
||||
this->offset_72[v4]->MarkIfHasDescendant(a2);
|
||||
auto v6 = this->offset_72[v4];
|
||||
this->offset_256 = v6->offset_256;
|
||||
this->offset_256 |= v6->offset_256;
|
||||
auto ret = std::find(a2.begin(), a2.end(), v6->offset_0);
|
||||
if (ret != a2.end())
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user