@@ -90,7 +90,7 @@ function flatten_argument!(state::FlatteningState, @nospecialize(argt))
9090 line = compact[Compiler. OldSSAValue (1 )][:line ]
9191 ssa = @insert_instruction_here (compact, line, settings, (:invoke )(nothing , InternalIntrinsics. external_equation):: Eq (eq))
9292 return ssa
93- elseif isa ( argt, Type)
93+ elseif argt <: Type
9494 return argt. parameters[1 ]
9595 elseif isabstracttype (argt) || ismutabletype (argt) || (! isa (argt, DataType) && ! isa (argt, PartialStruct))
9696 line = compact[Compiler. OldSSAValue (1 )][:line ]
@@ -112,19 +112,19 @@ function flatten_argument!(state::FlatteningState, @nospecialize(argt))
112112 end
113113end
114114
115- function flatten_arguments_for_callee! (compact:: IncrementalCompact , map:: ArgumentMap , argtypes, 𝕃 , line, settings)
115+ function flatten_arguments_for_callee! (compact:: IncrementalCompact , map:: ArgumentMap , argtypes, args , line, settings, 𝕃 = Compiler . fallback_lattice )
116116 list = Any[]
117117 this = nothing
118- last_index = Int[]
118+ last_index = CompositeIndex ()
119119 for index in map. variables
120120 from = findfirst (j -> get (last_index, j, - 1 ) != = index[j], eachindex (index)):: Int
121121 for i in from: length (index)
122122 field = index[i]
123123 if i == 1
124- this = Argument ( 2 + field)
124+ this = args[ field]
125125 else
126126 thistype = argextype (this, compact)
127- fieldtype = Compiler. getfield_tfunc (𝕃, Const (field))
127+ fieldtype = Compiler. getfield_tfunc (𝕃, thistype, Const (field))
128128 this = @insert_instruction_here (compact, line, settings, getfield (this, field):: fieldtype )
129129 end
130130 end
@@ -133,42 +133,6 @@ function flatten_arguments_for_callee!(compact::IncrementalCompact, map::Argumen
133133 return list
134134end
135135
136- function _flatten_parameter! (𝕃, compact, argtypes, ntharg, line, settings)
137- list = Any[]
138- for (argn, argt) in enumerate (argtypes)
139- if isa (argt, Const)
140- continue
141- elseif Base. issingletontype (argt)
142- continue
143- elseif Base. isprimitivetype (argt) || isa (argt, Incidence)
144- push! (list, ntharg (argn))
145- elseif argt === equation || isa (argt, Eq)
146- continue
147- elseif isa (argt, Type) && argt <: Intrinsics.AbstractScope
148- continue
149- elseif isabstracttype (argt) || ismutabletype (argt) || (! isa (argt, DataType) && ! isa (argt, PartialStruct))
150- continue
151- else
152- if ! isa (argt, PartialStruct) && Base. datatype_fieldcount (argt) === nothing
153- continue
154- end
155- this = ntharg (argn)
156- nthfield (i) = @insert_instruction_here (compact, line, settings, getfield (this, i):: Compiler.getfield_tfunc (𝕃, argextype (this, compact), Const (i)))
157- if isa (argt, PartialStruct)
158- fields = _flatten_parameter! (𝕃, compact, argt. fields, nthfield, line, settings)
159- else
160- fields = _flatten_parameter! (𝕃, compact, fieldtypes (argt), nthfield, line, settings)
161- end
162- append! (list, fields)
163- end
164- end
165- return list
166- end
167-
168- function flatten_parameter! (𝕃, compact, argtypes, ntharg, line, settings)
169- return @insert_instruction_here (compact, line, settings, tuple (_flatten_parameter! (𝕃, compact, argtypes, ntharg, line, settings)... ):: Tuple )
170- end
171-
172136remove_variable_and_equation_annotations (argtypes) = Any[widenconst (T) for T in argtypes]
173137
174138function annotate_variables_and_equations (argtypes:: Vector{Any} , map:: ArgumentMap )
0 commit comments