Skip to content

Commit 8cc9f1b

Browse files
committed
update: wcc compiler
1 parent 49d9077 commit 8cc9f1b

21 files changed

+718
-407
lines changed

compiler/nodejs/wcc

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env node
2-
// wcc.exe md5 = "0634f39da88890439a92351ce102efd9"
3-
const version = "20220424";
2+
// wcc.exe md5 = "33807bac814b4b639d98be3270bdc56c"
3+
const version = "20220426";
44
const { spawn } = require("child_process");
55
const path = require("path");
66
const fs = require("fs");
@@ -51,7 +51,7 @@ function parseDeps(source, x, pageConfig){
5151
dep
5252
)}\\]\\]={}\n[\\s\\S]*?e_\\[x\\[${x.indexOf(
5353
dep
54-
)}\\]\\]={f:m\\d+,j:\\[.*?\\],i:\\[.*?\\],ti:\\[(.*?)\\],ic:\\[.*?\\]}`;
54+
)}\\]\\]={f:m\\d+,j:\\[.*?\\],i:\\[.*?\\],ti:\\[(.*?)\\],ic:\\[.*?\\]}\n`;
5555

5656
let m0 = source.match(new RegExp(d_Exp));
5757
let m0_str = m0[0];
@@ -75,7 +75,8 @@ function parseDeps(source, x, pageConfig){
7575
new RegExp(`\\${funcName}\\_\\d+`, "g"),
7676
`${funcName}_${i}`
7777
)
78-
.replace(/m\d+/g, `m${i - 1}`).replace('={f', `=e_[x[${t_x.indexOf(dep)}]]||{f`) + "\n";
78+
.replace(/m\d+/g, `m${i - 1}`)
79+
// .replace('={f', `=e_[x[${t_x.indexOf(dep)}]]||{f`) + "\n";
7980
DEBUG_OUTPUT &&
8081
process.stderr.write("dep_d_: " + dep_d_ + "\n");
8182
let gz_name = m0_str.match(/var z=gz(.*?)\(\)/)[1];
@@ -168,7 +169,8 @@ function genFunctionContent_LLW(wxmlName, config = {}, source, x) {
168169
content += m0_str.replace(
169170
new RegExp(`\\${funcName}\\_\\d+`, "g"),
170171
`${config.funcName}_1`
171-
).replace('={f', `=e_[x[0]]||{f`);
172+
)
173+
// .replace('={f', `=e_[x[0]]||{f`);
172174

