1 # Copyright (C) 2006-2007, The Perl Foundation.
4 ## Control Flow Instructions
11 $I0 = ${NEXTPC} + ${INLINE}
13 ${INS} = concat " goto PC"
23 $I0 = ${NEXTPC} + ${ARG1}
25 ${INS} = concat " goto PC"
35 $I0 = ${NEXTPC} + ${ARG1}
37 ${INS} = concat " goto PC"
47 $I0 = ${PC} - ${INLINE}
49 ${INS} = concat " goto PC"
61 ${INS} = concat " goto PC"
73 ${INS} = concat " goto PC"
84 $I0 = ${NEXTPC} + ${INLINE}
86 ${INS} = concat " ${ITEMP0} = isfalse "
87 ${INS} = concat ${STACK0}
89 ${INS} = concat " if ${ITEMP0} goto PC"
100 $I0 = ${NEXTPC} + ${ARG1}
102 ${INS} = concat " ${ITEMP0} = isfalse "
103 ${INS} = concat ${STACK0}
105 ${INS} = concat " if ${ITEMP0} goto PC"
116 $I0 = ${NEXTPC} + ${ARG1}
118 ${INS} = concat " ${ITEMP0} = isfalse "
119 ${INS} = concat ${STACK0}
121 ${INS} = concat " if ${ITEMP0} goto PC"
132 $I0 = ${PC} - ${ARG1}
134 ${INS} = concat " ${ITEMP0} = isfalse "
135 ${INS} = concat ${STACK0}
137 ${INS} = concat " if ${ITEMP0} goto PC"
148 $I0 = ${PC} - ${ARG1}
150 ${INS} = concat " ${ITEMP0} = isfalse "
151 ${INS} = concat ${STACK0}
153 ${INS} = concat " if ${ITEMP0} goto PC"
158 ## Function Call Instructions
164 nb_arg = script.get_nb_arg(${INLINE})
167 ${INS} = concat ${DEST0}
168 ${INS} = concat " = function"
172 ${INS} = concat ${PARAMS}
173 ${INS} = concat ")\n"
180 nb_arg = script.get_nb_arg(${ARG1})
183 ${INS} = concat ${DEST0}
184 ${INS} = concat " = function"
188 ${INS} = concat ${PARAMS}
189 ${INS} = concat ")\n"
197 nb_arg = get_nb_arg_lib(${ARG1}, ${INLINE})
199 ${INS} = concat " ${PTEMP0} = find_lib("
200 $S0 = ${ARG1} # lindex
205 ${INS} = concat ")\n"
207 ${INS} = concat ${DEST0}
208 ${INS} = concat " = ${PTEMP0}("
209 ${INS} = concat ${PARAMS}
210 ${INS} = concat ")\n"
216 arguments = uint8, uint8
217 nb_arg = get_nb_arg_lib(${ARG2}, ${ARG1})
219 ${INS} = concat " ${PTEMP0} = find_lib("
220 $S0 = ${ARG2} # lindex
223 $S0 = ${ARG1} # findex
225 ${INS} = concat ")\n"
227 ${INS} = concat ${DEST0}
228 ${INS} = concat " = ${PTEMP0}("
229 ${INS} = concat ${PARAMS}
230 ${INS} = concat ")\n"
236 arguments = uint8, uint16
237 nb_arg = get_nb_arg_lib(${ARG2}, ${ARG1})
239 ${INS} = concat " ${PTEMP0} = find_lib("
240 $S0 = ${ARG2} # lindex
243 $S0 = ${ARG1} # findex
245 ${INS} = concat ")\n"
247 ${INS} = concat ${DEST0}
248 ${INS} = concat " = ${PTEMP0}("
249 ${INS} = concat ${PARAMS}
250 ${INS} = concat ")\n"
256 arguments = uint8, uint8, uint8
259 $S0 = ${ARG1} # urlindex
262 ${INS} = concat " ${STEMP1} = "
265 $I0 = exists ${CONST}[$S1]
266 if $I0 goto L6_${CURIC}
267 $S0 = constants.translate(${ARG1})
270 $S0 = ${ARG2} # findex
273 ${INS} = concat " ${STEMP2} = "
276 $I0 = exists ${CONST}[$S1]
277 if $I0 goto L7_${CURIC}
278 $S0 = constants.translate(${ARG2})
281 ${INS} = concat " ${PTEMP0} = find_lib_url(${STEMP1}, ${STEMP2})\n"
283 ${INS} = concat ${DEST0}
284 ${INS} = concat " = ${PTEMP0}("
285 ${INS} = concat ${PARAMS}
286 ${INS} = concat ")\n"
292 arguments = uint16, uint16, uint8
295 $S0 = ${ARG1} # urlindex
298 ${INS} = concat " ${STEMP1} = "
301 $I0 = exists ${CONST}[$S1]
302 if $I0 goto L6_${CURIC}
303 $S0 = constants.translate(${ARG1})
306 $S0 = ${ARG2} # findex
309 ${INS} = concat " ${STEMP2} = "
312 $I0 = exists ${CONST}[$S1]
313 if $I0 goto L7_${CURIC}
314 $S0 = constants.translate(${ARG2})
317 ${INS} = concat " ${PTEMP0} = find_lib_url(${STEMP1}, ${STEMP2})\n"
319 ${INS} = concat ${DEST0}
320 ${INS} = concat " = ${PTEMP0}("
321 ${INS} = concat ${PARAMS}
322 ${INS} = concat ")\n"
325 ## Variable Access and Manipulation
335 ${INS} = concat ${DEST0}
336 ${INS} = concat " = clone local"
349 ${INS} = concat ${DEST0}
350 ${INS} = concat " = clone local"
362 ${STOREREG} = "local"
363 ${STOREREG} = concat $S0
373 ${STOREREG} = "local"
374 ${STOREREG} = concat $S0
383 ${INS} = concat " inc local"
394 ${INS} = concat " inc local"
405 ${INS} = concat " dec local"
410 ## Access To Constants
422 ${INS} = concat ${DEST0}
423 ${INS} = concat " = clone "
426 $I0 = exists ${CONST}[$S1]
427 if $I0 goto L1_${CURIC}
428 $S0 = constants.translate(${INLINE})
443 ${INS} = concat ${DEST0}
444 ${INS} = concat " = clone "
447 $I0 = exists ${CONST}[$S1]
448 if $I0 goto L1_${CURIC}
449 $S0 = constants.translate(${ARG1})
464 ${INS} = concat ${DEST0}
465 ${INS} = concat " = clone "
468 $I0 = exists ${CONST}[$S1]
469 if $I0 goto L1_${CURIC}
470 $S0 = constants.translate(${ARG1})
481 ${INS} = concat ${DEST0}
482 ${INS} = concat " = clone const_0\n"
483 $I0 = exists ${CONST}['const_0']
484 if $I0 goto L1_${CURIC}
485 $S0 = " .local pmc const_0\n new const_0, 'WmlsInteger'\n set const_0, 0\n"
486 ${CONST}['const_0'] = $S0
496 ${INS} = concat ${DEST0}
497 ${INS} = concat " = clone const_1\n"
498 $I0 = exists ${CONST}['const_1']
499 if $I0 goto L1_${CURIC}
500 $S0 = " .local pmc const_1\n new const_1, 'WmlsInteger'\n set const_1, 1\n"
501 ${CONST}['const_1'] = $S0
511 ${INS} = concat ${DEST0}
512 ${INS} = concat " = clone const_m1\n"
513 $I0 = exists ${CONST}['const_m1']
514 if $I0 goto L1_${CURIC}
515 $S0 = " .local pmc const_m1\n new const_m1, 'WmlsInteger'\n set const_m1, -1\n"
516 ${CONST}['const_m1'] = $S0
526 ${INS} = concat ${DEST0}
527 ${INS} = concat " = clone const_es\n"
528 $I0 = exists ${CONST}['const_es']
529 if $I0 goto L1_${CURIC}
530 $S0 = " .local pmc const_es\n new const_es, 'WmlsString'\n"
531 ${CONST}['const_es'] = $S0
541 ${INS} = concat ${DEST0}
542 ${INS} = concat " = clone const_invalid\n"
543 $I0 = exists ${CONST}['const_invalid']
544 if $I0 goto L1_${CURIC}
545 $S0 = " .local pmc const_invalid\n new const_invalid, 'WmlsInvalid'\n"
546 ${CONST}['const_invalid'] = $S0
556 ${INS} = concat ${DEST0}
557 ${INS} = concat " = clone const_true\n"
558 $I0 = exists ${CONST}['const_true']
559 if $I0 goto L1_${CURIC}
560 $S0 = " .local pmc const_true\n new const_true, 'WmlsBoolean'\n set const_true, 1\n"
561 ${CONST}['const_true'] = $S0
571 ${INS} = concat ${DEST0}
572 ${INS} = concat " = clone const_false\n"
573 $I0 = exists ${CONST}['const_false']
574 if $I0 goto L1_${CURIC}
575 $S0 = " .local pmc const_false\n new const_false, 'WmlsBoolean'\n set const_false, 0\n"
576 ${CONST}['const_false'] = $S0
580 ## Arithmetic Instructions
588 ${INS} = concat " ${PTEMP0} = "
589 ${INS} = concat ${STACK0}
591 ${INS} = concat " inc ${PTEMP0}\n"
593 ${INS} = concat ${DEST0}
594 ${INS} = concat " = ${PTEMP0}\n"
603 ${INS} = concat " ${PTEMP0} = "
604 ${INS} = concat ${STACK0}
606 ${INS} = concat " dec ${PTEMP0}\n"
608 ${INS} = concat ${DEST0}
609 ${INS} = concat " = ${PTEMP0}\n"
619 ${INS} = concat " local"
621 ${INS} = concat " = add local"
624 ${INS} = concat ${STACK0}
635 ${INS} = concat " local"
637 ${INS} = concat " = sub local"
640 ${INS} = concat ${STACK0}
649 instruction = ${DEST0} = neg ${STACK0}
656 instruction = ${DEST0} = add ${STACK1}, ${STACK0}
663 instruction = ${DEST0} = sub ${STACK1}, ${STACK0}
670 instruction = ${DEST0} = mul ${STACK1}, ${STACK0}
677 instruction = ${DEST0} = div ${STACK1}, ${STACK0}
684 instruction = ${DEST0} = fdiv ${STACK1}, ${STACK0}
691 instruction = ${DEST0} = cmod ${STACK1}, ${STACK0}
693 ## Bitwise Instructions
700 instruction = ${DEST0} = band ${STACK1}, ${STACK0}
707 instruction = ${DEST0} = bor ${STACK1}, ${STACK0}
714 instruction = ${DEST0} = bxor ${STACK1}, ${STACK0}
721 instruction = ${DEST0} = bnot ${STACK0}
728 instruction = ${DEST0} = shl ${STACK1}, ${STACK0}
735 instruction = ${DEST0} = shr ${STACK1}, ${STACK0}
742 instruction = ${DEST0} = lsr ${STACK1}, ${STACK0}
744 ## Comparison Instructions
751 instruction = ${DEST0} = iseq ${STACK1}, ${STACK0}
758 instruction = ${DEST0} = isle ${STACK1}, ${STACK0}
765 instruction = ${DEST0} = islt ${STACK1}, ${STACK0}
772 instruction = ${DEST0} = isge ${STACK1}, ${STACK0}
779 instruction = ${DEST0} = isgt ${STACK1}, ${STACK0}
786 instruction = ${DEST0} = isne ${STACK1}, ${STACK0}
788 ## Logical Instructions
795 instruction = ${DEST0} = not ${STACK0}
805 ${INS} = concat " ${PTEMP0} = istrue "
806 ${INS} = concat ${STACK0}
808 ${INS} = concat " ${ITEMP0} = isa ${PTEMP0}, 'WmlsBoolean'\n"
809 ${INS} = concat " unless ${ITEMP0} goto PC"
811 ${INS} = concat "_A\n"
812 ${INS} = concat " ${ITEMP0} = istrue ${PTEMP0}\n"
813 ${INS} = concat " if ${ITEMP0} goto PC"
815 ${INS} = concat "_B\n"
818 ${INS} = concat "_A:\n"
820 ${INS} = concat ${DEST0}
821 ${INS} = concat " = clone ${PTEMP0}\n"
823 ${INS} = concat ${DEST1}
824 ${INS} = concat " = clone const_false\n"
826 ${INS} = concat "goto PC"
828 ${INS} = concat "_C\n"
831 ${INS} = concat "_B:\n"
833 ${INS} = concat ${DEST0}
834 ${INS} = concat " = clone const_true\n"
838 ${INS} = concat "_C:\n"
839 $I0 = exists ${CONST}['const_true']
840 if $I0 goto L1_${CURIC}
841 $S0 = " .local pmc const_true\n new const_true, 'WmlsBoolean'\n set const_true, 1\n"
842 ${CONST}['const_true'] = $S0
844 $I0 = exists ${CONST}['const_false']
845 if $I0 goto L2_${CURIC}
846 $S0 = " .local pmc const_false\n new const_false, 'WmlsBoolean'\n set const_false, 0\n"
847 ${CONST}['const_false'] = $S0
859 ${INS} = concat " ${PTEMP0} = istrue "
860 ${INS} = concat ${STACK0}
862 ${INS} = concat " ${ITEMP0} = isa ${PTEMP0}, 'WmlsBoolean'\n"
863 ${INS} = concat " unless ${ITEMP0} goto PC"
865 ${INS} = concat "_A\n"
866 ${INS} = concat " ${ITEMP0} = isfalse ${PTEMP0}\n"
867 ${INS} = concat " if ${ITEMP0} goto PC"
869 ${INS} = concat "_B\n"
872 ${INS} = concat "_A:\n"
874 ${INS} = concat ${DEST0}
875 ${INS} = concat " = clone ${PTEMP0}\n"
877 ${INS} = concat ${DEST1}
878 ${INS} = concat " = clone const_false\n"
880 ${INS} = concat "goto PC"
882 ${INS} = concat "_C\n"
885 ${INS} = concat "_B:\n"
887 ${INS} = concat ${DEST0}
888 ${INS} = concat " = clone const_true\n"
892 ${INS} = concat "_C:\n"
893 $I0 = exists ${CONST}['const_true']
894 if $I0 goto L1_${CURIC}
895 $S0 = " .local pmc const_true\n new const_true, 'WmlsBoolean'\n set const_true, 1\n"
896 ${CONST}['const_true'] = $S0
898 $I0 = exists ${CONST}['const_false']
899 if $I0 goto L2_${CURIC}
900 $S0 = " .local pmc const_false\n new const_false, 'WmlsBoolean'\n set const_false, 0\n"
901 ${CONST}['const_false'] = $S0
910 instruction = ${DEST0} = istrue ${STACK0}
912 ## Stack Instructions
918 instruction = # just pop
920 ## Access to Operand Type
927 instruction = ${DEST0} = typeof ${STACK0}
934 instruction = ${DEST0} = defined ${STACK0}
936 ## Function Return Instructions
943 ${INS} = concat " .return ("
944 ${INS} = concat ${STACK0}
945 ${INS} = concat ")\n"
952 ${INS} = concat " new ${PTEMP0}, 'WmlsString'\n"
953 ${INS} = concat " .return (${PTEMP0})\n"
956 ## Miscellaneous Instructions
961 instruction = # debug op