mirror of
https://github.com/CPunch/Cosmo.git
synced 2026-02-07 19:20:05 +00:00
Major refactoring, added classes, many bug fixes
This commit is contained in:
12
src/cdebug.c
12
src/cdebug.c
@@ -32,14 +32,6 @@ int constInstruction(const char *name, CChunk *chunk, int offset, int indent) {
|
||||
return offset + 1 + (sizeof(uint16_t) / sizeof(INSTRUCTION)); // consume opcode + uint
|
||||
}
|
||||
|
||||
int ABOperandInstruction(const char *name, CChunk *chunk, int offset) {
|
||||
int args = readu8Chunk(chunk, offset + 1);
|
||||
int nresults = readu8Chunk(chunk, offset + 2);
|
||||
|
||||
printf("%-16s [%03d] [%03d]", name, args, nresults);
|
||||
return offset + 3;
|
||||
}
|
||||
|
||||
// public methods in the cdebug.h header
|
||||
|
||||
void disasmChunk(CChunk *chunk, const char *name, int indent) {
|
||||
@@ -91,7 +83,7 @@ int disasmInstr(CChunk *chunk, int offset, int indent) {
|
||||
case OP_POP:
|
||||
return shortOperandInstruction("OP_POP", chunk, offset);
|
||||
case OP_CALL:
|
||||
return ABOperandInstruction("OP_CALL", chunk, offset);
|
||||
return shortOperandInstruction("OP_CALL", chunk, offset);
|
||||
case OP_CLOSURE: {
|
||||
int index = readu16Chunk(chunk, offset + 1);
|
||||
printf("%-16s [%05d] - ", "OP_CLOSURE", index);
|
||||
@@ -153,7 +145,7 @@ int disasmInstr(CChunk *chunk, int offset, int indent) {
|
||||
case OP_CONCAT:
|
||||
return shortOperandInstruction("OP_CONCAT", chunk, offset);
|
||||
case OP_RETURN:
|
||||
return shortOperandInstruction("OP_RETURN", chunk, offset);
|
||||
return simpleInstruction("OP_RETURN", offset);
|
||||
default:
|
||||
printf("Unknown opcode! [%d]\n", i);
|
||||
exit(0);
|
||||
|
||||
Reference in New Issue
Block a user