progress
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
|
||||
static inline void doLabels(GroundProgram* program, GroundState* state) {
|
||||
|
||||
for (size_t i = 0; i < program->len; i++) {
|
||||
for (GroundSize i = 0; i < program->len; i++) {
|
||||
GroundInstruction* instruction = &program->at[i];
|
||||
if (instruction->type == GroundInstruction_CREATELABEL) {
|
||||
if (instruction->args.len > 0) {
|
||||
@@ -30,11 +30,11 @@ static inline void doLabels(GroundProgram* program, GroundState* state) {
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < program->len; i++) {
|
||||
for (GroundSize i = 0; i < program->len; i++) {
|
||||
GroundInstruction* instruction = &program->at[i];
|
||||
if (instruction->type == GroundInstruction_JUMP) {
|
||||
GroundArg* arg = &instruction->args.at[0];
|
||||
size_t* line = Ground.State.findLabel(state, arg->as.ref->string);
|
||||
GroundSize* line = Ground.State.findLabel(state, arg->as.ref->string);
|
||||
if (line == NULL) {
|
||||
char buf[2048];
|
||||
snprintf(buf, 2047, "couldn't find label '%s' (instruction JUMP at %zu) in Ground.Internal.Run()", arg->as.ref->string, i);
|
||||
@@ -47,7 +47,7 @@ static inline void doLabels(GroundProgram* program, GroundState* state) {
|
||||
|
||||
} else if (instruction->type == GroundInstruction_IF) {
|
||||
GroundArg* arg = &instruction->args.at[1];
|
||||
size_t* line = Ground.State.findLabel(state, arg->as.ref->string);
|
||||
GroundSize* line = Ground.State.findLabel(state, arg->as.ref->string);
|
||||
if (line == NULL) {
|
||||
char buf[2048];
|
||||
snprintf(buf, 2047, "couldn't find label '%s' (instruction IF at %zu) in Ground.Internal.Run()", arg->as.ref->string, i);
|
||||
@@ -60,7 +60,7 @@ static inline void doLabels(GroundProgram* program, GroundState* state) {
|
||||
|
||||
} else if (instruction->type == GroundInstruction_CATCH) {
|
||||
GroundArg* arg = &instruction->args.at[1];
|
||||
size_t* line = Ground.State.findLabel(state, arg->as.ref->string);
|
||||
GroundSize* line = Ground.State.findLabel(state, arg->as.ref->string);
|
||||
if (line == NULL) {
|
||||
char buf[2048];
|
||||
snprintf(buf, 2047, "couldn't find label '%s' (instruction CATCH at %zu) in Ground.Internal.Run()", arg->as.ref->string, i);
|
||||
@@ -79,10 +79,10 @@ static inline void doLabels(GroundProgram* program, GroundState* state) {
|
||||
/*
|
||||
* Assigns an offset to each variable referenced.
|
||||
*/
|
||||
static inline size_t doOffsets(GroundProgram* program, GroundState* state) {
|
||||
size_t size = 0;
|
||||
for (size_t i = 0; i < program->len; i++) {
|
||||
for (size_t j = 0; j < program->at[i].args.len; j++) {
|
||||
static inline GroundSize doOffsets(GroundProgram* program, GroundState* state) {
|
||||
GroundSize size = 0;
|
||||
for (GroundSize i = 0; i < program->len; i++) {
|
||||
for (GroundSize j = 0; j < program->at[i].args.len; j++) {
|
||||
GroundArg* arg = &program->at[i].args.at[j];
|
||||
|
||||
if (
|
||||
@@ -120,12 +120,12 @@ void _GroundInternalRun(GroundProgram* program, GroundState* state) {
|
||||
doLabels(program, state);
|
||||
if (Ground.Flags.error) return;
|
||||
|
||||
size_t size = doOffsets(program, state);
|
||||
GroundSize size = doOffsets(program, state);
|
||||
if (Ground.Flags.error) return;
|
||||
|
||||
GroundValue* heap = malloc(sizeof(GroundValue) * size);
|
||||
|
||||
for (size_t i = 0; i < program->len; i++) {
|
||||
for (GroundSize i = 0; i < program->len; i++) {
|
||||
GroundInstruction instruction = Ground.Copy.Instruction(&program->at[i]);
|
||||
int64_t status = Ground.Instruction.execute(&instruction, heap);
|
||||
switch (status) {
|
||||
|
||||
Reference in New Issue
Block a user