Fix a couple things

This commit is contained in:
2026-06-16 20:08:21 +10:00
parent 02b5a9cc54
commit 6d35acbe60
6 changed files with 143 additions and 48 deletions

BIN
test/test

Binary file not shown.

View File

@@ -1,15 +1,29 @@
#include <ground.h>
#include <stdio.h>
int main() {
GroundProgram program = Ground.New.Program();
printf(Ground.Flags.error ? "true\n" : "false\n");
GroundState state = {NULL, NULL, NULL};
GroundInstruction instruction = Ground.New.Instruction(GroundInstruction_ADD);
printf(Ground.Flags.error ? "true\n" : "false\n");
Ground.Instruction.append(&instruction, Ground.New.Arg.Value(Ground.New.Value.Int(2)));
printf(Ground.Flags.error ? "true\n" : "false\n");
Ground.Instruction.append(&instruction, Ground.New.Arg.Value(Ground.New.Value.Int(2)));
printf(Ground.Flags.error ? "true\n" : "false\n");
// Instruction 1: CREATELABEL start
GroundInstruction label_inst = Ground.New.Instruction(GroundInstruction_CREATELABEL);
Ground.Instruction.append(&label_inst, Ground.New.Arg.LabelRef("start"));
Ground.Program.append(&program, label_inst);
// Instruction 2: JUMP start
GroundInstruction jump_inst = Ground.New.Instruction(GroundInstruction_JUMP);
Ground.Instruction.append(&jump_inst, Ground.New.Arg.LabelRef("start"));
Ground.Program.append(&program, jump_inst);
// Execute program
Ground.Program.execute(&program, &state);
printf(Ground.Flags.error ? "true\n" : "false\n");
if (Ground.Flags.error) {
printf("Error set during execution!\n");
Ground.Log.printErrors();
return 1;
} else {
printf("Success!\n");
return 0;
}
}