functionalscript 0.0.404 → 0.0.405

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/LANGUAGE.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # FunctionalScript Programming Language
2
2
 
3
+ Principals:
4
+ - FunctionalScript VM should behaves the same way as a JavaScript VM
5
+ - Any unsupported feature should be reported at compile-time.
6
+
3
7
  ## 1. Module Ecosystem
4
8
 
5
9
  FunctionalScript uses [CommonJS](https://en.wikipedia.org/wiki/CommonJS) conventions as a module ecosystem. For example,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "functionalscript",
3
- "version": "0.0.404",
3
+ "version": "0.0.405",
4
4
  "description": "FunctionalScript is a functional subset of JavaScript",
5
5
  "main": "module.f.cjs",
6
6
  "scripts": {
package/sha2/module.f.cjs CHANGED
@@ -74,41 +74,41 @@ const smallSigma0 = smallSigma(7)(18)(3)
74
74
  const smallSigma1 = smallSigma(17)(19)(10)
75
75
 
76
76
  /** @type {(a: array.Array4<number>) => number} */
77
- const wi = a => (smallSigma1(a[0]) + a[1] + smallSigma0(a[2]) + a[3]) | 0
78
-
79
- /** @type {(input: Array16) => Array16} */
80
- const nextW = w => {
81
- const _0 = wi([w[14], w[ 9], w[ 1], w[ 0]])
82
- const _1 = wi([w[15], w[10], w[ 2], w[ 1]])
83
- const _2 = wi([ _0, w[11], w[ 3], w[ 2]])
84
- const _3 = wi([ _1, w[12], w[ 4], w[ 3]])
85
- const _4 = wi([ _2, w[13], w[ 5], w[ 4]])
86
- const _5 = wi([ _3, w[14], w[ 6], w[ 5]])
87
- const _6 = wi([ _4, w[15], w[ 7], w[ 6]])
88
- const _7 = wi([ _5, _0, w[ 8], w[ 7]])
89
- const _8 = wi([ _6, _1, w[ 9], w[ 8]])
90
- const _9 = wi([ _7, _2, w[10], w[ 9]])
91
- const _A = wi([ _8, _3, w[11], w[10]])
92
- const _B = wi([ _9, _4, w[12], w[11]])
93
- const _C = wi([ _A, _5, w[13], w[12]])
94
- const _D = wi([ _B, _6, w[14], w[13]])
95
- const _E = wi([ _C, _7, w[15], w[14]])
96
- const _F = wi([ _D, _8, _0, w[15]])
97
- return [_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _A, _B, _C, _D, _E, _F]
77
+ const wi = ([a0, a1, a2, a3]) => (smallSigma1(a0) + a1 + smallSigma0(a2) + a3) | 0
78
+
79
+ /** @type {(w: Array16) => Array16} */
80
+ const nextW = ([w0, w1, w2, w3, w4, w5, w6, w7, w8, w9, wA, wB, wC, wD, wE, wF]) => {
81
+ w0 = wi([wE, w9, w1, w0])
82
+ w1 = wi([wF, wA, w2, w1])
83
+ w2 = wi([w0, wB, w3, w2])
84
+ w3 = wi([w1, wC, w4, w3])
85
+ w4 = wi([w2, wD, w5, w4])
86
+ w5 = wi([w3, wE, w6, w5])
87
+ w6 = wi([w4, wF, w7, w6])
88
+ w7 = wi([w5, w0, w8, w7])
89
+ w8 = wi([w6, w1, w9, w8])
90
+ w9 = wi([w7, w2, wA, w9])
91
+ wA = wi([w8, w3, wB, wA])
92
+ wB = wi([w9, w4, wC, wB])
93
+ wC = wi([wA, w5, wD, wC])
94
+ wD = wi([wB, w6, wE, wD])
95
+ wE = wi([wC, w7, wF, wE])
96
+ wF = wi([wD, w8, w0, wF])
97
+ return [w0, w1, w2, w3, w4, w5, w6, w7, w8, w9, wA, wB, wC, wD, wE, wF]
98
98
  }
99
99
 
100
100
  /** @type {(init: Hash8) => (data: Array16) => Hash8} */
101
- const compress = init => data => {
101
+ const compress = ([a0, b0, c0, d0, e0, f0, g0, h0]) => data => {
102
102
  let w = data
103
103
 
104
- let a = init[0]
105
- let b = init[1]
106
- let c = init[2]
107
- let d = init[3]
108
- let e = init[4]
109
- let f = init[5]
110
- let g = init[6]
111
- let h = init[7]
104
+ let a = a0
105
+ let b = b0
106
+ let c = c0
107
+ let d = d0
108
+ let e = e0
109
+ let f = f0
110
+ let g = g0
111
+ let h = h0
112
112
 
113
113
  for (let i = 0; i < 4; ++i) {
114
114
  const ki = k[i]
@@ -128,14 +128,14 @@ const compress = init => data => {
128
128
  }
129
129
 
130
130
  return [
131
- (init[0] + a) | 0,
132
- (init[1] + b) | 0,
133
- (init[2] + c) | 0,
134
- (init[3] + d) | 0,
135
- (init[4] + e) | 0,
136
- (init[5] + f) | 0,
137
- (init[6] + g) | 0,
138
- (init[7] + h) | 0,
131
+ (a0 + a) | 0,
132
+ (b0 + b) | 0,
133
+ (c0 + c) | 0,
134
+ (d0 + d) | 0,
135
+ (e0 + e) | 0,
136
+ (f0 + f) | 0,
137
+ (g0 + g) | 0,
138
+ (h0 + h) | 0,
139
139
  ]
140
140
  }
141
141