Skip to content

Instantly share code, notes, and snippets.

@dockimbel
Last active October 4, 2018 04:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dockimbel/8f42bf7e8f01f21950ea41d6c6cbd253 to your computer and use it in GitHub Desktop.
Save dockimbel/8f42bf7e8f01f21950ea41d6c6cbd253 to your computer and use it in GitHub Desktop.
Extracting current stack frame values using R/S.
Red []
get-arguments: routine [
/local
list [red-block!]
s [red-value!]
t [red-value!]
top
][
top: stack/ctop - 3 ;-- might need adjustments depending on interpreted vs compiled code.
s: top/prev
t: stack/arguments
list: block/push-only* 4
while [s < t][
block/rs-append list s
s: s + 1
]
SET_RETURN(list)
]
foo: function [a [integer!] b [string!] c [pair!] /bar /local d][
probe get-arguments
]
foo 123 "hello" 4x5
foo/bar 456 "world" 9x8
;; will output:
;; [123 "hello" 4x5 false none none]
;; [456 "world" 9x8 true none none]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment