|
1 | 1 | if :recursion_relation in fieldnames(Method)
|
2 | 2 |
|
3 | 3 | first(methods(Diffractor.∂⃖recurse{1}())).recursion_relation = function(method1, method2, parent_sig, new_sig)
|
4 |
| - # Recursion from a higher to a lower order is always allowed |
5 |
| - parent_order = parent_sig.parameters[1].parameters[1] |
6 |
| - child_order = new_sig.parameters[1].parameters[1] |
7 |
| - #@Core.Main.Base.show (parent_order, child_order) |
8 |
| - if parent_order > child_order |
9 |
| - return true |
10 |
| - end |
11 |
| - wrapped_parent_sig = Tuple{parent_sig.parameters[2:end]...} |
12 |
| - wrapped_new_sig = Tuple{parent_sig.parameters[2:end]...} |
13 |
| - if method2 !== nothing && isdefined(method2, :recursion_relation) |
14 |
| - # TODO: What if method2 is itself a generated function. |
15 |
| - return method2.recursion_relation(method2, nothing, wrapped_parent_sig, wrapped_new_sig) |
16 |
| - end |
17 |
| - return Core.Compiler.type_more_complex(new_sig, parent_sig, Core.svec(parent_sig), 1, 3, length(method1.sig.parameters)+1) |
| 4 | + # Recursion from a higher to a lower order is always allowed |
| 5 | + parent_order = parent_sig.parameters[1].parameters[1] |
| 6 | + child_order = new_sig.parameters[1].parameters[1] |
| 7 | + #@Core.Main.Base.show (parent_order, child_order) |
| 8 | + if parent_order > child_order |
| 9 | + return true |
| 10 | + end |
| 11 | + wrapped_parent_sig = Tuple{parent_sig.parameters[2:end]...} |
| 12 | + wrapped_new_sig = Tuple{parent_sig.parameters[2:end]...} |
| 13 | + if method2 !== nothing && isdefined(method2, :recursion_relation) |
| 14 | + # TODO: What if method2 is itself a generated function. |
| 15 | + return method2.recursion_relation(method2, nothing, wrapped_parent_sig, wrapped_new_sig) |
| 16 | + end |
| 17 | + return Core.Compiler.type_more_complex(new_sig, parent_sig, Core.svec(parent_sig), 1, 3, length(method1.sig.parameters)+1) |
18 | 18 | end
|
19 | 19 |
|
20 | 20 | first(methods(PrimeDerivativeBack(sin))).recursion_relation = function(method1, method2, parent_sig, new_sig)
|
21 |
| - # Recursion from a higher to a lower order is always allowed |
22 |
| - parent_order = parent_sig.parameters[1].parameters[1] |
23 |
| - child_order = new_sig.parameters[1].parameters[1] |
24 |
| - #@Core.Main.Base.show (parent_order, child_order) |
25 |
| - if parent_order > child_order |
26 |
| - return true |
27 |
| - end |
28 |
| - wrapped_parent_sig = Tuple{parent_sig.parameters[2:end]...} |
29 |
| - wrapped_new_sig = Tuple{parent_sig.parameters[2:end]...} |
30 |
| - return Core.Compiler.type_more_complex(new_sig, parent_sig, Core.svec(parent_sig), 1, 3, length(method1.sig.parameters)+1) |
| 21 | + # Recursion from a higher to a lower order is always allowed |
| 22 | + parent_order = parent_sig.parameters[1].parameters[1] |
| 23 | + child_order = new_sig.parameters[1].parameters[1] |
| 24 | + #@Core.Main.Base.show (parent_order, child_order) |
| 25 | + if parent_order > child_order |
| 26 | + return true |
| 27 | + end |
| 28 | + wrapped_parent_sig = Tuple{parent_sig.parameters[2:end]...} |
| 29 | + wrapped_new_sig = Tuple{parent_sig.parameters[2:end]...} |
| 30 | + return Core.Compiler.type_more_complex(new_sig, parent_sig, Core.svec(parent_sig), 1, 3, length(method1.sig.parameters)+1) |
31 | 31 | end
|
32 | 32 |
|
33 | 33 | which(Tuple{∂⃖{N}, T, Vararg{Any}} where {T,N}).recursion_relation = function(_, _, parent_sig, new_sig)
|
34 |
| - # Any actual recursion will always be caught be one of the functions we're |
35 |
| - # recursing into. |
36 |
| - return isa(Base.unwrap_unionall(parent_sig.parameters[1].parameters[1]), Int) && |
| 34 | + # Any actual recursion will always be caught be one of the functions we're |
| 35 | + # recursing into. |
| 36 | + return isa(Base.unwrap_unionall(parent_sig.parameters[1].parameters[1]), Int) && |
37 | 37 | isa(Base.unwrap_unionall(new_sig.parameters[1].parameters[1]), Int)
|
38 | 38 | end
|
39 | 39 |
|
40 | 40 | which(Tuple{∂⃖{N}, ∂⃖{1}, Vararg{Any}} where {N}).recursion_relation = function(_, _, parent_sig, new_sig)
|
41 |
| - # Allowed as long as both parent and new sig have concrete integers. In that |
42 |
| - # case, actual recursion will be caught elsewhere. |
43 |
| - return isa(Base.unwrap_unionall(parent_sig.parameters[1].parameters[1]), Int) && |
44 |
| - isa(Base.unwrap_unionall(new_sig.parameters[1].parameters[1]), Int) |
| 41 | + # Allowed as long as both parent and new sig have concrete integers. In that |
| 42 | + # case, actual recursion will be caught elsewhere. |
| 43 | + return isa(Base.unwrap_unionall(parent_sig.parameters[1].parameters[1]), Int) && |
| 44 | + isa(Base.unwrap_unionall(new_sig.parameters[1].parameters[1]), Int) |
45 | 45 | end
|
46 | 46 |
|
47 | 47 | for (;method) in Base._methods_by_ftype(Tuple{Diffractor.∂☆recurse{N}, Vararg{Any}} where {N}, nothing, -1, Base.get_world_counter())
|
48 |
| - method.recursion_relation = function (method1, method2, parent_sig, new_sig) |
49 |
| - # Recursion from a higher to a lower order is always allowed |
50 |
| - parent_order = parent_sig.parameters[1].parameters[1] |
51 |
| - child_order = new_sig.parameters[1].parameters[1] |
52 |
| - #@Core.Main.Base.show (parent_order, child_order) |
53 |
| - if parent_order > child_order |
54 |
| - return true |
55 |
| - end |
56 |
| - @show (parent_sig, new_sig) |
57 |
| - return false |
58 |
| - end |
| 48 | + method.recursion_relation = function (method1, method2, parent_sig, new_sig) |
| 49 | + # Recursion from a higher to a lower order is always allowed |
| 50 | + parent_order = parent_sig.parameters[1].parameters[1] |
| 51 | + child_order = new_sig.parameters[1].parameters[1] |
| 52 | + if parent_order > child_order |
| 53 | + return true |
| 54 | + end |
| 55 | + Core.Compiler.@show (parent_sig, new_sig) |
| 56 | + return false |
| 57 | + end |
59 | 58 | end
|
60 | 59 |
|
61 | 60 | for (;method) in Base._methods_by_ftype(Tuple{Diffractor.∂☆internal{N}, Vararg{Any}} where {N}, nothing, -1, Base.get_world_counter())
|
62 |
| - method.recursion_relation = function (method1, method2, parent_sig, new_sig) |
63 |
| - return true |
64 |
| - end |
| 61 | + method.recursion_relation = function (method1, method2, parent_sig, new_sig) |
| 62 | + return true |
| 63 | + end |
65 | 64 | end
|
66 | 65 |
|
67 | 66 | for (;method) in Base._methods_by_ftype(Tuple{Diffractor.∂☆{N}, Vararg{Any}} where {N}, nothing, -1, Base.get_world_counter())
|
68 |
| - method.recursion_relation = function (method1, method2, parent_sig, new_sig) |
69 |
| - return true |
70 |
| - end |
| 67 | + method.recursion_relation = function (method1, method2, parent_sig, new_sig) |
| 68 | + return true |
| 69 | + end |
71 | 70 | end
|
72 | 71 |
|
73 | 72 | end
|
0 commit comments