diff --git a/src/operations.jl b/src/operations.jl index 45afdc78b5..9c1146dcd0 100644 --- a/src/operations.jl +++ b/src/operations.jl @@ -63,3 +63,8 @@ Base.convert(::Type{Operation}, x::Number) = Operation(identity, Expression[Cons Base.convert(::Type{Operation}, x::Operation) = x Base.convert(::Type{Operation}, x::Expression) = Operation(identity, Expression[x]) Operation(x) = convert(Operation, x) + +#convert to Expr +Base.Expr(op::Operation) = + op.op isa Variable ? op.op.name : Expr(:call, Symbol(op.op), Expr.(op.args)...) +Base.convert(::Type{Expr},x::Operation) = Expr(x)