@tishlang/tish 1.6.0 → 1.7.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 (79) hide show
  1. package/Cargo.toml +1 -0
  2. package/bin/tish +0 -0
  3. package/crates/js_to_tish/src/error.rs +2 -8
  4. package/crates/js_to_tish/src/transform/expr.rs +101 -130
  5. package/crates/js_to_tish/src/transform/stmt.rs +25 -22
  6. package/crates/tish/Cargo.toml +1 -1
  7. package/crates/tish/src/cli_help.rs +76 -29
  8. package/crates/tish/src/main.rs +85 -54
  9. package/crates/tish/tests/cargo_example_compile.rs +3 -1
  10. package/crates/tish/tests/integration_test.rs +197 -47
  11. package/crates/tish/tests/run_optimize_stdout_parity.rs +3 -7
  12. package/crates/tish/tests/shortcircuit.rs +19 -4
  13. package/crates/tish_ast/src/ast.rs +12 -14
  14. package/crates/tish_build_utils/src/lib.rs +31 -6
  15. package/crates/tish_builtins/src/array.rs +52 -21
  16. package/crates/tish_builtins/src/construct.rs +2 -8
  17. package/crates/tish_builtins/src/globals.rs +30 -15
  18. package/crates/tish_builtins/src/lib.rs +5 -5
  19. package/crates/tish_builtins/src/math.rs +5 -3
  20. package/crates/tish_builtins/src/string.rs +71 -19
  21. package/crates/tish_bytecode/src/chunk.rs +0 -1
  22. package/crates/tish_bytecode/src/compiler.rs +164 -60
  23. package/crates/tish_bytecode/src/opcode.rs +13 -4
  24. package/crates/tish_bytecode/src/peephole.rs +2 -2
  25. package/crates/tish_compile/src/codegen.rs +921 -299
  26. package/crates/tish_compile/src/infer.rs +69 -19
  27. package/crates/tish_compile/src/lib.rs +15 -5
  28. package/crates/tish_compile/src/resolve.rs +112 -69
  29. package/crates/tish_compile/src/types.rs +10 -14
  30. package/crates/tish_compile_js/src/codegen.rs +34 -13
  31. package/crates/tish_compile_js/src/tests_jsx.rs +30 -6
  32. package/crates/tish_compiler_wasm/src/lib.rs +16 -13
  33. package/crates/tish_compiler_wasm/src/resolve_virtual.rs +39 -48
  34. package/crates/tish_core/src/json.rs +5 -3
  35. package/crates/tish_core/src/lib.rs +1 -1
  36. package/crates/tish_core/src/uri.rs +9 -6
  37. package/crates/tish_core/src/value.rs +92 -28
  38. package/crates/tish_cranelift/src/link.rs +6 -9
  39. package/crates/tish_cranelift/src/lower.rs +14 -8
  40. package/crates/tish_eval/src/eval.rs +389 -142
  41. package/crates/tish_eval/src/lib.rs +10 -6
  42. package/crates/tish_eval/src/natives.rs +95 -38
  43. package/crates/tish_eval/src/promise.rs +14 -8
  44. package/crates/tish_eval/src/timers.rs +28 -19
  45. package/crates/tish_eval/src/value.rs +10 -3
  46. package/crates/tish_fmt/src/lib.rs +29 -13
  47. package/crates/tish_lexer/src/lib.rs +217 -63
  48. package/crates/tish_lexer/src/token.rs +6 -6
  49. package/crates/tish_llvm/src/lib.rs +15 -8
  50. package/crates/tish_lsp/src/main.rs +41 -43
  51. package/crates/tish_native/src/build.rs +1 -6
  52. package/crates/tish_native/src/lib.rs +48 -19
  53. package/crates/tish_opt/src/lib.rs +67 -50
  54. package/crates/tish_parser/src/lib.rs +36 -11
  55. package/crates/tish_parser/src/parser.rs +172 -87
  56. package/crates/tish_runtime/src/http.rs +15 -6
  57. package/crates/tish_runtime/src/http_fetch.rs +24 -14
  58. package/crates/tish_runtime/src/lib.rs +224 -168
  59. package/crates/tish_runtime/src/promise.rs +1 -5
  60. package/crates/tish_runtime/src/ws.rs +45 -20
  61. package/crates/tish_runtime/tests/fetch_readable_stream.rs +5 -4
  62. package/crates/tish_ui/src/jsx.rs +41 -22
  63. package/crates/tish_ui/src/lib.rs +2 -2
  64. package/crates/tish_vm/src/vm.rs +309 -112
  65. package/crates/tish_vm/tests/peephole_jump_chain_logical_or.rs +8 -3
  66. package/crates/tish_wasm/src/lib.rs +38 -28
  67. package/crates/tishlang_cargo_bindgen/Cargo.toml +25 -0
  68. package/crates/tishlang_cargo_bindgen/src/classify.rs +265 -0
  69. package/crates/tishlang_cargo_bindgen/src/discover.rs +52 -0
  70. package/crates/tishlang_cargo_bindgen/src/infer.rs +372 -0
  71. package/crates/tishlang_cargo_bindgen/src/lib.rs +349 -0
  72. package/crates/tishlang_cargo_bindgen/src/main.rs +164 -0
  73. package/crates/tishlang_cargo_bindgen/src/metadata.rs +114 -0
  74. package/package.json +1 -1
  75. package/platform/darwin-arm64/tish +0 -0
  76. package/platform/darwin-x64/tish +0 -0
  77. package/platform/linux-arm64/tish +0 -0
  78. package/platform/linux-x64/tish +0 -0
  79. package/platform/win32-x64/tish.exe +0 -0
