File outputting while embedding GroundVM
This commit is contained in:
@@ -122,6 +122,7 @@ extern "C" {
|
||||
GroundProgram groundCreateProgram();
|
||||
void groundAddInstructionToProgram(GroundProgram* program, GroundInstruction instruction);
|
||||
GroundValue groundRunProgram(GroundProgram* program);
|
||||
void groundPrintProgram(GroundProgram* program);
|
||||
|
||||
GroundInstruction groundCreateInstruction(GroundInstType type);
|
||||
void groundAddValueToInstruction(GroundInstruction* inst, GroundValue value);
|
||||
|
||||
@@ -79,3 +79,10 @@ GroundValue groundCreateValue(GroundValueType type, ...) {
|
||||
GroundValue groundRunProgram(GroundProgram* program) {
|
||||
return interpretGroundProgram(program, NULL);
|
||||
}
|
||||
|
||||
void groundPrintProgram(GroundProgram* program) {
|
||||
for (size_t i = 0; i < program->size; i++) {
|
||||
printGroundInstruction(&program->instructions[i]);
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -372,15 +372,20 @@ void printGroundInstruction(GroundInstruction* gi) {
|
||||
printf("extern");
|
||||
break;
|
||||
case CREATELABEL:
|
||||
printf("createlabel");
|
||||
break;
|
||||
default:
|
||||
printf("FIXME");
|
||||
break;
|
||||
}
|
||||
printf(" ");
|
||||
if (gi->type != CREATELABEL) printf(" ");
|
||||
for (int i = 0; i < gi->args.length; i++) {
|
||||
if (gi->args.args[i].type == VALUE && gi->args.args[i].value.value.type == STRING) {
|
||||
printf("\"");
|
||||
printGroundArg(&gi->args.args[i]);
|
||||
printf("\"");
|
||||
} else {
|
||||
printGroundArg(&gi->args.args[i]);
|
||||
}
|
||||
printf(" ");
|
||||
}
|
||||
}
|
||||
|
||||
3
tests/convs.grnd
Normal file
3
tests/convs.grnd
Normal file
@@ -0,0 +1,3 @@
|
||||
tostring 32 &int
|
||||
|
||||
println $int
|
||||
Reference in New Issue
Block a user