@tishlang/tish-format 1.0.13 → 2.0.1
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.
- package/Cargo.toml +2 -0
- package/bin/tish-format +0 -0
- package/crates/js_to_tish/src/transform/expr.rs +1 -0
- package/crates/tish/Cargo.toml +10 -2
- package/crates/tish/build.rs +21 -0
- package/crates/tish/src/cli_help.rs +15 -4
- package/crates/tish/src/main.rs +93 -21
- package/crates/tish/src/repl_completion.rs +0 -1
- package/crates/tish/tests/error_source_location.rs +36 -0
- package/crates/tish/tests/fixtures/runtime_error_location.tish +5 -0
- package/crates/tish/tests/fixtures/trycatch_runtime_errors.tish +15 -0
- package/crates/tish/tests/fixtures/tty_capability.tish +9 -0
- package/crates/tish/tests/integration_test.rs +402 -91
- package/crates/tish/tests/trycatch_runtime_errors.rs +45 -0
- package/crates/tish/tests/tty_capability.rs +43 -0
- package/crates/tish_ast/src/ast.rs +37 -8
- package/crates/tish_builtins/Cargo.toml +2 -0
- package/crates/tish_builtins/src/array.rs +375 -13
- package/crates/tish_builtins/src/collections.rs +481 -0
- package/crates/tish_builtins/src/construct.rs +59 -19
- package/crates/tish_builtins/src/date.rs +538 -0
- package/crates/tish_builtins/src/globals.rs +86 -6
- package/crates/tish_builtins/src/iterator.rs +129 -0
- package/crates/tish_builtins/src/lib.rs +5 -0
- package/crates/tish_builtins/src/number.rs +96 -0
- package/crates/tish_builtins/src/object.rs +2 -2
- package/crates/tish_builtins/src/string.rs +19 -20
- package/crates/tish_builtins/src/symbol.rs +1 -1
- package/crates/tish_builtins/src/typedarrays.rs +298 -0
- package/crates/tish_bytecode/src/chunk.rs +69 -1
- package/crates/tish_bytecode/src/compiler.rs +933 -89
- package/crates/tish_bytecode/src/encoding.rs +2 -0
- package/crates/tish_bytecode/src/lib.rs +2 -1
- package/crates/tish_bytecode/src/opcode.rs +47 -4
- package/crates/tish_bytecode/src/serialize.rs +31 -1
- package/crates/tish_compile/Cargo.toml +1 -0
- package/crates/tish_compile/src/check.rs +774 -0
- package/crates/tish_compile/src/codegen.rs +2334 -349
- package/crates/tish_compile/src/infer.rs +1395 -6
- package/crates/tish_compile/src/lib.rs +50 -8
- package/crates/tish_compile/src/resolve.rs +584 -21
- package/crates/tish_compile/src/types.rs +106 -2
- package/crates/tish_compile_js/src/codegen.rs +67 -0
- package/crates/tish_compile_js/src/tests_jsx.rs +64 -0
- package/crates/tish_core/Cargo.toml +7 -1
- package/crates/tish_core/src/console_style.rs +11 -1
- package/crates/tish_core/src/json.rs +81 -38
- package/crates/tish_core/src/lib.rs +3 -0
- package/crates/tish_core/src/shape.rs +85 -0
- package/crates/tish_core/src/value.rs +679 -25
- package/crates/tish_core/src/vmref.rs +13 -8
- package/crates/tish_cranelift/src/link.rs +17 -4
- package/crates/tish_cranelift_runtime/Cargo.toml +1 -0
- package/crates/tish_eval/Cargo.toml +6 -0
- package/crates/tish_eval/src/eval.rs +665 -117
- package/crates/tish_eval/src/http.rs +4 -1
- package/crates/tish_eval/src/natives.rs +165 -13
- package/crates/tish_eval/src/value.rs +31 -13
- package/crates/tish_eval/src/value_convert.rs +10 -4
- package/crates/tish_ffi/Cargo.toml +26 -0
- package/crates/tish_ffi/src/lib.rs +518 -0
- package/crates/tish_ffi/tests/fixtures/testmod/Cargo.toml +18 -0
- package/crates/tish_ffi/tests/fixtures/testmod/src/lib.rs +46 -0
- package/crates/tish_ffi/tests/loader.rs +65 -0
- package/crates/tish_fmt/Cargo.toml +1 -1
- package/crates/tish_fmt/src/lib.rs +61 -5
- package/crates/tish_lexer/src/lib.rs +397 -9
- package/crates/tish_lexer/src/token.rs +7 -0
- package/crates/tish_lint/src/lib.rs +2 -10
- package/crates/tish_lsp/src/import_goto.rs +2 -0
- package/crates/tish_lsp/src/main.rs +439 -26
- package/crates/tish_native/src/build.rs +55 -1
- package/crates/tish_opt/src/lib.rs +126 -23
- package/crates/tish_parser/src/lib.rs +55 -1
- package/crates/tish_parser/src/parser.rs +456 -34
- package/crates/tish_pg/src/lib.rs +3 -3
- package/crates/tish_resolve/src/lib.rs +99 -59
- package/crates/tish_runtime/Cargo.toml +4 -0
- package/crates/tish_runtime/src/http.rs +66 -17
- package/crates/tish_runtime/src/http_fetch.rs +29 -8
- package/crates/tish_runtime/src/http_hyper.rs +25 -2
- package/crates/tish_runtime/src/lib.rs +299 -44
- package/crates/tish_runtime/src/promise.rs +328 -18
- package/crates/tish_runtime/src/timers.rs +13 -7
- package/crates/tish_runtime/src/tty.rs +226 -0
- package/crates/tish_runtime/src/ws.rs +35 -18
- package/crates/tish_runtime/tests/fetch_readable_stream.rs +2 -2
- package/crates/tish_ui/src/jsx.rs +10 -0
- package/crates/tish_ui/src/runtime/hooks.rs +19 -15
- package/crates/tish_ui/src/runtime/mod.rs +15 -12
- package/crates/tish_vm/Cargo.toml +14 -1
- package/crates/tish_vm/src/jit.rs +1050 -0
- package/crates/tish_vm/src/lib.rs +2 -0
- package/crates/tish_vm/src/vm.rs +1546 -202
- package/crates/tish_vm/tests/concurrent_shared_state.rs +140 -0
- package/crates/tish_wasm/src/lib.rs +6 -2
- package/crates/tish_wasm_runtime/src/gpu.rs +17 -1
- package/crates/tishlang_cargo_bindgen/src/classify.rs +1 -3
- package/crates/tishlang_cargo_bindgen/src/lib.rs +2 -2
- package/crates/tishlang_cargo_bindgen/src/metadata.rs +1 -1
- package/justfile +8 -0
- package/package.json +2 -2
- package/platform/darwin-arm64/tish-fmt +0 -0
- package/platform/darwin-x64/tish-fmt +0 -0
- package/platform/linux-arm64/tish-fmt +0 -0
- package/platform/linux-x64/tish-fmt +0 -0
- package/platform/win32-x64/tish-fmt.exe +0 -0
- package/README.md +0 -138
|
@@ -110,16 +110,17 @@ mod imp {
|
|
|
110
110
|
// --------------------------------------------------------------------------
|
|
111
111
|
#[cfg(feature = "send-values")]
|
|
112
112
|
mod imp {
|
|
113
|
-
use
|
|
113
|
+
use parking_lot::Mutex;
|
|
114
|
+
use std::sync::Arc;
|
|
114
115
|
|
|
115
116
|
#[derive(Default)]
|
|
116
117
|
pub struct VmRef<T: ?Sized>(pub(super) Arc<Mutex<T>>);
|
|
117
118
|
|
|
118
119
|
/// Read guard alias. On the multi-threaded path both readers and
|
|
119
120
|
/// writers share a single `MutexGuard` (exclusive access).
|
|
120
|
-
pub type ReadGuard<'a, T> =
|
|
121
|
+
pub type ReadGuard<'a, T> = parking_lot::MutexGuard<'a, T>;
|
|
121
122
|
/// Write guard alias.
|
|
122
|
-
pub type WriteGuard<'a, T> =
|
|
123
|
+
pub type WriteGuard<'a, T> = parking_lot::MutexGuard<'a, T>;
|
|
123
124
|
|
|
124
125
|
impl<T> VmRef<T> {
|
|
125
126
|
#[inline]
|
|
@@ -129,17 +130,21 @@ mod imp {
|
|
|
129
130
|
}
|
|
130
131
|
|
|
131
132
|
impl<T: ?Sized> VmRef<T> {
|
|
132
|
-
/// Acquire the inner mutex.
|
|
133
|
-
///
|
|
134
|
-
/// no
|
|
133
|
+
/// Acquire the inner mutex. `parking_lot::Mutex` is used (not
|
|
134
|
+
/// `std::sync::Mutex`): its uncontended lock is a single atomic with
|
|
135
|
+
/// no pthread syscall — a profile of object/array-heavy code showed
|
|
136
|
+
/// `pthread_mutex_lock/unlock` as a top cost under send-values, since
|
|
137
|
+
/// every property/element access locks. It also has no poisoning, so
|
|
138
|
+
/// there is no `Result` to swallow (a handler panic aborts the thread
|
|
139
|
+
/// regardless).
|
|
135
140
|
#[inline]
|
|
136
141
|
pub fn borrow(&self) -> ReadGuard<'_, T> {
|
|
137
|
-
self.0.lock()
|
|
142
|
+
self.0.lock()
|
|
138
143
|
}
|
|
139
144
|
|
|
140
145
|
#[inline]
|
|
141
146
|
pub fn borrow_mut(&self) -> WriteGuard<'_, T> {
|
|
142
|
-
self.0.lock()
|
|
147
|
+
self.0.lock()
|
|
143
148
|
}
|
|
144
149
|
|
|
145
150
|
#[inline]
|
|
@@ -54,9 +54,15 @@ pub fn link_to_binary(
|
|
|
54
54
|
.join(", ")
|
|
55
55
|
)
|
|
56
56
|
};
|
|
57
|
+
// UNIQUE package name per program. With the shared target dir, a fixed package name
|
|
58
|
+
// (`tishlang_cranelift_out`) made cargo cross-contaminate builds — each program links its own
|
|
59
|
+
// per-program object via build.rs, so program B would reuse program A's cached build script and
|
|
60
|
+
// link A's (now-deleted) `.o`. A distinct package name keeps them separate while the heavy
|
|
61
|
+
// dependency (`tishlang_cranelift_runtime`, same path + features for all) still compiles once.
|
|
62
|
+
let pkg_name = format!("clout_{}", out_name);
|
|
57
63
|
let cargo_toml_fixed = format!(
|
|
58
64
|
r#"[package]
|
|
59
|
-
name = "
|
|
65
|
+
name = "{}"
|
|
60
66
|
version = "0.1.0"
|
|
61
67
|
edition = "2021"
|
|
62
68
|
|
|
@@ -67,7 +73,7 @@ path = "src/main.rs"
|
|
|
67
73
|
[dependencies]
|
|
68
74
|
tishlang_cranelift_runtime = {{ path = {:?}{} }}
|
|
69
75
|
"#,
|
|
70
|
-
out_name, runtime_path, features_str
|
|
76
|
+
pkg_name, out_name, runtime_path, features_str
|
|
71
77
|
);
|
|
72
78
|
|
|
73
79
|
let main_rs = r#"
|
|
@@ -103,10 +109,17 @@ fn main() {{
|
|
|
103
109
|
message: format!("Cannot write build.rs: {}", e),
|
|
104
110
|
})?;
|
|
105
111
|
|
|
106
|
-
|
|
112
|
+
// Build into a SHARED target dir (one per host), not the per-program `build_dir/target`.
|
|
113
|
+
// The heavy deps (cranelift_codegen + the embedded VM, ~several GB) then compile ONCE and
|
|
114
|
+
// are reused by every cranelift build; only each program's tiny main + object is rebuilt.
|
|
115
|
+
// Without this, every program left its own multi-GB `target/` behind and a full-suite sweep
|
|
116
|
+
// filled the disk (see docs/full-backend-parity-plan.md A3). Concurrent builds are serialized
|
|
117
|
+
// by `run_cargo_build`'s nested-cargo mutex and cargo's own target lock, so sharing is safe.
|
|
118
|
+
let shared_target = std::env::temp_dir().join("tishlang_cranelift_target");
|
|
119
|
+
tishlang_build_utils::run_cargo_build(&build_dir, Some(&shared_target), None)
|
|
107
120
|
.map_err(|e| CraneliftError { message: e })?;
|
|
108
121
|
|
|
109
|
-
let binary_dir =
|
|
122
|
+
let binary_dir = shared_target.join("release");
|
|
110
123
|
let binary = tishlang_build_utils::find_release_binary(&binary_dir, out_name)
|
|
111
124
|
.map_err(|e| CraneliftError { message: e })?;
|
|
112
125
|
let target = tishlang_build_utils::resolve_output_path(output_path, out_name);
|
|
@@ -26,13 +26,19 @@ http = [
|
|
|
26
26
|
]
|
|
27
27
|
fs = []
|
|
28
28
|
process = []
|
|
29
|
+
tty = ["dep:tishlang_runtime", "tishlang_runtime/tty"]
|
|
29
30
|
regex = ["dep:fancy-regex", "tishlang_core/regex"]
|
|
30
31
|
tokio = ["dep:tokio"]
|
|
31
32
|
ws = ["dep:tishlang_runtime", "tishlang_runtime/ws"]
|
|
32
33
|
|
|
33
34
|
[dependencies]
|
|
34
35
|
ahash = "0.8.12"
|
|
36
|
+
indexmap = "2"
|
|
35
37
|
rand = "0.10.1"
|
|
38
|
+
# On-demand native stack growth for deep (non-tail) recursion in the tree-walker,
|
|
39
|
+
# mirroring the bytecode VM. Plain dep (stacker is a no-op shim on wasm32, where
|
|
40
|
+
# tish_vm already depends on it for the wasi backend).
|
|
41
|
+
stacker = "0.1"
|
|
36
42
|
tishlang_ast = { path = "../tish_ast", version = ">=0.1" }
|
|
37
43
|
tishlang_builtins = { path = "../tish_builtins", version = ">=0.1" }
|
|
38
44
|
tishlang_parser = { path = "../tish_parser", version = ">=0.1" }
|