diff options
Diffstat (limited to 'bos-sugar.sh')
-rw-r--r-- | bos-sugar.sh | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/bos-sugar.sh b/bos-sugar.sh index 1322b36..f211f97 100644 --- a/bos-sugar.sh +++ b/bos-sugar.sh @@ -44,13 +44,6 @@ function bos-sugar/class-open() { return 1 fi - local class="$1" - bos-namespaces/push "$class" - - local fq_class; bos-namespaces/current-namespace-into fq_class - - bos-sugar/set-metaclass-for "$fq_class" - function extends() { local fq_class; bos-namespaces/current-namespace-into fq_class local metaclass_ref; bos-namespaces/store-scalar-for-into metaclass_ref meta "$fq_class" @@ -58,9 +51,11 @@ function bos-sugar/class-open() { $metaclass_object set-superclasses-for "$fq_class" "$@" } - eval "function $fq_class { bos-dispatch/invoke \"$fq_class\" 0 \"\$@\"; }" + local class="$1" + bos-namespaces/namespace-open "$1" - bos-namespaces/save-funcs + local fq_class; bos-namespaces/current-namespace-into fq_class + bos-sugar/set-metaclass-for "$fq_class" # this will get renamed into the class function new-into() { @@ -70,7 +65,7 @@ function bos-sugar/class-open() { local -n metaclass_object="$metaclass_ref" local new_object - $metaclass_object create-object-into new_object "$class" + $metaclass_object create-object-into new_object "$class" "$@" new_into_result="$new_object" } @@ -85,12 +80,12 @@ function bos-sugar/class-close() { local metaclass_ref; bos-namespaces/store-scalar-for-into metaclass_ref meta "$fq_class" local -n metaclass_object="$metaclass_ref" - local -a methods_list; bos-namespaces/list-new-funcs-into methods_list - bos-namespaces/qualify-funcs "${methods_list[@]}" + bos-namespaces/namespace-close $metaclass_object make-mro-for "$fq_class" - bos-namespaces/pop + # TODO this should probably be done by the metaclass? + eval "function $fq_class { bos-dispatch/invoke \"$fq_class\" 0 \"\$@\"; }" return 0 } @@ -103,17 +98,13 @@ function bos-sugar/namespace-open() { return 1 fi - bos-namespaces/push "$1" - bos-namespaces/save-funcs + bos-namespaces/namespace-open "$1" return 0 } function bos-sugar/namespace-close() { - local -a methods_list; bos-namespaces/list-new-funcs-into methods_list - bos-namespaces/qualify-funcs "${methods_list[@]}" - - bos-namespaces/pop + bos-namespaces/namespace-close return 0 } |