Skip to content

Replace MacroTools with ExprTools & Base.remove_lines! #2425

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 29, 2024
Merged
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
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
DomainSets = "5b8099bc-c8ec-5219-889f-1d9e522a28bf"
DynamicQuantities = "06fc5a27-2a28-4c7c-a15d-362465fb6821"
ExprTools = "e2ba6199-217a-4e67-a87a-7c52f15ade04"
FindFirstFunctions = "64ca27bc-2ba2-4a57-88aa-44e436879224"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
FunctionWrappersWrappers = "77dc65aa-8811-40c2-897b-53d922fa7daf"
Expand All @@ -31,7 +32,6 @@ Latexify = "23fbe1c1-3f47-55db-b15f-69d7ec21a316"
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
MLStyle = "d8e11817-5142-5d16-987a-aa16d5891078"
MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
NaNMath = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3"
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
Expand Down Expand Up @@ -75,6 +75,7 @@ Distributions = "0.23, 0.24, 0.25"
DocStringExtensions = "0.7, 0.8, 0.9"
DomainSets = "0.6"
DynamicQuantities = "^0.11.2"
ExprTools = "0.1.10"
FindFirstFunctions = "1"
ForwardDiff = "0.10.3"
FunctionWrappersWrappers = "0.1"
Expand All @@ -88,7 +89,6 @@ Latexify = "0.11, 0.12, 0.13, 0.14, 0.15, 0.16"
Libdl = "1"
LinearAlgebra = "1"
MLStyle = "0.4.17"
MacroTools = "0.5"
NaNMath = "0.3, 1"
OrdinaryDiffEq = "6"
PrecompileTools = "1"
Expand Down
3 changes: 1 addition & 2 deletions src/ModelingToolkit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ using PrecompileTools, Reexport
using StaticArrays, LinearAlgebra, SparseArrays, LabelledArrays
using InteractiveUtils
using Latexify, Unitful, ArrayInterface
using MacroTools
using Setfield, ConstructionBase
using JumpProcesses
using DataStructures
Expand All @@ -23,7 +22,7 @@ using PrecompileTools, Reexport
using Base.Threads
using DiffEqCallbacks
using Graphs
import MacroTools: splitdef, combinedef, postwalk, striplines
import ExprTools: splitdef, combinedef
import Libdl
using DocStringExtensions
using Base: RefValue
Expand Down
2 changes: 1 addition & 1 deletion src/systems/abstractsystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ function toexpr(sys::AbstractSystem)
name = $name, checks = false)))
end

striplines(expr) # keeping the line numbers is never helpful
Base.remove_linenums!(expr) # keeping the line numbers is never helpful
end

Base.write(io::IO, sys::AbstractSystem) = write(io, readable_code(toexpr(sys)))
Expand Down
10 changes: 5 additions & 5 deletions src/systems/diffeqs/abstractodesystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ function ODEFunctionExpr{iip}(sys::AbstractODESystem, dvs = states(sys),
sparsity = $(sparsity ? jacobian_sparsity(sys) : nothing),
observed = $observedfun_exp)
end
!linenumbers ? striplines(ex) : ex
!linenumbers ? Base.remove_linenums!(ex) : ex
end

"""
Expand Down Expand Up @@ -886,7 +886,7 @@ function DAEFunctionExpr{iip}(sys::AbstractODESystem, dvs = states(sys),
$_f
ODEFunction{$iip}($fsym)
end
!linenumbers ? striplines(ex) : ex
!linenumbers ? Base.remove_linenums!(ex) : ex
end

function DAEFunctionExpr(sys::AbstractODESystem, args...; kwargs...)
Expand Down Expand Up @@ -1201,7 +1201,7 @@ function ODEProblemExpr{iip}(sys::AbstractODESystem, u0map, tspan,
p = $p
$odep
end
!linenumbers ? striplines(ex) : ex
!linenumbers ? Base.remove_linenums!(ex) : ex
end

function ODEProblemExpr(sys::AbstractODESystem, args...; kwargs...)
Expand Down Expand Up @@ -1250,7 +1250,7 @@ function DAEProblemExpr{iip}(sys::AbstractODESystem, du0map, u0map, tspan,
differential_vars = $differential_vars
$prob
end
!linenumbers ? striplines(ex) : ex
!linenumbers ? Base.remove_linenums!(ex) : ex
end

function DAEProblemExpr(sys::AbstractODESystem, args...; kwargs...)
Expand Down Expand Up @@ -1320,7 +1320,7 @@ function SteadyStateProblemExpr{iip}(sys::AbstractODESystem, u0map,
p = $p
$prob
end
!linenumbers ? striplines(ex) : ex
!linenumbers ? Base.remove_linenums!(ex) : ex
end

function SteadyStateProblemExpr(sys::AbstractODESystem, args...; kwargs...)
Expand Down
4 changes: 2 additions & 2 deletions src/systems/diffeqs/sdesystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ function SDEFunctionExpr{iip}(sys::SDESystem, dvs = states(sys),
indepsym = $(Symbol(get_iv(sys))),
paramsyms = $(Symbol.(parameters(sys))))
end
!linenumbers ? striplines(ex) : ex
!linenumbers ? Base.remove_linenums!(ex) : ex
end

function SDEFunctionExpr(sys::SDESystem, args...; kwargs...)
Expand Down Expand Up @@ -656,7 +656,7 @@ function SDEProblemExpr{iip}(sys::SDESystem, u0map, tspan,
SDEProblem(f, u0, tspan, p; noise_rate_prototype = noise_rate_prototype,
$(kwargs...))
end
!linenumbers ? striplines(ex) : ex
!linenumbers ? Base.remove_linenums!(ex) : ex
end

function SDEProblemExpr(sys::SDESystem, args...; kwargs...)
Expand Down
4 changes: 2 additions & 2 deletions src/systems/discrete_system/discrete_system.jl
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ function DiscreteFunctionExpr{iip}(sys::DiscreteSystem, dvs = states(sys),
indepsym = $(QuoteNode(Symbol(get_iv(sys)))),
paramsyms = $(Symbol.(parameters(sys))))
end
!linenumbers ? striplines(ex) : ex
!linenumbers ? Base.remove_linenums!(ex) : ex
end

function DiscreteFunctionExpr(sys::DiscreteSystem, args...; kwargs...)
Expand Down Expand Up @@ -460,5 +460,5 @@ function DiscreteProblemExpr{iip}(sys::DiscreteSystem, u0map, tspan,
tspan = $tspan
DiscreteProblem(f, u0, tspan, p; $(filter_kwargs(kwargs)...))
end
!linenumbers ? striplines(ex) : ex
!linenumbers ? Base.remove_linenums!(ex) : ex
end
4 changes: 2 additions & 2 deletions src/systems/nonlinear/nonlinearsystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ function NonlinearFunctionExpr{iip}(sys::NonlinearSystem, dvs = states(sys),
syms = $(Symbol.(states(sys))),
paramsyms = $(Symbol.(parameters(sys))))
end
!linenumbers ? striplines(ex) : ex
!linenumbers ? Base.remove_linenums!(ex) : ex
end

function process_NonlinearProblem(constructor, sys::NonlinearSystem, u0map, parammap;
Expand Down Expand Up @@ -406,7 +406,7 @@ function NonlinearProblemExpr{iip}(sys::NonlinearSystem, u0map,
p = $p
NonlinearProblem(f, u0, p; $(filter_kwargs(kwargs)...))
end
!linenumbers ? striplines(ex) : ex
!linenumbers ? Base.remove_linenums!(ex) : ex
end

function flatten(sys::NonlinearSystem, noeqs = false)
Expand Down