forked from ground/cground
File outputting while embedding GroundVM
This commit is contained in:
@@ -122,6 +122,7 @@ extern "C" {
|
|||||||
GroundProgram groundCreateProgram();
|
GroundProgram groundCreateProgram();
|
||||||
void groundAddInstructionToProgram(GroundProgram* program, GroundInstruction instruction);
|
void groundAddInstructionToProgram(GroundProgram* program, GroundInstruction instruction);
|
||||||
GroundValue groundRunProgram(GroundProgram* program);
|
GroundValue groundRunProgram(GroundProgram* program);
|
||||||
|
void groundPrintProgram(GroundProgram* program);
|
||||||
|
|
||||||
GroundInstruction groundCreateInstruction(GroundInstType type);
|
GroundInstruction groundCreateInstruction(GroundInstType type);
|
||||||
void groundAddValueToInstruction(GroundInstruction* inst, GroundValue value);
|
void groundAddValueToInstruction(GroundInstruction* inst, GroundValue value);
|
||||||
|
|||||||
@@ -79,3 +79,10 @@ GroundValue groundCreateValue(GroundValueType type, ...) {
|
|||||||
GroundValue groundRunProgram(GroundProgram* program) {
|
GroundValue groundRunProgram(GroundProgram* program) {
|
||||||
return interpretGroundProgram(program, NULL);
|
return interpretGroundProgram(program, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void groundPrintProgram(GroundProgram* program) {
|
||||||
|
for (size_t i = 0; i < program->size; i++) {
|
||||||
|
printGroundInstruction(&program->instructions[i]);
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
11
src/types.c
11
src/types.c
@@ -372,15 +372,20 @@ void printGroundInstruction(GroundInstruction* gi) {
|
|||||||
printf("extern");
|
printf("extern");
|
||||||
break;
|
break;
|
||||||
case CREATELABEL:
|
case CREATELABEL:
|
||||||
printf("createlabel");
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
printf("FIXME");
|
printf("FIXME");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
printf(" ");
|
if (gi->type != CREATELABEL) printf(" ");
|
||||||
for (int i = 0; i < gi->args.length; i++) {
|
for (int i = 0; i < gi->args.length; i++) {
|
||||||
printGroundArg(&gi->args.args[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(" ");
|
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