Skip to content

Commit 4740d6e

Browse files
committed
Generate handles
1 parent 14b125a commit 4740d6e

File tree

2 files changed

+5117
-1279
lines changed

2 files changed

+5117
-1279
lines changed

gen/generator.jl

+5-1
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,20 @@ build!(ctx, BUILDSTAGE_NO_PRINTING)
2121
function rewrite!(dag::ExprDAG)
2222
for node in get_nodes(dag)
2323
node.type isa Generators.AbstractFunctionNodeType || continue
24+
func_name = string(node.id)
25+
handle = Symbol(func_name*"_handle")
2426
for expr in node.exprs
2527
Meta.isexpr(expr, :function) || continue
2628
for block_expr in expr.args
2729
Meta.isexpr(block_expr, :block) || continue
2830
for ccall_expr in block_expr.args
2931
Meta.isexpr(ccall_expr, :call) || continue
30-
ccall_expr.args[2] = :(getprocaddress_e($(string(node.id))))
32+
ccall_expr.args[2] = :($handle[])
3133
end
34+
pushfirst!(block_expr.args, :($handle[] == C_NULL && ($handle[] = getprocaddress_e($func_name))))
3235
end
3336
end
37+
pushfirst!(node.exprs, :(const $handle = Ref{Ptr{Cvoid}}()))
3438
end
3539
end
3640

0 commit comments

Comments
 (0)