@ugo-studio/jspp 0.1.6 → 0.1.7

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/LICENSE CHANGED
@@ -1,21 +1,25 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Emmanuel
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the “Software”), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ # License
2
+
3
+ JSPP is licensed under the [MIT License](#mit-license).
4
+
5
+ ## MIT License
6
+
7
+ Copyright (c) 2025 Emmanuel
8
+
9
+ Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ of this software and associated documentation files (the "Software"), to deal
11
+ in the Software without restriction, including without limitation the rights
12
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ copies of the Software, and to permit persons to whom the Software is
14
+ furnished to do so, subject to the following conditions:
15
+
16
+ The above copyright notice and this permission notice shall be included in all
17
+ copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ SOFTWARE.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # JSPP (JavaScript++)
2
2
 
3
- [![Build Status](https://img.shields.io/badge/build-passing-brightgreen)](https://github.com/ugo-studio/jspp)
3
+ [![CI](https://github.com/ugo-studio/jspp/actions/workflows/ci.yml/badge.svg)](https://github.com/ugo-studio/jspp/actions/workflows/ci.yml)
4
4
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
5
 
6
6
  **JSPP is a modern, experimental transpiler that converts JavaScript code into high-performance, standard C++23.**
@@ -33,24 +33,10 @@ JSPP reserves certain keywords to avoid conflicts with the generated C++ code an
33
33
 
34
34
  - `std`: Reserved to prevent conflicts with the C++ standard library namespace.
35
35
  - `jspp`: Reserved for internal use by the JSPP transpiler.
36
- - `co_yield`: Reserved to prevent conflicts with the c++ generator functions.
37
- - `co_return`: Reserved to prevent conflicts with the c++ generator functions.
36
+ - `co_yield`,`co_return`,`co_await`: Reserved to prevent conflicts with the c++ couroutine keywords.
38
37
 
39
38
  Using these keywords as variable names will result in a `SyntaxError`.
40
39
 
41
- ## How It Works
42
-
43
- The transpilation process is a classic three-stage pipeline:
44
-
45
- 1. **Parsing:** The incoming JavaScript code is parsed into an Abstract Syntax Tree (AST) using the powerful TypeScript compiler API. This gives us a structured, traversable representation of the code.
46
-
47
- 2. **Analysis:** The `TypeAnalyzer` traverses the AST. While it doesn't perform traditional static type checking, it plays a crucial role in understanding the code's structure. It identifies scopes (global, function, block) and detects when variables are "captured" by closures.
48
-
49
- 3. **Code Generation:** The `CodeGenerator` performs a final traversal of the AST. It translates each node into its C++ equivalent.
50
- - All variables are declared as `std::shared_ptr<AnyValue>` (where `AnyValue` uses a [Tagged Union](https://en.wikipedia.org/wiki/Tagged_union) method for managing dynamic types like JavaScript). This approach elegantly mimics JavaScript's dynamic types and reference-based memory model.
51
- - Closures are implemented as C++ lambdas that capture `shared_ptr`s by value, ensuring variable lifetimes are correctly extended beyond their original scope.
52
- - The entire script is wrapped into a single `main` function, with hoisting logic carefully replicated to ensure correct execution order.
53
-
54
40
  ## Installation
55
41
 
56
42
  To use JSPP as a command-line tool, install it globally via npm:
package/dist/cli.js CHANGED
@@ -27,8 +27,11 @@ async function main() {
27
27
  console.log(`${COLORS.bold}JSPP Compiler${COLORS.reset} ${COLORS.dim}v${pkg.version}${COLORS.reset}`);
28
28
  console.log(`Mode: ${isRelease ? COLORS.green : COLORS.yellow}${mode.toUpperCase()}${COLORS.reset}\n`);
29
29
  const flags = isRelease
30
- ? ["-O3", "-DNDEBUG", "-Wa,-mbig-obj"]
31
- : ["-O0", "-Wa,-mbig-obj"];
30
+ ? ["-O3", "-DNDEBUG"]
31
+ : ["-O0"];
32
+ if (process.platform === "win32") {
33
+ flags.push("-Wa,-mbig-obj");
34
+ }
32
35
  const pchDir = path.resolve(process.cwd(), "prelude-build", mode);
33
36
  const spinner = new Spinner("Initializing...");
34
37
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ugo-studio/jspp",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "A modern transpiler that converts JavaScript code into high-performance, standard C++23.",
5
5
  "main": "dist/index.js",
6
6
  "module": "src/index.ts",
@@ -13,6 +13,7 @@
13
13
  "src/prelude"
14
14
  ],
15
15
  "scripts": {
16
+ "postinstall": "bun run scripts/setup-compiler.ts",
16
17
  "dev": "bun run src/cli.ts",
17
18
  "typecheck": "tsc --noEmit",
18
19
  "precompile": "bun run scripts/precompile-headers.ts",
@@ -17,8 +17,8 @@ namespace jspp
17
17
  uint64_t length = 0;
18
18
 
19
19
  JsArray() : proto(nullptr) {}
20
- explicit JsArray(const std::vector<AnyValue> &items) : dense(items), proto(nullptr), length(items.size()) {}
21
- explicit JsArray(std::vector<AnyValue> &&items) : dense(std::move(items)), proto(nullptr), length(dense.size()) {}
20
+ explicit JsArray(const std::vector<AnyValue> &items);
21
+ explicit JsArray(std::vector<AnyValue> &&items);
22
22
 
23
23
  std::string to_std_string() const;
24
24
  JsIterator<AnyValue> get_iterator();
@@ -6,6 +6,9 @@
6
6
  #include "any_value.hpp"
7
7
  #include "values/prototypes/array.hpp"
8
8
 
9
+ jspp::JsArray::JsArray(const std::vector<jspp::AnyValue> &items) : dense(items), proto(nullptr), length(items.size()) {}
10
+ jspp::JsArray::JsArray(std::vector<jspp::AnyValue> &&items) : dense(std::move(items)), proto(nullptr), length(dense.size()) {}
11
+
9
12
  std::string jspp::JsArray::to_std_string() const
10
13
  {
11
14
  if (length == 0)