-
Notifications
You must be signed in to change notification settings - Fork 20
/
vm_enter.js
974 lines (893 loc) · 31.9 KB
/
vm_enter.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
var {JSDOM} = require("jsdom");
var {window} = new JSDOM(`
<!doctype html>
<html>
<body>
<head>
<div style="">
<meta content="">
<meta>
</div>
<div>
bobo1
</div>
<div>
bobo2
</div>
</head>
</body>
</html>
`);
global["window"] = window;
fs = require("fs");
zcj_console = console.log;
console.log = function () {
try{
if (arguments[0] === ">>" && arguments[1] == 77 && arguments[2] == 49) {
debugger
}
}
catch (e){
}
return zcj_console.apply(undefined, arguments);
}
var OPCODE = {
PASS: 11, // 这是个无用字节码,不作任何操作
PUSH_NUM: 12,
PUSH_STR: 13,
PUSH_NULL: 14,
PUSH_UNDEFINED: 15,
PUSH_WINDOW: 65, // 主要是this可能是构造器,导致这个this不是window了.
PUSH_VAR: 66, // 将变量池里的变量压入栈
MOV_VAR: 67, // 对变量进行赋值
PUSH_THIS: 68, // push this => 泛指window
PUSH_CONSTANT: 69, // push 变量池
GET_OBJ: 51, // window.console , 获取对象下的属性/对象 ; 数组也是对象,同理;
SET_OBJ: 52, // window.console = xxx ; 数组也是对象,同理;
APPLY: 53, // 方法调用
COMPUTE: 54, // 运算,两个参数
SINGLE_COMPUTE: 55, // 运算,单个参数
UPDATE: 56, // a++ ++a --a a--
NEW_ARRAY: 30, //创建一个空的数组
NEW_OBJECT: 31, //创建一个空对象
NEW_FUNC: 32, // 创建一个function
NEW_CONSTRUCT: 33, // new 一个构造体
UPDATE_STACK: 20,
DECREMENT_STACK: 21,
TRY: 40,
CATCH: 41,
TRUE: 42,
FALSE: 43,
THROW: 44,
CATCH_OVER: 45,
DELETE: 46,
DEBUG: 47,
FORIN: 48,
RETURN: 88,
IS_TRUE: 89,
SKIP_BLOCK: 90,
GOTO: 91, // 跳转到循环头位置
BREAK: 92, // break, 正常的思路应该是break出一段代码的.
CONTINUE: 93, // continue
'*': 1000,
'/': 1001,
'%': 1002,
'+': 1003,
'-': 1004,
'<<': 1005,
'>>': 1006,
'>>>': 1007,
'>': 1008,
'<': 1009,
'>=': 1010,
'<=': 1011,
'==': 1012,
'===': 1013,
'!==': 1014,
'!=': 1015,
'&': 1016,
'^': 1017,
'|': 1018,
'=': 1019,
'*=': 1020,
'/=': 1021,
'%=': 1022,
'&=': 1023,
'+=': 1024,
'-=': 1025,
'<<=': 1026,
'>>=': 1027,
'^=': 1028,
'|=': 1029,
'in': 1030,
'instanceof': 1031,
}
var OPCODE1 = {
'!': 1032,
'+': 1033,
'-': 1034,
'~': 1035,
'typeof': 1036,
'void': 1037,
};
(function (constant) {
function vm_enter(opcode, index, constant, stack, esp, obj_arr) {
function vm_opcodeToString(e, s) {
var a = String["fromCharCode"], b = [];
for (m = 0; m < e.length; m++) {
b[m] = a["apply"](String, [e[m]]);
}
return s = b.join('');
}
function vm_push(e, s) {
return vm_stack[vm_stack.vm_esp++] = e, s;
}
function vm_push_2(e, s) {
return vm_stack[vm_stack.vm_esp] = e, vm_stack.vm_esp++, s;
}
function vm_push_fake_3(e, s) {
return vm_stack[++vm_stack.vm_esp] = e, vm_stack.vm_esp--, s;
}
function vm_push_fake_2(e, s) {
return s = vm_stack[vm_stack.vm_esp], vm_stack[vm_stack.vm_esp++] = s, vm_stack.vm_esp--, e;
}
function vm_push_fake_1(e, s) {
return vm_stack[vm_stack.vm_esp + 1] = e, s;
}
function vm_update_stack(e, s) {
return vm_stack.vm_esp++, s;
}
function vm_decrement_stack(e, s) {
return vm_stack.vm_esp--, s;
}
function vm_slice() {
var result;
// 字符串长度
h = vm_get_opcode();
// result = opcode.slice(index, index + h).split("").map((opc) => {
// return opc.charCodeAt() - 32
// });
result = opcode.slice(index, index + h);
// result = op_slice(this, index, index + h);
index += h;
return result;
}
function vm_stack_slice(s, e) {
// return vm_stack.splice(s, e);
return stack_splice(this, s, e);
}
function vm_get_value() {
if (vm_stack.vm_esp == 0){debugger;}
return vm_stack[--vm_stack.vm_esp];
}
function vm_get_value_fake() {
return vm_stack[vm_stack.vm_esp - 1];
}
function vm_get_opcode() {
return opcode[index++];
}
function vmExpression_single_calc(symbol, opNum1) {
switch (symbol) {
case "!":
return !opNum1
case "+":
return +opNum1
case "-":
return -opNum1
case "~":
return ~opNum1
case "typeof":
return typeof opNum1;
case "void":
return void opNum1;
default:
// debugger;
console.log("vmExpression_single_calc 没有这个 symbol =>", symbol);
return undefined
}
}
function vmExpression_calc(symbol, opNum2, opNum1) {
switch (symbol) {
case "*":
return opNum1 * opNum2
case "/":
return opNum1 / opNum2
case "%":
return opNum1 % opNum2
case "+":
return opNum1 + opNum2
case "-":
return opNum1 - opNum2
case "<<":
return opNum1 << opNum2
case ">>":
return opNum1 >> opNum2
case ">>>":
return opNum1 >>> opNum2
case ">":
return opNum1 > opNum2
case "<":
return opNum1 < opNum2
case ">=":
return opNum1 >= opNum2
case "<=":
return opNum1 <= opNum2
case "==":
return opNum1 == opNum2
case "===":
return opNum1 === opNum2
case "!==":
return opNum1 !== opNum2
case "!=":
return opNum1 != opNum2
case "&":
return opNum1 & opNum2
case "^":
return opNum1 ^ opNum2
case "|":
return opNum1 | opNum2
case "&&":
return opNum1 && opNum2
case "||":
return opNum1 || opNum2
case "=":
return opNum1 = opNum2
case "*=":
return opNum1 *= opNum2
case "/=":
return opNum1 /= opNum2
case "%=":
return opNum1 %= opNum2
case "&=":
return opNum1 &= opNum2
case "+=":
return opNum1 += opNum2
case "-=":
return opNum1 -= opNum2
case "<<=":
return opNum1 <<= opNum2
case ">>=":
return opNum1 >>= opNum2
case "^=":
return opNum1 ^= opNum2
case "|=":
return opNum1 |= opNum2
case "in":
return opNum1 in opNum2
case "instanceof":
return opNum1 instanceof opNum2
default:
console.log("vmExpression_calc 没有这个 symbol =>", symbol)
return undefined
}
}
function vm_call(s, e, p, args, constant) {
var i;
if (!p_constant) var p_constant = {};
for (i = 0; i < p.length; i++) {
p_constant[p[i]] = args[i];
}
Object.setPrototypeOf(p_constant, constant);
p_constant["arguments"] = args;
// 通过args把需要的参数放到当前常量池中去,然后开始调用
h = vm_enter.apply(this, [opcode.slice(s, e), 0, p_constant, [], 0, []]);
if (Array.isArray(h)){
h = h[1]
}
else return;
return h;
}
var is_console = false;
var vm_stack, h, y, d, g, m, cz, zc,
hj, jk, lk, ik,
vm_constant = constant, stack_splice, op_slice;
for (var i in obj_arr) {
vm_constant[obj_arr[i]] = this["window"][obj_arr[i]];
}
let get_key = (object, value) => {
return Object.keys(object).find(key => object[key] === value)
};
vm_stack = !stack ? [] : stack;
vm_stack.vm_esp = esp;
cz = [];
zc = cz.splice;
stack_splice = zc.bind(vm_stack).call.bind(zc.bind(vm_stack));
op_slice = zc.bind(opcode).call.bind(zc.bind(opcode));
for (; ;) {
// g = vm_get_opcode();
g = opcode[index++];
// console.log(g, index);
// console.log(g, "对应的指令 =>", get_key(OPCODE, g), " , 下一条指令 =>", opcode[index] , " index => " , index - 1);
// if (!get_key(OPCODE, g)) {
// debugger
// }
// console.log(get_key(OPCODE, g));
// g = opcode[index++];
// if (vm_stack.vm_esp === -1) {
// console.log("堆栈索引都到-1了!!gg");
// debugger;
// }
if (Number.isNaN(g) || !g) {
break
}
switch (g) {
case OPCODE.PUSH_WINDOW:
vm_push(window);
break
case OPCODE.PUSH_STR:
h = vm_opcodeToString.apply(undefined, [vm_slice()]);
vm_push(h);
// if (is_console) {
// console.log("push 字符串 => ", h);
// }
break
case OPCODE.PUSH_NUM:
h = vm_get_opcode();
vm_push(h);
break
case OPCODE.PUSH_NULL:
vm_push(null);
break
case OPCODE.PUSH_UNDEFINED:
vm_push(void 0);
break
case OPCODE.PUSH_CONSTANT:
vm_push(vm_constant);
break
case OPCODE.PUSH_THIS:
vm_push(this);
break
case OPCODE.PUSH_VAR:
d = vm_get_value();
y = vm_get_value();
// console.log("push key => ", y);
if (d === undefined || y === undefined || d[y] === undefined) {
vm_push(undefined);
// console.log(" 对象 => ", !!d && d.toString(), " key => ", y)
break;
}
if (d === vm_constant && !d.hasOwnProperty(y)) {
h = d.__proto__;
while (h != null) {
if (h.hasOwnProperty(y)) {
d = h;
break
}
h = h.__proto__;
}
}
vm_push(d[y]);
if (is_console) {
console.log("push 对象 => ", d[y].toString(), "对象 => ", d.toString(), " key => ", y);
}
break
case OPCODE.MOV_VAR:
/* 变量池或者其他的 */
d = vm_get_value();
/* key */
y = vm_get_value();
if (d === vm_constant && !d.hasOwnProperty(y)) {
h = d.__proto__;
while (h != null) {
if (h.hasOwnProperty(y)) {
d = h;
break
}
h = h.__proto__;
}
}
/* value */
h = vm_get_value();
d[y] = h;
break
case OPCODE.COMPUTE:
/* d是第二个 */
d = vm_get_value();
/* y是第一个 */
y = vm_get_value();
/* symbol */
h = vm_get_value();
vm_push(vmExpression_calc(h, d, y));
break
case OPCODE.SINGLE_COMPUTE:
/* 这里有二个值, 堆栈里的值,一个是标识符 */
d = vm_get_value();
/* symbol */
y = vm_get_value();
vm_push(vmExpression_single_calc(y, d));
break
case OPCODE.UPDATE:
/* 这里有二个值, 对象, key 最后是标识符 */
/* 对象 */
d = vm_get_value();
/* key */
h = vm_get_value();
/* symbol */
y = vm_get_value();
switch (y) {
case "++":
d[h]++;
break
case "--":
d[h]--;
break
}
break
case OPCODE.NEW_ARRAY:
/* new 一个 array 后面跟的是初始化的对象个数 */
y = vm_get_opcode();
// d = Array();
// for (var i = 0; i < y; i++) {
// d[y - i - 1] = vm_get_value();
// }
d = vm_stack_slice(vm_stack.vm_esp - y, y);
vm_stack.vm_esp = vm_stack.vm_esp - y;
vm_push(d);
break
case OPCODE.GET_OBJ:
/* 对象, key, 将值压入堆栈 */
y = vm_get_value();
d = vm_get_value();
h = y[d];
// h = vm_get_value()[vm_get_value()];
if (is_console) {
try {
console.log("GET_OBJ => ", d[y].toString(), "对象 => ", d.toString(), " key => ", y);
} catch (e) {
// debugger;
}
}
vm_push(h);
break;
case OPCODE.SET_OBJ:
/* 对象,key,进行赋值 */
y = vm_get_value();
d = vm_get_value();
h = vm_get_value();
y[d] = h;
// if (is_console) {
// console.log("SET_OBJ => ", d[y].toString(), "对象 => ", d.toString(), " key => ", y);
// }
/* 这样更具迷惑性 */
// vm_get_value()[vm_get_value()] = vm_get_value();
break
case OPCODE.NEW_OBJECT:
y = {};
d = vm_get_opcode();
for (var i = 0; i < d; i++) {
m = vm_get_value();
h = vm_get_value();
y[h] = m;
}
vm_stack_slice(vm_stack.vm_esp, vm_stack.length - 1);
vm_push(y);
break
case OPCODE.APPLY:
/* 定义在window下的方法,this是window,那在构造方法下呢? */
/* 调用者 */
y = vm_get_value();
/* 自定义方法 */
h = vm_get_value();
/* 传参 */
d = vm_get_value();
if (h === undefined) {
debugger
break
}
if (!!h.aaa) {
/* 这里this还没判断啊~ 很烦 */
d = h.apply(y, d);
} else {
/* 方法 */
if (h.name === "toString") {
/* toString(16) */
if (d.length > 1) {
console.log("toString 传参超过2个 ~~");
} else {
d = y.toString(d[0]);
}
} else if (h === undefined) {
/* 调用者为空 有bug 有bug */
// console.log("调用者为空 有bug!!!")
// debugger;
break;
} else {
d = h.apply(y, d);
}
}
/* 方法调用管你要不要值,我都直接push到堆栈里呢 */
vm_push(d);
break
case OPCODE.NEW_FUNC:
y = vm_get_opcode();
d = index;
index += y;
vm_push(function () {
return zzz.aaa = d,
zzz.bbb = index,
zzz.ccc = vm_stack[--vm_stack.vm_esp],
zzz;
function zzz() {
h = vm_call.apply(this, [zzz.aaa, zzz.bbb, zzz.ccc, arguments, vm_constant]);
return h;
}
}
());
break
case OPCODE.IS_TRUE:
y = vm_get_value();
if (!!y) {
index++;
} else {
d = vm_get_opcode();
index += d;
}
break
case OPCODE.SKIP_BLOCK:
y = vm_get_opcode();
index += y;
break
case OPCODE.GOTO:
/* 这里可能会有问题 */
index -= vm_get_opcode();
break
case OPCODE.NEW_CONSTRUCT:
/* 传参 */
d = vm_get_value();
/* 调用者/自定义方法 */
y = vm_get_value();
h = new y(...d);
vm_push(h);
// try {
// vm_push(new y(...d));
// } catch (e) {
// console.log("new 出霸哥~");
// debugger;
// // throw "new 出霸哥~"
// }
break
case OPCODE.BREAK:
y = vm_get_opcode();
index += y;
if (index > opcode.length) {
// console.log("break 超出当前opcode字节码数组长度~ return 上一层");
return [OPCODE.BREAK, y];
}
break
case OPCODE.CONTINUE:
y = vm_get_opcode();
index -= y;
if (index < 0 || index > opcode.length) {
// console.log("continue 超出当前opcode字节码数组长度~ return 上一层");
return [OPCODE.CONTINUE, y];
}
break
case OPCODE.PASS:
break
case OPCODE.TRUE:
h = void 0;
y = !h;
vm_push(y);
break
case OPCODE.FALSE:
m = void 0;
d = !!m;
vm_push(d);
break
case OPCODE.THROW:
throw vm_get_value();
case OPCODE.TRY:
try {
/* 现在的索引 */
d = index;
/* try opcode */
y = vm_slice();
d += y.length + 1;
h = vm_enter.apply(this, [y, 0, vm_constant, vm_stack, vm_stack.vm_esp, []]);
if (Array.isArray(h)) {
d = h[0] , y = h[1];
/* 这里多了2 try + slice 导致的index+2 */
switch (d) {
case OPCODE.BREAK:
index += y;
if (index > opcode.length) {
// console.log("try break 超出当前opcode字节码数组长度~ return 上一层");
return [OPCODE.BREAK, y];
}
break
case OPCODE.CONTINUE:
index -= y;
if (index < 0 || index > opcode.length) {
// console.log("try continue 超出当前opcode字节码数组长度~ return 上一层");
return [OPCODE.CONTINUE, y];
}
break
default:
// console.log("try 非BREAK CONTINUE 指令返回 => return ", h);
return h;
}
}
} catch (e) {
vm_push(e);
index = d + 2;
}
break
case OPCODE.FORIN:
d = vm_get_value();
zc = vm_slice();
for (cz in d) {
vm_push(cz);
h = vm_enter.apply(this, [zc, 0, vm_constant, vm_stack, vm_stack.vm_esp, []]);
if (Array.isArray(h)) {
m = h[0] , y = h[1];
/* 这里多了2 try + slice 导致的index+2 */
switch (m) {
case OPCODE.BREAK:
break
case OPCODE.CONTINUE:
continue;
default:
console.log("try 非BREAK CONTINUE 指令返回 => return ", h);
return h;
}
}
}
break
case OPCODE.UPDATE_STACK:
/* 把之前的值拿下来 */
vm_stack.vm_esp++;
break
case OPCODE.DECREMENT_STACK:
vm_stack.vm_esp--;
break
case OPCODE.DELETE:
d = vm_get_value();
h = vm_get_value();
delete h[d];
// delete h[d];
break
case OPCODE.RETURN:
y = vm_get_value();
return [0, y];
case OPCODE.DEBUG:
debugger;
break
case OPCODE["*"]:
d = vm_get_value();
h = vm_get_value();
y = h * d;
vm_push(y);
break;
case OPCODE["/"]:
d = vm_get_value();
h = vm_get_value();
y = h / d;
vm_push(y);
break;
case OPCODE["%"]:
d = vm_get_value();
h = vm_get_value();
y = h % d;
vm_push(y);
break;
case OPCODE["+"]:
d = vm_get_value();
h = vm_get_value();
y = h + d;
vm_push(y);
break;
case OPCODE["-"]:
d = vm_get_value();
h = vm_get_value();
y = h - d;
vm_push(y);
break;
case OPCODE["<<"]:
d = vm_get_value();
h = vm_get_value();
y = h << d;
vm_push(y);
break;
case OPCODE[">>"]:
d = vm_get_value();
h = vm_get_value();
y = h >> d;
vm_push(y);
break;
case OPCODE[">>>"]:
d = vm_get_value();
h = vm_get_value();
y = h >>> d;
vm_push(y);
break;
case OPCODE[">"]:
d = vm_get_value();
h = vm_get_value();
y = h > d;
vm_push(y);
break;
case OPCODE["<"]:
d = vm_get_value();
h = vm_get_value();
y = h < d;
vm_push(y);
break;
case OPCODE[">="]:
d = vm_get_value();
h = vm_get_value();
y = h >= d;
vm_push(y);
break;
case OPCODE["<="]:
d = vm_get_value();
h = vm_get_value();
y = h <= d;
vm_push(y);
break;
case OPCODE["=="]:
d = vm_get_value();
h = vm_get_value();
y = h == d;
vm_push(y);
break;
case OPCODE["==="]:
d = vm_get_value();
h = vm_get_value();
y = h === d;
vm_push(y);
break;
case OPCODE["!=="]:
d = vm_get_value();
h = vm_get_value();
y = h !== d;
vm_push(y);
break;
case OPCODE["!="]:
d = vm_get_value();
h = vm_get_value();
y = h != d;
vm_push(y);
break;
case OPCODE["&"]:
d = vm_get_value();
h = vm_get_value();
y = h & d;
vm_push(y);
break;
case OPCODE["^"]:
d = vm_get_value();
h = vm_get_value();
y = h ^ d;
vm_push(y);
break;
case OPCODE["|"]:
d = vm_get_value();
h = vm_get_value();
y = h | d;
vm_push(y);
break;
case OPCODE["="]:
d = vm_get_value();
h = vm_get_value();
y = h = d;
vm_push(y);
break;
case OPCODE["*="]:
d = vm_get_value();
h = vm_get_value();
y = h *= d;
vm_push(y);
break;
case OPCODE["/="]:
d = vm_get_value();
h = vm_get_value();
y = h /= d;
vm_push(y);
break;
case OPCODE["%="]:
d = vm_get_value();
h = vm_get_value();
y = h %= d;
vm_push(y);
break;
case OPCODE["&="]:
d = vm_get_value();
h = vm_get_value();
y = h &= d;
vm_push(y);
break;
case OPCODE["+="]:
d = vm_get_value();
h = vm_get_value();
y = h += d;
vm_push(y);
break;
case OPCODE["-="]:
d = vm_get_value();
h = vm_get_value();
y = h -= d;
vm_push(y);
break;
case OPCODE["<<="]:
d = vm_get_value();
h = vm_get_value();
y = h <<= d;
vm_push(y);
break;
case OPCODE[">>="]:
d = vm_get_value();
h = vm_get_value();
y = h >>= d;
vm_push(y);
break;
case OPCODE["^="]:
d = vm_get_value();
h = vm_get_value();
y = h ^= d;
vm_push(y);
break;
case OPCODE["|="]:
d = vm_get_value();
h = vm_get_value();
y = h |= d;
vm_push(y);
break;
case OPCODE["in"]:
d = vm_get_value();
h = vm_get_value();
y = h in d;
vm_push(y);
break;
case OPCODE["instanceof"]:
d = vm_get_value();
h = vm_get_value();
y = h instanceof d;
vm_push(y);
break;
case OPCODE1["!"]:
d = vm_get_value();
h = vm_get_value_fake();
y = !d;
vm_push(y);
break;
case OPCODE1["+"]:
d = vm_get_value();
h = vm_get_value_fake();
y = +d
vm_push(y);
break;
case OPCODE1["-"]:
d = vm_get_value();
h = vm_get_value_fake();
y = -d;
vm_push(y);
break;
case OPCODE1["~"]:
d = vm_get_value();
h = vm_get_value_fake();
y = ~d
vm_push(y);
break;
case OPCODE1["typeof"]:
d = vm_get_value();
h = vm_get_value_fake();
y = typeof d;
vm_push(y);
break;
case OPCODE1["void"]:
d = vm_get_value();
h = vm_get_value_fake();
y = void d;
vm_push(y);
break;
default:
console.log("index => ", index, "opcode => err => ", g);
debugger;
}
}
}
var opcode = eval(fs.readFileSync("./opcode.txt") + '')
/* collect 存放for循环test 后 IS_TRUE的索引 */
vm_enter(opcode, 0, constant, void 0, 0, ['window']);
}).apply(window, [constant = {"$_jsvmp": true}])
// console.log(window.md5(''))