Skip to content

Commit d03e0ef

Browse files
arguments wraps BasicSymbolicImpl and MetadataImpl
Co-authored-by: Aayush Sabharwal <aayush.sabharwal@gmail.com>
1 parent 2fcac04 commit d03e0ef

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/types.jl

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,18 @@ struct MetadataImpl
6868
children::Vector{Any}
6969
end
7070

71+
function MetadataImpl()
72+
MetadataImpl(nothing, Vector())
73+
end
74+
7175
@kwdef struct BasicSymbolic{T} <: Symbolic{T}
7276
expr::BasicSymbolicImpl{T}
7377
meta::MetadataImpl
7478
end
7579

80+
getmetaimpl(x::BasicSymbolic) = x.meta
81+
getmetaimpl(::Any) = nothing
82+
7683
function SymbolicIndexingInterface.symbolic_type(::Type{<:BasicSymbolic})
7784
ScalarSymbolic()
7885
end
@@ -210,7 +217,19 @@ end
210217
TermInterface.children(x::BasicSymbolic) = arguments(x)
211218
TermInterface.sorted_children(x::BasicSymbolic) = sorted_arguments(x)
212219
function TermInterface.arguments(x::BasicSymbolic)
213-
arguments(x.expr)
220+
args = arguments(x.expr)
221+
args_metadata = x.meta.children
222+
res = Vector()
223+
for (arg, meta) in zip(args, args_metadata)
224+
if arg isa BasicSymbolicImpl
225+
if isnothing(meta)
226+
meta = MetadataImpl()
227+
end
228+
arg = BasicSymbolic(arg, meta)
229+
end
230+
push!(res, arg)
231+
end
232+
res
214233
end
215234
function TermInterface.arguments(x::BasicSymbolicImpl)
216235
@compactified x::BasicSymbolicImpl begin

0 commit comments

Comments
 (0)