@tishlang/tish 1.0.29 → 1.0.33

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 (60) hide show
  1. package/Cargo.toml +1 -0
  2. package/crates/js_to_tish/src/transform/expr.rs +15 -6
  3. package/crates/tish/Cargo.toml +1 -1
  4. package/crates/tish/src/main.rs +1 -1
  5. package/crates/tish/tests/integration_test.rs +4 -3
  6. package/crates/tish_ast/src/ast.rs +65 -2
  7. package/crates/tish_build_utils/src/lib.rs +10 -2
  8. package/crates/tish_builtins/src/construct.rs +177 -0
  9. package/crates/tish_builtins/src/globals.rs +3 -5
  10. package/crates/tish_builtins/src/helpers.rs +2 -3
  11. package/crates/tish_builtins/src/lib.rs +1 -0
  12. package/crates/tish_builtins/src/object.rs +3 -4
  13. package/crates/tish_bytecode/src/compiler.rs +85 -11
  14. package/crates/tish_bytecode/src/opcode.rs +7 -3
  15. package/crates/tish_compile/Cargo.toml +1 -0
  16. package/crates/tish_compile/src/codegen.rs +233 -71
  17. package/crates/tish_compile/src/lib.rs +35 -0
  18. package/crates/tish_compile_js/Cargo.toml +1 -0
  19. package/crates/tish_compile_js/src/codegen.rs +38 -94
  20. package/crates/tish_compile_js/src/lib.rs +0 -1
  21. package/crates/tish_compile_js/src/tests_jsx.rs +68 -0
  22. package/crates/tish_core/Cargo.toml +4 -0
  23. package/crates/tish_core/src/console_style.rs +7 -1
  24. package/crates/tish_core/src/json.rs +1 -2
  25. package/crates/tish_core/src/macros.rs +2 -3
  26. package/crates/tish_core/src/value.rs +10 -5
  27. package/crates/tish_eval/Cargo.toml +2 -0
  28. package/crates/tish_eval/src/eval.rs +149 -72
  29. package/crates/tish_eval/src/http.rs +3 -4
  30. package/crates/tish_eval/src/regex.rs +3 -2
  31. package/crates/tish_eval/src/value.rs +11 -13
  32. package/crates/tish_eval/src/value_convert.rs +4 -8
  33. package/crates/tish_fmt/src/lib.rs +49 -10
  34. package/crates/tish_lexer/src/token.rs +2 -0
  35. package/crates/tish_lint/src/lib.rs +9 -0
  36. package/crates/tish_lsp/README.md +1 -1
  37. package/crates/tish_native/src/build.rs +16 -2
  38. package/crates/tish_opt/src/lib.rs +15 -0
  39. package/crates/tish_parser/src/lib.rs +101 -1
  40. package/crates/tish_parser/src/parser.rs +161 -50
  41. package/crates/tish_runtime/src/http.rs +4 -5
  42. package/crates/tish_runtime/src/http_fetch.rs +9 -10
  43. package/crates/tish_runtime/src/lib.rs +9 -2
  44. package/crates/tish_runtime/src/promise.rs +2 -3
  45. package/crates/tish_runtime/src/promise_io.rs +2 -3
  46. package/crates/tish_runtime/src/ws.rs +7 -7
  47. package/crates/tish_ui/Cargo.toml +17 -0
  48. package/crates/tish_ui/src/jsx.rs +390 -0
  49. package/crates/tish_ui/src/lib.rs +16 -0
  50. package/crates/tish_ui/src/runtime/hooks.rs +122 -0
  51. package/crates/tish_ui/src/runtime/mod.rs +173 -0
  52. package/crates/tish_vm/src/vm.rs +121 -27
  53. package/justfile +3 -3
  54. package/package.json +1 -1
  55. package/platform/darwin-arm64/tish +0 -0
  56. package/platform/darwin-x64/tish +0 -0
  57. package/platform/linux-arm64/tish +0 -0
  58. package/platform/linux-x64/tish +0 -0
  59. package/platform/win32-x64/tish.exe +0 -0
  60. package/crates/tish_compile_js/src/js_intrinsics.rs +0 -82
@@ -1,82 +0,0 @@
1
- //! JS-only call sites that require `new` (Tish has no `new`).
2
- //! Intrinsic names, validation, and runtime preamble live here — main codegen only dispatches.
3
-
4
- use tishlang_ast::{CallArg, Expr};
5
-
6
- use crate::error::CompileError;
7
-
8
- /// Built-in calls lowered to `new ...` in the JS emit.
9
- #[derive(Debug, Clone, Copy, PartialEq, Eq)]
10
- pub enum JsIntrinsic {
11
- WebAudioCreateContext,
12
- Uint8Array,
13
- }
14
-
15
- #[derive(Debug, Default)]
16
- pub struct JsIntrinsics {
17
- pub needs_web_audio: bool,
18
- pub needs_uint8_array: bool,
19
- }
20
-
21
- impl JsIntrinsics {
22
- pub fn new() -> Self {
23
- Self::default()
24
- }
25
-
26
- /// Recognize `webAudioCreateContext()` / `jsUint8Array(n)` and validate arguments.
27
- pub fn classify_call(callee: &Expr, args: &[CallArg]) -> Result<Option<JsIntrinsic>, CompileError> {
28
- let Expr::Ident { name, .. } = callee else {
29
- return Ok(None);
30
- };
31
- match name.as_ref() {
32
- "webAudioCreateContext" => {
33
- if !args.is_empty() {
34
- return Err(CompileError::new(
35
- "webAudioCreateContext() takes no arguments (JS target only)",
36
- ));
37
- }
38
- Ok(Some(JsIntrinsic::WebAudioCreateContext))
39
- }
40
- "jsUint8Array" => {
41
- if args.len() != 1 {
42
- return Err(CompileError::new(
43
- "jsUint8Array(length) expects one argument (JS target only)",
44
- ));
45
- }
46
- Ok(Some(JsIntrinsic::Uint8Array))
47
- }
48
- _ => Ok(None),
49
- }
50
- }
51
-
52
- pub fn mark(&mut self, kind: JsIntrinsic) {
53
- match kind {
54
- JsIntrinsic::WebAudioCreateContext => self.needs_web_audio = true,
55
- JsIntrinsic::Uint8Array => self.needs_uint8_array = true,
56
- }
57
- }
58
-
59
- pub fn emit_expr(kind: JsIntrinsic, uint8_length_js: &str) -> String {
60
- match kind {
61
- JsIntrinsic::WebAudioCreateContext => "(__tishWebAudioCreateContext() ?? null)".to_string(),
62
- JsIntrinsic::Uint8Array => format!("(__tishUint8Array({}) ?? null)", uint8_length_js),
63
- }
64
- }
65
-
66
- /// Prepend runtime helpers (Uint8Array above AudioContext when both are used).
67
- pub fn prepend_runtime_preamble(&self, mut output: String) -> String {
68
- if self.needs_web_audio {
69
- output = format!(
70
- "function __tishWebAudioCreateContext(){{ return new AudioContext(); }}\n{}",
71
- output
72
- );
73
- }
74
- if self.needs_uint8_array {
75
- output = format!(
76
- "function __tishUint8Array(n){{ return new Uint8Array(n); }}\n{}",
77
- output
78
- );
79
- }
80
- output
81
- }
82
- }