173175
// path
174176
content += `\u000aif(path&&e_[path]){\u000aouterGlobal.__wxml_comp_version__=0.02\u000areturn function(env,dd,global){$gwxc=0;var root={\u0022tag\u0022:\u0022wx-page\u0022};root.children=[]\u000a;g=\u0022${config.funcName}\u0022;var main=e_[path].f\u000acs=[]\u000aif (typeof global===\u0022undefined\u0022)global={};global.f=$gdc(f_[path],\u0022\u0022,1);\u000aif(typeof(outerGlobal.__webview_engine_version__)!='undefined'&&outerGlobal.__webview_engine_version__+1e-6>=0.02+1e-6&&outerGlobal.__mergeData__)\u000a{\u000aenv=outerGlobal.__mergeData__(env,dd);\u000a}\u000atry{\u000amain(env,{},root,global);\u000a_tsd(root)\u000aif(typeof(outerGlobal.__webview_engine_version__)=='undefined'|| outerGlobal.__webview_engine_version__+1e-6<0.01+1e-6){return _ev(root);}\u000a}catch(err){\u000aconsole.log(cs, env);\u000aconsole.log(err)\u000athrow err\u000a}\u000a;g=\u0022\u0022;\u000areturn root;\u000a}\u000a}\u000a}\u000a}`;
@@ -284,7 +286,8 @@ function genFunctionContent_LLA(wxmlName, config = {}, source, x) {
284286
content += `var x=['./${wxmlName}.wxml'`;
285287
if (!debugWXS && !hasDeps && !templateReg) {
286288
content += `];d_[x[0]]={}\u000a`;
287-
content += `var m0=function(e,s,r,gg){\u000avar z=gz${config.funcName}_1()\u000areturn r\u000a}\u000ae_[x[0]]=e_[x[0]]||{f:m0,j:[],i:[],ti:[],ic:[]}`;
289+
// e_[x[0]]||
290+
content += `var m0=function(e,s,r,gg){\u000avar z=gz${config.funcName}_1()\u000areturn r\u000a}\u000ae_[x[0]]={f:m0,j:[],i:[],ti:[],ic:[]}`;
288291
} else {
289292
// m0 --- m{num}
290293
const m0Exp = `var m${config.num}=function\\(e,s,r,gg\\){[\\s\\S]*e_\\[x\\[(\\d+)\\]\\]={f:m${config.num},j:\\[.*?\\],i:\\[.*?\\],ti:\\[(.*?)\\],ic:\\[.*?\\]}`;
@@ -311,7 +314,8 @@ function genFunctionContent_LLA(wxmlName, config = {}, source, x) {
311314
m0_str = m0_str.replace(
312315
new RegExp(`x\\[${config.num}\\]`, "g"),
313316
"x[0]"
314-
).replace('={f', '=e_[x[0]]||{f');
317+
)
318+
// .replace('={f', '=e_[x[0]]||{f');
315319
content += m0_str.replace(
316320
new RegExp(`\\${funcName}\\_\\d+`, "g"),
317321
`${config.funcName}_1`

compiler/test/wcc/lla/3/node_output.json

Lines changed: 5 additions & 5 deletions
Large diffs are not rendered by default.
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
无匹配
2+
------
3+
wxmlName: miniprogram_npm/miniprogram-barrage/index debugWXS: false, hasDeps: true, templateReg: false
4+
["./miniprogram_npm/miniprogram-barrage/index.wxml","./miniprogram_npm/miniprogram-recycle-view/recycle-item.wxml","./miniprogram_npm/miniprogram-recycle-view/recycle-view.wxml","./miniprogram_npm/wxml-to-canvas/index.wxml","./page/API/components/set-tab-bar/set-tab-bar.wxml","../../../common/head.wxml","../../../common/foot.wxml","./page/API/index.wxml","./page/cloud/index.wxml","./page/common/foot.wxml","./page/common/head.wxml","./page/component/index.wxml","./page/extend/index.wxml"] {"funcName":"$gwx_XC_0","num":0,"deps":[]}
5+
6+
无匹配
7+
------
8+
wxmlName: miniprogram_npm/miniprogram-recycle-view/recycle-item debugWXS: false, hasDeps: true, templateReg: false
9+
["./miniprogram_npm/miniprogram-barrage/index.wxml","./miniprogram_npm/miniprogram-recycle-view/recycle-item.wxml","./miniprogram_npm/miniprogram-recycle-view/recycle-view.wxml","./miniprogram_npm/wxml-to-canvas/index.wxml","./page/API/components/set-tab-bar/set-tab-bar.wxml","../../../common/head.wxml","../../../common/foot.wxml","./page/API/index.wxml","./page/cloud/index.wxml","./page/common/foot.wxml","./page/common/head.wxml","./page/component/index.wxml","./page/extend/index.wxml"] {"funcName":"$gwx_XC_1","num":1,"deps":[]}
10+
11+
无匹配
12+
------
13+
wxmlName: miniprogram_npm/miniprogram-recycle-view/recycle-view debugWXS: false, hasDeps: true, templateReg: false
14+
["./miniprogram_npm/miniprogram-barrage/index.wxml","./miniprogram_npm/miniprogram-recycle-view/recycle-item.wxml","./miniprogram_npm/miniprogram-recycle-view/recycle-view.wxml","./miniprogram_npm/wxml-to-canvas/index.wxml","./page/API/components/set-tab-bar/set-tab-bar.wxml","../../../common/head.wxml","../../../common/foot.wxml","./page/API/index.wxml","./page/cloud/index.wxml","./page/common/foot.wxml","./page/common/head.wxml","./page/component/index.wxml","./page/extend/index.wxml"] {"funcName":"$gwx_XC_2","num":2,"deps":[]}
15+
16+
无匹配
17+
------
18+
wxmlName: miniprogram_npm/wxml-to-canvas/index debugWXS: false, hasDeps: true, templateReg: false
19+
["./miniprogram_npm/miniprogram-barrage/index.wxml","./miniprogram_npm/miniprogram-recycle-view/recycle-item.wxml","./miniprogram_npm/miniprogram-recycle-view/recycle-view.wxml","./miniprogram_npm/wxml-to-canvas/index.wxml","./page/API/components/set-tab-bar/set-tab-bar.wxml","../../../common/head.wxml","../../../common/foot.wxml","./page/API/index.wxml","./page/cloud/index.wxml","./page/common/foot.wxml","./page/common/head.wxml","./page/component/index.wxml","./page/extend/index.wxml"] {"funcName":"$gwx_XC_3","num":3,"deps":[]}
20+
21+
无匹配
22+
------
23+
wxmlName: page/API/components/set-tab-bar/set-tab-bar debugWXS: false, hasDeps: true, templateReg: false
24+
["./miniprogram_npm/miniprogram-barrage/index.wxml","./miniprogram_npm/miniprogram-recycle-view/recycle-item.wxml","./miniprogram_npm/miniprogram-recycle-view/recycle-view.wxml","./miniprogram_npm/wxml-to-canvas/index.wxml","./page/API/components/set-tab-bar/set-tab-bar.wxml","../../../common/head.wxml","../../../common/foot.wxml","./page/API/index.wxml","./page/cloud/index.wxml","./page/common/foot.wxml","./page/common/head.wxml","./page/component/index.wxml","./page/extend/index.wxml"] {"funcName":"$gwx_XC_4","num":4,"deps":["./page/common/foot.wxml","./page/common/head.wxml"]}
25+
26+
无匹配
27+
------
28+
wxmlName: page/API/index debugWXS: false, hasDeps: true, templateReg: false
29+
["./miniprogram_npm/miniprogram-barrage/index.wxml","./miniprogram_npm/miniprogram-recycle-view/recycle-item.wxml","./miniprogram_npm/miniprogram-recycle-view/recycle-view.wxml","./miniprogram_npm/wxml-to-canvas/index.wxml","./page/API/components/set-tab-bar/set-tab-bar.wxml","../../../common/head.wxml","../../../common/foot.wxml","./page/API/index.wxml","./page/cloud/index.wxml","./page/common/foot.wxml","./page/common/head.wxml","./page/component/index.wxml","./page/extend/index.wxml"] {"funcName":"$gwx_XC_5","num":5,"deps":[]}
30+
31+
无匹配
32+
------
33+
wxmlName: page/cloud/index debugWXS: false, hasDeps: true, templateReg: false
34+
["./miniprogram_npm/miniprogram-barrage/index.wxml","./miniprogram_npm/miniprogram-recycle-view/recycle-item.wxml","./miniprogram_npm/miniprogram-recycle-view/recycle-view.wxml","./miniprogram_npm/wxml-to-canvas/index.wxml","./page/API/components/set-tab-bar/set-tab-bar.wxml","../../../common/head.wxml","../../../common/foot.wxml","./page/API/index.wxml","./page/cloud/index.wxml","./page/common/foot.wxml","./page/common/head.wxml","./page/component/index.wxml","./page/extend/index.wxml"] {"funcName":"$gwx_XC_6","num":6,"deps":[]}
35+
36+
无匹配
37+
------
38+
wxmlName: page/component/index debugWXS: false, hasDeps: true, templateReg: false
39+
["./miniprogram_npm/miniprogram-barrage/index.wxml","./miniprogram_npm/miniprogram-recycle-view/recycle-item.wxml","./miniprogram_npm/miniprogram-recycle-view/recycle-view.wxml","./miniprogram_npm/wxml-to-canvas/index.wxml","./page/API/components/set-tab-bar/set-tab-bar.wxml","../../../common/head.wxml","../../../common/foot.wxml","./page/API/index.wxml","./page/cloud/index.wxml","./page/common/foot.wxml","./page/common/head.wxml","./page/component/index.wxml","./page/extend/index.wxml"] {"funcName":"$gwx_XC_9","num":9,"deps":[]}
40+
41+
无匹配
42+
------
43+
wxmlName: page/extend/index debugWXS: false, hasDeps: true, templateReg: false
44+
["./miniprogram_npm/miniprogram-barrage/index.wxml","./miniprogram_npm/miniprogram-recycle-view/recycle-item.wxml","./miniprogram_npm/miniprogram-recycle-view/recycle-view.wxml","./miniprogram_npm/wxml-to-canvas/index.wxml","./page/API/components/set-tab-bar/set-tab-bar.wxml","../../../common/head.wxml","../../../common/foot.wxml","./page/API/index.wxml","./page/cloud/index.wxml","./page/common/foot.wxml","./page/common/head.wxml","./page/component/index.wxml","./page/extend/index.wxml"] {"funcName":"$gwx_XC_10","num":10,"deps":[]}
45+
46+
dep_d_: d_[x[0]]={}
47+
d_[x[0]]["foot"]=function(e,s,r,gg){
48+
var z=gz$gwx_1()
49+
var b=x[0]+':foot'
50+
r.wxVkey=b
51+
gg.f=$gdc(f_["./page/common/foot.wxml"],"",1)
52+
if(p_[b]){_wl(b,x[0]);return}
53+
p_[b]=true
54+
try{
55+
}catch(err){
56+
p_[b]=false
57+
throw err
58+
}
59+
p_[b]=false
60+
return r
61+
}
62+
var m0=function(e,s,r,gg){
63+
var z=gz$gwx_1()
64+
return r
65+
}
66+
e_[x[0]]={f:m0,j:[],i:[],ti:[],ic:[]}
67+
COMMON=====./page/common/foot.wxml----function gz\$gwx_8\(\)\{[\s\S]*?__WXML_GLOBAL__\.ops_cached\.\$gwx_8
68+
}
69+
dep_d_: d_[x[0]]={}
70+
d_[x[0]]["foot"]=function(e,s,r,gg){
71+
var z=gz$gwx_1()
72+
var b=x[0]+':foot'
73+
r.wxVkey=b
74+
gg.f=$gdc(f_["./page/common/foot.wxml"],"",1)
75+
if(p_[b]){_wl(b,x[0]);return}
76+
p_[b]=true
77+
try{
78+
}catch(err){
79+
p_[b]=false
80+
throw err
81+
}
82+
p_[b]=false
83+
return r
84+
}
85+
var m0=function(e,s,r,gg){
86+
var z=gz$gwx_1()
87+
return r
88+
}
89+
e_[x[0]]={f:m0,j:[],i:[],ti:[],ic:[]}d_[x[1]]={}
90+
d_[x[1]]["head"]=function(e,s,r,gg){
91+
var z=gz$gwx_2()
92+
var b=x[1]+':head'
93+
r.wxVkey=b
94+
gg.f=$gdc(f_["./page/common/head.wxml"],"",1)
95+
if(p_[b]){_wl(b,x[1]);return}
96+
p_[b]=true
97+
try{
98+
var oB=_v()
99+
_(r,oB)
100+
if(_oz(z,1,e,s,gg)){oB.wxVkey=1
101+
cs.push("./page/common/head.wxml:view:5:6")
102+
cs.pop()
103+
}
104+
oB.wxXCkey=1
105+
}catch(err){
106+
p_[b]=false
107+
throw err
108+
}
109+
p_[b]=false
110+
return r
111+
}
112+
var m1=function(e,s,r,gg){
113+
var z=gz$gwx_2()
114+
return r
115+
}
116+
e_[x[1]]={f:m1,j:[],i:[],ti:[],ic:[]}
117+
COMMON=====./page/common/head.wxml----function gz\$gwx_9\(\)\{[\s\S]*?__WXML_GLOBAL__\.ops_cached\.\$gwx_9
118+
}

compiler/test/wcc/lla/4/node_output.json

Lines changed: 35 additions & 39 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)