@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.
Files changed (99) hide show
  1. package/Cargo.toml +2 -0
  2. package/README.md +2 -0
  3. package/bin/tish +0 -0
  4. package/crates/js_to_tish/src/transform/expr.rs +28 -8
  5. package/crates/js_to_tish/src/transform/stmt.rs +49 -22
  6. package/crates/tish/Cargo.toml +14 -5
  7. package/crates/tish/src/cargo_native_registry.rs +29 -0
  8. package/crates/tish/src/cli_help.rs +16 -10
  9. package/crates/tish/src/main.rs +87 -32
  10. package/crates/tish/src/repl_completion.rs +3 -3
  11. package/crates/tish/tests/cargo_example_compile.rs +1 -1
  12. package/crates/tish/tests/integration_test.rs +19 -7
  13. package/crates/tish/tests/shortcircuit.rs +1 -1
  14. package/crates/tish_ast/src/ast.rs +80 -9
  15. package/crates/tish_build_utils/Cargo.toml +4 -0
  16. package/crates/tish_build_utils/src/lib.rs +105 -2
  17. package/crates/tish_builtins/Cargo.toml +5 -1
  18. package/crates/tish_builtins/src/array.rs +13 -12
  19. package/crates/tish_builtins/src/construct.rs +34 -33
  20. package/crates/tish_builtins/src/globals.rs +12 -11
  21. package/crates/tish_builtins/src/helpers.rs +2 -1
  22. package/crates/tish_builtins/src/object.rs +3 -2
  23. package/crates/tish_builtins/src/string.rs +73 -3
  24. package/crates/tish_bytecode/src/compiler.rs +12 -14
  25. package/crates/tish_bytecode/src/opcode.rs +12 -3
  26. package/crates/tish_compile/Cargo.toml +1 -0
  27. package/crates/tish_compile/src/codegen.rs +745 -199
  28. package/crates/tish_compile/src/infer.rs +6 -0
  29. package/crates/tish_compile/src/lib.rs +4 -3
  30. package/crates/tish_compile/src/resolve.rs +180 -82
  31. package/crates/tish_compile/src/types.rs +175 -11
  32. package/crates/tish_compile_js/Cargo.toml +1 -0
  33. package/crates/tish_compile_js/src/codegen.rs +152 -29
  34. package/crates/tish_compile_js/src/lib.rs +3 -1
  35. package/crates/tish_compiler_wasm/src/resolve_virtual.rs +31 -12
  36. package/crates/tish_core/Cargo.toml +8 -0
  37. package/crates/tish_core/src/json.rs +102 -53
  38. package/crates/tish_core/src/lib.rs +3 -1
  39. package/crates/tish_core/src/macros.rs +5 -5
  40. package/crates/tish_core/src/value.rs +53 -15
  41. package/crates/tish_core/src/vmref.rs +178 -0
  42. package/crates/tish_eval/Cargo.toml +17 -2
  43. package/crates/tish_eval/src/eval.rs +90 -28
  44. package/crates/tish_eval/src/http.rs +61 -0
  45. package/crates/tish_eval/src/lib.rs +3 -3
  46. package/crates/tish_eval/src/natives.rs +41 -0
  47. package/crates/tish_eval/src/value.rs +7 -3
  48. package/crates/tish_eval/src/value_convert.rs +13 -5
  49. package/crates/tish_fmt/src/lib.rs +120 -30
  50. package/crates/tish_lexer/src/lib.rs +20 -5
  51. package/crates/tish_lexer/src/token.rs +4 -0
  52. package/crates/tish_llvm/src/lib.rs +3 -1
  53. package/crates/tish_lsp/Cargo.toml +4 -1
  54. package/crates/tish_lsp/README.md +1 -1
  55. package/crates/tish_lsp/src/builtin_goto.rs +261 -0
  56. package/crates/tish_lsp/src/import_goto.rs +549 -0
  57. package/crates/tish_lsp/src/main.rs +502 -102
  58. package/crates/tish_native/src/build.rs +3 -2
  59. package/crates/tish_native/src/lib.rs +6 -2
  60. package/crates/tish_opt/src/lib.rs +17 -2
  61. package/crates/tish_parser/src/lib.rs +10 -3
  62. package/crates/tish_parser/src/parser.rs +346 -56
  63. package/crates/tish_pg/Cargo.toml +34 -0
  64. package/crates/tish_pg/README.md +38 -0
  65. package/crates/tish_pg/src/error.rs +52 -0
  66. package/crates/tish_pg/src/lib.rs +967 -0
  67. package/crates/tish_resolve/Cargo.toml +13 -0
  68. package/crates/tish_resolve/src/lib.rs +3436 -0
  69. package/crates/tish_resolve/src/pos.rs +133 -0
  70. package/crates/tish_runtime/Cargo.toml +68 -3
  71. package/crates/tish_runtime/src/http.rs +1123 -141
  72. package/crates/tish_runtime/src/http_fetch.rs +15 -14
  73. package/crates/tish_runtime/src/http_hyper.rs +418 -0
  74. package/crates/tish_runtime/src/http_prefork.rs +189 -0
  75. package/crates/tish_runtime/src/lib.rs +159 -29
  76. package/crates/tish_runtime/src/promise.rs +199 -36
  77. package/crates/tish_runtime/src/promise_io.rs +2 -1
  78. package/crates/tish_runtime/src/timers.rs +37 -1
  79. package/crates/tish_runtime/src/ws.rs +26 -28
  80. package/crates/tish_ui/src/jsx.rs +279 -8
  81. package/crates/tish_ui/src/lib.rs +5 -2
  82. package/crates/tish_ui/src/runtime/hooks.rs +406 -45
  83. package/crates/tish_ui/src/runtime/mod.rs +36 -9
  84. package/crates/tish_vm/Cargo.toml +15 -5
  85. package/crates/tish_vm/src/vm.rs +506 -259
  86. package/crates/tish_vm/tests/peephole_jump_chain_logical_or.rs +3 -1
  87. package/crates/tish_wasm/src/lib.rs +17 -14
  88. package/crates/tish_wasm_runtime/Cargo.toml +2 -1
  89. package/crates/tish_wasm_runtime/src/lib.rs +1 -1
  90. package/crates/tishlang_cargo_bindgen/Cargo.toml +1 -0
  91. package/crates/tishlang_cargo_bindgen/src/discover.rs +68 -0
  92. package/crates/tishlang_cargo_bindgen/src/lib.rs +5 -4
  93. package/justfile +8 -0
  94. package/package.json +1 -1
  95. package/platform/darwin-arm64/tish +0 -0
  96. package/platform/darwin-x64/tish +0 -0
  97. package/platform/linux-arm64/tish +0 -0
  98. package/platform/linux-x64/tish +0 -0
  99. 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] = &["http", "fs", "process", "regex", "ws"];
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 = "thin"
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).map_err(|e| NativeError {
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).map_err(|e| NativeError {
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 { .. } | Statement::Export { .. } => stmt.clone(),
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(n) => tishlang_ast::MemberProp::Name(Arc::clone(n)),
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(p), .. } if p.as_ref() == "AudioContext"
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(p),
217
+ prop: tishlang_ast::MemberProp::Name { name, .. },
218
218
  ..
219
219
  } => {
220
- assert_eq!(p.as_ref(), "bar");
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
  }