Skip to content

Commit

Permalink
Merge pull request #458 from JuliaArrays/fe/modarg
Browse files Browse the repository at this point in the history
clean up _module_arg
  • Loading branch information
andyferris authored Jul 2, 2018
2 parents 4cd2f2a + b81a62b commit e5bd424
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/MArray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ macro MArray(ex)
ex = ex.args[1]
n_rng = length(ex.args) - 1
rng_args = [ex.args[i+1].args[1] for i = 1:n_rng]
rngs = [Core.eval(_module_arg ? __module__ : current_module(), ex.args[i+1].args[2]) for i = 1:n_rng]
rngs = [Core.eval(__module__, ex.args[i+1].args[2]) for i = 1:n_rng]
rng_lengths = map(length, rngs)

f = gensym()
Expand Down Expand Up @@ -231,7 +231,7 @@ macro MArray(ex)
ex = ex.args[2]
n_rng = length(ex.args) - 1
rng_args = [ex.args[i+1].args[1] for i = 1:n_rng]
rngs = [Core.eval(_module_arg ? __module__ : current_module(), ex.args[i+1].args[2]) for i = 1:n_rng]
rngs = [Core.eval(__module__, ex.args[i+1].args[2]) for i = 1:n_rng]
rng_lengths = map(length, rngs)

f = gensym()
Expand Down
8 changes: 4 additions & 4 deletions src/MMatrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ macro MMatrix(ex)
error("Use a 2-dimensional comprehension for @MMatrx")
end

rng1 = Core.eval(_module_arg ? __module__ : current_module(), ex.args[2].args[2])
rng2 = Core.eval(_module_arg ? __module__ : current_module(), ex.args[3].args[2])
rng1 = Core.eval(__module__, ex.args[2].args[2])
rng2 = Core.eval(__module__, ex.args[3].args[2])
f = gensym()
f_expr = :($f = (($(ex.args[2].args[1]), $(ex.args[3].args[1])) -> $(ex.args[1])))
exprs = [:($f($j1, $j2)) for j1 in rng1, j2 in rng2]
Expand All @@ -182,8 +182,8 @@ macro MMatrix(ex)
error("Use a 2-dimensional comprehension for @MMatrx")
end

rng1 = Core.eval(_module_arg ? __module__ : current_module(), ex.args[2].args[2])
rng2 = Core.eval(_module_arg ? __module__ : current_module(), ex.args[3].args[2])
rng1 = Core.eval(__module__, ex.args[2].args[2])
rng2 = Core.eval(__module__, ex.args[3].args[2])
f = gensym()
f_expr = :($f = (($(ex.args[2].args[1]), $(ex.args[3].args[1])) -> $(ex.args[1])))
exprs = [:($f($j1, $j2)) for j1 in rng1, j2 in rng2]
Expand Down
4 changes: 2 additions & 2 deletions src/MVector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ macro MVector(ex)
error("Use a one-dimensional comprehension for @MVector")
end

rng = Core.eval(_module_arg ? __module__ : current_module(), ex.args[2].args[2])
rng = Core.eval(__module__, ex.args[2].args[2])
f = gensym()
f_expr = :($f = ($(ex.args[2].args[1]) -> $(ex.args[1])))
exprs = [:($f($j)) for j in rng]
Expand All @@ -86,7 +86,7 @@ macro MVector(ex)
error("Use a one-dimensional comprehension for @MVector")
end

rng = Core.eval(_module_arg ? __module__ : current_module(), ex.args[2].args[2])
rng = Core.eval(__module__, ex.args[2].args[2])
f = gensym()
f_expr = :($f = ($(ex.args[2].args[1]) -> $(ex.args[1])))
exprs = [:($f($j)) for j in rng]
Expand Down
4 changes: 2 additions & 2 deletions src/SArray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ macro SArray(ex)
ex = ex.args[1]
n_rng = length(ex.args) - 1
rng_args = [ex.args[i+1].args[1] for i = 1:n_rng]
rngs = Any[Core.eval(_module_arg ? __module__ : current_module(), ex.args[i+1].args[2]) for i = 1:n_rng]
rngs = Any[Core.eval(__module__, ex.args[i+1].args[2]) for i = 1:n_rng]
rng_lengths = map(length, rngs)

f = gensym()
Expand Down Expand Up @@ -180,7 +180,7 @@ macro SArray(ex)
ex = ex.args[2]
n_rng = length(ex.args) - 1
rng_args = [ex.args[i+1].args[1] for i = 1:n_rng]
rngs = [Core.eval(_module_arg ? __module__ : current_module(), ex.args[i+1].args[2]) for i = 1:n_rng]
rngs = [Core.eval(__module__, ex.args[i+1].args[2]) for i = 1:n_rng]
rng_lengths = map(length, rngs)

f = gensym()
Expand Down
8 changes: 4 additions & 4 deletions src/SMatrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ macro SMatrix(ex)
error("Use a 2-dimensional comprehension for @SMatrix")
end

rng1 = Core.eval(_module_arg ? __module__ : current_module(), ex.args[2].args[2])
rng2 = Core.eval(_module_arg ? __module__ : current_module(), ex.args[3].args[2])
rng1 = Core.eval(__module__, ex.args[2].args[2])
rng2 = Core.eval(__module__, ex.args[3].args[2])
f = gensym()
f_expr = :($f = (($(ex.args[2].args[1]), $(ex.args[3].args[1])) -> $(ex.args[1])))
exprs = [:($f($j1, $j2)) for j1 in rng1, j2 in rng2]
Expand All @@ -152,8 +152,8 @@ macro SMatrix(ex)
error("Use a 2-dimensional comprehension for @SMatrix")
end

rng1 = Core.eval(_module_arg ? __module__ : current_module(), ex.args[2].args[2])
rng2 = Core.eval(_module_arg ? __module__ : current_module(), ex.args[3].args[2])
rng1 = Core.eval(__module__, ex.args[2].args[2])
rng2 = Core.eval(__module__, ex.args[3].args[2])
f = gensym()
f_expr = :($f = (($(ex.args[2].args[1]), $(ex.args[3].args[1])) -> $(ex.args[1])))
exprs = [:($f($j1, $j2)) for j1 in rng1, j2 in rng2]
Expand Down
4 changes: 2 additions & 2 deletions src/SVector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ macro SVector(ex)
error("Use a one-dimensional comprehension for @SVector")
end

rng = Core.eval(_module_arg ? __module__ : current_module(), ex.args[2].args[2])
rng = Core.eval(__module__, ex.args[2].args[2])
f = gensym()
f_expr = :($f = ($(ex.args[2].args[1]) -> $(ex.args[1])))
exprs = [:($f($j)) for j in rng]
Expand All @@ -77,7 +77,7 @@ macro SVector(ex)
error("Use a one-dimensional comprehension for @SVector")
end

rng = Core.eval(_module_arg ? __module__ : current_module(), ex.args[2].args[2])
rng = Core.eval(__module__, ex.args[2].args[2])
f = gensym()
f_expr = :($f = ($(ex.args[2].args[1]) -> $(ex.args[1])))
exprs = [:($f($j)) for j in rng]
Expand Down
2 changes: 0 additions & 2 deletions src/StaticArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ export @MVector, @MMatrix, @MArray
export similar_type
export push, pop, pushfirst, popfirst, insert, deleteat, setindex

const _module_arg = isdefined(Base, Symbol("@__MODULE__"))

"""
abstract type StaticArray{S, T, N} <: AbstractArray{T, N} end
StaticScalar{T} = StaticArray{Tuple{}, T, 0}
Expand Down

0 comments on commit e5bd424

Please sign in to comment.