| 1 | module scheme |
| 2 | |
| 3 | fn (vm &VM) goops_invalidate_method_container(value Value, method &GoopsMethod) { |
| 4 | if value.tag != .procedure || value.procedure_pointer().mode !in [.goops_generic, .goops_make, |
| 5 | .goops_accessor, .goops_generic_setter] { |
| 6 | return |
| 7 | } |
| 8 | mut generic := vm.checked_goops_generic(value) or { return } |
| 9 | for candidate in generic.methods { |
| 10 | if voidptr(candidate) == voidptr(method) { |
| 11 | generic.generation++ |
| 12 | return |
| 13 | } |
| 14 | } |
| 15 | } |
| 16 | |
| 17 | // A shared method can acquire a new generic-function backlink when an accessor |
| 18 | // is made. The standard constructor guards must also observe edits through such |
| 19 | // an alias, even though that backlink no longer names the original container. |
| 20 | fn (vm &VM) goops_method_changed(method &GoopsMethod, previous_generic Value) { |
| 21 | vm.goops_invalidate_method_container(previous_generic, method) |
| 22 | vm.goops_invalidate_method_container(method.generic, method) |
| 23 | if vm.goops.protocols_ready { |
| 24 | vm.goops_invalidate_method_container(vm.goops.make_instance, method) |
| 25 | vm.goops_invalidate_method_container(vm.goops.initialize, method) |
| 26 | vm.goops_invalidate_method_container(vm.goops.allocate_instance, method) |
| 27 | } |
| 28 | } |
| 29 | |