diff --git a/.vscode/settings.json b/.vscode/settings.json index 69ffe1f..716efff 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -57,10 +57,10 @@ "variant": "cpp" }, "cmake.debugConfig": { - "cwd": "/mnt/d/Work/WeChatProjects/miniprogram-demo/miniprogram", + "cwd": "/mnt/d/Work/WeChatProjects/miniprogram-1", "args": [ "\"--config-path\"", - "\"/mnt/d/Work/disassembly/wcc-exec/wcsc/config/ll2.txt\"" + "\"/mnt/d/Work/WeChatProjects/miniprogram-1/wcc/99a9bac3c05fc25dd070298212c4a7d3\"" ] }, "cmake.configureSettings": { diff --git a/src/include/wxml.h b/src/include/wxml.h index 81c3d37..ab95e3a 100644 --- a/src/include/wxml.h +++ b/src/include/wxml.h @@ -486,14 +486,13 @@ namespace WXML int Compile( std::map const&,// a1 std::string&, // a2 - std::string&, // a3 + std::string&, // a3 result std::map>,// a4 std::map const&,// a5 bool,// a6 std::string const& gwxMark,// a7 uint mark, // a8 char lineEndMark, // a9 - std::string const&, // a10 std::string const&, // a11 std::string const& , // a12 std::string const& ggMark, // a13 diff --git a/src/night/ns_ast_parse.cpp b/src/night/ns_ast_parse.cpp index 6614fad..c7af1b4 100644 --- a/src/night/ns_ast_parse.cpp +++ b/src/night/ns_ast_parse.cpp @@ -297,7 +297,32 @@ namespace night } night::ns_node *NSASTParse::ast_for() { - throw "not implement"; + this->offset_28->next(); + auto v7 = this->offset_24->gen_son(night::NS_TYPE_FOR); + v7->offset_216 = nullptr; + v7->offset_228 = nullptr; + + v7->offset_228 = this->make_list_by_parser("(", ")", ";", "ast_expression", false, 2, ""); + auto v5 = v7->offset_228; + if (!v5) + { + this->offset_28->err("Expected `for(xxx;xxx;xxx)`", 0, 0, 0); + } + if (v5->size() == 2) + { + auto t = this->offset_24->gen_son(night::NS_TYPE_SKIP); + v5->emplace_back(t); + } + if (v5->size() != 3) + { + this->offset_28->err("Expected `for(xxx;xxx;xxx)`", 0, 0, 0); + } + this->offset_36++; + this->offset_40++; + v7->offset_216 = this->ast_expression(); + this->offset_36--; + this->offset_40--; + return v7; } night::ns_node *NSASTParse::ast_while() { diff --git a/src/wcc.cpp b/src/wcc.cpp index 2f601c2..570b5f3 100644 --- a/src/wcc.cpp +++ b/src/wcc.cpp @@ -64,9 +64,7 @@ int main(int argc, const char **argv) int mark = 0; bool isReadFromStdin = false; bool version = false; - bool hasXCParam = false; - bool hasCompleteCodeParam = false; - bool isLLA = false; + bool v53 = false; bool hasLL = false; string xc_Or_completeCode_Param; string outputFileName; @@ -132,7 +130,7 @@ int main(int argc, const char **argv) /* code */ if (param[2] == 'c' && i + 1 < paramList.size()) { - hasXCParam = true; + v53 = true; if (paramList[i + 1][0] != '-') { xc_Or_completeCode_Param.assign(paramList[i + 1]); @@ -146,7 +144,7 @@ int main(int argc, const char **argv) /* code */ if (param[2] == 'c' && i + 1 < paramList.size()) { - hasCompleteCodeParam = true; + v53 = false; if (paramList[i + 1][0] != '-') { xc_Or_completeCode_Param.assign(paramList[i + 1]); @@ -244,7 +242,7 @@ int main(int argc, const char **argv) printf("Error: expected -llw or -lla, but got %s\n", param.c_str()); return -1; } - isLLA = true; + v53 = true; } string splitMark; if (!splitMarkStr.compare(" ")) @@ -368,7 +366,7 @@ int main(int argc, const char **argv) componentListMap, // componentListMap splitedData, mapData1, - isLLA, + v53, gwxMark, mark, 10, @@ -458,28 +456,32 @@ int main(int argc, const char **argv) { std::string errorMessage; const char off_5403C3[] = {'s', '\0', 'e', '\0'}; + std::string v111; + std::string v113; + std::map> v126; int compilerResult = 0; - // compilerResult = WXML::Compiler::Compile( - // v3, - // &v107, - // errorMessage - // (unsigned __int8 **)v113, - // v126, - // &v105, - // v53, - // (int *)gwxMark, - // mark, - // '\n', - // off_5403C3[2], // off_5403C3[2] - // off_5403C3, // off_5403C3 - // "gg", // "gg" - // "e_", // "e_" - // "d_", // "d_" - // "p_", // "p_" - // '\0', // '\0' - // "boxofchocolate", // "boxofchocolate" - // "$gdwx", // "$gdwx" - // "f_"); // "f_" + std::map v105; + + compilerResult = WXML::Compiler::Compile( + fileContentMap, // a2 + v111, // a3 + v113, // a4 + v126, // a5 + v105, // a6 + v53, // a7 + gwxMark, // a8 + mark, // a9 + '\n', // + "e", // off_5403C3[2] + "s", // off_5403C3 + "gg", // "gg" a13 + "e_", // "e_" + "d_", // "d_" + "p_", // "p_" + "", // '\0' + "boxofchocolate", // "boxofchocolate" + "$gdwx", // "$gdwx" + "f_"); // "f_" FILE *f; if (compilerResult) { @@ -493,7 +495,7 @@ int main(int argc, const char **argv) { f = fopen(outputFileName.data(), "w"); } - fprintf(f, "%s\n", "result..."); + fprintf(f, "%s\n", v113.data()); fclose(f); } } diff --git a/src/wxml/compiler.cpp b/src/wxml/compiler.cpp index ecb26ca..470fadb 100644 --- a/src/wxml/compiler.cpp +++ b/src/wxml/compiler.cpp @@ -37,7 +37,7 @@ namespace WXML{ std::vector tokenList; // v102 parseResult = v50.Parse(content.c_str(), errorMessage, filePath, tokenList); - if (parseResult) + if (!parseResult) { // ParseSource - 5 // GetParsed @@ -788,18 +788,859 @@ namespace WXML{ } int Compile( - std::map const&,// a1 - std::string&, // a2 - std::string&, // a3 - std::map>,// a4 - std::map const&,// a5 - bool,// a6 - std::string const& gwxMark,// a7 - uint mark, // a8 - char lineEndMark, // a9 - std::string const&, // a10 - std::string const&, // a11 - std::string const& , // a12 + std::map const& a2,// a2 + std::string& a3, // a3 + std::string& a4, // a4 + std::map> a5,// a5 + std::map const& a6,// a6 + bool a7,// a7 + std::string const& gwxMark,// a8 + uint mark, // a9 + char lineEndMark, // a10 + std::string const& eMark1, // a11 + std::string const& sMark, // a12 + std::string const& ggMark, // a13 + std::string const& eMark2, // a14 + std::string const& dMark, // a15 + std::string const& pMark, // a16 + std::string const& endMark, // a17 + std::string const& boxMark, // a18 + std::string const& gdwxMark, // a19 + std::string const& fMark) // a20 + { + std::stringstream v317; + std::shared_ptr lb(new WXML::DOMLib::StrCache()); + std::map> v286; + std::map v290; + std::map v292; + for (auto i = a2.begin(); i != a2.end(); i++) + { + auto key = i->first; + std::string suffix = key.substr(key.length() - 5); + if (suffix == ".wxml") + { + WXML::DOMLib::Parser v228; + std::vector v283; + int v266 = v228.Parse(i->second.data(), a3, key, v283); + if (v266) + { + return v266; + } + auto v323 = v228.GetParsed(); + v286[key] = v323; + std::stringstream v320; + if (v283.begin() != v283.end()) + { + v320 << "f_['"; + v320 << WXML::Rewrite::ToStringCode(key); + v320 << "']={};" << lineEndMark; + } + for (int j = 0; j < v283.size(); j++) + { + auto cur = v283[j]; + std::string v299, v304, v301, v306; + int v280; + int v246 = WXML::Compiler::DealWxsTag(key, cur, v299, v301, v304, &v280, a3); + if (v246) + { + return v246; + } + v320 << fMark << "['"; + v320 << WXML::Rewrite::ToStringCode(key) << "']['"; + v320 << WXML::Rewrite::ToStringCode(v299) << "'] ="; + if (v301.length()) + { + MMBizWxaAppComm::PathCombine(key, v301, v306); + if (v306[0] == '/') + { + v306 = '.' + v306; + } + if (a2.find(v306) == a2.end()) + { + if ((mark & 0x20) != 0 || gwxMark == "$gwx") + { + std::stringstream v323; + v323 << key << ":" << v280 << ":" << cur.offset_12; + v323 << ":" << v301 << " not found from " << key; + a3 = v323.str(); + return 1; + } + } + v320 << "f_['"; + v320 << WXML::Rewrite::ToStringCode(v306); + v320 << "'] || "; + v320 << "nv_require(\""; + v320 << WXML::Rewrite::ToStringCode("p_" + v306); + v320 << "\");" << lineEndMark; + v320 << fMark; + v320 << "['" << WXML::Rewrite::ToStringCode(key) << "']['"; + v320 << WXML::Rewrite::ToStringCode(v299) << "']();" << lineEndMark; + } + else + { + std::string v314 = "m_" + key; + v314.append(":"); + v314.append(v299); + WXML::Compiler::GetFuncId(v292, v314); + std::string v309, v297; + int v246 = night::compile_ns(key, v309, v304, v280, v297, false); + if(v246) + { + return v246; + } + v320 << "nv_require(\""; + v320 << WXML::Rewrite::ToStringCode(v314); + v320 << "\");" << lineEndMark; + v320 << v297 << lineEndMark; + } + // next + } + std::string v314 = v320.str(); + if (v314.length()) + { + v290[key].assign(v314); + } + + } + else + { + std::string v316 = key.substr(key.length() - 4); + if (v316 == ".wxs") + { + std::string v311; + std::string v327 = "p_" + key; + std::string v314 = WXML::Compiler::GetFuncId(v292, v327); + int v266 = night::compile_ns(key, v314, i->second, 1, v311, false); + if (v266) + { + return v266; + } + std::stringstream v327_s; + v327_s << "f_['"; + v327_s << WXML::Rewrite::ToStringCode(key) << "'] = nv_require(\""; + v327_s << WXML::Rewrite::ToStringCode("p_" + key) << "\");" << lineEndMark; + v327_s << v311 << lineEndMark; + std::string v323 = v327_s.str(); + v290[key] = v323; + } + } + } + std::string v323; + // Compile - 5 + if (a7) + { + v323 = "global"; + } + else + { + v323 = "window"; + } + std::string v327; + WXML::Compiler::GetVersionInfo(v327, v323); + v317 << v327 << std::endl; + WXML::NameAllocator v323_na(endMark, boxMark); + v317 << "var $gwxc" << lineEndMark; + v317 << "var $gaic={}" << lineEndMark; + v317 << gwxMark << "=function(path,global){" << lineEndMark; + v317 << "if(typeof global === 'undefined') global={};"; + v317 << "if(typeof __WXML_GLOBAL__ === 'undefined') {"; + v317 << "__WXML_GLOBAL__={};" << lineEndMark; + if ((mark & 0x80) != 0) + { + auto lccc = a6.find("life_cycle_callback_content"); + if (lccc != a6.end()) + { + v317 << lccc->second; + } + + } + v317 << "}"; + v317 << "__WXML_GLOBAL__.modules = __WXML_GLOBAL__.modules || {};" << lineEndMark; + if (gwxMark != "$gwx" && (mark & 0x60) == 0) + { + v317 << "$gwx('init', global);" << lineEndMark; + } + // Compile - 15 + v317 << "function _(a,b){if(typeof(b)!='undefined')a.children.push(b);}" << lineEndMark; + v317 << "function _v(k){if(typeof(k)!='undefined')return {tag:'virtual','wxKey':k,children:[]};return {tag:'virtual',children:[]};}" << lineEndMark; + v317 << "function _n(tag){$gwxc++;if($gwxc>=16000){throw 'Dom limit exceeded, please check if there\\'s any mistake you" + "\\'ve made.'};return {tag:'wx-'+tag,attr:{},children:[],n:[],raw:{},generics:{}}}" << lineEndMark; + v317 << "function _p(a,b){b&&a.properities.push(b);}" << lineEndMark; + v317 << "function _s(scope,env,key){return typeof(scope[key])!='undefined'?scope[key]:env[key]}" << lineEndMark; + v317 << "function _wp(m){console.warn(\"WXMLRT_" << gwxMark << ":\"+m)}" << lineEndMark; + v317 << "function _wl(tname,prefix){_wp(prefix+':-1:-1:-1: Template `' + tname + '` is being called recursively, will be stop.')}" << lineEndMark; + v317 << aGwnConsoleWarn << lineEndMark; + v317 << "function wfor( to_iter, func, env, _s, global, father, itemname, indexname, keyname )\n" + "{\n" + "var _n = wh.hn( to_iter ) === 'n'; \n" + "var scope = wh.rv( _s ); \n" + "var has_old_item = scope.hasOwnProperty(itemname);\n" + "var has_old_index = scope.hasOwnProperty(indexname);\n" + "var old_item = scope[itemname];\n" + "var old_index = scope[indexname];\n" + "var full = Object.prototype.toString.call(wh.rv(to_iter));\n" + "var type = full[8]; \n" + "if( type === 'N' && full[10] === 'l' ) type = 'X'; \n" + "var _y;\n" + "if( _n )\n" + "{\n" + "if( type === 'A' ) \n" + "{\n" + "var r_iter_item;\n" + "for( var i = 0 ; i < to_iter.length ; i++ )\n" + "{\n" + "scope[itemname] = to_iter[i];\n" + "scope[indexname] = _n ? i : wh.nh(i, 'h');\n" + "r_iter_item = wh.rv(to_iter[i]);\n" + "var key = keyname && r_iter_item ? (keyname===\"*this\" ? r_iter_item : wh.rv(r_iter_item[keyname])) : undefin" + "ed;\n" + "_y = _v(key);\n" + "_(father,_y);\n" + "func( env, scope, _y, global );\n" + "}\n" + "}\n" + "else if( type === 'O' ) \n" + "{\n" + "var i = 0;\n" + "var r_iter_item;\n" + "for( var k in to_iter )\n" + "{\n" + "scope[itemname] = to_iter[k];\n" + "scope[indexname] = _n ? k : wh.nh(k, 'h');\n" + "r_iter_item = wh.rv(to_iter[k]);\n" + "var key = keyname && r_iter_item ? (keyname===\"*this\" ? r_iter_item : wh.rv(r_iter_item[keyname])) : undefin" + "ed;\n" + "_y = _v(key);\n" + "_(father,_y);\n" + "func( env,scope,_y,global );\n" + "i++;\n" + "}\n" + "}\n" + "else if( type === 'S' ) \n" + "{\n" + "for( var i = 0 ; i < to_iter.length ; i++ )\n" + "{\n" + "scope[itemname] = to_iter[i];\n" + "scope[indexname] = _n ? i : wh.nh(i, 'h');\n" + "_y = _v( to_iter[i] + i );\n" + "_(father,_y);\n" + "func( env,scope,_y,global );\n" + "}\n" + "}\n" + "else if( type === 'N' ) \n" + "{\n" + "for( var i = 0 ; i < to_iter ; i++ )\n" + "{\n" + "scope[itemname] = i;\n" + "scope[indexname] = _n ? i : wh.nh(i, 'h');\n" + "_y = _v( i );\n" + "_(father,_y);\n" + "func(env,scope,_y,global);\n" + "}\n" + "}\n" + "else\n" + "{\n" + "}\n" + "}\n" + "else\n" + "{\n" + "var r_to_iter = wh.rv(to_iter);\n" + "var r_iter_item, iter_item;\n" + "if( type === 'A' ) \n" + "{\n" + "for( var i = 0 ; i < r_to_iter.length ; i++ )\n" + "{\n" + "iter_item = r_to_iter[i];\n" + "iter_item = wh.hn(iter_item)==='n' ? wh.nh(iter_item,'h') : iter_item;\n" + "r_iter_item = wh.rv( iter_item );\n" + "scope[itemname] = iter_item\n" + "scope[indexname] = _n ? i : wh.nh(i, 'h');\n" + "var key = keyname && r_iter_item ? (keyname===\"*this\" ? r_iter_item : wh.rv(r_iter_item[keyname])) : undefin" + "ed;\n" + "_y = _v(key);\n" + "_(father,_y);\n" + "func( env, scope, _y, global );\n" + "}\n" + "}\n" + "else if( type === 'O' ) \n" + "{\n" + "var i=0;\n" + "for( var k in r_to_iter )\n" + "{\n" + "iter_item = r_to_iter[k];\n" + "iter_item = wh.hn(iter_item)==='n'? wh.nh(iter_item,'h') : iter_item;\n" + "r_iter_item = wh.rv( iter_item );\n" + "scope[itemname] = iter_item;\n" + "scope[indexname] = _n ? k : wh.nh(k, 'h');\n" + "var key = keyname && r_iter_item ? (keyname===\"*this\" ? r_iter_item : wh.rv(r_iter_item[keyname])) : undefin" + "ed;\n" + "_y=_v(key);\n" + "_(father,_y);\n" + "func( env, scope, _y, global );\n" + "i++\n" + "}\n" + "}\n" + "else if( type === 'S' ) \n" + "{\n" + "for( var i = 0 ; i < r_to_iter.length ; i++ )\n" + "{\n" + "iter_item = wh.nh(r_to_iter[i],'h');\n" + "scope[itemname] = iter_item;\n" + "scope[indexname] = _n ? i : wh.nh(i, 'h');\n" + "_y = _v( to_iter[i] + i );\n" + "_(father,_y);\n" + "func( env, scope, _y, global );\n" + "}\n" + "}\n" + "else if( type === 'N' ) \n" + "{\n" + "for( var i = 0 ; i < r_to_iter ; i++ )\n" + "{\n" + "iter_item = wh.nh(i,'h');\n" + "scope[itemname] = iter_item;\n" + "scope[indexname]= _n ? i : wh.nh(i,'h');\n" + "_y = _v( i );\n" + "_(father,_y);\n" + "func(env,scope,_y,global);\n" + "}\n" + "}\n" + "else\n" + "{\n" + "}\n" + "}\n" + "if(has_old_item)\n" + "{\n" + "scope[itemname]=old_item;\n" + "}\n" + "else\n" + "{\n" + "delete scope[itemname];\n" + "}\n" + "if(has_old_index)\n" + "{\n" + "scope[indexname]=old_index;\n" + "}\n" + "else\n" + "{\n" + "delete scope[indexname];\n" + "}\n" + "}\n" << lineEndMark; + // Compile - 20 + v317 << "function _ca(o)\n" + "{ \n" + "if ( wh.hn(o) == 'h' ) return true;\n" + "if ( typeof o !== \"object\" ) return false;\n" + "for(var i in o){ \n" + "if ( o.hasOwnProperty(i) ){\n" + "if (_ca(o[i])) return true;\n" + "}\n" + "}\n" + "return false;\n" + "}\n" + "function _da( node, attrname, opindex, raw, o )\n" + "{\n" + "var isaffected = false;\n" + "var value = $gdc( raw, \"\", 2 );\n" + "if ( o.ap && value && value.constructor===Function ) \n" + "{\n" + "attrname = \"$wxs:\" + attrname; \n" + "node.attr[\"$gdc\"] = $gdc;\n" + "}\n" + "if ( o.is_affected || _ca(raw) ) \n" + "{\n" + "node.n.push( attrname );\n" + "node.raw[attrname] = raw;\n" + "}\n" + "node.attr[attrname] = value;\n" + "}\n" + "function _r( node, attrname, opindex, env, scope, global ) \n" + "{\n" + "global.opindex=opindex;\n" + "var o = {}, _env;\n" + "var a = grb( z[opindex], env, scope, global, o );\n" + "_da( node, attrname, opindex, a, o );\n" + "}\n" + "function _rz( z, node, attrname, opindex, env, scope, global ) \n" + "{\n" + "global.opindex=opindex;\n" + "var o = {}, _env;\n" + "var a = grb( z[opindex], env, scope, global, o );\n" + "_da( node, attrname, opindex, a, o );\n" + "}\n" + "function _o( opindex, env, scope, global )\n" + "{\n" + "global.opindex=opindex;\n" + "var nothing = {};\n" + "var r = grb( z[opindex], env, scope, global, nothing );\n" + "return (r&&r.constructor===Function) ? undefined : r;\n" + "}\n" + "function _oz( z, opindex, env, scope, global )\n" + "{\n" + "global.opindex=opindex;\n" + "var nothing = {};\n" + "var r = grb( z[opindex], env, scope, global, nothing );\n" + "return (r&&r.constructor===Function) ? undefined : r;\n" + "}\n" + "function _1( opindex, env, scope, global, o )\n" + "{\n" + "var o = o || {};\n" + "global.opindex=opindex;\n" + "return gra( z[opindex], env, scope, global, o );\n" + "}\n" + "function _1z( z, opindex, env, scope, global, o )\n" + "{\n" + "var o = o || {};\n" + "global.opindex=opindex;\n" + "return gra( z[opindex], env, scope, global, o );\n" + "}\n" + "function _2( opindex, func, env, scope, global, father, itemname, indexname, keyname )\n" + "{\n" + "var o = {};\n" + "var to_iter = _1( opindex, env, scope, global );\n" + "wfor( to_iter, func, env, scope, global, father, itemname, indexname, keyname );\n" + "}\n" + "function _2z( z, opindex, func, env, scope, global, father, itemname, indexname, keyname )\n" + "{\n" + "var o = {};\n" + "var to_iter = _1z( z, opindex, env, scope, global );\n" + "wfor( to_iter, func, env, scope, global, father, itemname, indexname, keyname );\n" + "}\n" << lineEndMark; + v317 << "\n" + "function _m(tag,attrs,generics,env,scope,global)\n" + "{\n" + "var tmp=_n(tag);\n" + "var base=0;\n" + "for(var i = 0 ; i < attrs.length ; i+=2 )\n" + "{\n" + "if(base+attrs[i+1]<0)\n" + "{\n" + "tmp.attr[attrs[i]]=true;\n" + "}\n" + "else\n" + "{\n" + "_r(tmp,attrs[i],base+attrs[i+1],env,scope,global);\n" + "if(base===0)base=attrs[i+1];\n" + "}\n" + "}\n" + "for(var i=0;i=0;x--){if(e[p].i[x]&&d[e[p" + "].i[x]][c])return d[e[p].i[x]][c]};"; + v317 << "for(var x=e[p].ti.length-1;x>=0;x--){var q=_grp(e[p].ti[x],e,p);if(q&&d[q][c])return d[q][c]}"; + v317 << "var ii=_gapi(e,p);for(var x=0;x=0;k--)if(e[p].j[k]){for(var q=e[e[p].j[k]].ti.length-1;q>=0;q--){var pp=_grp(e[e[p].j[k" + "]].ti[q],e,p);if(pp&&d[pp][c]){return d[pp][c]}}}"; + v317 << "}" << lineEndMark; + v317 << "function _gapi(e,p){if(!p)return [];if($gaic[p]){return $gaic[p]};var ret=[],q=[],h=0,t=0,put={},visited={};q.push(p" + ");visited[p]=true;t++;while(hsecond->RewriteTree(); + std::string v327 = "ALL"; + std::vector v113 = a5[v327]; + j->second->MarkIfHasDescendant(v113); + if (a7) + { + j->second->CutDomsForCustomComponent(v113); + } + } + // Compile - 45 + v317 << "__WXML_GLOBAL__.ops_cached = __WXML_GLOBAL__.ops_cached || {}" << lineEndMark; + v317 << "__WXML_GLOBAL__.ops_set = __WXML_GLOBAL__.ops_set || {};" << lineEndMark; + v317 << "__WXML_GLOBAL__.ops_init = __WXML_GLOBAL__.ops_init || {};" << lineEndMark; + v317 << "var z=__WXML_GLOBAL__.ops_set." << gwxMark << " || [];" << lineEndMark; + if ((mark & 4) != 0) + { + v317 << "__WXML_GLOBAL__.debuginfo_set = __WXML_GLOBAL__.debuginfo_set || {};" << lineEndMark; + v317 << "var debugInfo=__WXML_GLOBAL__.debuginfo_set." << gwxMark << " || [];" << lineEndMark; + } + // Compile - 50 + int v254 = 0; + for (auto k = v286.begin(); k != v286.end(); k++) + { + v254++; + std::stringstream v327; + v327 << gwxMark << "_" << v254; + std::string v314 = v327.str(); + std::string v316 = "gz" + v314; + v317 << "function " << v316 << "(){" << lineEndMark; + v317 << "if( __WXML_GLOBAL__.ops_cached." << v314 << ")"; + v317 << "return __WXML_GLOBAL__.ops_cached." << v314 << lineEndMark; + v317 << "__WXML_GLOBAL__.ops_cached." << v314 << "=[];" << lineEndMark; + v317 << "(function(z){var a=11;"; + if ((mark & 4) != 0) + { + v317 << "function Z(ops,debugLine){z.push(['11182016',ops,debugLine])}"; + } + else + { + v317 << "function Z(ops){z.push(ops)}"; + } + v317 << lineEndMark; + std::map v311; + WXML::DOMLib::RVMOpCodePositionRecorder v306; + k->second->RenderAllOpsAndRecord(k->first, a3, v317, v311, &v306, (mark & 4) != 0, a6); + v317 << "})(__WXML_GLOBAL__.ops_cached." << v314 << ");"; + v317 << "return __WXML_GLOBAL__.ops_cached." << v314 << lineEndMark; + v317 << "}" << lineEndMark; + k->second->offset_272["get_page_z_name"].assign(v316); + + } + // Compile - 55 + v317 << "__WXML_GLOBAL__.ops_set." << gwxMark << "=z;" << lineEndMark; + v317 << "__WXML_GLOBAL__.ops_init." << gwxMark << "=true;" << lineEndMark; + if ((mark & 4) != 0) + { + v317 << "__WXML_GLOBAL__.debuginfo_set." << gwxMark << "=debugInfo;" << lineEndMark; + + } + v317 << "var nv_require=function(){var nnm={"; + for (auto m = v292.rbegin(); m != v292.rend(); m++) + { + v317 << "\""; + v317 << WXML::Rewrite::ToStringCode(m->first); + v317 << "\":np_"; + v317 << m->second << ","; + } + // Compile - 60 + v317 << "};var nom={};return function(n){"; + v317 << "if(n[0]==='p'&&n[1]==='_'&&f_[n.slice(2)])return f_[n.slice(2)];"; + v317 << "return function(){if(!nnm[n]) return undefined;"; + v317 << "try{if(!nom[n])nom[n]=nnm[n]();return nom[n];}" << "catch(e){"; + v317 << "e.message=e.message.replace(/nv_/g,'');"; + v317 << "var tmp = e.stack.substring(0,e.stack.lastIndexOf(n));"; + v317 << "e.stack = tmp.substring(0,tmp.lastIndexOf('\\n'));"; + v317 << "e.stack = e.stack.replace(/\\snv_/g,' ');"; + v317 << "e.stack = $gstack(e.stack);"; + v317 << "e.stack += '\\n at ' + n.substring(2);console.error(e);}" << lineEndMark; + v317 << "}}}()" << lineEndMark; + for (auto n = v290.rbegin(); n != v290.rend(); n++) + { + v317 << n->second << lineEndMark; + } + // Compile - 65 + std::shared_ptr v281(new WXML::DOMLib::StrCache()); + for (auto ii = v286.begin(); ii != v286.end(); ii++) + { + v281->Insert(ii->first); + ii->second->offset_248 = v281; + ii->second->RecordAllPath(); + } + v281->RenderPathDefine(v317); + int inc = 0; + for (auto i = v286.begin(); i != v286.end(); i++) + { + std::map v309; + v317 << dMark << "[x["; + int strId = v281->GetStrID(i->first); + v317 << strId << "]]={}" << lineEndMark; + std::string v165 = i->second->offset_272["get_page_z_name"]; + int v266 = WXML::Compiler::RenderDefine( + *i->second, + i->first, + v309, + a3, + v317, + a6, + (mark & 2) != 0, + mark, + lineEndMark, + eMark1, + sMark, + ggMark, + gwxMark, + eMark2, + dMark, + pMark, + endMark, + boxMark, + gdwxMark, + v165 + ); + if (v266) + { + return v266; + } + std::stringstream v327; + v327 << "m"; + inc++; + v327 << inc; + std::string v314 = v327.str(); + auto v276 = i->second->offset_272["get_page_z_name"]; + std::string v320 = "r"; + i->second->RenderMeAsFunction( + i->first, + eMark2, + a3, + v314, + v317, + &v323_na, + eMark1, + sMark, + ggMark, + v320, + dMark, + lineEndMark, + pMark, + false, + (mark & 2) != 0, + mark, + v276 + ); + // if (v266) + // { + // return v266; + // } + v317 << eMark2 << "[x["; + int v167 = v281->GetStrID(i->first); + v317 << v167 << "]]={f:" << v314 << ",j:[],i:[],ti:["; + auto v171 = i->second->offset_72; + for (int j = 0; j < v171.size(); j++) + { + auto cur = v171[j]; + if (cur->offset_0 == "import") + { + if (cur->offset_48.find("src") != cur->offset_48.end()) + { + if (j) + { + v317 << ","; + } + v317 << "x["; + auto v172 = cur->offset_48.find("src"); + auto v173 = v172->second.ToAttrContent(); + int v174 = v281->GetStrID(v173); + v317 << v174 << "]"; + } + } + } + v317 << "],ic:["; + for (int jj = 0; jj < i->second->offset_72.size(); jj++) + { + auto cur = i->second->offset_72[jj]; + if (cur->offset_0 == "include") + { + auto src = cur->offset_48.find("src"); + if (src != cur->offset_48.end()) + { + if (jj) + { + v317 << ","; + } + auto v178 = src->second.ToAttrContent(); + int v179 = v281->GetStrID(v178); + v317 << v179 << "]"; + } + } + } + v317 << "]}" << lineEndMark; + + } + // Compile - 70 + v317 << "if(path&&" << eMark2 << "[path]){" << lineEndMark; + if (!a7) + { + v317 << "window.__wxml_comp_version__=0.02" << lineEndMark; + } + v317 << "return function(env,dd,global){$gwxc=0;var root={\"tag\":\"wx-page\"};root.children=[]" << lineEndMark; + v317 << "var main=" << eMark2 << "[path].f" << lineEndMark; + if ((mark & 2) != 0) + { + v317 << "cs=[]" << lineEndMark; + } + if ((mark & 0x10) != 0) + { + v317 << "console.log(path+': benv:\\n'+JSON.stringify(env))" << lineEndMark; + } + v317 << "if (typeof global===\"undefined\")global={};"; + v317 << "global.f=$gdc(" << fMark << "[path],\"\",1);" << lineEndMark; + if (!a7) + { + v317 << "if(typeof(window.__webview_engine_version__)!='undefined'&&window.__webview_engine_version__+1e-6>=0.02+1e-" + "6&&window.__mergeData__)" << lineEndMark; + v317 << "{" << lineEndMark; + v317 << "env=window.__mergeData__(env,dd);" << lineEndMark; + v317 << "}" << lineEndMark; + } + v317 << "try{" << lineEndMark; + if ((mark & 0x10) != 0) + { + v317 << "console.log(path+': aenv:\\n'+JSON.stringify(env)+', '+JSON.stringify(dd))" << lineEndMark; + } + // Compile - 75 + if ((mark & 0x80) != 0) + { + v317 << "if(__WXML_GLOBAL__.before_calculate)__WXML_GLOBAL__.before_calculate(path, env)" << lineEndMark; + } + v317 << "main(env,{},root,global);" << lineEndMark; + if ((mark & 0x80) != 0) + { + v317 << "if(__WXML_GLOBAL__.after_calculate)__WXML_GLOBAL__.after_calculate(path, root)" << lineEndMark; + } + v317 << "_tsd(root)" << lineEndMark; + if (!a7) + { + v317 << "if(typeof(window.__webview_engine_version__)=='undefined'|| window.__webview_engine_version__+1e-6<0.01+1e-" + "6){return _ev(root);}" << lineEndMark; + } + // Compile - 80 + v317 << "}catch(err){" << lineEndMark; + if ((mark & 2) != 0) + { + v317 << "console.log(cs, env);" << lineEndMark; + } + v317 << "console.log(err)" << lineEndMark; + if ((mark & 2) != 0) + { + v317 << "throw err" << lineEndMark; + } + v317 << "}" << lineEndMark; + if ((mark & 0x10) != 0) + { + v317 << "console.log(path+': resp:\\n'+JSON.stringify(root))" << lineEndMark; + } + v317 << "return root;" << lineEndMark; + v317 << "}" << lineEndMark; + v317 << "}" << lineEndMark; + v317 << "}" << lineEndMark; + if ( (mark & 8) != 0 ) + { + for (auto kk = v286.begin(); kk != v286.end(); kk++) + { + v317 << "//" << kk->first << ":" << std::endl; + kk->second->Print(0, "//", &v317); + } + + } + a4 = v317.str(); + + /* + std::map const& a2,// a2 + std::string& a3, // a3 + std::string& a4, // a4 + std::map> a5,// a5 + std::map const& a6,// a6 + bool a7,// a7 + std::string const& gwxMark,// a8 + uint mark, // a9 + char lineEndMark, // a10 + std::string const& a11, // a11 + std::string const& a12, // a12 std::string const& ggMark, // a13 std::string const& eMark, // a14 std::string const& dMark, // a15 @@ -808,7 +1649,7 @@ namespace WXML{ std::string const& boxMark, // a18 std::string const& gdwxMark, // a19 std::string const& fMark) // a20 - { + */ return 0; } int DealWxsTag( @@ -851,7 +1692,7 @@ namespace WXML{ std::vector v50; bool parseResult = p.Parse(data.data(), errorMessage, filePath, v50); // DealWxsTag - 10 - if (parseResult) + if (!parseResult) { auto dom = p.GetParsed(); *a6 = a2.offset_8; diff --git a/src/wxml/dom_lib/machine.cpp b/src/wxml/dom_lib/machine.cpp index cfafa0f..98c62f7 100644 --- a/src/wxml/dom_lib/machine.cpp +++ b/src/wxml/dom_lib/machine.cpp @@ -367,13 +367,11 @@ namespace WXML } if (bittest(&v46, 0x16u)) // 0x16 -> 22 { - throw "not implement"; - // WXML::DOMLib::Token token(*(a5.end() - 1)); + auto v49 = a5.back(); a5.pop_back(); - - // ---- - // this->offset_4 = - // this->offset_5 = + this->offset_16 = v49.offset_8; + this->offset_20 = v49.offset_12; + this->offset_4 = v49.offset_16; } }while(bittest(&v46, 0x14u)); // 0x14 -> 20 diff --git a/src/wxml/dom_lib/parser.cpp b/src/wxml/dom_lib/parser.cpp index 776db52..4c4c3f3 100644 --- a/src/wxml/dom_lib/parser.cpp +++ b/src/wxml/dom_lib/parser.cpp @@ -100,7 +100,7 @@ namespace WXML // DOMS this->DOMS(); } - return ret == 0; + return ret; } std::shared_ptr Parser::GetParsed() diff --git a/src/wxml/dom_lib/wxml_dom.cpp b/src/wxml/dom_lib/wxml_dom.cpp index 16508d1..4ac6a89 100644 --- a/src/wxml/dom_lib/wxml_dom.cpp +++ b/src/wxml/dom_lib/wxml_dom.cpp @@ -252,7 +252,7 @@ namespace WXML { std::string const& a2, std::string& a3, std::stringstream & a4, - std::map &a5, + std::map &a5, WXML::DOMLib::RVMOpCodePositionRecorder *a6, bool a7, const std::map & a8 @@ -293,6 +293,7 @@ namespace WXML { } return; } + int RenderMeAsFunction_i = 0; void WXMLDom::RenderMeAsFunction( std::string const& a2, std::string const& a3, @@ -313,8 +314,10 @@ namespace WXML { std::string const& a18 ) { - try - { + RenderMeAsFunction_i++; + int inner_RenderMeAsFunction_i = RenderMeAsFunction_i; + // try + // { std::string name; a7->GetNextName(name); if (a15) @@ -371,11 +374,11 @@ namespace WXML { a6 << a13 << a14 << "[" << name << "]=false" << a13; } a6 << "return " << a11 << a13 << "}" << a13; - } - catch(const std::exception& e) - { - std::cerr << e.what() << '\n'; - } + // } + // catch(const std::exception& e) + // { + // std::cerr << e.what() << '\n'; + // } } diff --git a/test/wcc.disassembly.cpp b/test/wcc.disassembly.cpp index 88811e9..1c88aa5 100644 --- a/test/wcc.disassembly.cpp +++ b/test/wcc.disassembly.cpp @@ -11922,6 +11922,7 @@ std::ostream::sentry *__usercall WXML::Compiler::Compile@( char v328[4]; // [esp+4A8h] [ebp-170h] BYREF char v329[364]; // [esp+4ACh] [ebp-16Ch] BYREF + // Compile - 0 std::basic_stringstream,std::allocator>::basic_stringstream((int)v317); std::_Rb_tree_header::_Rb_tree_header(v287); std::_Rb_tree_header::_Rb_tree_header(v289); @@ -11951,7 +11952,7 @@ std::ostream::sentry *__usercall WXML::Compiler::Compile@( (int)v327, (WXML::DOMLib::Parser *)a1, *((char **)i + 10), - (int)a3, + (int)a3, // errorMessage (int)lpuexcpt, &v283); if ( v266 ) @@ -11959,7 +11960,7 @@ std::ostream::sentry *__usercall WXML::Compiler::Compile@( LABEL_25: WXML::DOMLib::Parser::~Parser((int)v327); std::vector::~vector((void **)&v283); - goto LABEL_118; + goto LABEL_118; // 销毁数据,返回v266 } WXML::DOMLib::Parser::GetParsed(&v323, (WXML::DOMLib::Parser *)v327); v20 = std::map>::operator[](&v286, (int)lpuexcpt); @@ -11973,7 +11974,7 @@ LABEL_25: v297[1] = 0; v298 = 0; std::basic_stringstream,std::allocator>::basic_stringstream((int)v320); - if ( v283 != v284 ) + if ( v283 != v284 ) // begin() != end() { v245 = std::operator<<>((std::ostream::sentry *)v321, "f_['"); WXML::Rewrite::ToStringCode((int)&v323, lpuexcpt); @@ -11985,18 +11986,23 @@ LABEL_25: } while ( (unsigned int)v266 < -1227133513 * (((char *)v284 - (char *)v283) >> 4) ) { - v299[1] = 0; - v304[0] = &v305; - a1 = a3; v299[0] = &v300; - v301 = (int)&v303; - v306 = (int)&v308; - v300 = 0; - v302 = 0; - v303 = 0; + v299[1] = 0; + + v304[0] = &v305; v304[1] = 0; - v305 = 0; + + a1 = a3; + + v301 = (int)&v303; + v302 = 0; + + v306 = (int)&v308; v307 = 0; + + v300 = 0; + v303 = 0; + v305 = 0; v308 = 0; v246 = WXML::Compiler::DealWxsTag( (int)lpuexcpt, @@ -12007,7 +12013,7 @@ LABEL_25: &v280, a3); if ( v246 ) - goto LABEL_21; + goto LABEL_21; // 销毁数据,返回v246 v23 = std::operator<<((std::ostream::sentry *)v321, a20); v247 = std::operator<<>(v23, "['"); WXML::Rewrite::ToStringCode((int)v316, lpuexcpt); @@ -12021,9 +12027,9 @@ LABEL_25: if ( v302 ) { MMBizWxaAppComm::PathCombine(lpuexcpt, &v301, (unsigned int *)&v306); - if ( *(_BYTE *)v306 == 47 ) + if ( *(_BYTE *)v306 == '/'/*47*/ ) { - std::operator+((int)&v309, 46, (int)&v306); + std::operator+((int)&v309, '.'/*46*/, (int)&v306); std::string::operator=((unsigned __int8 **)&v306, (int)&v309); std::string::_M_dispose((void **)&v309); } @@ -12039,6 +12045,7 @@ LABEL_25: std::operator<<>(v27, ":"); v28 = (std::ostream::sentry *)std::ostream::operator<<(v280); std::operator<<>(v28, ":"); + // int ** v283 v29 = (std::ostream::sentry *)std::ostream::operator<<(v283[28 * (_DWORD)v266 + 3]); v30 = std::operator<<>(v29, ":"); v31 = std::operator<<(v30, &v301); @@ -12058,7 +12065,7 @@ LABEL_21: std::string::_M_dispose((void **)v297); std::string::_M_dispose((void **)&v294); v266 = (std::ostream::sentry *)v246; - goto LABEL_25; + goto LABEL_25; // 销毁数据,返回v266 } } v249 = std::operator<<>((std::ostream::sentry *)v321, "f_['"); @@ -12103,7 +12110,7 @@ LABEL_21: { std::string::_M_assign((int)a3, (int)v297); std::string::_M_dispose((void **)&v309); - goto LABEL_21; + goto LABEL_21; // 销毁数据,返回v246 } v253 = std::operator<<>((std::ostream::sentry *)v321, "nv_require(\""); std::operator+((int)&v311, "m_", (int)lpuexcpt); @@ -12151,7 +12158,7 @@ LABEL_21: std::string::_M_dispose((void **)v316); if ( v267 ) { - v311 = (int)&v313; + v311 = (int)&v313; // std::string v312 = 0; v313 = 0; std::operator+((int)v327, "p_", (int)lpuexcpt); @@ -12170,7 +12177,7 @@ LABEL_21: std::string::_M_assign((int)a3, (int)&v311); std::string::_M_dispose((void **)v314); std::string::_M_dispose((void **)&v311); - goto LABEL_118; + goto LABEL_118; // 销毁数据,返回v266 } std::basic_stringstream,std::allocator>::basic_stringstream((int)v327); v268 = std::operator<<>((std::ostream::sentry *)v328, "f_['"); @@ -12199,6 +12206,7 @@ LABEL_21: } } } + // Compile - 5 if ( a7 ) std::string::basic_string((void **)&v323, "global"); else @@ -12220,6 +12228,7 @@ LABEL_21: std::operator<<>((std::ostream::sentry *)v318, "if(typeof __WXML_GLOBAL__ === 'undefined') {"); v61 = std::operator<<>((std::ostream::sentry *)v318, "__WXML_GLOBAL__={};"); std::operator<<>(v61, a10); + // Compile - 10 if ( (a9 & 0x80) != 0 ) { std::string::basic_string((void **)v327, "life_cycle_callback_content"); @@ -12247,6 +12256,7 @@ LABEL_21: v64 = std::operator<<>((std::ostream::sentry *)v318, "$gwx('init', global);"); std::operator<<>(v64, a10); } + // Compile - 15 v65 = std::operator<<>( (std::ostream::sentry *)v318, "function _(a,b){if(typeof(b)!='undefined')a.children.push(b);}"); @@ -12436,6 +12446,7 @@ LABEL_21: "}\n" "}\n"); std::operator<<>(v75, a10); + // Compile - 20 v76 = std::operator<<>( (std::ostream::sentry *)v318, "function _ca(o)\n" @@ -12595,6 +12606,7 @@ LABEL_21: "if ( typeof(c) != 'undefined' ) p.extraAttr.t_cid = c;\n" "}\n"); std::operator<<>(v79, a10); + // Compile - 25 if ( !a7 ) { v80 = std::operator<<>((std::ostream::sentry *)v318, "function _gv( )"); @@ -12619,6 +12631,7 @@ LABEL_21: ">(v84, a10); + // Compile - 30 std::operator<<>( (std::ostream::sentry *)v318, "function _gd(p,c,e,d){if(!c)return;if(d[p][c])return d[p][c];for(var x=e[p].i.length-1;x>=0;x--){if(e[p].i[x]&&d[e[p" @@ -12668,6 +12681,7 @@ LABEL_21: "or(var j=0;ch.children&&j>(v88, a10); + // Compile - 35 v89 = std::operator<<>( (std::ostream::sentry *)v318, "function _tsd( root )\n" @@ -12723,6 +12737,7 @@ LABEL_21: v109 = std::operator<<(v108, a16); v110 = std::operator<<>(v109, "={}"); std::operator<<>(v110, a10); + // Compile - 40 if ( (a9 & 2) != 0 ) { v111 = std::operator<<>((std::ostream::sentry *)v318, "var cs"); @@ -12736,19 +12751,20 @@ LABEL_21: break; WXML::DOMLib::WXMLDom::RewriteTree(*((_DWORD *)j + 10)); v260 = (std::ostream::sentry *)*((_DWORD *)v270 + 10); - std::string::basic_string((void **)v327, (char *)off_550B3F); + std::string::basic_string((void **)v327, (char *)off_550B3F); // "ALL" v113 = std::map>::operator[](a5, v327); WXML::DOMLib::WXMLDom::MarkIfHasDescendant((int)v260, v113); std::string::_M_dispose((void **)v327); if ( a7 ) { v261 = (std::ostream::sentry *)*((_DWORD *)v270 + 10); - std::string::basic_string((void **)v327, (char *)off_550B3F); + std::string::basic_string((void **)v327, (char *)off_550B3F); // "ALL" v114 = std::map>::operator[](a5, v327); WXML::DOMLib::WXMLDom::CutDomsForCustomComponent(v261, v114); std::string::_M_dispose((void **)v327); } } + // Compile - 45 v115 = std::operator<<>( (std::ostream::sentry *)v318, "__WXML_GLOBAL__.ops_cached = __WXML_GLOBAL__.ops_cached || {}"); @@ -12779,6 +12795,7 @@ LABEL_21: std::operator<<>(v124, a10); } v254 = 0; + // Compile - 50 for ( k = v288; k != (std::ostream::sentry *)v287; k = (std::ostream::sentry *)std::_Rb_tree_increment((int)k) ) { std::_Rb_tree_header::_Rb_tree_header(&v312); @@ -12840,6 +12857,7 @@ LABEL_21: std::basic_stringstream,std::allocator>::~basic_stringstream((int)v327); std::_Rb_tree,std::_Select1st>,std::less,std::allocator>>::~_Rb_tree((int)&v311); } + // Compile - 55 v143 = std::operator<<>((std::ostream::sentry *)v318, "__WXML_GLOBAL__.ops_set."); v144 = std::operator<<(v143, a8); v145 = std::operator<<>(v144, "=z;"); @@ -12870,6 +12888,7 @@ LABEL_21: std::operator<<>(v155, ","); std::string::_M_dispose((void **)v327); } + // Compile - 60 std::operator<<>((std::ostream::sentry *)v318, "};var nom={};return function(n){"); std::operator<<>( (std::ostream::sentry *)v318, @@ -12904,16 +12923,17 @@ LABEL_21: v159 = std::operator<<((std::ostream::sentry *)v318, n + 10); std::operator<<>(v159, a10); } + // Compile - 65 for ( ii = v288; ; ii = (std::ostream::sentry *)std::_Rb_tree_increment((int)v274) ) { v274 = ii; v263 = v281; if ( ii == (std::ostream::sentry *)v287 ) break; - std::string::basic_string((char *)v327, (int)ii + 16); + std::string::basic_string((char *)v327, (int)ii + 16); // first WXML::DOMLib::StrCache::Insert(v263, (int)v327); std::string::_M_dispose((void **)v327); - v161 = *((_DWORD *)v274 + 10); // v374 ii + v161 = *((_DWORD *)v274 + 10); // v274 ii second *(_DWORD *)(v161 + 248) = v281; std::__shared_count<(__gnu_cxx::_Lock_policy)2>::operator=((volatile signed __int32 **)(v161 + 252), v282); WXML::DOMLib::WXMLDom::RecordAllPath(*((_DWORD **)v274 + 10)); @@ -12925,16 +12945,17 @@ LABEL_21: while ( v264 != (std::ostream::sentry *)v287 ) { v162 = std::operator<<((std::ostream::sentry *)v318, a15); - std::operator<<>(v162, (char *)off_55101C); + std::operator<<>(v162, (char *)off_55101C); // "[x[" v275 = v281; v255 = (int *)((char *)v264 + 16); - std::string::basic_string((char *)v327, (int)v264 + 16); + std::string::basic_string((char *)v327, (int)v264 + 16); // first StrID = WXML::DOMLib::StrCache::GetStrID(v275, (int)v327); std::ostream::operator<<(StrID); std::string::_M_dispose((void **)v327); v164 = std::operator<<>((std::ostream::sentry *)v318, "]]={}"); std::operator<<>(v164, a10); std::string::basic_string((void **)v327, "get_page_z_name"); + // cur->second->offset_272["get_page_z_name"] v165 = std::map::operator[]((_DWORD *)(*((_DWORD *)v264 + 10) + 272), v327); v266 = WXML::Compiler::RenderDefine( (unsigned int **)v264 + 10, @@ -12945,7 +12966,7 @@ LABEL_21: (int)a6, v234, a9, - a10, + a10, // lineEndMark a11, a12, a13, @@ -12959,11 +12980,13 @@ LABEL_21: v165); std::string::_M_dispose((void **)v327); if ( v266 ) - goto LABEL_117; + goto LABEL_117; // 销毁数据,返回v266 std::basic_stringstream,std::allocator>::basic_stringstream((int)v327); - v314[0] = (int)&v315; + + v314[0] = (int)&v315; // std::string v314[1] = 0; v315 = 0; + std::operator<<>((std::ostream::sentry *)v328, "m"); v231 = v238 + 1; std::ostream::operator<<(v238); @@ -12999,10 +13022,10 @@ LABEL_21: { std::string::_M_dispose((void **)v314); std::basic_stringstream,std::allocator>::~basic_stringstream((int)v327); - goto LABEL_117; + goto LABEL_117; // 销毁数据,返回v266 } v166 = std::operator<<((std::ostream::sentry *)v318, a14); - std::operator<<>(v166, (char *)off_55101C); + std::operator<<>(v166, (char *)off_55101C); // "[x[" v240 = v281; std::string::basic_string((char *)v320, (int)v255); v167 = WXML::DOMLib::StrCache::GetStrID(v240, (int)v320); @@ -13023,7 +13046,7 @@ LABEL_21: { v235 = *(_DWORD *)(*(_DWORD *)(*((_DWORD *)v264 + 10) + 72) + 8 * (_DWORD)v256); v229 = (_DWORD *)(v235 + 52); - std::string::basic_string((void **)v320, (char *)off_547B7D); + std::string::basic_string((void **)v320, (char *)off_547B7D); // "src" v236 = std::_Rb_tree,std::_Select1st>,std::less,std::allocator>>::find( (_DWORD *)(v235 + 48), (int)v320); @@ -13035,7 +13058,7 @@ LABEL_21: std::operator<<>((std::ostream::sentry *)v318, "x["); v230 = v281; v237 = *(_DWORD *)(*(_DWORD *)(*((_DWORD *)v264 + 10) + 72) + 8 * (_DWORD)v256); - std::string::basic_string((void **)v316, (char *)off_547B7D); + std::string::basic_string((void **)v316, (char *)off_547B7D); // src v172 = std::_Rb_tree,std::_Select1st>,std::less,std::allocator>>::find( (_DWORD *)(v237 + 48), (int)v316); @@ -13062,7 +13085,7 @@ LABEL_21: { v242 = *(_DWORD *)(*(_DWORD *)(*((_DWORD *)v264 + 10) + 72) + 8 * (_DWORD)jj); v232 = (_DWORD *)(v242 + 52); - std::string::basic_string((void **)v320, (char *)off_547B7D); + std::string::basic_string((void **)v320, (char *)off_547B7D); // src v243 = std::_Rb_tree,std::_Select1st>,std::less,std::allocator>>::find( (_DWORD *)(v242 + 48), (int)v320); @@ -13096,6 +13119,7 @@ LABEL_21: v264 = (std::ostream::sentry *)std::_Rb_tree_increment((int)v264); v238 = v231; } + // Compile - 70 v181 = std::operator<<>((std::ostream::sentry *)v318, "if(path&&"); v182 = std::operator<<(v181, a14); v183 = std::operator<<>(v182, "[path]){"); @@ -13153,6 +13177,7 @@ LABEL_21: "console.log(path+': aenv:\\n'+JSON.stringify(env)+', '+JSON.stringify(dd))"); std::operator<<>(v199, a10); } + // Compile - 75 if ( (a9 & 0x80) != 0 ) { v200 = std::operator<<>((std::ostream::sentry *)v318, "if(__WXML_GLOBAL__."); @@ -13185,6 +13210,7 @@ LABEL_21: "6){return _ev(root);}"); std::operator<<>(v212, a10); } + // Compile - 80 v213 = std::operator<<>((std::ostream::sentry *)v318, "}catch(err){"); std::operator<<>(v213, a10); if ( (a9 & 2) != 0 ) @@ -13233,6 +13259,7 @@ LABEL_21: std::stringbuf::str((int)v327, (int)v319); std::string::operator=(a4, (int)v327); std::string::_M_dispose((void **)v327); + // Compile - 85 v266 = 0; LABEL_117: std::_Rb_tree,std::_Select1st>,std::less,std::allocator>>::~_Rb_tree((int)&v309); @@ -18984,11 +19011,11 @@ _DWORD *__fastcall night::NSASTParse::ast_for(int *a1) std::string::_M_dispose(v15); v7[57] = 0; v7[54] = 0; - std::string::basic_string(v15, (char *)&byte_551F04); + std::string::basic_string(v15, (char *)&byte_551F04); // '\0' std::string::basic_string(v14, "ast_expression"); std::string::basic_string(v13, ";"); std::string::basic_string(v12, (char *)&asc_5527F4[2]); - std::string::basic_string(v11, (char *)asc_5527F4); + std::string::basic_string(v11, (char *)asc_5527F4); // "(\000)\000{" v7[57] = night::NSASTParse::make_list_by_parser(a1, (int)v11, (int)v12, (int)v13, (int)v14, 0, 2, (int)v15); std::string::_M_dispose(v11); std::string::_M_dispose(v12); @@ -191583,8 +191610,8 @@ int main(int argc, const char **argv, const char **envp) v68 = (int)WXML::Compiler::Compile( v3, &v107, - (int *)v111, - (unsigned __int8 **)v113, + (int *)v111, // errpr + (unsigned __int8 **)v113, // result v126, &v105, v53, diff --git a/test/wcc.sh b/test/wcc.sh index 35418ed..21ef7b6 100644 --- a/test/wcc.sh +++ b/test/wcc.sh @@ -2,7 +2,7 @@ root_dir=$(cd `dirname $0`/.. && pwd -P) -cd /mnt/d/Work/WeChatProjects/miniprogram-demo/miniprogram +cd /mnt/d/Work/WeChatProjects/miniprogram-1 # list="cmd1 cmd2" # for cmd in $list; @@ -11,6 +11,6 @@ cd /mnt/d/Work/WeChatProjects/miniprogram-demo/miniprogram # /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="llw2.txt" -/root/github/wx-compiler/build/wcc "--config-path" "/mnt/d/Work/disassembly/wcc-exec/wcc/config/$filename" > /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/$filename" > /root/github/wx-compiler/test/wcc_win.json +filename="WeChatProjects/miniprogram-1/wcc/99a9bac3c05fc25dd070298212c4a7d3" +/root/github/wx-compiler/build/wcc "--config-path" "/mnt/d/Work/$filename" > /root/github/wx-compiler/test/wcc_linux.json +/mnt/d/Work/disassembly/wcc-exec/wcc/wcc.exe "--config-path" "d:/Work/$filename" > /root/github/wx-compiler/test/wcc_win.json