Skip to content

Commit 427d255

Browse files
Merge pull request #306 from SciML/expression
improve expression generation
2 parents 6cb4f23 + 257b287 commit 427d255

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/utils.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
function Base.convert(::Type{Expression}, ex::Expr)
1+
Base.convert(::Type{Expression}, ex::Expr) = Expression(ex)
2+
function Expression(ex;mod=Main)
23
ex.head === :if && (ex = Expr(:call, ifelse, ex.args...))
34
ex.head === :call || throw(ArgumentError("internal representation does not support non-call Expr"))
45

5-
op = eval(ex.args[1]) # HACK
6+
op = getproperty(mod,Symbol(ex.args[1]))
67
args = convert.(Expression, ex.args[2:end])
78

89
return Operation(op, args)

0 commit comments

Comments
 (0)