Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
9932de3
Update CodeInfo struct and handling
mlechu Mar 28, 2025
375f474
Don't produce raw symbol from globalref
mlechu Mar 31, 2025
0e94978
Updates to const and global lowering; add K"constdecl"; omit `wrap`
mlechu Apr 1, 2025
b1c0b09
Add `isdefinedglobal` builtin
mlechu Apr 1, 2025
7d2efca
:global no longer valid_ir_argument; rm `is_defined_nothrow_global`
mlechu Apr 1, 2025
950b87c
Fix `is_defined_and_owned_global` (Core.Binding changes)
mlechu Apr 17, 2025
7194d9b
Struct desugaring: "Undo decision to publish incomplete types..."
mlechu Apr 1, 2025
32aab4f
Emit `latestworld` world age increments
mlechu Apr 2, 2025
1501b34
bpart changes: `Core._typebody!` signature
mlechu Apr 4, 2025
e1d3444
bpart changes: struct desugaring
mlechu Apr 18, 2025
ed91f96
Additional argument in `new_opaque_closure`
mlechu Apr 4, 2025
0dd6c87
Adapt to different `GeneratedFunctionStub` signature
mlechu Apr 8, 2025
af6a509
Fix `public` and `export`
mlechu Apr 8, 2025
fd8dd63
Fix modules.jl test
mlechu Apr 8, 2025
4f5c877
Regenerate IR tests
mlechu Apr 30, 2025
dda8afd
Update README to known-good julia, JuliaSyntax versions
mlechu Jun 25, 2025
08f101a
Fix small bug from #16 so tests pass
mlechu Jul 29, 2025
50bd7e4
Changes from code review: const/global lowering
mlechu Jul 30, 2025
ddfa8f1
Changes from code review
mlechu Jul 31, 2025
c1242d1
Remove a special case
mlechu Jul 31, 2025
56422aa
Conversion from Expr and JuliaSyntax bump
mlechu Jun 27, 2025
5c6df5a
Apply suggestions from code review
mlechu Jul 3, 2025
01e33d4
Consistency, comments
mlechu Jul 3, 2025
ebe29ee
Tweaks for macros
mlechu Jul 4, 2025
cc88301
More tiny fixes
mlechu Jul 8, 2025
fb2ea80
Use macro expansion ctx param
mlechu Jul 10, 2025
23bd0c4
Handle Expr-nospecialize
mlechu Jul 11, 2025
ca66fb3
symboliclabel, symbolicgoto
mlechu Jul 11, 2025
98a05bd
Fix `setattr!`
mlechu Jul 11, 2025
2c24aa5
Reorganize some cases; handle ``:[no]inline`
mlechu Jul 11, 2025
bf07c55
Support :flatten
mlechu Jul 14, 2025
44e54b9
Small tweaks
mlechu Jul 16, 2025
96e83c2
Support Expr(:core)
mlechu Jul 17, 2025
ab1768f
Fix some logic bugs from testing
mlechu Jul 18, 2025
247d425
:islocal, :isglobal
mlechu Jul 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ This work is intended to

Note this is a work in progress; many types of syntax are not yet handled.

1. You need a 1.12-DEV build of Julia: At least 1.12.0-DEV.512. Commit `263928f9ad4` is currentl known to work. Note that JuliaLowering relies on Julia internals and may be broken on the latest Julia dev version from time to time. (In fact it is currently broken on the latest `1.12-DEV`.)
2. Check out the main branch of [JuliaSyntax](https://github.com/JuliaLang/JuliaSyntax.jl)
1. You need a 1.13.0-DEV build of Julia: At least 1.13.0-DEV.880. Commit `5ebc5b463ea` is currently known to work. Note that JuliaLowering relies on Julia internals and may be broken on the latest Julia dev version from time to time.
2. Use commit `46723f0` of [JuliaSyntax](https://github.com/JuliaLang/JuliaSyntax.jl)
3. Get the latest version of [JuliaSyntaxFormatter](https://github.com/c42f/JuliaSyntaxFormatter.jl)
4. Run the demo `include("test/demo.jl")`

Expand Down
3 changes: 2 additions & 1 deletion src/JuliaLowering.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ using JuliaSyntax: highlight, Kind, @KSet_str
using JuliaSyntax: is_leaf, children, numchildren, head, kind, flags, has_flags, numeric_flags
using JuliaSyntax: filename, first_byte, last_byte, byte_range, sourcefile, source_location, span, sourcetext

using JuliaSyntax: is_literal, is_number, is_operator, is_prec_assignment, is_prefix_call, is_infix_op_call, is_postfix_op_call, is_error, is_dotted
using JuliaSyntax: is_literal, is_number, is_operator, is_prec_assignment, is_prefix_call, is_infix_op_call, is_postfix_op_call, is_error

_include("kinds.jl")
_register_kinds()
Expand All @@ -32,6 +32,7 @@ _include("runtime.jl")
_include("syntax_macros.jl")

_include("eval.jl")
_include("compat.jl")

function __init__()
_register_kinds()
Expand Down
7 changes: 5 additions & 2 deletions src/ast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -498,17 +498,20 @@ end
# the middle of a pass.
const CompileHints = Base.ImmutableDict{Symbol,Any}

function setmeta(ex::SyntaxTree; kws...)
function setmeta!(ex::SyntaxTree; kws...)
@assert length(kws) == 1 # todo relax later ?
key = first(keys(kws))
value = first(values(kws))
meta = begin
m = get(ex, :meta, nothing)
isnothing(m) ? CompileHints(key, value) : CompileHints(m, key, value)
end
setattr(ex; meta=meta)
setattr!(ex; meta=meta)
ex
end

setmeta(ex::SyntaxTree; kws...) = setmeta!(copy_node(ex); kws...)

function getmeta(ex::SyntaxTree, name::Symbol, default)
meta = get(ex, :meta, nothing)
isnothing(meta) ? default : get(meta, name, default)
Expand Down
23 changes: 17 additions & 6 deletions src/closure_conversion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ function convert_global_assignment(ctx, ex, var, rhs0)
end
push!(stmts, @ast ctx ex [K"=" var rhs])
@ast ctx ex [K"block"
[K"globaldecl" var]
stmts...
rhs1
]
Expand Down Expand Up @@ -337,19 +338,27 @@ function _convert_closures(ctx::ClosureConversionCtx, ex)
elseif binfo.is_always_defined || is_self_captured(ctx, var)
# Captured but unboxed vars are always defined
@ast ctx ex true::K"Bool"
elseif binfo.kind == :global
# Normal isdefined won't work for globals (#56985)
@ast ctx ex [K"call"
"isdefinedglobal"::K"core"
ctx.mod::K"Value"
binfo.name::K"Symbol"
false::K"Bool"]
else
ex
end
elseif k == K"decl"
@assert kind(ex[1]) == K"BindingId"
binfo = lookup_binding(ctx, ex[1])
if binfo.kind == :global
@ast ctx ex [K"call"
"set_binding_type!"::K"core"
binfo.mod::K"Value"
binfo.name::K"Symbol"
_convert_closures(ctx, ex[2])
]
@ast ctx ex [K"block"
# flisp has this, but our K"assert" handling is in a previous pass
# [K"assert" "toplevel_only"::K"Symbol" [K"inert" ex]]
[K"globaldecl"
ex[1]
_convert_closures(ctx, ex[2])]
"nothing"::K"core"]
else
makeleaf(ctx, ex, K"TOMBSTONE")
end
Expand Down Expand Up @@ -382,6 +391,7 @@ function _convert_closures(ctx::ClosureConversionCtx, ex)
type_for_closure(ctx, ex, name_str, field_syms, field_is_box)
if !ctx.is_toplevel_seq_point
push!(ctx.toplevel_stmts, closure_type_def)
push!(ctx.toplevel_stmts, @ast ctx ex [K"latestworld_if_toplevel"])
closure_type_def = nothing
end
closure_info = ClosureInfo(closure_type_, field_syms, field_inds)
Expand All @@ -406,6 +416,7 @@ function _convert_closures(ctx::ClosureConversionCtx, ex)
end
@ast ctx ex [K"block"
closure_type_def
[K"latestworld_if_toplevel"]
closure_type := if isempty(type_params)
closure_type_
else
Expand Down
Loading
Loading