Skip to content

Commit dd68598

Browse files
mlechugiordano
authored andcommitted
Try removing stmt lowering option
1 parent d94ff3b commit dd68598

File tree

6 files changed

+16
-26
lines changed

6 files changed

+16
-26
lines changed

Diff for: src/ast.c

+6-7
Original file line numberDiff line numberDiff line change
@@ -1277,9 +1277,8 @@ JL_DLLEXPORT jl_value_t *jl_macroexpand1(jl_value_t *expr, jl_module_t *inmodule
12771277

12781278
// Main entry point to flisp lowering. Most arguments are optional; see `jl_lower_expr_mod`.
12791279
// warn: Print any lowering warnings returned; otherwise ignore
1280-
// stmt: Lower knowing that the value of expr is unused
12811280
JL_DLLEXPORT jl_value_t *jl_fl_lower(jl_value_t *expr, jl_module_t *inmodule,
1282-
const char *file, int line, size_t world, bool_t warn, bool_t stmt)
1281+
const char *file, int line, size_t world, bool_t warn)
12831282
{
12841283
JL_TIMING(LOWERING, LOWERING);
12851284
jl_timing_show_location(file, line, inmodule, JL_TIMING_DEFAULT_BLOCK);
@@ -1290,8 +1289,8 @@ JL_DLLEXPORT jl_value_t *jl_fl_lower(jl_value_t *expr, jl_module_t *inmodule,
12901289
jl_ast_context_t *ctx = jl_ast_ctx_enter(inmodule);
12911290
fl_context_t *fl_ctx = &ctx->fl;
12921291
value_t arg = julia_to_scm(fl_ctx, expr);
1293-
value_t e = fl_applyn(fl_ctx, 4, symbol_value(symbol(fl_ctx, "jl-lower-to-thunk")), arg,
1294-
symbol(fl_ctx, file), fixnum(line), stmt ? fl_ctx->T : fl_ctx->F);
1292+
value_t e = fl_applyn(fl_ctx, 3, symbol_value(symbol(fl_ctx, "jl-lower-to-thunk")), arg,
1293+
symbol(fl_ctx, file), fixnum(line));
12951294
value_t lwr = car_(e);
12961295
value_t warnings = car_(cdr_(e));
12971296
expr = scm_to_julia(fl_ctx, lwr, inmodule);
@@ -1326,15 +1325,15 @@ JL_DLLEXPORT jl_value_t *jl_fl_lower(jl_value_t *expr, jl_module_t *inmodule,
13261325

13271326
// Lower an expression tree into Julia's intermediate-representation.
13281327
JL_DLLEXPORT jl_value_t *jl_lower(jl_value_t *expr, jl_module_t *inmodule,
1329-
const char *file, int line, size_t world, bool_t warn, bool_t stmt)
1328+
const char *file, int line, size_t world, bool_t warn)
13301329
{
13311330
// TODO: Allow change of lowerer
1332-
return jl_fl_lower(expr, inmodule, file, line, world, warn, stmt);
1331+
return jl_fl_lower(expr, inmodule, file, line, world, warn);
13331332
}
13341333

13351334
JL_DLLEXPORT jl_value_t *jl_lower_expr_mod(jl_value_t *expr, jl_module_t *inmodule)
13361335
{
1337-
return jl_lower(expr, inmodule, "none", 0, ~(size_t)0, 0, 0);
1336+
return jl_lower(expr, inmodule, "none", 0, ~(size_t)0, 0);
13381337
}
13391338

13401339
jl_code_info_t *jl_outer_ctor_body(jl_value_t *thistype, size_t nfields, size_t nsparams, jl_module_t *inmodule, const char *file, int line)

Diff for: src/jlfrontend.scm

+3-11
Original file line numberDiff line numberDiff line change
@@ -167,17 +167,11 @@
167167
(error-wrap (lambda ()
168168
(lower-toplevel-expr expr file line))))
169169

170-
(define (lower-to-thunk-stmt- expr file line)
171-
(lower-to-thunk- (if (toplevel-only-expr? expr)
172-
expr
173-
`(block ,expr (null)))
174-
file line))
175-
176170
;; Returns a list `(,lowered-code ,warnings) where
177171
;; - warnings (currently only ambiguous soft scope assignments) may be ignored,
178172
;; e.g. when running interactively
179173
;; - more items may be added to the list later
180-
(define (jl-lower-to-thunk expr file line stmt)
174+
(define (jl-lower-to-thunk expr file line)
181175
(let ((warnings '()))
182176
(with-bindings
183177
;; Abuse scm_to_julia here to convert arguments to warn. This is meant for
@@ -187,10 +181,8 @@
187181
(let ((line (if (= warn_line 0) line warn_line))
188182
(file (if (eq? warn_file 'none) file warn_file)))
189183
(set! warnings (cons (list* 'warn level group (symbol (string file line)) file line lst) warnings))))))
190-
(let ((thunk (if stmt
191-
(lower-to-thunk-stmt- expr file line)
192-
(lower-to-thunk- expr file line))))
193-
`(,thunk ,(reverse warnings))))))
184+
`(,(lower-to-thunk- expr file line)
185+
,(reverse warnings)))))
194186

195187
(define (jl-expand-macroscope expr)
196188
(error-wrap (lambda ()

Diff for: src/julia.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -2258,7 +2258,7 @@ JL_DLLEXPORT jl_value_t *jl_parse_string(const char *text, size_t text_len,
22582258
// lowering
22592259
JL_DLLEXPORT jl_value_t *jl_lower(jl_value_t *expr, jl_module_t *inmodule,
22602260
const char *file, int line, size_t world,
2261-
bool_t warn, bool_t stmt);
2261+
bool_t warn);
22622262
JL_DLLEXPORT jl_value_t *jl_lower_expr_mod(jl_value_t *expr, jl_module_t *inmodule);
22632263
// deprecated; use jl_parse_all
22642264
JL_DLLEXPORT jl_value_t *jl_parse_input_line(const char *text, size_t text_len,

Diff for: src/toplevel.c

+4-5
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ static jl_value_t *jl_eval_module_expr(jl_module_t *parent_module, jl_expr_t *ex
196196
for (int i = 0; i < jl_array_nrows(exprs); i++) {
197197
// process toplevel form
198198
ct->world_age = jl_atomic_load_acquire(&jl_world_counter);
199-
form = jl_lower(jl_array_ptr_ref(exprs, i), newm, filename, lineno, ~(size_t)0, 0, 1);
199+
form = jl_lower(jl_array_ptr_ref(exprs, i), newm, filename, lineno, ~(size_t)0, 0);
200200
ct->world_age = jl_atomic_load_acquire(&jl_world_counter);
201201
(void)jl_toplevel_eval_flex(newm, form, 1, 1, &filename, &lineno);
202202
}
@@ -808,7 +808,7 @@ JL_DLLEXPORT jl_value_t *jl_toplevel_eval_flex(jl_module_t *JL_NONNULL m, jl_val
808808
size_t last_age = ct->world_age;
809809
if (!expanded && jl_needs_lowering(e)) {
810810
ct->world_age = jl_atomic_load_acquire(&jl_world_counter);
811-
ex = (jl_expr_t*)jl_lower(e, m, *toplevel_filename, *toplevel_lineno, ~(size_t)0, 1, 0);
811+
ex = (jl_expr_t*)jl_lower(e, m, *toplevel_filename, *toplevel_lineno, ~(size_t)0, 1);
812812
ct->world_age = last_age;
813813
}
814814
jl_sym_t *head = jl_is_expr(ex) ? ex->head : NULL;
@@ -972,7 +972,7 @@ JL_DLLEXPORT jl_value_t *jl_toplevel_eval_flex(jl_module_t *JL_NONNULL m, jl_val
972972
root = jl_array_ptr_ref(ex->args, i);
973973
if (jl_needs_lowering(root)) {
974974
ct->world_age = jl_atomic_load_acquire(&jl_world_counter);
975-
root = jl_lower(root, m, *toplevel_filename, *toplevel_lineno, ~(size_t)0, 1, 0);
975+
root = jl_lower(root, m, *toplevel_filename, *toplevel_lineno, ~(size_t)0, 1);
976976
}
977977
ct->world_age = jl_atomic_load_acquire(&jl_world_counter);
978978
res = jl_toplevel_eval_flex(m, root, fast, 1, toplevel_filename, toplevel_lineno);
@@ -1151,8 +1151,7 @@ static jl_value_t *jl_parse_eval_all(jl_module_t *module, jl_value_t *text,
11511151
continue;
11521152
}
11531153
ct->world_age = jl_atomic_load_relaxed(&jl_world_counter);
1154-
expression = jl_lower(expression, module,
1155-
jl_string_data(filename), lineno, ~(size_t)0, 1, 0);
1154+
expression = jl_lower(expression, module, jl_string_data(filename), lineno, ~(size_t)0, 1);
11561155
ct->world_age = jl_atomic_load_relaxed(&jl_world_counter);
11571156
result = jl_toplevel_eval_flex(module, expression, 1, 1, &filename_str, &lineno);
11581157
}

Diff for: stdlib/REPL/src/REPL.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ const install_packages_hooks = Any[]
297297
# We need to do this for both the actual eval and macroexpand, since the latter can cause custom macro
298298
# code to run (and error).
299299
__repl_entry_lower_with_loc(mod::Module, @nospecialize(ast), toplevel_file::Ref{Ptr{UInt8}}, toplevel_line::Ref{Cint}) =
300-
ccall(:jl_lower, Any, (Any, Any, Ptr{UInt8}, Cint, Csize_t, Cint, Cint), ast, mod, toplevel_file[], toplevel_line[], typemax(Csize_t), 0, 0)
300+
ccall(:jl_lower, Any, (Any, Any, Ptr{UInt8}, Cint, Csize_t, Cint), ast, mod, toplevel_file[], toplevel_line[], typemax(Csize_t), 0)
301301
__repl_entry_eval_expanded_with_loc(mod::Module, @nospecialize(ast), toplevel_file::Ref{Ptr{UInt8}}, toplevel_line::Ref{Cint}) =
302302
ccall(:jl_toplevel_eval_flex, Any, (Any, Any, Cint, Cint, Ptr{Ptr{UInt8}}, Ptr{Cint}), mod, ast, 1, 1, toplevel_file, toplevel_line)
303303

Diff for: test/meta.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ let ex = Meta.parseall("@foo", filename=:bar)
234234
@test isa(arg2arg2, LineNumberNode) && arg2arg2.file === :bar
235235
end
236236

237-
_lower(m::Module, ex, world::UInt) = ccall(:jl_lower, Any, (Any, Ref{Module}, Cstring, Cint, Csize_t, Cint, Cint), ex, m, "none", 0, world, 0, 0)
237+
_lower(m::Module, ex, world::UInt) = ccall(:jl_lower, Any, (Any, Ref{Module}, Cstring, Cint, Csize_t, Cint), ex, m, "none", 0, world, 0)
238238

239239
module TestExpandInWorldModule
240240
macro m() 1 end

0 commit comments

Comments
 (0)