@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.
Files changed (108) hide show
  1. package/Cargo.toml +2 -0
  2. package/bin/tish-format +0 -0
  3. package/crates/js_to_tish/src/transform/expr.rs +1 -0
  4. package/crates/tish/Cargo.toml +10 -2
  5. package/crates/tish/build.rs +21 -0
  6. package/crates/tish/src/cli_help.rs +15 -4
  7. package/crates/tish/src/main.rs +93 -21
  8. package/crates/tish/src/repl_completion.rs +0 -1
  9. package/crates/tish/tests/error_source_location.rs +36 -0
  10. package/crates/tish/tests/fixtures/runtime_error_location.tish +5 -0
  11. package/crates/tish/tests/fixtures/trycatch_runtime_errors.tish +15 -0
  12. package/crates/tish/tests/fixtures/tty_capability.tish +9 -0
  13. package/crates/tish/tests/integration_test.rs +402 -91
  14. package/crates/tish/tests/trycatch_runtime_errors.rs +45 -0
  15. package/crates/tish/tests/tty_capability.rs +43 -0
  16. package/crates/tish_ast/src/ast.rs +37 -8
  17. package/crates/tish_builtins/Cargo.toml +2 -0
  18. package/crates/tish_builtins/src/array.rs +375 -13
  19. package/crates/tish_builtins/src/collections.rs +481 -0
  20. package/crates/tish_builtins/src/construct.rs +59 -19
  21. package/crates/tish_builtins/src/date.rs +538 -0
  22. package/crates/tish_builtins/src/globals.rs +86 -6
  23. package/crates/tish_builtins/src/iterator.rs +129 -0
  24. package/crates/tish_builtins/src/lib.rs +5 -0
  25. package/crates/tish_builtins/src/number.rs +96 -0
  26. package/crates/tish_builtins/src/object.rs +2 -2
  27. package/crates/tish_builtins/src/string.rs +19 -20
  28. package/crates/tish_builtins/src/symbol.rs +1 -1
  29. package/crates/tish_builtins/src/typedarrays.rs +298 -0
  30. package/crates/tish_bytecode/src/chunk.rs +69 -1
  31. package/crates/tish_bytecode/src/compiler.rs +933 -89
  32. package/crates/tish_bytecode/src/encoding.rs +2 -0
  33. package/crates/tish_bytecode/src/lib.rs +2 -1
  34. package/crates/tish_bytecode/src/opcode.rs +47 -4
  35. package/crates/tish_bytecode/src/serialize.rs +31 -1
  36. package/crates/tish_compile/Cargo.toml +1 -0
  37. package/crates/tish_compile/src/check.rs +774 -0
  38. package/crates/tish_compile/src/codegen.rs +2334 -349
  39. package/crates/tish_compile/src/infer.rs +1395 -6
  40. package/crates/tish_compile/src/lib.rs +50 -8
  41. package/crates/tish_compile/src/resolve.rs +584 -21
  42. package/crates/tish_compile/src/types.rs +106 -2
  43. package/crates/tish_compile_js/src/codegen.rs +67 -0
  44. package/crates/tish_compile_js/src/tests_jsx.rs +64 -0
  45. package/crates/tish_core/Cargo.toml +7 -1
  46. package/crates/tish_core/src/console_style.rs +11 -1
  47. package/crates/tish_core/src/json.rs +81 -38
  48. package/crates/tish_core/src/lib.rs +3 -0
  49. package/crates/tish_core/src/shape.rs +85 -0
  50. package/crates/tish_core/src/value.rs +679 -25
  51. package/crates/tish_core/src/vmref.rs +13 -8
  52. package/crates/tish_cranelift/src/link.rs +17 -4
  53. package/crates/tish_cranelift_runtime/Cargo.toml +1 -0
  54. package/crates/tish_eval/Cargo.toml +6 -0
  55. package/crates/tish_eval/src/eval.rs +665 -117
  56. package/crates/tish_eval/src/http.rs +4 -1
  57. package/crates/tish_eval/src/natives.rs +165 -13
  58. package/crates/tish_eval/src/value.rs +31 -13
  59. package/crates/tish_eval/src/value_convert.rs +10 -4
  60. package/crates/tish_ffi/Cargo.toml +26 -0
  61. package/crates/tish_ffi/src/lib.rs +518 -0
  62. package/crates/tish_ffi/tests/fixtures/testmod/Cargo.toml +18 -0
  63. package/crates/tish_ffi/tests/fixtures/testmod/src/lib.rs +46 -0
  64. package/crates/tish_ffi/tests/loader.rs +65 -0
  65. package/crates/tish_fmt/Cargo.toml +1 -1
  66. package/crates/tish_fmt/src/lib.rs +61 -5
  67. package/crates/tish_lexer/src/lib.rs +397 -9
  68. package/crates/tish_lexer/src/token.rs +7 -0
  69. package/crates/tish_lint/src/lib.rs +2 -10
  70. package/crates/tish_lsp/src/import_goto.rs +2 -0
  71. package/crates/tish_lsp/src/main.rs +439 -26
  72. package/crates/tish_native/src/build.rs +55 -1
  73. package/crates/tish_opt/src/lib.rs +126 -23
  74. package/crates/tish_parser/src/lib.rs +55 -1
  75. package/crates/tish_parser/src/parser.rs +456 -34
  76. package/crates/tish_pg/src/lib.rs +3 -3
  77. package/crates/tish_resolve/src/lib.rs +99 -59
  78. package/crates/tish_runtime/Cargo.toml +4 -0
  79. package/crates/tish_runtime/src/http.rs +66 -17
  80. package/crates/tish_runtime/src/http_fetch.rs +29 -8
  81. package/crates/tish_runtime/src/http_hyper.rs +25 -2
  82. package/crates/tish_runtime/src/lib.rs +299 -44
  83. package/crates/tish_runtime/src/promise.rs +328 -18
  84. package/crates/tish_runtime/src/timers.rs +13 -7
  85. package/crates/tish_runtime/src/tty.rs +226 -0
  86. package/crates/tish_runtime/src/ws.rs +35 -18
  87. package/crates/tish_runtime/tests/fetch_readable_stream.rs +2 -2
  88. package/crates/tish_ui/src/jsx.rs +10 -0
  89. package/crates/tish_ui/src/runtime/hooks.rs +19 -15
  90. package/crates/tish_ui/src/runtime/mod.rs +15 -12
  91. package/crates/tish_vm/Cargo.toml +14 -1
  92. package/crates/tish_vm/src/jit.rs +1050 -0
  93. package/crates/tish_vm/src/lib.rs +2 -0
  94. package/crates/tish_vm/src/vm.rs +1546 -202
  95. package/crates/tish_vm/tests/concurrent_shared_state.rs +140 -0
  96. package/crates/tish_wasm/src/lib.rs +6 -2
  97. package/crates/tish_wasm_runtime/src/gpu.rs +17 -1
  98. package/crates/tishlang_cargo_bindgen/src/classify.rs +1 -3
  99. package/crates/tishlang_cargo_bindgen/src/lib.rs +2 -2
  100. package/crates/tishlang_cargo_bindgen/src/metadata.rs +1 -1
  101. package/justfile +8 -0
  102. package/package.json +2 -2
  103. package/platform/darwin-arm64/tish-fmt +0 -0
  104. package/platform/darwin-x64/tish-fmt +0 -0
  105. package/platform/linux-arm64/tish-fmt +0 -0
  106. package/platform/linux-x64/tish-fmt +0 -0
  107. package/platform/win32-x64/tish-fmt.exe +0 -0
  108. package/README.md +0 -138
