From f35a3c6de1e010042056f2364a3575b193c97128 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Thu, 17 Dec 2015 19:24:16 +0100 Subject: Update stdlib with vars --- stdlib.rip | 120 ++++++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 104 insertions(+), 16 deletions(-) (limited to 'stdlib.rip') diff --git a/stdlib.rip b/stdlib.rip index 4100df9..af428c3 100644 --- a/stdlib.rip +++ b/stdlib.rip @@ -40,20 +40,108 @@ F[ P ] -0I[ - a b 256 - a b 256 256 - a 256 b 256 - a 256 256 b - a 256 256 b b - a 256 b b 256 - a 256 b b%ff - 256 b b%ff a - 256 b newa - newa 256 b - newa b 256 - newa b 256 256 - newa 256 b 256 - newa 256 newb - newa newb 256 + +0I[initialises variable store at beginning of stack (no args) (CALL ONLY ONCE)] +F[ + 0lr 0lr 0lr 0I[guard] +] + +0I[INTERNAL FUNCTION + hauls variable by name in argument to top of stack; pushes 0 0 if non-existent] +F[ + 00 0I[guard] + lRlR + SD3rW[ + 0I['s't'a'r't' 'w'h'i'l'e 9i 93a] + SD3r + 6R 0I[get target varname up] + D5r + EDI[P + 0I['e'q'u'a'l'! 9i 7] + D3r + 4RD5rW[ + 4r4rlrlr + 4RD5r] + 3RP3RP + 0 0I[to stop while loop] + 1 0I[to prevent taking of the else branch] + ] + nI[ + 0I['u'n'e'q'u'a'l'! 9i 9] + lRlR 0I[get next one] + SD3r 0I[get name up; if zero, then while loop should stop: end of var list] + ] + ] + 0I['d'o'n'e' 'w'i't'h' 'w'h'i'l'e 9i 79a] + SD3rnI[ + 0I['i's' 'z'e'r'o 9i 8] + lrlr3RP + SD3rW[ + lrlr + SD3r] + ] + 0I['d'o'n'e' 'w'i't'h' 'v'a'r'h'a'u'l'u'p 9i 99aii] +] + +0I[pushes whether specified variable exists in store] +F[ + + Pnn +] + +0I[deletes variable given by argument from store] +F[ + 00 0I[guard] + lRlR + SD3rW[ + 0I['s't'a'r't' 'w'h'i'l'e 9i 93a] + SD3r + 6R 0I[get target varname up] + D5r + EDI[P + 0I['e'q'u'a'l'! 9i 7] + PPP + SD3rW[ + lrlr + SD3r] + PP + 1 0I[did find the thing] + 0 0I[to stop while loop] + 1 0I[to prevent taking of the else branch] + ] + nI[ + 0I['u'n'e'q'u'a'l'! 9i 9] + lRlR 0I[get next one] + SD3r 0I[get name up; if zero, then while loop should stop: end of var list] + ] + ] + 0I['d'o'n'e' 'w'i't'h' 'w'h'i'l'e 9i 79a] + nI[ + 0I['i's' 'z'e'r'o 9i 8] + 0lrlr3RP + SD3rW[ + lrlr + SD3r] + PP + ] + 0I['d'o'n'e' 'w'i't'h' 'v'a'r'd'e'l 9i 89a] +] + +0I[takes variable name (string) and value to store] +F[ + 0I['s't'o'r'i'n'g' 8 + O + ' 'i'n' 4 + + 9io + ] + + SD + Slrlr +] + +0I[takes variable name (string) and pushes its value] +F[ + + SP ] -- cgit v1.2.3-70-g09d2