functionalscript 0.0.563 → 0.0.565

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/doc/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # Documentation
2
2
 
3
- FunctionalScript files have `.f.cjs` file extensions because it's using a `Common.JS` module system. See
3
+ FunctionalScript files have `.f.cjs` file extensions because it's using a `Common.JS` module system. We plan to add
4
+ ESM support when we have the first parser working. See
4
5
  [ESM. Resolver Algorithm Specification](https://nodejs.org/api/esm.html#resolver-algorithm-specification)
5
6
  and [ESM. Enabling](https://nodejs.org/docs/latest-v13.x/api/esm.html#esm_enabling).
6
7
 
@@ -93,4 +94,4 @@ const range5 = {*[System.iterator]() {
93
94
  yield 2
94
95
  yield 3
95
96
  }}
96
- ```
97
+ ```
@@ -0,0 +1,60 @@
1
+ # Byte Code
2
+
3
+ This format is designed for fast and straightforward serialization and doesn't depend on a particular VM implementation.
4
+
5
+ **Requirements:**
6
+ - VM serializer/deserializer should be very simple.
7
+ - string: UTF16
8
+ - number: in a binary format
9
+ - bigint: in a binary format
10
+ - len: u32
11
+ - the byte code doesn't know anything about importing modules or I/O functions.
12
+ - the byte code shouldn't contain syntax sugar.
13
+ - serialized in a byte array so we can save it into a file. One byte is one unit.
14
+ - least-significant byte first.
15
+
16
+ ```rust
17
+ struct Array<T> {
18
+ len: u32,
19
+ array: [T; self.len],
20
+ }
21
+
22
+ type String = Array<u16>;
23
+
24
+ // LSB first.
25
+ type BigUInt = Array<u64>;
26
+
27
+ type Object = Array<(String, Any)>;
28
+
29
+ // This is the main structure for serialization.
30
+ type Code = Array<u8>;
31
+
32
+ struct Function {
33
+ length: u32
34
+ code: Code
35
+ }
36
+
37
+ // This structure is not for serialization because
38
+ // a serialized module should resolve all imports.
39
+ struct Module {
40
+ import: Array<String>
41
+ code: Code
42
+ }
43
+ ```
44
+
45
+ |type|any |tag| | |
46
+ |----|--------------|---|-----------------------|-----------------------------|
47
+ |JSON|null | 00| | |
48
+ | |number | 01|u64 | |
49
+ | |false | 02| | |
50
+ | |true | 03| | |
51
+ | |string | 04|String | |
52
+ | |object | 05|Object | |
53
+ | |array | 06|Array<Any> | |
54
+ |DJS |bigint+ | 07|BigUInt | |
55
+ | |bigint- | 08|BigUInt | |
56
+ | |local_ref | 09|u32 |consts[i] |
57
+ |FJS |arg_ref | 0A|u32 |args[i] |
58
+ | |undefined | 0B| | |
59
+ | |function | 0C|Function |the last constant is a return|
60
+ | |... | | | |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "functionalscript",
3
- "version": "0.0.563",
3
+ "version": "0.0.565",
4
4
  "description": "FunctionalScript is a functional subset of JavaScript",
5
5
  "main": "module.f.cjs",
6
6
  "scripts": {