1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980(* Claude Code
*
* Copyright (C) 2026 Yoann Padioleau
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public License
* (LGPL) as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*)(* See Pcode.mli *)typecsp=Wri|Wrc|Wrb|Wrsofstring|Wln|Rdi|Rdc|Rln|Rnd|Eoltypeinstr=|Ldcofint|Lodofint*int|Ldaofint*int|Strofint*int|Indofint|Sto|Ldmofint|Stmofint|Ixaofint|Incofint|Chkofint*int|Adi|Sbi|Mpi|Dvi|Mod|Ngi|Abi|Sqi|Odd|Equ|Neq|Les|Leq|Grt|Geq|And|Ior|Not|Ujpofint|Fjpofint|Mstofint|Cupofint*int|Entofint|Retp|Retf|Cspofcsp|Stptypevtype=Vint|Vbool|Vchar|Varrayofint*int*vtype|Vrecordof(string*int*vtype)listtypevariable={vname:string;offset:int;vtype:vtype;by_ref:bool;param:bool}typeprocedure={pname:string;level:int;parent:int;first:int;last:int;variables:variablelist}typeprogram={code:instrarray;lines:intarray;statements:intarray;procedures:procedurearray}letmark=4letshow(i:instr):string=letopname=Printf.sprintf"%-4s"nameinmatchiwith|Ldcn->op"ldc"^string_of_intn|Lod(d,o)->op"lod"^Printf.sprintf"%d,%d"do|Lda(d,o)->op"lda"^Printf.sprintf"%d,%d"do|Str(d,o)->op"str"^Printf.sprintf"%d,%d"do|Indo->op"ind"^string_of_into|Sto->"sto"|Ldmn->op"ldm"^string_of_intn|Stmn->op"stm"^string_of_intn|Ixan->op"ixa"^string_of_intn|Incn->op"inc"^string_of_intn|Chk(lo,hi)->op"chk"^Printf.sprintf"%d,%d"lohi|Adi->"adi"|Sbi->"sbi"|Mpi->"mpi"|Dvi->"dvi"|Mod->"mod"|Ngi->"ngi"|Abi->"abi"|Sqi->"sqi"|Odd->"odd"|Equ->"equ"|Neq->"neq"|Les->"les"|Leq->"leq"|Grt->"grt"|Geq->"geq"|And->"and"|Ior->"ior"|Not->"not"|Ujpl->op"ujp"^string_of_intl|Fjpl->op"fjp"^string_of_intl|Mstd->op"mst"^string_of_intd|Cup(n,l)->op"cup"^Printf.sprintf"%d,%d"nl|Entn->op"ent"^string_of_intn|Retp->"retp"|Retf->"retf"|Cspc->(op"csp"^matchcwith|Wri->"wri"|Wrc->"wrc"|Wrb->"wrb"|Wrss->"wrs '"^s^"'"|Wln->"wln"|Rdi->"rdi"|Rdc->"rdc"|Rln->"rln"|Rnd->"rnd"|Eol->"eol")|Stp->"stp"letlisting(p:program):string=String.concat""(Array.to_list(Array.mapi(funai->Printf.sprintf"%4d %-18s ; %d\n"a(showi)p.lines.(a))p.code))