@tishlang/tish 1.7.0 → 1.9.0
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/README.md +2 -0
- package/bin/tish +0 -0
- package/crates/js_to_tish/src/transform/expr.rs +28 -8
- package/crates/js_to_tish/src/transform/stmt.rs +49 -22
- package/crates/tish/Cargo.toml +14 -5
- package/crates/tish/src/cargo_native_registry.rs +29 -0
- package/crates/tish/src/cli_help.rs +16 -10
- package/crates/tish/src/main.rs +87 -32
- package/crates/tish/src/repl_completion.rs +3 -3
- package/crates/tish/tests/cargo_example_compile.rs +1 -1
- package/crates/tish/tests/integration_test.rs +19 -7
- package/crates/tish/tests/shortcircuit.rs +1 -1
- package/crates/tish_ast/src/ast.rs +80 -9
- package/crates/tish_build_utils/Cargo.toml +4 -0
- package/crates/tish_build_utils/src/lib.rs +105 -2
- package/crates/tish_builtins/Cargo.toml +5 -1
- package/crates/tish_builtins/src/array.rs +13 -12
- package/crates/tish_builtins/src/construct.rs +34 -33
- package/crates/tish_builtins/src/globals.rs +12 -11
- package/crates/tish_builtins/src/helpers.rs +2 -1
- package/crates/tish_builtins/src/object.rs +3 -2
- package/crates/tish_builtins/src/string.rs +73 -3
- package/crates/tish_bytecode/src/compiler.rs +12 -14
- package/crates/tish_bytecode/src/opcode.rs +12 -3
- package/crates/tish_compile/Cargo.toml +1 -0
- package/crates/tish_compile/src/codegen.rs +745 -199
- package/crates/tish_compile/src/infer.rs +6 -0
- package/crates/tish_compile/src/lib.rs +4 -3
- package/crates/tish_compile/src/resolve.rs +180 -82
- package/crates/tish_compile/src/types.rs +175 -11
- package/crates/tish_compile_js/Cargo.toml +1 -0
- package/crates/tish_compile_js/src/codegen.rs +152 -29
- package/crates/tish_compile_js/src/lib.rs +3 -1
- package/crates/tish_compiler_wasm/src/resolve_virtual.rs +31 -12
- package/crates/tish_core/Cargo.toml +8 -0
- package/crates/tish_core/src/json.rs +102 -53
- package/crates/tish_core/src/lib.rs +3 -1
- package/crates/tish_core/src/macros.rs +5 -5
- package/crates/tish_core/src/value.rs +53 -15
- package/crates/tish_core/src/vmref.rs +178 -0
- package/crates/tish_eval/Cargo.toml +17 -2
- package/crates/tish_eval/src/eval.rs +90 -28
- package/crates/tish_eval/src/http.rs +61 -0
- package/crates/tish_eval/src/lib.rs +3 -3
- package/crates/tish_eval/src/natives.rs +41 -0
- package/crates/tish_eval/src/value.rs +7 -3
- package/crates/tish_eval/src/value_convert.rs +13 -5
- package/crates/tish_fmt/src/lib.rs +120 -30
- package/crates/tish_lexer/src/lib.rs +20 -5
- package/crates/tish_lexer/src/token.rs +4 -0
- package/crates/tish_llvm/src/lib.rs +3 -1
- package/crates/tish_lsp/Cargo.toml +4 -1
- package/crates/tish_lsp/README.md +1 -1
- package/crates/tish_lsp/src/builtin_goto.rs +261 -0
- package/crates/tish_lsp/src/import_goto.rs +549 -0
- package/crates/tish_lsp/src/main.rs +502 -102
- package/crates/tish_native/src/build.rs +3 -2
- package/crates/tish_native/src/lib.rs +6 -2
- package/crates/tish_opt/src/lib.rs +17 -2
- package/crates/tish_parser/src/lib.rs +10 -3
- package/crates/tish_parser/src/parser.rs +346 -56
- package/crates/tish_pg/Cargo.toml +34 -0
- package/crates/tish_pg/README.md +38 -0
- package/crates/tish_pg/src/error.rs +52 -0
- package/crates/tish_pg/src/lib.rs +967 -0
- package/crates/tish_resolve/Cargo.toml +13 -0
- package/crates/tish_resolve/src/lib.rs +3436 -0
- package/crates/tish_resolve/src/pos.rs +133 -0
- package/crates/tish_runtime/Cargo.toml +68 -3
- package/crates/tish_runtime/src/http.rs +1123 -141
- package/crates/tish_runtime/src/http_fetch.rs +15 -14
- package/crates/tish_runtime/src/http_hyper.rs +418 -0
- package/crates/tish_runtime/src/http_prefork.rs +189 -0
- package/crates/tish_runtime/src/lib.rs +159 -29
- package/crates/tish_runtime/src/promise.rs +199 -36
- package/crates/tish_runtime/src/promise_io.rs +2 -1
- package/crates/tish_runtime/src/timers.rs +37 -1
- package/crates/tish_runtime/src/ws.rs +26 -28
- package/crates/tish_ui/src/jsx.rs +279 -8
- package/crates/tish_ui/src/lib.rs +5 -2
- package/crates/tish_ui/src/runtime/hooks.rs +406 -45
- package/crates/tish_ui/src/runtime/mod.rs +36 -9
- package/crates/tish_vm/Cargo.toml +15 -5
- package/crates/tish_vm/src/vm.rs +506 -259
- package/crates/tish_vm/tests/peephole_jump_chain_logical_or.rs +3 -1
- package/crates/tish_wasm/src/lib.rs +17 -14
- package/crates/tish_wasm_runtime/Cargo.toml +2 -1
- package/crates/tish_wasm_runtime/src/lib.rs +1 -1
- package/crates/tishlang_cargo_bindgen/Cargo.toml +1 -0
- package/crates/tishlang_cargo_bindgen/src/discover.rs +68 -0
- package/crates/tishlang_cargo_bindgen/src/lib.rs +5 -4
- package/justfile +8 -0
- package/package.json +1 -1
- package/platform/darwin-arm64/tish +0 -0
- package/platform/darwin-x64/tish +0 -0
- package/platform/linux-arm64/tish +0 -0
- package/platform/linux-x64/tish +0 -0
- package/platform/win32-x64/tish.exe +0 -0
|
@@ -6,7 +6,8 @@ use std::path::Path;
|
|
|
6
6
|
use tishlang_compile::ResolvedNativeModule;
|
|
7
7
|
|
|
8
8
|
/// `tishlang_runtime` Cargo feature names (subset of CLI / compile feature names).
|
|
9
|
-
const RUNTIME_CARGO_FEATURES: &[&str] =
|
|
9
|
+
const RUNTIME_CARGO_FEATURES: &[&str] =
|
|
10
|
+
&["http", "http-hyper", "http-io-uring", "fs", "process", "regex", "ws"];
|
|
10
11
|
|
|
11
12
|
/// Map CLI/compile features to flags passed to `tishlang_runtime` in the temp crate's Cargo.toml.
|
|
12
13
|
/// `full` enables every optional runtime capability (matches `tish build --feature full` / LANGUAGE.md).
|
|
@@ -122,7 +123,7 @@ path = "src/main.rs"
|
|
|
122
123
|
strip = true
|
|
123
124
|
panic = "abort"
|
|
124
125
|
codegen-units = 1
|
|
125
|
-
lto = "
|
|
126
|
+
lto = "fat"
|
|
126
127
|
|
|
127
128
|
[dependencies]
|
|
128
129
|
tishlang_runtime = {{ path = {:?}{} }}
|
|
@@ -90,7 +90,9 @@ pub fn compile_to_native(
|
|
|
90
90
|
message: e.to_string(),
|
|
91
91
|
})?;
|
|
92
92
|
let program = {
|
|
93
|
-
let prog = tishlang_compile::merge_modules(modules)
|
|
93
|
+
let prog = tishlang_compile::merge_modules(modules)
|
|
94
|
+
.map(|m| m.program)
|
|
95
|
+
.map_err(|e| NativeError {
|
|
94
96
|
message: e.to_string(),
|
|
95
97
|
})?;
|
|
96
98
|
if optimize {
|
|
@@ -133,7 +135,9 @@ pub fn compile_to_native(
|
|
|
133
135
|
message: e.to_string(),
|
|
134
136
|
})?;
|
|
135
137
|
let program = {
|
|
136
|
-
let prog = tishlang_compile::merge_modules(modules)
|
|
138
|
+
let prog = tishlang_compile::merge_modules(modules)
|
|
139
|
+
.map(|m| m.program)
|
|
140
|
+
.map_err(|e| NativeError {
|
|
137
141
|
message: e.to_string(),
|
|
138
142
|
})?;
|
|
139
143
|
if optimize {
|
|
@@ -25,12 +25,14 @@ fn optimize_statement(stmt: &Statement) -> Statement {
|
|
|
25
25
|
}
|
|
26
26
|
Statement::VarDecl {
|
|
27
27
|
name,
|
|
28
|
+
name_span,
|
|
28
29
|
mutable,
|
|
29
30
|
type_ann,
|
|
30
31
|
init,
|
|
31
32
|
span,
|
|
32
33
|
} => Statement::VarDecl {
|
|
33
34
|
name: Arc::clone(name),
|
|
35
|
+
name_span: *name_span,
|
|
34
36
|
mutable: *mutable,
|
|
35
37
|
type_ann: type_ann.clone(),
|
|
36
38
|
init: init.as_ref().map(optimize_expr),
|
|
@@ -101,11 +103,13 @@ fn optimize_statement(stmt: &Statement) -> Statement {
|
|
|
101
103
|
},
|
|
102
104
|
Statement::ForOf {
|
|
103
105
|
name,
|
|
106
|
+
name_span,
|
|
104
107
|
iterable,
|
|
105
108
|
body,
|
|
106
109
|
span,
|
|
107
110
|
} => Statement::ForOf {
|
|
108
111
|
name: Arc::clone(name),
|
|
112
|
+
name_span: *name_span,
|
|
109
113
|
iterable: optimize_expr(iterable),
|
|
110
114
|
body: Box::new(optimize_statement(body)),
|
|
111
115
|
span: *span,
|
|
@@ -119,6 +123,7 @@ fn optimize_statement(stmt: &Statement) -> Statement {
|
|
|
119
123
|
Statement::FunDecl {
|
|
120
124
|
async_,
|
|
121
125
|
name,
|
|
126
|
+
name_span,
|
|
122
127
|
params,
|
|
123
128
|
rest_param,
|
|
124
129
|
return_type,
|
|
@@ -127,6 +132,7 @@ fn optimize_statement(stmt: &Statement) -> Statement {
|
|
|
127
132
|
} => Statement::FunDecl {
|
|
128
133
|
async_: *async_,
|
|
129
134
|
name: Arc::clone(name),
|
|
135
|
+
name_span: *name_span,
|
|
130
136
|
params: params.clone(),
|
|
131
137
|
rest_param: rest_param.clone(),
|
|
132
138
|
return_type: return_type.clone(),
|
|
@@ -159,19 +165,25 @@ fn optimize_statement(stmt: &Statement) -> Statement {
|
|
|
159
165
|
Statement::Try {
|
|
160
166
|
body,
|
|
161
167
|
catch_param,
|
|
168
|
+
catch_param_span,
|
|
162
169
|
catch_body,
|
|
163
170
|
finally_body,
|
|
164
171
|
span,
|
|
165
172
|
} => Statement::Try {
|
|
166
173
|
body: Box::new(optimize_statement(body)),
|
|
167
174
|
catch_param: catch_param.clone(),
|
|
175
|
+
catch_param_span: *catch_param_span,
|
|
168
176
|
catch_body: catch_body.as_ref().map(|b| Box::new(optimize_statement(b))),
|
|
169
177
|
finally_body: finally_body
|
|
170
178
|
.as_ref()
|
|
171
179
|
.map(|b| Box::new(optimize_statement(b))),
|
|
172
180
|
span: *span,
|
|
173
181
|
},
|
|
174
|
-
Statement::Import { .. }
|
|
182
|
+
Statement::Import { .. }
|
|
183
|
+
| Statement::Export { .. }
|
|
184
|
+
| Statement::TypeAlias { .. }
|
|
185
|
+
| Statement::DeclareVar { .. }
|
|
186
|
+
| Statement::DeclareFun { .. } => stmt.clone(),
|
|
175
187
|
}
|
|
176
188
|
}
|
|
177
189
|
|
|
@@ -354,7 +366,10 @@ fn optimize_expr(expr: &Expr) -> Expr {
|
|
|
354
366
|
} => {
|
|
355
367
|
let opt_obj = optimize_expr(object);
|
|
356
368
|
let opt_prop = match prop {
|
|
357
|
-
tishlang_ast::MemberProp::Name
|
|
369
|
+
tishlang_ast::MemberProp::Name { name, span } => tishlang_ast::MemberProp::Name {
|
|
370
|
+
name: Arc::clone(name),
|
|
371
|
+
span: *span,
|
|
372
|
+
},
|
|
358
373
|
tishlang_ast::MemberProp::Expr(e) => {
|
|
359
374
|
tishlang_ast::MemberProp::Expr(Box::new(optimize_expr(e)))
|
|
360
375
|
}
|
|
@@ -174,7 +174,7 @@ mod tests {
|
|
|
174
174
|
Expr::New { callee, args, .. } => {
|
|
175
175
|
assert!(matches!(
|
|
176
176
|
callee.as_ref(),
|
|
177
|
-
Expr::Member { prop: tishlang_ast::MemberProp::Name
|
|
177
|
+
Expr::Member { prop: tishlang_ast::MemberProp::Name { name, .. }, .. } if name.as_ref() == "AudioContext"
|
|
178
178
|
));
|
|
179
179
|
assert!(args.is_empty());
|
|
180
180
|
}
|
|
@@ -214,10 +214,10 @@ mod tests {
|
|
|
214
214
|
match e {
|
|
215
215
|
Expr::Member {
|
|
216
216
|
object,
|
|
217
|
-
prop: tishlang_ast::MemberProp::Name
|
|
217
|
+
prop: tishlang_ast::MemberProp::Name { name, .. },
|
|
218
218
|
..
|
|
219
219
|
} => {
|
|
220
|
-
assert_eq!(
|
|
220
|
+
assert_eq!(name.as_ref(), "bar");
|
|
221
221
|
match object.as_ref() {
|
|
222
222
|
Expr::New { callee, args, .. } => {
|
|
223
223
|
assert!(
|
|
@@ -245,4 +245,11 @@ mod tests {
|
|
|
245
245
|
_ => panic!("expected New"),
|
|
246
246
|
}
|
|
247
247
|
}
|
|
248
|
+
|
|
249
|
+
#[test]
|
|
250
|
+
fn stdlib_builtins_d_tish_parses() {
|
|
251
|
+
const SRC: &str = include_str!("../../../stdlib/builtins.d.tish");
|
|
252
|
+
parse(SRC).expect("stdlib/builtins.d.tish should parse");
|
|
253
|
+
}
|
|
254
|
+
|
|
248
255
|
}
|