koatl 0.1.40__tar.gz → 0.1.41__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {koatl-0.1.40 → koatl-0.1.41}/Cargo.lock +1 -1
- {koatl-0.1.40 → koatl-0.1.41}/PKG-INFO +1 -1
- {koatl-0.1.40 → koatl-0.1.41}/koatl/Cargo.toml +1 -1
- {koatl-0.1.40 → koatl-0.1.41}/koatl-core/parser/src/lib.rs +3 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl-core/src/transform.rs +66 -81
- {koatl-0.1.40 → koatl-0.1.41}/Cargo.toml +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/README.md +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/.github/workflows/CI.yml +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/.gitignore +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/LICENSE +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/README.md +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/python/koatl/__init__.py +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/python/koatl/__main__.py +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/python/koatl/cli.py +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/python/koatl/notebook/__init__.py +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/python/koatl/notebook/magic.py +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/python/koatl/prelude/__init__.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/python/koatl/runtime/__init__.py +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/python/koatl/runtime/meta_finder.py +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/python/koatl/runtime/record.py +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/python/koatl/runtime/vattr.py +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/python/koatl/std/alg/__init__.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/python/koatl/std/alg/async.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/python/koatl/std/alg/base.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/python/koatl/std/alg/do.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/python/koatl/std/alg/env.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/python/koatl/std/alg/memo.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/python/koatl/std/alg/result.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/python/koatl/std/data/__init__.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/python/koatl/std/data/list.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/python/koatl/std/data/record.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/python/koatl/std/ext.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/python/koatl/std/io.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/python/koatl/std/iter.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/python/koatl/std/lazy_module.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/python/koatl/std/re.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/python/koatl/std/trait.py +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/requirements.txt +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/src/emit_py.rs +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/src/lib.rs +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/tests/e2e/base/containers.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/tests/e2e/base/data.txt +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/tests/e2e/base/decorators.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/tests/e2e/base/destructure-for-and-fn.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/tests/e2e/base/destructure.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/tests/e2e/base/escape_ident.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/tests/e2e/base/fstr.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/tests/e2e/base/functions.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/tests/e2e/base/generator.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/tests/e2e/base/if_expr.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/tests/e2e/base/loops.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/tests/e2e/base/match.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/tests/e2e/base/nary-list.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/tests/e2e/base/placeholder.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/tests/e2e/base/precedence.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/tests/e2e/base/scopes.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/tests/e2e/base/semantic_whitespace.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/tests/e2e/base/short_circuit.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/tests/e2e/base/with.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/tests/e2e/prelude/async.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/tests/e2e/prelude/aug_assign.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/tests/e2e/prelude/coal.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/tests/e2e/prelude/env.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/tests/e2e/prelude/imports.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/tests/e2e/prelude/iterables.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/tests/e2e/prelude/list.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/tests/e2e/prelude/memo.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/tests/e2e/prelude/record.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/tests/e2e/prelude/result.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/tests/e2e/prelude/slice.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/tests/e2e/prelude/try.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/tests/e2e/prelude/virtual.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/tests/e2e/util/__init__.py +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/tests/e2e/util/module0.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/tests/e2e/util/module1.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/tests/e2e/util/module2.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/tests/parse/arith.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/tests/parse/assign.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/tests/parse/block-comments.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/tests/parse/deco.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/tests/parse/func.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/tests/parse/matches.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/tests/test_e2e.py +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl/tests/test_parse.py +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl-core/Cargo.toml +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl-core/parser/Cargo.toml +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl-core/parser/src/ast.rs +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl-core/parser/src/lexer.rs +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl-core/parser/src/parser.rs +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl-core/parser/src/util.rs +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl-core/src/inference.rs +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl-core/src/lib.rs +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl-core/src/main.rs +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl-core/src/parse_timer.rs +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl-core/src/parser.rs +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl-core/src/py/ast.rs +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl-core/src/py/emit.rs +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl-core/src/py/mod.rs +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl-core/src/py/util.rs +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl-core/src/resolve_scopes.rs +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl-core/src/types.rs +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/koatl-core/src/util.rs +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/pyproject.toml +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/python/koatl/__init__.py +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/python/koatl/__main__.py +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/python/koatl/cli.py +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/python/koatl/notebook/__init__.py +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/python/koatl/notebook/magic.py +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/python/koatl/prelude/__init__.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/python/koatl/runtime/__init__.py +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/python/koatl/runtime/meta_finder.py +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/python/koatl/runtime/record.py +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/python/koatl/runtime/vattr.py +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/python/koatl/std/alg/__init__.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/python/koatl/std/alg/async.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/python/koatl/std/alg/base.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/python/koatl/std/alg/do.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/python/koatl/std/alg/env.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/python/koatl/std/alg/memo.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/python/koatl/std/alg/result.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/python/koatl/std/data/__init__.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/python/koatl/std/data/list.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/python/koatl/std/data/record.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/python/koatl/std/ext.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/python/koatl/std/io.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/python/koatl/std/iter.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/python/koatl/std/lazy_module.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/python/koatl/std/re.tl +0 -0
- {koatl-0.1.40 → koatl-0.1.41}/python/koatl/std/trait.py +0 -0
|
@@ -177,14 +177,7 @@ impl<'src> PyBlock<'src> {
|
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
179
|
|
|
180
|
-
enum PyBlockExpr<'src> {
|
|
181
|
-
Nothing,
|
|
182
|
-
Never,
|
|
183
|
-
Expr(SPyExpr<'src>),
|
|
184
|
-
}
|
|
185
|
-
|
|
186
180
|
type SPyExprWithPre<'src> = WithPre<'src, SPyExpr<'src>>;
|
|
187
|
-
type PyBlockExprWithPre<'src> = WithPre<'src, PyBlockExpr<'src>>;
|
|
188
181
|
|
|
189
182
|
trait SPyExprWithPreExt<'src> {
|
|
190
183
|
fn drop_expr<'ast>(self, ctx: &mut TlCtx<'src, 'ast>) -> PyBlock<'src>;
|
|
@@ -206,27 +199,6 @@ impl<'src> SPyExprWithPreExt<'src> for SPyExprWithPre<'src> {
|
|
|
206
199
|
}
|
|
207
200
|
}
|
|
208
201
|
|
|
209
|
-
impl<'src> SPyExprWithPreExt<'src> for PyBlockExprWithPre<'src> {
|
|
210
|
-
fn drop_expr<'ast>(self, ctx: &mut TlCtx<'src, 'ast>) -> PyBlock<'src> {
|
|
211
|
-
if let PyBlockExpr::Expr(expr) = self.value {
|
|
212
|
-
SPyExprWithPre {
|
|
213
|
-
pre: self.pre,
|
|
214
|
-
value: expr,
|
|
215
|
-
}
|
|
216
|
-
.drop_expr(ctx)
|
|
217
|
-
} else {
|
|
218
|
-
self.pre
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
trait BlockExt<'src> {
|
|
224
|
-
fn transform<'ast>(
|
|
225
|
-
&'ast self,
|
|
226
|
-
ctx: &mut TlCtx<'src, 'ast>,
|
|
227
|
-
) -> TlResult<PyBlockExprWithPre<'src>>;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
202
|
fn simple_err(msg: impl Into<String>, span: Span) -> TlErrs {
|
|
231
203
|
TlErrBuilder::new().message(msg.into()).span(span).build()
|
|
232
204
|
}
|
|
@@ -254,15 +226,26 @@ fn deduplicate<'src, 'ast>(
|
|
|
254
226
|
Ok(SPyExprWithPre { value: expr, pre })
|
|
255
227
|
}
|
|
256
228
|
|
|
229
|
+
trait BlockExt<'src> {
|
|
230
|
+
fn transform<'ast>(
|
|
231
|
+
&'ast self,
|
|
232
|
+
ctx: &mut TlCtx<'src, 'ast>,
|
|
233
|
+
span: &Span,
|
|
234
|
+
) -> TlResult<SPyExprWithPre<'src>>;
|
|
235
|
+
}
|
|
236
|
+
|
|
257
237
|
impl<'src> BlockExt<'src> for [Indirect<SStmt<'src>>] {
|
|
258
238
|
fn transform<'ast>(
|
|
259
239
|
&'ast self,
|
|
260
240
|
ctx: &mut TlCtx<'src, 'ast>,
|
|
261
|
-
|
|
241
|
+
span: &Span,
|
|
242
|
+
) -> TlResult<SPyExprWithPre<'src>> {
|
|
243
|
+
let mut value = (PyExpr::Literal(PyLiteral::None), *span).into();
|
|
244
|
+
|
|
262
245
|
if self.is_empty() {
|
|
263
|
-
return Ok(
|
|
246
|
+
return Ok(SPyExprWithPre {
|
|
264
247
|
pre: PyBlock::new(),
|
|
265
|
-
value
|
|
248
|
+
value,
|
|
266
249
|
});
|
|
267
250
|
}
|
|
268
251
|
|
|
@@ -289,22 +272,17 @@ impl<'src> BlockExt<'src> for [Indirect<SStmt<'src>>] {
|
|
|
289
272
|
}
|
|
290
273
|
|
|
291
274
|
let final_stmt = iter.next().unwrap();
|
|
292
|
-
let mut value = PyBlockExpr::Nothing;
|
|
293
275
|
|
|
294
276
|
match &final_stmt.value {
|
|
295
277
|
Stmt::Expr(expr) => match expr.transform(ctx) {
|
|
296
278
|
Ok(expr_with_aux) => {
|
|
297
|
-
value =
|
|
279
|
+
value = pre.bind(expr_with_aux);
|
|
298
280
|
}
|
|
299
281
|
Err(e) => {
|
|
300
282
|
errs.extend(e.0);
|
|
301
283
|
ok = false;
|
|
302
284
|
}
|
|
303
285
|
},
|
|
304
|
-
Stmt::Raise(..) | Stmt::Return(..) | Stmt::Break | Stmt::Continue => {
|
|
305
|
-
handle_stmt(final_stmt);
|
|
306
|
-
value = PyBlockExpr::Never;
|
|
307
|
-
}
|
|
308
286
|
_ => {
|
|
309
287
|
handle_stmt(final_stmt);
|
|
310
288
|
}
|
|
@@ -1031,7 +1009,7 @@ fn make_arglist<'src, 'ast>(
|
|
|
1031
1009
|
}
|
|
1032
1010
|
|
|
1033
1011
|
struct PartialPyFnDef<'a> {
|
|
1034
|
-
body:
|
|
1012
|
+
body: SPyExprWithPre<'a>,
|
|
1035
1013
|
decorators: PyDecorators<'a>,
|
|
1036
1014
|
args: Vec<PyArgDefItem<'a>>,
|
|
1037
1015
|
async_: bool,
|
|
@@ -1041,7 +1019,7 @@ enum FnDef<'src, 'ast> {
|
|
|
1041
1019
|
/**
|
|
1042
1020
|
* Args, body, is_do, is_async
|
|
1043
1021
|
*/
|
|
1044
|
-
PyFnDef(Vec<PyArgDefItem<'src>>,
|
|
1022
|
+
PyFnDef(Vec<PyArgDefItem<'src>>, SPyExprWithPre<'src>, bool, bool),
|
|
1045
1023
|
|
|
1046
1024
|
// Expr::Fn, args, body
|
|
1047
1025
|
TlFnDef(
|
|
@@ -1060,7 +1038,8 @@ fn prepare_py_fn<'src, 'ast>(
|
|
|
1060
1038
|
span: &Span,
|
|
1061
1039
|
) -> TlResult<WithPre<'src, PartialPyFnDef<'src>>> {
|
|
1062
1040
|
let mut pre = PyBlock::new();
|
|
1063
|
-
let mut
|
|
1041
|
+
let mut py_body_pre = PyBlock::new();
|
|
1042
|
+
let py_body_expr: SPyExpr;
|
|
1064
1043
|
let mut decorators = PyDecorators(vec![]);
|
|
1065
1044
|
|
|
1066
1045
|
let a = PyAstBuilder::new(*span);
|
|
@@ -1079,7 +1058,8 @@ fn prepare_py_fn<'src, 'ast>(
|
|
|
1079
1058
|
decorators.push(a.tl_builtin("do"));
|
|
1080
1059
|
}
|
|
1081
1060
|
|
|
1082
|
-
|
|
1061
|
+
py_body_pre.extend(body.pre);
|
|
1062
|
+
py_body_expr = body.value;
|
|
1083
1063
|
}
|
|
1084
1064
|
FnDef::TlFnDef(expr, arglist, body) => {
|
|
1085
1065
|
let fn_info = ctx.fn_info(expr)?;
|
|
@@ -1093,7 +1073,7 @@ fn prepare_py_fn<'src, 'ast>(
|
|
|
1093
1073
|
args = args_;
|
|
1094
1074
|
|
|
1095
1075
|
pre.extend(arg_pre);
|
|
1096
|
-
|
|
1076
|
+
py_body_pre.extend(post);
|
|
1097
1077
|
|
|
1098
1078
|
let body = body.transform(ctx)?;
|
|
1099
1079
|
|
|
@@ -1107,16 +1087,18 @@ fn prepare_py_fn<'src, 'ast>(
|
|
|
1107
1087
|
|
|
1108
1088
|
let (py_bindings, _, _) = py_fn_bindings(ctx, fn_info, *span)?;
|
|
1109
1089
|
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
py_body.push(a.return_(body.value));
|
|
1090
|
+
py_body_pre.extend(py_bindings);
|
|
1091
|
+
py_body_expr = py_body_pre.bind(body);
|
|
1113
1092
|
}
|
|
1114
1093
|
}
|
|
1115
1094
|
|
|
1116
1095
|
Ok(WithPre {
|
|
1117
1096
|
pre,
|
|
1118
1097
|
value: PartialPyFnDef {
|
|
1119
|
-
body:
|
|
1098
|
+
body: WithPre {
|
|
1099
|
+
pre: py_body_pre,
|
|
1100
|
+
value: py_body_expr,
|
|
1101
|
+
},
|
|
1120
1102
|
args,
|
|
1121
1103
|
decorators,
|
|
1122
1104
|
async_,
|
|
@@ -1138,34 +1120,34 @@ fn make_fn_exp<'src, 'ast>(
|
|
|
1138
1120
|
} = pre.bind(prepare_py_fn(ctx, def, span)?);
|
|
1139
1121
|
let a = PyAstBuilder::new(*span);
|
|
1140
1122
|
|
|
1141
|
-
if body.
|
|
1123
|
+
if body.pre.is_empty() && !async_ {
|
|
1142
1124
|
// TODO maybe refactor prepare_py_fn to return body_stmts as PyExprWithPre instead of pattern matching Return
|
|
1143
1125
|
|
|
1144
|
-
|
|
1145
|
-
let PyStmt::Return(expr) = body.0.into_iter().next().unwrap().value else {
|
|
1146
|
-
return Err(simple_err(
|
|
1147
|
-
"Internal error: Expected a single return statement in function body",
|
|
1148
|
-
*span,
|
|
1149
|
-
));
|
|
1150
|
-
};
|
|
1151
|
-
|
|
1152
|
-
let mut inner = a.lambda(args, expr);
|
|
1126
|
+
let mut inner = a.lambda(args, body.value);
|
|
1153
1127
|
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
}
|
|
1157
|
-
|
|
1158
|
-
return Ok(SPyExprWithPre { value: inner, pre });
|
|
1128
|
+
for deco in decorators.0.into_iter().rev() {
|
|
1129
|
+
inner = a.call(deco, vec![a.call_arg(inner)]);
|
|
1159
1130
|
}
|
|
1131
|
+
|
|
1132
|
+
return Ok(SPyExprWithPre {
|
|
1133
|
+
pre: PyBlock::new(),
|
|
1134
|
+
value: inner,
|
|
1135
|
+
});
|
|
1160
1136
|
}
|
|
1161
1137
|
|
|
1138
|
+
let body = {
|
|
1139
|
+
let mut block = body.pre;
|
|
1140
|
+
block.push(a.return_(body.value));
|
|
1141
|
+
block
|
|
1142
|
+
};
|
|
1143
|
+
|
|
1162
1144
|
let name = ctx.create_aux_var("fnexp", span.start);
|
|
1163
1145
|
pre.push(
|
|
1164
1146
|
(
|
|
1165
1147
|
PyStmt::FnDef(PyFnDef {
|
|
1166
1148
|
name: name.clone().into(),
|
|
1167
1149
|
args: args,
|
|
1168
|
-
body,
|
|
1150
|
+
body: body,
|
|
1169
1151
|
decorators: decorators,
|
|
1170
1152
|
async_,
|
|
1171
1153
|
}),
|
|
@@ -1188,6 +1170,7 @@ fn make_fn_def<'src, 'ast>(
|
|
|
1188
1170
|
span: &Span,
|
|
1189
1171
|
) -> TlResult<PyBlock<'src>> {
|
|
1190
1172
|
let mut pre = PyBlock::new();
|
|
1173
|
+
let a = PyAstBuilder::new(*span);
|
|
1191
1174
|
let PartialPyFnDef {
|
|
1192
1175
|
body,
|
|
1193
1176
|
args,
|
|
@@ -1197,6 +1180,12 @@ fn make_fn_def<'src, 'ast>(
|
|
|
1197
1180
|
|
|
1198
1181
|
decorators.0.extend(inner_decorators.0);
|
|
1199
1182
|
|
|
1183
|
+
let body = {
|
|
1184
|
+
let mut block = body.pre;
|
|
1185
|
+
block.push(a.return_(body.value));
|
|
1186
|
+
block
|
|
1187
|
+
};
|
|
1188
|
+
|
|
1200
1189
|
pre.push(
|
|
1201
1190
|
(
|
|
1202
1191
|
PyStmt::FnDef(PyFnDef {
|
|
@@ -1385,14 +1374,12 @@ fn transform_postfix_expr<'src, 'ast>(
|
|
|
1385
1374
|
let py_expr = make_expr(ctx, a.load_ident(arg_name.clone()))?;
|
|
1386
1375
|
|
|
1387
1376
|
let fn_info = ctx.mapped_fninfo.get(&expr.into()).unwrap();
|
|
1388
|
-
let mut fn_body = py_expr.pre;
|
|
1389
|
-
fn_body.push(a.return_(py_expr.value));
|
|
1390
1377
|
|
|
1391
1378
|
let inner_fn = pre.bind(make_fn_exp(
|
|
1392
1379
|
ctx,
|
|
1393
1380
|
FnDef::PyFnDef(
|
|
1394
1381
|
vec![a.arg_def(arg_name, None)],
|
|
1395
|
-
|
|
1382
|
+
py_expr,
|
|
1396
1383
|
false,
|
|
1397
1384
|
fn_info.is_async,
|
|
1398
1385
|
),
|
|
@@ -1946,14 +1933,7 @@ impl<'src, 'ast> SExprExt<'src, 'ast> for SExpr<'src> {
|
|
|
1946
1933
|
else_block.as_ref().map(|x| x.as_ref()),
|
|
1947
1934
|
&span,
|
|
1948
1935
|
)?),
|
|
1949
|
-
Expr::Block(block) =>
|
|
1950
|
-
let block = pre.bind(block.transform(ctx)?);
|
|
1951
|
-
|
|
1952
|
-
match block {
|
|
1953
|
-
PyBlockExpr::Expr(expr) => expr,
|
|
1954
|
-
PyBlockExpr::Nothing | PyBlockExpr::Never => a.none(),
|
|
1955
|
-
}
|
|
1956
|
-
}
|
|
1936
|
+
Expr::Block(block) => pre.bind(block.transform(ctx, &span)?),
|
|
1957
1937
|
Expr::Match(subject, cases) => pre
|
|
1958
1938
|
.bind(transform_match_expr(ctx, MatchSubject::Tl(subject), cases, true, &span)?.0),
|
|
1959
1939
|
Expr::Matches(subject, pattern) => {
|
|
@@ -2088,12 +2068,19 @@ impl<'src, 'ast> SExprExt<'src, 'ast> for SExpr<'src> {
|
|
|
2088
2068
|
}
|
|
2089
2069
|
|
|
2090
2070
|
py_body.extend(py_bindings);
|
|
2091
|
-
py_body.
|
|
2092
|
-
py_body.push(a.return_(py_expr.value));
|
|
2071
|
+
let py_expr = py_body.bind(py_expr);
|
|
2093
2072
|
|
|
2094
2073
|
let callback = pre.bind(make_fn_exp(
|
|
2095
2074
|
ctx,
|
|
2096
|
-
FnDef::PyFnDef(
|
|
2075
|
+
FnDef::PyFnDef(
|
|
2076
|
+
vec![],
|
|
2077
|
+
WithPre {
|
|
2078
|
+
pre: py_body,
|
|
2079
|
+
value: py_expr,
|
|
2080
|
+
},
|
|
2081
|
+
memo_captures.is_do,
|
|
2082
|
+
memo_captures.is_async,
|
|
2083
|
+
),
|
|
2097
2084
|
&span,
|
|
2098
2085
|
)?);
|
|
2099
2086
|
|
|
@@ -2257,16 +2244,14 @@ fn create_coalesce<'src, 'ast>(
|
|
|
2257
2244
|
) -> TlResult<SPyExprWithPre<'src>> {
|
|
2258
2245
|
let a = PyAstBuilder::new(span);
|
|
2259
2246
|
let mut pre = PyBlock::new();
|
|
2260
|
-
let mut fn_body = PyBlock::new();
|
|
2261
|
-
|
|
2262
|
-
let py_rhs = fn_body.bind(rhs.transform(ctx)?);
|
|
2263
|
-
fn_body.push(a.return_(py_rhs));
|
|
2264
2247
|
|
|
2265
2248
|
let fn_info = ctx.coal_fninfo.get(&rhs.into()).unwrap();
|
|
2266
2249
|
|
|
2250
|
+
let py_body = rhs.transform(ctx)?;
|
|
2251
|
+
|
|
2267
2252
|
let inner_fn = pre.bind(make_fn_exp(
|
|
2268
2253
|
ctx,
|
|
2269
|
-
FnDef::PyFnDef(vec![],
|
|
2254
|
+
FnDef::PyFnDef(vec![], py_body, false, fn_info.is_async),
|
|
2270
2255
|
&span,
|
|
2271
2256
|
)?);
|
|
2272
2257
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|