@@ -12,9 +12,8 @@ pub fn link_to_binary(
12
12
  output_path: &Path,
13
13
  features: &[String],
14
14
  ) -> Result<(), CraneliftError> {
15
- let workspace_root = tishlang_build_utils::find_workspace_root().map_err(|e| CraneliftError {
16
- message: e,
17
- })?;
15
+ let workspace_root =
16
+ tishlang_build_utils::find_workspace_root().map_err(|e| CraneliftError { message: e })?;
18
17
  let out_name = output_path
19
18
  .file_stem()
20
19
  .and_then(|s| s.to_str())
@@ -104,17 +103,15 @@ fn main() {{
104
103
  message: format!("Cannot write build.rs: {}", e),
105
104
  })?;
106
105
 
107
- tishlang_build_utils::run_cargo_build(&build_dir, None).map_err(|e| CraneliftError { message: e })?;
106
+ tishlang_build_utils::run_cargo_build(&build_dir, None)
107
+ .map_err(|e| CraneliftError { message: e })?;
108
108
 
109
109
  let binary_dir = build_dir.join("target").join("release");
110
- let binary =
111
- tishlang_build_utils::find_release_binary(&binary_dir, out_name)
112
- .map_err(|e| CraneliftError { message: e })?;
110
+ let binary = tishlang_build_utils::find_release_binary(&binary_dir, out_name)
111
+ .map_err(|e| CraneliftError { message: e })?;
113
112
  let target = tishlang_build_utils::resolve_output_path(output_path, out_name);
114
113
  tishlang_build_utils::copy_binary_to_output(&binary, &target)
115
114
  .map_err(|e| CraneliftError { message: e })?;
116
115
 
117
116
  Ok(())
118
117
  }
119
-
120
-
@@ -7,8 +7,8 @@
7
7
 
8
8
  use std::path::Path;
9
9
 
10
- use cranelift::codegen::settings::Configurable;
11
10
  use cranelift::codegen::settings;
11
+ use cranelift::codegen::settings::Configurable;
12
12
  use cranelift_module::{DataDescription, Linkage, Module};
13
13
  use cranelift_object::{ObjectBuilder, ObjectModule};
14
14
 
@@ -18,9 +18,11 @@ use crate::CraneliftError;
18
18
 
19
19
  pub fn lower_and_emit(chunk: &Chunk, object_path: &Path) -> Result<(), CraneliftError> {
20
20
  let mut settings_builder = settings::builder();
21
- settings_builder.set("opt_level", "speed").map_err(|_| CraneliftError {
22
- message: "Failed to set opt_level".to_string(),
23
- })?;
21
+ settings_builder
22
+ .set("opt_level", "speed")
23
+ .map_err(|_| CraneliftError {
24
+ message: "Failed to set opt_level".to_string(),
25
+ })?;
24
26
  let flags = settings::Flags::new(settings_builder);
25
27
 
26
28
  let isa_builder = cranelift_native::builder().map_err(|e| CraneliftError {
@@ -30,10 +32,14 @@ pub fn lower_and_emit(chunk: &Chunk, object_path: &Path) -> Result<(), Cranelift
30
32
  message: format!("Failed to finish ISA: {}", e),
31
33
  })?;
32
34
 
33
- let object_builder = ObjectBuilder::new(isa, "tishlang_cranelift", cranelift_module::default_libcall_names())
34
- .map_err(|e| CraneliftError {
35
- message: format!("Failed to create ObjectBuilder: {}", e),
36
- })?;
35
+ let object_builder = ObjectBuilder::new(
36
+ isa,
37
+ "tishlang_cranelift",
38
+ cranelift_module::default_libcall_names(),
39
+ )
40
+ .map_err(|e| CraneliftError {
41
+ message: format!("Failed to create ObjectBuilder: {}", e),
42
+ })?;
37
43
  let mut module = ObjectModule::new(object_builder);
38
44
 
39
45
  // Serialize chunk and emit as data - link step will build a Rust binary that reads it