From 55bf7e269e04f43f4a341f2001d725ac5fd50c23 Mon Sep 17 00:00:00 2001 From: "hyunghwan.chung" Date: Sun, 4 Aug 2019 16:38:09 +0000 Subject: [PATCH] trying to fix some goto implementation issues --- moo/kernel/test-003.moo | 10 +++++++++- moo/lib/moo-prv.h | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/moo/kernel/test-003.moo b/moo/kernel/test-003.moo index 4b45979..26b0615 100644 --- a/moo/kernel/test-003.moo +++ b/moo/kernel/test-003.moo @@ -108,7 +108,15 @@ start: [goto B02. A01: 10. B02: 1000. ] value class dump. self q. -[ | a | a := 21. if (a = 21) { goto X02 }. X02: ] value dump. ## this causes a stack depletion problem... TODO: +[ | a | a := 21. if (a = 21) { goto X02 }. X02: ] value dump. // this causes a stack depletion problem... TODO: + +/* +this is horrible... the stack won't be cleared when goto is made... +System should never be popped out + (if (2 > 1) { 20. System log: (if (2 > 1) {goto X2}) }) dump. +X2: + a dump. +*/ EXCEPTION_TEST: Exception signal: 'experiment with exception signalling'. diff --git a/moo/lib/moo-prv.h b/moo/lib/moo-prv.h index a2a6e69..31dcc09 100644 --- a/moo/lib/moo-prv.h +++ b/moo/lib/moo-prv.h @@ -959,7 +959,7 @@ enum moo_bcode_t BCODE_JUMP2_FORWARD_IF_TRUE = 0xC7, /* 199 ## */ BCODE_JUMP_FORWARD_IF_FALSE = 0xC8, /* 200 ## */ BCODE_JUMP2_FORWARD_IF_FALSE = 0xC9, /* 201 ## */ - /* JMPOP = JUMP + POP */ + /* JMPOP = JUMP + POP -> it pops the stack top always but it jumps only if the condition is met */ BCODE_JMPOP_FORWARD_IF_TRUE = 0xCA, /* 202 ## */ BCODE_JMPOP2_FORWARD_IF_TRUE = 0xCB, /* 203 ## */ BCODE_JMPOP_FORWARD_IF_FALSE = 0xCC, /* 204 ## */