Skip to content

Commit 868c1d6

Browse files
author
Christopher Doris
committed
fix large integer literals
1 parent 414fb91 commit 868c1d6

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/pymacro/_.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ py_macro_assign(body, ans, ex) = push!(body, :($ans = $ex))
149149

150150
py_macro_del(body, var, tmp) = if tmp; push!(body, :($pydel!($var))); end
151151

152+
ismacroexpr(ex, name) = isexpr(ex, :macrocall) && (ex.args[1] === Symbol(name) || ex.args[1] === GlobalRef(Core, Symbol(name)))
153+
152154
function py_macro_lower(st, body, ans, ex; flavour=:expr)
153155

154156
# scalar literals
@@ -158,21 +160,21 @@ function py_macro_lower(st, body, ans, ex; flavour=:expr)
158160
return false
159161

160162
# Int128 literals
161-
elseif isexpr(ex, :macrocall) && ex.args[1] === GlobalRef(Core, Symbol("@int128_str"))
163+
elseif ismacroexpr(ex, "@int128_str")
162164
value = parse(Int128, ex.args[3])
163165
x = get!(pynew, st.consts, value)
164166
py_macro_assign(body, ans, x)
165167
return false
166168

167169
# UInt128 literals
168-
elseif isexpr(ex, :macrocall) && ex.args[1] === GlobalRef(Core, Symbol("@uint128_str"))
170+
elseif ismacroexpr(ex, "@uint128_str")
169171
value = parse(UInt128, ex.args[3])
170172
x = get!(pynew, st.consts, value)
171173
py_macro_assign(body, ans, x)
172174
return false
173175

174176
# big integer literals
175-
elseif isexpr(ex, :macrocall) && ex.args[1] === GlobalRef(Core, Symbol("@big_str"))
177+
elseif ismacroexpr(ex, "@big_str")
176178
value = parse(BigInt, ex.args[3])
177179
x = get!(pynew, st.consts, value)
178180
py_macro_assign(body, ans, x)

0 commit comments

Comments
 (0)