|
93 | 93 | baremodule __deserialized_types__ end
|
94 | 94 |
|
95 | 95 | if VERSION < v"1.7-"
|
96 |
| -function newstruct_raw(cache, ::Type{TypeName}, d, init) |
97 |
| - name = raise_recursive(d[:data][2], cache, init) |
98 |
| - name = isdefined(__deserialized_types__, name) ? gensym() : name |
99 |
| - tn = ccall(:jl_new_typename_in, Ref{Core.TypeName}, (Any, Any), |
100 |
| - name, __deserialized_types__) |
101 |
| - cache[d] = tn |
102 |
| - names, super, parameters, types, has_instance, |
103 |
| - abstr, mutabl, ninitialized = map(x -> raise_recursive(x, cache, init), d[:data][3:end-1]) |
104 |
| - tn.names = names |
105 |
| - ndt = ccall(:jl_new_datatype, Any, (Any, Any, Any, Any, Any, Any, Cint, Cint, Cint), |
106 |
| - tn, tn.module, super, parameters, names, types, |
107 |
| - abstr, mutabl, ninitialized) |
108 |
| - ty = tn.wrapper = ndt.name.wrapper |
109 |
| - ccall(:jl_set_const, Cvoid, (Any, Any, Any), tn.module, tn.name, ty) |
110 |
| - if has_instance && !isdefined(ty, :instance) |
111 |
| - # use setfield! directly to avoid `fieldtype` lowering expecting to see a Singleton object already on ty |
112 |
| - Core.setfield!(ty, :instance, ccall(:jl_new_struct, Any, (Any, Any...), ty)) |
113 |
| - end |
114 |
| - mt = raise_recursive(d[:data][end], cache, init) |
115 |
| - if mt != nothing |
116 |
| - mtname, defs, maxa, kwsorter = mt |
117 |
| - tn.mt = ccall(:jl_new_method_table, Any, (Any, Any), name, tn.module) |
118 |
| - tn.mt.name = mtname |
119 |
| - tn.mt.max_args = maxa |
120 |
| - for def in defs |
121 |
| - isdefined(def, :sig) || continue |
122 |
| - ccall(:jl_method_table_insert, Cvoid, (Any, Any, Ptr{Cvoid}), tn.mt, def, C_NULL) |
| 96 | + function newstruct_raw(cache, ::Type{TypeName}, d, init) |
| 97 | + name = raise_recursive(d[:data][2], cache, init) |
| 98 | + name = isdefined(__deserialized_types__, name) ? gensym() : name |
| 99 | + tn = ccall(:jl_new_typename_in, Ref{Core.TypeName}, (Any, Any), |
| 100 | + name, __deserialized_types__) |
| 101 | + cache[d] = tn |
| 102 | + names, super, parameters, types, has_instance, |
| 103 | + abstr, mutabl, ninitialized = map(x -> raise_recursive(x, cache, init), d[:data][3:end-1]) |
| 104 | + tn.names = names |
| 105 | + ndt = ccall(:jl_new_datatype, Any, (Any, Any, Any, Any, Any, Any, Cint, Cint, Cint), |
| 106 | + tn, tn.module, super, parameters, names, types, |
| 107 | + abstr, mutabl, ninitialized) |
| 108 | + ty = tn.wrapper = ndt.name.wrapper |
| 109 | + ccall(:jl_set_const, Cvoid, (Any, Any, Any), tn.module, tn.name, ty) |
| 110 | + if has_instance && !isdefined(ty, :instance) |
| 111 | + # use setfield! directly to avoid `fieldtype` lowering expecting to see a Singleton object already on ty |
| 112 | + Core.setfield!(ty, :instance, ccall(:jl_new_struct, Any, (Any, Any...), ty)) |
| 113 | + end |
| 114 | + mt = raise_recursive(d[:data][end], cache, init) |
| 115 | + if mt != nothing |
| 116 | + mtname, defs, maxa, kwsorter = mt |
| 117 | + tn.mt = ccall(:jl_new_method_table, Any, (Any, Any), name, tn.module) |
| 118 | + tn.mt.name = mtname |
| 119 | + tn.mt.max_args = maxa |
| 120 | + for def in defs |
| 121 | + isdefined(def, :sig) || continue |
| 122 | + ccall(:jl_method_table_insert, Cvoid, (Any, Any, Ptr{Cvoid}), tn.mt, def, C_NULL) |
| 123 | + end |
123 | 124 | end
|
| 125 | + return tn |
124 | 126 | end
|
125 |
| - return tn |
126 |
| -end |
127 | 127 | else
|
128 |
| -function newstruct_raw(cache, ::Type{TypeName}, d, init) |
129 |
| - name = raise_recursive(d[:data][2], cache, init) |
130 |
| - name = isdefined(__deserialized_types__, name) ? gensym() : name |
131 |
| - tn = ccall(:jl_new_typename_in, Ref{Core.TypeName}, (Any, Any), |
132 |
| - name, __deserialized_types__) |
133 |
| - cache[d] = tn |
134 |
| - names, super, parameters, types, has_instance, atomicfields, |
135 |
| - abstr, mutabl, ninitialized = map(x -> raise_recursive(x, cache, init), d[:data][3:end-1]) |
136 |
| - tn.names = names |
137 |
| - ndt = ccall(:jl_new_datatype, Any, (Any, Any, Any, Any, Any, Any, Any, Cint, Cint, Cint), |
138 |
| - tn, tn.module, super, parameters, names, types, atomicfields, |
139 |
| - abstr, mutabl, ninitialized) |
140 |
| - ty = tn.wrapper = ndt.name.wrapper |
141 |
| - ccall(:jl_set_const, Cvoid, (Any, Any, Any), tn.module, tn.name, ty) |
142 |
| - if has_instance && !isdefined(ty, :instance) |
143 |
| - # use setfield! directly to avoid `fieldtype` lowering expecting to see a Singleton object already on ty |
144 |
| - Core.setfield!(ty, :instance, ccall(:jl_new_struct, Any, (Any, Any...), ty)) |
145 |
| - end |
146 |
| - mt = raise_recursive(d[:data][end], cache, init) |
147 |
| - if mt != nothing |
148 |
| - mtname, defs, maxa, kwsorter = mt |
149 |
| - tn.mt = ccall(:jl_new_method_table, Any, (Any, Any), name, tn.module) |
150 |
| - tn.mt.name = mtname |
151 |
| - tn.mt.max_args = maxa |
152 |
| - for def in defs |
153 |
| - isdefined(def, :sig) || continue |
154 |
| - ccall(:jl_method_table_insert, Cvoid, (Any, Any, Ptr{Cvoid}), tn.mt, def, C_NULL) |
| 128 | + function newstruct_raw(cache, ::Type{TypeName}, d, init) |
| 129 | + name = raise_recursive(d[:data][2], cache, init) |
| 130 | + name = isdefined(__deserialized_types__, name) ? gensym() : name |
| 131 | + tn = ccall(:jl_new_typename_in, Ref{Core.TypeName}, (Any, Any), |
| 132 | + name, __deserialized_types__) |
| 133 | + cache[d] = tn |
| 134 | + names, super, parameters, types, has_instance, atomicfields, |
| 135 | + abstr, mutabl, ninitialized = map(x -> raise_recursive(x, cache, init), d[:data][3:end-1]) |
| 136 | + ndt = ccall(:jl_new_datatype, Any, (Any, Any, Any, Any, Any, Any, Any, Cint, Cint, Cint), |
| 137 | + tn, tn.module, super, parameters, names, types, atomicfields, |
| 138 | + abstr, mutabl, ninitialized) |
| 139 | + # ty = tn.wrapper = ndt.name.wrapper |
| 140 | + ty = ndt.name.wrapper |
| 141 | + ccall(:jl_set_const, Cvoid, (Any, Any, Any), tn.module, tn.name, ty) |
| 142 | + if has_instance && !isdefined(ty, :instance) |
| 143 | + # use setfield! directly to avoid `fieldtype` lowering expecting to see a Singleton object already on ty |
| 144 | + Core.setfield!(ty, :instance, ccall(:jl_new_struct, Any, (Any, Any...), ty)) |
| 145 | + end |
| 146 | + mt = raise_recursive(d[:data][end], cache, init) |
| 147 | + if mt != nothing |
| 148 | + mtname, defs, maxa, kwsorter = mt |
| 149 | + mt = ccall(:jl_new_method_table, Any, (Any, Any), name, tn.module) |
| 150 | + mt.name = mtname |
| 151 | + mt.max_args = maxa |
| 152 | + ccall(:jl_set_nth_field, Cvoid, (Any, Csize_t, Any), tn, Base.fieldindex(Core.TypeName, :mt)-1, mt) |
| 153 | + for def in defs |
| 154 | + isdefined(def, :sig) || continue |
| 155 | + ccall(:jl_method_table_insert, Cvoid, (Any, Any, Ptr{Cvoid}), mt, def, C_NULL) |
| 156 | + end |
155 | 157 | end
|
| 158 | + return tn |
156 | 159 | end
|
157 |
| - return tn |
158 |
| -end |
159 | 160 | end
|
160 | 161 |
|
161 | 162 | # Function Types
|
|
0 commit comments