Nim
Nim copied to clipboard
fixes #19401; fixes #19402; rework Forward declaration and finalizer for ORC
fixes #19401 fixes #19402
It is a draft because It's the solution I can think of for now. I'm going to examine it tomorrow. At least it works for #19401 and #19402 locally.
It seems that at the time of magicsAfterOverloadResolution
is called, the finalizer function is not transformed completely. By adding a wrapper around the finalizer function, we can ignore the incomplete function body and delay the analysis to later phases. Finally, when the finalizer function gets transformed properly, and the wrapper function will call it. So we don't need to touch the internal symbols of the finalizer function.
For instance
type
Object = object
Ref = ref Object
proc delete(x: Ref)
It generates a deleteFinalizerWrapper
function:
proc delete(x: Ref)
proc deleteFinalizerWrapper(x: var Object) =
delete(x)
After some refactorings, it can solve https://github.com/nim-lang/Nim/issues/19231 too
Thanks for your hard work on this PR! The lines below are statistics of the Nim compiler built from 80e739f2bf5a3e40df7000566a9cbb9cfab29ac4
Hint: mm: orc; threads: on; opt: speed; options: -d:release 164214 lines; 17.767s; 667.836MiB peakmem