diff options
author | Gianni Ceccarelli <gianni.ceccarelli@broadbean.com> | 2023-07-14 11:56:20 +0100 |
---|---|---|
committer | Gianni Ceccarelli <gianni.ceccarelli@broadbean.com> | 2023-07-14 11:56:20 +0100 |
commit | dc627de951cb666b123b5b23c1e040dc9f77e696 (patch) | |
tree | 8cc4e0b93b497b9cf28fc61a3a8dc036f178ed95 /bos-mop.sh | |
parent | flailing about with MOPs (diff) | |
download | bash-object-system-dc627de951cb666b123b5b23c1e040dc9f77e696.tar.gz bash-object-system-dc627de951cb666b123b5b23c1e040dc9f77e696.tar.bz2 bash-object-system-dc627de951cb666b123b5b23c1e040dc9f77e696.zip |
method dispatch seems to work
Diffstat (limited to 'bos-mop.sh')
-rw-r--r-- | bos-mop.sh | 14 |
1 files changed, 6 insertions, 8 deletions
@@ -1,14 +1,12 @@ #!bash -bos_class__bos__mop__base__meta="bos-dipatch/invoke bos/mop/base 0" +bos_namespaces__bos__mop__base__meta="bos-dipatch/invoke bos/mop/base 0" +declare -a bos_namespaces__bos__mop__base__mro=( "bos/mop/base" ) # these are instance methods of the base metaclass function bos/mop/base/mro-for-into() { - local name="bos_mop__mro__${1//\//__}" - local -n result="$2" - declare -ga "$name" - result="$name" + bos-namespaces/store-array-for-into mro "$1" "$2" } # find the first class (in MRO) that defines a given method @@ -22,14 +20,14 @@ function bos/mop/base/find-method-into() { local method="$3" local -n result="$4" - local mro_store; $self mro-for-into mro_store + local mro_store; $self mro-for-into "$class" mro_store local -n mro="$mro_store" local idx=0 # if we don't have a $start_from_class, it means we're doing the # initial method resolution, so don't skip any class in $mro if [[ -n "$start_from_class" ]]; then - for (( ; idx < "${#mro}" ; ++idx )); do + for (( ; idx <= "${#mro}" ; ++idx )); do if [[ "${mro[$idx]}" == "$start_from_class" ]]; then (( ++idx )) break @@ -37,7 +35,7 @@ function bos/mop/base/find-method-into() { done fi - for (( ; idx < "${#mro}" ; ++idx )); do + for (( ; idx <= "${#mro}" ; ++idx )); do local full_name="${mro[$idx]}/${method}" if declare -F "$full_name" >/dev/null; then result="${full_name}" |