Modify by codeCheck

Signed-off-by: chenxun <chenxun@kaihong.com>
This commit is contained in:
chenxun 2023-07-18 09:42:53 +08:00
parent af0527a0d9
commit 39bdd0fe4d
42 changed files with 4090 additions and 120 deletions

File diff suppressed because one or more lines are too long

View File

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

4062
tools/circuit_viewer/dist/main.js vendored Normal file

File diff suppressed because it is too large Load Diff

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

Before

Width:  |  Height:  |  Size: 3.5 MiB

After

Width:  |  Height:  |  Size: 3.5 MiB

View File

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

View File

Before

Width:  |  Height:  |  Size: 3.4 MiB

After

Width:  |  Height:  |  Size: 3.4 MiB

View File

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

View File

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -61,7 +61,6 @@ class MainEditor {
reader.readAsDataURL(files[0]);
reader.onload = (e) => {
let ret = atob(e.target.result.split(",")[1]);
// ret = Buffer.from(e.target.result.split(",")[1], 'base64');
this.onLoad(files[0].name, ret);
}
}
@ -77,19 +76,13 @@ class MainEditor {
X2DFast.gi().drawText("拖入log文件", 30, Scr.logicw / 2, Scr.logich / 2, 1, 1, 0, -2, -2, 0xff000000);
return;
}
// X2DFast.gi().fillRect(0, 0, Scr.logicw, Scr.logich, 0xffffffff);
// X2DFast.gi().fillRect(0, 0, Scr.logicw/2, Scr.logich/2, 0x80c0c0ff);
// return;
// X2DFast.gi().fillRect(0, 0, Scr.logicw, Scr.logich, 0xffffffff);
for (let v in this.viewer_) {
if (this.filePoint_ == v) {
this.viewer_[v].onDraw();
}
}
// if (this.filePoint_ in this.files_) {
// let irList = this.files_[this.filePoint_]["b.abc"]["cxunmzadd"][0]["irList"];
// X2DFast.gi().drawRect(100, 100, 200, 200, 0xffff0000, 3);
// }
this.selectFile_.move(Scr.logicw - 200 - 10, 10, 200, 20);
this.selectFile_.draw();
if (XTools.PROC_TO > 0 && XTools.PROC_TO < 100) {
@ -115,7 +108,6 @@ class MainEditor {
}
onKey(k) {
// console.log(k);
for (let v in this.viewer_) {
if (this.filePoint_ == v) {
if (this.viewer_[v].onKey(k)) {

View File

@ -29,7 +29,7 @@ export class Scr {
Scr.logich = h;
Scr.width = w;
Scr.height = h;
// NapiLog.logError('setLogicScreenSize');
if ('undefined' != typeof wx) {
var info = wx.getSystemInfoSync();
Scr.width = info.windowWidth;

View File

@ -77,9 +77,7 @@ class XSelect {
if (i == this.tmpSelect_) {
this.pm2f_.fillRect(x, y + h + i * 20, w, 20, this.backgroundColor_ + 0x303030);
}
// if (this.list_[i] == this.default_) {
// this.pm2f_.fillRect(x, y + h + i * 20, w, 20, this.backgroundColor_);
// }
let name1 = '...';
if (this.list_[i].indexOf('\\') != -1) {
let list = this.list_[i].split('\\');

View File

@ -67,8 +67,8 @@ export class X2DFast {
gl.disable(gl.DEPTH_TEST);
gl.enable(gl.BLEND);
gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);//ONE_MINUS_SRC_ALPHA
// gl.blendEquation(gl.FUNC_SUBTRACT);//GL_FUNC_ADD、GL_FUNC_SUBTRACT、GL_FUNC_REVERSE_SUBTRACT、GL_MIN、GL_MAX和GL_LOGIC_OP
gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);// ONE_MINUS_SRC_ALPHA
// GL_FUNC_ADD、GL_FUNC_SUBTRACT、GL_FUNC_REVERSE_SUBTRACT、GL_MIN、GL_MAX和GL_LOGIC_OP
}
DrawCircle(ox, oy, rw, rh, c = 0xffffffff, lw = 1) {
@ -105,7 +105,7 @@ export class X2DFast {
linewidth,
fAngle(x2 - x1, y2 - y1),
0,
0,//+0.5
0,// +0.5
c
);
}

View File

@ -187,7 +187,6 @@ export class XTexture {
}
initTextImageData(s, size) {
this.textCtx.clearRect(0, 0, 1024, 256);
// this.textCtx.font = size + "px 'Microsoft YaHei'";
this.textCtx.font = size + "px '宋体'";
this.textCtx.fillStyle = 'rgba(255,255,255,1)';
this.textCtx.fillText(s, 1, 1);

View File

@ -50,7 +50,6 @@ function myTouch(msg, x, y) {
}
function myKey(type, code) {
// NapiLog.logError(type + code);
MainEditor.gi().onKey(code);
}

View File

@ -125,8 +125,6 @@ class IrToPicture {
}
}
// console.log(JSON.stringify(nodes,null,4));
let lines = [];
let lid = 0;
for (let i in nodes) {//生成连接线
@ -157,12 +155,8 @@ class IrToPicture {
}
}
// console.log(JSON.stringify(lines,null,4));
this.resetPicture(nodes, isBlock);
// console.log(JSON.stringify(nodes,null,4));
return {
nodes: nodes,
lines: lines,
@ -293,11 +287,7 @@ class IrToPicture {
}
}
collectDebug.push(enums);
// console.log(collectDebug.length,enums.length);
// if (collectDebug.length > 2000 || enums.length > 10000) {
// // console.log(JSON.stringify(collectDebug));
// break;
// }
enums = nextenums;
}
@ -352,11 +342,9 @@ class IrToPicture {
n[i].inh[l.fromId + l.lineType] = (inP + 1) * 5;
inP += 1;
}
// n[i].inh[j] = (inP + 1) * 5;
// inP += 1;
}
inCount += Object.keys(n[i].inh).length;
// inCount += n[i].in.length;
outCount += n[i].ltypes.length;
}
posy += (inCount + 1) * 5;
@ -373,9 +361,9 @@ class IrToPicture {
n[i].pos.y = posy;
outP += n[i].ltypes.length;
}
// posy += (n.length + 1) * 5 + IrViewer.NODEH;
posy += (outCount + 1) * 5 + this.NODEH;
// if (n.length > 1) {
let w = 0;
for (let i = 0; i < levels[k].length; i++) {//当前行总宽度
w += levels[k][i].nameWidth + 20;
@ -385,7 +373,6 @@ class IrToPicture {
levels[k][i].pos.x = x + 10;
x += levels[k][i].nameWidth + 20;
}
// }
}
}
}

View File

@ -143,9 +143,7 @@ class IrViewer {
for (let l of lines) {
let n1 = nodes[l.fromId];
let n2 = nodes[l.toId];
// if (n1.hide || n2.hide) {
// continue;
// }
let id1 = parseInt(n1.ir.id);
let id2 = parseInt(n2.ir.id);
let idx = -1;
@ -194,9 +192,7 @@ class IrViewer {
continue;
}
loadonce--;
// console.log("******************", method.type);
// method.irControl = IrViewer.toPicture(method.irList, 0);
// console.log("---------------------");
method.irAll = IrToPicture.toPicture(method.irList, 1, method.type.startsWith("block:"));
method.loaded = true;
}
@ -237,15 +233,7 @@ class IrViewer {
this.visable_ = this.direct_.irAll;
let nodes = this.visable_.nodes;
let lines = this.visable_.lines;
// for (let k in nodes) {
// let n = nodes[k];
// if (this.hideNodeIds_.indexOf(parseInt(n.ir.id)) >= 0) {
// n.hide = true;
// }
// else {
// n.hide = (n.mask & this.mask_) == 0;
// }
// }
let showNodes = [];
for (let k in nodes) {
let n = nodes[k];
@ -300,7 +288,6 @@ class IrViewer {
let sw = w / (x2 - x1);
let sh = h / (y2 - y1);
// [sw, sh] = [Math.min(sw, sh), Math.min(sw, sh)];
let dh = Math.max(20 * sh, 1);
for (let k in nodes) {//画节点
@ -317,7 +304,6 @@ class IrViewer {
dy += this.drapSelect_.dy;
}
X2DFast.gi().fillRect(tx + (dx - 3) * sw, ty + (dy - 10) * sh, dw, dh, 0xff000000);
// X2DFast.gi().drawRect(tx + (dx - 3) * sw, ty + (dy - 10) * sh, dw, dh, 0xff000000, 2);
}
else {
let selectWith = false;
@ -342,7 +328,6 @@ class IrViewer {
X2DFast.gi().fillRect(tx + (dx - 3) * sw, ty + (dy - 10) * sh, dw, dh, XTools.CONFIG.NodeColor[n.type]);
}
}
// X2DFast.gi().drawText(n.name, 14, dx + n.nameWidth / 2, dy + 2, 1, 1, 0, -2, -2, 0xff000000);
}
X2DFast.gi().drawRect(tx - (this.offx_ + x1) * sw, ty - (this.offy_ + y1) * sh, Math.min(Scr.logicw * sw, w), Math.min(Scr.logich * sh, h), 0xff00ff00, 1);
}
@ -449,12 +434,9 @@ class IrViewer {
if (y < 130) {
y = 130;
}
// let r = (IrViewer.COLOR[n.type] >> 16) & 0xff;
// let g = (IrViewer.COLOR[n.type] >> 8) & 0xff;
// let b = (IrViewer.COLOR[n.type]) & 0xff;
// X2DFast.gi().fillRect(x, y, w, h, (parseInt(r * r * r / 255 / 255) << 16) | (parseInt(g * g * g / 255 / 255) << 8) | parseInt(b * b * b / 255 / 255) | 0x80000000);
X2DFast.gi().fillRect(x, y, w, h, (XTools.CONFIG.NodeColor[n.type] & 0xffffff) | 0xC0000000);
// X2DFast.gi().fillRect(x, y, w, h, [r,g,b,0x80]);
for (let i = 0; i < n.ir.detailList.length; i++) {
X2DFast.gi().drawText(n.ir.detailList[i], 14, x + 1, y + 1 + i * 16, 1, 1, 0, -1, -1, 0xff000000);
}
@ -463,9 +445,6 @@ class IrViewer {
for (let btn of this.btnGo_) {
btn.draw();
}
// if (this.direct_.callerMethod) {
// X2DFast.gi().drawText("Caller Method:" + this.direct_.callerMethod, 14, 480, 40, 1, 1, 0, -1, -1, 0xff000000);
// }
let x1 = 9999;
let y1 = 9999;
@ -509,8 +488,6 @@ class IrViewer {
else {
this.offy_ = (-this.scrollY_.getBarOff()) * this.dragScoll.hh - this.dragScoll.y1;
this.offx_ = (-this.scrollX_.getBarOff()) * this.dragScoll.ww - this.dragScoll.x1;
// this.scrollY_.setBarOff(-(this.offy_ + this.dragScoll.y1) / this.dragScoll.hh);
// this.scrollX_.setBarOff(-(this.offx_ + this.dragScoll.x1) / this.dragScoll.ww);
}
if (this.dragScoll.hh > 1) this.scrollY_.move(Scr.logicw - 20, 100, 20, Scr.logich - 100 - 20).draw();
if (this.dragScoll.ww > 1) this.scrollX_.move(20, Scr.logich - 20, Scr.logicw - 40, 20).draw();
@ -523,18 +500,14 @@ class IrViewer {
let w = this.searchInput.pos[2];
let h = this.searchInput.pos[3];
X2DFast.gi().fillRect(x, y, w, h, 0x80000000);
// X2DFast.gi().drawRect(x + 28, y + 56 / 2 - 8, 100, 20, 0xffffffff);
// x = x + 16 + 290 + 16;
let searchResultTxt =
this.searchInput.result.length == 0
? '0/0'
: this.searchInput.point + 1 + '/' + this.searchInput.result.length;
// x += 16
// X2DFast.gi().fillRect(x, y + 56 / 2 - 8, 16, 16, 0xffffffff);
this.searchInput.btnUp.move(x + 20, y + 50, 32, 24).draw();
// x += 32 + 16;
X2DFast.gi().drawText(
searchResultTxt,
20,
@ -547,16 +520,12 @@ class IrViewer {
-2,
0xffffffff
) + 16;
// X2DFast.gi().fillRect(x, y + 56 / 2 - 8, 16, 16, 0xffffffff);
this.searchInput.btnDown.move(x + w - 20 - 32, y + 50, 32, 24).draw();
this.searchInput.btnClose.move(x + w - 40, y + 10, 30, 30).draw();
// x += 16 + 16;
// X2DFast.gi().fillRect(x, y + 56 / 2 - 8, 16, 16, 0xffffffff);
// this.searchInput.btnClose.move(x, y - 8, 16, 16).draw();
}
}
checkLevel(levely, n1, n2) {
// return n1.deep + 1 == n2.deep;
let i1 = levely.indexOf(n1.pos.y);
let i2 = levely.indexOf(n2.pos.y);
return i1 + 1 == i2;
@ -575,7 +544,7 @@ class IrViewer {
let lor = n1.pos.x + n2.pos.x < -50 ? 0 : 1;
if (this.checkLevel(levely, n1, n2)) { }
else {
if (!(n1.outh[l.outNum] in n1.outhx)) {//???
if (!(n1.outh[l.outNum] in n1.outhx)) {
mmx[lor] += lor == 0 ? aaa : -aaa;
n1.outhx[n1.outh[l.outNum]] = mmx[lor];
}
@ -590,11 +559,6 @@ class IrViewer {
continue;
}
// try {
// n1.ltypes.indexOf(l.lineType)
// } catch (e) {
// console.log("ee");
// }
let x1 = n1.pos.x + n1.nameWidth - 5 + offx - n1.ltypes.indexOf(l.lineType) * 5;
let y1 = n1.pos.y + 10 + offy;
let x2 = n2.pos.x + n2.nameWidth - 5 + offx - l.inNum * 5;
@ -615,11 +579,8 @@ class IrViewer {
}
}
}
// if (l.fromId == 1 && l.toId == 14) {
// console.log(1);
// }
if (select != selected) {
// if (n1.deep + 1 == n2.deep) { }
if (this.checkLevel(levely, n1, n2)) { }
else {
mmx[lor] += lor == 0 ? -aaa : aaa;
@ -641,15 +602,9 @@ class IrViewer {
ls.push([x2, y1 + n1.outh[l.outNum], x2, y2, c, lw]);
}
else {
if (y1 >= y2) {
// c = 0xff00ffff;
// lw = 3;
}
let lx = n1.outhx[n1.outh[l.outNum]];//n1.outhx[l.outNum] mmx[lor];
let ly = n2.inh[l.fromId + l.lineType];//n2.inh[l.inNum]; n2.inh[n1.ir.id]
// if (isNaN(ly)) {
// console.log("sdf");
// }
let lx = n1.outhx[n1.outh[l.outNum]];//n1.outhx[l.outNum] 或 mmx[lor]
let ly = n2.inh[l.fromId + l.lineType];//n2.inh[l.inNum] 或 n2.inh[n1.ir.id]
ls.push([x1, y1, x1, y1 + n1.outh[l.outNum], c, lw]);
ls.push([x1, y1 + n1.outh[l.outNum], lx, y1 + n1.outh[l.outNum], c, lw]);
ls.push([lx, y1 + n1.outh[l.outNum], lx, y2 - ly, c, lw]);
@ -689,15 +644,13 @@ class IrViewer {
else {
}
// X2DFast.gi().drawLine(x1, y1, x2, y2, c, lw);
return false;
}
locateNode(p) {
this.selectPoint_ = [parseInt(p)];
let nodes = this.visable_.nodes;
let n = nodes[p];
// let r = [n.pos.x + this.offx_ - 3, n.pos.y + this.offy_ - 10, n.nameWidth + 6, 20];
// console.log(r);
this.offx_ = Scr.logicw / 2 - n.pos.x;
this.offy_ = Scr.logich / 2 - n.pos.y;
this.scrollY_.setBarOff(-(this.offy_ + this.dragScoll.y1) / this.dragScoll.hh);
@ -812,11 +765,6 @@ class IrViewer {
}
}
return true;
} else {
// if (msg == 1) {
// // this.searchInput = null;
// }
// return true;
}
}
for (let i = this.btnGo_.length - 1; i >= 0; i--) {
@ -841,7 +789,6 @@ class IrViewer {
}
}
this.drapSelect_ = {
// levely: this.makeLevely(nodes),
x: x,
y: y,
dx: 0,
@ -920,12 +867,12 @@ class IrViewer {
for (let i in nodes) {
let n = nodes[i];
if (n.ir.op == "JS_BYTECODE") {
if (n.ir.id == v || n.ir.bytecode.indexOf(v) >= 0 || (isRegExp(v) && n.ir.bytecode.match(v))) {//㊣
if (n.ir.id == v || n.ir.bytecode.indexOf(v) >= 0 || (isRegExp(v) && n.ir.bytecode.match(v))) {
this.searchInput.result.push(i);
}
}
else {
if (n.ir.id == v || n.ir.op.indexOf(v) >= 0 || (isRegExp(v) && n.ir.op.match(v))) {//㊣
if (n.ir.id == v || n.ir.op.indexOf(v) >= 0 || (isRegExp(v) && n.ir.op.match(v))) {
this.searchInput.result.push(i);
}
}

View File

@ -38,12 +38,10 @@ class LogParser {
}
this.procNormal_ = null;
this.output_ = {};
// this.t1_ = Date.now();
}
parsing() {
if (this.lineNum_ >= this.logLines_.length) {
// let t2 = Date.now() - this.t1_;
return false;
}
@ -117,7 +115,6 @@ class LogParser {
file: tt2[1],//文件名
irList: [],
startLine: l,
// callerMethod: ret[3],
};
this.stat_ = 1;
[this.initBlock_.funcPoint, this.initBlock_.filePoint] = [tt2[0], tt2[tt2.length - 1]];
@ -191,14 +188,12 @@ class LogParser {
this.output_[this.procNormal_.file][this.procNormal_.func].push(this.procNormal_);
}
else {
NapiLog.logError("After和End之间没有指令(" + this.lineNum_ + "行)");//this.procNormal_.startLine
NapiLog.logError("After和End之间没有指令(" + this.lineNum_ + "行)");
}
this.stat_ = 0;
}
else {
NapiLog.logError("After和End之间解析失败(" + (this.lineNum_ + 1) + ")行");//+ l
// alert("After和End之间解析失败("+lineNum+")"+l);
// throw new Error("解析失败");
NapiLog.logError("After和End之间解析失败(" + (this.lineNum_ + 1) + ")行");
this.stat_ = 0;
}
}
@ -237,8 +232,6 @@ class LogParser {
if (xhr.status === 200) {
XTools.PORC_TO = 10;
cb(fn, xhr.responseText);
} else {
// console.error('Failed to load file');
}
}
};
@ -311,9 +304,6 @@ class LogParser {
return false;
}
if (!pb.oneBlock) {//完成了一个block的解析
// stat = 0;
// NapiLog.logError("parse block fail at line" + (lineNum + 1));
// lineNum -= 1;
if (!(pb.blockCollect.file in this.output_)) {
this.output_[pb.blockCollect.file] = {};
}
@ -382,9 +372,6 @@ class LogParser {
return false;
}
if (!pb.oneBlock) {//完成了一个block的解析
// stat = 0;
// NapiLog.logError("parse block fail at line" + (lineNum + 1));
// lineNum -= 1;
if (!(pb.blockCollect.file in this.output_)) {
this.output_[pb.blockCollect.file] = {};
}