6如上
作者 @淘汰郎 https://www.bandbbs.cn/threads/9536/
•index.bin 大小縮小>90% (77 kb -> 7 kb)
•大幅減少APP對手環RAM的使用量
•使用更快更流暢
•UI優化
源代碼 (僅作部份開源,有興趣可以自己去原帖買,只需2023 coins 哦 🙂 ):
JavaScript:/** * Build with ZMake tool */ // Build at 2022-08-08 16:53:06.368238 (() => { // source: /home/melianmiko/Projects/mb7_apps/calculator/src/Calculator.js class Calculator { buttons = []; screen = null; screenData = ""; currentSet = []; currentSetId = -1; buttonSets = [ ["7", "8", "9", "4", "5", "6", "1", "2", "3", "0", "."], ["+", "-", "×", "÷", "^", "√", "|", "=", "π", "(", ")"], ["x", "y", "z", "分數", "又", "分之", "", "", "", "", ""],]; operations = { "+": "+", "-": "-", "×": "×", "÷": "÷", "^": "^", "√": "√(", "∛": "∛(", "π": "π", "分數": "分數(", }; start() { // Init screen hmUI.createWidget(5, { x: 5, y: 80, w: 183, h: 76, radius: 8, line_width: 2, color: 0x222222 }); this.screen = hmUI.createWidget(2, { x: 11, y: 80, w: 172, h: 80, color: 0xc5c5c5, text_size: 24, text_style: 1, align_v: 16, }); this.screen.addEventListener(3, () => { this.backspace(); }); // Init buttons for (let i = 0; i < 12; i++) { this.buttons[i] = hmUI.createWidget(23, { x: (i % 3) * 64 + 2, y: Math.floor(i / 3) * 64 + 168, w: 60, h: 60, radius: 8, text_size: 28, normal_color: 0x222222, press_color: 0x333333, click_func: this.initButtonEvents(i), }); } this.buttons[11].setProperty(0, { x: 130, y: 360, w: 60, h: 60, text: "...", normal_color: 0x444444, press_color: 0x666666, }); this.switchSet(); hmUI.createWidget(5, { x: 5, y: 80, w: 183, h: 76, radius: 8, line_width: 2, color: 0x222222 }); this.screen = hmUI.createWidget(2, { x: 11, y: 80, w: 172, h: 80, color: 0xc5c5c5, text_size: 24, text_style: 1, align_v: 16, }); this.screen.addEventListener(3, () => { this.backspace(); }); // Init buttons for (let i = 0; i < 12; i++) { this.buttons[i] = hmUI.createWidget(23, { x: (i % 3) * 64 + 2, y: Math.floor(i / 3) * 64 + 168, w: 60, h: 60, radius: 8, text_size: 28, normal_color: 0x222222, press_color: 0x333333, click_func: this.initButtonEvents(i), }); } this.buttons[11].setProperty(0, { x: 130, y: 360, w: 60, h: 60, text: "...", normal_color: 0x444444, press_color: 0x666666, }); this.switchSet(); // Init remove and process buttons hmUI.createWidget(23, { x: 0, y: 426, w: 192, h: 65, text: "解方程式", normal_color: 0x222222, press_color: 0x444444, text_size: 28, click_func: () => { this.process(); } }); hmUI.createWidget(23, { x: 0, y: 0, w: 192, h: 70, text: "拉進垃圾車", text_size: 20, color: 0x999999, click_func: () => { this.clear(); } }); } calcFactorial(num) { if (num % 1 != 0 || num < 0) { num++; return Math.sqrt(2 * Math.PI / num) * Math.pow((1 / Math.E) * (num + 1 / (12 * num - 1 / (10 * num))), num); } else { return (num == 0) ? 1 : num * this.calcFactorial(num - 1); } } process() { let Error = false; const brDiff = this._countIncl(this.screenData, "(") - this._countIncl(this.screenData, ")"); if (brDiff === 0) { try { function solveEquation(equationString) { /* function not open source bytecode: /sdcard/index.js:181: function: solveEquation mode: strict args: equationString locals: 0: var Fraction 1: var parseNumber 2: var arr 3: catch error [level:3 next:4] 4: let unknownVariable [level:1 next:-1] 5: let tolerance [level:6 next:4] 6: let maxIterations [level:6 next:5] 7: let replacedEquationString [level:6 next:6] 8: let equation [level:6 next:7] 9: let leftHandSide [level:6 next:8] 10: let rightHandSide [level:6 next:9] 11: let equationFunction [level:6 next:10] 12: let ans [level:6 next:11] 13: let text [level:6 next:12] 14: let guess [level:6 next:13] 15: let i [level:7 next:14] 16: let f [level:8 next:15] 17: const parsedNumber [level:10 next:18] 18: let df [level:8 next:16] 19: var this 20: var new.target 21: var arguments closure vars: 0: solveEquation local:loc2 let 1: brDiff local:loc1 const 2: Error local:loc0 let 3: <class_fields_init> parent:loc0 const 4: Calculator parent:loc1 const 5: __$$module$$__ parent:loc2 let 6: __$$app$$__ parent:loc3 let 7: Calculator parent:loc4 let stack_size: 9 opcodes: 0 0C 03 special_object 3 2 C2 14 put_loc8 20: "new.target" 4 08 push_this 5 C2 13 put_loc8 19: this 7 0C 00 special_object 0 9 C2 15 put_loc8 21: arguments 11 BF 00 fclosure8 0: [bytecode Fraction] 13 C8 put_loc0 0: Fraction [definition of function Fraction(str)] */ function Fraction(str) { /* function not open source bytecode: /sdcard/index.js:182: function: Fraction mode: strict args: str locals: 0: let arr [level:7 next:-1] 1: let arr [level:11 next:-1] stack_size: 5 opcodes: 0 D0 get_arg0 0: str 1 98 typeof 2 04 48 00 00 00 push_atom_value string 7 AD strict_neq 8 E9 0B if_false8 20 10 D0 get_arg0 0: str 11 42 37 00 00 00 get_field2 toString 16 24 00 00 call_method 0 19 D4 put_arg0 0: str 20 BE 00 20: push_const8 0: 1"\u5206\u6570\\([^)]+\\)" 22 BE 01 push_const8 1: 1"\u0000\u0001\u00009\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u0006R\u0001pe\u0001(\u0000\u001c\u000c\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0002\u0000\u0000\u0000(\u0000*\u0000\u00ff\u00ff\n\u0001)\u0000\u000c\u0000\n" 24 33 regexp 25 42 82 01 00 00 get_field2 test 30 D0 get_arg0 0: str 31 24 01 00 call_method 1 34 E9 1C if_false8 63 36 38 BC 01 00 00 get_var hmUI 41 42 08 02 00 00 get_field2 showToast 46 0B object 47 04 09 02 00 00 push_atom_value "\u00e6\u00a0\u00bc\u00e5\u00bc\u008f\u00e4\u00b8\u008d\u00e7\u00ac\u00a6\u00e5\u0090\u0088\n\u00e5\u00b7\u00b2\u00e6\u0094\u00b9\u00e6\u0088\u00900" 52 4C D1 01 00 00 define_field text 57 24 01 00 call_method 1 60 0E drop 61 B4 push_0 0 62 28 return 63 BE 02 63: push_const8 2: 1"(^[\\s\\S]*)\u53c8([\\s\\S]*)\u5206\u4e4b([\\s\\S]*)" 65 BE 03 push_const8 3: 1"\u0000\u0004\u0000q\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u000b\u0001\u0005\u001c\u0008\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u0000\u0000\u0000\u00ff\u00ff\n\u000c\u0001\u0001\u00c8S\u000b\u0002\u001c\u0008\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u0000\u0000\u0000\u00ff\u00ff\n\u000c\u0002\u0001\u0006R\u0001KN\u000b\u0003\u001c\u0008\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u0000\u0000\u0000\u00ff\u00ff\n\u000c\u0003\u000c\u0000\n" 67 33 regexp 68 42 82 01 00 00 get_field2 test 73 D0 get_arg0 0: str 74 24 01 00 call_method 1 77 69 C2 00 00 00 if_false 272 82 61 00 00 set_loc_uninitialized 0: arr 85 D0 get_arg0 0: str 86 42 5C 00 00 00 get_field2 split 91 BE 04 push_const8 4: 1"\u53c8|\u5206\u4e4b" 93 BE 05 push_const8 5: 1"\u0000\u0001\u0000#\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0009\u0008\u0000\u0000\u0000\u0001\u00c8S\u0007\u0006\u0000\u0000\u0000\u0001\u0006R\u0001KN\u000c\u0000\n" 95 33 regexp 96 24 01 00 call_method 1 99 C8 put_loc0 0: arr 100 62 00 00 get_loc_check 0: arr 103 E8 get_length 104 B7 push_3 3 105 AD strict_neq 106 11 dup 107 EA 26 if_true8 146 109 0E drop 110 BE 06 push_const8 6: 1"\u53c8" 112 BE 07 push_const8 7: 1"\u0000\u0001\u0000\u0013\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u00c8S\u000c\u0000\n" 114 33 regexp 115 42 82 01 00 00 get_field2 test 120 D0 get_arg0 0: str 121 24 01 00 call_method 1 124 0A push_true 125 AD strict_neq 126 11 dup 127 EA 12 if_true8 146 129 0E drop 130 BE 08 push_const8 8: 1"\u5206\u4e4b" 132 BE 09 push_const8 9: 1"\u0000\u0001\u0000\u0016\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u0006R\u0001KN\u000c\u0000\n" 134 33 regexp 135 42 82 01 00 00 get_field2 test 140 D0 get_arg0 0: str 141 24 01 00 call_method 1 144 0A push_true 145 AD strict_neq 146 E9 1C 146: if_false8 175 148 38 BC 01 00 00 get_var hmUI 153 42 08 02 00 00 get_field2 showToast 158 0B object 159 04 09 02 00 00 push_atom_value "\u00e6\u00a0\u00bc\u00e5\u00bc\u008f\u00e4\u00b8\u008d\u00e7\u00ac\u00a6\u00e5\u0090\u0088\n\u00e5\u00b7\u00b2\u00e6\u0094\u00b9\u00e6\u0088\u00900" 164 4C D1 01 00 00 define_field text 169 24 01 00 call_method 1 172 0E drop 173 B4 push_0 0 174 28 return 175 38 A3 01 00 00 175: get_var console 180 42 A2 01 00 00 get_field2 log 185 04 DD 01 00 00 push_atom_value "(" 190 62 00 00 get_loc_check 0: arr 193 B4 push_0 0 194 47 get_array_el 195 9E add 196 04 0A 02 00 00 push_atom_value " + " 201 9E add 202 62 00 00 get_loc_check 0: arr 205 B6 push_2 2 206 47 get_array_el 207 9E add 208 04 0B 02 00 00 push_atom_value " / " 213 9E add 214 62 00 00 get_loc_check 0: arr 217 B5 push_1 1 218 47 get_array_el 219 9E add 220 04 DE 01 00 00 push_atom_value ")" 225 9E add 226 24 01 00 call_method 1 229 0E drop 230 04 DD 01 00 00 push_atom_value "(" 235 62 00 00 get_loc_check 0: arr 238 B4 push_0 0 239 47 get_array_el 240 9E add 241 04 0A 02 00 00 push_atom_value " + " 246 9E add 247 62 00 00 get_loc_check 0: arr 250 B6 push_2 2 251 47 get_array_el 252 04 0B 02 00 00 push_atom_value " / " 257 9E add 258 62 00 00 get_loc_check 0: arr 261 B5 push_1 1 262 47 get_array_el 263 9E add 264 9E add 265 04 DE 01 00 00 push_atom_value ")" 270 9E add 271 28 return 272 BE 0A 272: push_const8 10: 1"(^[\\s\\S]*)\u5206\u4e4b([\\s\\S]*)" 274 BE 0B push_const8 11: 1"\u0000\u0003\u0000Q\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u000b\u0001\u0005\u001c\u0008\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u0000\u0000\u0000\u00ff\u00ff\n\u000c\u0001\u0001\u0006R\u0001KN\u000b\u0002\u001c\u0008\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u0000\u0000\u0000\u00ff\u00ff\n\u000c\u0002\u000c\u0000\n" 276 33 regexp 277 42 82 01 00 00 get_field2 test 282 D0 get_arg0 0: str 283 24 01 00 call_method 1 286 69 96 00 00 00 if_false 437 291 61 01 00 set_loc_uninitialized 1: arr 294 D0 get_arg0 0: str 295 42 5C 00 00 00 get_field2 split 300 BE 0C push_const8 12: 1"\u5206\u4e4b" 302 BE 0D push_const8 13: 1"\u0000\u0001\u0000\u0016\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u0006R\u0001KN\u000c\u0000\n" 304 33 regexp 305 24 01 00 call_method 1 308 C9 put_loc1 1: arr 309 62 01 00 get_loc_check 1: arr 312 E8 get_length 313 B6 push_2 2 314 AD strict_neq 315 11 dup 316 EA 12 if_true8 335 318 0E drop 319 BE 0E push_const8 14: 1"\u5206\u4e4b" 321 BE 0F push_const8 15: 1"\u0000\u0001\u0000\u0016\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u0006R\u0001KN\u000c\u0000\n" 323 33 regexp 324 42 82 01 00 00 get_field2 test 329 D0 get_arg0 0: str 330 24 01 00 call_method 1 333 0A push_true 334 AD strict_neq 335 E9 1C 335: if_false8 364 337 38 BC 01 00 00 get_var hmUI 342 42 08 02 00 00 get_field2 showToast 347 0B object 348 04 09 02 00 00 push_atom_value "\u00e6\u00a0\u00bc\u00e5\u00bc\u008f\u00e4\u00b8\u008d\u00e7\u00ac\u00a6\u00e5\u0090\u0088\n\u00e5\u00b7\u00b2\u00e6\u0094\u00b9\u00e6\u0088\u00900" 353 4C D1 01 00 00 define_field text 358 24 01 00 call_method 1 361 0E drop 362 B4 push_0 0 363 28 return 364 38 A3 01 00 00 364: get_var console 369 42 A2 01 00 00 get_field2 log 374 04 DD 01 00 00 push_atom_value "(" 379 62 01 00 get_loc_check 1: arr 382 B5 push_1 1 383 47 get_array_el 384 9E add 385 04 0B 02 00 00 push_atom_value " / " 390 9E add 391 62 01 00 get_loc_check 1: arr 394 B4 push_0 0 395 47 get_array_el 396 9E add 397 04 DE 01 00 00 push_atom_value ")" 402 9E add 403 24 01 00 call_method 1 406 0E drop 407 04 DD 01 00 00 push_atom_value "(" 412 62 01 00 get_loc_check 1: arr 415 B5 push_1 1 416 47 get_array_el 417 9E add 418 04 0B 02 00 00 push_atom_value " / " 423 9E add 424 62 01 00 get_loc_check 1: arr 427 B4 push_0 0 428 47 get_array_el 429 9E add 430 04 DE 01 00 00 push_atom_value ")" 435 9E add 436 28 return 437 38 BC 01 00 00 437: get_var hmUI 442 42 08 02 00 00 get_field2 showToast 447 0B object 448 04 09 02 00 00 push_atom_value "\u00e6\u00a0\u00bc\u00e5\u00bc\u008f\u00e4\u00b8\u008d\u00e7\u00ac\u00a6\u00e5\u0090\u0088\n\u00e5\u00b7\u00b2\u00e6\u0094\u00b9\u00e6\u0088\u00900" 453 4C D1 01 00 00 define_field text 458 24 01 00 call_method 1 461 0E drop 462 B4 push_0 0 463 28 return */ } /* bytecode: 14 BF 01 fclosure8 1: [bytecode parseNumber] 16 C9 put_loc1 1: parseNumber [definition of function parseNumber(str)] */ function parseNumber(str) { /* function not open source bytecode: /sdcard/index.js:211: function: parseNumber mode: strict args: str locals: 0: const regex [level:1 next:-1] 1: const matches [level:1 next:0] 2: let integerPart [level:5 next:1] 3: let decimalPart [level:5 next:2] stack_size: 4 opcodes: 0 61 01 00 set_loc_uninitialized 1: matches 3 61 00 00 set_loc_uninitialized 0: regex 6 D0 get_arg0 0: str 7 98 typeof 8 04 46 00 00 00 push_atom_value number 13 AC strict_eq 14 E9 0B if_false8 26 16 D0 get_arg0 0: str 17 42 37 00 00 00 get_field2 toString 22 24 00 00 call_method 0 25 D4 put_arg0 0: str 26 BE 00 26: push_const8 0: 1"^(-?\\d+)(\\.\\d+)?$" 28 BE 01 push_const8 1: 1"\u0000\u0003\u0000l\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0005\u000b\u0001\u001c\u0004\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u0001-\u0000\n\u001c\u0008\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u00000\u00009\u0000\n\u000c\u0001\u000d\u0002\u0002\u0009 \u0000\u0000\u0000\u000b\u0002\u0001.\u0000\u001c\u0008\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u00000\u00009\u0000\n\u000c\u0002\u0006\u000c\u0000\n" 30 33 regexp 31 C8 put_loc0 0: regex 32 D0 get_arg0 0: str 33 42 22 01 00 00 get_field2 match 38 62 00 00 get_loc_check 0: regex 41 24 01 00 call_method 1 44 C9 put_loc1 1: matches 45 62 01 00 get_loc_check 1: matches 48 E9 60 if_false8 145 50 61 03 00 set_loc_uninitialized 3: decimalPart 53 61 02 00 set_loc_uninitialized 2: integerPart 56 62 01 00 get_loc_check 1: matches 59 B5 push_1 1 60 47 get_array_el 61 CA put_loc2 2: integerPart 62 62 01 00 get_loc_check 1: matches 65 B6 push_2 2 66 47 get_array_el 67 CB put_loc3 3: decimalPart 68 62 03 00 get_loc_check 3: decimalPart 71 E9 1D if_false8 101 73 62 03 00 get_loc_check 3: decimalPart 76 42 28 01 00 00 get_field2 replace 81 BE 02 push_const8 2: 1"^\\." 83 BE 03 push_const8 3: 1"\u0000\u0001\u0000\u0014\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0005\u0001.\u0000\u000c\u0000\n" 85 33 regexp 86 04 0E 02 00 00 push_atom_value "0." 91 24 02 00 call_method 2 94 11 dup 95 63 03 00 put_loc_check 3: decimalPart 98 0E drop 99 EB 0B goto8 111 101 04 0F 02 00 00 101: push_atom_value "0.0" 106 11 dup 107 63 03 00 put_loc_check 3: decimalPart 110 0E drop 111 0B 111: object 112 62 02 00 get_loc_check 2: integerPart 115 42 37 00 00 00 get_field2 toString 120 24 00 00 call_method 0 123 4C FE 01 00 00 define_field integerPart 128 62 03 00 get_loc_check 3: decimalPart 131 42 37 00 00 00 get_field2 toString 136 24 00 00 call_method 0 139 4C 00 02 00 00 define_field decimalPart 144 28 return 145 D0 145: get_arg0 0: str 146 28 return */ } /* 17 61 04 00 set_loc_uninitialized 4: unknownVariable 20 6C 23 00 00 00 catch 56 25 D0 get_arg0 0: equationString 26 42 22 01 00 00 get_field2 match 31 BE 02 push_const8 2: 1"[a-zA-Z]+" 33 BE 03 push_const8 3: 1"\u0001\u0001\u0000-\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u001c\u000c\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0002\u0000A\u0000Z\u0000a\u0000z\u0000\n\u000c\u0000\n" 35 33 regexp 36 24 01 00 call_method 1 39 42 EE 00 00 00 get_field2 reduce 44 BF 04 fclosure8 4: [bytecode <null>] 46 26 00 00 array_from 0 49 24 02 00 call_method 2 52 CA put_loc2 2: arr 53 0E drop 54 EB 0B goto8 66 56 CB 56: put_loc3 3: error 57 6C 07 00 00 00 catch 65 62 0E drop 63 EB 02 goto8 66 65 2F 65: throw 66 C6 66: get_loc2 2: arr 67 B4 push_0 0 68 47 get_array_el 69 C2 04 put_loc8 4: unknownVariable 71 C6 get_loc2 2: arr 72 E8 get_length 73 B5 push_1 1 74 AC strict_eq 75 69 67 02 00 00 if_false 691 80 61 0E 00 set_loc_uninitialized 14: guess 83 61 0D 00 set_loc_uninitialized 13: text 86 61 0C 00 set_loc_uninitialized 12: ans 89 61 0B 00 set_loc_uninitialized 11: equationFunction 92 61 0A 00 set_loc_uninitialized 10: rightHandSide 95 61 09 00 set_loc_uninitialized 9: leftHandSide 98 61 08 00 set_loc_uninitialized 8: equation 101 61 07 00 set_loc_uninitialized 7: replacedEquationString 104 61 06 00 set_loc_uninitialized 6: maxIterations 107 61 05 00 set_loc_uninitialized 5: tolerance 110 BE 05 push_const8 5: 1e-08 112 C2 05 put_loc8 5: tolerance 114 BD 10 27 push_i16 10000 117 C2 06 put_loc8 6: maxIterations 119 D0 get_arg0 0: equationString 120 42 28 01 00 00 get_field2 replace 125 BE 06 push_const8 6: 1"(\\d|\\))(\\(|[a-z]|\u03c0|\u5206\u6578)" 127 BE 07 push_const8 7: 1"\u0001\u0003\u0000]\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u000b\u0001\u0009\u000c\u0000\u0000\u0000\u0015\u0001\u00000\u00009\u0000\u0007\u0003\u0000\u0000\u0000\u0001)\u0000\u000c\u0001\u000b\u0002\u0009&\u0000\u0000\u0000\u0009\u0019\u0000\u0000\u0000\u0009\u0008\u0000\u0000\u0000\u0001(\u0000\u0007\u0007\u0000\u0000\u0000\u0015\u0001\u0000a\u0000z\u0000\u0007\u0003\u0000\u0000\u0000\u0001\u00c0\u0003\u0007\u0006\u0000\u0000\u0000\u0001\u0006R\u0001xe\u000c\u0002\u000c\u0000\n" 129 33 regexp 130 04 F3 01 00 00 push_atom_value "$1*$2" 135 24 02 00 call_method 2 138 42 28 01 00 00 get_field2 replace 143 BE 08 push_const8 8: 1"\\^" 145 BE 09 push_const8 9: 1"\u0001\u0001\u0000\u0013\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001^\u0000\u000c\u0000\n" 147 33 regexp 148 04 F4 01 00 00 push_atom_value "**" 153 24 02 00 call_method 2 156 42 28 01 00 00 get_field2 replace 161 BE 0A push_const8 10: 1"\u00d7" 163 BE 0B push_const8 11: 1"\u0001\u0001\u0000\u0013\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u00d7\u0000\u000c\u0000\n" 165 33 regexp 166 04 7C 00 00 00 push_atom_value "*" 171 24 02 00 call_method 2 174 42 28 01 00 00 get_field2 replace 179 BE 0C push_const8 12: 1"\u00f7" 181 BE 0D push_const8 13: 1"\u0001\u0001\u0000\u0013\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u00f7\u0000\u000c\u0000\n" 183 33 regexp 184 04 F5 01 00 00 push_atom_value "/" 189 24 02 00 call_method 2 192 42 28 01 00 00 get_field2 replace 197 BE 0E push_const8 14: 1"\u03c0" 199 BE 0F push_const8 15: 1"\u0001\u0001\u0000\u0013\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u00c0\u0003\u000c\u0000\n" 201 33 regexp 202 04 F6 01 00 00 push_atom_value "3.14" 207 24 02 00 call_method 2 210 42 28 01 00 00 get_field2 replace 215 BE 10 push_const8 16: 1"\\|([^|]+)\\|" 217 BE 11 push_const8 17: 1"\u0001\u0002\u00007\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001|\u0000\u000b\u0001\u001c\u000c\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0002\u0000\u0000\u0000{\u0000}\u0000\u00ff\u00ff\n\u000c\u0001\u0001|\u0000\u000c\u0000\n" 219 33 regexp 220 04 F7 01 00 00 push_atom_value "(Math.abs($1))" 225 24 02 00 call_method 2 228 42 28 01 00 00 get_field2 replace 233 BE 12 push_const8 18: 1"\u221a\\(([^)]+)\\)" 235 BE 13 push_const8 19: 1"\u0001\u0002\u0000:\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u001a\"\u0001(\u0000\u000b\u0001\u001c\u000c\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0002\u0000\u0000\u0000(\u0000*\u0000\u00ff\u00ff\n\u000c\u0001\u0001)\u0000\u000c\u0000\n" 237 33 regexp 238 04 F8 01 00 00 push_atom_value "(Math.sqrt($1))" 243 24 02 00 call_method 2 246 42 28 01 00 00 get_field2 replace 251 BE 14 push_const8 20: 1"\u5206\u6578\\(([^)]+)\\)" 253 BE 15 push_const8 21: 1"\u0001\u0002\u0000=\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u0006R\u0001xe\u0001(\u0000\u000b\u0001\u001c\u000c\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0002\u0000\u0000\u0000(\u0000*\u0000\u00ff\u00ff\n\u000c\u0001\u0001)\u0000\u000c\u0000\n" 255 33 regexp 256 BF 16 fclosure8 22: [bytecode <null>] 258 24 02 00 call_method 2 261 C2 07 put_loc8 7: replacedEquationString 263 38 A3 01 00 00 get_var console 268 42 A2 01 00 00 get_field2 log 273 62 07 00 get_loc_check 7: replacedEquationString 276 24 01 00 call_method 1 279 0E drop 280 62 07 00 get_loc_check 7: replacedEquationString 283 42 28 01 00 00 get_field2 replace 288 BE 17 push_const8 23: 1"\\s" 290 BE 18 push_const8 24: 1"\u0001\u0001\u0000;\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0015\n\u0000\u0009\u0000\u000d\u0000 \u0000 \u0000\u00a0\u0000\u00a0\u0000\u0080\u0016\u0080\u0016\u0000 \n ( ) / / _ _ \u00000\u00000\u00ff\u00fe\u00ff\u00fe\u000c\u0000\n" 292 33 regexp 293 C0 push_empty_string 294 24 02 00 call_method 2 297 C2 08 put_loc8 8: equation 299 62 08 00 get_loc_check 8: equation 302 42 5C 00 00 00 get_field2 split 307 04 F9 01 00 00 push_atom_value "=" 312 24 01 00 call_method 1 315 B4 push_0 0 316 47 get_array_el 317 C2 09 put_loc8 9: leftHandSide 319 62 08 00 get_loc_check 8: equation 322 42 5C 00 00 00 get_field2 split 327 04 F9 01 00 00 push_atom_value "=" 332 24 01 00 call_method 1 335 B5 push_1 1 336 47 get_array_el 337 C2 0A put_loc8 10: rightHandSide 339 38 3A 00 00 00 get_var eval 344 04 DD 01 00 00 push_atom_value "(" 349 42 5B 00 00 00 get_field2 concat 354 62 04 00 get_loc_check 4: unknownVariable 357 04 FA 01 00 00 push_atom_value ") => " 362 62 09 00 get_loc_check 9: leftHandSide 365 04 FB 01 00 00 push_atom_value " - (" 370 62 0A 00 get_loc_check 10: rightHandSide 373 04 DE 01 00 00 push_atom_value ")" 378 24 06 00 call_method 6 381 31 01 00 0F 00 eval 1,15 386 C2 0B put_loc8 11: equationFunction 388 C0 push_empty_string 389 C2 0C put_loc8 12: ans 391 06 undefined 392 C2 0D put_loc8 13: text 394 B5 push_1 1 395 C2 0E put_loc8 14: guess 397 61 0F 00 set_loc_uninitialized 15: i 400 B4 push_0 0 401 C2 0F put_loc8 15: i 403 62 0F 00 403: get_loc_check 15: i 406 62 06 00 get_loc_check 6: maxIterations 409 A4 lt 410 69 F8 00 00 00 if_false 659 415 61 12 00 set_loc_uninitialized 18: df 418 61 10 00 set_loc_uninitialized 16: f 421 62 0B 00 get_loc_check 11: equationFunction 424 62 0E 00 get_loc_check 14: guess 427 EE call1 1 428 C2 10 put_loc8 16: f 430 38 96 00 00 00 get_var Math 435 42 FC 01 00 00 get_field2 abs 440 62 10 00 get_loc_check 16: f 443 24 01 00 call_method 1 446 62 05 00 get_loc_check 5: tolerance 449 A4 lt 450 69 92 00 00 00 if_false 597 455 61 11 00 set_loc_uninitialized 17: parsedNumber 458 C5 get_loc1 1: parseNumber 459 62 0E 00 get_loc_check 14: guess 462 EE call1 1 463 C2 11 put_loc8 17: parsedNumber 465 38 A3 01 00 00 get_var console 470 42 A2 01 00 00 get_field2 log 475 04 FD 01 00 00 push_atom_value "\u00e6\u0095\u00b4\u00e6\u0095\u00b0\u00e9\u0083\u00a8\u00e5\u0088\u0086:" 480 62 11 00 get_loc_check 17: parsedNumber 483 41 FE 01 00 00 get_field integerPart 488 24 02 00 call_method 2 491 0E drop 492 38 A3 01 00 00 get_var console 497 42 A2 01 00 00 get_field2 log 502 04 FF 01 00 00 push_atom_value "\u00e5\u00b0\u008f\u00e6\u0095\u00b0\u00e9\u0083\u00a8\u00e5\u0088\u0086:" 507 62 11 00 get_loc_check 17: parsedNumber 510 41 00 02 00 00 get_field decimalPart 515 42 37 00 00 00 get_field2 toString 520 24 00 00 call_method 0 523 42 26 01 00 00 get_field2 substr 528 B4 push_0 0 529 BC 0A push_i8 10 531 24 02 00 call_method 2 534 24 02 00 call_method 2 537 0E drop 538 38 96 00 00 00 get_var Math 543 42 01 02 00 00 get_field2 round 548 62 0E 00 get_loc_check 14: guess 551 01 80 96 98 00 push_i32 10000000 556 9B mul 557 24 01 00 call_method 1 560 01 80 96 98 00 push_i32 10000000 565 9C div 566 11 dup 567 63 0D 00 put_loc_check 13: text 570 0E drop 571 04 02 02 00 00 push_atom_value "\u00e6\u0096\u00b9\u00e7\u00a8\u008b\u00e7\u009a\u0084\u00e8\u00a7\u00a3\u00e4\u00b8\u00ba\u00ef\u00bc\u009a\n" 576 62 04 00 get_loc_check 4: unknownVariable 579 9E add 580 04 03 02 00 00 push_atom_value " = " 585 9E add 586 62 0D 00 get_loc_check 13: text 589 9E add 590 11 dup 591 63 0C 00 put_loc_check 12: ans 594 0E drop 595 EB 3F goto8 659 597 62 0B 00 597: get_loc_check 11: equationFunction 600 62 0E 00 get_loc_check 14: guess 603 BE 19 push_const8 25: 1e-13 605 9E add 606 EE call1 1 607 62 10 00 get_loc_check 16: f 610 9F sub 611 BE 1A push_const8 26: 1e-13 613 9C div 614 C2 12 put_loc8 18: df 616 62 0E 00 get_loc_check 14: guess 619 62 10 00 get_loc_check 16: f 622 62 12 00 get_loc_check 18: df 625 9C div 626 9F sub 627 11 dup 628 63 0E 00 put_loc_check 14: guess 631 0E drop 632 38 A3 01 00 00 get_var console 637 42 A2 01 00 00 get_field2 log 642 62 0F 00 get_loc_check 15: i 645 92 post_inc 646 63 0F 00 put_loc_check 15: i 649 62 0E 00 get_loc_check 14: guess 652 24 02 00 call_method 2 655 0E drop 656 EC 02 FF goto16 403 659 38 A3 01 00 00 659: get_var console 664 42 A2 01 00 00 get_field2 log 669 62 0C 00 get_loc_check 12: ans 672 24 01 00 call_method 1 675 0E drop 676 62 0C 00 get_loc_check 12: ans 679 E9 05 if_false8 685 681 62 0C 00 get_loc_check 12: ans 684 28 return 685 04 04 02 00 00 685: push_atom_value "\u00e6\u009c\u00aa\u00e8\u0083\u00bd\u00e6\u0089\u00be\u00e5\u0088\u00b0\u00e6\u0096\u00b9\u00e7\u00a8\u008b\u00e7\u009a\u0084\u00e8\u00a7\u00a3" 690 28 return 691 C6 691: get_loc2 2: arr 692 E8 get_length 693 B4 push_0 0 694 AC strict_eq 695 E9 07 if_false8 703 697 04 05 02 00 00 push_atom_value "\u00e6\u00b2\u0092\u00e6\u009c\u0089\u00e6\u009c\u00aa\u00e7\u009f\u00a5\u00e6\u0095\u00b8" 702 28 return 703 04 06 02 00 00 703: push_atom_value "\u00e7\u009b\u00a1\u00e8\u00ab\u008b\u00e6\u009c\u009f\u00e5\u00be\u0085" 708 28 return */ } this.screen.setProperty(hmUI.prop.MORE, { text: solveEquation(this.screenData), }); Error = true; //this.screenData = "方程式的解为:"+ JSON.stringify(result) } catch (e) { this.screen.setProperty(hmUI.prop.MORE, { text: "請先檢査方程式", }); Error = true; } } else { for (let i = 0; i < brDiff; i++) this.screenData += ")"; } if (Error == false) this.updateScreen(); } _countIncl(str, chr) { let c = 0; for (let i in str) if (str[i] === chr) c++; return c; } switchSet() { const newId = (this.currentSetId + 1) % this.buttonSets.length; const newSet = this.buttonSets[newId]; for (let i = 0; i < newSet.length; i++) { this.buttons[i].setProperty(hmUI.prop.TEXT, newSet[i]); } this.currentSetId = newId; this.currentSet = newSet; } initButtonEvents(i) { return () => { if (i == 11) return this.switchSet(); let val = this.currentSet[i]; if (this.operations[val]) val = this.operations[val]; this.appendScreen(val); while (this.currentSetId != 0) this.switchSet(); }; } appendScreen(val) { this.screenData += val; this.updateScreen(); } updateScreen() { this.screen.setProperty(hmUI.prop.MORE, { text: this.screenData, }); } clear() { this.screenData = ""; this.updateScreen(); } backspace() { let delchar = 1 this.screenData = this.screenData.substring(0, this.screenData.length - delchar); this.updateScreen(); } } // source: /home/melianmiko/Projects/mb7_apps/calculator/entrypoint.js let __$$app$$__ = __$$hmAppManager$$__.currentApp; let __$$module$$__ = __$$app$$__.current; __$$module$$__.module = DeviceRuntimeCore.Page({ onInit() { hmUI.setLayerScrolling(false); new Calculator() .start(); }, }); })();
66如上
作者 @淘汰郎 https://www.bandbbs.cn/threads/9536/
•index.bin 大小縮小>90% (77 kb -> 7 kb)
•大幅減少APP對手環RAM的使用量
•使用更快更流暢
•UI優化
源代碼 (僅作部份開源,有興趣可以自己去原帖買,只需2023 coins 哦 🙂 ):
JavaScript:/** * Build with ZMake tool */ // Build at 2022-08-08 16:53:06.368238 (() => { // source: /home/melianmiko/Projects/mb7_apps/calculator/src/Calculator.js class Calculator { buttons = []; screen = null; screenData = ""; currentSet = []; currentSetId = -1; buttonSets = [ ["7", "8", "9", "4", "5", "6", "1", "2", "3", "0", "."], ["+", "-", "×", "÷", "^", "√", "|", "=", "π", "(", ")"], ["x", "y", "z", "分數", "又", "分之", "", "", "", "", ""],]; operations = { "+": "+", "-": "-", "×": "×", "÷": "÷", "^": "^", "√": "√(", "∛": "∛(", "π": "π", "分數": "分數(", }; start() { // Init screen hmUI.createWidget(5, { x: 5, y: 80, w: 183, h: 76, radius: 8, line_width: 2, color: 0x222222 }); this.screen = hmUI.createWidget(2, { x: 11, y: 80, w: 172, h: 80, color: 0xc5c5c5, text_size: 24, text_style: 1, align_v: 16, }); this.screen.addEventListener(3, () => { this.backspace(); }); // Init buttons for (let i = 0; i < 12; i++) { this.buttons[i] = hmUI.createWidget(23, { x: (i % 3) * 64 + 2, y: Math.floor(i / 3) * 64 + 168, w: 60, h: 60, radius: 8, text_size: 28, normal_color: 0x222222, press_color: 0x333333, click_func: this.initButtonEvents(i), }); } this.buttons[11].setProperty(0, { x: 130, y: 360, w: 60, h: 60, text: "...", normal_color: 0x444444, press_color: 0x666666, }); this.switchSet(); hmUI.createWidget(5, { x: 5, y: 80, w: 183, h: 76, radius: 8, line_width: 2, color: 0x222222 }); this.screen = hmUI.createWidget(2, { x: 11, y: 80, w: 172, h: 80, color: 0xc5c5c5, text_size: 24, text_style: 1, align_v: 16, }); this.screen.addEventListener(3, () => { this.backspace(); }); // Init buttons for (let i = 0; i < 12; i++) { this.buttons[i] = hmUI.createWidget(23, { x: (i % 3) * 64 + 2, y: Math.floor(i / 3) * 64 + 168, w: 60, h: 60, radius: 8, text_size: 28, normal_color: 0x222222, press_color: 0x333333, click_func: this.initButtonEvents(i), }); } this.buttons[11].setProperty(0, { x: 130, y: 360, w: 60, h: 60, text: "...", normal_color: 0x444444, press_color: 0x666666, }); this.switchSet(); // Init remove and process buttons hmUI.createWidget(23, { x: 0, y: 426, w: 192, h: 65, text: "解方程式", normal_color: 0x222222, press_color: 0x444444, text_size: 28, click_func: () => { this.process(); } }); hmUI.createWidget(23, { x: 0, y: 0, w: 192, h: 70, text: "拉進垃圾車", text_size: 20, color: 0x999999, click_func: () => { this.clear(); } }); } calcFactorial(num) { if (num % 1 != 0 || num < 0) { num++; return Math.sqrt(2 * Math.PI / num) * Math.pow((1 / Math.E) * (num + 1 / (12 * num - 1 / (10 * num))), num); } else { return (num == 0) ? 1 : num * this.calcFactorial(num - 1); } } process() { let Error = false; const brDiff = this._countIncl(this.screenData, "(") - this._countIncl(this.screenData, ")"); if (brDiff === 0) { try { function solveEquation(equationString) { /* function not open source bytecode: /sdcard/index.js:181: function: solveEquation mode: strict args: equationString locals: 0: var Fraction 1: var parseNumber 2: var arr 3: catch error [level:3 next:4] 4: let unknownVariable [level:1 next:-1] 5: let tolerance [level:6 next:4] 6: let maxIterations [level:6 next:5] 7: let replacedEquationString [level:6 next:6] 8: let equation [level:6 next:7] 9: let leftHandSide [level:6 next:8] 10: let rightHandSide [level:6 next:9] 11: let equationFunction [level:6 next:10] 12: let ans [level:6 next:11] 13: let text [level:6 next:12] 14: let guess [level:6 next:13] 15: let i [level:7 next:14] 16: let f [level:8 next:15] 17: const parsedNumber [level:10 next:18] 18: let df [level:8 next:16] 19: var this 20: var new.target 21: var arguments closure vars: 0: solveEquation local:loc2 let 1: brDiff local:loc1 const 2: Error local:loc0 let 3: <class_fields_init> parent:loc0 const 4: Calculator parent:loc1 const 5: __$$module$$__ parent:loc2 let 6: __$$app$$__ parent:loc3 let 7: Calculator parent:loc4 let stack_size: 9 opcodes: 0 0C 03 special_object 3 2 C2 14 put_loc8 20: "new.target" 4 08 push_this 5 C2 13 put_loc8 19: this 7 0C 00 special_object 0 9 C2 15 put_loc8 21: arguments 11 BF 00 fclosure8 0: [bytecode Fraction] 13 C8 put_loc0 0: Fraction [definition of function Fraction(str)] */ function Fraction(str) { /* function not open source bytecode: /sdcard/index.js:182: function: Fraction mode: strict args: str locals: 0: let arr [level:7 next:-1] 1: let arr [level:11 next:-1] stack_size: 5 opcodes: 0 D0 get_arg0 0: str 1 98 typeof 2 04 48 00 00 00 push_atom_value string 7 AD strict_neq 8 E9 0B if_false8 20 10 D0 get_arg0 0: str 11 42 37 00 00 00 get_field2 toString 16 24 00 00 call_method 0 19 D4 put_arg0 0: str 20 BE 00 20: push_const8 0: 1"\u5206\u6570\\([^)]+\\)" 22 BE 01 push_const8 1: 1"\u0000\u0001\u00009\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u0006R\u0001pe\u0001(\u0000\u001c\u000c\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0002\u0000\u0000\u0000(\u0000*\u0000\u00ff\u00ff\n\u0001)\u0000\u000c\u0000\n" 24 33 regexp 25 42 82 01 00 00 get_field2 test 30 D0 get_arg0 0: str 31 24 01 00 call_method 1 34 E9 1C if_false8 63 36 38 BC 01 00 00 get_var hmUI 41 42 08 02 00 00 get_field2 showToast 46 0B object 47 04 09 02 00 00 push_atom_value "\u00e6\u00a0\u00bc\u00e5\u00bc\u008f\u00e4\u00b8\u008d\u00e7\u00ac\u00a6\u00e5\u0090\u0088\n\u00e5\u00b7\u00b2\u00e6\u0094\u00b9\u00e6\u0088\u00900" 52 4C D1 01 00 00 define_field text 57 24 01 00 call_method 1 60 0E drop 61 B4 push_0 0 62 28 return 63 BE 02 63: push_const8 2: 1"(^[\\s\\S]*)\u53c8([\\s\\S]*)\u5206\u4e4b([\\s\\S]*)" 65 BE 03 push_const8 3: 1"\u0000\u0004\u0000q\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u000b\u0001\u0005\u001c\u0008\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u0000\u0000\u0000\u00ff\u00ff\n\u000c\u0001\u0001\u00c8S\u000b\u0002\u001c\u0008\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u0000\u0000\u0000\u00ff\u00ff\n\u000c\u0002\u0001\u0006R\u0001KN\u000b\u0003\u001c\u0008\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u0000\u0000\u0000\u00ff\u00ff\n\u000c\u0003\u000c\u0000\n" 67 33 regexp 68 42 82 01 00 00 get_field2 test 73 D0 get_arg0 0: str 74 24 01 00 call_method 1 77 69 C2 00 00 00 if_false 272 82 61 00 00 set_loc_uninitialized 0: arr 85 D0 get_arg0 0: str 86 42 5C 00 00 00 get_field2 split 91 BE 04 push_const8 4: 1"\u53c8|\u5206\u4e4b" 93 BE 05 push_const8 5: 1"\u0000\u0001\u0000#\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0009\u0008\u0000\u0000\u0000\u0001\u00c8S\u0007\u0006\u0000\u0000\u0000\u0001\u0006R\u0001KN\u000c\u0000\n" 95 33 regexp 96 24 01 00 call_method 1 99 C8 put_loc0 0: arr 100 62 00 00 get_loc_check 0: arr 103 E8 get_length 104 B7 push_3 3 105 AD strict_neq 106 11 dup 107 EA 26 if_true8 146 109 0E drop 110 BE 06 push_const8 6: 1"\u53c8" 112 BE 07 push_const8 7: 1"\u0000\u0001\u0000\u0013\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u00c8S\u000c\u0000\n" 114 33 regexp 115 42 82 01 00 00 get_field2 test 120 D0 get_arg0 0: str 121 24 01 00 call_method 1 124 0A push_true 125 AD strict_neq 126 11 dup 127 EA 12 if_true8 146 129 0E drop 130 BE 08 push_const8 8: 1"\u5206\u4e4b" 132 BE 09 push_const8 9: 1"\u0000\u0001\u0000\u0016\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u0006R\u0001KN\u000c\u0000\n" 134 33 regexp 135 42 82 01 00 00 get_field2 test 140 D0 get_arg0 0: str 141 24 01 00 call_method 1 144 0A push_true 145 AD strict_neq 146 E9 1C 146: if_false8 175 148 38 BC 01 00 00 get_var hmUI 153 42 08 02 00 00 get_field2 showToast 158 0B object 159 04 09 02 00 00 push_atom_value "\u00e6\u00a0\u00bc\u00e5\u00bc\u008f\u00e4\u00b8\u008d\u00e7\u00ac\u00a6\u00e5\u0090\u0088\n\u00e5\u00b7\u00b2\u00e6\u0094\u00b9\u00e6\u0088\u00900" 164 4C D1 01 00 00 define_field text 169 24 01 00 call_method 1 172 0E drop 173 B4 push_0 0 174 28 return 175 38 A3 01 00 00 175: get_var console 180 42 A2 01 00 00 get_field2 log 185 04 DD 01 00 00 push_atom_value "(" 190 62 00 00 get_loc_check 0: arr 193 B4 push_0 0 194 47 get_array_el 195 9E add 196 04 0A 02 00 00 push_atom_value " + " 201 9E add 202 62 00 00 get_loc_check 0: arr 205 B6 push_2 2 206 47 get_array_el 207 9E add 208 04 0B 02 00 00 push_atom_value " / " 213 9E add 214 62 00 00 get_loc_check 0: arr 217 B5 push_1 1 218 47 get_array_el 219 9E add 220 04 DE 01 00 00 push_atom_value ")" 225 9E add 226 24 01 00 call_method 1 229 0E drop 230 04 DD 01 00 00 push_atom_value "(" 235 62 00 00 get_loc_check 0: arr 238 B4 push_0 0 239 47 get_array_el 240 9E add 241 04 0A 02 00 00 push_atom_value " + " 246 9E add 247 62 00 00 get_loc_check 0: arr 250 B6 push_2 2 251 47 get_array_el 252 04 0B 02 00 00 push_atom_value " / " 257 9E add 258 62 00 00 get_loc_check 0: arr 261 B5 push_1 1 262 47 get_array_el 263 9E add 264 9E add 265 04 DE 01 00 00 push_atom_value ")" 270 9E add 271 28 return 272 BE 0A 272: push_const8 10: 1"(^[\\s\\S]*)\u5206\u4e4b([\\s\\S]*)" 274 BE 0B push_const8 11: 1"\u0000\u0003\u0000Q\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u000b\u0001\u0005\u001c\u0008\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u0000\u0000\u0000\u00ff\u00ff\n\u000c\u0001\u0001\u0006R\u0001KN\u000b\u0002\u001c\u0008\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u0000\u0000\u0000\u00ff\u00ff\n\u000c\u0002\u000c\u0000\n" 276 33 regexp 277 42 82 01 00 00 get_field2 test 282 D0 get_arg0 0: str 283 24 01 00 call_method 1 286 69 96 00 00 00 if_false 437 291 61 01 00 set_loc_uninitialized 1: arr 294 D0 get_arg0 0: str 295 42 5C 00 00 00 get_field2 split 300 BE 0C push_const8 12: 1"\u5206\u4e4b" 302 BE 0D push_const8 13: 1"\u0000\u0001\u0000\u0016\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u0006R\u0001KN\u000c\u0000\n" 304 33 regexp 305 24 01 00 call_method 1 308 C9 put_loc1 1: arr 309 62 01 00 get_loc_check 1: arr 312 E8 get_length 313 B6 push_2 2 314 AD strict_neq 315 11 dup 316 EA 12 if_true8 335 318 0E drop 319 BE 0E push_const8 14: 1"\u5206\u4e4b" 321 BE 0F push_const8 15: 1"\u0000\u0001\u0000\u0016\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u0006R\u0001KN\u000c\u0000\n" 323 33 regexp 324 42 82 01 00 00 get_field2 test 329 D0 get_arg0 0: str 330 24 01 00 call_method 1 333 0A push_true 334 AD strict_neq 335 E9 1C 335: if_false8 364 337 38 BC 01 00 00 get_var hmUI 342 42 08 02 00 00 get_field2 showToast 347 0B object 348 04 09 02 00 00 push_atom_value "\u00e6\u00a0\u00bc\u00e5\u00bc\u008f\u00e4\u00b8\u008d\u00e7\u00ac\u00a6\u00e5\u0090\u0088\n\u00e5\u00b7\u00b2\u00e6\u0094\u00b9\u00e6\u0088\u00900" 353 4C D1 01 00 00 define_field text 358 24 01 00 call_method 1 361 0E drop 362 B4 push_0 0 363 28 return 364 38 A3 01 00 00 364: get_var console 369 42 A2 01 00 00 get_field2 log 374 04 DD 01 00 00 push_atom_value "(" 379 62 01 00 get_loc_check 1: arr 382 B5 push_1 1 383 47 get_array_el 384 9E add 385 04 0B 02 00 00 push_atom_value " / " 390 9E add 391 62 01 00 get_loc_check 1: arr 394 B4 push_0 0 395 47 get_array_el 396 9E add 397 04 DE 01 00 00 push_atom_value ")" 402 9E add 403 24 01 00 call_method 1 406 0E drop 407 04 DD 01 00 00 push_atom_value "(" 412 62 01 00 get_loc_check 1: arr 415 B5 push_1 1 416 47 get_array_el 417 9E add 418 04 0B 02 00 00 push_atom_value " / " 423 9E add 424 62 01 00 get_loc_check 1: arr 427 B4 push_0 0 428 47 get_array_el 429 9E add 430 04 DE 01 00 00 push_atom_value ")" 435 9E add 436 28 return 437 38 BC 01 00 00 437: get_var hmUI 442 42 08 02 00 00 get_field2 showToast 447 0B object 448 04 09 02 00 00 push_atom_value "\u00e6\u00a0\u00bc\u00e5\u00bc\u008f\u00e4\u00b8\u008d\u00e7\u00ac\u00a6\u00e5\u0090\u0088\n\u00e5\u00b7\u00b2\u00e6\u0094\u00b9\u00e6\u0088\u00900" 453 4C D1 01 00 00 define_field text 458 24 01 00 call_method 1 461 0E drop 462 B4 push_0 0 463 28 return */ } /* bytecode: 14 BF 01 fclosure8 1: [bytecode parseNumber] 16 C9 put_loc1 1: parseNumber [definition of function parseNumber(str)] */ function parseNumber(str) { /* function not open source bytecode: /sdcard/index.js:211: function: parseNumber mode: strict args: str locals: 0: const regex [level:1 next:-1] 1: const matches [level:1 next:0] 2: let integerPart [level:5 next:1] 3: let decimalPart [level:5 next:2] stack_size: 4 opcodes: 0 61 01 00 set_loc_uninitialized 1: matches 3 61 00 00 set_loc_uninitialized 0: regex 6 D0 get_arg0 0: str 7 98 typeof 8 04 46 00 00 00 push_atom_value number 13 AC strict_eq 14 E9 0B if_false8 26 16 D0 get_arg0 0: str 17 42 37 00 00 00 get_field2 toString 22 24 00 00 call_method 0 25 D4 put_arg0 0: str 26 BE 00 26: push_const8 0: 1"^(-?\\d+)(\\.\\d+)?$" 28 BE 01 push_const8 1: 1"\u0000\u0003\u0000l\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0005\u000b\u0001\u001c\u0004\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u0001-\u0000\n\u001c\u0008\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u00000\u00009\u0000\n\u000c\u0001\u000d\u0002\u0002\u0009 \u0000\u0000\u0000\u000b\u0002\u0001.\u0000\u001c\u0008\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u00000\u00009\u0000\n\u000c\u0002\u0006\u000c\u0000\n" 30 33 regexp 31 C8 put_loc0 0: regex 32 D0 get_arg0 0: str 33 42 22 01 00 00 get_field2 match 38 62 00 00 get_loc_check 0: regex 41 24 01 00 call_method 1 44 C9 put_loc1 1: matches 45 62 01 00 get_loc_check 1: matches 48 E9 60 if_false8 145 50 61 03 00 set_loc_uninitialized 3: decimalPart 53 61 02 00 set_loc_uninitialized 2: integerPart 56 62 01 00 get_loc_check 1: matches 59 B5 push_1 1 60 47 get_array_el 61 CA put_loc2 2: integerPart 62 62 01 00 get_loc_check 1: matches 65 B6 push_2 2 66 47 get_array_el 67 CB put_loc3 3: decimalPart 68 62 03 00 get_loc_check 3: decimalPart 71 E9 1D if_false8 101 73 62 03 00 get_loc_check 3: decimalPart 76 42 28 01 00 00 get_field2 replace 81 BE 02 push_const8 2: 1"^\\." 83 BE 03 push_const8 3: 1"\u0000\u0001\u0000\u0014\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0005\u0001.\u0000\u000c\u0000\n" 85 33 regexp 86 04 0E 02 00 00 push_atom_value "0." 91 24 02 00 call_method 2 94 11 dup 95 63 03 00 put_loc_check 3: decimalPart 98 0E drop 99 EB 0B goto8 111 101 04 0F 02 00 00 101: push_atom_value "0.0" 106 11 dup 107 63 03 00 put_loc_check 3: decimalPart 110 0E drop 111 0B 111: object 112 62 02 00 get_loc_check 2: integerPart 115 42 37 00 00 00 get_field2 toString 120 24 00 00 call_method 0 123 4C FE 01 00 00 define_field integerPart 128 62 03 00 get_loc_check 3: decimalPart 131 42 37 00 00 00 get_field2 toString 136 24 00 00 call_method 0 139 4C 00 02 00 00 define_field decimalPart 144 28 return 145 D0 145: get_arg0 0: str 146 28 return */ } /* 17 61 04 00 set_loc_uninitialized 4: unknownVariable 20 6C 23 00 00 00 catch 56 25 D0 get_arg0 0: equationString 26 42 22 01 00 00 get_field2 match 31 BE 02 push_const8 2: 1"[a-zA-Z]+" 33 BE 03 push_const8 3: 1"\u0001\u0001\u0000-\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u001c\u000c\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0002\u0000A\u0000Z\u0000a\u0000z\u0000\n\u000c\u0000\n" 35 33 regexp 36 24 01 00 call_method 1 39 42 EE 00 00 00 get_field2 reduce 44 BF 04 fclosure8 4: [bytecode <null>] 46 26 00 00 array_from 0 49 24 02 00 call_method 2 52 CA put_loc2 2: arr 53 0E drop 54 EB 0B goto8 66 56 CB 56: put_loc3 3: error 57 6C 07 00 00 00 catch 65 62 0E drop 63 EB 02 goto8 66 65 2F 65: throw 66 C6 66: get_loc2 2: arr 67 B4 push_0 0 68 47 get_array_el 69 C2 04 put_loc8 4: unknownVariable 71 C6 get_loc2 2: arr 72 E8 get_length 73 B5 push_1 1 74 AC strict_eq 75 69 67 02 00 00 if_false 691 80 61 0E 00 set_loc_uninitialized 14: guess 83 61 0D 00 set_loc_uninitialized 13: text 86 61 0C 00 set_loc_uninitialized 12: ans 89 61 0B 00 set_loc_uninitialized 11: equationFunction 92 61 0A 00 set_loc_uninitialized 10: rightHandSide 95 61 09 00 set_loc_uninitialized 9: leftHandSide 98 61 08 00 set_loc_uninitialized 8: equation 101 61 07 00 set_loc_uninitialized 7: replacedEquationString 104 61 06 00 set_loc_uninitialized 6: maxIterations 107 61 05 00 set_loc_uninitialized 5: tolerance 110 BE 05 push_const8 5: 1e-08 112 C2 05 put_loc8 5: tolerance 114 BD 10 27 push_i16 10000 117 C2 06 put_loc8 6: maxIterations 119 D0 get_arg0 0: equationString 120 42 28 01 00 00 get_field2 replace 125 BE 06 push_const8 6: 1"(\\d|\\))(\\(|[a-z]|\u03c0|\u5206\u6578)" 127 BE 07 push_const8 7: 1"\u0001\u0003\u0000]\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u000b\u0001\u0009\u000c\u0000\u0000\u0000\u0015\u0001\u00000\u00009\u0000\u0007\u0003\u0000\u0000\u0000\u0001)\u0000\u000c\u0001\u000b\u0002\u0009&\u0000\u0000\u0000\u0009\u0019\u0000\u0000\u0000\u0009\u0008\u0000\u0000\u0000\u0001(\u0000\u0007\u0007\u0000\u0000\u0000\u0015\u0001\u0000a\u0000z\u0000\u0007\u0003\u0000\u0000\u0000\u0001\u00c0\u0003\u0007\u0006\u0000\u0000\u0000\u0001\u0006R\u0001xe\u000c\u0002\u000c\u0000\n" 129 33 regexp 130 04 F3 01 00 00 push_atom_value "$1*$2" 135 24 02 00 call_method 2 138 42 28 01 00 00 get_field2 replace 143 BE 08 push_const8 8: 1"\\^" 145 BE 09 push_const8 9: 1"\u0001\u0001\u0000\u0013\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001^\u0000\u000c\u0000\n" 147 33 regexp 148 04 F4 01 00 00 push_atom_value "**" 153 24 02 00 call_method 2 156 42 28 01 00 00 get_field2 replace 161 BE 0A push_const8 10: 1"\u00d7" 163 BE 0B push_const8 11: 1"\u0001\u0001\u0000\u0013\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u00d7\u0000\u000c\u0000\n" 165 33 regexp 166 04 7C 00 00 00 push_atom_value "*" 171 24 02 00 call_method 2 174 42 28 01 00 00 get_field2 replace 179 BE 0C push_const8 12: 1"\u00f7" 181 BE 0D push_const8 13: 1"\u0001\u0001\u0000\u0013\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u00f7\u0000\u000c\u0000\n" 183 33 regexp 184 04 F5 01 00 00 push_atom_value "/" 189 24 02 00 call_method 2 192 42 28 01 00 00 get_field2 replace 197 BE 0E push_const8 14: 1"\u03c0" 199 BE 0F push_const8 15: 1"\u0001\u0001\u0000\u0013\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u00c0\u0003\u000c\u0000\n" 201 33 regexp 202 04 F6 01 00 00 push_atom_value "3.14" 207 24 02 00 call_method 2 210 42 28 01 00 00 get_field2 replace 215 BE 10 push_const8 16: 1"\\|([^|]+)\\|" 217 BE 11 push_const8 17: 1"\u0001\u0002\u00007\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001|\u0000\u000b\u0001\u001c\u000c\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0002\u0000\u0000\u0000{\u0000}\u0000\u00ff\u00ff\n\u000c\u0001\u0001|\u0000\u000c\u0000\n" 219 33 regexp 220 04 F7 01 00 00 push_atom_value "(Math.abs($1))" 225 24 02 00 call_method 2 228 42 28 01 00 00 get_field2 replace 233 BE 12 push_const8 18: 1"\u221a\\(([^)]+)\\)" 235 BE 13 push_const8 19: 1"\u0001\u0002\u0000:\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u001a\"\u0001(\u0000\u000b\u0001\u001c\u000c\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0002\u0000\u0000\u0000(\u0000*\u0000\u00ff\u00ff\n\u000c\u0001\u0001)\u0000\u000c\u0000\n" 237 33 regexp 238 04 F8 01 00 00 push_atom_value "(Math.sqrt($1))" 243 24 02 00 call_method 2 246 42 28 01 00 00 get_field2 replace 251 BE 14 push_const8 20: 1"\u5206\u6578\\(([^)]+)\\)" 253 BE 15 push_const8 21: 1"\u0001\u0002\u0000=\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u0006R\u0001xe\u0001(\u0000\u000b\u0001\u001c\u000c\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0002\u0000\u0000\u0000(\u0000*\u0000\u00ff\u00ff\n\u000c\u0001\u0001)\u0000\u000c\u0000\n" 255 33 regexp 256 BF 16 fclosure8 22: [bytecode <null>] 258 24 02 00 call_method 2 261 C2 07 put_loc8 7: replacedEquationString 263 38 A3 01 00 00 get_var console 268 42 A2 01 00 00 get_field2 log 273 62 07 00 get_loc_check 7: replacedEquationString 276 24 01 00 call_method 1 279 0E drop 280 62 07 00 get_loc_check 7: replacedEquationString 283 42 28 01 00 00 get_field2 replace 288 BE 17 push_const8 23: 1"\\s" 290 BE 18 push_const8 24: 1"\u0001\u0001\u0000;\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0015\n\u0000\u0009\u0000\u000d\u0000 \u0000 \u0000\u00a0\u0000\u00a0\u0000\u0080\u0016\u0080\u0016\u0000 \n ( ) / / _ _ \u00000\u00000\u00ff\u00fe\u00ff\u00fe\u000c\u0000\n" 292 33 regexp 293 C0 push_empty_string 294 24 02 00 call_method 2 297 C2 08 put_loc8 8: equation 299 62 08 00 get_loc_check 8: equation 302 42 5C 00 00 00 get_field2 split 307 04 F9 01 00 00 push_atom_value "=" 312 24 01 00 call_method 1 315 B4 push_0 0 316 47 get_array_el 317 C2 09 put_loc8 9: leftHandSide 319 62 08 00 get_loc_check 8: equation 322 42 5C 00 00 00 get_field2 split 327 04 F9 01 00 00 push_atom_value "=" 332 24 01 00 call_method 1 335 B5 push_1 1 336 47 get_array_el 337 C2 0A put_loc8 10: rightHandSide 339 38 3A 00 00 00 get_var eval 344 04 DD 01 00 00 push_atom_value "(" 349 42 5B 00 00 00 get_field2 concat 354 62 04 00 get_loc_check 4: unknownVariable 357 04 FA 01 00 00 push_atom_value ") => " 362 62 09 00 get_loc_check 9: leftHandSide 365 04 FB 01 00 00 push_atom_value " - (" 370 62 0A 00 get_loc_check 10: rightHandSide 373 04 DE 01 00 00 push_atom_value ")" 378 24 06 00 call_method 6 381 31 01 00 0F 00 eval 1,15 386 C2 0B put_loc8 11: equationFunction 388 C0 push_empty_string 389 C2 0C put_loc8 12: ans 391 06 undefined 392 C2 0D put_loc8 13: text 394 B5 push_1 1 395 C2 0E put_loc8 14: guess 397 61 0F 00 set_loc_uninitialized 15: i 400 B4 push_0 0 401 C2 0F put_loc8 15: i 403 62 0F 00 403: get_loc_check 15: i 406 62 06 00 get_loc_check 6: maxIterations 409 A4 lt 410 69 F8 00 00 00 if_false 659 415 61 12 00 set_loc_uninitialized 18: df 418 61 10 00 set_loc_uninitialized 16: f 421 62 0B 00 get_loc_check 11: equationFunction 424 62 0E 00 get_loc_check 14: guess 427 EE call1 1 428 C2 10 put_loc8 16: f 430 38 96 00 00 00 get_var Math 435 42 FC 01 00 00 get_field2 abs 440 62 10 00 get_loc_check 16: f 443 24 01 00 call_method 1 446 62 05 00 get_loc_check 5: tolerance 449 A4 lt 450 69 92 00 00 00 if_false 597 455 61 11 00 set_loc_uninitialized 17: parsedNumber 458 C5 get_loc1 1: parseNumber 459 62 0E 00 get_loc_check 14: guess 462 EE call1 1 463 C2 11 put_loc8 17: parsedNumber 465 38 A3 01 00 00 get_var console 470 42 A2 01 00 00 get_field2 log 475 04 FD 01 00 00 push_atom_value "\u00e6\u0095\u00b4\u00e6\u0095\u00b0\u00e9\u0083\u00a8\u00e5\u0088\u0086:" 480 62 11 00 get_loc_check 17: parsedNumber 483 41 FE 01 00 00 get_field integerPart 488 24 02 00 call_method 2 491 0E drop 492 38 A3 01 00 00 get_var console 497 42 A2 01 00 00 get_field2 log 502 04 FF 01 00 00 push_atom_value "\u00e5\u00b0\u008f\u00e6\u0095\u00b0\u00e9\u0083\u00a8\u00e5\u0088\u0086:" 507 62 11 00 get_loc_check 17: parsedNumber 510 41 00 02 00 00 get_field decimalPart 515 42 37 00 00 00 get_field2 toString 520 24 00 00 call_method 0 523 42 26 01 00 00 get_field2 substr 528 B4 push_0 0 529 BC 0A push_i8 10 531 24 02 00 call_method 2 534 24 02 00 call_method 2 537 0E drop 538 38 96 00 00 00 get_var Math 543 42 01 02 00 00 get_field2 round 548 62 0E 00 get_loc_check 14: guess 551 01 80 96 98 00 push_i32 10000000 556 9B mul 557 24 01 00 call_method 1 560 01 80 96 98 00 push_i32 10000000 565 9C div 566 11 dup 567 63 0D 00 put_loc_check 13: text 570 0E drop 571 04 02 02 00 00 push_atom_value "\u00e6\u0096\u00b9\u00e7\u00a8\u008b\u00e7\u009a\u0084\u00e8\u00a7\u00a3\u00e4\u00b8\u00ba\u00ef\u00bc\u009a\n" 576 62 04 00 get_loc_check 4: unknownVariable 579 9E add 580 04 03 02 00 00 push_atom_value " = " 585 9E add 586 62 0D 00 get_loc_check 13: text 589 9E add 590 11 dup 591 63 0C 00 put_loc_check 12: ans 594 0E drop 595 EB 3F goto8 659 597 62 0B 00 597: get_loc_check 11: equationFunction 600 62 0E 00 get_loc_check 14: guess 603 BE 19 push_const8 25: 1e-13 605 9E add 606 EE call1 1 607 62 10 00 get_loc_check 16: f 610 9F sub 611 BE 1A push_const8 26: 1e-13 613 9C div 614 C2 12 put_loc8 18: df 616 62 0E 00 get_loc_check 14: guess 619 62 10 00 get_loc_check 16: f 622 62 12 00 get_loc_check 18: df 625 9C div 626 9F sub 627 11 dup 628 63 0E 00 put_loc_check 14: guess 631 0E drop 632 38 A3 01 00 00 get_var console 637 42 A2 01 00 00 get_field2 log 642 62 0F 00 get_loc_check 15: i 645 92 post_inc 646 63 0F 00 put_loc_check 15: i 649 62 0E 00 get_loc_check 14: guess 652 24 02 00 call_method 2 655 0E drop 656 EC 02 FF goto16 403 659 38 A3 01 00 00 659: get_var console 664 42 A2 01 00 00 get_field2 log 669 62 0C 00 get_loc_check 12: ans 672 24 01 00 call_method 1 675 0E drop 676 62 0C 00 get_loc_check 12: ans 679 E9 05 if_false8 685 681 62 0C 00 get_loc_check 12: ans 684 28 return 685 04 04 02 00 00 685: push_atom_value "\u00e6\u009c\u00aa\u00e8\u0083\u00bd\u00e6\u0089\u00be\u00e5\u0088\u00b0\u00e6\u0096\u00b9\u00e7\u00a8\u008b\u00e7\u009a\u0084\u00e8\u00a7\u00a3" 690 28 return 691 C6 691: get_loc2 2: arr 692 E8 get_length 693 B4 push_0 0 694 AC strict_eq 695 E9 07 if_false8 703 697 04 05 02 00 00 push_atom_value "\u00e6\u00b2\u0092\u00e6\u009c\u0089\u00e6\u009c\u00aa\u00e7\u009f\u00a5\u00e6\u0095\u00b8" 702 28 return 703 04 06 02 00 00 703: push_atom_value "\u00e7\u009b\u00a1\u00e8\u00ab\u008b\u00e6\u009c\u009f\u00e5\u00be\u0085" 708 28 return */ } this.screen.setProperty(hmUI.prop.MORE, { text: solveEquation(this.screenData), }); Error = true; //this.screenData = "方程式的解为:"+ JSON.stringify(result) } catch (e) { this.screen.setProperty(hmUI.prop.MORE, { text: "請先檢査方程式", }); Error = true; } } else { for (let i = 0; i < brDiff; i++) this.screenData += ")"; } if (Error == false) this.updateScreen(); } _countIncl(str, chr) { let c = 0; for (let i in str) if (str[i] === chr) c++; return c; } switchSet() { const newId = (this.currentSetId + 1) % this.buttonSets.length; const newSet = this.buttonSets[newId]; for (let i = 0; i < newSet.length; i++) { this.buttons[i].setProperty(hmUI.prop.TEXT, newSet[i]); } this.currentSetId = newId; this.currentSet = newSet; } initButtonEvents(i) { return () => { if (i == 11) return this.switchSet(); let val = this.currentSet[i]; if (this.operations[val]) val = this.operations[val]; this.appendScreen(val); while (this.currentSetId != 0) this.switchSet(); }; } appendScreen(val) { this.screenData += val; this.updateScreen(); } updateScreen() { this.screen.setProperty(hmUI.prop.MORE, { text: this.screenData, }); } clear() { this.screenData = ""; this.updateScreen(); } backspace() { let delchar = 1 this.screenData = this.screenData.substring(0, this.screenData.length - delchar); this.updateScreen(); } } // source: /home/melianmiko/Projects/mb7_apps/calculator/entrypoint.js let __$$app$$__ = __$$hmAppManager$$__.currentApp; let __$$module$$__ = __$$app$$__.current; __$$module$$__.module = DeviceRuntimeCore.Page({ onInit() { hmUI.setLayerScrolling(false); new Calculator() .start(); }, }); })();
damn如上
作者 @淘汰郎 https://www.bandbbs.cn/threads/9536/
•index.bin 大小縮小>90% (77 kb -> 7 kb)
•大幅減少APP對手環RAM的使用量
•使用更快更流暢
•UI優化
源代碼 (僅作部份開源,有興趣可以自己去原帖買,只需2023 coins 哦 🙂 ):
JavaScript:/** * Build with ZMake tool */ // Build at 2022-08-08 16:53:06.368238 (() => { // source: /home/melianmiko/Projects/mb7_apps/calculator/src/Calculator.js class Calculator { buttons = []; screen = null; screenData = ""; currentSet = []; currentSetId = -1; buttonSets = [ ["7", "8", "9", "4", "5", "6", "1", "2", "3", "0", "."], ["+", "-", "×", "÷", "^", "√", "|", "=", "π", "(", ")"], ["x", "y", "z", "分數", "又", "分之", "", "", "", "", ""],]; operations = { "+": "+", "-": "-", "×": "×", "÷": "÷", "^": "^", "√": "√(", "∛": "∛(", "π": "π", "分數": "分數(", }; start() { // Init screen hmUI.createWidget(5, { x: 5, y: 80, w: 183, h: 76, radius: 8, line_width: 2, color: 0x222222 }); this.screen = hmUI.createWidget(2, { x: 11, y: 80, w: 172, h: 80, color: 0xc5c5c5, text_size: 24, text_style: 1, align_v: 16, }); this.screen.addEventListener(3, () => { this.backspace(); }); // Init buttons for (let i = 0; i < 12; i++) { this.buttons[i] = hmUI.createWidget(23, { x: (i % 3) * 64 + 2, y: Math.floor(i / 3) * 64 + 168, w: 60, h: 60, radius: 8, text_size: 28, normal_color: 0x222222, press_color: 0x333333, click_func: this.initButtonEvents(i), }); } this.buttons[11].setProperty(0, { x: 130, y: 360, w: 60, h: 60, text: "...", normal_color: 0x444444, press_color: 0x666666, }); this.switchSet(); hmUI.createWidget(5, { x: 5, y: 80, w: 183, h: 76, radius: 8, line_width: 2, color: 0x222222 }); this.screen = hmUI.createWidget(2, { x: 11, y: 80, w: 172, h: 80, color: 0xc5c5c5, text_size: 24, text_style: 1, align_v: 16, }); this.screen.addEventListener(3, () => { this.backspace(); }); // Init buttons for (let i = 0; i < 12; i++) { this.buttons[i] = hmUI.createWidget(23, { x: (i % 3) * 64 + 2, y: Math.floor(i / 3) * 64 + 168, w: 60, h: 60, radius: 8, text_size: 28, normal_color: 0x222222, press_color: 0x333333, click_func: this.initButtonEvents(i), }); } this.buttons[11].setProperty(0, { x: 130, y: 360, w: 60, h: 60, text: "...", normal_color: 0x444444, press_color: 0x666666, }); this.switchSet(); // Init remove and process buttons hmUI.createWidget(23, { x: 0, y: 426, w: 192, h: 65, text: "解方程式", normal_color: 0x222222, press_color: 0x444444, text_size: 28, click_func: () => { this.process(); } }); hmUI.createWidget(23, { x: 0, y: 0, w: 192, h: 70, text: "拉進垃圾車", text_size: 20, color: 0x999999, click_func: () => { this.clear(); } }); } calcFactorial(num) { if (num % 1 != 0 || num < 0) { num++; return Math.sqrt(2 * Math.PI / num) * Math.pow((1 / Math.E) * (num + 1 / (12 * num - 1 / (10 * num))), num); } else { return (num == 0) ? 1 : num * this.calcFactorial(num - 1); } } process() { let Error = false; const brDiff = this._countIncl(this.screenData, "(") - this._countIncl(this.screenData, ")"); if (brDiff === 0) { try { function solveEquation(equationString) { /* function not open source bytecode: /sdcard/index.js:181: function: solveEquation mode: strict args: equationString locals: 0: var Fraction 1: var parseNumber 2: var arr 3: catch error [level:3 next:4] 4: let unknownVariable [level:1 next:-1] 5: let tolerance [level:6 next:4] 6: let maxIterations [level:6 next:5] 7: let replacedEquationString [level:6 next:6] 8: let equation [level:6 next:7] 9: let leftHandSide [level:6 next:8] 10: let rightHandSide [level:6 next:9] 11: let equationFunction [level:6 next:10] 12: let ans [level:6 next:11] 13: let text [level:6 next:12] 14: let guess [level:6 next:13] 15: let i [level:7 next:14] 16: let f [level:8 next:15] 17: const parsedNumber [level:10 next:18] 18: let df [level:8 next:16] 19: var this 20: var new.target 21: var arguments closure vars: 0: solveEquation local:loc2 let 1: brDiff local:loc1 const 2: Error local:loc0 let 3: <class_fields_init> parent:loc0 const 4: Calculator parent:loc1 const 5: __$$module$$__ parent:loc2 let 6: __$$app$$__ parent:loc3 let 7: Calculator parent:loc4 let stack_size: 9 opcodes: 0 0C 03 special_object 3 2 C2 14 put_loc8 20: "new.target" 4 08 push_this 5 C2 13 put_loc8 19: this 7 0C 00 special_object 0 9 C2 15 put_loc8 21: arguments 11 BF 00 fclosure8 0: [bytecode Fraction] 13 C8 put_loc0 0: Fraction [definition of function Fraction(str)] */ function Fraction(str) { /* function not open source bytecode: /sdcard/index.js:182: function: Fraction mode: strict args: str locals: 0: let arr [level:7 next:-1] 1: let arr [level:11 next:-1] stack_size: 5 opcodes: 0 D0 get_arg0 0: str 1 98 typeof 2 04 48 00 00 00 push_atom_value string 7 AD strict_neq 8 E9 0B if_false8 20 10 D0 get_arg0 0: str 11 42 37 00 00 00 get_field2 toString 16 24 00 00 call_method 0 19 D4 put_arg0 0: str 20 BE 00 20: push_const8 0: 1"\u5206\u6570\\([^)]+\\)" 22 BE 01 push_const8 1: 1"\u0000\u0001\u00009\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u0006R\u0001pe\u0001(\u0000\u001c\u000c\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0002\u0000\u0000\u0000(\u0000*\u0000\u00ff\u00ff\n\u0001)\u0000\u000c\u0000\n" 24 33 regexp 25 42 82 01 00 00 get_field2 test 30 D0 get_arg0 0: str 31 24 01 00 call_method 1 34 E9 1C if_false8 63 36 38 BC 01 00 00 get_var hmUI 41 42 08 02 00 00 get_field2 showToast 46 0B object 47 04 09 02 00 00 push_atom_value "\u00e6\u00a0\u00bc\u00e5\u00bc\u008f\u00e4\u00b8\u008d\u00e7\u00ac\u00a6\u00e5\u0090\u0088\n\u00e5\u00b7\u00b2\u00e6\u0094\u00b9\u00e6\u0088\u00900" 52 4C D1 01 00 00 define_field text 57 24 01 00 call_method 1 60 0E drop 61 B4 push_0 0 62 28 return 63 BE 02 63: push_const8 2: 1"(^[\\s\\S]*)\u53c8([\\s\\S]*)\u5206\u4e4b([\\s\\S]*)" 65 BE 03 push_const8 3: 1"\u0000\u0004\u0000q\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u000b\u0001\u0005\u001c\u0008\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u0000\u0000\u0000\u00ff\u00ff\n\u000c\u0001\u0001\u00c8S\u000b\u0002\u001c\u0008\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u0000\u0000\u0000\u00ff\u00ff\n\u000c\u0002\u0001\u0006R\u0001KN\u000b\u0003\u001c\u0008\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u0000\u0000\u0000\u00ff\u00ff\n\u000c\u0003\u000c\u0000\n" 67 33 regexp 68 42 82 01 00 00 get_field2 test 73 D0 get_arg0 0: str 74 24 01 00 call_method 1 77 69 C2 00 00 00 if_false 272 82 61 00 00 set_loc_uninitialized 0: arr 85 D0 get_arg0 0: str 86 42 5C 00 00 00 get_field2 split 91 BE 04 push_const8 4: 1"\u53c8|\u5206\u4e4b" 93 BE 05 push_const8 5: 1"\u0000\u0001\u0000#\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0009\u0008\u0000\u0000\u0000\u0001\u00c8S\u0007\u0006\u0000\u0000\u0000\u0001\u0006R\u0001KN\u000c\u0000\n" 95 33 regexp 96 24 01 00 call_method 1 99 C8 put_loc0 0: arr 100 62 00 00 get_loc_check 0: arr 103 E8 get_length 104 B7 push_3 3 105 AD strict_neq 106 11 dup 107 EA 26 if_true8 146 109 0E drop 110 BE 06 push_const8 6: 1"\u53c8" 112 BE 07 push_const8 7: 1"\u0000\u0001\u0000\u0013\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u00c8S\u000c\u0000\n" 114 33 regexp 115 42 82 01 00 00 get_field2 test 120 D0 get_arg0 0: str 121 24 01 00 call_method 1 124 0A push_true 125 AD strict_neq 126 11 dup 127 EA 12 if_true8 146 129 0E drop 130 BE 08 push_const8 8: 1"\u5206\u4e4b" 132 BE 09 push_const8 9: 1"\u0000\u0001\u0000\u0016\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u0006R\u0001KN\u000c\u0000\n" 134 33 regexp 135 42 82 01 00 00 get_field2 test 140 D0 get_arg0 0: str 141 24 01 00 call_method 1 144 0A push_true 145 AD strict_neq 146 E9 1C 146: if_false8 175 148 38 BC 01 00 00 get_var hmUI 153 42 08 02 00 00 get_field2 showToast 158 0B object 159 04 09 02 00 00 push_atom_value "\u00e6\u00a0\u00bc\u00e5\u00bc\u008f\u00e4\u00b8\u008d\u00e7\u00ac\u00a6\u00e5\u0090\u0088\n\u00e5\u00b7\u00b2\u00e6\u0094\u00b9\u00e6\u0088\u00900" 164 4C D1 01 00 00 define_field text 169 24 01 00 call_method 1 172 0E drop 173 B4 push_0 0 174 28 return 175 38 A3 01 00 00 175: get_var console 180 42 A2 01 00 00 get_field2 log 185 04 DD 01 00 00 push_atom_value "(" 190 62 00 00 get_loc_check 0: arr 193 B4 push_0 0 194 47 get_array_el 195 9E add 196 04 0A 02 00 00 push_atom_value " + " 201 9E add 202 62 00 00 get_loc_check 0: arr 205 B6 push_2 2 206 47 get_array_el 207 9E add 208 04 0B 02 00 00 push_atom_value " / " 213 9E add 214 62 00 00 get_loc_check 0: arr 217 B5 push_1 1 218 47 get_array_el 219 9E add 220 04 DE 01 00 00 push_atom_value ")" 225 9E add 226 24 01 00 call_method 1 229 0E drop 230 04 DD 01 00 00 push_atom_value "(" 235 62 00 00 get_loc_check 0: arr 238 B4 push_0 0 239 47 get_array_el 240 9E add 241 04 0A 02 00 00 push_atom_value " + " 246 9E add 247 62 00 00 get_loc_check 0: arr 250 B6 push_2 2 251 47 get_array_el 252 04 0B 02 00 00 push_atom_value " / " 257 9E add 258 62 00 00 get_loc_check 0: arr 261 B5 push_1 1 262 47 get_array_el 263 9E add 264 9E add 265 04 DE 01 00 00 push_atom_value ")" 270 9E add 271 28 return 272 BE 0A 272: push_const8 10: 1"(^[\\s\\S]*)\u5206\u4e4b([\\s\\S]*)" 274 BE 0B push_const8 11: 1"\u0000\u0003\u0000Q\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u000b\u0001\u0005\u001c\u0008\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u0000\u0000\u0000\u00ff\u00ff\n\u000c\u0001\u0001\u0006R\u0001KN\u000b\u0002\u001c\u0008\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u0000\u0000\u0000\u00ff\u00ff\n\u000c\u0002\u000c\u0000\n" 276 33 regexp 277 42 82 01 00 00 get_field2 test 282 D0 get_arg0 0: str 283 24 01 00 call_method 1 286 69 96 00 00 00 if_false 437 291 61 01 00 set_loc_uninitialized 1: arr 294 D0 get_arg0 0: str 295 42 5C 00 00 00 get_field2 split 300 BE 0C push_const8 12: 1"\u5206\u4e4b" 302 BE 0D push_const8 13: 1"\u0000\u0001\u0000\u0016\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u0006R\u0001KN\u000c\u0000\n" 304 33 regexp 305 24 01 00 call_method 1 308 C9 put_loc1 1: arr 309 62 01 00 get_loc_check 1: arr 312 E8 get_length 313 B6 push_2 2 314 AD strict_neq 315 11 dup 316 EA 12 if_true8 335 318 0E drop 319 BE 0E push_const8 14: 1"\u5206\u4e4b" 321 BE 0F push_const8 15: 1"\u0000\u0001\u0000\u0016\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u0006R\u0001KN\u000c\u0000\n" 323 33 regexp 324 42 82 01 00 00 get_field2 test 329 D0 get_arg0 0: str 330 24 01 00 call_method 1 333 0A push_true 334 AD strict_neq 335 E9 1C 335: if_false8 364 337 38 BC 01 00 00 get_var hmUI 342 42 08 02 00 00 get_field2 showToast 347 0B object 348 04 09 02 00 00 push_atom_value "\u00e6\u00a0\u00bc\u00e5\u00bc\u008f\u00e4\u00b8\u008d\u00e7\u00ac\u00a6\u00e5\u0090\u0088\n\u00e5\u00b7\u00b2\u00e6\u0094\u00b9\u00e6\u0088\u00900" 353 4C D1 01 00 00 define_field text 358 24 01 00 call_method 1 361 0E drop 362 B4 push_0 0 363 28 return 364 38 A3 01 00 00 364: get_var console 369 42 A2 01 00 00 get_field2 log 374 04 DD 01 00 00 push_atom_value "(" 379 62 01 00 get_loc_check 1: arr 382 B5 push_1 1 383 47 get_array_el 384 9E add 385 04 0B 02 00 00 push_atom_value " / " 390 9E add 391 62 01 00 get_loc_check 1: arr 394 B4 push_0 0 395 47 get_array_el 396 9E add 397 04 DE 01 00 00 push_atom_value ")" 402 9E add 403 24 01 00 call_method 1 406 0E drop 407 04 DD 01 00 00 push_atom_value "(" 412 62 01 00 get_loc_check 1: arr 415 B5 push_1 1 416 47 get_array_el 417 9E add 418 04 0B 02 00 00 push_atom_value " / " 423 9E add 424 62 01 00 get_loc_check 1: arr 427 B4 push_0 0 428 47 get_array_el 429 9E add 430 04 DE 01 00 00 push_atom_value ")" 435 9E add 436 28 return 437 38 BC 01 00 00 437: get_var hmUI 442 42 08 02 00 00 get_field2 showToast 447 0B object 448 04 09 02 00 00 push_atom_value "\u00e6\u00a0\u00bc\u00e5\u00bc\u008f\u00e4\u00b8\u008d\u00e7\u00ac\u00a6\u00e5\u0090\u0088\n\u00e5\u00b7\u00b2\u00e6\u0094\u00b9\u00e6\u0088\u00900" 453 4C D1 01 00 00 define_field text 458 24 01 00 call_method 1 461 0E drop 462 B4 push_0 0 463 28 return */ } /* bytecode: 14 BF 01 fclosure8 1: [bytecode parseNumber] 16 C9 put_loc1 1: parseNumber [definition of function parseNumber(str)] */ function parseNumber(str) { /* function not open source bytecode: /sdcard/index.js:211: function: parseNumber mode: strict args: str locals: 0: const regex [level:1 next:-1] 1: const matches [level:1 next:0] 2: let integerPart [level:5 next:1] 3: let decimalPart [level:5 next:2] stack_size: 4 opcodes: 0 61 01 00 set_loc_uninitialized 1: matches 3 61 00 00 set_loc_uninitialized 0: regex 6 D0 get_arg0 0: str 7 98 typeof 8 04 46 00 00 00 push_atom_value number 13 AC strict_eq 14 E9 0B if_false8 26 16 D0 get_arg0 0: str 17 42 37 00 00 00 get_field2 toString 22 24 00 00 call_method 0 25 D4 put_arg0 0: str 26 BE 00 26: push_const8 0: 1"^(-?\\d+)(\\.\\d+)?$" 28 BE 01 push_const8 1: 1"\u0000\u0003\u0000l\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0005\u000b\u0001\u001c\u0004\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u0001-\u0000\n\u001c\u0008\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u00000\u00009\u0000\n\u000c\u0001\u000d\u0002\u0002\u0009 \u0000\u0000\u0000\u000b\u0002\u0001.\u0000\u001c\u0008\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u00000\u00009\u0000\n\u000c\u0002\u0006\u000c\u0000\n" 30 33 regexp 31 C8 put_loc0 0: regex 32 D0 get_arg0 0: str 33 42 22 01 00 00 get_field2 match 38 62 00 00 get_loc_check 0: regex 41 24 01 00 call_method 1 44 C9 put_loc1 1: matches 45 62 01 00 get_loc_check 1: matches 48 E9 60 if_false8 145 50 61 03 00 set_loc_uninitialized 3: decimalPart 53 61 02 00 set_loc_uninitialized 2: integerPart 56 62 01 00 get_loc_check 1: matches 59 B5 push_1 1 60 47 get_array_el 61 CA put_loc2 2: integerPart 62 62 01 00 get_loc_check 1: matches 65 B6 push_2 2 66 47 get_array_el 67 CB put_loc3 3: decimalPart 68 62 03 00 get_loc_check 3: decimalPart 71 E9 1D if_false8 101 73 62 03 00 get_loc_check 3: decimalPart 76 42 28 01 00 00 get_field2 replace 81 BE 02 push_const8 2: 1"^\\." 83 BE 03 push_const8 3: 1"\u0000\u0001\u0000\u0014\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0005\u0001.\u0000\u000c\u0000\n" 85 33 regexp 86 04 0E 02 00 00 push_atom_value "0." 91 24 02 00 call_method 2 94 11 dup 95 63 03 00 put_loc_check 3: decimalPart 98 0E drop 99 EB 0B goto8 111 101 04 0F 02 00 00 101: push_atom_value "0.0" 106 11 dup 107 63 03 00 put_loc_check 3: decimalPart 110 0E drop 111 0B 111: object 112 62 02 00 get_loc_check 2: integerPart 115 42 37 00 00 00 get_field2 toString 120 24 00 00 call_method 0 123 4C FE 01 00 00 define_field integerPart 128 62 03 00 get_loc_check 3: decimalPart 131 42 37 00 00 00 get_field2 toString 136 24 00 00 call_method 0 139 4C 00 02 00 00 define_field decimalPart 144 28 return 145 D0 145: get_arg0 0: str 146 28 return */ } /* 17 61 04 00 set_loc_uninitialized 4: unknownVariable 20 6C 23 00 00 00 catch 56 25 D0 get_arg0 0: equationString 26 42 22 01 00 00 get_field2 match 31 BE 02 push_const8 2: 1"[a-zA-Z]+" 33 BE 03 push_const8 3: 1"\u0001\u0001\u0000-\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u001c\u000c\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0002\u0000A\u0000Z\u0000a\u0000z\u0000\n\u000c\u0000\n" 35 33 regexp 36 24 01 00 call_method 1 39 42 EE 00 00 00 get_field2 reduce 44 BF 04 fclosure8 4: [bytecode <null>] 46 26 00 00 array_from 0 49 24 02 00 call_method 2 52 CA put_loc2 2: arr 53 0E drop 54 EB 0B goto8 66 56 CB 56: put_loc3 3: error 57 6C 07 00 00 00 catch 65 62 0E drop 63 EB 02 goto8 66 65 2F 65: throw 66 C6 66: get_loc2 2: arr 67 B4 push_0 0 68 47 get_array_el 69 C2 04 put_loc8 4: unknownVariable 71 C6 get_loc2 2: arr 72 E8 get_length 73 B5 push_1 1 74 AC strict_eq 75 69 67 02 00 00 if_false 691 80 61 0E 00 set_loc_uninitialized 14: guess 83 61 0D 00 set_loc_uninitialized 13: text 86 61 0C 00 set_loc_uninitialized 12: ans 89 61 0B 00 set_loc_uninitialized 11: equationFunction 92 61 0A 00 set_loc_uninitialized 10: rightHandSide 95 61 09 00 set_loc_uninitialized 9: leftHandSide 98 61 08 00 set_loc_uninitialized 8: equation 101 61 07 00 set_loc_uninitialized 7: replacedEquationString 104 61 06 00 set_loc_uninitialized 6: maxIterations 107 61 05 00 set_loc_uninitialized 5: tolerance 110 BE 05 push_const8 5: 1e-08 112 C2 05 put_loc8 5: tolerance 114 BD 10 27 push_i16 10000 117 C2 06 put_loc8 6: maxIterations 119 D0 get_arg0 0: equationString 120 42 28 01 00 00 get_field2 replace 125 BE 06 push_const8 6: 1"(\\d|\\))(\\(|[a-z]|\u03c0|\u5206\u6578)" 127 BE 07 push_const8 7: 1"\u0001\u0003\u0000]\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u000b\u0001\u0009\u000c\u0000\u0000\u0000\u0015\u0001\u00000\u00009\u0000\u0007\u0003\u0000\u0000\u0000\u0001)\u0000\u000c\u0001\u000b\u0002\u0009&\u0000\u0000\u0000\u0009\u0019\u0000\u0000\u0000\u0009\u0008\u0000\u0000\u0000\u0001(\u0000\u0007\u0007\u0000\u0000\u0000\u0015\u0001\u0000a\u0000z\u0000\u0007\u0003\u0000\u0000\u0000\u0001\u00c0\u0003\u0007\u0006\u0000\u0000\u0000\u0001\u0006R\u0001xe\u000c\u0002\u000c\u0000\n" 129 33 regexp 130 04 F3 01 00 00 push_atom_value "$1*$2" 135 24 02 00 call_method 2 138 42 28 01 00 00 get_field2 replace 143 BE 08 push_const8 8: 1"\\^" 145 BE 09 push_const8 9: 1"\u0001\u0001\u0000\u0013\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001^\u0000\u000c\u0000\n" 147 33 regexp 148 04 F4 01 00 00 push_atom_value "**" 153 24 02 00 call_method 2 156 42 28 01 00 00 get_field2 replace 161 BE 0A push_const8 10: 1"\u00d7" 163 BE 0B push_const8 11: 1"\u0001\u0001\u0000\u0013\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u00d7\u0000\u000c\u0000\n" 165 33 regexp 166 04 7C 00 00 00 push_atom_value "*" 171 24 02 00 call_method 2 174 42 28 01 00 00 get_field2 replace 179 BE 0C push_const8 12: 1"\u00f7" 181 BE 0D push_const8 13: 1"\u0001\u0001\u0000\u0013\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u00f7\u0000\u000c\u0000\n" 183 33 regexp 184 04 F5 01 00 00 push_atom_value "/" 189 24 02 00 call_method 2 192 42 28 01 00 00 get_field2 replace 197 BE 0E push_const8 14: 1"\u03c0" 199 BE 0F push_const8 15: 1"\u0001\u0001\u0000\u0013\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u00c0\u0003\u000c\u0000\n" 201 33 regexp 202 04 F6 01 00 00 push_atom_value "3.14" 207 24 02 00 call_method 2 210 42 28 01 00 00 get_field2 replace 215 BE 10 push_const8 16: 1"\\|([^|]+)\\|" 217 BE 11 push_const8 17: 1"\u0001\u0002\u00007\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001|\u0000\u000b\u0001\u001c\u000c\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0002\u0000\u0000\u0000{\u0000}\u0000\u00ff\u00ff\n\u000c\u0001\u0001|\u0000\u000c\u0000\n" 219 33 regexp 220 04 F7 01 00 00 push_atom_value "(Math.abs($1))" 225 24 02 00 call_method 2 228 42 28 01 00 00 get_field2 replace 233 BE 12 push_const8 18: 1"\u221a\\(([^)]+)\\)" 235 BE 13 push_const8 19: 1"\u0001\u0002\u0000:\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u001a\"\u0001(\u0000\u000b\u0001\u001c\u000c\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0002\u0000\u0000\u0000(\u0000*\u0000\u00ff\u00ff\n\u000c\u0001\u0001)\u0000\u000c\u0000\n" 237 33 regexp 238 04 F8 01 00 00 push_atom_value "(Math.sqrt($1))" 243 24 02 00 call_method 2 246 42 28 01 00 00 get_field2 replace 251 BE 14 push_const8 20: 1"\u5206\u6578\\(([^)]+)\\)" 253 BE 15 push_const8 21: 1"\u0001\u0002\u0000=\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u0006R\u0001xe\u0001(\u0000\u000b\u0001\u001c\u000c\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0002\u0000\u0000\u0000(\u0000*\u0000\u00ff\u00ff\n\u000c\u0001\u0001)\u0000\u000c\u0000\n" 255 33 regexp 256 BF 16 fclosure8 22: [bytecode <null>] 258 24 02 00 call_method 2 261 C2 07 put_loc8 7: replacedEquationString 263 38 A3 01 00 00 get_var console 268 42 A2 01 00 00 get_field2 log 273 62 07 00 get_loc_check 7: replacedEquationString 276 24 01 00 call_method 1 279 0E drop 280 62 07 00 get_loc_check 7: replacedEquationString 283 42 28 01 00 00 get_field2 replace 288 BE 17 push_const8 23: 1"\\s" 290 BE 18 push_const8 24: 1"\u0001\u0001\u0000;\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0015\n\u0000\u0009\u0000\u000d\u0000 \u0000 \u0000\u00a0\u0000\u00a0\u0000\u0080\u0016\u0080\u0016\u0000 \n ( ) / / _ _ \u00000\u00000\u00ff\u00fe\u00ff\u00fe\u000c\u0000\n" 292 33 regexp 293 C0 push_empty_string 294 24 02 00 call_method 2 297 C2 08 put_loc8 8: equation 299 62 08 00 get_loc_check 8: equation 302 42 5C 00 00 00 get_field2 split 307 04 F9 01 00 00 push_atom_value "=" 312 24 01 00 call_method 1 315 B4 push_0 0 316 47 get_array_el 317 C2 09 put_loc8 9: leftHandSide 319 62 08 00 get_loc_check 8: equation 322 42 5C 00 00 00 get_field2 split 327 04 F9 01 00 00 push_atom_value "=" 332 24 01 00 call_method 1 335 B5 push_1 1 336 47 get_array_el 337 C2 0A put_loc8 10: rightHandSide 339 38 3A 00 00 00 get_var eval 344 04 DD 01 00 00 push_atom_value "(" 349 42 5B 00 00 00 get_field2 concat 354 62 04 00 get_loc_check 4: unknownVariable 357 04 FA 01 00 00 push_atom_value ") => " 362 62 09 00 get_loc_check 9: leftHandSide 365 04 FB 01 00 00 push_atom_value " - (" 370 62 0A 00 get_loc_check 10: rightHandSide 373 04 DE 01 00 00 push_atom_value ")" 378 24 06 00 call_method 6 381 31 01 00 0F 00 eval 1,15 386 C2 0B put_loc8 11: equationFunction 388 C0 push_empty_string 389 C2 0C put_loc8 12: ans 391 06 undefined 392 C2 0D put_loc8 13: text 394 B5 push_1 1 395 C2 0E put_loc8 14: guess 397 61 0F 00 set_loc_uninitialized 15: i 400 B4 push_0 0 401 C2 0F put_loc8 15: i 403 62 0F 00 403: get_loc_check 15: i 406 62 06 00 get_loc_check 6: maxIterations 409 A4 lt 410 69 F8 00 00 00 if_false 659 415 61 12 00 set_loc_uninitialized 18: df 418 61 10 00 set_loc_uninitialized 16: f 421 62 0B 00 get_loc_check 11: equationFunction 424 62 0E 00 get_loc_check 14: guess 427 EE call1 1 428 C2 10 put_loc8 16: f 430 38 96 00 00 00 get_var Math 435 42 FC 01 00 00 get_field2 abs 440 62 10 00 get_loc_check 16: f 443 24 01 00 call_method 1 446 62 05 00 get_loc_check 5: tolerance 449 A4 lt 450 69 92 00 00 00 if_false 597 455 61 11 00 set_loc_uninitialized 17: parsedNumber 458 C5 get_loc1 1: parseNumber 459 62 0E 00 get_loc_check 14: guess 462 EE call1 1 463 C2 11 put_loc8 17: parsedNumber 465 38 A3 01 00 00 get_var console 470 42 A2 01 00 00 get_field2 log 475 04 FD 01 00 00 push_atom_value "\u00e6\u0095\u00b4\u00e6\u0095\u00b0\u00e9\u0083\u00a8\u00e5\u0088\u0086:" 480 62 11 00 get_loc_check 17: parsedNumber 483 41 FE 01 00 00 get_field integerPart 488 24 02 00 call_method 2 491 0E drop 492 38 A3 01 00 00 get_var console 497 42 A2 01 00 00 get_field2 log 502 04 FF 01 00 00 push_atom_value "\u00e5\u00b0\u008f\u00e6\u0095\u00b0\u00e9\u0083\u00a8\u00e5\u0088\u0086:" 507 62 11 00 get_loc_check 17: parsedNumber 510 41 00 02 00 00 get_field decimalPart 515 42 37 00 00 00 get_field2 toString 520 24 00 00 call_method 0 523 42 26 01 00 00 get_field2 substr 528 B4 push_0 0 529 BC 0A push_i8 10 531 24 02 00 call_method 2 534 24 02 00 call_method 2 537 0E drop 538 38 96 00 00 00 get_var Math 543 42 01 02 00 00 get_field2 round 548 62 0E 00 get_loc_check 14: guess 551 01 80 96 98 00 push_i32 10000000 556 9B mul 557 24 01 00 call_method 1 560 01 80 96 98 00 push_i32 10000000 565 9C div 566 11 dup 567 63 0D 00 put_loc_check 13: text 570 0E drop 571 04 02 02 00 00 push_atom_value "\u00e6\u0096\u00b9\u00e7\u00a8\u008b\u00e7\u009a\u0084\u00e8\u00a7\u00a3\u00e4\u00b8\u00ba\u00ef\u00bc\u009a\n" 576 62 04 00 get_loc_check 4: unknownVariable 579 9E add 580 04 03 02 00 00 push_atom_value " = " 585 9E add 586 62 0D 00 get_loc_check 13: text 589 9E add 590 11 dup 591 63 0C 00 put_loc_check 12: ans 594 0E drop 595 EB 3F goto8 659 597 62 0B 00 597: get_loc_check 11: equationFunction 600 62 0E 00 get_loc_check 14: guess 603 BE 19 push_const8 25: 1e-13 605 9E add 606 EE call1 1 607 62 10 00 get_loc_check 16: f 610 9F sub 611 BE 1A push_const8 26: 1e-13 613 9C div 614 C2 12 put_loc8 18: df 616 62 0E 00 get_loc_check 14: guess 619 62 10 00 get_loc_check 16: f 622 62 12 00 get_loc_check 18: df 625 9C div 626 9F sub 627 11 dup 628 63 0E 00 put_loc_check 14: guess 631 0E drop 632 38 A3 01 00 00 get_var console 637 42 A2 01 00 00 get_field2 log 642 62 0F 00 get_loc_check 15: i 645 92 post_inc 646 63 0F 00 put_loc_check 15: i 649 62 0E 00 get_loc_check 14: guess 652 24 02 00 call_method 2 655 0E drop 656 EC 02 FF goto16 403 659 38 A3 01 00 00 659: get_var console 664 42 A2 01 00 00 get_field2 log 669 62 0C 00 get_loc_check 12: ans 672 24 01 00 call_method 1 675 0E drop 676 62 0C 00 get_loc_check 12: ans 679 E9 05 if_false8 685 681 62 0C 00 get_loc_check 12: ans 684 28 return 685 04 04 02 00 00 685: push_atom_value "\u00e6\u009c\u00aa\u00e8\u0083\u00bd\u00e6\u0089\u00be\u00e5\u0088\u00b0\u00e6\u0096\u00b9\u00e7\u00a8\u008b\u00e7\u009a\u0084\u00e8\u00a7\u00a3" 690 28 return 691 C6 691: get_loc2 2: arr 692 E8 get_length 693 B4 push_0 0 694 AC strict_eq 695 E9 07 if_false8 703 697 04 05 02 00 00 push_atom_value "\u00e6\u00b2\u0092\u00e6\u009c\u0089\u00e6\u009c\u00aa\u00e7\u009f\u00a5\u00e6\u0095\u00b8" 702 28 return 703 04 06 02 00 00 703: push_atom_value "\u00e7\u009b\u00a1\u00e8\u00ab\u008b\u00e6\u009c\u009f\u00e5\u00be\u0085" 708 28 return */ } this.screen.setProperty(hmUI.prop.MORE, { text: solveEquation(this.screenData), }); Error = true; //this.screenData = "方程式的解为:"+ JSON.stringify(result) } catch (e) { this.screen.setProperty(hmUI.prop.MORE, { text: "請先檢査方程式", }); Error = true; } } else { for (let i = 0; i < brDiff; i++) this.screenData += ")"; } if (Error == false) this.updateScreen(); } _countIncl(str, chr) { let c = 0; for (let i in str) if (str[i] === chr) c++; return c; } switchSet() { const newId = (this.currentSetId + 1) % this.buttonSets.length; const newSet = this.buttonSets[newId]; for (let i = 0; i < newSet.length; i++) { this.buttons[i].setProperty(hmUI.prop.TEXT, newSet[i]); } this.currentSetId = newId; this.currentSet = newSet; } initButtonEvents(i) { return () => { if (i == 11) return this.switchSet(); let val = this.currentSet[i]; if (this.operations[val]) val = this.operations[val]; this.appendScreen(val); while (this.currentSetId != 0) this.switchSet(); }; } appendScreen(val) { this.screenData += val; this.updateScreen(); } updateScreen() { this.screen.setProperty(hmUI.prop.MORE, { text: this.screenData, }); } clear() { this.screenData = ""; this.updateScreen(); } backspace() { let delchar = 1 this.screenData = this.screenData.substring(0, this.screenData.length - delchar); this.updateScreen(); } } // source: /home/melianmiko/Projects/mb7_apps/calculator/entrypoint.js let __$$app$$__ = __$$hmAppManager$$__.currentApp; let __$$module$$__ = __$$app$$__.current; __$$module$$__.module = DeviceRuntimeCore.Page({ onInit() { hmUI.setLayerScrolling(false); new Calculator() .start(); }, }); })();
666如上
作者 @淘汰郎 https://www.bandbbs.cn/threads/9536/
•index.bin 大小縮小>90% (77 kb -> 7 kb)
•大幅減少APP對手環RAM的使用量
•使用更快更流暢
•UI優化
源代碼 (僅作部份開源,有興趣可以自己去原帖買,只需2023 coins 哦 🙂 ):
JavaScript:/** * Build with ZMake tool */ // Build at 2022-08-08 16:53:06.368238 (() => { // source: /home/melianmiko/Projects/mb7_apps/calculator/src/Calculator.js class Calculator { buttons = []; screen = null; screenData = ""; currentSet = []; currentSetId = -1; buttonSets = [ ["7", "8", "9", "4", "5", "6", "1", "2", "3", "0", "."], ["+", "-", "×", "÷", "^", "√", "|", "=", "π", "(", ")"], ["x", "y", "z", "分數", "又", "分之", "", "", "", "", ""],]; operations = { "+": "+", "-": "-", "×": "×", "÷": "÷", "^": "^", "√": "√(", "∛": "∛(", "π": "π", "分數": "分數(", }; start() { // Init screen hmUI.createWidget(5, { x: 5, y: 80, w: 183, h: 76, radius: 8, line_width: 2, color: 0x222222 }); this.screen = hmUI.createWidget(2, { x: 11, y: 80, w: 172, h: 80, color: 0xc5c5c5, text_size: 24, text_style: 1, align_v: 16, }); this.screen.addEventListener(3, () => { this.backspace(); }); // Init buttons for (let i = 0; i < 12; i++) { this.buttons[i] = hmUI.createWidget(23, { x: (i % 3) * 64 + 2, y: Math.floor(i / 3) * 64 + 168, w: 60, h: 60, radius: 8, text_size: 28, normal_color: 0x222222, press_color: 0x333333, click_func: this.initButtonEvents(i), }); } this.buttons[11].setProperty(0, { x: 130, y: 360, w: 60, h: 60, text: "...", normal_color: 0x444444, press_color: 0x666666, }); this.switchSet(); hmUI.createWidget(5, { x: 5, y: 80, w: 183, h: 76, radius: 8, line_width: 2, color: 0x222222 }); this.screen = hmUI.createWidget(2, { x: 11, y: 80, w: 172, h: 80, color: 0xc5c5c5, text_size: 24, text_style: 1, align_v: 16, }); this.screen.addEventListener(3, () => { this.backspace(); }); // Init buttons for (let i = 0; i < 12; i++) { this.buttons[i] = hmUI.createWidget(23, { x: (i % 3) * 64 + 2, y: Math.floor(i / 3) * 64 + 168, w: 60, h: 60, radius: 8, text_size: 28, normal_color: 0x222222, press_color: 0x333333, click_func: this.initButtonEvents(i), }); } this.buttons[11].setProperty(0, { x: 130, y: 360, w: 60, h: 60, text: "...", normal_color: 0x444444, press_color: 0x666666, }); this.switchSet(); // Init remove and process buttons hmUI.createWidget(23, { x: 0, y: 426, w: 192, h: 65, text: "解方程式", normal_color: 0x222222, press_color: 0x444444, text_size: 28, click_func: () => { this.process(); } }); hmUI.createWidget(23, { x: 0, y: 0, w: 192, h: 70, text: "拉進垃圾車", text_size: 20, color: 0x999999, click_func: () => { this.clear(); } }); } calcFactorial(num) { if (num % 1 != 0 || num < 0) { num++; return Math.sqrt(2 * Math.PI / num) * Math.pow((1 / Math.E) * (num + 1 / (12 * num - 1 / (10 * num))), num); } else { return (num == 0) ? 1 : num * this.calcFactorial(num - 1); } } process() { let Error = false; const brDiff = this._countIncl(this.screenData, "(") - this._countIncl(this.screenData, ")"); if (brDiff === 0) { try { function solveEquation(equationString) { /* function not open source bytecode: /sdcard/index.js:181: function: solveEquation mode: strict args: equationString locals: 0: var Fraction 1: var parseNumber 2: var arr 3: catch error [level:3 next:4] 4: let unknownVariable [level:1 next:-1] 5: let tolerance [level:6 next:4] 6: let maxIterations [level:6 next:5] 7: let replacedEquationString [level:6 next:6] 8: let equation [level:6 next:7] 9: let leftHandSide [level:6 next:8] 10: let rightHandSide [level:6 next:9] 11: let equationFunction [level:6 next:10] 12: let ans [level:6 next:11] 13: let text [level:6 next:12] 14: let guess [level:6 next:13] 15: let i [level:7 next:14] 16: let f [level:8 next:15] 17: const parsedNumber [level:10 next:18] 18: let df [level:8 next:16] 19: var this 20: var new.target 21: var arguments closure vars: 0: solveEquation local:loc2 let 1: brDiff local:loc1 const 2: Error local:loc0 let 3: <class_fields_init> parent:loc0 const 4: Calculator parent:loc1 const 5: __$$module$$__ parent:loc2 let 6: __$$app$$__ parent:loc3 let 7: Calculator parent:loc4 let stack_size: 9 opcodes: 0 0C 03 special_object 3 2 C2 14 put_loc8 20: "new.target" 4 08 push_this 5 C2 13 put_loc8 19: this 7 0C 00 special_object 0 9 C2 15 put_loc8 21: arguments 11 BF 00 fclosure8 0: [bytecode Fraction] 13 C8 put_loc0 0: Fraction [definition of function Fraction(str)] */ function Fraction(str) { /* function not open source bytecode: /sdcard/index.js:182: function: Fraction mode: strict args: str locals: 0: let arr [level:7 next:-1] 1: let arr [level:11 next:-1] stack_size: 5 opcodes: 0 D0 get_arg0 0: str 1 98 typeof 2 04 48 00 00 00 push_atom_value string 7 AD strict_neq 8 E9 0B if_false8 20 10 D0 get_arg0 0: str 11 42 37 00 00 00 get_field2 toString 16 24 00 00 call_method 0 19 D4 put_arg0 0: str 20 BE 00 20: push_const8 0: 1"\u5206\u6570\\([^)]+\\)" 22 BE 01 push_const8 1: 1"\u0000\u0001\u00009\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u0006R\u0001pe\u0001(\u0000\u001c\u000c\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0002\u0000\u0000\u0000(\u0000*\u0000\u00ff\u00ff\n\u0001)\u0000\u000c\u0000\n" 24 33 regexp 25 42 82 01 00 00 get_field2 test 30 D0 get_arg0 0: str 31 24 01 00 call_method 1 34 E9 1C if_false8 63 36 38 BC 01 00 00 get_var hmUI 41 42 08 02 00 00 get_field2 showToast 46 0B object 47 04 09 02 00 00 push_atom_value "\u00e6\u00a0\u00bc\u00e5\u00bc\u008f\u00e4\u00b8\u008d\u00e7\u00ac\u00a6\u00e5\u0090\u0088\n\u00e5\u00b7\u00b2\u00e6\u0094\u00b9\u00e6\u0088\u00900" 52 4C D1 01 00 00 define_field text 57 24 01 00 call_method 1 60 0E drop 61 B4 push_0 0 62 28 return 63 BE 02 63: push_const8 2: 1"(^[\\s\\S]*)\u53c8([\\s\\S]*)\u5206\u4e4b([\\s\\S]*)" 65 BE 03 push_const8 3: 1"\u0000\u0004\u0000q\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u000b\u0001\u0005\u001c\u0008\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u0000\u0000\u0000\u00ff\u00ff\n\u000c\u0001\u0001\u00c8S\u000b\u0002\u001c\u0008\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u0000\u0000\u0000\u00ff\u00ff\n\u000c\u0002\u0001\u0006R\u0001KN\u000b\u0003\u001c\u0008\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u0000\u0000\u0000\u00ff\u00ff\n\u000c\u0003\u000c\u0000\n" 67 33 regexp 68 42 82 01 00 00 get_field2 test 73 D0 get_arg0 0: str 74 24 01 00 call_method 1 77 69 C2 00 00 00 if_false 272 82 61 00 00 set_loc_uninitialized 0: arr 85 D0 get_arg0 0: str 86 42 5C 00 00 00 get_field2 split 91 BE 04 push_const8 4: 1"\u53c8|\u5206\u4e4b" 93 BE 05 push_const8 5: 1"\u0000\u0001\u0000#\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0009\u0008\u0000\u0000\u0000\u0001\u00c8S\u0007\u0006\u0000\u0000\u0000\u0001\u0006R\u0001KN\u000c\u0000\n" 95 33 regexp 96 24 01 00 call_method 1 99 C8 put_loc0 0: arr 100 62 00 00 get_loc_check 0: arr 103 E8 get_length 104 B7 push_3 3 105 AD strict_neq 106 11 dup 107 EA 26 if_true8 146 109 0E drop 110 BE 06 push_const8 6: 1"\u53c8" 112 BE 07 push_const8 7: 1"\u0000\u0001\u0000\u0013\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u00c8S\u000c\u0000\n" 114 33 regexp 115 42 82 01 00 00 get_field2 test 120 D0 get_arg0 0: str 121 24 01 00 call_method 1 124 0A push_true 125 AD strict_neq 126 11 dup 127 EA 12 if_true8 146 129 0E drop 130 BE 08 push_const8 8: 1"\u5206\u4e4b" 132 BE 09 push_const8 9: 1"\u0000\u0001\u0000\u0016\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u0006R\u0001KN\u000c\u0000\n" 134 33 regexp 135 42 82 01 00 00 get_field2 test 140 D0 get_arg0 0: str 141 24 01 00 call_method 1 144 0A push_true 145 AD strict_neq 146 E9 1C 146: if_false8 175 148 38 BC 01 00 00 get_var hmUI 153 42 08 02 00 00 get_field2 showToast 158 0B object 159 04 09 02 00 00 push_atom_value "\u00e6\u00a0\u00bc\u00e5\u00bc\u008f\u00e4\u00b8\u008d\u00e7\u00ac\u00a6\u00e5\u0090\u0088\n\u00e5\u00b7\u00b2\u00e6\u0094\u00b9\u00e6\u0088\u00900" 164 4C D1 01 00 00 define_field text 169 24 01 00 call_method 1 172 0E drop 173 B4 push_0 0 174 28 return 175 38 A3 01 00 00 175: get_var console 180 42 A2 01 00 00 get_field2 log 185 04 DD 01 00 00 push_atom_value "(" 190 62 00 00 get_loc_check 0: arr 193 B4 push_0 0 194 47 get_array_el 195 9E add 196 04 0A 02 00 00 push_atom_value " + " 201 9E add 202 62 00 00 get_loc_check 0: arr 205 B6 push_2 2 206 47 get_array_el 207 9E add 208 04 0B 02 00 00 push_atom_value " / " 213 9E add 214 62 00 00 get_loc_check 0: arr 217 B5 push_1 1 218 47 get_array_el 219 9E add 220 04 DE 01 00 00 push_atom_value ")" 225 9E add 226 24 01 00 call_method 1 229 0E drop 230 04 DD 01 00 00 push_atom_value "(" 235 62 00 00 get_loc_check 0: arr 238 B4 push_0 0 239 47 get_array_el 240 9E add 241 04 0A 02 00 00 push_atom_value " + " 246 9E add 247 62 00 00 get_loc_check 0: arr 250 B6 push_2 2 251 47 get_array_el 252 04 0B 02 00 00 push_atom_value " / " 257 9E add 258 62 00 00 get_loc_check 0: arr 261 B5 push_1 1 262 47 get_array_el 263 9E add 264 9E add 265 04 DE 01 00 00 push_atom_value ")" 270 9E add 271 28 return 272 BE 0A 272: push_const8 10: 1"(^[\\s\\S]*)\u5206\u4e4b([\\s\\S]*)" 274 BE 0B push_const8 11: 1"\u0000\u0003\u0000Q\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u000b\u0001\u0005\u001c\u0008\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u0000\u0000\u0000\u00ff\u00ff\n\u000c\u0001\u0001\u0006R\u0001KN\u000b\u0002\u001c\u0008\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u0000\u0000\u0000\u00ff\u00ff\n\u000c\u0002\u000c\u0000\n" 276 33 regexp 277 42 82 01 00 00 get_field2 test 282 D0 get_arg0 0: str 283 24 01 00 call_method 1 286 69 96 00 00 00 if_false 437 291 61 01 00 set_loc_uninitialized 1: arr 294 D0 get_arg0 0: str 295 42 5C 00 00 00 get_field2 split 300 BE 0C push_const8 12: 1"\u5206\u4e4b" 302 BE 0D push_const8 13: 1"\u0000\u0001\u0000\u0016\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u0006R\u0001KN\u000c\u0000\n" 304 33 regexp 305 24 01 00 call_method 1 308 C9 put_loc1 1: arr 309 62 01 00 get_loc_check 1: arr 312 E8 get_length 313 B6 push_2 2 314 AD strict_neq 315 11 dup 316 EA 12 if_true8 335 318 0E drop 319 BE 0E push_const8 14: 1"\u5206\u4e4b" 321 BE 0F push_const8 15: 1"\u0000\u0001\u0000\u0016\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u0006R\u0001KN\u000c\u0000\n" 323 33 regexp 324 42 82 01 00 00 get_field2 test 329 D0 get_arg0 0: str 330 24 01 00 call_method 1 333 0A push_true 334 AD strict_neq 335 E9 1C 335: if_false8 364 337 38 BC 01 00 00 get_var hmUI 342 42 08 02 00 00 get_field2 showToast 347 0B object 348 04 09 02 00 00 push_atom_value "\u00e6\u00a0\u00bc\u00e5\u00bc\u008f\u00e4\u00b8\u008d\u00e7\u00ac\u00a6\u00e5\u0090\u0088\n\u00e5\u00b7\u00b2\u00e6\u0094\u00b9\u00e6\u0088\u00900" 353 4C D1 01 00 00 define_field text 358 24 01 00 call_method 1 361 0E drop 362 B4 push_0 0 363 28 return 364 38 A3 01 00 00 364: get_var console 369 42 A2 01 00 00 get_field2 log 374 04 DD 01 00 00 push_atom_value "(" 379 62 01 00 get_loc_check 1: arr 382 B5 push_1 1 383 47 get_array_el 384 9E add 385 04 0B 02 00 00 push_atom_value " / " 390 9E add 391 62 01 00 get_loc_check 1: arr 394 B4 push_0 0 395 47 get_array_el 396 9E add 397 04 DE 01 00 00 push_atom_value ")" 402 9E add 403 24 01 00 call_method 1 406 0E drop 407 04 DD 01 00 00 push_atom_value "(" 412 62 01 00 get_loc_check 1: arr 415 B5 push_1 1 416 47 get_array_el 417 9E add 418 04 0B 02 00 00 push_atom_value " / " 423 9E add 424 62 01 00 get_loc_check 1: arr 427 B4 push_0 0 428 47 get_array_el 429 9E add 430 04 DE 01 00 00 push_atom_value ")" 435 9E add 436 28 return 437 38 BC 01 00 00 437: get_var hmUI 442 42 08 02 00 00 get_field2 showToast 447 0B object 448 04 09 02 00 00 push_atom_value "\u00e6\u00a0\u00bc\u00e5\u00bc\u008f\u00e4\u00b8\u008d\u00e7\u00ac\u00a6\u00e5\u0090\u0088\n\u00e5\u00b7\u00b2\u00e6\u0094\u00b9\u00e6\u0088\u00900" 453 4C D1 01 00 00 define_field text 458 24 01 00 call_method 1 461 0E drop 462 B4 push_0 0 463 28 return */ } /* bytecode: 14 BF 01 fclosure8 1: [bytecode parseNumber] 16 C9 put_loc1 1: parseNumber [definition of function parseNumber(str)] */ function parseNumber(str) { /* function not open source bytecode: /sdcard/index.js:211: function: parseNumber mode: strict args: str locals: 0: const regex [level:1 next:-1] 1: const matches [level:1 next:0] 2: let integerPart [level:5 next:1] 3: let decimalPart [level:5 next:2] stack_size: 4 opcodes: 0 61 01 00 set_loc_uninitialized 1: matches 3 61 00 00 set_loc_uninitialized 0: regex 6 D0 get_arg0 0: str 7 98 typeof 8 04 46 00 00 00 push_atom_value number 13 AC strict_eq 14 E9 0B if_false8 26 16 D0 get_arg0 0: str 17 42 37 00 00 00 get_field2 toString 22 24 00 00 call_method 0 25 D4 put_arg0 0: str 26 BE 00 26: push_const8 0: 1"^(-?\\d+)(\\.\\d+)?$" 28 BE 01 push_const8 1: 1"\u0000\u0003\u0000l\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0005\u000b\u0001\u001c\u0004\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u0001-\u0000\n\u001c\u0008\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u00000\u00009\u0000\n\u000c\u0001\u000d\u0002\u0002\u0009 \u0000\u0000\u0000\u000b\u0002\u0001.\u0000\u001c\u0008\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u00000\u00009\u0000\n\u000c\u0002\u0006\u000c\u0000\n" 30 33 regexp 31 C8 put_loc0 0: regex 32 D0 get_arg0 0: str 33 42 22 01 00 00 get_field2 match 38 62 00 00 get_loc_check 0: regex 41 24 01 00 call_method 1 44 C9 put_loc1 1: matches 45 62 01 00 get_loc_check 1: matches 48 E9 60 if_false8 145 50 61 03 00 set_loc_uninitialized 3: decimalPart 53 61 02 00 set_loc_uninitialized 2: integerPart 56 62 01 00 get_loc_check 1: matches 59 B5 push_1 1 60 47 get_array_el 61 CA put_loc2 2: integerPart 62 62 01 00 get_loc_check 1: matches 65 B6 push_2 2 66 47 get_array_el 67 CB put_loc3 3: decimalPart 68 62 03 00 get_loc_check 3: decimalPart 71 E9 1D if_false8 101 73 62 03 00 get_loc_check 3: decimalPart 76 42 28 01 00 00 get_field2 replace 81 BE 02 push_const8 2: 1"^\\." 83 BE 03 push_const8 3: 1"\u0000\u0001\u0000\u0014\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0005\u0001.\u0000\u000c\u0000\n" 85 33 regexp 86 04 0E 02 00 00 push_atom_value "0." 91 24 02 00 call_method 2 94 11 dup 95 63 03 00 put_loc_check 3: decimalPart 98 0E drop 99 EB 0B goto8 111 101 04 0F 02 00 00 101: push_atom_value "0.0" 106 11 dup 107 63 03 00 put_loc_check 3: decimalPart 110 0E drop 111 0B 111: object 112 62 02 00 get_loc_check 2: integerPart 115 42 37 00 00 00 get_field2 toString 120 24 00 00 call_method 0 123 4C FE 01 00 00 define_field integerPart 128 62 03 00 get_loc_check 3: decimalPart 131 42 37 00 00 00 get_field2 toString 136 24 00 00 call_method 0 139 4C 00 02 00 00 define_field decimalPart 144 28 return 145 D0 145: get_arg0 0: str 146 28 return */ } /* 17 61 04 00 set_loc_uninitialized 4: unknownVariable 20 6C 23 00 00 00 catch 56 25 D0 get_arg0 0: equationString 26 42 22 01 00 00 get_field2 match 31 BE 02 push_const8 2: 1"[a-zA-Z]+" 33 BE 03 push_const8 3: 1"\u0001\u0001\u0000-\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u001c\u000c\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0002\u0000A\u0000Z\u0000a\u0000z\u0000\n\u000c\u0000\n" 35 33 regexp 36 24 01 00 call_method 1 39 42 EE 00 00 00 get_field2 reduce 44 BF 04 fclosure8 4: [bytecode <null>] 46 26 00 00 array_from 0 49 24 02 00 call_method 2 52 CA put_loc2 2: arr 53 0E drop 54 EB 0B goto8 66 56 CB 56: put_loc3 3: error 57 6C 07 00 00 00 catch 65 62 0E drop 63 EB 02 goto8 66 65 2F 65: throw 66 C6 66: get_loc2 2: arr 67 B4 push_0 0 68 47 get_array_el 69 C2 04 put_loc8 4: unknownVariable 71 C6 get_loc2 2: arr 72 E8 get_length 73 B5 push_1 1 74 AC strict_eq 75 69 67 02 00 00 if_false 691 80 61 0E 00 set_loc_uninitialized 14: guess 83 61 0D 00 set_loc_uninitialized 13: text 86 61 0C 00 set_loc_uninitialized 12: ans 89 61 0B 00 set_loc_uninitialized 11: equationFunction 92 61 0A 00 set_loc_uninitialized 10: rightHandSide 95 61 09 00 set_loc_uninitialized 9: leftHandSide 98 61 08 00 set_loc_uninitialized 8: equation 101 61 07 00 set_loc_uninitialized 7: replacedEquationString 104 61 06 00 set_loc_uninitialized 6: maxIterations 107 61 05 00 set_loc_uninitialized 5: tolerance 110 BE 05 push_const8 5: 1e-08 112 C2 05 put_loc8 5: tolerance 114 BD 10 27 push_i16 10000 117 C2 06 put_loc8 6: maxIterations 119 D0 get_arg0 0: equationString 120 42 28 01 00 00 get_field2 replace 125 BE 06 push_const8 6: 1"(\\d|\\))(\\(|[a-z]|\u03c0|\u5206\u6578)" 127 BE 07 push_const8 7: 1"\u0001\u0003\u0000]\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u000b\u0001\u0009\u000c\u0000\u0000\u0000\u0015\u0001\u00000\u00009\u0000\u0007\u0003\u0000\u0000\u0000\u0001)\u0000\u000c\u0001\u000b\u0002\u0009&\u0000\u0000\u0000\u0009\u0019\u0000\u0000\u0000\u0009\u0008\u0000\u0000\u0000\u0001(\u0000\u0007\u0007\u0000\u0000\u0000\u0015\u0001\u0000a\u0000z\u0000\u0007\u0003\u0000\u0000\u0000\u0001\u00c0\u0003\u0007\u0006\u0000\u0000\u0000\u0001\u0006R\u0001xe\u000c\u0002\u000c\u0000\n" 129 33 regexp 130 04 F3 01 00 00 push_atom_value "$1*$2" 135 24 02 00 call_method 2 138 42 28 01 00 00 get_field2 replace 143 BE 08 push_const8 8: 1"\\^" 145 BE 09 push_const8 9: 1"\u0001\u0001\u0000\u0013\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001^\u0000\u000c\u0000\n" 147 33 regexp 148 04 F4 01 00 00 push_atom_value "**" 153 24 02 00 call_method 2 156 42 28 01 00 00 get_field2 replace 161 BE 0A push_const8 10: 1"\u00d7" 163 BE 0B push_const8 11: 1"\u0001\u0001\u0000\u0013\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u00d7\u0000\u000c\u0000\n" 165 33 regexp 166 04 7C 00 00 00 push_atom_value "*" 171 24 02 00 call_method 2 174 42 28 01 00 00 get_field2 replace 179 BE 0C push_const8 12: 1"\u00f7" 181 BE 0D push_const8 13: 1"\u0001\u0001\u0000\u0013\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u00f7\u0000\u000c\u0000\n" 183 33 regexp 184 04 F5 01 00 00 push_atom_value "/" 189 24 02 00 call_method 2 192 42 28 01 00 00 get_field2 replace 197 BE 0E push_const8 14: 1"\u03c0" 199 BE 0F push_const8 15: 1"\u0001\u0001\u0000\u0013\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u00c0\u0003\u000c\u0000\n" 201 33 regexp 202 04 F6 01 00 00 push_atom_value "3.14" 207 24 02 00 call_method 2 210 42 28 01 00 00 get_field2 replace 215 BE 10 push_const8 16: 1"\\|([^|]+)\\|" 217 BE 11 push_const8 17: 1"\u0001\u0002\u00007\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001|\u0000\u000b\u0001\u001c\u000c\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0002\u0000\u0000\u0000{\u0000}\u0000\u00ff\u00ff\n\u000c\u0001\u0001|\u0000\u000c\u0000\n" 219 33 regexp 220 04 F7 01 00 00 push_atom_value "(Math.abs($1))" 225 24 02 00 call_method 2 228 42 28 01 00 00 get_field2 replace 233 BE 12 push_const8 18: 1"\u221a\\(([^)]+)\\)" 235 BE 13 push_const8 19: 1"\u0001\u0002\u0000:\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u001a\"\u0001(\u0000\u000b\u0001\u001c\u000c\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0002\u0000\u0000\u0000(\u0000*\u0000\u00ff\u00ff\n\u000c\u0001\u0001)\u0000\u000c\u0000\n" 237 33 regexp 238 04 F8 01 00 00 push_atom_value "(Math.sqrt($1))" 243 24 02 00 call_method 2 246 42 28 01 00 00 get_field2 replace 251 BE 14 push_const8 20: 1"\u5206\u6578\\(([^)]+)\\)" 253 BE 15 push_const8 21: 1"\u0001\u0002\u0000=\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u0006R\u0001xe\u0001(\u0000\u000b\u0001\u001c\u000c\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0002\u0000\u0000\u0000(\u0000*\u0000\u00ff\u00ff\n\u000c\u0001\u0001)\u0000\u000c\u0000\n" 255 33 regexp 256 BF 16 fclosure8 22: [bytecode <null>] 258 24 02 00 call_method 2 261 C2 07 put_loc8 7: replacedEquationString 263 38 A3 01 00 00 get_var console 268 42 A2 01 00 00 get_field2 log 273 62 07 00 get_loc_check 7: replacedEquationString 276 24 01 00 call_method 1 279 0E drop 280 62 07 00 get_loc_check 7: replacedEquationString 283 42 28 01 00 00 get_field2 replace 288 BE 17 push_const8 23: 1"\\s" 290 BE 18 push_const8 24: 1"\u0001\u0001\u0000;\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0015\n\u0000\u0009\u0000\u000d\u0000 \u0000 \u0000\u00a0\u0000\u00a0\u0000\u0080\u0016\u0080\u0016\u0000 \n ( ) / / _ _ \u00000\u00000\u00ff\u00fe\u00ff\u00fe\u000c\u0000\n" 292 33 regexp 293 C0 push_empty_string 294 24 02 00 call_method 2 297 C2 08 put_loc8 8: equation 299 62 08 00 get_loc_check 8: equation 302 42 5C 00 00 00 get_field2 split 307 04 F9 01 00 00 push_atom_value "=" 312 24 01 00 call_method 1 315 B4 push_0 0 316 47 get_array_el 317 C2 09 put_loc8 9: leftHandSide 319 62 08 00 get_loc_check 8: equation 322 42 5C 00 00 00 get_field2 split 327 04 F9 01 00 00 push_atom_value "=" 332 24 01 00 call_method 1 335 B5 push_1 1 336 47 get_array_el 337 C2 0A put_loc8 10: rightHandSide 339 38 3A 00 00 00 get_var eval 344 04 DD 01 00 00 push_atom_value "(" 349 42 5B 00 00 00 get_field2 concat 354 62 04 00 get_loc_check 4: unknownVariable 357 04 FA 01 00 00 push_atom_value ") => " 362 62 09 00 get_loc_check 9: leftHandSide 365 04 FB 01 00 00 push_atom_value " - (" 370 62 0A 00 get_loc_check 10: rightHandSide 373 04 DE 01 00 00 push_atom_value ")" 378 24 06 00 call_method 6 381 31 01 00 0F 00 eval 1,15 386 C2 0B put_loc8 11: equationFunction 388 C0 push_empty_string 389 C2 0C put_loc8 12: ans 391 06 undefined 392 C2 0D put_loc8 13: text 394 B5 push_1 1 395 C2 0E put_loc8 14: guess 397 61 0F 00 set_loc_uninitialized 15: i 400 B4 push_0 0 401 C2 0F put_loc8 15: i 403 62 0F 00 403: get_loc_check 15: i 406 62 06 00 get_loc_check 6: maxIterations 409 A4 lt 410 69 F8 00 00 00 if_false 659 415 61 12 00 set_loc_uninitialized 18: df 418 61 10 00 set_loc_uninitialized 16: f 421 62 0B 00 get_loc_check 11: equationFunction 424 62 0E 00 get_loc_check 14: guess 427 EE call1 1 428 C2 10 put_loc8 16: f 430 38 96 00 00 00 get_var Math 435 42 FC 01 00 00 get_field2 abs 440 62 10 00 get_loc_check 16: f 443 24 01 00 call_method 1 446 62 05 00 get_loc_check 5: tolerance 449 A4 lt 450 69 92 00 00 00 if_false 597 455 61 11 00 set_loc_uninitialized 17: parsedNumber 458 C5 get_loc1 1: parseNumber 459 62 0E 00 get_loc_check 14: guess 462 EE call1 1 463 C2 11 put_loc8 17: parsedNumber 465 38 A3 01 00 00 get_var console 470 42 A2 01 00 00 get_field2 log 475 04 FD 01 00 00 push_atom_value "\u00e6\u0095\u00b4\u00e6\u0095\u00b0\u00e9\u0083\u00a8\u00e5\u0088\u0086:" 480 62 11 00 get_loc_check 17: parsedNumber 483 41 FE 01 00 00 get_field integerPart 488 24 02 00 call_method 2 491 0E drop 492 38 A3 01 00 00 get_var console 497 42 A2 01 00 00 get_field2 log 502 04 FF 01 00 00 push_atom_value "\u00e5\u00b0\u008f\u00e6\u0095\u00b0\u00e9\u0083\u00a8\u00e5\u0088\u0086:" 507 62 11 00 get_loc_check 17: parsedNumber 510 41 00 02 00 00 get_field decimalPart 515 42 37 00 00 00 get_field2 toString 520 24 00 00 call_method 0 523 42 26 01 00 00 get_field2 substr 528 B4 push_0 0 529 BC 0A push_i8 10 531 24 02 00 call_method 2 534 24 02 00 call_method 2 537 0E drop 538 38 96 00 00 00 get_var Math 543 42 01 02 00 00 get_field2 round 548 62 0E 00 get_loc_check 14: guess 551 01 80 96 98 00 push_i32 10000000 556 9B mul 557 24 01 00 call_method 1 560 01 80 96 98 00 push_i32 10000000 565 9C div 566 11 dup 567 63 0D 00 put_loc_check 13: text 570 0E drop 571 04 02 02 00 00 push_atom_value "\u00e6\u0096\u00b9\u00e7\u00a8\u008b\u00e7\u009a\u0084\u00e8\u00a7\u00a3\u00e4\u00b8\u00ba\u00ef\u00bc\u009a\n" 576 62 04 00 get_loc_check 4: unknownVariable 579 9E add 580 04 03 02 00 00 push_atom_value " = " 585 9E add 586 62 0D 00 get_loc_check 13: text 589 9E add 590 11 dup 591 63 0C 00 put_loc_check 12: ans 594 0E drop 595 EB 3F goto8 659 597 62 0B 00 597: get_loc_check 11: equationFunction 600 62 0E 00 get_loc_check 14: guess 603 BE 19 push_const8 25: 1e-13 605 9E add 606 EE call1 1 607 62 10 00 get_loc_check 16: f 610 9F sub 611 BE 1A push_const8 26: 1e-13 613 9C div 614 C2 12 put_loc8 18: df 616 62 0E 00 get_loc_check 14: guess 619 62 10 00 get_loc_check 16: f 622 62 12 00 get_loc_check 18: df 625 9C div 626 9F sub 627 11 dup 628 63 0E 00 put_loc_check 14: guess 631 0E drop 632 38 A3 01 00 00 get_var console 637 42 A2 01 00 00 get_field2 log 642 62 0F 00 get_loc_check 15: i 645 92 post_inc 646 63 0F 00 put_loc_check 15: i 649 62 0E 00 get_loc_check 14: guess 652 24 02 00 call_method 2 655 0E drop 656 EC 02 FF goto16 403 659 38 A3 01 00 00 659: get_var console 664 42 A2 01 00 00 get_field2 log 669 62 0C 00 get_loc_check 12: ans 672 24 01 00 call_method 1 675 0E drop 676 62 0C 00 get_loc_check 12: ans 679 E9 05 if_false8 685 681 62 0C 00 get_loc_check 12: ans 684 28 return 685 04 04 02 00 00 685: push_atom_value "\u00e6\u009c\u00aa\u00e8\u0083\u00bd\u00e6\u0089\u00be\u00e5\u0088\u00b0\u00e6\u0096\u00b9\u00e7\u00a8\u008b\u00e7\u009a\u0084\u00e8\u00a7\u00a3" 690 28 return 691 C6 691: get_loc2 2: arr 692 E8 get_length 693 B4 push_0 0 694 AC strict_eq 695 E9 07 if_false8 703 697 04 05 02 00 00 push_atom_value "\u00e6\u00b2\u0092\u00e6\u009c\u0089\u00e6\u009c\u00aa\u00e7\u009f\u00a5\u00e6\u0095\u00b8" 702 28 return 703 04 06 02 00 00 703: push_atom_value "\u00e7\u009b\u00a1\u00e8\u00ab\u008b\u00e6\u009c\u009f\u00e5\u00be\u0085" 708 28 return */ } this.screen.setProperty(hmUI.prop.MORE, { text: solveEquation(this.screenData), }); Error = true; //this.screenData = "方程式的解为:"+ JSON.stringify(result) } catch (e) { this.screen.setProperty(hmUI.prop.MORE, { text: "請先檢査方程式", }); Error = true; } } else { for (let i = 0; i < brDiff; i++) this.screenData += ")"; } if (Error == false) this.updateScreen(); } _countIncl(str, chr) { let c = 0; for (let i in str) if (str[i] === chr) c++; return c; } switchSet() { const newId = (this.currentSetId + 1) % this.buttonSets.length; const newSet = this.buttonSets[newId]; for (let i = 0; i < newSet.length; i++) { this.buttons[i].setProperty(hmUI.prop.TEXT, newSet[i]); } this.currentSetId = newId; this.currentSet = newSet; } initButtonEvents(i) { return () => { if (i == 11) return this.switchSet(); let val = this.currentSet[i]; if (this.operations[val]) val = this.operations[val]; this.appendScreen(val); while (this.currentSetId != 0) this.switchSet(); }; } appendScreen(val) { this.screenData += val; this.updateScreen(); } updateScreen() { this.screen.setProperty(hmUI.prop.MORE, { text: this.screenData, }); } clear() { this.screenData = ""; this.updateScreen(); } backspace() { let delchar = 1 this.screenData = this.screenData.substring(0, this.screenData.length - delchar); this.updateScreen(); } } // source: /home/melianmiko/Projects/mb7_apps/calculator/entrypoint.js let __$$app$$__ = __$$hmAppManager$$__.currentApp; let __$$module$$__ = __$$app$$__.current; __$$module$$__.module = DeviceRuntimeCore.Page({ onInit() { hmUI.setLayerScrolling(false); new Calculator() .start(); }, }); })();
1如上
作者 @淘汰郎 https://www.bandbbs.cn/threads/9536/
•index.bin 大小縮小>90% (77 kb -> 7 kb)
•大幅減少APP對手環RAM的使用量
•使用更快更流暢
•UI優化
源代碼 (僅作部份開源,有興趣可以自己去原帖買,只需2023 coins 哦 🙂 ):
JavaScript:/** * Build with ZMake tool */ // Build at 2022-08-08 16:53:06.368238 (() => { // source: /home/melianmiko/Projects/mb7_apps/calculator/src/Calculator.js class Calculator { buttons = []; screen = null; screenData = ""; currentSet = []; currentSetId = -1; buttonSets = [ ["7", "8", "9", "4", "5", "6", "1", "2", "3", "0", "."], ["+", "-", "×", "÷", "^", "√", "|", "=", "π", "(", ")"], ["x", "y", "z", "分數", "又", "分之", "", "", "", "", ""],]; operations = { "+": "+", "-": "-", "×": "×", "÷": "÷", "^": "^", "√": "√(", "∛": "∛(", "π": "π", "分數": "分數(", }; start() { // Init screen hmUI.createWidget(5, { x: 5, y: 80, w: 183, h: 76, radius: 8, line_width: 2, color: 0x222222 }); this.screen = hmUI.createWidget(2, { x: 11, y: 80, w: 172, h: 80, color: 0xc5c5c5, text_size: 24, text_style: 1, align_v: 16, }); this.screen.addEventListener(3, () => { this.backspace(); }); // Init buttons for (let i = 0; i < 12; i++) { this.buttons[i] = hmUI.createWidget(23, { x: (i % 3) * 64 + 2, y: Math.floor(i / 3) * 64 + 168, w: 60, h: 60, radius: 8, text_size: 28, normal_color: 0x222222, press_color: 0x333333, click_func: this.initButtonEvents(i), }); } this.buttons[11].setProperty(0, { x: 130, y: 360, w: 60, h: 60, text: "...", normal_color: 0x444444, press_color: 0x666666, }); this.switchSet(); hmUI.createWidget(5, { x: 5, y: 80, w: 183, h: 76, radius: 8, line_width: 2, color: 0x222222 }); this.screen = hmUI.createWidget(2, { x: 11, y: 80, w: 172, h: 80, color: 0xc5c5c5, text_size: 24, text_style: 1, align_v: 16, }); this.screen.addEventListener(3, () => { this.backspace(); }); // Init buttons for (let i = 0; i < 12; i++) { this.buttons[i] = hmUI.createWidget(23, { x: (i % 3) * 64 + 2, y: Math.floor(i / 3) * 64 + 168, w: 60, h: 60, radius: 8, text_size: 28, normal_color: 0x222222, press_color: 0x333333, click_func: this.initButtonEvents(i), }); } this.buttons[11].setProperty(0, { x: 130, y: 360, w: 60, h: 60, text: "...", normal_color: 0x444444, press_color: 0x666666, }); this.switchSet(); // Init remove and process buttons hmUI.createWidget(23, { x: 0, y: 426, w: 192, h: 65, text: "解方程式", normal_color: 0x222222, press_color: 0x444444, text_size: 28, click_func: () => { this.process(); } }); hmUI.createWidget(23, { x: 0, y: 0, w: 192, h: 70, text: "拉進垃圾車", text_size: 20, color: 0x999999, click_func: () => { this.clear(); } }); } calcFactorial(num) { if (num % 1 != 0 || num < 0) { num++; return Math.sqrt(2 * Math.PI / num) * Math.pow((1 / Math.E) * (num + 1 / (12 * num - 1 / (10 * num))), num); } else { return (num == 0) ? 1 : num * this.calcFactorial(num - 1); } } process() { let Error = false; const brDiff = this._countIncl(this.screenData, "(") - this._countIncl(this.screenData, ")"); if (brDiff === 0) { try { function solveEquation(equationString) { /* function not open source bytecode: /sdcard/index.js:181: function: solveEquation mode: strict args: equationString locals: 0: var Fraction 1: var parseNumber 2: var arr 3: catch error [level:3 next:4] 4: let unknownVariable [level:1 next:-1] 5: let tolerance [level:6 next:4] 6: let maxIterations [level:6 next:5] 7: let replacedEquationString [level:6 next:6] 8: let equation [level:6 next:7] 9: let leftHandSide [level:6 next:8] 10: let rightHandSide [level:6 next:9] 11: let equationFunction [level:6 next:10] 12: let ans [level:6 next:11] 13: let text [level:6 next:12] 14: let guess [level:6 next:13] 15: let i [level:7 next:14] 16: let f [level:8 next:15] 17: const parsedNumber [level:10 next:18] 18: let df [level:8 next:16] 19: var this 20: var new.target 21: var arguments closure vars: 0: solveEquation local:loc2 let 1: brDiff local:loc1 const 2: Error local:loc0 let 3: <class_fields_init> parent:loc0 const 4: Calculator parent:loc1 const 5: __$$module$$__ parent:loc2 let 6: __$$app$$__ parent:loc3 let 7: Calculator parent:loc4 let stack_size: 9 opcodes: 0 0C 03 special_object 3 2 C2 14 put_loc8 20: "new.target" 4 08 push_this 5 C2 13 put_loc8 19: this 7 0C 00 special_object 0 9 C2 15 put_loc8 21: arguments 11 BF 00 fclosure8 0: [bytecode Fraction] 13 C8 put_loc0 0: Fraction [definition of function Fraction(str)] */ function Fraction(str) { /* function not open source bytecode: /sdcard/index.js:182: function: Fraction mode: strict args: str locals: 0: let arr [level:7 next:-1] 1: let arr [level:11 next:-1] stack_size: 5 opcodes: 0 D0 get_arg0 0: str 1 98 typeof 2 04 48 00 00 00 push_atom_value string 7 AD strict_neq 8 E9 0B if_false8 20 10 D0 get_arg0 0: str 11 42 37 00 00 00 get_field2 toString 16 24 00 00 call_method 0 19 D4 put_arg0 0: str 20 BE 00 20: push_const8 0: 1"\u5206\u6570\\([^)]+\\)" 22 BE 01 push_const8 1: 1"\u0000\u0001\u00009\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u0006R\u0001pe\u0001(\u0000\u001c\u000c\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0002\u0000\u0000\u0000(\u0000*\u0000\u00ff\u00ff\n\u0001)\u0000\u000c\u0000\n" 24 33 regexp 25 42 82 01 00 00 get_field2 test 30 D0 get_arg0 0: str 31 24 01 00 call_method 1 34 E9 1C if_false8 63 36 38 BC 01 00 00 get_var hmUI 41 42 08 02 00 00 get_field2 showToast 46 0B object 47 04 09 02 00 00 push_atom_value "\u00e6\u00a0\u00bc\u00e5\u00bc\u008f\u00e4\u00b8\u008d\u00e7\u00ac\u00a6\u00e5\u0090\u0088\n\u00e5\u00b7\u00b2\u00e6\u0094\u00b9\u00e6\u0088\u00900" 52 4C D1 01 00 00 define_field text 57 24 01 00 call_method 1 60 0E drop 61 B4 push_0 0 62 28 return 63 BE 02 63: push_const8 2: 1"(^[\\s\\S]*)\u53c8([\\s\\S]*)\u5206\u4e4b([\\s\\S]*)" 65 BE 03 push_const8 3: 1"\u0000\u0004\u0000q\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u000b\u0001\u0005\u001c\u0008\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u0000\u0000\u0000\u00ff\u00ff\n\u000c\u0001\u0001\u00c8S\u000b\u0002\u001c\u0008\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u0000\u0000\u0000\u00ff\u00ff\n\u000c\u0002\u0001\u0006R\u0001KN\u000b\u0003\u001c\u0008\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u0000\u0000\u0000\u00ff\u00ff\n\u000c\u0003\u000c\u0000\n" 67 33 regexp 68 42 82 01 00 00 get_field2 test 73 D0 get_arg0 0: str 74 24 01 00 call_method 1 77 69 C2 00 00 00 if_false 272 82 61 00 00 set_loc_uninitialized 0: arr 85 D0 get_arg0 0: str 86 42 5C 00 00 00 get_field2 split 91 BE 04 push_const8 4: 1"\u53c8|\u5206\u4e4b" 93 BE 05 push_const8 5: 1"\u0000\u0001\u0000#\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0009\u0008\u0000\u0000\u0000\u0001\u00c8S\u0007\u0006\u0000\u0000\u0000\u0001\u0006R\u0001KN\u000c\u0000\n" 95 33 regexp 96 24 01 00 call_method 1 99 C8 put_loc0 0: arr 100 62 00 00 get_loc_check 0: arr 103 E8 get_length 104 B7 push_3 3 105 AD strict_neq 106 11 dup 107 EA 26 if_true8 146 109 0E drop 110 BE 06 push_const8 6: 1"\u53c8" 112 BE 07 push_const8 7: 1"\u0000\u0001\u0000\u0013\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u00c8S\u000c\u0000\n" 114 33 regexp 115 42 82 01 00 00 get_field2 test 120 D0 get_arg0 0: str 121 24 01 00 call_method 1 124 0A push_true 125 AD strict_neq 126 11 dup 127 EA 12 if_true8 146 129 0E drop 130 BE 08 push_const8 8: 1"\u5206\u4e4b" 132 BE 09 push_const8 9: 1"\u0000\u0001\u0000\u0016\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u0006R\u0001KN\u000c\u0000\n" 134 33 regexp 135 42 82 01 00 00 get_field2 test 140 D0 get_arg0 0: str 141 24 01 00 call_method 1 144 0A push_true 145 AD strict_neq 146 E9 1C 146: if_false8 175 148 38 BC 01 00 00 get_var hmUI 153 42 08 02 00 00 get_field2 showToast 158 0B object 159 04 09 02 00 00 push_atom_value "\u00e6\u00a0\u00bc\u00e5\u00bc\u008f\u00e4\u00b8\u008d\u00e7\u00ac\u00a6\u00e5\u0090\u0088\n\u00e5\u00b7\u00b2\u00e6\u0094\u00b9\u00e6\u0088\u00900" 164 4C D1 01 00 00 define_field text 169 24 01 00 call_method 1 172 0E drop 173 B4 push_0 0 174 28 return 175 38 A3 01 00 00 175: get_var console 180 42 A2 01 00 00 get_field2 log 185 04 DD 01 00 00 push_atom_value "(" 190 62 00 00 get_loc_check 0: arr 193 B4 push_0 0 194 47 get_array_el 195 9E add 196 04 0A 02 00 00 push_atom_value " + " 201 9E add 202 62 00 00 get_loc_check 0: arr 205 B6 push_2 2 206 47 get_array_el 207 9E add 208 04 0B 02 00 00 push_atom_value " / " 213 9E add 214 62 00 00 get_loc_check 0: arr 217 B5 push_1 1 218 47 get_array_el 219 9E add 220 04 DE 01 00 00 push_atom_value ")" 225 9E add 226 24 01 00 call_method 1 229 0E drop 230 04 DD 01 00 00 push_atom_value "(" 235 62 00 00 get_loc_check 0: arr 238 B4 push_0 0 239 47 get_array_el 240 9E add 241 04 0A 02 00 00 push_atom_value " + " 246 9E add 247 62 00 00 get_loc_check 0: arr 250 B6 push_2 2 251 47 get_array_el 252 04 0B 02 00 00 push_atom_value " / " 257 9E add 258 62 00 00 get_loc_check 0: arr 261 B5 push_1 1 262 47 get_array_el 263 9E add 264 9E add 265 04 DE 01 00 00 push_atom_value ")" 270 9E add 271 28 return 272 BE 0A 272: push_const8 10: 1"(^[\\s\\S]*)\u5206\u4e4b([\\s\\S]*)" 274 BE 0B push_const8 11: 1"\u0000\u0003\u0000Q\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u000b\u0001\u0005\u001c\u0008\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u0000\u0000\u0000\u00ff\u00ff\n\u000c\u0001\u0001\u0006R\u0001KN\u000b\u0002\u001c\u0008\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u0000\u0000\u0000\u00ff\u00ff\n\u000c\u0002\u000c\u0000\n" 276 33 regexp 277 42 82 01 00 00 get_field2 test 282 D0 get_arg0 0: str 283 24 01 00 call_method 1 286 69 96 00 00 00 if_false 437 291 61 01 00 set_loc_uninitialized 1: arr 294 D0 get_arg0 0: str 295 42 5C 00 00 00 get_field2 split 300 BE 0C push_const8 12: 1"\u5206\u4e4b" 302 BE 0D push_const8 13: 1"\u0000\u0001\u0000\u0016\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u0006R\u0001KN\u000c\u0000\n" 304 33 regexp 305 24 01 00 call_method 1 308 C9 put_loc1 1: arr 309 62 01 00 get_loc_check 1: arr 312 E8 get_length 313 B6 push_2 2 314 AD strict_neq 315 11 dup 316 EA 12 if_true8 335 318 0E drop 319 BE 0E push_const8 14: 1"\u5206\u4e4b" 321 BE 0F push_const8 15: 1"\u0000\u0001\u0000\u0016\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u0006R\u0001KN\u000c\u0000\n" 323 33 regexp 324 42 82 01 00 00 get_field2 test 329 D0 get_arg0 0: str 330 24 01 00 call_method 1 333 0A push_true 334 AD strict_neq 335 E9 1C 335: if_false8 364 337 38 BC 01 00 00 get_var hmUI 342 42 08 02 00 00 get_field2 showToast 347 0B object 348 04 09 02 00 00 push_atom_value "\u00e6\u00a0\u00bc\u00e5\u00bc\u008f\u00e4\u00b8\u008d\u00e7\u00ac\u00a6\u00e5\u0090\u0088\n\u00e5\u00b7\u00b2\u00e6\u0094\u00b9\u00e6\u0088\u00900" 353 4C D1 01 00 00 define_field text 358 24 01 00 call_method 1 361 0E drop 362 B4 push_0 0 363 28 return 364 38 A3 01 00 00 364: get_var console 369 42 A2 01 00 00 get_field2 log 374 04 DD 01 00 00 push_atom_value "(" 379 62 01 00 get_loc_check 1: arr 382 B5 push_1 1 383 47 get_array_el 384 9E add 385 04 0B 02 00 00 push_atom_value " / " 390 9E add 391 62 01 00 get_loc_check 1: arr 394 B4 push_0 0 395 47 get_array_el 396 9E add 397 04 DE 01 00 00 push_atom_value ")" 402 9E add 403 24 01 00 call_method 1 406 0E drop 407 04 DD 01 00 00 push_atom_value "(" 412 62 01 00 get_loc_check 1: arr 415 B5 push_1 1 416 47 get_array_el 417 9E add 418 04 0B 02 00 00 push_atom_value " / " 423 9E add 424 62 01 00 get_loc_check 1: arr 427 B4 push_0 0 428 47 get_array_el 429 9E add 430 04 DE 01 00 00 push_atom_value ")" 435 9E add 436 28 return 437 38 BC 01 00 00 437: get_var hmUI 442 42 08 02 00 00 get_field2 showToast 447 0B object 448 04 09 02 00 00 push_atom_value "\u00e6\u00a0\u00bc\u00e5\u00bc\u008f\u00e4\u00b8\u008d\u00e7\u00ac\u00a6\u00e5\u0090\u0088\n\u00e5\u00b7\u00b2\u00e6\u0094\u00b9\u00e6\u0088\u00900" 453 4C D1 01 00 00 define_field text 458 24 01 00 call_method 1 461 0E drop 462 B4 push_0 0 463 28 return */ } /* bytecode: 14 BF 01 fclosure8 1: [bytecode parseNumber] 16 C9 put_loc1 1: parseNumber [definition of function parseNumber(str)] */ function parseNumber(str) { /* function not open source bytecode: /sdcard/index.js:211: function: parseNumber mode: strict args: str locals: 0: const regex [level:1 next:-1] 1: const matches [level:1 next:0] 2: let integerPart [level:5 next:1] 3: let decimalPart [level:5 next:2] stack_size: 4 opcodes: 0 61 01 00 set_loc_uninitialized 1: matches 3 61 00 00 set_loc_uninitialized 0: regex 6 D0 get_arg0 0: str 7 98 typeof 8 04 46 00 00 00 push_atom_value number 13 AC strict_eq 14 E9 0B if_false8 26 16 D0 get_arg0 0: str 17 42 37 00 00 00 get_field2 toString 22 24 00 00 call_method 0 25 D4 put_arg0 0: str 26 BE 00 26: push_const8 0: 1"^(-?\\d+)(\\.\\d+)?$" 28 BE 01 push_const8 1: 1"\u0000\u0003\u0000l\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0005\u000b\u0001\u001c\u0004\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u0001-\u0000\n\u001c\u0008\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u00000\u00009\u0000\n\u000c\u0001\u000d\u0002\u0002\u0009 \u0000\u0000\u0000\u000b\u0002\u0001.\u0000\u001c\u0008\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u00000\u00009\u0000\n\u000c\u0002\u0006\u000c\u0000\n" 30 33 regexp 31 C8 put_loc0 0: regex 32 D0 get_arg0 0: str 33 42 22 01 00 00 get_field2 match 38 62 00 00 get_loc_check 0: regex 41 24 01 00 call_method 1 44 C9 put_loc1 1: matches 45 62 01 00 get_loc_check 1: matches 48 E9 60 if_false8 145 50 61 03 00 set_loc_uninitialized 3: decimalPart 53 61 02 00 set_loc_uninitialized 2: integerPart 56 62 01 00 get_loc_check 1: matches 59 B5 push_1 1 60 47 get_array_el 61 CA put_loc2 2: integerPart 62 62 01 00 get_loc_check 1: matches 65 B6 push_2 2 66 47 get_array_el 67 CB put_loc3 3: decimalPart 68 62 03 00 get_loc_check 3: decimalPart 71 E9 1D if_false8 101 73 62 03 00 get_loc_check 3: decimalPart 76 42 28 01 00 00 get_field2 replace 81 BE 02 push_const8 2: 1"^\\." 83 BE 03 push_const8 3: 1"\u0000\u0001\u0000\u0014\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0005\u0001.\u0000\u000c\u0000\n" 85 33 regexp 86 04 0E 02 00 00 push_atom_value "0." 91 24 02 00 call_method 2 94 11 dup 95 63 03 00 put_loc_check 3: decimalPart 98 0E drop 99 EB 0B goto8 111 101 04 0F 02 00 00 101: push_atom_value "0.0" 106 11 dup 107 63 03 00 put_loc_check 3: decimalPart 110 0E drop 111 0B 111: object 112 62 02 00 get_loc_check 2: integerPart 115 42 37 00 00 00 get_field2 toString 120 24 00 00 call_method 0 123 4C FE 01 00 00 define_field integerPart 128 62 03 00 get_loc_check 3: decimalPart 131 42 37 00 00 00 get_field2 toString 136 24 00 00 call_method 0 139 4C 00 02 00 00 define_field decimalPart 144 28 return 145 D0 145: get_arg0 0: str 146 28 return */ } /* 17 61 04 00 set_loc_uninitialized 4: unknownVariable 20 6C 23 00 00 00 catch 56 25 D0 get_arg0 0: equationString 26 42 22 01 00 00 get_field2 match 31 BE 02 push_const8 2: 1"[a-zA-Z]+" 33 BE 03 push_const8 3: 1"\u0001\u0001\u0000-\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u001c\u000c\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0002\u0000A\u0000Z\u0000a\u0000z\u0000\n\u000c\u0000\n" 35 33 regexp 36 24 01 00 call_method 1 39 42 EE 00 00 00 get_field2 reduce 44 BF 04 fclosure8 4: [bytecode <null>] 46 26 00 00 array_from 0 49 24 02 00 call_method 2 52 CA put_loc2 2: arr 53 0E drop 54 EB 0B goto8 66 56 CB 56: put_loc3 3: error 57 6C 07 00 00 00 catch 65 62 0E drop 63 EB 02 goto8 66 65 2F 65: throw 66 C6 66: get_loc2 2: arr 67 B4 push_0 0 68 47 get_array_el 69 C2 04 put_loc8 4: unknownVariable 71 C6 get_loc2 2: arr 72 E8 get_length 73 B5 push_1 1 74 AC strict_eq 75 69 67 02 00 00 if_false 691 80 61 0E 00 set_loc_uninitialized 14: guess 83 61 0D 00 set_loc_uninitialized 13: text 86 61 0C 00 set_loc_uninitialized 12: ans 89 61 0B 00 set_loc_uninitialized 11: equationFunction 92 61 0A 00 set_loc_uninitialized 10: rightHandSide 95 61 09 00 set_loc_uninitialized 9: leftHandSide 98 61 08 00 set_loc_uninitialized 8: equation 101 61 07 00 set_loc_uninitialized 7: replacedEquationString 104 61 06 00 set_loc_uninitialized 6: maxIterations 107 61 05 00 set_loc_uninitialized 5: tolerance 110 BE 05 push_const8 5: 1e-08 112 C2 05 put_loc8 5: tolerance 114 BD 10 27 push_i16 10000 117 C2 06 put_loc8 6: maxIterations 119 D0 get_arg0 0: equationString 120 42 28 01 00 00 get_field2 replace 125 BE 06 push_const8 6: 1"(\\d|\\))(\\(|[a-z]|\u03c0|\u5206\u6578)" 127 BE 07 push_const8 7: 1"\u0001\u0003\u0000]\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u000b\u0001\u0009\u000c\u0000\u0000\u0000\u0015\u0001\u00000\u00009\u0000\u0007\u0003\u0000\u0000\u0000\u0001)\u0000\u000c\u0001\u000b\u0002\u0009&\u0000\u0000\u0000\u0009\u0019\u0000\u0000\u0000\u0009\u0008\u0000\u0000\u0000\u0001(\u0000\u0007\u0007\u0000\u0000\u0000\u0015\u0001\u0000a\u0000z\u0000\u0007\u0003\u0000\u0000\u0000\u0001\u00c0\u0003\u0007\u0006\u0000\u0000\u0000\u0001\u0006R\u0001xe\u000c\u0002\u000c\u0000\n" 129 33 regexp 130 04 F3 01 00 00 push_atom_value "$1*$2" 135 24 02 00 call_method 2 138 42 28 01 00 00 get_field2 replace 143 BE 08 push_const8 8: 1"\\^" 145 BE 09 push_const8 9: 1"\u0001\u0001\u0000\u0013\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001^\u0000\u000c\u0000\n" 147 33 regexp 148 04 F4 01 00 00 push_atom_value "**" 153 24 02 00 call_method 2 156 42 28 01 00 00 get_field2 replace 161 BE 0A push_const8 10: 1"\u00d7" 163 BE 0B push_const8 11: 1"\u0001\u0001\u0000\u0013\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u00d7\u0000\u000c\u0000\n" 165 33 regexp 166 04 7C 00 00 00 push_atom_value "*" 171 24 02 00 call_method 2 174 42 28 01 00 00 get_field2 replace 179 BE 0C push_const8 12: 1"\u00f7" 181 BE 0D push_const8 13: 1"\u0001\u0001\u0000\u0013\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u00f7\u0000\u000c\u0000\n" 183 33 regexp 184 04 F5 01 00 00 push_atom_value "/" 189 24 02 00 call_method 2 192 42 28 01 00 00 get_field2 replace 197 BE 0E push_const8 14: 1"\u03c0" 199 BE 0F push_const8 15: 1"\u0001\u0001\u0000\u0013\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u00c0\u0003\u000c\u0000\n" 201 33 regexp 202 04 F6 01 00 00 push_atom_value "3.14" 207 24 02 00 call_method 2 210 42 28 01 00 00 get_field2 replace 215 BE 10 push_const8 16: 1"\\|([^|]+)\\|" 217 BE 11 push_const8 17: 1"\u0001\u0002\u00007\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001|\u0000\u000b\u0001\u001c\u000c\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0002\u0000\u0000\u0000{\u0000}\u0000\u00ff\u00ff\n\u000c\u0001\u0001|\u0000\u000c\u0000\n" 219 33 regexp 220 04 F7 01 00 00 push_atom_value "(Math.abs($1))" 225 24 02 00 call_method 2 228 42 28 01 00 00 get_field2 replace 233 BE 12 push_const8 18: 1"\u221a\\(([^)]+)\\)" 235 BE 13 push_const8 19: 1"\u0001\u0002\u0000:\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u001a\"\u0001(\u0000\u000b\u0001\u001c\u000c\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0002\u0000\u0000\u0000(\u0000*\u0000\u00ff\u00ff\n\u000c\u0001\u0001)\u0000\u000c\u0000\n" 237 33 regexp 238 04 F8 01 00 00 push_atom_value "(Math.sqrt($1))" 243 24 02 00 call_method 2 246 42 28 01 00 00 get_field2 replace 251 BE 14 push_const8 20: 1"\u5206\u6578\\(([^)]+)\\)" 253 BE 15 push_const8 21: 1"\u0001\u0002\u0000=\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u0006R\u0001xe\u0001(\u0000\u000b\u0001\u001c\u000c\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0002\u0000\u0000\u0000(\u0000*\u0000\u00ff\u00ff\n\u000c\u0001\u0001)\u0000\u000c\u0000\n" 255 33 regexp 256 BF 16 fclosure8 22: [bytecode <null>] 258 24 02 00 call_method 2 261 C2 07 put_loc8 7: replacedEquationString 263 38 A3 01 00 00 get_var console 268 42 A2 01 00 00 get_field2 log 273 62 07 00 get_loc_check 7: replacedEquationString 276 24 01 00 call_method 1 279 0E drop 280 62 07 00 get_loc_check 7: replacedEquationString 283 42 28 01 00 00 get_field2 replace 288 BE 17 push_const8 23: 1"\\s" 290 BE 18 push_const8 24: 1"\u0001\u0001\u0000;\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0015\n\u0000\u0009\u0000\u000d\u0000 \u0000 \u0000\u00a0\u0000\u00a0\u0000\u0080\u0016\u0080\u0016\u0000 \n ( ) / / _ _ \u00000\u00000\u00ff\u00fe\u00ff\u00fe\u000c\u0000\n" 292 33 regexp 293 C0 push_empty_string 294 24 02 00 call_method 2 297 C2 08 put_loc8 8: equation 299 62 08 00 get_loc_check 8: equation 302 42 5C 00 00 00 get_field2 split 307 04 F9 01 00 00 push_atom_value "=" 312 24 01 00 call_method 1 315 B4 push_0 0 316 47 get_array_el 317 C2 09 put_loc8 9: leftHandSide 319 62 08 00 get_loc_check 8: equation 322 42 5C 00 00 00 get_field2 split 327 04 F9 01 00 00 push_atom_value "=" 332 24 01 00 call_method 1 335 B5 push_1 1 336 47 get_array_el 337 C2 0A put_loc8 10: rightHandSide 339 38 3A 00 00 00 get_var eval 344 04 DD 01 00 00 push_atom_value "(" 349 42 5B 00 00 00 get_field2 concat 354 62 04 00 get_loc_check 4: unknownVariable 357 04 FA 01 00 00 push_atom_value ") => " 362 62 09 00 get_loc_check 9: leftHandSide 365 04 FB 01 00 00 push_atom_value " - (" 370 62 0A 00 get_loc_check 10: rightHandSide 373 04 DE 01 00 00 push_atom_value ")" 378 24 06 00 call_method 6 381 31 01 00 0F 00 eval 1,15 386 C2 0B put_loc8 11: equationFunction 388 C0 push_empty_string 389 C2 0C put_loc8 12: ans 391 06 undefined 392 C2 0D put_loc8 13: text 394 B5 push_1 1 395 C2 0E put_loc8 14: guess 397 61 0F 00 set_loc_uninitialized 15: i 400 B4 push_0 0 401 C2 0F put_loc8 15: i 403 62 0F 00 403: get_loc_check 15: i 406 62 06 00 get_loc_check 6: maxIterations 409 A4 lt 410 69 F8 00 00 00 if_false 659 415 61 12 00 set_loc_uninitialized 18: df 418 61 10 00 set_loc_uninitialized 16: f 421 62 0B 00 get_loc_check 11: equationFunction 424 62 0E 00 get_loc_check 14: guess 427 EE call1 1 428 C2 10 put_loc8 16: f 430 38 96 00 00 00 get_var Math 435 42 FC 01 00 00 get_field2 abs 440 62 10 00 get_loc_check 16: f 443 24 01 00 call_method 1 446 62 05 00 get_loc_check 5: tolerance 449 A4 lt 450 69 92 00 00 00 if_false 597 455 61 11 00 set_loc_uninitialized 17: parsedNumber 458 C5 get_loc1 1: parseNumber 459 62 0E 00 get_loc_check 14: guess 462 EE call1 1 463 C2 11 put_loc8 17: parsedNumber 465 38 A3 01 00 00 get_var console 470 42 A2 01 00 00 get_field2 log 475 04 FD 01 00 00 push_atom_value "\u00e6\u0095\u00b4\u00e6\u0095\u00b0\u00e9\u0083\u00a8\u00e5\u0088\u0086:" 480 62 11 00 get_loc_check 17: parsedNumber 483 41 FE 01 00 00 get_field integerPart 488 24 02 00 call_method 2 491 0E drop 492 38 A3 01 00 00 get_var console 497 42 A2 01 00 00 get_field2 log 502 04 FF 01 00 00 push_atom_value "\u00e5\u00b0\u008f\u00e6\u0095\u00b0\u00e9\u0083\u00a8\u00e5\u0088\u0086:" 507 62 11 00 get_loc_check 17: parsedNumber 510 41 00 02 00 00 get_field decimalPart 515 42 37 00 00 00 get_field2 toString 520 24 00 00 call_method 0 523 42 26 01 00 00 get_field2 substr 528 B4 push_0 0 529 BC 0A push_i8 10 531 24 02 00 call_method 2 534 24 02 00 call_method 2 537 0E drop 538 38 96 00 00 00 get_var Math 543 42 01 02 00 00 get_field2 round 548 62 0E 00 get_loc_check 14: guess 551 01 80 96 98 00 push_i32 10000000 556 9B mul 557 24 01 00 call_method 1 560 01 80 96 98 00 push_i32 10000000 565 9C div 566 11 dup 567 63 0D 00 put_loc_check 13: text 570 0E drop 571 04 02 02 00 00 push_atom_value "\u00e6\u0096\u00b9\u00e7\u00a8\u008b\u00e7\u009a\u0084\u00e8\u00a7\u00a3\u00e4\u00b8\u00ba\u00ef\u00bc\u009a\n" 576 62 04 00 get_loc_check 4: unknownVariable 579 9E add 580 04 03 02 00 00 push_atom_value " = " 585 9E add 586 62 0D 00 get_loc_check 13: text 589 9E add 590 11 dup 591 63 0C 00 put_loc_check 12: ans 594 0E drop 595 EB 3F goto8 659 597 62 0B 00 597: get_loc_check 11: equationFunction 600 62 0E 00 get_loc_check 14: guess 603 BE 19 push_const8 25: 1e-13 605 9E add 606 EE call1 1 607 62 10 00 get_loc_check 16: f 610 9F sub 611 BE 1A push_const8 26: 1e-13 613 9C div 614 C2 12 put_loc8 18: df 616 62 0E 00 get_loc_check 14: guess 619 62 10 00 get_loc_check 16: f 622 62 12 00 get_loc_check 18: df 625 9C div 626 9F sub 627 11 dup 628 63 0E 00 put_loc_check 14: guess 631 0E drop 632 38 A3 01 00 00 get_var console 637 42 A2 01 00 00 get_field2 log 642 62 0F 00 get_loc_check 15: i 645 92 post_inc 646 63 0F 00 put_loc_check 15: i 649 62 0E 00 get_loc_check 14: guess 652 24 02 00 call_method 2 655 0E drop 656 EC 02 FF goto16 403 659 38 A3 01 00 00 659: get_var console 664 42 A2 01 00 00 get_field2 log 669 62 0C 00 get_loc_check 12: ans 672 24 01 00 call_method 1 675 0E drop 676 62 0C 00 get_loc_check 12: ans 679 E9 05 if_false8 685 681 62 0C 00 get_loc_check 12: ans 684 28 return 685 04 04 02 00 00 685: push_atom_value "\u00e6\u009c\u00aa\u00e8\u0083\u00bd\u00e6\u0089\u00be\u00e5\u0088\u00b0\u00e6\u0096\u00b9\u00e7\u00a8\u008b\u00e7\u009a\u0084\u00e8\u00a7\u00a3" 690 28 return 691 C6 691: get_loc2 2: arr 692 E8 get_length 693 B4 push_0 0 694 AC strict_eq 695 E9 07 if_false8 703 697 04 05 02 00 00 push_atom_value "\u00e6\u00b2\u0092\u00e6\u009c\u0089\u00e6\u009c\u00aa\u00e7\u009f\u00a5\u00e6\u0095\u00b8" 702 28 return 703 04 06 02 00 00 703: push_atom_value "\u00e7\u009b\u00a1\u00e8\u00ab\u008b\u00e6\u009c\u009f\u00e5\u00be\u0085" 708 28 return */ } this.screen.setProperty(hmUI.prop.MORE, { text: solveEquation(this.screenData), }); Error = true; //this.screenData = "方程式的解为:"+ JSON.stringify(result) } catch (e) { this.screen.setProperty(hmUI.prop.MORE, { text: "請先檢査方程式", }); Error = true; } } else { for (let i = 0; i < brDiff; i++) this.screenData += ")"; } if (Error == false) this.updateScreen(); } _countIncl(str, chr) { let c = 0; for (let i in str) if (str[i] === chr) c++; return c; } switchSet() { const newId = (this.currentSetId + 1) % this.buttonSets.length; const newSet = this.buttonSets[newId]; for (let i = 0; i < newSet.length; i++) { this.buttons[i].setProperty(hmUI.prop.TEXT, newSet[i]); } this.currentSetId = newId; this.currentSet = newSet; } initButtonEvents(i) { return () => { if (i == 11) return this.switchSet(); let val = this.currentSet[i]; if (this.operations[val]) val = this.operations[val]; this.appendScreen(val); while (this.currentSetId != 0) this.switchSet(); }; } appendScreen(val) { this.screenData += val; this.updateScreen(); } updateScreen() { this.screen.setProperty(hmUI.prop.MORE, { text: this.screenData, }); } clear() { this.screenData = ""; this.updateScreen(); } backspace() { let delchar = 1 this.screenData = this.screenData.substring(0, this.screenData.length - delchar); this.updateScreen(); } } // source: /home/melianmiko/Projects/mb7_apps/calculator/entrypoint.js let __$$app$$__ = __$$hmAppManager$$__.currentApp; let __$$module$$__ = __$$app$$__.current; __$$module$$__.module = DeviceRuntimeCore.Page({ onInit() { hmUI.setLayerScrolling(false); new Calculator() .start(); }, }); })();
好好好如上
作者 @淘汰郎 https://www.bandbbs.cn/threads/9536/
•index.bin 大小縮小>90% (77 kb -> 7 kb)
•大幅減少APP對手環RAM的使用量
•使用更快更流暢
•UI優化
源代碼 (僅作部份開源,有興趣可以自己去原帖買,只需2023 coins 哦 🙂 ):
JavaScript:/** * Build with ZMake tool */ // Build at 2022-08-08 16:53:06.368238 (() => { // source: /home/melianmiko/Projects/mb7_apps/calculator/src/Calculator.js class Calculator { buttons = []; screen = null; screenData = ""; currentSet = []; currentSetId = -1; buttonSets = [ ["7", "8", "9", "4", "5", "6", "1", "2", "3", "0", "."], ["+", "-", "×", "÷", "^", "√", "|", "=", "π", "(", ")"], ["x", "y", "z", "分數", "又", "分之", "", "", "", "", ""],]; operations = { "+": "+", "-": "-", "×": "×", "÷": "÷", "^": "^", "√": "√(", "∛": "∛(", "π": "π", "分數": "分數(", }; start() { // Init screen hmUI.createWidget(5, { x: 5, y: 80, w: 183, h: 76, radius: 8, line_width: 2, color: 0x222222 }); this.screen = hmUI.createWidget(2, { x: 11, y: 80, w: 172, h: 80, color: 0xc5c5c5, text_size: 24, text_style: 1, align_v: 16, }); this.screen.addEventListener(3, () => { this.backspace(); }); // Init buttons for (let i = 0; i < 12; i++) { this.buttons[i] = hmUI.createWidget(23, { x: (i % 3) * 64 + 2, y: Math.floor(i / 3) * 64 + 168, w: 60, h: 60, radius: 8, text_size: 28, normal_color: 0x222222, press_color: 0x333333, click_func: this.initButtonEvents(i), }); } this.buttons[11].setProperty(0, { x: 130, y: 360, w: 60, h: 60, text: "...", normal_color: 0x444444, press_color: 0x666666, }); this.switchSet(); hmUI.createWidget(5, { x: 5, y: 80, w: 183, h: 76, radius: 8, line_width: 2, color: 0x222222 }); this.screen = hmUI.createWidget(2, { x: 11, y: 80, w: 172, h: 80, color: 0xc5c5c5, text_size: 24, text_style: 1, align_v: 16, }); this.screen.addEventListener(3, () => { this.backspace(); }); // Init buttons for (let i = 0; i < 12; i++) { this.buttons[i] = hmUI.createWidget(23, { x: (i % 3) * 64 + 2, y: Math.floor(i / 3) * 64 + 168, w: 60, h: 60, radius: 8, text_size: 28, normal_color: 0x222222, press_color: 0x333333, click_func: this.initButtonEvents(i), }); } this.buttons[11].setProperty(0, { x: 130, y: 360, w: 60, h: 60, text: "...", normal_color: 0x444444, press_color: 0x666666, }); this.switchSet(); // Init remove and process buttons hmUI.createWidget(23, { x: 0, y: 426, w: 192, h: 65, text: "解方程式", normal_color: 0x222222, press_color: 0x444444, text_size: 28, click_func: () => { this.process(); } }); hmUI.createWidget(23, { x: 0, y: 0, w: 192, h: 70, text: "拉進垃圾車", text_size: 20, color: 0x999999, click_func: () => { this.clear(); } }); } calcFactorial(num) { if (num % 1 != 0 || num < 0) { num++; return Math.sqrt(2 * Math.PI / num) * Math.pow((1 / Math.E) * (num + 1 / (12 * num - 1 / (10 * num))), num); } else { return (num == 0) ? 1 : num * this.calcFactorial(num - 1); } } process() { let Error = false; const brDiff = this._countIncl(this.screenData, "(") - this._countIncl(this.screenData, ")"); if (brDiff === 0) { try { function solveEquation(equationString) { /* function not open source bytecode: /sdcard/index.js:181: function: solveEquation mode: strict args: equationString locals: 0: var Fraction 1: var parseNumber 2: var arr 3: catch error [level:3 next:4] 4: let unknownVariable [level:1 next:-1] 5: let tolerance [level:6 next:4] 6: let maxIterations [level:6 next:5] 7: let replacedEquationString [level:6 next:6] 8: let equation [level:6 next:7] 9: let leftHandSide [level:6 next:8] 10: let rightHandSide [level:6 next:9] 11: let equationFunction [level:6 next:10] 12: let ans [level:6 next:11] 13: let text [level:6 next:12] 14: let guess [level:6 next:13] 15: let i [level:7 next:14] 16: let f [level:8 next:15] 17: const parsedNumber [level:10 next:18] 18: let df [level:8 next:16] 19: var this 20: var new.target 21: var arguments closure vars: 0: solveEquation local:loc2 let 1: brDiff local:loc1 const 2: Error local:loc0 let 3: <class_fields_init> parent:loc0 const 4: Calculator parent:loc1 const 5: __$$module$$__ parent:loc2 let 6: __$$app$$__ parent:loc3 let 7: Calculator parent:loc4 let stack_size: 9 opcodes: 0 0C 03 special_object 3 2 C2 14 put_loc8 20: "new.target" 4 08 push_this 5 C2 13 put_loc8 19: this 7 0C 00 special_object 0 9 C2 15 put_loc8 21: arguments 11 BF 00 fclosure8 0: [bytecode Fraction] 13 C8 put_loc0 0: Fraction [definition of function Fraction(str)] */ function Fraction(str) { /* function not open source bytecode: /sdcard/index.js:182: function: Fraction mode: strict args: str locals: 0: let arr [level:7 next:-1] 1: let arr [level:11 next:-1] stack_size: 5 opcodes: 0 D0 get_arg0 0: str 1 98 typeof 2 04 48 00 00 00 push_atom_value string 7 AD strict_neq 8 E9 0B if_false8 20 10 D0 get_arg0 0: str 11 42 37 00 00 00 get_field2 toString 16 24 00 00 call_method 0 19 D4 put_arg0 0: str 20 BE 00 20: push_const8 0: 1"\u5206\u6570\\([^)]+\\)" 22 BE 01 push_const8 1: 1"\u0000\u0001\u00009\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u0006R\u0001pe\u0001(\u0000\u001c\u000c\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0002\u0000\u0000\u0000(\u0000*\u0000\u00ff\u00ff\n\u0001)\u0000\u000c\u0000\n" 24 33 regexp 25 42 82 01 00 00 get_field2 test 30 D0 get_arg0 0: str 31 24 01 00 call_method 1 34 E9 1C if_false8 63 36 38 BC 01 00 00 get_var hmUI 41 42 08 02 00 00 get_field2 showToast 46 0B object 47 04 09 02 00 00 push_atom_value "\u00e6\u00a0\u00bc\u00e5\u00bc\u008f\u00e4\u00b8\u008d\u00e7\u00ac\u00a6\u00e5\u0090\u0088\n\u00e5\u00b7\u00b2\u00e6\u0094\u00b9\u00e6\u0088\u00900" 52 4C D1 01 00 00 define_field text 57 24 01 00 call_method 1 60 0E drop 61 B4 push_0 0 62 28 return 63 BE 02 63: push_const8 2: 1"(^[\\s\\S]*)\u53c8([\\s\\S]*)\u5206\u4e4b([\\s\\S]*)" 65 BE 03 push_const8 3: 1"\u0000\u0004\u0000q\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u000b\u0001\u0005\u001c\u0008\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u0000\u0000\u0000\u00ff\u00ff\n\u000c\u0001\u0001\u00c8S\u000b\u0002\u001c\u0008\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u0000\u0000\u0000\u00ff\u00ff\n\u000c\u0002\u0001\u0006R\u0001KN\u000b\u0003\u001c\u0008\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u0000\u0000\u0000\u00ff\u00ff\n\u000c\u0003\u000c\u0000\n" 67 33 regexp 68 42 82 01 00 00 get_field2 test 73 D0 get_arg0 0: str 74 24 01 00 call_method 1 77 69 C2 00 00 00 if_false 272 82 61 00 00 set_loc_uninitialized 0: arr 85 D0 get_arg0 0: str 86 42 5C 00 00 00 get_field2 split 91 BE 04 push_const8 4: 1"\u53c8|\u5206\u4e4b" 93 BE 05 push_const8 5: 1"\u0000\u0001\u0000#\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0009\u0008\u0000\u0000\u0000\u0001\u00c8S\u0007\u0006\u0000\u0000\u0000\u0001\u0006R\u0001KN\u000c\u0000\n" 95 33 regexp 96 24 01 00 call_method 1 99 C8 put_loc0 0: arr 100 62 00 00 get_loc_check 0: arr 103 E8 get_length 104 B7 push_3 3 105 AD strict_neq 106 11 dup 107 EA 26 if_true8 146 109 0E drop 110 BE 06 push_const8 6: 1"\u53c8" 112 BE 07 push_const8 7: 1"\u0000\u0001\u0000\u0013\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u00c8S\u000c\u0000\n" 114 33 regexp 115 42 82 01 00 00 get_field2 test 120 D0 get_arg0 0: str 121 24 01 00 call_method 1 124 0A push_true 125 AD strict_neq 126 11 dup 127 EA 12 if_true8 146 129 0E drop 130 BE 08 push_const8 8: 1"\u5206\u4e4b" 132 BE 09 push_const8 9: 1"\u0000\u0001\u0000\u0016\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u0006R\u0001KN\u000c\u0000\n" 134 33 regexp 135 42 82 01 00 00 get_field2 test 140 D0 get_arg0 0: str 141 24 01 00 call_method 1 144 0A push_true 145 AD strict_neq 146 E9 1C 146: if_false8 175 148 38 BC 01 00 00 get_var hmUI 153 42 08 02 00 00 get_field2 showToast 158 0B object 159 04 09 02 00 00 push_atom_value "\u00e6\u00a0\u00bc\u00e5\u00bc\u008f\u00e4\u00b8\u008d\u00e7\u00ac\u00a6\u00e5\u0090\u0088\n\u00e5\u00b7\u00b2\u00e6\u0094\u00b9\u00e6\u0088\u00900" 164 4C D1 01 00 00 define_field text 169 24 01 00 call_method 1 172 0E drop 173 B4 push_0 0 174 28 return 175 38 A3 01 00 00 175: get_var console 180 42 A2 01 00 00 get_field2 log 185 04 DD 01 00 00 push_atom_value "(" 190 62 00 00 get_loc_check 0: arr 193 B4 push_0 0 194 47 get_array_el 195 9E add 196 04 0A 02 00 00 push_atom_value " + " 201 9E add 202 62 00 00 get_loc_check 0: arr 205 B6 push_2 2 206 47 get_array_el 207 9E add 208 04 0B 02 00 00 push_atom_value " / " 213 9E add 214 62 00 00 get_loc_check 0: arr 217 B5 push_1 1 218 47 get_array_el 219 9E add 220 04 DE 01 00 00 push_atom_value ")" 225 9E add 226 24 01 00 call_method 1 229 0E drop 230 04 DD 01 00 00 push_atom_value "(" 235 62 00 00 get_loc_check 0: arr 238 B4 push_0 0 239 47 get_array_el 240 9E add 241 04 0A 02 00 00 push_atom_value " + " 246 9E add 247 62 00 00 get_loc_check 0: arr 250 B6 push_2 2 251 47 get_array_el 252 04 0B 02 00 00 push_atom_value " / " 257 9E add 258 62 00 00 get_loc_check 0: arr 261 B5 push_1 1 262 47 get_array_el 263 9E add 264 9E add 265 04 DE 01 00 00 push_atom_value ")" 270 9E add 271 28 return 272 BE 0A 272: push_const8 10: 1"(^[\\s\\S]*)\u5206\u4e4b([\\s\\S]*)" 274 BE 0B push_const8 11: 1"\u0000\u0003\u0000Q\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u000b\u0001\u0005\u001c\u0008\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u0000\u0000\u0000\u00ff\u00ff\n\u000c\u0001\u0001\u0006R\u0001KN\u000b\u0002\u001c\u0008\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u0000\u0000\u0000\u00ff\u00ff\n\u000c\u0002\u000c\u0000\n" 276 33 regexp 277 42 82 01 00 00 get_field2 test 282 D0 get_arg0 0: str 283 24 01 00 call_method 1 286 69 96 00 00 00 if_false 437 291 61 01 00 set_loc_uninitialized 1: arr 294 D0 get_arg0 0: str 295 42 5C 00 00 00 get_field2 split 300 BE 0C push_const8 12: 1"\u5206\u4e4b" 302 BE 0D push_const8 13: 1"\u0000\u0001\u0000\u0016\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u0006R\u0001KN\u000c\u0000\n" 304 33 regexp 305 24 01 00 call_method 1 308 C9 put_loc1 1: arr 309 62 01 00 get_loc_check 1: arr 312 E8 get_length 313 B6 push_2 2 314 AD strict_neq 315 11 dup 316 EA 12 if_true8 335 318 0E drop 319 BE 0E push_const8 14: 1"\u5206\u4e4b" 321 BE 0F push_const8 15: 1"\u0000\u0001\u0000\u0016\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u0006R\u0001KN\u000c\u0000\n" 323 33 regexp 324 42 82 01 00 00 get_field2 test 329 D0 get_arg0 0: str 330 24 01 00 call_method 1 333 0A push_true 334 AD strict_neq 335 E9 1C 335: if_false8 364 337 38 BC 01 00 00 get_var hmUI 342 42 08 02 00 00 get_field2 showToast 347 0B object 348 04 09 02 00 00 push_atom_value "\u00e6\u00a0\u00bc\u00e5\u00bc\u008f\u00e4\u00b8\u008d\u00e7\u00ac\u00a6\u00e5\u0090\u0088\n\u00e5\u00b7\u00b2\u00e6\u0094\u00b9\u00e6\u0088\u00900" 353 4C D1 01 00 00 define_field text 358 24 01 00 call_method 1 361 0E drop 362 B4 push_0 0 363 28 return 364 38 A3 01 00 00 364: get_var console 369 42 A2 01 00 00 get_field2 log 374 04 DD 01 00 00 push_atom_value "(" 379 62 01 00 get_loc_check 1: arr 382 B5 push_1 1 383 47 get_array_el 384 9E add 385 04 0B 02 00 00 push_atom_value " / " 390 9E add 391 62 01 00 get_loc_check 1: arr 394 B4 push_0 0 395 47 get_array_el 396 9E add 397 04 DE 01 00 00 push_atom_value ")" 402 9E add 403 24 01 00 call_method 1 406 0E drop 407 04 DD 01 00 00 push_atom_value "(" 412 62 01 00 get_loc_check 1: arr 415 B5 push_1 1 416 47 get_array_el 417 9E add 418 04 0B 02 00 00 push_atom_value " / " 423 9E add 424 62 01 00 get_loc_check 1: arr 427 B4 push_0 0 428 47 get_array_el 429 9E add 430 04 DE 01 00 00 push_atom_value ")" 435 9E add 436 28 return 437 38 BC 01 00 00 437: get_var hmUI 442 42 08 02 00 00 get_field2 showToast 447 0B object 448 04 09 02 00 00 push_atom_value "\u00e6\u00a0\u00bc\u00e5\u00bc\u008f\u00e4\u00b8\u008d\u00e7\u00ac\u00a6\u00e5\u0090\u0088\n\u00e5\u00b7\u00b2\u00e6\u0094\u00b9\u00e6\u0088\u00900" 453 4C D1 01 00 00 define_field text 458 24 01 00 call_method 1 461 0E drop 462 B4 push_0 0 463 28 return */ } /* bytecode: 14 BF 01 fclosure8 1: [bytecode parseNumber] 16 C9 put_loc1 1: parseNumber [definition of function parseNumber(str)] */ function parseNumber(str) { /* function not open source bytecode: /sdcard/index.js:211: function: parseNumber mode: strict args: str locals: 0: const regex [level:1 next:-1] 1: const matches [level:1 next:0] 2: let integerPart [level:5 next:1] 3: let decimalPart [level:5 next:2] stack_size: 4 opcodes: 0 61 01 00 set_loc_uninitialized 1: matches 3 61 00 00 set_loc_uninitialized 0: regex 6 D0 get_arg0 0: str 7 98 typeof 8 04 46 00 00 00 push_atom_value number 13 AC strict_eq 14 E9 0B if_false8 26 16 D0 get_arg0 0: str 17 42 37 00 00 00 get_field2 toString 22 24 00 00 call_method 0 25 D4 put_arg0 0: str 26 BE 00 26: push_const8 0: 1"^(-?\\d+)(\\.\\d+)?$" 28 BE 01 push_const8 1: 1"\u0000\u0003\u0000l\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0005\u000b\u0001\u001c\u0004\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u0001-\u0000\n\u001c\u0008\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u00000\u00009\u0000\n\u000c\u0001\u000d\u0002\u0002\u0009 \u0000\u0000\u0000\u000b\u0002\u0001.\u0000\u001c\u0008\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u00000\u00009\u0000\n\u000c\u0002\u0006\u000c\u0000\n" 30 33 regexp 31 C8 put_loc0 0: regex 32 D0 get_arg0 0: str 33 42 22 01 00 00 get_field2 match 38 62 00 00 get_loc_check 0: regex 41 24 01 00 call_method 1 44 C9 put_loc1 1: matches 45 62 01 00 get_loc_check 1: matches 48 E9 60 if_false8 145 50 61 03 00 set_loc_uninitialized 3: decimalPart 53 61 02 00 set_loc_uninitialized 2: integerPart 56 62 01 00 get_loc_check 1: matches 59 B5 push_1 1 60 47 get_array_el 61 CA put_loc2 2: integerPart 62 62 01 00 get_loc_check 1: matches 65 B6 push_2 2 66 47 get_array_el 67 CB put_loc3 3: decimalPart 68 62 03 00 get_loc_check 3: decimalPart 71 E9 1D if_false8 101 73 62 03 00 get_loc_check 3: decimalPart 76 42 28 01 00 00 get_field2 replace 81 BE 02 push_const8 2: 1"^\\." 83 BE 03 push_const8 3: 1"\u0000\u0001\u0000\u0014\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0005\u0001.\u0000\u000c\u0000\n" 85 33 regexp 86 04 0E 02 00 00 push_atom_value "0." 91 24 02 00 call_method 2 94 11 dup 95 63 03 00 put_loc_check 3: decimalPart 98 0E drop 99 EB 0B goto8 111 101 04 0F 02 00 00 101: push_atom_value "0.0" 106 11 dup 107 63 03 00 put_loc_check 3: decimalPart 110 0E drop 111 0B 111: object 112 62 02 00 get_loc_check 2: integerPart 115 42 37 00 00 00 get_field2 toString 120 24 00 00 call_method 0 123 4C FE 01 00 00 define_field integerPart 128 62 03 00 get_loc_check 3: decimalPart 131 42 37 00 00 00 get_field2 toString 136 24 00 00 call_method 0 139 4C 00 02 00 00 define_field decimalPart 144 28 return 145 D0 145: get_arg0 0: str 146 28 return */ } /* 17 61 04 00 set_loc_uninitialized 4: unknownVariable 20 6C 23 00 00 00 catch 56 25 D0 get_arg0 0: equationString 26 42 22 01 00 00 get_field2 match 31 BE 02 push_const8 2: 1"[a-zA-Z]+" 33 BE 03 push_const8 3: 1"\u0001\u0001\u0000-\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u001c\u000c\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0002\u0000A\u0000Z\u0000a\u0000z\u0000\n\u000c\u0000\n" 35 33 regexp 36 24 01 00 call_method 1 39 42 EE 00 00 00 get_field2 reduce 44 BF 04 fclosure8 4: [bytecode <null>] 46 26 00 00 array_from 0 49 24 02 00 call_method 2 52 CA put_loc2 2: arr 53 0E drop 54 EB 0B goto8 66 56 CB 56: put_loc3 3: error 57 6C 07 00 00 00 catch 65 62 0E drop 63 EB 02 goto8 66 65 2F 65: throw 66 C6 66: get_loc2 2: arr 67 B4 push_0 0 68 47 get_array_el 69 C2 04 put_loc8 4: unknownVariable 71 C6 get_loc2 2: arr 72 E8 get_length 73 B5 push_1 1 74 AC strict_eq 75 69 67 02 00 00 if_false 691 80 61 0E 00 set_loc_uninitialized 14: guess 83 61 0D 00 set_loc_uninitialized 13: text 86 61 0C 00 set_loc_uninitialized 12: ans 89 61 0B 00 set_loc_uninitialized 11: equationFunction 92 61 0A 00 set_loc_uninitialized 10: rightHandSide 95 61 09 00 set_loc_uninitialized 9: leftHandSide 98 61 08 00 set_loc_uninitialized 8: equation 101 61 07 00 set_loc_uninitialized 7: replacedEquationString 104 61 06 00 set_loc_uninitialized 6: maxIterations 107 61 05 00 set_loc_uninitialized 5: tolerance 110 BE 05 push_const8 5: 1e-08 112 C2 05 put_loc8 5: tolerance 114 BD 10 27 push_i16 10000 117 C2 06 put_loc8 6: maxIterations 119 D0 get_arg0 0: equationString 120 42 28 01 00 00 get_field2 replace 125 BE 06 push_const8 6: 1"(\\d|\\))(\\(|[a-z]|\u03c0|\u5206\u6578)" 127 BE 07 push_const8 7: 1"\u0001\u0003\u0000]\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u000b\u0001\u0009\u000c\u0000\u0000\u0000\u0015\u0001\u00000\u00009\u0000\u0007\u0003\u0000\u0000\u0000\u0001)\u0000\u000c\u0001\u000b\u0002\u0009&\u0000\u0000\u0000\u0009\u0019\u0000\u0000\u0000\u0009\u0008\u0000\u0000\u0000\u0001(\u0000\u0007\u0007\u0000\u0000\u0000\u0015\u0001\u0000a\u0000z\u0000\u0007\u0003\u0000\u0000\u0000\u0001\u00c0\u0003\u0007\u0006\u0000\u0000\u0000\u0001\u0006R\u0001xe\u000c\u0002\u000c\u0000\n" 129 33 regexp 130 04 F3 01 00 00 push_atom_value "$1*$2" 135 24 02 00 call_method 2 138 42 28 01 00 00 get_field2 replace 143 BE 08 push_const8 8: 1"\\^" 145 BE 09 push_const8 9: 1"\u0001\u0001\u0000\u0013\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001^\u0000\u000c\u0000\n" 147 33 regexp 148 04 F4 01 00 00 push_atom_value "**" 153 24 02 00 call_method 2 156 42 28 01 00 00 get_field2 replace 161 BE 0A push_const8 10: 1"\u00d7" 163 BE 0B push_const8 11: 1"\u0001\u0001\u0000\u0013\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u00d7\u0000\u000c\u0000\n" 165 33 regexp 166 04 7C 00 00 00 push_atom_value "*" 171 24 02 00 call_method 2 174 42 28 01 00 00 get_field2 replace 179 BE 0C push_const8 12: 1"\u00f7" 181 BE 0D push_const8 13: 1"\u0001\u0001\u0000\u0013\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u00f7\u0000\u000c\u0000\n" 183 33 regexp 184 04 F5 01 00 00 push_atom_value "/" 189 24 02 00 call_method 2 192 42 28 01 00 00 get_field2 replace 197 BE 0E push_const8 14: 1"\u03c0" 199 BE 0F push_const8 15: 1"\u0001\u0001\u0000\u0013\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u00c0\u0003\u000c\u0000\n" 201 33 regexp 202 04 F6 01 00 00 push_atom_value "3.14" 207 24 02 00 call_method 2 210 42 28 01 00 00 get_field2 replace 215 BE 10 push_const8 16: 1"\\|([^|]+)\\|" 217 BE 11 push_const8 17: 1"\u0001\u0002\u00007\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001|\u0000\u000b\u0001\u001c\u000c\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0002\u0000\u0000\u0000{\u0000}\u0000\u00ff\u00ff\n\u000c\u0001\u0001|\u0000\u000c\u0000\n" 219 33 regexp 220 04 F7 01 00 00 push_atom_value "(Math.abs($1))" 225 24 02 00 call_method 2 228 42 28 01 00 00 get_field2 replace 233 BE 12 push_const8 18: 1"\u221a\\(([^)]+)\\)" 235 BE 13 push_const8 19: 1"\u0001\u0002\u0000:\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u001a\"\u0001(\u0000\u000b\u0001\u001c\u000c\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0002\u0000\u0000\u0000(\u0000*\u0000\u00ff\u00ff\n\u000c\u0001\u0001)\u0000\u000c\u0000\n" 237 33 regexp 238 04 F8 01 00 00 push_atom_value "(Math.sqrt($1))" 243 24 02 00 call_method 2 246 42 28 01 00 00 get_field2 replace 251 BE 14 push_const8 20: 1"\u5206\u6578\\(([^)]+)\\)" 253 BE 15 push_const8 21: 1"\u0001\u0002\u0000=\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u0006R\u0001xe\u0001(\u0000\u000b\u0001\u001c\u000c\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0002\u0000\u0000\u0000(\u0000*\u0000\u00ff\u00ff\n\u000c\u0001\u0001)\u0000\u000c\u0000\n" 255 33 regexp 256 BF 16 fclosure8 22: [bytecode <null>] 258 24 02 00 call_method 2 261 C2 07 put_loc8 7: replacedEquationString 263 38 A3 01 00 00 get_var console 268 42 A2 01 00 00 get_field2 log 273 62 07 00 get_loc_check 7: replacedEquationString 276 24 01 00 call_method 1 279 0E drop 280 62 07 00 get_loc_check 7: replacedEquationString 283 42 28 01 00 00 get_field2 replace 288 BE 17 push_const8 23: 1"\\s" 290 BE 18 push_const8 24: 1"\u0001\u0001\u0000;\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0015\n\u0000\u0009\u0000\u000d\u0000 \u0000 \u0000\u00a0\u0000\u00a0\u0000\u0080\u0016\u0080\u0016\u0000 \n ( ) / / _ _ \u00000\u00000\u00ff\u00fe\u00ff\u00fe\u000c\u0000\n" 292 33 regexp 293 C0 push_empty_string 294 24 02 00 call_method 2 297 C2 08 put_loc8 8: equation 299 62 08 00 get_loc_check 8: equation 302 42 5C 00 00 00 get_field2 split 307 04 F9 01 00 00 push_atom_value "=" 312 24 01 00 call_method 1 315 B4 push_0 0 316 47 get_array_el 317 C2 09 put_loc8 9: leftHandSide 319 62 08 00 get_loc_check 8: equation 322 42 5C 00 00 00 get_field2 split 327 04 F9 01 00 00 push_atom_value "=" 332 24 01 00 call_method 1 335 B5 push_1 1 336 47 get_array_el 337 C2 0A put_loc8 10: rightHandSide 339 38 3A 00 00 00 get_var eval 344 04 DD 01 00 00 push_atom_value "(" 349 42 5B 00 00 00 get_field2 concat 354 62 04 00 get_loc_check 4: unknownVariable 357 04 FA 01 00 00 push_atom_value ") => " 362 62 09 00 get_loc_check 9: leftHandSide 365 04 FB 01 00 00 push_atom_value " - (" 370 62 0A 00 get_loc_check 10: rightHandSide 373 04 DE 01 00 00 push_atom_value ")" 378 24 06 00 call_method 6 381 31 01 00 0F 00 eval 1,15 386 C2 0B put_loc8 11: equationFunction 388 C0 push_empty_string 389 C2 0C put_loc8 12: ans 391 06 undefined 392 C2 0D put_loc8 13: text 394 B5 push_1 1 395 C2 0E put_loc8 14: guess 397 61 0F 00 set_loc_uninitialized 15: i 400 B4 push_0 0 401 C2 0F put_loc8 15: i 403 62 0F 00 403: get_loc_check 15: i 406 62 06 00 get_loc_check 6: maxIterations 409 A4 lt 410 69 F8 00 00 00 if_false 659 415 61 12 00 set_loc_uninitialized 18: df 418 61 10 00 set_loc_uninitialized 16: f 421 62 0B 00 get_loc_check 11: equationFunction 424 62 0E 00 get_loc_check 14: guess 427 EE call1 1 428 C2 10 put_loc8 16: f 430 38 96 00 00 00 get_var Math 435 42 FC 01 00 00 get_field2 abs 440 62 10 00 get_loc_check 16: f 443 24 01 00 call_method 1 446 62 05 00 get_loc_check 5: tolerance 449 A4 lt 450 69 92 00 00 00 if_false 597 455 61 11 00 set_loc_uninitialized 17: parsedNumber 458 C5 get_loc1 1: parseNumber 459 62 0E 00 get_loc_check 14: guess 462 EE call1 1 463 C2 11 put_loc8 17: parsedNumber 465 38 A3 01 00 00 get_var console 470 42 A2 01 00 00 get_field2 log 475 04 FD 01 00 00 push_atom_value "\u00e6\u0095\u00b4\u00e6\u0095\u00b0\u00e9\u0083\u00a8\u00e5\u0088\u0086:" 480 62 11 00 get_loc_check 17: parsedNumber 483 41 FE 01 00 00 get_field integerPart 488 24 02 00 call_method 2 491 0E drop 492 38 A3 01 00 00 get_var console 497 42 A2 01 00 00 get_field2 log 502 04 FF 01 00 00 push_atom_value "\u00e5\u00b0\u008f\u00e6\u0095\u00b0\u00e9\u0083\u00a8\u00e5\u0088\u0086:" 507 62 11 00 get_loc_check 17: parsedNumber 510 41 00 02 00 00 get_field decimalPart 515 42 37 00 00 00 get_field2 toString 520 24 00 00 call_method 0 523 42 26 01 00 00 get_field2 substr 528 B4 push_0 0 529 BC 0A push_i8 10 531 24 02 00 call_method 2 534 24 02 00 call_method 2 537 0E drop 538 38 96 00 00 00 get_var Math 543 42 01 02 00 00 get_field2 round 548 62 0E 00 get_loc_check 14: guess 551 01 80 96 98 00 push_i32 10000000 556 9B mul 557 24 01 00 call_method 1 560 01 80 96 98 00 push_i32 10000000 565 9C div 566 11 dup 567 63 0D 00 put_loc_check 13: text 570 0E drop 571 04 02 02 00 00 push_atom_value "\u00e6\u0096\u00b9\u00e7\u00a8\u008b\u00e7\u009a\u0084\u00e8\u00a7\u00a3\u00e4\u00b8\u00ba\u00ef\u00bc\u009a\n" 576 62 04 00 get_loc_check 4: unknownVariable 579 9E add 580 04 03 02 00 00 push_atom_value " = " 585 9E add 586 62 0D 00 get_loc_check 13: text 589 9E add 590 11 dup 591 63 0C 00 put_loc_check 12: ans 594 0E drop 595 EB 3F goto8 659 597 62 0B 00 597: get_loc_check 11: equationFunction 600 62 0E 00 get_loc_check 14: guess 603 BE 19 push_const8 25: 1e-13 605 9E add 606 EE call1 1 607 62 10 00 get_loc_check 16: f 610 9F sub 611 BE 1A push_const8 26: 1e-13 613 9C div 614 C2 12 put_loc8 18: df 616 62 0E 00 get_loc_check 14: guess 619 62 10 00 get_loc_check 16: f 622 62 12 00 get_loc_check 18: df 625 9C div 626 9F sub 627 11 dup 628 63 0E 00 put_loc_check 14: guess 631 0E drop 632 38 A3 01 00 00 get_var console 637 42 A2 01 00 00 get_field2 log 642 62 0F 00 get_loc_check 15: i 645 92 post_inc 646 63 0F 00 put_loc_check 15: i 649 62 0E 00 get_loc_check 14: guess 652 24 02 00 call_method 2 655 0E drop 656 EC 02 FF goto16 403 659 38 A3 01 00 00 659: get_var console 664 42 A2 01 00 00 get_field2 log 669 62 0C 00 get_loc_check 12: ans 672 24 01 00 call_method 1 675 0E drop 676 62 0C 00 get_loc_check 12: ans 679 E9 05 if_false8 685 681 62 0C 00 get_loc_check 12: ans 684 28 return 685 04 04 02 00 00 685: push_atom_value "\u00e6\u009c\u00aa\u00e8\u0083\u00bd\u00e6\u0089\u00be\u00e5\u0088\u00b0\u00e6\u0096\u00b9\u00e7\u00a8\u008b\u00e7\u009a\u0084\u00e8\u00a7\u00a3" 690 28 return 691 C6 691: get_loc2 2: arr 692 E8 get_length 693 B4 push_0 0 694 AC strict_eq 695 E9 07 if_false8 703 697 04 05 02 00 00 push_atom_value "\u00e6\u00b2\u0092\u00e6\u009c\u0089\u00e6\u009c\u00aa\u00e7\u009f\u00a5\u00e6\u0095\u00b8" 702 28 return 703 04 06 02 00 00 703: push_atom_value "\u00e7\u009b\u00a1\u00e8\u00ab\u008b\u00e6\u009c\u009f\u00e5\u00be\u0085" 708 28 return */ } this.screen.setProperty(hmUI.prop.MORE, { text: solveEquation(this.screenData), }); Error = true; //this.screenData = "方程式的解为:"+ JSON.stringify(result) } catch (e) { this.screen.setProperty(hmUI.prop.MORE, { text: "請先檢査方程式", }); Error = true; } } else { for (let i = 0; i < brDiff; i++) this.screenData += ")"; } if (Error == false) this.updateScreen(); } _countIncl(str, chr) { let c = 0; for (let i in str) if (str[i] === chr) c++; return c; } switchSet() { const newId = (this.currentSetId + 1) % this.buttonSets.length; const newSet = this.buttonSets[newId]; for (let i = 0; i < newSet.length; i++) { this.buttons[i].setProperty(hmUI.prop.TEXT, newSet[i]); } this.currentSetId = newId; this.currentSet = newSet; } initButtonEvents(i) { return () => { if (i == 11) return this.switchSet(); let val = this.currentSet[i]; if (this.operations[val]) val = this.operations[val]; this.appendScreen(val); while (this.currentSetId != 0) this.switchSet(); }; } appendScreen(val) { this.screenData += val; this.updateScreen(); } updateScreen() { this.screen.setProperty(hmUI.prop.MORE, { text: this.screenData, }); } clear() { this.screenData = ""; this.updateScreen(); } backspace() { let delchar = 1 this.screenData = this.screenData.substring(0, this.screenData.length - delchar); this.updateScreen(); } } // source: /home/melianmiko/Projects/mb7_apps/calculator/entrypoint.js let __$$app$$__ = __$$hmAppManager$$__.currentApp; let __$$module$$__ = __$$app$$__.current; __$$module$$__.module = DeviceRuntimeCore.Page({ onInit() { hmUI.setLayerScrolling(false); new Calculator() .start(); }, }); })();
66如上
作者 @淘汰郎 https://www.bandbbs.cn/threads/9536/
•index.bin 大小縮小>90% (77 kb -> 7 kb)
•大幅減少APP對手環RAM的使用量
•使用更快更流暢
•UI優化
源代碼 (僅作部份開源,有興趣可以自己去原帖買,只需2023 coins 哦 🙂 ):
JavaScript:/** * Build with ZMake tool */ // Build at 2022-08-08 16:53:06.368238 (() => { // source: /home/melianmiko/Projects/mb7_apps/calculator/src/Calculator.js class Calculator { buttons = []; screen = null; screenData = ""; currentSet = []; currentSetId = -1; buttonSets = [ ["7", "8", "9", "4", "5", "6", "1", "2", "3", "0", "."], ["+", "-", "×", "÷", "^", "√", "|", "=", "π", "(", ")"], ["x", "y", "z", "分數", "又", "分之", "", "", "", "", ""],]; operations = { "+": "+", "-": "-", "×": "×", "÷": "÷", "^": "^", "√": "√(", "∛": "∛(", "π": "π", "分數": "分數(", }; start() { // Init screen hmUI.createWidget(5, { x: 5, y: 80, w: 183, h: 76, radius: 8, line_width: 2, color: 0x222222 }); this.screen = hmUI.createWidget(2, { x: 11, y: 80, w: 172, h: 80, color: 0xc5c5c5, text_size: 24, text_style: 1, align_v: 16, }); this.screen.addEventListener(3, () => { this.backspace(); }); // Init buttons for (let i = 0; i < 12; i++) { this.buttons[i] = hmUI.createWidget(23, { x: (i % 3) * 64 + 2, y: Math.floor(i / 3) * 64 + 168, w: 60, h: 60, radius: 8, text_size: 28, normal_color: 0x222222, press_color: 0x333333, click_func: this.initButtonEvents(i), }); } this.buttons[11].setProperty(0, { x: 130, y: 360, w: 60, h: 60, text: "...", normal_color: 0x444444, press_color: 0x666666, }); this.switchSet(); hmUI.createWidget(5, { x: 5, y: 80, w: 183, h: 76, radius: 8, line_width: 2, color: 0x222222 }); this.screen = hmUI.createWidget(2, { x: 11, y: 80, w: 172, h: 80, color: 0xc5c5c5, text_size: 24, text_style: 1, align_v: 16, }); this.screen.addEventListener(3, () => { this.backspace(); }); // Init buttons for (let i = 0; i < 12; i++) { this.buttons[i] = hmUI.createWidget(23, { x: (i % 3) * 64 + 2, y: Math.floor(i / 3) * 64 + 168, w: 60, h: 60, radius: 8, text_size: 28, normal_color: 0x222222, press_color: 0x333333, click_func: this.initButtonEvents(i), }); } this.buttons[11].setProperty(0, { x: 130, y: 360, w: 60, h: 60, text: "...", normal_color: 0x444444, press_color: 0x666666, }); this.switchSet(); // Init remove and process buttons hmUI.createWidget(23, { x: 0, y: 426, w: 192, h: 65, text: "解方程式", normal_color: 0x222222, press_color: 0x444444, text_size: 28, click_func: () => { this.process(); } }); hmUI.createWidget(23, { x: 0, y: 0, w: 192, h: 70, text: "拉進垃圾車", text_size: 20, color: 0x999999, click_func: () => { this.clear(); } }); } calcFactorial(num) { if (num % 1 != 0 || num < 0) { num++; return Math.sqrt(2 * Math.PI / num) * Math.pow((1 / Math.E) * (num + 1 / (12 * num - 1 / (10 * num))), num); } else { return (num == 0) ? 1 : num * this.calcFactorial(num - 1); } } process() { let Error = false; const brDiff = this._countIncl(this.screenData, "(") - this._countIncl(this.screenData, ")"); if (brDiff === 0) { try { function solveEquation(equationString) { /* function not open source bytecode: /sdcard/index.js:181: function: solveEquation mode: strict args: equationString locals: 0: var Fraction 1: var parseNumber 2: var arr 3: catch error [level:3 next:4] 4: let unknownVariable [level:1 next:-1] 5: let tolerance [level:6 next:4] 6: let maxIterations [level:6 next:5] 7: let replacedEquationString [level:6 next:6] 8: let equation [level:6 next:7] 9: let leftHandSide [level:6 next:8] 10: let rightHandSide [level:6 next:9] 11: let equationFunction [level:6 next:10] 12: let ans [level:6 next:11] 13: let text [level:6 next:12] 14: let guess [level:6 next:13] 15: let i [level:7 next:14] 16: let f [level:8 next:15] 17: const parsedNumber [level:10 next:18] 18: let df [level:8 next:16] 19: var this 20: var new.target 21: var arguments closure vars: 0: solveEquation local:loc2 let 1: brDiff local:loc1 const 2: Error local:loc0 let 3: <class_fields_init> parent:loc0 const 4: Calculator parent:loc1 const 5: __$$module$$__ parent:loc2 let 6: __$$app$$__ parent:loc3 let 7: Calculator parent:loc4 let stack_size: 9 opcodes: 0 0C 03 special_object 3 2 C2 14 put_loc8 20: "new.target" 4 08 push_this 5 C2 13 put_loc8 19: this 7 0C 00 special_object 0 9 C2 15 put_loc8 21: arguments 11 BF 00 fclosure8 0: [bytecode Fraction] 13 C8 put_loc0 0: Fraction [definition of function Fraction(str)] */ function Fraction(str) { /* function not open source bytecode: /sdcard/index.js:182: function: Fraction mode: strict args: str locals: 0: let arr [level:7 next:-1] 1: let arr [level:11 next:-1] stack_size: 5 opcodes: 0 D0 get_arg0 0: str 1 98 typeof 2 04 48 00 00 00 push_atom_value string 7 AD strict_neq 8 E9 0B if_false8 20 10 D0 get_arg0 0: str 11 42 37 00 00 00 get_field2 toString 16 24 00 00 call_method 0 19 D4 put_arg0 0: str 20 BE 00 20: push_const8 0: 1"\u5206\u6570\\([^)]+\\)" 22 BE 01 push_const8 1: 1"\u0000\u0001\u00009\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u0006R\u0001pe\u0001(\u0000\u001c\u000c\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0002\u0000\u0000\u0000(\u0000*\u0000\u00ff\u00ff\n\u0001)\u0000\u000c\u0000\n" 24 33 regexp 25 42 82 01 00 00 get_field2 test 30 D0 get_arg0 0: str 31 24 01 00 call_method 1 34 E9 1C if_false8 63 36 38 BC 01 00 00 get_var hmUI 41 42 08 02 00 00 get_field2 showToast 46 0B object 47 04 09 02 00 00 push_atom_value "\u00e6\u00a0\u00bc\u00e5\u00bc\u008f\u00e4\u00b8\u008d\u00e7\u00ac\u00a6\u00e5\u0090\u0088\n\u00e5\u00b7\u00b2\u00e6\u0094\u00b9\u00e6\u0088\u00900" 52 4C D1 01 00 00 define_field text 57 24 01 00 call_method 1 60 0E drop 61 B4 push_0 0 62 28 return 63 BE 02 63: push_const8 2: 1"(^[\\s\\S]*)\u53c8([\\s\\S]*)\u5206\u4e4b([\\s\\S]*)" 65 BE 03 push_const8 3: 1"\u0000\u0004\u0000q\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u000b\u0001\u0005\u001c\u0008\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u0000\u0000\u0000\u00ff\u00ff\n\u000c\u0001\u0001\u00c8S\u000b\u0002\u001c\u0008\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u0000\u0000\u0000\u00ff\u00ff\n\u000c\u0002\u0001\u0006R\u0001KN\u000b\u0003\u001c\u0008\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u0000\u0000\u0000\u00ff\u00ff\n\u000c\u0003\u000c\u0000\n" 67 33 regexp 68 42 82 01 00 00 get_field2 test 73 D0 get_arg0 0: str 74 24 01 00 call_method 1 77 69 C2 00 00 00 if_false 272 82 61 00 00 set_loc_uninitialized 0: arr 85 D0 get_arg0 0: str 86 42 5C 00 00 00 get_field2 split 91 BE 04 push_const8 4: 1"\u53c8|\u5206\u4e4b" 93 BE 05 push_const8 5: 1"\u0000\u0001\u0000#\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0009\u0008\u0000\u0000\u0000\u0001\u00c8S\u0007\u0006\u0000\u0000\u0000\u0001\u0006R\u0001KN\u000c\u0000\n" 95 33 regexp 96 24 01 00 call_method 1 99 C8 put_loc0 0: arr 100 62 00 00 get_loc_check 0: arr 103 E8 get_length 104 B7 push_3 3 105 AD strict_neq 106 11 dup 107 EA 26 if_true8 146 109 0E drop 110 BE 06 push_const8 6: 1"\u53c8" 112 BE 07 push_const8 7: 1"\u0000\u0001\u0000\u0013\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u00c8S\u000c\u0000\n" 114 33 regexp 115 42 82 01 00 00 get_field2 test 120 D0 get_arg0 0: str 121 24 01 00 call_method 1 124 0A push_true 125 AD strict_neq 126 11 dup 127 EA 12 if_true8 146 129 0E drop 130 BE 08 push_const8 8: 1"\u5206\u4e4b" 132 BE 09 push_const8 9: 1"\u0000\u0001\u0000\u0016\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u0006R\u0001KN\u000c\u0000\n" 134 33 regexp 135 42 82 01 00 00 get_field2 test 140 D0 get_arg0 0: str 141 24 01 00 call_method 1 144 0A push_true 145 AD strict_neq 146 E9 1C 146: if_false8 175 148 38 BC 01 00 00 get_var hmUI 153 42 08 02 00 00 get_field2 showToast 158 0B object 159 04 09 02 00 00 push_atom_value "\u00e6\u00a0\u00bc\u00e5\u00bc\u008f\u00e4\u00b8\u008d\u00e7\u00ac\u00a6\u00e5\u0090\u0088\n\u00e5\u00b7\u00b2\u00e6\u0094\u00b9\u00e6\u0088\u00900" 164 4C D1 01 00 00 define_field text 169 24 01 00 call_method 1 172 0E drop 173 B4 push_0 0 174 28 return 175 38 A3 01 00 00 175: get_var console 180 42 A2 01 00 00 get_field2 log 185 04 DD 01 00 00 push_atom_value "(" 190 62 00 00 get_loc_check 0: arr 193 B4 push_0 0 194 47 get_array_el 195 9E add 196 04 0A 02 00 00 push_atom_value " + " 201 9E add 202 62 00 00 get_loc_check 0: arr 205 B6 push_2 2 206 47 get_array_el 207 9E add 208 04 0B 02 00 00 push_atom_value " / " 213 9E add 214 62 00 00 get_loc_check 0: arr 217 B5 push_1 1 218 47 get_array_el 219 9E add 220 04 DE 01 00 00 push_atom_value ")" 225 9E add 226 24 01 00 call_method 1 229 0E drop 230 04 DD 01 00 00 push_atom_value "(" 235 62 00 00 get_loc_check 0: arr 238 B4 push_0 0 239 47 get_array_el 240 9E add 241 04 0A 02 00 00 push_atom_value " + " 246 9E add 247 62 00 00 get_loc_check 0: arr 250 B6 push_2 2 251 47 get_array_el 252 04 0B 02 00 00 push_atom_value " / " 257 9E add 258 62 00 00 get_loc_check 0: arr 261 B5 push_1 1 262 47 get_array_el 263 9E add 264 9E add 265 04 DE 01 00 00 push_atom_value ")" 270 9E add 271 28 return 272 BE 0A 272: push_const8 10: 1"(^[\\s\\S]*)\u5206\u4e4b([\\s\\S]*)" 274 BE 0B push_const8 11: 1"\u0000\u0003\u0000Q\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u000b\u0001\u0005\u001c\u0008\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u0000\u0000\u0000\u00ff\u00ff\n\u000c\u0001\u0001\u0006R\u0001KN\u000b\u0002\u001c\u0008\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u0000\u0000\u0000\u00ff\u00ff\n\u000c\u0002\u000c\u0000\n" 276 33 regexp 277 42 82 01 00 00 get_field2 test 282 D0 get_arg0 0: str 283 24 01 00 call_method 1 286 69 96 00 00 00 if_false 437 291 61 01 00 set_loc_uninitialized 1: arr 294 D0 get_arg0 0: str 295 42 5C 00 00 00 get_field2 split 300 BE 0C push_const8 12: 1"\u5206\u4e4b" 302 BE 0D push_const8 13: 1"\u0000\u0001\u0000\u0016\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u0006R\u0001KN\u000c\u0000\n" 304 33 regexp 305 24 01 00 call_method 1 308 C9 put_loc1 1: arr 309 62 01 00 get_loc_check 1: arr 312 E8 get_length 313 B6 push_2 2 314 AD strict_neq 315 11 dup 316 EA 12 if_true8 335 318 0E drop 319 BE 0E push_const8 14: 1"\u5206\u4e4b" 321 BE 0F push_const8 15: 1"\u0000\u0001\u0000\u0016\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u0006R\u0001KN\u000c\u0000\n" 323 33 regexp 324 42 82 01 00 00 get_field2 test 329 D0 get_arg0 0: str 330 24 01 00 call_method 1 333 0A push_true 334 AD strict_neq 335 E9 1C 335: if_false8 364 337 38 BC 01 00 00 get_var hmUI 342 42 08 02 00 00 get_field2 showToast 347 0B object 348 04 09 02 00 00 push_atom_value "\u00e6\u00a0\u00bc\u00e5\u00bc\u008f\u00e4\u00b8\u008d\u00e7\u00ac\u00a6\u00e5\u0090\u0088\n\u00e5\u00b7\u00b2\u00e6\u0094\u00b9\u00e6\u0088\u00900" 353 4C D1 01 00 00 define_field text 358 24 01 00 call_method 1 361 0E drop 362 B4 push_0 0 363 28 return 364 38 A3 01 00 00 364: get_var console 369 42 A2 01 00 00 get_field2 log 374 04 DD 01 00 00 push_atom_value "(" 379 62 01 00 get_loc_check 1: arr 382 B5 push_1 1 383 47 get_array_el 384 9E add 385 04 0B 02 00 00 push_atom_value " / " 390 9E add 391 62 01 00 get_loc_check 1: arr 394 B4 push_0 0 395 47 get_array_el 396 9E add 397 04 DE 01 00 00 push_atom_value ")" 402 9E add 403 24 01 00 call_method 1 406 0E drop 407 04 DD 01 00 00 push_atom_value "(" 412 62 01 00 get_loc_check 1: arr 415 B5 push_1 1 416 47 get_array_el 417 9E add 418 04 0B 02 00 00 push_atom_value " / " 423 9E add 424 62 01 00 get_loc_check 1: arr 427 B4 push_0 0 428 47 get_array_el 429 9E add 430 04 DE 01 00 00 push_atom_value ")" 435 9E add 436 28 return 437 38 BC 01 00 00 437: get_var hmUI 442 42 08 02 00 00 get_field2 showToast 447 0B object 448 04 09 02 00 00 push_atom_value "\u00e6\u00a0\u00bc\u00e5\u00bc\u008f\u00e4\u00b8\u008d\u00e7\u00ac\u00a6\u00e5\u0090\u0088\n\u00e5\u00b7\u00b2\u00e6\u0094\u00b9\u00e6\u0088\u00900" 453 4C D1 01 00 00 define_field text 458 24 01 00 call_method 1 461 0E drop 462 B4 push_0 0 463 28 return */ } /* bytecode: 14 BF 01 fclosure8 1: [bytecode parseNumber] 16 C9 put_loc1 1: parseNumber [definition of function parseNumber(str)] */ function parseNumber(str) { /* function not open source bytecode: /sdcard/index.js:211: function: parseNumber mode: strict args: str locals: 0: const regex [level:1 next:-1] 1: const matches [level:1 next:0] 2: let integerPart [level:5 next:1] 3: let decimalPart [level:5 next:2] stack_size: 4 opcodes: 0 61 01 00 set_loc_uninitialized 1: matches 3 61 00 00 set_loc_uninitialized 0: regex 6 D0 get_arg0 0: str 7 98 typeof 8 04 46 00 00 00 push_atom_value number 13 AC strict_eq 14 E9 0B if_false8 26 16 D0 get_arg0 0: str 17 42 37 00 00 00 get_field2 toString 22 24 00 00 call_method 0 25 D4 put_arg0 0: str 26 BE 00 26: push_const8 0: 1"^(-?\\d+)(\\.\\d+)?$" 28 BE 01 push_const8 1: 1"\u0000\u0003\u0000l\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0005\u000b\u0001\u001c\u0004\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u0001-\u0000\n\u001c\u0008\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u00000\u00009\u0000\n\u000c\u0001\u000d\u0002\u0002\u0009 \u0000\u0000\u0000\u000b\u0002\u0001.\u0000\u001c\u0008\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u00000\u00009\u0000\n\u000c\u0002\u0006\u000c\u0000\n" 30 33 regexp 31 C8 put_loc0 0: regex 32 D0 get_arg0 0: str 33 42 22 01 00 00 get_field2 match 38 62 00 00 get_loc_check 0: regex 41 24 01 00 call_method 1 44 C9 put_loc1 1: matches 45 62 01 00 get_loc_check 1: matches 48 E9 60 if_false8 145 50 61 03 00 set_loc_uninitialized 3: decimalPart 53 61 02 00 set_loc_uninitialized 2: integerPart 56 62 01 00 get_loc_check 1: matches 59 B5 push_1 1 60 47 get_array_el 61 CA put_loc2 2: integerPart 62 62 01 00 get_loc_check 1: matches 65 B6 push_2 2 66 47 get_array_el 67 CB put_loc3 3: decimalPart 68 62 03 00 get_loc_check 3: decimalPart 71 E9 1D if_false8 101 73 62 03 00 get_loc_check 3: decimalPart 76 42 28 01 00 00 get_field2 replace 81 BE 02 push_const8 2: 1"^\\." 83 BE 03 push_const8 3: 1"\u0000\u0001\u0000\u0014\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0005\u0001.\u0000\u000c\u0000\n" 85 33 regexp 86 04 0E 02 00 00 push_atom_value "0." 91 24 02 00 call_method 2 94 11 dup 95 63 03 00 put_loc_check 3: decimalPart 98 0E drop 99 EB 0B goto8 111 101 04 0F 02 00 00 101: push_atom_value "0.0" 106 11 dup 107 63 03 00 put_loc_check 3: decimalPart 110 0E drop 111 0B 111: object 112 62 02 00 get_loc_check 2: integerPart 115 42 37 00 00 00 get_field2 toString 120 24 00 00 call_method 0 123 4C FE 01 00 00 define_field integerPart 128 62 03 00 get_loc_check 3: decimalPart 131 42 37 00 00 00 get_field2 toString 136 24 00 00 call_method 0 139 4C 00 02 00 00 define_field decimalPart 144 28 return 145 D0 145: get_arg0 0: str 146 28 return */ } /* 17 61 04 00 set_loc_uninitialized 4: unknownVariable 20 6C 23 00 00 00 catch 56 25 D0 get_arg0 0: equationString 26 42 22 01 00 00 get_field2 match 31 BE 02 push_const8 2: 1"[a-zA-Z]+" 33 BE 03 push_const8 3: 1"\u0001\u0001\u0000-\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u001c\u000c\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0002\u0000A\u0000Z\u0000a\u0000z\u0000\n\u000c\u0000\n" 35 33 regexp 36 24 01 00 call_method 1 39 42 EE 00 00 00 get_field2 reduce 44 BF 04 fclosure8 4: [bytecode <null>] 46 26 00 00 array_from 0 49 24 02 00 call_method 2 52 CA put_loc2 2: arr 53 0E drop 54 EB 0B goto8 66 56 CB 56: put_loc3 3: error 57 6C 07 00 00 00 catch 65 62 0E drop 63 EB 02 goto8 66 65 2F 65: throw 66 C6 66: get_loc2 2: arr 67 B4 push_0 0 68 47 get_array_el 69 C2 04 put_loc8 4: unknownVariable 71 C6 get_loc2 2: arr 72 E8 get_length 73 B5 push_1 1 74 AC strict_eq 75 69 67 02 00 00 if_false 691 80 61 0E 00 set_loc_uninitialized 14: guess 83 61 0D 00 set_loc_uninitialized 13: text 86 61 0C 00 set_loc_uninitialized 12: ans 89 61 0B 00 set_loc_uninitialized 11: equationFunction 92 61 0A 00 set_loc_uninitialized 10: rightHandSide 95 61 09 00 set_loc_uninitialized 9: leftHandSide 98 61 08 00 set_loc_uninitialized 8: equation 101 61 07 00 set_loc_uninitialized 7: replacedEquationString 104 61 06 00 set_loc_uninitialized 6: maxIterations 107 61 05 00 set_loc_uninitialized 5: tolerance 110 BE 05 push_const8 5: 1e-08 112 C2 05 put_loc8 5: tolerance 114 BD 10 27 push_i16 10000 117 C2 06 put_loc8 6: maxIterations 119 D0 get_arg0 0: equationString 120 42 28 01 00 00 get_field2 replace 125 BE 06 push_const8 6: 1"(\\d|\\))(\\(|[a-z]|\u03c0|\u5206\u6578)" 127 BE 07 push_const8 7: 1"\u0001\u0003\u0000]\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u000b\u0001\u0009\u000c\u0000\u0000\u0000\u0015\u0001\u00000\u00009\u0000\u0007\u0003\u0000\u0000\u0000\u0001)\u0000\u000c\u0001\u000b\u0002\u0009&\u0000\u0000\u0000\u0009\u0019\u0000\u0000\u0000\u0009\u0008\u0000\u0000\u0000\u0001(\u0000\u0007\u0007\u0000\u0000\u0000\u0015\u0001\u0000a\u0000z\u0000\u0007\u0003\u0000\u0000\u0000\u0001\u00c0\u0003\u0007\u0006\u0000\u0000\u0000\u0001\u0006R\u0001xe\u000c\u0002\u000c\u0000\n" 129 33 regexp 130 04 F3 01 00 00 push_atom_value "$1*$2" 135 24 02 00 call_method 2 138 42 28 01 00 00 get_field2 replace 143 BE 08 push_const8 8: 1"\\^" 145 BE 09 push_const8 9: 1"\u0001\u0001\u0000\u0013\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001^\u0000\u000c\u0000\n" 147 33 regexp 148 04 F4 01 00 00 push_atom_value "**" 153 24 02 00 call_method 2 156 42 28 01 00 00 get_field2 replace 161 BE 0A push_const8 10: 1"\u00d7" 163 BE 0B push_const8 11: 1"\u0001\u0001\u0000\u0013\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u00d7\u0000\u000c\u0000\n" 165 33 regexp 166 04 7C 00 00 00 push_atom_value "*" 171 24 02 00 call_method 2 174 42 28 01 00 00 get_field2 replace 179 BE 0C push_const8 12: 1"\u00f7" 181 BE 0D push_const8 13: 1"\u0001\u0001\u0000\u0013\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u00f7\u0000\u000c\u0000\n" 183 33 regexp 184 04 F5 01 00 00 push_atom_value "/" 189 24 02 00 call_method 2 192 42 28 01 00 00 get_field2 replace 197 BE 0E push_const8 14: 1"\u03c0" 199 BE 0F push_const8 15: 1"\u0001\u0001\u0000\u0013\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u00c0\u0003\u000c\u0000\n" 201 33 regexp 202 04 F6 01 00 00 push_atom_value "3.14" 207 24 02 00 call_method 2 210 42 28 01 00 00 get_field2 replace 215 BE 10 push_const8 16: 1"\\|([^|]+)\\|" 217 BE 11 push_const8 17: 1"\u0001\u0002\u00007\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001|\u0000\u000b\u0001\u001c\u000c\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0002\u0000\u0000\u0000{\u0000}\u0000\u00ff\u00ff\n\u000c\u0001\u0001|\u0000\u000c\u0000\n" 219 33 regexp 220 04 F7 01 00 00 push_atom_value "(Math.abs($1))" 225 24 02 00 call_method 2 228 42 28 01 00 00 get_field2 replace 233 BE 12 push_const8 18: 1"\u221a\\(([^)]+)\\)" 235 BE 13 push_const8 19: 1"\u0001\u0002\u0000:\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u001a\"\u0001(\u0000\u000b\u0001\u001c\u000c\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0002\u0000\u0000\u0000(\u0000*\u0000\u00ff\u00ff\n\u000c\u0001\u0001)\u0000\u000c\u0000\n" 237 33 regexp 238 04 F8 01 00 00 push_atom_value "(Math.sqrt($1))" 243 24 02 00 call_method 2 246 42 28 01 00 00 get_field2 replace 251 BE 14 push_const8 20: 1"\u5206\u6578\\(([^)]+)\\)" 253 BE 15 push_const8 21: 1"\u0001\u0002\u0000=\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u0006R\u0001xe\u0001(\u0000\u000b\u0001\u001c\u000c\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0002\u0000\u0000\u0000(\u0000*\u0000\u00ff\u00ff\n\u000c\u0001\u0001)\u0000\u000c\u0000\n" 255 33 regexp 256 BF 16 fclosure8 22: [bytecode <null>] 258 24 02 00 call_method 2 261 C2 07 put_loc8 7: replacedEquationString 263 38 A3 01 00 00 get_var console 268 42 A2 01 00 00 get_field2 log 273 62 07 00 get_loc_check 7: replacedEquationString 276 24 01 00 call_method 1 279 0E drop 280 62 07 00 get_loc_check 7: replacedEquationString 283 42 28 01 00 00 get_field2 replace 288 BE 17 push_const8 23: 1"\\s" 290 BE 18 push_const8 24: 1"\u0001\u0001\u0000;\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0015\n\u0000\u0009\u0000\u000d\u0000 \u0000 \u0000\u00a0\u0000\u00a0\u0000\u0080\u0016\u0080\u0016\u0000 \n ( ) / / _ _ \u00000\u00000\u00ff\u00fe\u00ff\u00fe\u000c\u0000\n" 292 33 regexp 293 C0 push_empty_string 294 24 02 00 call_method 2 297 C2 08 put_loc8 8: equation 299 62 08 00 get_loc_check 8: equation 302 42 5C 00 00 00 get_field2 split 307 04 F9 01 00 00 push_atom_value "=" 312 24 01 00 call_method 1 315 B4 push_0 0 316 47 get_array_el 317 C2 09 put_loc8 9: leftHandSide 319 62 08 00 get_loc_check 8: equation 322 42 5C 00 00 00 get_field2 split 327 04 F9 01 00 00 push_atom_value "=" 332 24 01 00 call_method 1 335 B5 push_1 1 336 47 get_array_el 337 C2 0A put_loc8 10: rightHandSide 339 38 3A 00 00 00 get_var eval 344 04 DD 01 00 00 push_atom_value "(" 349 42 5B 00 00 00 get_field2 concat 354 62 04 00 get_loc_check 4: unknownVariable 357 04 FA 01 00 00 push_atom_value ") => " 362 62 09 00 get_loc_check 9: leftHandSide 365 04 FB 01 00 00 push_atom_value " - (" 370 62 0A 00 get_loc_check 10: rightHandSide 373 04 DE 01 00 00 push_atom_value ")" 378 24 06 00 call_method 6 381 31 01 00 0F 00 eval 1,15 386 C2 0B put_loc8 11: equationFunction 388 C0 push_empty_string 389 C2 0C put_loc8 12: ans 391 06 undefined 392 C2 0D put_loc8 13: text 394 B5 push_1 1 395 C2 0E put_loc8 14: guess 397 61 0F 00 set_loc_uninitialized 15: i 400 B4 push_0 0 401 C2 0F put_loc8 15: i 403 62 0F 00 403: get_loc_check 15: i 406 62 06 00 get_loc_check 6: maxIterations 409 A4 lt 410 69 F8 00 00 00 if_false 659 415 61 12 00 set_loc_uninitialized 18: df 418 61 10 00 set_loc_uninitialized 16: f 421 62 0B 00 get_loc_check 11: equationFunction 424 62 0E 00 get_loc_check 14: guess 427 EE call1 1 428 C2 10 put_loc8 16: f 430 38 96 00 00 00 get_var Math 435 42 FC 01 00 00 get_field2 abs 440 62 10 00 get_loc_check 16: f 443 24 01 00 call_method 1 446 62 05 00 get_loc_check 5: tolerance 449 A4 lt 450 69 92 00 00 00 if_false 597 455 61 11 00 set_loc_uninitialized 17: parsedNumber 458 C5 get_loc1 1: parseNumber 459 62 0E 00 get_loc_check 14: guess 462 EE call1 1 463 C2 11 put_loc8 17: parsedNumber 465 38 A3 01 00 00 get_var console 470 42 A2 01 00 00 get_field2 log 475 04 FD 01 00 00 push_atom_value "\u00e6\u0095\u00b4\u00e6\u0095\u00b0\u00e9\u0083\u00a8\u00e5\u0088\u0086:" 480 62 11 00 get_loc_check 17: parsedNumber 483 41 FE 01 00 00 get_field integerPart 488 24 02 00 call_method 2 491 0E drop 492 38 A3 01 00 00 get_var console 497 42 A2 01 00 00 get_field2 log 502 04 FF 01 00 00 push_atom_value "\u00e5\u00b0\u008f\u00e6\u0095\u00b0\u00e9\u0083\u00a8\u00e5\u0088\u0086:" 507 62 11 00 get_loc_check 17: parsedNumber 510 41 00 02 00 00 get_field decimalPart 515 42 37 00 00 00 get_field2 toString 520 24 00 00 call_method 0 523 42 26 01 00 00 get_field2 substr 528 B4 push_0 0 529 BC 0A push_i8 10 531 24 02 00 call_method 2 534 24 02 00 call_method 2 537 0E drop 538 38 96 00 00 00 get_var Math 543 42 01 02 00 00 get_field2 round 548 62 0E 00 get_loc_check 14: guess 551 01 80 96 98 00 push_i32 10000000 556 9B mul 557 24 01 00 call_method 1 560 01 80 96 98 00 push_i32 10000000 565 9C div 566 11 dup 567 63 0D 00 put_loc_check 13: text 570 0E drop 571 04 02 02 00 00 push_atom_value "\u00e6\u0096\u00b9\u00e7\u00a8\u008b\u00e7\u009a\u0084\u00e8\u00a7\u00a3\u00e4\u00b8\u00ba\u00ef\u00bc\u009a\n" 576 62 04 00 get_loc_check 4: unknownVariable 579 9E add 580 04 03 02 00 00 push_atom_value " = " 585 9E add 586 62 0D 00 get_loc_check 13: text 589 9E add 590 11 dup 591 63 0C 00 put_loc_check 12: ans 594 0E drop 595 EB 3F goto8 659 597 62 0B 00 597: get_loc_check 11: equationFunction 600 62 0E 00 get_loc_check 14: guess 603 BE 19 push_const8 25: 1e-13 605 9E add 606 EE call1 1 607 62 10 00 get_loc_check 16: f 610 9F sub 611 BE 1A push_const8 26: 1e-13 613 9C div 614 C2 12 put_loc8 18: df 616 62 0E 00 get_loc_check 14: guess 619 62 10 00 get_loc_check 16: f 622 62 12 00 get_loc_check 18: df 625 9C div 626 9F sub 627 11 dup 628 63 0E 00 put_loc_check 14: guess 631 0E drop 632 38 A3 01 00 00 get_var console 637 42 A2 01 00 00 get_field2 log 642 62 0F 00 get_loc_check 15: i 645 92 post_inc 646 63 0F 00 put_loc_check 15: i 649 62 0E 00 get_loc_check 14: guess 652 24 02 00 call_method 2 655 0E drop 656 EC 02 FF goto16 403 659 38 A3 01 00 00 659: get_var console 664 42 A2 01 00 00 get_field2 log 669 62 0C 00 get_loc_check 12: ans 672 24 01 00 call_method 1 675 0E drop 676 62 0C 00 get_loc_check 12: ans 679 E9 05 if_false8 685 681 62 0C 00 get_loc_check 12: ans 684 28 return 685 04 04 02 00 00 685: push_atom_value "\u00e6\u009c\u00aa\u00e8\u0083\u00bd\u00e6\u0089\u00be\u00e5\u0088\u00b0\u00e6\u0096\u00b9\u00e7\u00a8\u008b\u00e7\u009a\u0084\u00e8\u00a7\u00a3" 690 28 return 691 C6 691: get_loc2 2: arr 692 E8 get_length 693 B4 push_0 0 694 AC strict_eq 695 E9 07 if_false8 703 697 04 05 02 00 00 push_atom_value "\u00e6\u00b2\u0092\u00e6\u009c\u0089\u00e6\u009c\u00aa\u00e7\u009f\u00a5\u00e6\u0095\u00b8" 702 28 return 703 04 06 02 00 00 703: push_atom_value "\u00e7\u009b\u00a1\u00e8\u00ab\u008b\u00e6\u009c\u009f\u00e5\u00be\u0085" 708 28 return */ } this.screen.setProperty(hmUI.prop.MORE, { text: solveEquation(this.screenData), }); Error = true; //this.screenData = "方程式的解为:"+ JSON.stringify(result) } catch (e) { this.screen.setProperty(hmUI.prop.MORE, { text: "請先檢査方程式", }); Error = true; } } else { for (let i = 0; i < brDiff; i++) this.screenData += ")"; } if (Error == false) this.updateScreen(); } _countIncl(str, chr) { let c = 0; for (let i in str) if (str[i] === chr) c++; return c; } switchSet() { const newId = (this.currentSetId + 1) % this.buttonSets.length; const newSet = this.buttonSets[newId]; for (let i = 0; i < newSet.length; i++) { this.buttons[i].setProperty(hmUI.prop.TEXT, newSet[i]); } this.currentSetId = newId; this.currentSet = newSet; } initButtonEvents(i) { return () => { if (i == 11) return this.switchSet(); let val = this.currentSet[i]; if (this.operations[val]) val = this.operations[val]; this.appendScreen(val); while (this.currentSetId != 0) this.switchSet(); }; } appendScreen(val) { this.screenData += val; this.updateScreen(); } updateScreen() { this.screen.setProperty(hmUI.prop.MORE, { text: this.screenData, }); } clear() { this.screenData = ""; this.updateScreen(); } backspace() { let delchar = 1 this.screenData = this.screenData.substring(0, this.screenData.length - delchar); this.updateScreen(); } } // source: /home/melianmiko/Projects/mb7_apps/calculator/entrypoint.js let __$$app$$__ = __$$hmAppManager$$__.currentApp; let __$$module$$__ = __$$app$$__.current; __$$module$$__.module = DeviceRuntimeCore.Page({ onInit() { hmUI.setLayerScrolling(false); new Calculator() .start(); }, }); })();
6如上
作者 @淘汰郎 https://www.bandbbs.cn/threads/9536/
•index.bin 大小縮小>90% (77 kb -> 7 kb)
•大幅減少APP對手環RAM的使用量
•使用更快更流暢
•UI優化
源代碼 (僅作部份開源,有興趣可以自己去原帖買,只需2023 coins 哦 🙂 ):
JavaScript:/** * Build with ZMake tool */ // Build at 2022-08-08 16:53:06.368238 (() => { // source: /home/melianmiko/Projects/mb7_apps/calculator/src/Calculator.js class Calculator { buttons = []; screen = null; screenData = ""; currentSet = []; currentSetId = -1; buttonSets = [ ["7", "8", "9", "4", "5", "6", "1", "2", "3", "0", "."], ["+", "-", "×", "÷", "^", "√", "|", "=", "π", "(", ")"], ["x", "y", "z", "分數", "又", "分之", "", "", "", "", ""],]; operations = { "+": "+", "-": "-", "×": "×", "÷": "÷", "^": "^", "√": "√(", "∛": "∛(", "π": "π", "分數": "分數(", }; start() { // Init screen hmUI.createWidget(5, { x: 5, y: 80, w: 183, h: 76, radius: 8, line_width: 2, color: 0x222222 }); this.screen = hmUI.createWidget(2, { x: 11, y: 80, w: 172, h: 80, color: 0xc5c5c5, text_size: 24, text_style: 1, align_v: 16, }); this.screen.addEventListener(3, () => { this.backspace(); }); // Init buttons for (let i = 0; i < 12; i++) { this.buttons[i] = hmUI.createWidget(23, { x: (i % 3) * 64 + 2, y: Math.floor(i / 3) * 64 + 168, w: 60, h: 60, radius: 8, text_size: 28, normal_color: 0x222222, press_color: 0x333333, click_func: this.initButtonEvents(i), }); } this.buttons[11].setProperty(0, { x: 130, y: 360, w: 60, h: 60, text: "...", normal_color: 0x444444, press_color: 0x666666, }); this.switchSet(); hmUI.createWidget(5, { x: 5, y: 80, w: 183, h: 76, radius: 8, line_width: 2, color: 0x222222 }); this.screen = hmUI.createWidget(2, { x: 11, y: 80, w: 172, h: 80, color: 0xc5c5c5, text_size: 24, text_style: 1, align_v: 16, }); this.screen.addEventListener(3, () => { this.backspace(); }); // Init buttons for (let i = 0; i < 12; i++) { this.buttons[i] = hmUI.createWidget(23, { x: (i % 3) * 64 + 2, y: Math.floor(i / 3) * 64 + 168, w: 60, h: 60, radius: 8, text_size: 28, normal_color: 0x222222, press_color: 0x333333, click_func: this.initButtonEvents(i), }); } this.buttons[11].setProperty(0, { x: 130, y: 360, w: 60, h: 60, text: "...", normal_color: 0x444444, press_color: 0x666666, }); this.switchSet(); // Init remove and process buttons hmUI.createWidget(23, { x: 0, y: 426, w: 192, h: 65, text: "解方程式", normal_color: 0x222222, press_color: 0x444444, text_size: 28, click_func: () => { this.process(); } }); hmUI.createWidget(23, { x: 0, y: 0, w: 192, h: 70, text: "拉進垃圾車", text_size: 20, color: 0x999999, click_func: () => { this.clear(); } }); } calcFactorial(num) { if (num % 1 != 0 || num < 0) { num++; return Math.sqrt(2 * Math.PI / num) * Math.pow((1 / Math.E) * (num + 1 / (12 * num - 1 / (10 * num))), num); } else { return (num == 0) ? 1 : num * this.calcFactorial(num - 1); } } process() { let Error = false; const brDiff = this._countIncl(this.screenData, "(") - this._countIncl(this.screenData, ")"); if (brDiff === 0) { try { function solveEquation(equationString) { /* function not open source bytecode: /sdcard/index.js:181: function: solveEquation mode: strict args: equationString locals: 0: var Fraction 1: var parseNumber 2: var arr 3: catch error [level:3 next:4] 4: let unknownVariable [level:1 next:-1] 5: let tolerance [level:6 next:4] 6: let maxIterations [level:6 next:5] 7: let replacedEquationString [level:6 next:6] 8: let equation [level:6 next:7] 9: let leftHandSide [level:6 next:8] 10: let rightHandSide [level:6 next:9] 11: let equationFunction [level:6 next:10] 12: let ans [level:6 next:11] 13: let text [level:6 next:12] 14: let guess [level:6 next:13] 15: let i [level:7 next:14] 16: let f [level:8 next:15] 17: const parsedNumber [level:10 next:18] 18: let df [level:8 next:16] 19: var this 20: var new.target 21: var arguments closure vars: 0: solveEquation local:loc2 let 1: brDiff local:loc1 const 2: Error local:loc0 let 3: <class_fields_init> parent:loc0 const 4: Calculator parent:loc1 const 5: __$$module$$__ parent:loc2 let 6: __$$app$$__ parent:loc3 let 7: Calculator parent:loc4 let stack_size: 9 opcodes: 0 0C 03 special_object 3 2 C2 14 put_loc8 20: "new.target" 4 08 push_this 5 C2 13 put_loc8 19: this 7 0C 00 special_object 0 9 C2 15 put_loc8 21: arguments 11 BF 00 fclosure8 0: [bytecode Fraction] 13 C8 put_loc0 0: Fraction [definition of function Fraction(str)] */ function Fraction(str) { /* function not open source bytecode: /sdcard/index.js:182: function: Fraction mode: strict args: str locals: 0: let arr [level:7 next:-1] 1: let arr [level:11 next:-1] stack_size: 5 opcodes: 0 D0 get_arg0 0: str 1 98 typeof 2 04 48 00 00 00 push_atom_value string 7 AD strict_neq 8 E9 0B if_false8 20 10 D0 get_arg0 0: str 11 42 37 00 00 00 get_field2 toString 16 24 00 00 call_method 0 19 D4 put_arg0 0: str 20 BE 00 20: push_const8 0: 1"\u5206\u6570\\([^)]+\\)" 22 BE 01 push_const8 1: 1"\u0000\u0001\u00009\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u0006R\u0001pe\u0001(\u0000\u001c\u000c\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0002\u0000\u0000\u0000(\u0000*\u0000\u00ff\u00ff\n\u0001)\u0000\u000c\u0000\n" 24 33 regexp 25 42 82 01 00 00 get_field2 test 30 D0 get_arg0 0: str 31 24 01 00 call_method 1 34 E9 1C if_false8 63 36 38 BC 01 00 00 get_var hmUI 41 42 08 02 00 00 get_field2 showToast 46 0B object 47 04 09 02 00 00 push_atom_value "\u00e6\u00a0\u00bc\u00e5\u00bc\u008f\u00e4\u00b8\u008d\u00e7\u00ac\u00a6\u00e5\u0090\u0088\n\u00e5\u00b7\u00b2\u00e6\u0094\u00b9\u00e6\u0088\u00900" 52 4C D1 01 00 00 define_field text 57 24 01 00 call_method 1 60 0E drop 61 B4 push_0 0 62 28 return 63 BE 02 63: push_const8 2: 1"(^[\\s\\S]*)\u53c8([\\s\\S]*)\u5206\u4e4b([\\s\\S]*)" 65 BE 03 push_const8 3: 1"\u0000\u0004\u0000q\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u000b\u0001\u0005\u001c\u0008\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u0000\u0000\u0000\u00ff\u00ff\n\u000c\u0001\u0001\u00c8S\u000b\u0002\u001c\u0008\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u0000\u0000\u0000\u00ff\u00ff\n\u000c\u0002\u0001\u0006R\u0001KN\u000b\u0003\u001c\u0008\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u0000\u0000\u0000\u00ff\u00ff\n\u000c\u0003\u000c\u0000\n" 67 33 regexp 68 42 82 01 00 00 get_field2 test 73 D0 get_arg0 0: str 74 24 01 00 call_method 1 77 69 C2 00 00 00 if_false 272 82 61 00 00 set_loc_uninitialized 0: arr 85 D0 get_arg0 0: str 86 42 5C 00 00 00 get_field2 split 91 BE 04 push_const8 4: 1"\u53c8|\u5206\u4e4b" 93 BE 05 push_const8 5: 1"\u0000\u0001\u0000#\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0009\u0008\u0000\u0000\u0000\u0001\u00c8S\u0007\u0006\u0000\u0000\u0000\u0001\u0006R\u0001KN\u000c\u0000\n" 95 33 regexp 96 24 01 00 call_method 1 99 C8 put_loc0 0: arr 100 62 00 00 get_loc_check 0: arr 103 E8 get_length 104 B7 push_3 3 105 AD strict_neq 106 11 dup 107 EA 26 if_true8 146 109 0E drop 110 BE 06 push_const8 6: 1"\u53c8" 112 BE 07 push_const8 7: 1"\u0000\u0001\u0000\u0013\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u00c8S\u000c\u0000\n" 114 33 regexp 115 42 82 01 00 00 get_field2 test 120 D0 get_arg0 0: str 121 24 01 00 call_method 1 124 0A push_true 125 AD strict_neq 126 11 dup 127 EA 12 if_true8 146 129 0E drop 130 BE 08 push_const8 8: 1"\u5206\u4e4b" 132 BE 09 push_const8 9: 1"\u0000\u0001\u0000\u0016\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u0006R\u0001KN\u000c\u0000\n" 134 33 regexp 135 42 82 01 00 00 get_field2 test 140 D0 get_arg0 0: str 141 24 01 00 call_method 1 144 0A push_true 145 AD strict_neq 146 E9 1C 146: if_false8 175 148 38 BC 01 00 00 get_var hmUI 153 42 08 02 00 00 get_field2 showToast 158 0B object 159 04 09 02 00 00 push_atom_value "\u00e6\u00a0\u00bc\u00e5\u00bc\u008f\u00e4\u00b8\u008d\u00e7\u00ac\u00a6\u00e5\u0090\u0088\n\u00e5\u00b7\u00b2\u00e6\u0094\u00b9\u00e6\u0088\u00900" 164 4C D1 01 00 00 define_field text 169 24 01 00 call_method 1 172 0E drop 173 B4 push_0 0 174 28 return 175 38 A3 01 00 00 175: get_var console 180 42 A2 01 00 00 get_field2 log 185 04 DD 01 00 00 push_atom_value "(" 190 62 00 00 get_loc_check 0: arr 193 B4 push_0 0 194 47 get_array_el 195 9E add 196 04 0A 02 00 00 push_atom_value " + " 201 9E add 202 62 00 00 get_loc_check 0: arr 205 B6 push_2 2 206 47 get_array_el 207 9E add 208 04 0B 02 00 00 push_atom_value " / " 213 9E add 214 62 00 00 get_loc_check 0: arr 217 B5 push_1 1 218 47 get_array_el 219 9E add 220 04 DE 01 00 00 push_atom_value ")" 225 9E add 226 24 01 00 call_method 1 229 0E drop 230 04 DD 01 00 00 push_atom_value "(" 235 62 00 00 get_loc_check 0: arr 238 B4 push_0 0 239 47 get_array_el 240 9E add 241 04 0A 02 00 00 push_atom_value " + " 246 9E add 247 62 00 00 get_loc_check 0: arr 250 B6 push_2 2 251 47 get_array_el 252 04 0B 02 00 00 push_atom_value " / " 257 9E add 258 62 00 00 get_loc_check 0: arr 261 B5 push_1 1 262 47 get_array_el 263 9E add 264 9E add 265 04 DE 01 00 00 push_atom_value ")" 270 9E add 271 28 return 272 BE 0A 272: push_const8 10: 1"(^[\\s\\S]*)\u5206\u4e4b([\\s\\S]*)" 274 BE 0B push_const8 11: 1"\u0000\u0003\u0000Q\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u000b\u0001\u0005\u001c\u0008\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u0000\u0000\u0000\u00ff\u00ff\n\u000c\u0001\u0001\u0006R\u0001KN\u000b\u0002\u001c\u0008\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u0000\u0000\u0000\u00ff\u00ff\n\u000c\u0002\u000c\u0000\n" 276 33 regexp 277 42 82 01 00 00 get_field2 test 282 D0 get_arg0 0: str 283 24 01 00 call_method 1 286 69 96 00 00 00 if_false 437 291 61 01 00 set_loc_uninitialized 1: arr 294 D0 get_arg0 0: str 295 42 5C 00 00 00 get_field2 split 300 BE 0C push_const8 12: 1"\u5206\u4e4b" 302 BE 0D push_const8 13: 1"\u0000\u0001\u0000\u0016\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u0006R\u0001KN\u000c\u0000\n" 304 33 regexp 305 24 01 00 call_method 1 308 C9 put_loc1 1: arr 309 62 01 00 get_loc_check 1: arr 312 E8 get_length 313 B6 push_2 2 314 AD strict_neq 315 11 dup 316 EA 12 if_true8 335 318 0E drop 319 BE 0E push_const8 14: 1"\u5206\u4e4b" 321 BE 0F push_const8 15: 1"\u0000\u0001\u0000\u0016\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u0006R\u0001KN\u000c\u0000\n" 323 33 regexp 324 42 82 01 00 00 get_field2 test 329 D0 get_arg0 0: str 330 24 01 00 call_method 1 333 0A push_true 334 AD strict_neq 335 E9 1C 335: if_false8 364 337 38 BC 01 00 00 get_var hmUI 342 42 08 02 00 00 get_field2 showToast 347 0B object 348 04 09 02 00 00 push_atom_value "\u00e6\u00a0\u00bc\u00e5\u00bc\u008f\u00e4\u00b8\u008d\u00e7\u00ac\u00a6\u00e5\u0090\u0088\n\u00e5\u00b7\u00b2\u00e6\u0094\u00b9\u00e6\u0088\u00900" 353 4C D1 01 00 00 define_field text 358 24 01 00 call_method 1 361 0E drop 362 B4 push_0 0 363 28 return 364 38 A3 01 00 00 364: get_var console 369 42 A2 01 00 00 get_field2 log 374 04 DD 01 00 00 push_atom_value "(" 379 62 01 00 get_loc_check 1: arr 382 B5 push_1 1 383 47 get_array_el 384 9E add 385 04 0B 02 00 00 push_atom_value " / " 390 9E add 391 62 01 00 get_loc_check 1: arr 394 B4 push_0 0 395 47 get_array_el 396 9E add 397 04 DE 01 00 00 push_atom_value ")" 402 9E add 403 24 01 00 call_method 1 406 0E drop 407 04 DD 01 00 00 push_atom_value "(" 412 62 01 00 get_loc_check 1: arr 415 B5 push_1 1 416 47 get_array_el 417 9E add 418 04 0B 02 00 00 push_atom_value " / " 423 9E add 424 62 01 00 get_loc_check 1: arr 427 B4 push_0 0 428 47 get_array_el 429 9E add 430 04 DE 01 00 00 push_atom_value ")" 435 9E add 436 28 return 437 38 BC 01 00 00 437: get_var hmUI 442 42 08 02 00 00 get_field2 showToast 447 0B object 448 04 09 02 00 00 push_atom_value "\u00e6\u00a0\u00bc\u00e5\u00bc\u008f\u00e4\u00b8\u008d\u00e7\u00ac\u00a6\u00e5\u0090\u0088\n\u00e5\u00b7\u00b2\u00e6\u0094\u00b9\u00e6\u0088\u00900" 453 4C D1 01 00 00 define_field text 458 24 01 00 call_method 1 461 0E drop 462 B4 push_0 0 463 28 return */ } /* bytecode: 14 BF 01 fclosure8 1: [bytecode parseNumber] 16 C9 put_loc1 1: parseNumber [definition of function parseNumber(str)] */ function parseNumber(str) { /* function not open source bytecode: /sdcard/index.js:211: function: parseNumber mode: strict args: str locals: 0: const regex [level:1 next:-1] 1: const matches [level:1 next:0] 2: let integerPart [level:5 next:1] 3: let decimalPart [level:5 next:2] stack_size: 4 opcodes: 0 61 01 00 set_loc_uninitialized 1: matches 3 61 00 00 set_loc_uninitialized 0: regex 6 D0 get_arg0 0: str 7 98 typeof 8 04 46 00 00 00 push_atom_value number 13 AC strict_eq 14 E9 0B if_false8 26 16 D0 get_arg0 0: str 17 42 37 00 00 00 get_field2 toString 22 24 00 00 call_method 0 25 D4 put_arg0 0: str 26 BE 00 26: push_const8 0: 1"^(-?\\d+)(\\.\\d+)?$" 28 BE 01 push_const8 1: 1"\u0000\u0003\u0000l\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0005\u000b\u0001\u001c\u0004\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u0001-\u0000\n\u001c\u0008\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u00000\u00009\u0000\n\u000c\u0001\u000d\u0002\u0002\u0009 \u0000\u0000\u0000\u000b\u0002\u0001.\u0000\u001c\u0008\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u00000\u00009\u0000\n\u000c\u0002\u0006\u000c\u0000\n" 30 33 regexp 31 C8 put_loc0 0: regex 32 D0 get_arg0 0: str 33 42 22 01 00 00 get_field2 match 38 62 00 00 get_loc_check 0: regex 41 24 01 00 call_method 1 44 C9 put_loc1 1: matches 45 62 01 00 get_loc_check 1: matches 48 E9 60 if_false8 145 50 61 03 00 set_loc_uninitialized 3: decimalPart 53 61 02 00 set_loc_uninitialized 2: integerPart 56 62 01 00 get_loc_check 1: matches 59 B5 push_1 1 60 47 get_array_el 61 CA put_loc2 2: integerPart 62 62 01 00 get_loc_check 1: matches 65 B6 push_2 2 66 47 get_array_el 67 CB put_loc3 3: decimalPart 68 62 03 00 get_loc_check 3: decimalPart 71 E9 1D if_false8 101 73 62 03 00 get_loc_check 3: decimalPart 76 42 28 01 00 00 get_field2 replace 81 BE 02 push_const8 2: 1"^\\." 83 BE 03 push_const8 3: 1"\u0000\u0001\u0000\u0014\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0005\u0001.\u0000\u000c\u0000\n" 85 33 regexp 86 04 0E 02 00 00 push_atom_value "0." 91 24 02 00 call_method 2 94 11 dup 95 63 03 00 put_loc_check 3: decimalPart 98 0E drop 99 EB 0B goto8 111 101 04 0F 02 00 00 101: push_atom_value "0.0" 106 11 dup 107 63 03 00 put_loc_check 3: decimalPart 110 0E drop 111 0B 111: object 112 62 02 00 get_loc_check 2: integerPart 115 42 37 00 00 00 get_field2 toString 120 24 00 00 call_method 0 123 4C FE 01 00 00 define_field integerPart 128 62 03 00 get_loc_check 3: decimalPart 131 42 37 00 00 00 get_field2 toString 136 24 00 00 call_method 0 139 4C 00 02 00 00 define_field decimalPart 144 28 return 145 D0 145: get_arg0 0: str 146 28 return */ } /* 17 61 04 00 set_loc_uninitialized 4: unknownVariable 20 6C 23 00 00 00 catch 56 25 D0 get_arg0 0: equationString 26 42 22 01 00 00 get_field2 match 31 BE 02 push_const8 2: 1"[a-zA-Z]+" 33 BE 03 push_const8 3: 1"\u0001\u0001\u0000-\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u001c\u000c\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0002\u0000A\u0000Z\u0000a\u0000z\u0000\n\u000c\u0000\n" 35 33 regexp 36 24 01 00 call_method 1 39 42 EE 00 00 00 get_field2 reduce 44 BF 04 fclosure8 4: [bytecode <null>] 46 26 00 00 array_from 0 49 24 02 00 call_method 2 52 CA put_loc2 2: arr 53 0E drop 54 EB 0B goto8 66 56 CB 56: put_loc3 3: error 57 6C 07 00 00 00 catch 65 62 0E drop 63 EB 02 goto8 66 65 2F 65: throw 66 C6 66: get_loc2 2: arr 67 B4 push_0 0 68 47 get_array_el 69 C2 04 put_loc8 4: unknownVariable 71 C6 get_loc2 2: arr 72 E8 get_length 73 B5 push_1 1 74 AC strict_eq 75 69 67 02 00 00 if_false 691 80 61 0E 00 set_loc_uninitialized 14: guess 83 61 0D 00 set_loc_uninitialized 13: text 86 61 0C 00 set_loc_uninitialized 12: ans 89 61 0B 00 set_loc_uninitialized 11: equationFunction 92 61 0A 00 set_loc_uninitialized 10: rightHandSide 95 61 09 00 set_loc_uninitialized 9: leftHandSide 98 61 08 00 set_loc_uninitialized 8: equation 101 61 07 00 set_loc_uninitialized 7: replacedEquationString 104 61 06 00 set_loc_uninitialized 6: maxIterations 107 61 05 00 set_loc_uninitialized 5: tolerance 110 BE 05 push_const8 5: 1e-08 112 C2 05 put_loc8 5: tolerance 114 BD 10 27 push_i16 10000 117 C2 06 put_loc8 6: maxIterations 119 D0 get_arg0 0: equationString 120 42 28 01 00 00 get_field2 replace 125 BE 06 push_const8 6: 1"(\\d|\\))(\\(|[a-z]|\u03c0|\u5206\u6578)" 127 BE 07 push_const8 7: 1"\u0001\u0003\u0000]\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u000b\u0001\u0009\u000c\u0000\u0000\u0000\u0015\u0001\u00000\u00009\u0000\u0007\u0003\u0000\u0000\u0000\u0001)\u0000\u000c\u0001\u000b\u0002\u0009&\u0000\u0000\u0000\u0009\u0019\u0000\u0000\u0000\u0009\u0008\u0000\u0000\u0000\u0001(\u0000\u0007\u0007\u0000\u0000\u0000\u0015\u0001\u0000a\u0000z\u0000\u0007\u0003\u0000\u0000\u0000\u0001\u00c0\u0003\u0007\u0006\u0000\u0000\u0000\u0001\u0006R\u0001xe\u000c\u0002\u000c\u0000\n" 129 33 regexp 130 04 F3 01 00 00 push_atom_value "$1*$2" 135 24 02 00 call_method 2 138 42 28 01 00 00 get_field2 replace 143 BE 08 push_const8 8: 1"\\^" 145 BE 09 push_const8 9: 1"\u0001\u0001\u0000\u0013\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001^\u0000\u000c\u0000\n" 147 33 regexp 148 04 F4 01 00 00 push_atom_value "**" 153 24 02 00 call_method 2 156 42 28 01 00 00 get_field2 replace 161 BE 0A push_const8 10: 1"\u00d7" 163 BE 0B push_const8 11: 1"\u0001\u0001\u0000\u0013\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u00d7\u0000\u000c\u0000\n" 165 33 regexp 166 04 7C 00 00 00 push_atom_value "*" 171 24 02 00 call_method 2 174 42 28 01 00 00 get_field2 replace 179 BE 0C push_const8 12: 1"\u00f7" 181 BE 0D push_const8 13: 1"\u0001\u0001\u0000\u0013\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u00f7\u0000\u000c\u0000\n" 183 33 regexp 184 04 F5 01 00 00 push_atom_value "/" 189 24 02 00 call_method 2 192 42 28 01 00 00 get_field2 replace 197 BE 0E push_const8 14: 1"\u03c0" 199 BE 0F push_const8 15: 1"\u0001\u0001\u0000\u0013\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u00c0\u0003\u000c\u0000\n" 201 33 regexp 202 04 F6 01 00 00 push_atom_value "3.14" 207 24 02 00 call_method 2 210 42 28 01 00 00 get_field2 replace 215 BE 10 push_const8 16: 1"\\|([^|]+)\\|" 217 BE 11 push_const8 17: 1"\u0001\u0002\u00007\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001|\u0000\u000b\u0001\u001c\u000c\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0002\u0000\u0000\u0000{\u0000}\u0000\u00ff\u00ff\n\u000c\u0001\u0001|\u0000\u000c\u0000\n" 219 33 regexp 220 04 F7 01 00 00 push_atom_value "(Math.abs($1))" 225 24 02 00 call_method 2 228 42 28 01 00 00 get_field2 replace 233 BE 12 push_const8 18: 1"\u221a\\(([^)]+)\\)" 235 BE 13 push_const8 19: 1"\u0001\u0002\u0000:\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u001a\"\u0001(\u0000\u000b\u0001\u001c\u000c\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0002\u0000\u0000\u0000(\u0000*\u0000\u00ff\u00ff\n\u000c\u0001\u0001)\u0000\u000c\u0000\n" 237 33 regexp 238 04 F8 01 00 00 push_atom_value "(Math.sqrt($1))" 243 24 02 00 call_method 2 246 42 28 01 00 00 get_field2 replace 251 BE 14 push_const8 20: 1"\u5206\u6578\\(([^)]+)\\)" 253 BE 15 push_const8 21: 1"\u0001\u0002\u0000=\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u0006R\u0001xe\u0001(\u0000\u000b\u0001\u001c\u000c\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0002\u0000\u0000\u0000(\u0000*\u0000\u00ff\u00ff\n\u000c\u0001\u0001)\u0000\u000c\u0000\n" 255 33 regexp 256 BF 16 fclosure8 22: [bytecode <null>] 258 24 02 00 call_method 2 261 C2 07 put_loc8 7: replacedEquationString 263 38 A3 01 00 00 get_var console 268 42 A2 01 00 00 get_field2 log 273 62 07 00 get_loc_check 7: replacedEquationString 276 24 01 00 call_method 1 279 0E drop 280 62 07 00 get_loc_check 7: replacedEquationString 283 42 28 01 00 00 get_field2 replace 288 BE 17 push_const8 23: 1"\\s" 290 BE 18 push_const8 24: 1"\u0001\u0001\u0000;\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0015\n\u0000\u0009\u0000\u000d\u0000 \u0000 \u0000\u00a0\u0000\u00a0\u0000\u0080\u0016\u0080\u0016\u0000 \n ( ) / / _ _ \u00000\u00000\u00ff\u00fe\u00ff\u00fe\u000c\u0000\n" 292 33 regexp 293 C0 push_empty_string 294 24 02 00 call_method 2 297 C2 08 put_loc8 8: equation 299 62 08 00 get_loc_check 8: equation 302 42 5C 00 00 00 get_field2 split 307 04 F9 01 00 00 push_atom_value "=" 312 24 01 00 call_method 1 315 B4 push_0 0 316 47 get_array_el 317 C2 09 put_loc8 9: leftHandSide 319 62 08 00 get_loc_check 8: equation 322 42 5C 00 00 00 get_field2 split 327 04 F9 01 00 00 push_atom_value "=" 332 24 01 00 call_method 1 335 B5 push_1 1 336 47 get_array_el 337 C2 0A put_loc8 10: rightHandSide 339 38 3A 00 00 00 get_var eval 344 04 DD 01 00 00 push_atom_value "(" 349 42 5B 00 00 00 get_field2 concat 354 62 04 00 get_loc_check 4: unknownVariable 357 04 FA 01 00 00 push_atom_value ") => " 362 62 09 00 get_loc_check 9: leftHandSide 365 04 FB 01 00 00 push_atom_value " - (" 370 62 0A 00 get_loc_check 10: rightHandSide 373 04 DE 01 00 00 push_atom_value ")" 378 24 06 00 call_method 6 381 31 01 00 0F 00 eval 1,15 386 C2 0B put_loc8 11: equationFunction 388 C0 push_empty_string 389 C2 0C put_loc8 12: ans 391 06 undefined 392 C2 0D put_loc8 13: text 394 B5 push_1 1 395 C2 0E put_loc8 14: guess 397 61 0F 00 set_loc_uninitialized 15: i 400 B4 push_0 0 401 C2 0F put_loc8 15: i 403 62 0F 00 403: get_loc_check 15: i 406 62 06 00 get_loc_check 6: maxIterations 409 A4 lt 410 69 F8 00 00 00 if_false 659 415 61 12 00 set_loc_uninitialized 18: df 418 61 10 00 set_loc_uninitialized 16: f 421 62 0B 00 get_loc_check 11: equationFunction 424 62 0E 00 get_loc_check 14: guess 427 EE call1 1 428 C2 10 put_loc8 16: f 430 38 96 00 00 00 get_var Math 435 42 FC 01 00 00 get_field2 abs 440 62 10 00 get_loc_check 16: f 443 24 01 00 call_method 1 446 62 05 00 get_loc_check 5: tolerance 449 A4 lt 450 69 92 00 00 00 if_false 597 455 61 11 00 set_loc_uninitialized 17: parsedNumber 458 C5 get_loc1 1: parseNumber 459 62 0E 00 get_loc_check 14: guess 462 EE call1 1 463 C2 11 put_loc8 17: parsedNumber 465 38 A3 01 00 00 get_var console 470 42 A2 01 00 00 get_field2 log 475 04 FD 01 00 00 push_atom_value "\u00e6\u0095\u00b4\u00e6\u0095\u00b0\u00e9\u0083\u00a8\u00e5\u0088\u0086:" 480 62 11 00 get_loc_check 17: parsedNumber 483 41 FE 01 00 00 get_field integerPart 488 24 02 00 call_method 2 491 0E drop 492 38 A3 01 00 00 get_var console 497 42 A2 01 00 00 get_field2 log 502 04 FF 01 00 00 push_atom_value "\u00e5\u00b0\u008f\u00e6\u0095\u00b0\u00e9\u0083\u00a8\u00e5\u0088\u0086:" 507 62 11 00 get_loc_check 17: parsedNumber 510 41 00 02 00 00 get_field decimalPart 515 42 37 00 00 00 get_field2 toString 520 24 00 00 call_method 0 523 42 26 01 00 00 get_field2 substr 528 B4 push_0 0 529 BC 0A push_i8 10 531 24 02 00 call_method 2 534 24 02 00 call_method 2 537 0E drop 538 38 96 00 00 00 get_var Math 543 42 01 02 00 00 get_field2 round 548 62 0E 00 get_loc_check 14: guess 551 01 80 96 98 00 push_i32 10000000 556 9B mul 557 24 01 00 call_method 1 560 01 80 96 98 00 push_i32 10000000 565 9C div 566 11 dup 567 63 0D 00 put_loc_check 13: text 570 0E drop 571 04 02 02 00 00 push_atom_value "\u00e6\u0096\u00b9\u00e7\u00a8\u008b\u00e7\u009a\u0084\u00e8\u00a7\u00a3\u00e4\u00b8\u00ba\u00ef\u00bc\u009a\n" 576 62 04 00 get_loc_check 4: unknownVariable 579 9E add 580 04 03 02 00 00 push_atom_value " = " 585 9E add 586 62 0D 00 get_loc_check 13: text 589 9E add 590 11 dup 591 63 0C 00 put_loc_check 12: ans 594 0E drop 595 EB 3F goto8 659 597 62 0B 00 597: get_loc_check 11: equationFunction 600 62 0E 00 get_loc_check 14: guess 603 BE 19 push_const8 25: 1e-13 605 9E add 606 EE call1 1 607 62 10 00 get_loc_check 16: f 610 9F sub 611 BE 1A push_const8 26: 1e-13 613 9C div 614 C2 12 put_loc8 18: df 616 62 0E 00 get_loc_check 14: guess 619 62 10 00 get_loc_check 16: f 622 62 12 00 get_loc_check 18: df 625 9C div 626 9F sub 627 11 dup 628 63 0E 00 put_loc_check 14: guess 631 0E drop 632 38 A3 01 00 00 get_var console 637 42 A2 01 00 00 get_field2 log 642 62 0F 00 get_loc_check 15: i 645 92 post_inc 646 63 0F 00 put_loc_check 15: i 649 62 0E 00 get_loc_check 14: guess 652 24 02 00 call_method 2 655 0E drop 656 EC 02 FF goto16 403 659 38 A3 01 00 00 659: get_var console 664 42 A2 01 00 00 get_field2 log 669 62 0C 00 get_loc_check 12: ans 672 24 01 00 call_method 1 675 0E drop 676 62 0C 00 get_loc_check 12: ans 679 E9 05 if_false8 685 681 62 0C 00 get_loc_check 12: ans 684 28 return 685 04 04 02 00 00 685: push_atom_value "\u00e6\u009c\u00aa\u00e8\u0083\u00bd\u00e6\u0089\u00be\u00e5\u0088\u00b0\u00e6\u0096\u00b9\u00e7\u00a8\u008b\u00e7\u009a\u0084\u00e8\u00a7\u00a3" 690 28 return 691 C6 691: get_loc2 2: arr 692 E8 get_length 693 B4 push_0 0 694 AC strict_eq 695 E9 07 if_false8 703 697 04 05 02 00 00 push_atom_value "\u00e6\u00b2\u0092\u00e6\u009c\u0089\u00e6\u009c\u00aa\u00e7\u009f\u00a5\u00e6\u0095\u00b8" 702 28 return 703 04 06 02 00 00 703: push_atom_value "\u00e7\u009b\u00a1\u00e8\u00ab\u008b\u00e6\u009c\u009f\u00e5\u00be\u0085" 708 28 return */ } this.screen.setProperty(hmUI.prop.MORE, { text: solveEquation(this.screenData), }); Error = true; //this.screenData = "方程式的解为:"+ JSON.stringify(result) } catch (e) { this.screen.setProperty(hmUI.prop.MORE, { text: "請先檢査方程式", }); Error = true; } } else { for (let i = 0; i < brDiff; i++) this.screenData += ")"; } if (Error == false) this.updateScreen(); } _countIncl(str, chr) { let c = 0; for (let i in str) if (str[i] === chr) c++; return c; } switchSet() { const newId = (this.currentSetId + 1) % this.buttonSets.length; const newSet = this.buttonSets[newId]; for (let i = 0; i < newSet.length; i++) { this.buttons[i].setProperty(hmUI.prop.TEXT, newSet[i]); } this.currentSetId = newId; this.currentSet = newSet; } initButtonEvents(i) { return () => { if (i == 11) return this.switchSet(); let val = this.currentSet[i]; if (this.operations[val]) val = this.operations[val]; this.appendScreen(val); while (this.currentSetId != 0) this.switchSet(); }; } appendScreen(val) { this.screenData += val; this.updateScreen(); } updateScreen() { this.screen.setProperty(hmUI.prop.MORE, { text: this.screenData, }); } clear() { this.screenData = ""; this.updateScreen(); } backspace() { let delchar = 1 this.screenData = this.screenData.substring(0, this.screenData.length - delchar); this.updateScreen(); } } // source: /home/melianmiko/Projects/mb7_apps/calculator/entrypoint.js let __$$app$$__ = __$$hmAppManager$$__.currentApp; let __$$module$$__ = __$$app$$__.current; __$$module$$__.module = DeviceRuntimeCore.Page({ onInit() { hmUI.setLayerScrolling(false); new Calculator() .start(); }, }); })();
酷如上
作者 @淘汰郎 https://www.bandbbs.cn/threads/9536/
•index.bin 大小縮小>90% (77 kb -> 7 kb)
•大幅減少APP對手環RAM的使用量
•使用更快更流暢
•UI優化
源代碼 (僅作部份開源,有興趣可以自己去原帖買,只需2023 coins 哦 🙂 ):
JavaScript:/** * Build with ZMake tool */ // Build at 2022-08-08 16:53:06.368238 (() => { // source: /home/melianmiko/Projects/mb7_apps/calculator/src/Calculator.js class Calculator { buttons = []; screen = null; screenData = ""; currentSet = []; currentSetId = -1; buttonSets = [ ["7", "8", "9", "4", "5", "6", "1", "2", "3", "0", "."], ["+", "-", "×", "÷", "^", "√", "|", "=", "π", "(", ")"], ["x", "y", "z", "分數", "又", "分之", "", "", "", "", ""],]; operations = { "+": "+", "-": "-", "×": "×", "÷": "÷", "^": "^", "√": "√(", "∛": "∛(", "π": "π", "分數": "分數(", }; start() { // Init screen hmUI.createWidget(5, { x: 5, y: 80, w: 183, h: 76, radius: 8, line_width: 2, color: 0x222222 }); this.screen = hmUI.createWidget(2, { x: 11, y: 80, w: 172, h: 80, color: 0xc5c5c5, text_size: 24, text_style: 1, align_v: 16, }); this.screen.addEventListener(3, () => { this.backspace(); }); // Init buttons for (let i = 0; i < 12; i++) { this.buttons[i] = hmUI.createWidget(23, { x: (i % 3) * 64 + 2, y: Math.floor(i / 3) * 64 + 168, w: 60, h: 60, radius: 8, text_size: 28, normal_color: 0x222222, press_color: 0x333333, click_func: this.initButtonEvents(i), }); } this.buttons[11].setProperty(0, { x: 130, y: 360, w: 60, h: 60, text: "...", normal_color: 0x444444, press_color: 0x666666, }); this.switchSet(); hmUI.createWidget(5, { x: 5, y: 80, w: 183, h: 76, radius: 8, line_width: 2, color: 0x222222 }); this.screen = hmUI.createWidget(2, { x: 11, y: 80, w: 172, h: 80, color: 0xc5c5c5, text_size: 24, text_style: 1, align_v: 16, }); this.screen.addEventListener(3, () => { this.backspace(); }); // Init buttons for (let i = 0; i < 12; i++) { this.buttons[i] = hmUI.createWidget(23, { x: (i % 3) * 64 + 2, y: Math.floor(i / 3) * 64 + 168, w: 60, h: 60, radius: 8, text_size: 28, normal_color: 0x222222, press_color: 0x333333, click_func: this.initButtonEvents(i), }); } this.buttons[11].setProperty(0, { x: 130, y: 360, w: 60, h: 60, text: "...", normal_color: 0x444444, press_color: 0x666666, }); this.switchSet(); // Init remove and process buttons hmUI.createWidget(23, { x: 0, y: 426, w: 192, h: 65, text: "解方程式", normal_color: 0x222222, press_color: 0x444444, text_size: 28, click_func: () => { this.process(); } }); hmUI.createWidget(23, { x: 0, y: 0, w: 192, h: 70, text: "拉進垃圾車", text_size: 20, color: 0x999999, click_func: () => { this.clear(); } }); } calcFactorial(num) { if (num % 1 != 0 || num < 0) { num++; return Math.sqrt(2 * Math.PI / num) * Math.pow((1 / Math.E) * (num + 1 / (12 * num - 1 / (10 * num))), num); } else { return (num == 0) ? 1 : num * this.calcFactorial(num - 1); } } process() { let Error = false; const brDiff = this._countIncl(this.screenData, "(") - this._countIncl(this.screenData, ")"); if (brDiff === 0) { try { function solveEquation(equationString) { /* function not open source bytecode: /sdcard/index.js:181: function: solveEquation mode: strict args: equationString locals: 0: var Fraction 1: var parseNumber 2: var arr 3: catch error [level:3 next:4] 4: let unknownVariable [level:1 next:-1] 5: let tolerance [level:6 next:4] 6: let maxIterations [level:6 next:5] 7: let replacedEquationString [level:6 next:6] 8: let equation [level:6 next:7] 9: let leftHandSide [level:6 next:8] 10: let rightHandSide [level:6 next:9] 11: let equationFunction [level:6 next:10] 12: let ans [level:6 next:11] 13: let text [level:6 next:12] 14: let guess [level:6 next:13] 15: let i [level:7 next:14] 16: let f [level:8 next:15] 17: const parsedNumber [level:10 next:18] 18: let df [level:8 next:16] 19: var this 20: var new.target 21: var arguments closure vars: 0: solveEquation local:loc2 let 1: brDiff local:loc1 const 2: Error local:loc0 let 3: <class_fields_init> parent:loc0 const 4: Calculator parent:loc1 const 5: __$$module$$__ parent:loc2 let 6: __$$app$$__ parent:loc3 let 7: Calculator parent:loc4 let stack_size: 9 opcodes: 0 0C 03 special_object 3 2 C2 14 put_loc8 20: "new.target" 4 08 push_this 5 C2 13 put_loc8 19: this 7 0C 00 special_object 0 9 C2 15 put_loc8 21: arguments 11 BF 00 fclosure8 0: [bytecode Fraction] 13 C8 put_loc0 0: Fraction [definition of function Fraction(str)] */ function Fraction(str) { /* function not open source bytecode: /sdcard/index.js:182: function: Fraction mode: strict args: str locals: 0: let arr [level:7 next:-1] 1: let arr [level:11 next:-1] stack_size: 5 opcodes: 0 D0 get_arg0 0: str 1 98 typeof 2 04 48 00 00 00 push_atom_value string 7 AD strict_neq 8 E9 0B if_false8 20 10 D0 get_arg0 0: str 11 42 37 00 00 00 get_field2 toString 16 24 00 00 call_method 0 19 D4 put_arg0 0: str 20 BE 00 20: push_const8 0: 1"\u5206\u6570\\([^)]+\\)" 22 BE 01 push_const8 1: 1"\u0000\u0001\u00009\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u0006R\u0001pe\u0001(\u0000\u001c\u000c\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0002\u0000\u0000\u0000(\u0000*\u0000\u00ff\u00ff\n\u0001)\u0000\u000c\u0000\n" 24 33 regexp 25 42 82 01 00 00 get_field2 test 30 D0 get_arg0 0: str 31 24 01 00 call_method 1 34 E9 1C if_false8 63 36 38 BC 01 00 00 get_var hmUI 41 42 08 02 00 00 get_field2 showToast 46 0B object 47 04 09 02 00 00 push_atom_value "\u00e6\u00a0\u00bc\u00e5\u00bc\u008f\u00e4\u00b8\u008d\u00e7\u00ac\u00a6\u00e5\u0090\u0088\n\u00e5\u00b7\u00b2\u00e6\u0094\u00b9\u00e6\u0088\u00900" 52 4C D1 01 00 00 define_field text 57 24 01 00 call_method 1 60 0E drop 61 B4 push_0 0 62 28 return 63 BE 02 63: push_const8 2: 1"(^[\\s\\S]*)\u53c8([\\s\\S]*)\u5206\u4e4b([\\s\\S]*)" 65 BE 03 push_const8 3: 1"\u0000\u0004\u0000q\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u000b\u0001\u0005\u001c\u0008\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u0000\u0000\u0000\u00ff\u00ff\n\u000c\u0001\u0001\u00c8S\u000b\u0002\u001c\u0008\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u0000\u0000\u0000\u00ff\u00ff\n\u000c\u0002\u0001\u0006R\u0001KN\u000b\u0003\u001c\u0008\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u0000\u0000\u0000\u00ff\u00ff\n\u000c\u0003\u000c\u0000\n" 67 33 regexp 68 42 82 01 00 00 get_field2 test 73 D0 get_arg0 0: str 74 24 01 00 call_method 1 77 69 C2 00 00 00 if_false 272 82 61 00 00 set_loc_uninitialized 0: arr 85 D0 get_arg0 0: str 86 42 5C 00 00 00 get_field2 split 91 BE 04 push_const8 4: 1"\u53c8|\u5206\u4e4b" 93 BE 05 push_const8 5: 1"\u0000\u0001\u0000#\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0009\u0008\u0000\u0000\u0000\u0001\u00c8S\u0007\u0006\u0000\u0000\u0000\u0001\u0006R\u0001KN\u000c\u0000\n" 95 33 regexp 96 24 01 00 call_method 1 99 C8 put_loc0 0: arr 100 62 00 00 get_loc_check 0: arr 103 E8 get_length 104 B7 push_3 3 105 AD strict_neq 106 11 dup 107 EA 26 if_true8 146 109 0E drop 110 BE 06 push_const8 6: 1"\u53c8" 112 BE 07 push_const8 7: 1"\u0000\u0001\u0000\u0013\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u00c8S\u000c\u0000\n" 114 33 regexp 115 42 82 01 00 00 get_field2 test 120 D0 get_arg0 0: str 121 24 01 00 call_method 1 124 0A push_true 125 AD strict_neq 126 11 dup 127 EA 12 if_true8 146 129 0E drop 130 BE 08 push_const8 8: 1"\u5206\u4e4b" 132 BE 09 push_const8 9: 1"\u0000\u0001\u0000\u0016\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u0006R\u0001KN\u000c\u0000\n" 134 33 regexp 135 42 82 01 00 00 get_field2 test 140 D0 get_arg0 0: str 141 24 01 00 call_method 1 144 0A push_true 145 AD strict_neq 146 E9 1C 146: if_false8 175 148 38 BC 01 00 00 get_var hmUI 153 42 08 02 00 00 get_field2 showToast 158 0B object 159 04 09 02 00 00 push_atom_value "\u00e6\u00a0\u00bc\u00e5\u00bc\u008f\u00e4\u00b8\u008d\u00e7\u00ac\u00a6\u00e5\u0090\u0088\n\u00e5\u00b7\u00b2\u00e6\u0094\u00b9\u00e6\u0088\u00900" 164 4C D1 01 00 00 define_field text 169 24 01 00 call_method 1 172 0E drop 173 B4 push_0 0 174 28 return 175 38 A3 01 00 00 175: get_var console 180 42 A2 01 00 00 get_field2 log 185 04 DD 01 00 00 push_atom_value "(" 190 62 00 00 get_loc_check 0: arr 193 B4 push_0 0 194 47 get_array_el 195 9E add 196 04 0A 02 00 00 push_atom_value " + " 201 9E add 202 62 00 00 get_loc_check 0: arr 205 B6 push_2 2 206 47 get_array_el 207 9E add 208 04 0B 02 00 00 push_atom_value " / " 213 9E add 214 62 00 00 get_loc_check 0: arr 217 B5 push_1 1 218 47 get_array_el 219 9E add 220 04 DE 01 00 00 push_atom_value ")" 225 9E add 226 24 01 00 call_method 1 229 0E drop 230 04 DD 01 00 00 push_atom_value "(" 235 62 00 00 get_loc_check 0: arr 238 B4 push_0 0 239 47 get_array_el 240 9E add 241 04 0A 02 00 00 push_atom_value " + " 246 9E add 247 62 00 00 get_loc_check 0: arr 250 B6 push_2 2 251 47 get_array_el 252 04 0B 02 00 00 push_atom_value " / " 257 9E add 258 62 00 00 get_loc_check 0: arr 261 B5 push_1 1 262 47 get_array_el 263 9E add 264 9E add 265 04 DE 01 00 00 push_atom_value ")" 270 9E add 271 28 return 272 BE 0A 272: push_const8 10: 1"(^[\\s\\S]*)\u5206\u4e4b([\\s\\S]*)" 274 BE 0B push_const8 11: 1"\u0000\u0003\u0000Q\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u000b\u0001\u0005\u001c\u0008\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u0000\u0000\u0000\u00ff\u00ff\n\u000c\u0001\u0001\u0006R\u0001KN\u000b\u0002\u001c\u0008\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u0000\u0000\u0000\u00ff\u00ff\n\u000c\u0002\u000c\u0000\n" 276 33 regexp 277 42 82 01 00 00 get_field2 test 282 D0 get_arg0 0: str 283 24 01 00 call_method 1 286 69 96 00 00 00 if_false 437 291 61 01 00 set_loc_uninitialized 1: arr 294 D0 get_arg0 0: str 295 42 5C 00 00 00 get_field2 split 300 BE 0C push_const8 12: 1"\u5206\u4e4b" 302 BE 0D push_const8 13: 1"\u0000\u0001\u0000\u0016\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u0006R\u0001KN\u000c\u0000\n" 304 33 regexp 305 24 01 00 call_method 1 308 C9 put_loc1 1: arr 309 62 01 00 get_loc_check 1: arr 312 E8 get_length 313 B6 push_2 2 314 AD strict_neq 315 11 dup 316 EA 12 if_true8 335 318 0E drop 319 BE 0E push_const8 14: 1"\u5206\u4e4b" 321 BE 0F push_const8 15: 1"\u0000\u0001\u0000\u0016\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u0006R\u0001KN\u000c\u0000\n" 323 33 regexp 324 42 82 01 00 00 get_field2 test 329 D0 get_arg0 0: str 330 24 01 00 call_method 1 333 0A push_true 334 AD strict_neq 335 E9 1C 335: if_false8 364 337 38 BC 01 00 00 get_var hmUI 342 42 08 02 00 00 get_field2 showToast 347 0B object 348 04 09 02 00 00 push_atom_value "\u00e6\u00a0\u00bc\u00e5\u00bc\u008f\u00e4\u00b8\u008d\u00e7\u00ac\u00a6\u00e5\u0090\u0088\n\u00e5\u00b7\u00b2\u00e6\u0094\u00b9\u00e6\u0088\u00900" 353 4C D1 01 00 00 define_field text 358 24 01 00 call_method 1 361 0E drop 362 B4 push_0 0 363 28 return 364 38 A3 01 00 00 364: get_var console 369 42 A2 01 00 00 get_field2 log 374 04 DD 01 00 00 push_atom_value "(" 379 62 01 00 get_loc_check 1: arr 382 B5 push_1 1 383 47 get_array_el 384 9E add 385 04 0B 02 00 00 push_atom_value " / " 390 9E add 391 62 01 00 get_loc_check 1: arr 394 B4 push_0 0 395 47 get_array_el 396 9E add 397 04 DE 01 00 00 push_atom_value ")" 402 9E add 403 24 01 00 call_method 1 406 0E drop 407 04 DD 01 00 00 push_atom_value "(" 412 62 01 00 get_loc_check 1: arr 415 B5 push_1 1 416 47 get_array_el 417 9E add 418 04 0B 02 00 00 push_atom_value " / " 423 9E add 424 62 01 00 get_loc_check 1: arr 427 B4 push_0 0 428 47 get_array_el 429 9E add 430 04 DE 01 00 00 push_atom_value ")" 435 9E add 436 28 return 437 38 BC 01 00 00 437: get_var hmUI 442 42 08 02 00 00 get_field2 showToast 447 0B object 448 04 09 02 00 00 push_atom_value "\u00e6\u00a0\u00bc\u00e5\u00bc\u008f\u00e4\u00b8\u008d\u00e7\u00ac\u00a6\u00e5\u0090\u0088\n\u00e5\u00b7\u00b2\u00e6\u0094\u00b9\u00e6\u0088\u00900" 453 4C D1 01 00 00 define_field text 458 24 01 00 call_method 1 461 0E drop 462 B4 push_0 0 463 28 return */ } /* bytecode: 14 BF 01 fclosure8 1: [bytecode parseNumber] 16 C9 put_loc1 1: parseNumber [definition of function parseNumber(str)] */ function parseNumber(str) { /* function not open source bytecode: /sdcard/index.js:211: function: parseNumber mode: strict args: str locals: 0: const regex [level:1 next:-1] 1: const matches [level:1 next:0] 2: let integerPart [level:5 next:1] 3: let decimalPart [level:5 next:2] stack_size: 4 opcodes: 0 61 01 00 set_loc_uninitialized 1: matches 3 61 00 00 set_loc_uninitialized 0: regex 6 D0 get_arg0 0: str 7 98 typeof 8 04 46 00 00 00 push_atom_value number 13 AC strict_eq 14 E9 0B if_false8 26 16 D0 get_arg0 0: str 17 42 37 00 00 00 get_field2 toString 22 24 00 00 call_method 0 25 D4 put_arg0 0: str 26 BE 00 26: push_const8 0: 1"^(-?\\d+)(\\.\\d+)?$" 28 BE 01 push_const8 1: 1"\u0000\u0003\u0000l\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0005\u000b\u0001\u001c\u0004\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u0001-\u0000\n\u001c\u0008\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u00000\u00009\u0000\n\u000c\u0001\u000d\u0002\u0002\u0009 \u0000\u0000\u0000\u000b\u0002\u0001.\u0000\u001c\u0008\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0001\u00000\u00009\u0000\n\u000c\u0002\u0006\u000c\u0000\n" 30 33 regexp 31 C8 put_loc0 0: regex 32 D0 get_arg0 0: str 33 42 22 01 00 00 get_field2 match 38 62 00 00 get_loc_check 0: regex 41 24 01 00 call_method 1 44 C9 put_loc1 1: matches 45 62 01 00 get_loc_check 1: matches 48 E9 60 if_false8 145 50 61 03 00 set_loc_uninitialized 3: decimalPart 53 61 02 00 set_loc_uninitialized 2: integerPart 56 62 01 00 get_loc_check 1: matches 59 B5 push_1 1 60 47 get_array_el 61 CA put_loc2 2: integerPart 62 62 01 00 get_loc_check 1: matches 65 B6 push_2 2 66 47 get_array_el 67 CB put_loc3 3: decimalPart 68 62 03 00 get_loc_check 3: decimalPart 71 E9 1D if_false8 101 73 62 03 00 get_loc_check 3: decimalPart 76 42 28 01 00 00 get_field2 replace 81 BE 02 push_const8 2: 1"^\\." 83 BE 03 push_const8 3: 1"\u0000\u0001\u0000\u0014\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0005\u0001.\u0000\u000c\u0000\n" 85 33 regexp 86 04 0E 02 00 00 push_atom_value "0." 91 24 02 00 call_method 2 94 11 dup 95 63 03 00 put_loc_check 3: decimalPart 98 0E drop 99 EB 0B goto8 111 101 04 0F 02 00 00 101: push_atom_value "0.0" 106 11 dup 107 63 03 00 put_loc_check 3: decimalPart 110 0E drop 111 0B 111: object 112 62 02 00 get_loc_check 2: integerPart 115 42 37 00 00 00 get_field2 toString 120 24 00 00 call_method 0 123 4C FE 01 00 00 define_field integerPart 128 62 03 00 get_loc_check 3: decimalPart 131 42 37 00 00 00 get_field2 toString 136 24 00 00 call_method 0 139 4C 00 02 00 00 define_field decimalPart 144 28 return 145 D0 145: get_arg0 0: str 146 28 return */ } /* 17 61 04 00 set_loc_uninitialized 4: unknownVariable 20 6C 23 00 00 00 catch 56 25 D0 get_arg0 0: equationString 26 42 22 01 00 00 get_field2 match 31 BE 02 push_const8 2: 1"[a-zA-Z]+" 33 BE 03 push_const8 3: 1"\u0001\u0001\u0000-\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u001c\u000c\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0002\u0000A\u0000Z\u0000a\u0000z\u0000\n\u000c\u0000\n" 35 33 regexp 36 24 01 00 call_method 1 39 42 EE 00 00 00 get_field2 reduce 44 BF 04 fclosure8 4: [bytecode <null>] 46 26 00 00 array_from 0 49 24 02 00 call_method 2 52 CA put_loc2 2: arr 53 0E drop 54 EB 0B goto8 66 56 CB 56: put_loc3 3: error 57 6C 07 00 00 00 catch 65 62 0E drop 63 EB 02 goto8 66 65 2F 65: throw 66 C6 66: get_loc2 2: arr 67 B4 push_0 0 68 47 get_array_el 69 C2 04 put_loc8 4: unknownVariable 71 C6 get_loc2 2: arr 72 E8 get_length 73 B5 push_1 1 74 AC strict_eq 75 69 67 02 00 00 if_false 691 80 61 0E 00 set_loc_uninitialized 14: guess 83 61 0D 00 set_loc_uninitialized 13: text 86 61 0C 00 set_loc_uninitialized 12: ans 89 61 0B 00 set_loc_uninitialized 11: equationFunction 92 61 0A 00 set_loc_uninitialized 10: rightHandSide 95 61 09 00 set_loc_uninitialized 9: leftHandSide 98 61 08 00 set_loc_uninitialized 8: equation 101 61 07 00 set_loc_uninitialized 7: replacedEquationString 104 61 06 00 set_loc_uninitialized 6: maxIterations 107 61 05 00 set_loc_uninitialized 5: tolerance 110 BE 05 push_const8 5: 1e-08 112 C2 05 put_loc8 5: tolerance 114 BD 10 27 push_i16 10000 117 C2 06 put_loc8 6: maxIterations 119 D0 get_arg0 0: equationString 120 42 28 01 00 00 get_field2 replace 125 BE 06 push_const8 6: 1"(\\d|\\))(\\(|[a-z]|\u03c0|\u5206\u6578)" 127 BE 07 push_const8 7: 1"\u0001\u0003\u0000]\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u000b\u0001\u0009\u000c\u0000\u0000\u0000\u0015\u0001\u00000\u00009\u0000\u0007\u0003\u0000\u0000\u0000\u0001)\u0000\u000c\u0001\u000b\u0002\u0009&\u0000\u0000\u0000\u0009\u0019\u0000\u0000\u0000\u0009\u0008\u0000\u0000\u0000\u0001(\u0000\u0007\u0007\u0000\u0000\u0000\u0015\u0001\u0000a\u0000z\u0000\u0007\u0003\u0000\u0000\u0000\u0001\u00c0\u0003\u0007\u0006\u0000\u0000\u0000\u0001\u0006R\u0001xe\u000c\u0002\u000c\u0000\n" 129 33 regexp 130 04 F3 01 00 00 push_atom_value "$1*$2" 135 24 02 00 call_method 2 138 42 28 01 00 00 get_field2 replace 143 BE 08 push_const8 8: 1"\\^" 145 BE 09 push_const8 9: 1"\u0001\u0001\u0000\u0013\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001^\u0000\u000c\u0000\n" 147 33 regexp 148 04 F4 01 00 00 push_atom_value "**" 153 24 02 00 call_method 2 156 42 28 01 00 00 get_field2 replace 161 BE 0A push_const8 10: 1"\u00d7" 163 BE 0B push_const8 11: 1"\u0001\u0001\u0000\u0013\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u00d7\u0000\u000c\u0000\n" 165 33 regexp 166 04 7C 00 00 00 push_atom_value "*" 171 24 02 00 call_method 2 174 42 28 01 00 00 get_field2 replace 179 BE 0C push_const8 12: 1"\u00f7" 181 BE 0D push_const8 13: 1"\u0001\u0001\u0000\u0013\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u00f7\u0000\u000c\u0000\n" 183 33 regexp 184 04 F5 01 00 00 push_atom_value "/" 189 24 02 00 call_method 2 192 42 28 01 00 00 get_field2 replace 197 BE 0E push_const8 14: 1"\u03c0" 199 BE 0F push_const8 15: 1"\u0001\u0001\u0000\u0013\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u00c0\u0003\u000c\u0000\n" 201 33 regexp 202 04 F6 01 00 00 push_atom_value "3.14" 207 24 02 00 call_method 2 210 42 28 01 00 00 get_field2 replace 215 BE 10 push_const8 16: 1"\\|([^|]+)\\|" 217 BE 11 push_const8 17: 1"\u0001\u0002\u00007\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001|\u0000\u000b\u0001\u001c\u000c\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0002\u0000\u0000\u0000{\u0000}\u0000\u00ff\u00ff\n\u000c\u0001\u0001|\u0000\u000c\u0000\n" 219 33 regexp 220 04 F7 01 00 00 push_atom_value "(Math.abs($1))" 225 24 02 00 call_method 2 228 42 28 01 00 00 get_field2 replace 233 BE 12 push_const8 18: 1"\u221a\\(([^)]+)\\)" 235 BE 13 push_const8 19: 1"\u0001\u0002\u0000:\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u001a\"\u0001(\u0000\u000b\u0001\u001c\u000c\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0002\u0000\u0000\u0000(\u0000*\u0000\u00ff\u00ff\n\u000c\u0001\u0001)\u0000\u000c\u0000\n" 237 33 regexp 238 04 F8 01 00 00 push_atom_value "(Math.sqrt($1))" 243 24 02 00 call_method 2 246 42 28 01 00 00 get_field2 replace 251 BE 14 push_const8 20: 1"\u5206\u6578\\(([^)]+)\\)" 253 BE 15 push_const8 21: 1"\u0001\u0002\u0000=\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0001\u0006R\u0001xe\u0001(\u0000\u000b\u0001\u001c\u000c\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u00ff\u00ff\u00ff\u007f\u0001\u0000\u0000\u0000\u0015\u0002\u0000\u0000\u0000(\u0000*\u0000\u00ff\u00ff\n\u000c\u0001\u0001)\u0000\u000c\u0000\n" 255 33 regexp 256 BF 16 fclosure8 22: [bytecode <null>] 258 24 02 00 call_method 2 261 C2 07 put_loc8 7: replacedEquationString 263 38 A3 01 00 00 get_var console 268 42 A2 01 00 00 get_field2 log 273 62 07 00 get_loc_check 7: replacedEquationString 276 24 01 00 call_method 1 279 0E drop 280 62 07 00 get_loc_check 7: replacedEquationString 283 42 28 01 00 00 get_field2 replace 288 BE 17 push_const8 23: 1"\\s" 290 BE 18 push_const8 24: 1"\u0001\u0001\u0000;\u0000\u0000\u0000\u0008\u0006\u0000\u0000\u0000\u0004\u0007\u00f5\u00ff\u00ff\u00ff\u000b\u0000\u0015\n\u0000\u0009\u0000\u000d\u0000 \u0000 \u0000\u00a0\u0000\u00a0\u0000\u0080\u0016\u0080\u0016\u0000 \n ( ) / / _ _ \u00000\u00000\u00ff\u00fe\u00ff\u00fe\u000c\u0000\n" 292 33 regexp 293 C0 push_empty_string 294 24 02 00 call_method 2 297 C2 08 put_loc8 8: equation 299 62 08 00 get_loc_check 8: equation 302 42 5C 00 00 00 get_field2 split 307 04 F9 01 00 00 push_atom_value "=" 312 24 01 00 call_method 1 315 B4 push_0 0 316 47 get_array_el 317 C2 09 put_loc8 9: leftHandSide 319 62 08 00 get_loc_check 8: equation 322 42 5C 00 00 00 get_field2 split 327 04 F9 01 00 00 push_atom_value "=" 332 24 01 00 call_method 1 335 B5 push_1 1 336 47 get_array_el 337 C2 0A put_loc8 10: rightHandSide 339 38 3A 00 00 00 get_var eval 344 04 DD 01 00 00 push_atom_value "(" 349 42 5B 00 00 00 get_field2 concat 354 62 04 00 get_loc_check 4: unknownVariable 357 04 FA 01 00 00 push_atom_value ") => " 362 62 09 00 get_loc_check 9: leftHandSide 365 04 FB 01 00 00 push_atom_value " - (" 370 62 0A 00 get_loc_check 10: rightHandSide 373 04 DE 01 00 00 push_atom_value ")" 378 24 06 00 call_method 6 381 31 01 00 0F 00 eval 1,15 386 C2 0B put_loc8 11: equationFunction 388 C0 push_empty_string 389 C2 0C put_loc8 12: ans 391 06 undefined 392 C2 0D put_loc8 13: text 394 B5 push_1 1 395 C2 0E put_loc8 14: guess 397 61 0F 00 set_loc_uninitialized 15: i 400 B4 push_0 0 401 C2 0F put_loc8 15: i 403 62 0F 00 403: get_loc_check 15: i 406 62 06 00 get_loc_check 6: maxIterations 409 A4 lt 410 69 F8 00 00 00 if_false 659 415 61 12 00 set_loc_uninitialized 18: df 418 61 10 00 set_loc_uninitialized 16: f 421 62 0B 00 get_loc_check 11: equationFunction 424 62 0E 00 get_loc_check 14: guess 427 EE call1 1 428 C2 10 put_loc8 16: f 430 38 96 00 00 00 get_var Math 435 42 FC 01 00 00 get_field2 abs 440 62 10 00 get_loc_check 16: f 443 24 01 00 call_method 1 446 62 05 00 get_loc_check 5: tolerance 449 A4 lt 450 69 92 00 00 00 if_false 597 455 61 11 00 set_loc_uninitialized 17: parsedNumber 458 C5 get_loc1 1: parseNumber 459 62 0E 00 get_loc_check 14: guess 462 EE call1 1 463 C2 11 put_loc8 17: parsedNumber 465 38 A3 01 00 00 get_var console 470 42 A2 01 00 00 get_field2 log 475 04 FD 01 00 00 push_atom_value "\u00e6\u0095\u00b4\u00e6\u0095\u00b0\u00e9\u0083\u00a8\u00e5\u0088\u0086:" 480 62 11 00 get_loc_check 17: parsedNumber 483 41 FE 01 00 00 get_field integerPart 488 24 02 00 call_method 2 491 0E drop 492 38 A3 01 00 00 get_var console 497 42 A2 01 00 00 get_field2 log 502 04 FF 01 00 00 push_atom_value "\u00e5\u00b0\u008f\u00e6\u0095\u00b0\u00e9\u0083\u00a8\u00e5\u0088\u0086:" 507 62 11 00 get_loc_check 17: parsedNumber 510 41 00 02 00 00 get_field decimalPart 515 42 37 00 00 00 get_field2 toString 520 24 00 00 call_method 0 523 42 26 01 00 00 get_field2 substr 528 B4 push_0 0 529 BC 0A push_i8 10 531 24 02 00 call_method 2 534 24 02 00 call_method 2 537 0E drop 538 38 96 00 00 00 get_var Math 543 42 01 02 00 00 get_field2 round 548 62 0E 00 get_loc_check 14: guess 551 01 80 96 98 00 push_i32 10000000 556 9B mul 557 24 01 00 call_method 1 560 01 80 96 98 00 push_i32 10000000 565 9C div 566 11 dup 567 63 0D 00 put_loc_check 13: text 570 0E drop 571 04 02 02 00 00 push_atom_value "\u00e6\u0096\u00b9\u00e7\u00a8\u008b\u00e7\u009a\u0084\u00e8\u00a7\u00a3\u00e4\u00b8\u00ba\u00ef\u00bc\u009a\n" 576 62 04 00 get_loc_check 4: unknownVariable 579 9E add 580 04 03 02 00 00 push_atom_value " = " 585 9E add 586 62 0D 00 get_loc_check 13: text 589 9E add 590 11 dup 591 63 0C 00 put_loc_check 12: ans 594 0E drop 595 EB 3F goto8 659 597 62 0B 00 597: get_loc_check 11: equationFunction 600 62 0E 00 get_loc_check 14: guess 603 BE 19 push_const8 25: 1e-13 605 9E add 606 EE call1 1 607 62 10 00 get_loc_check 16: f 610 9F sub 611 BE 1A push_const8 26: 1e-13 613 9C div 614 C2 12 put_loc8 18: df 616 62 0E 00 get_loc_check 14: guess 619 62 10 00 get_loc_check 16: f 622 62 12 00 get_loc_check 18: df 625 9C div 626 9F sub 627 11 dup 628 63 0E 00 put_loc_check 14: guess 631 0E drop 632 38 A3 01 00 00 get_var console 637 42 A2 01 00 00 get_field2 log 642 62 0F 00 get_loc_check 15: i 645 92 post_inc 646 63 0F 00 put_loc_check 15: i 649 62 0E 00 get_loc_check 14: guess 652 24 02 00 call_method 2 655 0E drop 656 EC 02 FF goto16 403 659 38 A3 01 00 00 659: get_var console 664 42 A2 01 00 00 get_field2 log 669 62 0C 00 get_loc_check 12: ans 672 24 01 00 call_method 1 675 0E drop 676 62 0C 00 get_loc_check 12: ans 679 E9 05 if_false8 685 681 62 0C 00 get_loc_check 12: ans 684 28 return 685 04 04 02 00 00 685: push_atom_value "\u00e6\u009c\u00aa\u00e8\u0083\u00bd\u00e6\u0089\u00be\u00e5\u0088\u00b0\u00e6\u0096\u00b9\u00e7\u00a8\u008b\u00e7\u009a\u0084\u00e8\u00a7\u00a3" 690 28 return 691 C6 691: get_loc2 2: arr 692 E8 get_length 693 B4 push_0 0 694 AC strict_eq 695 E9 07 if_false8 703 697 04 05 02 00 00 push_atom_value "\u00e6\u00b2\u0092\u00e6\u009c\u0089\u00e6\u009c\u00aa\u00e7\u009f\u00a5\u00e6\u0095\u00b8" 702 28 return 703 04 06 02 00 00 703: push_atom_value "\u00e7\u009b\u00a1\u00e8\u00ab\u008b\u00e6\u009c\u009f\u00e5\u00be\u0085" 708 28 return */ } this.screen.setProperty(hmUI.prop.MORE, { text: solveEquation(this.screenData), }); Error = true; //this.screenData = "方程式的解为:"+ JSON.stringify(result) } catch (e) { this.screen.setProperty(hmUI.prop.MORE, { text: "請先檢査方程式", }); Error = true; } } else { for (let i = 0; i < brDiff; i++) this.screenData += ")"; } if (Error == false) this.updateScreen(); } _countIncl(str, chr) { let c = 0; for (let i in str) if (str[i] === chr) c++; return c; } switchSet() { const newId = (this.currentSetId + 1) % this.buttonSets.length; const newSet = this.buttonSets[newId]; for (let i = 0; i < newSet.length; i++) { this.buttons[i].setProperty(hmUI.prop.TEXT, newSet[i]); } this.currentSetId = newId; this.currentSet = newSet; } initButtonEvents(i) { return () => { if (i == 11) return this.switchSet(); let val = this.currentSet[i]; if (this.operations[val]) val = this.operations[val]; this.appendScreen(val); while (this.currentSetId != 0) this.switchSet(); }; } appendScreen(val) { this.screenData += val; this.updateScreen(); } updateScreen() { this.screen.setProperty(hmUI.prop.MORE, { text: this.screenData, }); } clear() { this.screenData = ""; this.updateScreen(); } backspace() { let delchar = 1 this.screenData = this.screenData.substring(0, this.screenData.length - delchar); this.updateScreen(); } } // source: /home/melianmiko/Projects/mb7_apps/calculator/entrypoint.js let __$$app$$__ = __$$hmAppManager$$__.currentApp; let __$$module$$__ = __$$app$$__.current; __$$module$$__.module = DeviceRuntimeCore.Page({ onInit() { hmUI.setLayerScrolling(false); new Calculator() .start(); }, }); })();
*这是一则由 Google AdSense 自动推荐的广告,与本站无关,不对其真实性与可靠性负责