Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/data.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import OrderedCollections
import StaticArraysCore
document[:Base] = Symbol[]

const FLAG_EXPLAIN_EXPRESSION = Ref(false)

#= ============================ =#
# IDS and IDSvector structures #
#= ============================ =#
Expand Down Expand Up @@ -398,10 +400,27 @@ function _getproperty(@nospecialize(ids::IDS), field::Symbol)

elseif !isfrozen(ids)
# expressions
if FLAG_EXPLAIN_EXPRESSION[]
expr_info_dict = get_expr_info_dict(Val{:onetime_and_dynamic})
end
uloc = ulocation(ids, field)
for (onetime, expressions) in zip((true, false), (get_expressions(Val{:onetime}), get_expressions(Val{:dynamic})))
if uloc ∈ keys(expressions)
func = expressions[uloc]

if FLAG_EXPLAIN_EXPRESSION[]
show(stdout, "text/plain", expr_info_dict[uloc])

# To get the result of this expression, turning off the FLAG temporarily
FLAG_EXPLAIN_EXPRESSION[] = false
value = exec_expression_with_ancestor_args(ids, field, func)
FLAG_EXPLAIN_EXPRESSION[] = true

# Display the result
printstyled("[Result]\n"; color=:blue)
display(value)
print("\n")
end
value = exec_expression_with_ancestor_args(ids, field, func)
if typeof(value) <: Exception
# check in the reference
Expand Down
5 changes: 5 additions & 0 deletions src/expressions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ function get_expressions(::Type{Val{T}}) where {T}
return Dict{String,Function}()
end

function get_expr_info_dict(::Type{Val{T}}) where {T}
# This is just a place holder, the actual second argument will be "ExprInfo" struct defined in IMAS
return Dict{String,Any}()
end

const expression_onetime_weakref = Dict{UInt64,WeakRef}()

"""
Expand Down