Skip to content

Commit

Permalink
for v1.0 compat, not to depend Base.@Locals
Browse files Browse the repository at this point in the history
  • Loading branch information
thautwarm committed Feb 1, 2019
1 parent b94a8a9 commit 3b352bc
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ os:
- osx

julia:
- 1.0
- 1.1
- nightly
notifications:
Expand Down
4 changes: 0 additions & 4 deletions src/Infras.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ macro format(args, template)
esc(format(args, template))
end

macro format(template)
esc(format(template))
end

export @typed_as
"""
this macro provide a convenient and type-stable way to generate
Expand Down
6 changes: 3 additions & 3 deletions src/MatchCore.jl
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,9 @@ end
function mk_match_body(target, tag_sym, cbl, mod)
bind(getBy $ loc) do loc # start 1
final =
@format [loc] quote
@format [loc, throw, InternalException] quote
loc
throw(($InternalException)("Non-exhaustive pattern found!"))
throw(InternalException("Non-exhaustive pattern found!"))
end
result = mangle(mod)
cbl = collect(cbl)
Expand All @@ -244,7 +244,7 @@ function mk_match_body(target, tag_sym, cbl, mod)
result === failed ? last : result
end
end # end 2
return! $ @format quote
return! $ @format [tag_sym, target, main_logic] quote
let tag_sym = target
main_logic
end
Expand Down
3 changes: 2 additions & 1 deletion src/Pervasives.jl
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,9 @@ function ordered_seq_match(tag, elts, mod)

TARGET = mangle(mod)
NAME = mangle(mod)
T = mangle(mod)
function check_generic_array(body)
@format [AbstractArray] quote
@format [AbstractArray, NAME, TARGET, body, T, tag] quote

@inline __L__ function NAME(TARGET :: AbstractArray{T, 1}) where {T}
body
Expand Down
5 changes: 4 additions & 1 deletion src/Render.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,13 @@ function format(args, template)
function dispatch(_)
throw("Unknown argtype")
end

constlist = map(dispatch, args.args)
constlist = Expr(:vect, constlist...)
config = Expr(:call, Dict{Symbol, Any}, constlist)
Expr(:call, render, template, Expr(:call, merge, :(Base.@locals), config))

wrap = @static VERSION < v"1.1.0" ? (x -> x) : (x -> Expr(:call, merge, :(Base.@locals), x))
Expr(:call, render, template, wrap(config))
end

function format(template)
Expand Down

0 comments on commit 3b352bc

Please sign in to comment.