koatl 0.3.5__tar.gz → 0.3.6__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.3.5 → koatl-0.3.6}/Cargo.lock +1 -1
- {koatl-0.3.5 → koatl-0.3.6}/PKG-INFO +1 -1
- {koatl-0.3.5 → koatl-0.3.6}/koatl/Cargo.toml +1 -1
- {koatl-0.3.5 → koatl-0.3.6/koatl}/python/koatl/runtime/meta_finder.py +7 -2
- {koatl-0.3.5 → koatl-0.3.6}/koatl/src/lib.rs +22 -6
- {koatl-0.3.5 → koatl-0.3.6}/koatl-core/src/lib.rs +15 -14
- {koatl-0.3.5 → koatl-0.3.6}/koatl-core/src/transform.rs +22 -4
- {koatl-0.3.5/koatl → koatl-0.3.6}/python/koatl/runtime/meta_finder.py +7 -2
- {koatl-0.3.5 → koatl-0.3.6}/Cargo.toml +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/README.md +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/.github/workflows/CI.yml +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/.gitignore +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/LICENSE +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/README.md +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/python/koatl/__init__.py +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/python/koatl/__main__.py +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/python/koatl/cli.py +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/python/koatl/notebook/__init__.py +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/python/koatl/notebook/magic.py +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/python/koatl/prelude/__init__.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/python/koatl/runtime/__init__.py +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/python/koatl/runtime/record.py +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/python/koatl/runtime/vattr.py +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/python/koatl/std/__init__.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/python/koatl/std/alg/__init__.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/python/koatl/std/alg/async.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/python/koatl/std/alg/base.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/python/koatl/std/alg/do.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/python/koatl/std/alg/env.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/python/koatl/std/alg/memo.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/python/koatl/std/alg/result.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/python/koatl/std/data/__init__.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/python/koatl/std/data/list.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/python/koatl/std/data/record.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/python/koatl/std/ext.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/python/koatl/std/io.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/python/koatl/std/iter.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/python/koatl/std/json.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/python/koatl/std/lazy_module.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/python/koatl/std/pickle.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/python/koatl/std/re.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/python/koatl/std/trait.py +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/requirements.txt +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/src/emit_py.rs +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/tests/e2e/base/containers.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/tests/e2e/base/data.txt +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/tests/e2e/base/decorators.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/tests/e2e/base/destructure-for-and-fn.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/tests/e2e/base/destructure.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/tests/e2e/base/escape_ident.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/tests/e2e/base/fstr.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/tests/e2e/base/functions.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/tests/e2e/base/generator.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/tests/e2e/base/if_expr.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/tests/e2e/base/loops.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/tests/e2e/base/match.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/tests/e2e/base/nary-list.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/tests/e2e/base/placeholder.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/tests/e2e/base/precedence.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/tests/e2e/base/scopes.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/tests/e2e/base/semantic_whitespace.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/tests/e2e/base/short_circuit.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/tests/e2e/base/with.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/tests/e2e/prelude/async.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/tests/e2e/prelude/aug_assign.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/tests/e2e/prelude/coal.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/tests/e2e/prelude/env.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/tests/e2e/prelude/imports.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/tests/e2e/prelude/iterables.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/tests/e2e/prelude/list.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/tests/e2e/prelude/memo.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/tests/e2e/prelude/record.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/tests/e2e/prelude/result.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/tests/e2e/prelude/slice.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/tests/e2e/prelude/try.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/tests/e2e/prelude/virtual.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/tests/e2e/util/__init__.py +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/tests/e2e/util/module0.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/tests/e2e/util/module1.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/tests/e2e/util/module2.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/tests/parse/arith.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/tests/parse/assign.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/tests/parse/block-comments.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/tests/parse/deco.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/tests/parse/func.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/tests/parse/matches.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/tests/parse/numbers.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/tests/test_e2e.py +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl/tests/test_parse.py +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl-core/Cargo.toml +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl-core/src/ast.rs +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl-core/src/ast_builder.rs +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl-core/src/inference.rs +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl-core/src/lift_cst.rs +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl-core/src/main.rs +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl-core/src/py/ast.rs +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl-core/src/py/ast_builder.rs +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl-core/src/py/emit.rs +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl-core/src/py/mod.rs +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl-core/src/resolve_scopes.rs +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl-core/src/types.rs +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl-core/src/util.rs +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl-parser/Cargo.toml +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl-parser/src/cst.rs +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl-parser/src/lexer.rs +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl-parser/src/lib.rs +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl-parser/src/parser.rs +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/koatl-parser/src/simple_fmt.rs +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/pyproject.toml +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/python/koatl/__init__.py +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/python/koatl/__main__.py +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/python/koatl/cli.py +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/python/koatl/notebook/__init__.py +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/python/koatl/notebook/magic.py +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/python/koatl/prelude/__init__.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/python/koatl/runtime/__init__.py +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/python/koatl/runtime/record.py +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/python/koatl/runtime/vattr.py +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/python/koatl/std/__init__.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/python/koatl/std/alg/__init__.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/python/koatl/std/alg/async.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/python/koatl/std/alg/base.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/python/koatl/std/alg/do.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/python/koatl/std/alg/env.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/python/koatl/std/alg/memo.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/python/koatl/std/alg/result.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/python/koatl/std/data/__init__.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/python/koatl/std/data/list.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/python/koatl/std/data/record.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/python/koatl/std/ext.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/python/koatl/std/io.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/python/koatl/std/iter.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/python/koatl/std/json.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/python/koatl/std/lazy_module.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/python/koatl/std/pickle.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/python/koatl/std/re.tl +0 -0
- {koatl-0.3.5 → koatl-0.3.6}/python/koatl/std/trait.py +0 -0
|
@@ -52,13 +52,18 @@ class TlLoader(Loader):
|
|
|
52
52
|
self.filepath,
|
|
53
53
|
)
|
|
54
54
|
|
|
55
|
+
ver = (sys.version_info.major, sys.version_info.minor)
|
|
56
|
+
|
|
55
57
|
if module.__name__.startswith("koatl"):
|
|
56
58
|
transpiled_code = transpile(
|
|
57
|
-
source_code,
|
|
59
|
+
source_code,
|
|
60
|
+
mode="no_prelude",
|
|
61
|
+
filename=self.filepath,
|
|
62
|
+
target_version=ver,
|
|
58
63
|
)
|
|
59
64
|
else:
|
|
60
65
|
transpiled_code = transpile(
|
|
61
|
-
source_code, mode="module", filename=self.filepath
|
|
66
|
+
source_code, mode="module", filename=self.filepath, target_version=ver
|
|
62
67
|
)
|
|
63
68
|
|
|
64
69
|
code = compile(transpiled_code, self.filepath, "exec")
|
|
@@ -25,9 +25,17 @@ fn get_option(mode: &str) -> PyResult<TranspileOptions> {
|
|
|
25
25
|
})
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
#[pyfunction(signature=(src, mode="script", filename="<string>"))]
|
|
29
|
-
fn transpile(
|
|
30
|
-
|
|
28
|
+
#[pyfunction(signature=(src, mode="script", filename="<string>", target_version=None))]
|
|
29
|
+
fn transpile(
|
|
30
|
+
src: &str,
|
|
31
|
+
mode: &str,
|
|
32
|
+
filename: &str,
|
|
33
|
+
target_version: Option<(usize, usize)>,
|
|
34
|
+
) -> PyResult<PyObject> {
|
|
35
|
+
let mut options = get_option(mode)?;
|
|
36
|
+
if let Some(ver) = target_version {
|
|
37
|
+
options.target_version = ver;
|
|
38
|
+
}
|
|
31
39
|
|
|
32
40
|
let py_ast = transpile_to_py_ast(src, filename, options).map_err(|e| {
|
|
33
41
|
PyErr::new::<pyo3::exceptions::PySyntaxError, _>(format_errs(&e, filename, src))
|
|
@@ -39,9 +47,17 @@ fn transpile(src: &str, mode: &str, filename: &str) -> PyResult<PyObject> {
|
|
|
39
47
|
Ok(py_ast_obj)
|
|
40
48
|
}
|
|
41
49
|
|
|
42
|
-
#[pyfunction(signature=(src, mode="script", filename="<string>"))]
|
|
43
|
-
fn transpile_raw(
|
|
44
|
-
|
|
50
|
+
#[pyfunction(signature=(src, mode="script", filename="<string>", target_version=None))]
|
|
51
|
+
fn transpile_raw(
|
|
52
|
+
src: &str,
|
|
53
|
+
mode: &str,
|
|
54
|
+
filename: &str,
|
|
55
|
+
target_version: Option<(usize, usize)>,
|
|
56
|
+
) -> PyResult<PyObject> {
|
|
57
|
+
let mut options = get_option(mode)?;
|
|
58
|
+
if let Some(ver) = target_version {
|
|
59
|
+
options.target_version = ver;
|
|
60
|
+
}
|
|
45
61
|
|
|
46
62
|
let ctx = transpile_to_source(src, filename, options).map_err(|e| {
|
|
47
63
|
PyErr::new::<pyo3::exceptions::PySyntaxError, _>(format_errs(&e, filename, src))
|
|
@@ -20,6 +20,7 @@ use crate::util::{TlErr, TlErrKind, TlErrs, TlResult};
|
|
|
20
20
|
use ariadne::{Color, Label, Report, ReportKind, sources};
|
|
21
21
|
|
|
22
22
|
pub struct TranspileOptions {
|
|
23
|
+
pub target_version: (usize, usize),
|
|
23
24
|
pub inject_prelude: bool,
|
|
24
25
|
pub inject_runtime: bool,
|
|
25
26
|
pub set_exports: bool,
|
|
@@ -28,16 +29,23 @@ pub struct TranspileOptions {
|
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
impl TranspileOptions {
|
|
31
|
-
pub fn
|
|
32
|
+
pub fn module() -> Self {
|
|
32
33
|
TranspileOptions {
|
|
33
34
|
inject_prelude: true,
|
|
34
35
|
inject_runtime: true,
|
|
35
|
-
|
|
36
|
-
set_exports: false,
|
|
36
|
+
set_exports: true,
|
|
37
37
|
allow_await: false,
|
|
38
|
+
interactive: false,
|
|
39
|
+
target_version: (3, 12),
|
|
38
40
|
}
|
|
39
41
|
}
|
|
40
42
|
|
|
43
|
+
pub fn script() -> Self {
|
|
44
|
+
let mut opt = TranspileOptions::module();
|
|
45
|
+
opt.set_exports = false;
|
|
46
|
+
opt
|
|
47
|
+
}
|
|
48
|
+
|
|
41
49
|
pub fn interactive() -> Self {
|
|
42
50
|
let mut opt = TranspileOptions::script();
|
|
43
51
|
opt.inject_prelude = false;
|
|
@@ -47,16 +55,6 @@ impl TranspileOptions {
|
|
|
47
55
|
opt
|
|
48
56
|
}
|
|
49
57
|
|
|
50
|
-
pub fn module() -> Self {
|
|
51
|
-
TranspileOptions {
|
|
52
|
-
allow_await: false,
|
|
53
|
-
inject_prelude: true,
|
|
54
|
-
inject_runtime: true,
|
|
55
|
-
set_exports: true,
|
|
56
|
-
interactive: false,
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
58
|
pub fn no_prelude() -> Self {
|
|
61
59
|
let mut opt = TranspileOptions::module();
|
|
62
60
|
opt.inject_prelude = false; // don't inject the prelude when loading prelude
|
|
@@ -96,7 +94,10 @@ pub fn transpile_to_py_ast<'src>(
|
|
|
96
94
|
&tl_ast,
|
|
97
95
|
&resolve_state,
|
|
98
96
|
&inference,
|
|
99
|
-
|
|
97
|
+
transform::TransformOptions {
|
|
98
|
+
interactive: options.interactive,
|
|
99
|
+
target_version: options.target_version,
|
|
100
|
+
},
|
|
100
101
|
) {
|
|
101
102
|
Ok(output) => Some(output),
|
|
102
103
|
Err(e) => {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
use core::fmt;
|
|
1
2
|
use std::{
|
|
2
3
|
borrow::Cow,
|
|
3
4
|
collections::{HashMap, HashSet},
|
|
@@ -70,6 +71,8 @@ struct TlCtx<'src, 'ast> {
|
|
|
70
71
|
declarations: &'ast SlotMap<DeclarationKey, Declaration<'src>>,
|
|
71
72
|
|
|
72
73
|
types: &'ast HashMap<RefHash, Type>,
|
|
74
|
+
|
|
75
|
+
target_version: (usize, usize),
|
|
73
76
|
}
|
|
74
77
|
|
|
75
78
|
impl<'src, 'ast> TlCtx<'src, 'ast> {
|
|
@@ -99,6 +102,7 @@ impl<'src, 'ast> TlCtx<'src, 'ast> {
|
|
|
99
102
|
declarations: &resolve_state.declarations,
|
|
100
103
|
|
|
101
104
|
types: &inference.types,
|
|
105
|
+
target_version: (3, 12),
|
|
102
106
|
})
|
|
103
107
|
}
|
|
104
108
|
|
|
@@ -208,7 +212,7 @@ fn deduplicate<'src, 'ast>(
|
|
|
208
212
|
expr: SPyExpr<'src>,
|
|
209
213
|
span: Span,
|
|
210
214
|
) -> TlResult<SPyExprWithPre<'src>> {
|
|
211
|
-
let var_name = ctx.create_aux_var("
|
|
215
|
+
let var_name = ctx.create_aux_var("exp", span.start);
|
|
212
216
|
let a = PyAstBuilder::new(span);
|
|
213
217
|
let mut pre = PyBlock::new();
|
|
214
218
|
|
|
@@ -2242,7 +2246,15 @@ impl<'src, 'ast> SExprExt<'src, 'ast> for SExpr<'src> {
|
|
|
2242
2246
|
nodes.push(PyFstrPart::Str(begin.value.clone().into()));
|
|
2243
2247
|
|
|
2244
2248
|
for (fmt_expr, str_part) in parts {
|
|
2245
|
-
|
|
2249
|
+
// Nested strings are not allowed in f-strings pre 3.12,
|
|
2250
|
+
// so lift the expression part out
|
|
2251
|
+
let expr = if ctx.target_version >= (3, 12) {
|
|
2252
|
+
pre.bind(fmt_expr.expr.transform(ctx)?)
|
|
2253
|
+
} else {
|
|
2254
|
+
let e = pre.bind(fmt_expr.expr.transform(ctx)?);
|
|
2255
|
+
pre.bind(deduplicate(ctx, e, fmt_expr.expr.span)?)
|
|
2256
|
+
};
|
|
2257
|
+
|
|
2246
2258
|
let fmt = fmt_expr
|
|
2247
2259
|
.fmt
|
|
2248
2260
|
.as_ref()
|
|
@@ -2369,6 +2381,11 @@ fn py_fn_bindings<'src, 'ast>(
|
|
|
2369
2381
|
Ok((py_body, nonlocals, globals))
|
|
2370
2382
|
}
|
|
2371
2383
|
|
|
2384
|
+
pub struct TransformOptions {
|
|
2385
|
+
pub interactive: bool,
|
|
2386
|
+
pub target_version: (usize, usize),
|
|
2387
|
+
}
|
|
2388
|
+
|
|
2372
2389
|
pub struct TransformOutput<'src> {
|
|
2373
2390
|
pub py_block: PyBlock<'src>,
|
|
2374
2391
|
pub exports: Vec<PyToken<'src>>,
|
|
@@ -2381,11 +2398,12 @@ pub fn transform_ast<'src, 'ast>(
|
|
|
2381
2398
|
block: &'ast SExpr<'src>,
|
|
2382
2399
|
resolve_state: &'ast ResolveState<'src>,
|
|
2383
2400
|
inference: &'ast InferenceCtx<'src, 'ast>,
|
|
2384
|
-
|
|
2401
|
+
options: TransformOptions,
|
|
2385
2402
|
) -> TlResult<TransformOutput<'src>> {
|
|
2386
2403
|
let mut ctx = TlCtx::new(source, filename, resolve_state, inference)?;
|
|
2404
|
+
ctx.target_version = options.target_version;
|
|
2387
2405
|
|
|
2388
|
-
let py_block = if interactive {
|
|
2406
|
+
let py_block = if options.interactive {
|
|
2389
2407
|
let mut py_value = block.transform(&mut ctx)?;
|
|
2390
2408
|
let span = py_value.value.tl_span;
|
|
2391
2409
|
py_value
|
|
@@ -52,13 +52,18 @@ class TlLoader(Loader):
|
|
|
52
52
|
self.filepath,
|
|
53
53
|
)
|
|
54
54
|
|
|
55
|
+
ver = (sys.version_info.major, sys.version_info.minor)
|
|
56
|
+
|
|
55
57
|
if module.__name__.startswith("koatl"):
|
|
56
58
|
transpiled_code = transpile(
|
|
57
|
-
source_code,
|
|
59
|
+
source_code,
|
|
60
|
+
mode="no_prelude",
|
|
61
|
+
filename=self.filepath,
|
|
62
|
+
target_version=ver,
|
|
58
63
|
)
|
|
59
64
|
else:
|
|
60
65
|
transpiled_code = transpile(
|
|
61
|
-
source_code, mode="module", filename=self.filepath
|
|
66
|
+
source_code, mode="module", filename=self.filepath, target_version=ver
|
|
62
67
|
)
|
|
63
68
|
|
|
64
69
|
code = compile(transpiled_code, self.filepath, "exec")
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|