Skip to content

Commit 3e51701

Browse files
committed
Use macro expansion ctx param
Doesn't handle hygiene yet, but necessary for it. TODO: We cannot handle intentional un-hygiene from the user with the current data structures, as far as I'm aware.
1 parent 46ee307 commit 3e51701

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/compat.jl

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,17 @@ Expr-producing macros. Always prefer re-parsing source text over using this.
1919
2020
Supports parsed and/or macro-expanded exprs, but not lowered exprs
2121
"""
22-
function expr_to_syntaxtree(@nospecialize(e), lnn::Union{LineNumberNode, Nothing}=nothing)
23-
graph = SyntaxGraph()
24-
ensure_attributes!(graph,
25-
kind=Kind, syntax_flags=UInt16,
26-
source=SourceAttrType, var_id=Int, value=Any,
27-
name_val=String, is_toplevel_thunk=Bool)
22+
function expr_to_syntaxtree(@nospecialize(e),
23+
mctx::Union{MacroExpansionContext, Nothing}=nothing,
24+
lnn::Union{LineNumberNode, Nothing}=nothing)
25+
graph = if isnothing(mctx)
26+
ensure_attributes!(SyntaxGraph(),
27+
kind=Kind, syntax_flags=UInt16,
28+
source=SourceAttrType, var_id=Int, value=Any,
29+
name_val=String, is_toplevel_thunk=Bool)
30+
else
31+
mctx.graph
32+
end
2833
toplevel_src = if isnothing(lnn)
2934
# Provenance sinkhole for all nodes until we hit a linenode
3035
dummy_src = SourceRef(

0 commit comments

Comments
 (0)