@@ -24,6 +24,20 @@ pub enum TypeAnnotation {
24
24
  },
25
25
  /// Union type: T1 | T2
26
26
  Union(Vec<TypeAnnotation>),
27
+ /// Tuple type: [T1, T2, ...]
28
+ Tuple(Vec<TypeAnnotation>),
29
+ /// Literal type: "foo" | 42 | true (a value used as a type)
30
+ Literal(TypeLiteral),
31
+ /// Intersection type: T1 & T2 (e.g. `interface X extends Y { … }` → `Y & { … }`)
32
+ Intersection(Vec<TypeAnnotation>),
33
+ }
34
+
35
+ /// A literal value used in type position (`"a"`, `42`, `true`).
36
+ #[derive(Debug, Clone, PartialEq)]
37
+ pub enum TypeLiteral {
38
+ Str(Arc<str>),
39
+ Num(f64),
40
+ Bool(bool),
27
41
  }
28
42
 
29
43
  /// Function parameter with optional type annotation and default value.
@@ -62,15 +76,13 @@ impl FunParam {
62
76
  fn collect_pattern_binding_names(pattern: &DestructPattern, out: &mut Vec<Arc<str>>) {
63
77
  match pattern {
64
78
  DestructPattern::Array(elements) => {
65
- for el in elements {
66
- if let Some(el) = el {
67
- match el {
68
- DestructElement::Ident(n, _) => out.push(Arc::clone(n)),
69
- DestructElement::Pattern(p) => {
70
- Self::collect_pattern_binding_names(p, out);
71
- }
72
- DestructElement::Rest(n, _) => out.push(Arc::clone(n)),
79
+ for el in elements.iter().flatten() {
80
+ match el {
81
+ DestructElement::Ident(n, _) => out.push(Arc::clone(n)),
82
+ DestructElement::Pattern(p) => {
83
+ Self::collect_pattern_binding_names(p, out);
73
84
  }
85
+ DestructElement::Rest(n, _) => out.push(Arc::clone(n)),
74
86
  }
75
87
  }
76
88
  }
@@ -169,6 +181,14 @@ pub enum Statement {
169
181
  init: Expr,
170
182
  span: Span,
171
183
  },
184
+ /// A transparent group of statements that execute in the *current* scope
185
+ /// (no new block scope). Produced for comma-separated declarators
186
+ /// (`let a = 1, b = 2`) so each declarator lowers to its own VarDecl while
187
+ /// still occupying a single statement slot (e.g. a `for` initializer).
188
+ Multi {
189
+ statements: Vec<Statement>,
190
+ span: Span,
191
+ },
172
192
  ExprStmt {
173
193
  expr: Expr,
174
194
  span: Span,
@@ -349,6 +369,11 @@ pub enum Expr {
349
369
  operand: Box<Expr>,
350
370
  span: Span,
351
371
  },
372
+ /// `delete obj.prop` / `delete obj[key]` — removes a property, evaluates to a boolean.
373
+ Delete {
374
+ target: Box<Expr>,
375
+ span: Span,
376
+ },
352
377
  PostfixInc {
353
378
  name: Arc<str>,
354
379
  span: Span,
@@ -475,6 +500,7 @@ impl Expr {
475
500
  Expr::Object { span, .. } => *span,
476
501
  Expr::Assign { span, .. } => *span,
477
502
  Expr::TypeOf { span, .. } => *span,
503
+ Expr::Delete { span, .. } => *span,
478
504
  Expr::PostfixInc { span, .. } => *span,
479
505
  Expr::PostfixDec { span, .. } => *span,
480
506
  Expr::PrefixInc { span, .. } => *span,
@@ -568,6 +594,8 @@ pub enum BinOp {
568
594
  BitXor,
569
595
  Shl,
570
596
  Shr,
597
+ /// `>>>` — unsigned (logical) right shift; JS ToUint32 semantics.
598
+ UShr,
571
599
  In,
572
600
  }
573
601
 
@@ -597,6 +625,7 @@ impl Statement {
597
625
  Statement::Block { span, .. }
598
626
  | Statement::VarDecl { span, .. }
599
627
  | Statement::VarDeclDestructure { span, .. }
628
+ | Statement::Multi { span, .. }
600
629
  | Statement::ExprStmt { span, .. }
601
630
  | Statement::If { span, .. }
602
631
  | Statement::While { span, .. }
@@ -8,6 +8,8 @@ description = "Shared builtin implementations for Tish (array, string, object, m
8
8
  license-file = { workspace = true }
9
9
  repository = { workspace = true }
10
10
  [dependencies]
11
+ ahash = "0.8.11"
12
+ indexmap = "2"
11
13
  rand = "0.10.1"
12
14
  tishlang_core = { path = "../tish_core", version = ">=0.1" }
13
15