5 * Created by Bryan Donlan on Wed 07 Dec 2005.
6 * Copyright (c) 2005 Bryan Donlan. All rights reserved.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
22 #include <boost/format.hpp>
27 const char *cnams
[] = {
38 static std::string
try_lookup(const Dialect
*d
, int idx
) {
40 return std::string(d
->getcmd(idx
)->fullname
);
41 return str(format("%d") % idx
);
44 std::string
dumpOp(const Dialect
*d
, caosOp op
) {
45 int arg
= op
.argument
; // weird C++ issues
48 return std::string("NOP");
50 return str(format("DIE %d") % arg
);
52 return std::string("STOP");
54 return str(format("CMD %s") % try_lookup(d
, arg
));
56 return str(format("COND %s %s") % (arg
& CAND
? "AND" : "OR") % cnams
[arg
& CMASK
]);
58 return str(format("CONST %d") % arg
);
60 return str(format("CONSTINT %d") % arg
);
62 return str(format("BYTESTR %d") % arg
);
64 return str(format("PUSH AUX %d") % arg
);
65 case CAOS_RESTORE_AUX
:
66 return str(format("RESTORE AUX %d") % arg
);
68 return str(format("CMD SAVE %s") % try_lookup(d
, arg
));
70 return str(format("YIELD %d") % arg
);
72 return str(format("STACK ROT %d") % arg
);
75 return str(format("CJMP %08d") % arg
);
77 return str(format("JMP %08d") % arg
);
79 return str(format("DECJNZ %08d") % arg
);
81 return str(format("GSUB %08d") % arg
);
83 return str(format("ENUMPOP %08d") % arg
);
85 return str(format("UNKNOWN %02x %06x") % arg
);