@elaraai/east 0.0.1-beta.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 (251) hide show
  1. package/LICENSE.md +682 -0
  2. package/README.md +276 -0
  3. package/dist/src/analyze.d.ts +95 -0
  4. package/dist/src/analyze.d.ts.map +1 -0
  5. package/dist/src/analyze.js +1110 -0
  6. package/dist/src/analyze.js.map +1 -0
  7. package/dist/src/ast.d.ts +263 -0
  8. package/dist/src/ast.d.ts.map +1 -0
  9. package/dist/src/ast.js +151 -0
  10. package/dist/src/ast.js.map +1 -0
  11. package/dist/src/ast_to_ir.d.ts +24 -0
  12. package/dist/src/ast_to_ir.d.ts.map +1 -0
  13. package/dist/src/ast_to_ir.js +834 -0
  14. package/dist/src/ast_to_ir.js.map +1 -0
  15. package/dist/src/builtins.d.ts +18 -0
  16. package/dist/src/builtins.d.ts.map +1 -0
  17. package/dist/src/builtins.js +1105 -0
  18. package/dist/src/builtins.js.map +1 -0
  19. package/dist/src/comparison.d.ts +28 -0
  20. package/dist/src/comparison.d.ts.map +1 -0
  21. package/dist/src/comparison.js +1017 -0
  22. package/dist/src/comparison.js.map +1 -0
  23. package/dist/src/compile.d.ts +22 -0
  24. package/dist/src/compile.d.ts.map +1 -0
  25. package/dist/src/compile.js +3260 -0
  26. package/dist/src/compile.js.map +1 -0
  27. package/dist/src/containers/ref.d.ts +106 -0
  28. package/dist/src/containers/ref.d.ts.map +1 -0
  29. package/dist/src/containers/ref.js +100 -0
  30. package/dist/src/containers/ref.js.map +1 -0
  31. package/dist/src/containers/sortedmap.d.ts +165 -0
  32. package/dist/src/containers/sortedmap.d.ts.map +1 -0
  33. package/dist/src/containers/sortedmap.js +237 -0
  34. package/dist/src/containers/sortedmap.js.map +1 -0
  35. package/dist/src/containers/sortedset.d.ts +185 -0
  36. package/dist/src/containers/sortedset.d.ts.map +1 -0
  37. package/dist/src/containers/sortedset.js +312 -0
  38. package/dist/src/containers/sortedset.js.map +1 -0
  39. package/dist/src/containers/variant.d.ts +131 -0
  40. package/dist/src/containers/variant.d.ts.map +1 -0
  41. package/dist/src/containers/variant.js +68 -0
  42. package/dist/src/containers/variant.js.map +1 -0
  43. package/dist/src/datetime_format/parse.d.ts +50 -0
  44. package/dist/src/datetime_format/parse.d.ts.map +1 -0
  45. package/dist/src/datetime_format/parse.js +908 -0
  46. package/dist/src/datetime_format/parse.js.map +1 -0
  47. package/dist/src/datetime_format/print.d.ts +35 -0
  48. package/dist/src/datetime_format/print.d.ts.map +1 -0
  49. package/dist/src/datetime_format/print.js +157 -0
  50. package/dist/src/datetime_format/print.js.map +1 -0
  51. package/dist/src/datetime_format/tokenize.d.ts +76 -0
  52. package/dist/src/datetime_format/tokenize.d.ts.map +1 -0
  53. package/dist/src/datetime_format/tokenize.js +271 -0
  54. package/dist/src/datetime_format/tokenize.js.map +1 -0
  55. package/dist/src/datetime_format/types.d.ts +99 -0
  56. package/dist/src/datetime_format/types.d.ts.map +1 -0
  57. package/dist/src/datetime_format/types.js +103 -0
  58. package/dist/src/datetime_format/types.js.map +1 -0
  59. package/dist/src/datetime_format/validate.d.ts +51 -0
  60. package/dist/src/datetime_format/validate.d.ts.map +1 -0
  61. package/dist/src/datetime_format/validate.js +208 -0
  62. package/dist/src/datetime_format/validate.js.map +1 -0
  63. package/dist/src/default.d.ts +21 -0
  64. package/dist/src/default.d.ts.map +1 -0
  65. package/dist/src/default.js +82 -0
  66. package/dist/src/default.js.map +1 -0
  67. package/dist/src/eastir.d.ts +33 -0
  68. package/dist/src/eastir.d.ts.map +1 -0
  69. package/dist/src/eastir.js +92 -0
  70. package/dist/src/eastir.js.map +1 -0
  71. package/dist/src/error.d.ts +13 -0
  72. package/dist/src/error.d.ts.map +1 -0
  73. package/dist/src/error.js +8 -0
  74. package/dist/src/error.js.map +1 -0
  75. package/dist/src/expr/array.d.ts +1711 -0
  76. package/dist/src/expr/array.d.ts.map +1 -0
  77. package/dist/src/expr/array.js +1805 -0
  78. package/dist/src/expr/array.js.map +1 -0
  79. package/dist/src/expr/ast.d.ts +17 -0
  80. package/dist/src/expr/ast.d.ts.map +1 -0
  81. package/dist/src/expr/ast.js +302 -0
  82. package/dist/src/expr/ast.js.map +1 -0
  83. package/dist/src/expr/blob.d.ts +141 -0
  84. package/dist/src/expr/blob.d.ts.map +1 -0
  85. package/dist/src/expr/blob.js +198 -0
  86. package/dist/src/expr/blob.js.map +1 -0
  87. package/dist/src/expr/block.d.ts +201 -0
  88. package/dist/src/expr/block.d.ts.map +1 -0
  89. package/dist/src/expr/block.js +1505 -0
  90. package/dist/src/expr/block.js.map +1 -0
  91. package/dist/src/expr/boolean.d.ts +207 -0
  92. package/dist/src/expr/boolean.d.ts.map +1 -0
  93. package/dist/src/expr/boolean.js +261 -0
  94. package/dist/src/expr/boolean.js.map +1 -0
  95. package/dist/src/expr/datetime.d.ts +544 -0
  96. package/dist/src/expr/datetime.d.ts.map +1 -0
  97. package/dist/src/expr/datetime.js +980 -0
  98. package/dist/src/expr/datetime.js.map +1 -0
  99. package/dist/src/expr/dict.d.ts +1242 -0
  100. package/dist/src/expr/dict.d.ts.map +1 -0
  101. package/dist/src/expr/dict.js +1492 -0
  102. package/dist/src/expr/dict.js.map +1 -0
  103. package/dist/src/expr/expr.d.ts +95 -0
  104. package/dist/src/expr/expr.d.ts.map +1 -0
  105. package/dist/src/expr/expr.js +171 -0
  106. package/dist/src/expr/expr.js.map +1 -0
  107. package/dist/src/expr/float.d.ts +357 -0
  108. package/dist/src/expr/float.d.ts.map +1 -0
  109. package/dist/src/expr/float.js +637 -0
  110. package/dist/src/expr/float.js.map +1 -0
  111. package/dist/src/expr/function.d.ts +46 -0
  112. package/dist/src/expr/function.d.ts.map +1 -0
  113. package/dist/src/expr/function.js +58 -0
  114. package/dist/src/expr/function.js.map +1 -0
  115. package/dist/src/expr/index.d.ts +450 -0
  116. package/dist/src/expr/index.d.ts.map +1 -0
  117. package/dist/src/expr/index.js +423 -0
  118. package/dist/src/expr/index.js.map +1 -0
  119. package/dist/src/expr/integer.d.ts +256 -0
  120. package/dist/src/expr/integer.d.ts.map +1 -0
  121. package/dist/src/expr/integer.js +311 -0
  122. package/dist/src/expr/integer.js.map +1 -0
  123. package/dist/src/expr/libs/array.d.ts +106 -0
  124. package/dist/src/expr/libs/array.d.ts.map +1 -0
  125. package/dist/src/expr/libs/array.js +140 -0
  126. package/dist/src/expr/libs/array.js.map +1 -0
  127. package/dist/src/expr/libs/blob.d.ts +42 -0
  128. package/dist/src/expr/libs/blob.d.ts.map +1 -0
  129. package/dist/src/expr/libs/blob.js +70 -0
  130. package/dist/src/expr/libs/blob.js.map +1 -0
  131. package/dist/src/expr/libs/datetime.d.ts +479 -0
  132. package/dist/src/expr/libs/datetime.d.ts.map +1 -0
  133. package/dist/src/expr/libs/datetime.js +624 -0
  134. package/dist/src/expr/libs/datetime.js.map +1 -0
  135. package/dist/src/expr/libs/dict.d.ts +66 -0
  136. package/dist/src/expr/libs/dict.d.ts.map +1 -0
  137. package/dist/src/expr/libs/dict.js +77 -0
  138. package/dist/src/expr/libs/dict.js.map +1 -0
  139. package/dist/src/expr/libs/float.d.ts +299 -0
  140. package/dist/src/expr/libs/float.d.ts.map +1 -0
  141. package/dist/src/expr/libs/float.js +564 -0
  142. package/dist/src/expr/libs/float.js.map +1 -0
  143. package/dist/src/expr/libs/integer.d.ts +228 -0
  144. package/dist/src/expr/libs/integer.d.ts.map +1 -0
  145. package/dist/src/expr/libs/integer.js +398 -0
  146. package/dist/src/expr/libs/integer.js.map +1 -0
  147. package/dist/src/expr/libs/set.d.ts +59 -0
  148. package/dist/src/expr/libs/set.d.ts.map +1 -0
  149. package/dist/src/expr/libs/set.js +69 -0
  150. package/dist/src/expr/libs/set.js.map +1 -0
  151. package/dist/src/expr/libs/string.d.ts +71 -0
  152. package/dist/src/expr/libs/string.d.ts.map +1 -0
  153. package/dist/src/expr/libs/string.js +75 -0
  154. package/dist/src/expr/libs/string.js.map +1 -0
  155. package/dist/src/expr/never.d.ts +15 -0
  156. package/dist/src/expr/never.d.ts.map +1 -0
  157. package/dist/src/expr/never.js +12 -0
  158. package/dist/src/expr/never.js.map +1 -0
  159. package/dist/src/expr/null.d.ts +15 -0
  160. package/dist/src/expr/null.d.ts.map +1 -0
  161. package/dist/src/expr/null.js +12 -0
  162. package/dist/src/expr/null.js.map +1 -0
  163. package/dist/src/expr/ref.d.ts +103 -0
  164. package/dist/src/expr/ref.d.ts.map +1 -0
  165. package/dist/src/expr/ref.js +131 -0
  166. package/dist/src/expr/ref.js.map +1 -0
  167. package/dist/src/expr/regex_validation.d.ts +25 -0
  168. package/dist/src/expr/regex_validation.d.ts.map +1 -0
  169. package/dist/src/expr/regex_validation.js +130 -0
  170. package/dist/src/expr/regex_validation.js.map +1 -0
  171. package/dist/src/expr/set.d.ts +1071 -0
  172. package/dist/src/expr/set.d.ts.map +1 -0
  173. package/dist/src/expr/set.js +1137 -0
  174. package/dist/src/expr/set.js.map +1 -0
  175. package/dist/src/expr/string.d.ts +414 -0
  176. package/dist/src/expr/string.d.ts.map +1 -0
  177. package/dist/src/expr/string.js +683 -0
  178. package/dist/src/expr/string.js.map +1 -0
  179. package/dist/src/expr/struct.d.ts +48 -0
  180. package/dist/src/expr/struct.d.ts.map +1 -0
  181. package/dist/src/expr/struct.js +65 -0
  182. package/dist/src/expr/struct.js.map +1 -0
  183. package/dist/src/expr/types.d.ts +68 -0
  184. package/dist/src/expr/types.d.ts.map +1 -0
  185. package/dist/src/expr/types.js +6 -0
  186. package/dist/src/expr/types.js.map +1 -0
  187. package/dist/src/expr/variant.d.ts +137 -0
  188. package/dist/src/expr/variant.d.ts.map +1 -0
  189. package/dist/src/expr/variant.js +105 -0
  190. package/dist/src/expr/variant.js.map +1 -0
  191. package/dist/src/fuzz.d.ts +80 -0
  192. package/dist/src/fuzz.d.ts.map +1 -0
  193. package/dist/src/fuzz.js +300 -0
  194. package/dist/src/fuzz.js.map +1 -0
  195. package/dist/src/index.d.ts +21 -0
  196. package/dist/src/index.d.ts.map +1 -0
  197. package/dist/src/index.js +21 -0
  198. package/dist/src/index.js.map +1 -0
  199. package/dist/src/internal.d.ts +36 -0
  200. package/dist/src/internal.d.ts.map +1 -0
  201. package/dist/src/internal.js +11 -0
  202. package/dist/src/internal.js.map +1 -0
  203. package/dist/src/ir.d.ts +1571 -0
  204. package/dist/src/ir.d.ts.map +1 -0
  205. package/dist/src/ir.js +56 -0
  206. package/dist/src/ir.js.map +1 -0
  207. package/dist/src/location.d.ts +48 -0
  208. package/dist/src/location.d.ts.map +1 -0
  209. package/dist/src/location.js +62 -0
  210. package/dist/src/location.js.map +1 -0
  211. package/dist/src/platform.d.ts +21 -0
  212. package/dist/src/platform.d.ts.map +1 -0
  213. package/dist/src/platform.js +8 -0
  214. package/dist/src/platform.js.map +1 -0
  215. package/dist/src/serialization/beast.d.ts +39 -0
  216. package/dist/src/serialization/beast.d.ts.map +1 -0
  217. package/dist/src/serialization/beast.js +555 -0
  218. package/dist/src/serialization/beast.js.map +1 -0
  219. package/dist/src/serialization/beast2-stream.d.ts +38 -0
  220. package/dist/src/serialization/beast2-stream.d.ts.map +1 -0
  221. package/dist/src/serialization/beast2-stream.js +665 -0
  222. package/dist/src/serialization/beast2-stream.js.map +1 -0
  223. package/dist/src/serialization/beast2.d.ts +41 -0
  224. package/dist/src/serialization/beast2.d.ts.map +1 -0
  225. package/dist/src/serialization/beast2.js +489 -0
  226. package/dist/src/serialization/beast2.js.map +1 -0
  227. package/dist/src/serialization/binary-utils.d.ts +151 -0
  228. package/dist/src/serialization/binary-utils.d.ts.map +1 -0
  229. package/dist/src/serialization/binary-utils.js +929 -0
  230. package/dist/src/serialization/binary-utils.js.map +1 -0
  231. package/dist/src/serialization/east.d.ts +84 -0
  232. package/dist/src/serialization/east.d.ts.map +1 -0
  233. package/dist/src/serialization/east.js +1802 -0
  234. package/dist/src/serialization/east.js.map +1 -0
  235. package/dist/src/serialization/index.d.ts +11 -0
  236. package/dist/src/serialization/index.d.ts.map +1 -0
  237. package/dist/src/serialization/index.js +12 -0
  238. package/dist/src/serialization/index.js.map +1 -0
  239. package/dist/src/serialization/json.d.ts +36 -0
  240. package/dist/src/serialization/json.d.ts.map +1 -0
  241. package/dist/src/serialization/json.js +849 -0
  242. package/dist/src/serialization/json.js.map +1 -0
  243. package/dist/src/type_of_type.d.ts +115 -0
  244. package/dist/src/type_of_type.d.ts.map +1 -0
  245. package/dist/src/type_of_type.js +362 -0
  246. package/dist/src/type_of_type.js.map +1 -0
  247. package/dist/src/types.d.ts +648 -0
  248. package/dist/src/types.d.ts.map +1 -0
  249. package/dist/src/types.js +1631 -0
  250. package/dist/src/types.js.map +1 -0
  251. package/package.json +87 -0
@@ -0,0 +1,637 @@
1
+ import { get_location } from "../location.js";
2
+ import { FloatType, IntegerType, isTypeEqual, printType } from "../types.js";
3
+ import { AstSymbol, Expr, FactorySymbol } from "./expr.js";
4
+ import { valueOrExprToAstTyped } from "./ast.js";
5
+ /**
6
+ * Expression representing floating-point values and operations (IEEE 754 double-precision).
7
+ *
8
+ * FloatExpr provides arithmetic, trigonometric, and conversion operations for 64-bit floats.
9
+ * Automatically converts integer operands to float when needed. Supports special values: Infinity, -Infinity, NaN.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * // Basic arithmetic
14
+ * const calculate = East.function([FloatType, FloatType], FloatType, ($, x, y) => {
15
+ * const sum = x.add(y);
16
+ * const ratio = x.divide(y);
17
+ * $.return(sum.multiply(ratio));
18
+ * });
19
+ *
20
+ * // Trigonometry
21
+ * const angle = East.function([FloatType], FloatType, ($, degrees) => {
22
+ * const radians = degrees.multiply(Math.PI / 180);
23
+ * $.return(radians.sin());
24
+ * });
25
+ *
26
+ * // Mixed with integers
27
+ * const mixed = East.function([IntegerType], FloatType, ($, x) => {
28
+ * $.return(x.add(2.5)); // Integer auto-converts to float
29
+ * });
30
+ * ```
31
+ */
32
+ export class FloatExpr extends Expr {
33
+ constructor(ast, createExpr) {
34
+ super(FloatType, ast, createExpr);
35
+ }
36
+ /**
37
+ * Negates a floating-point number (-x).
38
+ *
39
+ * @returns A FloatExpr representing the negated value
40
+ *
41
+ * @example
42
+ * ```ts
43
+ * const negateFloat = East.function([FloatType], FloatType, ($, x) => {
44
+ * $.return(x.negate());
45
+ * });
46
+ * const compiled = East.compile(negateFloat.toIR(), []);
47
+ * compiled(3.14); // -3.14
48
+ * compiled(-2.5); // 2.5
49
+ * compiled(0.0); // -0.0 (negative zero)
50
+ * ```
51
+ */
52
+ negate() {
53
+ return this[FactorySymbol]({
54
+ ast_type: "Builtin",
55
+ type: FloatType,
56
+ location: get_location(2),
57
+ builtin: "FloatNegate",
58
+ type_parameters: [],
59
+ arguments: [this[AstSymbol]],
60
+ });
61
+ }
62
+ /**
63
+ * Adds two floating-point numbers or converts integer to float and adds (x + y).
64
+ *
65
+ * @param y - The float, number, IntegerExpr, or bigint to add
66
+ * @returns A FloatExpr representing the sum
67
+ *
68
+ * @remarks Automatically converts integer operands to float before addition.
69
+ *
70
+ * @example
71
+ * ```ts
72
+ * const addFloats = East.function([FloatType, FloatType], FloatType, ($, x, y) => {
73
+ * $.return(x.add(y));
74
+ * });
75
+ * const compiled = East.compile(addFloats.toIR(), []);
76
+ * compiled(3.14, 2.86); // 6.0
77
+ * compiled(1.5, -0.5); // 1.0
78
+ *
79
+ * // Mixed with integers
80
+ * const addMixed = East.function([FloatType, IntegerType], FloatType, ($, x, y) => {
81
+ * $.return(x.add(y)); // Integer auto-converts to float
82
+ * });
83
+ * compiled = East.compile(addMixed.toIR(), []);
84
+ * compiled(3.14, 2n); // 5.14
85
+ * ```
86
+ */
87
+ add(y) {
88
+ let rightAst;
89
+ if (typeof y === "bigint") {
90
+ // Convert integer to float first
91
+ rightAst = valueOrExprToAstTyped(Number(y), FloatType);
92
+ }
93
+ else if (typeof y === "number") {
94
+ rightAst = valueOrExprToAstTyped(y, FloatType);
95
+ }
96
+ else if (y instanceof Expr) {
97
+ if (isTypeEqual(Expr.type(y), IntegerType)) {
98
+ // Convert integer to float first
99
+ rightAst = y.toFloat()[AstSymbol];
100
+ }
101
+ else if (isTypeEqual(Expr.type(y), FloatType)) {
102
+ rightAst = y[AstSymbol];
103
+ }
104
+ else {
105
+ throw new Error(`Cannot add Float and ${printType(Expr.type(y))}`);
106
+ }
107
+ }
108
+ else {
109
+ throw new Error(`Cannot add Float and ${typeof y}`);
110
+ }
111
+ return this[FactorySymbol]({
112
+ ast_type: "Builtin",
113
+ type: FloatType,
114
+ location: get_location(2),
115
+ builtin: "FloatAdd",
116
+ type_parameters: [],
117
+ arguments: [this[AstSymbol], rightAst],
118
+ });
119
+ }
120
+ /**
121
+ * Subtracts two floating-point numbers or converts integer to float and subtracts (x - y).
122
+ *
123
+ * @param y - The float, number, IntegerExpr, or bigint to subtract
124
+ * @returns A FloatExpr representing the difference
125
+ *
126
+ * @remarks Automatically converts integer operands to float before subtraction.
127
+ *
128
+ * @example
129
+ * ```ts
130
+ * const subtractFloats = East.function([FloatType, FloatType], FloatType, ($, x, y) => {
131
+ * $.return(x.subtract(y));
132
+ * });
133
+ * const compiled = East.compile(subtractFloats.toIR(), []);
134
+ * compiled(5.5, 2.3); // 3.2
135
+ * compiled(1.0, 1.0); // 0.0
136
+ * compiled(-2.5, 3.5); // -6.0
137
+ * ```
138
+ */
139
+ subtract(y) {
140
+ let rightAst;
141
+ if (typeof y === "bigint") {
142
+ // Convert integer to float first
143
+ rightAst = valueOrExprToAstTyped(Number(y), FloatType);
144
+ }
145
+ else if (typeof y === "number") {
146
+ rightAst = valueOrExprToAstTyped(y, FloatType);
147
+ }
148
+ else if (y instanceof Expr) {
149
+ if (isTypeEqual(Expr.type(y), IntegerType)) {
150
+ // Convert integer to float first
151
+ rightAst = y.toFloat()[AstSymbol];
152
+ }
153
+ else if (isTypeEqual(Expr.type(y), FloatType)) {
154
+ rightAst = y[AstSymbol];
155
+ }
156
+ else {
157
+ throw new Error(`Cannot add Float and ${printType(Expr.type(y))}`);
158
+ }
159
+ }
160
+ else {
161
+ throw new Error(`Cannot add Float and ${typeof y}`);
162
+ }
163
+ return this[FactorySymbol]({
164
+ ast_type: "Builtin",
165
+ type: FloatType,
166
+ location: get_location(2),
167
+ builtin: "FloatSubtract",
168
+ type_parameters: [],
169
+ arguments: [this[AstSymbol], rightAst],
170
+ });
171
+ }
172
+ /**
173
+ * Multiplies two floating-point numbers or converts integer to float and multiplies (x * y).
174
+ *
175
+ * @param y - The float, number, IntegerExpr, or bigint to multiply
176
+ * @returns A FloatExpr representing the product
177
+ *
178
+ * @remarks Automatically converts integer operands to float before multiplication.
179
+ *
180
+ * @example
181
+ * ```ts
182
+ * const multiplyFloats = East.function([FloatType, FloatType], FloatType, ($, x, y) => {
183
+ * $.return(x.multiply(y));
184
+ * });
185
+ * const compiled = East.compile(multiplyFloats.toIR(), []);
186
+ * compiled(3.0, 2.5); // 7.5
187
+ * compiled(2.0, -1.5); // -3.0
188
+ * compiled(0.5, 0.5); // 0.25
189
+ * ```
190
+ */
191
+ multiply(y) {
192
+ let rightAst;
193
+ if (typeof y === "bigint") {
194
+ // Convert integer to float first
195
+ rightAst = valueOrExprToAstTyped(Number(y), FloatType);
196
+ }
197
+ else if (typeof y === "number") {
198
+ rightAst = valueOrExprToAstTyped(y, FloatType);
199
+ }
200
+ else if (y instanceof Expr) {
201
+ if (isTypeEqual(Expr.type(y), IntegerType)) {
202
+ // Convert integer to float first
203
+ rightAst = y.toFloat()[AstSymbol];
204
+ }
205
+ else if (isTypeEqual(Expr.type(y), FloatType)) {
206
+ rightAst = y[AstSymbol];
207
+ }
208
+ else {
209
+ throw new Error(`Cannot add Float and ${printType(Expr.type(y))}`);
210
+ }
211
+ }
212
+ else {
213
+ throw new Error(`Cannot add Float and ${typeof y}`);
214
+ }
215
+ return this[FactorySymbol]({
216
+ ast_type: "Builtin",
217
+ type: FloatType,
218
+ location: get_location(2),
219
+ builtin: "FloatMultiply",
220
+ type_parameters: [],
221
+ arguments: [this[AstSymbol], rightAst],
222
+ });
223
+ }
224
+ /**
225
+ * Divides two floating-point numbers or converts integer to float and divides (x / y).
226
+ *
227
+ * @param y - The float, number, IntegerExpr, or bigint divisor
228
+ * @returns A FloatExpr representing the quotient
229
+ *
230
+ * @remarks Division by zero returns Infinity, -Infinity, or NaN according to IEEE 754.
231
+ * Automatically converts integer operands to float before division.
232
+ *
233
+ * @example
234
+ * ```ts
235
+ * const divideFloats = East.function([FloatType, FloatType], FloatType, ($, x, y) => {
236
+ * $.return(x.divide(y));
237
+ * });
238
+ * const compiled = East.compile(divideFloats.toIR(), []);
239
+ * compiled(10.0, 2.0); // 5.0
240
+ * compiled(1.0, 3.0); // 0.3333333333333333
241
+ * compiled(5.0, 0.0); // Infinity
242
+ * compiled(-5.0, 0.0); // -Infinity
243
+ * compiled(0.0, 0.0); // NaN
244
+ * ```
245
+ */
246
+ divide(y) {
247
+ let rightAst;
248
+ if (typeof y === "bigint") {
249
+ // Convert integer to float first
250
+ rightAst = valueOrExprToAstTyped(Number(y), FloatType);
251
+ }
252
+ else if (typeof y === "number") {
253
+ rightAst = valueOrExprToAstTyped(y, FloatType);
254
+ }
255
+ else if (y instanceof Expr) {
256
+ if (isTypeEqual(Expr.type(y), IntegerType)) {
257
+ // Convert integer to float first
258
+ rightAst = y.toFloat()[AstSymbol];
259
+ }
260
+ else if (isTypeEqual(Expr.type(y), FloatType)) {
261
+ rightAst = y[AstSymbol];
262
+ }
263
+ else {
264
+ throw new Error(`Cannot add Float and ${printType(Expr.type(y))}`);
265
+ }
266
+ }
267
+ else {
268
+ throw new Error(`Cannot add Float and ${typeof y}`);
269
+ }
270
+ return this[FactorySymbol]({
271
+ ast_type: "Builtin",
272
+ type: FloatType,
273
+ location: get_location(2),
274
+ builtin: "FloatDivide",
275
+ type_parameters: [],
276
+ arguments: [this[AstSymbol], rightAst],
277
+ });
278
+ }
279
+ /**
280
+ * Computes floating-point remainder of division (x % y).
281
+ *
282
+ * @param y - The float, number, IntegerExpr, or bigint divisor
283
+ * @returns A FloatExpr representing the remainder
284
+ *
285
+ * @remarks Uses IEEE 754 remainder semantics. Automatically converts integer operands to float.
286
+ *
287
+ * @example
288
+ * ```ts
289
+ * const remainderFloats = East.function([FloatType, FloatType], FloatType, ($, x, y) => {
290
+ * $.return(x.remainder(y));
291
+ * });
292
+ * const compiled = East.compile(remainderFloats.toIR(), []);
293
+ * compiled(7.5, 2.0); // 1.5
294
+ * compiled(10.0, 3.0); // 1.0
295
+ * compiled(-7.5, 2.0); // -1.5
296
+ * ```
297
+ */
298
+ remainder(y) {
299
+ let rightAst;
300
+ if (typeof y === "bigint") {
301
+ // Convert integer to float first
302
+ rightAst = valueOrExprToAstTyped(Number(y), FloatType);
303
+ }
304
+ else if (typeof y === "number") {
305
+ rightAst = valueOrExprToAstTyped(y, FloatType);
306
+ }
307
+ else if (y instanceof Expr) {
308
+ if (isTypeEqual(Expr.type(y), IntegerType)) {
309
+ // Convert integer to float first
310
+ rightAst = y.toFloat()[AstSymbol];
311
+ }
312
+ else if (isTypeEqual(Expr.type(y), FloatType)) {
313
+ rightAst = y[AstSymbol];
314
+ }
315
+ else {
316
+ throw new Error(`Cannot add Float and ${printType(Expr.type(y))}`);
317
+ }
318
+ }
319
+ else {
320
+ throw new Error(`Cannot add Float and ${typeof y}`);
321
+ }
322
+ return this[FactorySymbol]({
323
+ ast_type: "Builtin",
324
+ type: FloatType,
325
+ location: get_location(2),
326
+ builtin: "FloatRemainder",
327
+ type_parameters: [],
328
+ arguments: [this[AstSymbol], rightAst],
329
+ });
330
+ }
331
+ /**
332
+ * Raises a floating-point number to a power (x ** y).
333
+ *
334
+ * @param y - The float, number, IntegerExpr, or bigint exponent
335
+ * @returns A FloatExpr representing x raised to the power of y
336
+ *
337
+ * @remarks Automatically converts integer operands to float before exponentiation.
338
+ *
339
+ * @example
340
+ * ```ts
341
+ * const powFloats = East.function([FloatType, FloatType], FloatType, ($, x, y) => {
342
+ * $.return(x.pow(y));
343
+ * });
344
+ * const compiled = East.compile(powFloats.toIR(), []);
345
+ * compiled(2.0, 3.0); // 8.0
346
+ * compiled(9.0, 0.5); // 3.0 (square root)
347
+ * compiled(2.0, -1.0); // 0.5
348
+ * compiled(-1.0, 0.5); // NaN (square root of negative)
349
+ * ```
350
+ */
351
+ pow(y) {
352
+ let rightAst;
353
+ if (typeof y === "bigint") {
354
+ // Convert integer to float first
355
+ rightAst = valueOrExprToAstTyped(Number(y), FloatType);
356
+ }
357
+ else if (typeof y === "number") {
358
+ rightAst = valueOrExprToAstTyped(y, FloatType);
359
+ }
360
+ else if (y instanceof Expr) {
361
+ if (isTypeEqual(Expr.type(y), IntegerType)) {
362
+ // Convert integer to float first
363
+ rightAst = y.toFloat()[AstSymbol];
364
+ }
365
+ else if (isTypeEqual(Expr.type(y), FloatType)) {
366
+ rightAst = y[AstSymbol];
367
+ }
368
+ else {
369
+ throw new Error(`Cannot add Float and ${printType(Expr.type(y))}`);
370
+ }
371
+ }
372
+ else {
373
+ throw new Error(`Cannot add Float and ${typeof y}`);
374
+ }
375
+ return this[FactorySymbol]({
376
+ ast_type: "Builtin",
377
+ type: FloatType,
378
+ location: get_location(2),
379
+ builtin: "FloatPow",
380
+ type_parameters: [],
381
+ arguments: [this[AstSymbol], rightAst],
382
+ });
383
+ }
384
+ /**
385
+ * Computes the absolute value of a floating-point number (|x|).
386
+ *
387
+ * @returns A FloatExpr representing the absolute value
388
+ *
389
+ * @example
390
+ * ```ts
391
+ * const absFloat = East.function([FloatType], FloatType, ($, x) => {
392
+ * $.return(x.abs());
393
+ * });
394
+ * const compiled = East.compile(absFloat.toIR(), []);
395
+ * compiled(3.14); // 3.14
396
+ * compiled(-2.5); // 2.5
397
+ * compiled(0.0); // 0.0
398
+ * compiled(-0.0); // 0.0
399
+ * ```
400
+ */
401
+ abs() {
402
+ return this[FactorySymbol]({
403
+ ast_type: "Builtin",
404
+ type: FloatType,
405
+ location: get_location(2),
406
+ builtin: "FloatAbs",
407
+ type_parameters: [],
408
+ arguments: [this[AstSymbol]],
409
+ });
410
+ }
411
+ /**
412
+ * Computes the sign of a floating-point number.
413
+ *
414
+ * @returns A FloatExpr representing -1.0 for negative, 0.0 for zero, 1.0 for positive, or NaN for NaN
415
+ *
416
+ * @example
417
+ * ```ts
418
+ * const signFloat = East.function([FloatType], FloatType, ($, x) => {
419
+ * $.return(x.sign());
420
+ * });
421
+ * const compiled = East.compile(signFloat.toIR(), []);
422
+ * compiled(3.14); // 1.0
423
+ * compiled(-2.5); // -1.0
424
+ * compiled(0.0); // 0.0
425
+ * compiled(-0.0); // -0.0
426
+ * ```
427
+ */
428
+ sign() {
429
+ return this[FactorySymbol]({
430
+ ast_type: "Builtin",
431
+ type: FloatType,
432
+ location: get_location(2),
433
+ builtin: "FloatSign",
434
+ type_parameters: [],
435
+ arguments: [this[AstSymbol]],
436
+ });
437
+ }
438
+ /**
439
+ * Computes the square root of a floating-point number (√x).
440
+ *
441
+ * @returns A FloatExpr representing the square root
442
+ *
443
+ * @remarks Returns NaN for negative numbers.
444
+ *
445
+ * @example
446
+ * ```ts
447
+ * const sqrtFloat = East.function([FloatType], FloatType, ($, x) => {
448
+ * $.return(x.sqrt());
449
+ * });
450
+ * const compiled = East.compile(sqrtFloat.toIR(), []);
451
+ * compiled(9.0); // 3.0
452
+ * compiled(2.0); // 1.4142135623730951
453
+ * compiled(0.0); // 0.0
454
+ * compiled(-1.0); // NaN
455
+ * ```
456
+ */
457
+ sqrt() {
458
+ return this[FactorySymbol]({
459
+ ast_type: "Builtin",
460
+ type: FloatType,
461
+ location: get_location(2),
462
+ builtin: "FloatSqrt",
463
+ type_parameters: [],
464
+ arguments: [this[AstSymbol]],
465
+ });
466
+ }
467
+ /**
468
+ * Computes the exponential function (e^x).
469
+ *
470
+ * @returns A FloatExpr representing e raised to the power of x
471
+ *
472
+ * @example
473
+ * ```ts
474
+ * const expFloat = East.function([FloatType], FloatType, ($, x) => {
475
+ * $.return(x.exp());
476
+ * });
477
+ * const compiled = East.compile(expFloat.toIR(), []);
478
+ * compiled(0.0); // 1.0
479
+ * compiled(1.0); // 2.718281828459045
480
+ * compiled(2.0); // 7.38905609893065
481
+ * compiled(-1.0); // 0.36787944117144233
482
+ * ```
483
+ */
484
+ exp() {
485
+ return this[FactorySymbol]({
486
+ ast_type: "Builtin",
487
+ type: FloatType,
488
+ location: get_location(2),
489
+ builtin: "FloatExp",
490
+ type_parameters: [],
491
+ arguments: [this[AstSymbol]],
492
+ });
493
+ }
494
+ /**
495
+ * Computes the natural logarithm (ln(x)).
496
+ *
497
+ * @returns A FloatExpr representing the natural logarithm of x
498
+ *
499
+ * @remarks Returns NaN for negative numbers, -Infinity for 0.
500
+ *
501
+ * @example
502
+ * ```ts
503
+ * const logFloat = East.function([FloatType], FloatType, ($, x) => {
504
+ * $.return(x.log());
505
+ * });
506
+ * const compiled = East.compile(logFloat.toIR(), []);
507
+ * compiled(Math.E); // 1.0
508
+ * compiled(1.0); // 0.0
509
+ * compiled(10.0); // 2.302585092994046
510
+ * compiled(0.0); // -Infinity
511
+ * compiled(-1.0); // NaN
512
+ * ```
513
+ */
514
+ log() {
515
+ return this[FactorySymbol]({
516
+ ast_type: "Builtin",
517
+ type: FloatType,
518
+ location: get_location(2),
519
+ builtin: "FloatLog",
520
+ type_parameters: [],
521
+ arguments: [this[AstSymbol]],
522
+ });
523
+ }
524
+ /**
525
+ * Computes the sine of a floating-point number (sin(x)).
526
+ *
527
+ * @returns A FloatExpr representing the sine of x (x in radians)
528
+ *
529
+ * @example
530
+ * ```ts
531
+ * const sinFloat = East.function([FloatType], FloatType, ($, x) => {
532
+ * $.return(x.sin());
533
+ * });
534
+ * const compiled = East.compile(sinFloat.toIR(), []);
535
+ * compiled(0.0); // 0.0
536
+ * compiled(Math.PI / 2); // 1.0
537
+ * compiled(Math.PI); // ~0.0 (very close to zero)
538
+ * compiled(Math.PI / 6); // 0.5
539
+ * ```
540
+ */
541
+ sin() {
542
+ return this[FactorySymbol]({
543
+ ast_type: "Builtin",
544
+ type: FloatType,
545
+ location: get_location(2),
546
+ builtin: "FloatSin",
547
+ type_parameters: [],
548
+ arguments: [this[AstSymbol]],
549
+ });
550
+ }
551
+ /**
552
+ * Computes the cosine of a floating-point number (cos(x)).
553
+ *
554
+ * @returns A FloatExpr representing the cosine of x (x in radians)
555
+ *
556
+ * @example
557
+ * ```ts
558
+ * const cosFloat = East.function([FloatType], FloatType, ($, x) => {
559
+ * $.return(x.cos());
560
+ * });
561
+ * const compiled = East.compile(cosFloat.toIR(), []);
562
+ * compiled(0.0); // 1.0
563
+ * compiled(Math.PI / 2); // ~0.0 (very close to zero)
564
+ * compiled(Math.PI); // -1.0
565
+ * compiled(Math.PI / 3); // 0.5
566
+ * ```
567
+ */
568
+ cos() {
569
+ return this[FactorySymbol]({
570
+ ast_type: "Builtin",
571
+ type: FloatType,
572
+ location: get_location(2),
573
+ builtin: "FloatCos",
574
+ type_parameters: [],
575
+ arguments: [this[AstSymbol]],
576
+ });
577
+ }
578
+ /**
579
+ * Computes the tangent of a floating-point number (tan(x)).
580
+ *
581
+ * @returns A FloatExpr representing the tangent of x (x in radians)
582
+ *
583
+ * @example
584
+ * ```ts
585
+ * const tanFloat = East.function([FloatType], FloatType, ($, x) => {
586
+ * $.return(x.tan());
587
+ * });
588
+ * const compiled = East.compile(tanFloat.toIR(), []);
589
+ * compiled(0.0); // 0.0
590
+ * compiled(Math.PI / 4); // 1.0
591
+ * compiled(Math.PI / 6); // 0.5773502691896257
592
+ * compiled(-Math.PI / 4); // -1.0
593
+ * ```
594
+ */
595
+ tan() {
596
+ return this[FactorySymbol]({
597
+ ast_type: "Builtin",
598
+ type: FloatType,
599
+ location: get_location(2),
600
+ builtin: "FloatTan",
601
+ type_parameters: [],
602
+ arguments: [this[AstSymbol]],
603
+ });
604
+ }
605
+ /**
606
+ * Converts a floating-point number to an integer.
607
+ *
608
+ * @returns An IntegerExpr representing the converted value
609
+ *
610
+ * @throws East runtime error if the float is NaN, infinite, larger than 2^63-1, smaller than -2^63, or not an integer value
611
+ *
612
+ * @example
613
+ * ```ts
614
+ * const floatToInt = East.function([FloatType], IntegerType, ($, x) => {
615
+ * $.return(x.toInteger());
616
+ * });
617
+ * const compiled = East.compile(floatToInt.toIR(), []);
618
+ * compiled(42.0); // 42n
619
+ * compiled(-10.0); // -10n
620
+ * compiled(0.0); // 0n
621
+ * // compiled(3.14) would throw error (not an integer value)
622
+ * // compiled(NaN) would throw error
623
+ * // compiled(Infinity) would throw error
624
+ * ```
625
+ */
626
+ toInteger() {
627
+ return this[FactorySymbol]({
628
+ ast_type: "Builtin",
629
+ type: IntegerType,
630
+ location: get_location(2),
631
+ builtin: "FloatToInteger",
632
+ type_parameters: [],
633
+ arguments: [this[AstSymbol]],
634
+ });
635
+ }
636
+ }
637
+ //# sourceMappingURL=float.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"float.js","sourceRoot":"","sources":["../../../src/expr/float.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7E,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,aAAa,EAAe,MAAM,WAAW,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAGjD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,OAAO,SAAU,SAAQ,IAAe;IAC5C,YAAY,GAAQ,EAAE,UAAkB;QACtC,KAAK,CAAC,SAAS,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC;IACpC,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,aAAa,CAAC,CAAC;YACzB,QAAQ,EAAE,SAAS;YACnB,IAAI,EAAE,SAAS;YACf,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC;YACzB,OAAO,EAAE,aAAa;YACtB,eAAe,EAAE,EAAE;YACnB,SAAS,EAAE,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C;IAClB,CAAC;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,GAAG;QACD,OAAO,IAAI,CAAC,aAAa,CAAC,CAAC;YACzB,QAAQ,EAAE,SAAS;YACnB,IAAI,EAAE,SAAS;YACf,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC;YACzB,OAAO,EAAE,UAAU;YACnB,eAAe,EAAE,EAAE;YACnB,SAAS,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;SAC7B,CAAc,CAAC;IAClB,CAAC;IAED;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,SAAS;QACP,OAAO,IAAI,CAAC,aAAa,CAAC,CAAC;YACzB,QAAQ,EAAE,SAAS;YACnB,IAAI,EAAE,WAAW;YACjB,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC;YACzB,OAAO,EAAE,gBAAgB;YACzB,eAAe,EAAE,EAAE;YACnB,SAAS,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;SAC7B,CAAgB,CAAC;IACpB,CAAC;CACF"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
4
+ */
5
+ import type { AST } from "../ast.js";
6
+ import { EastIR } from "../eastir.js";
7
+ import { FunctionType } from "../types.js";
8
+ import { Expr, type ToExpr } from "./expr.js";
9
+ import type { ExprType, SubtypeExprOrValue } from "./types.js";
10
+ /**
11
+ * Expression representing the Function type.
12
+ * Used for function calls, composition, etc.
13
+ */
14
+ export declare class FunctionExpr<I extends any[], O extends any> extends Expr<FunctionType<I, O>> {
15
+ private input_types;
16
+ private output_type;
17
+ constructor(input_types: I, output_type: O, ast: AST, createExpr: ToExpr);
18
+ /** Note that {@link CallableFunctionExpr} provides a more ergonomic way to call functions.
19
+ *
20
+ * @internal */
21
+ call(...args: {
22
+ [K in keyof I]: SubtypeExprOrValue<I[K]>;
23
+ }): ExprType<O>;
24
+ /** Convert the function to East's "intermediate representation" (IR). This can then be serialized or compiled.
25
+ *
26
+ * Note that the function must be a "free" function, with no captures.
27
+ */
28
+ toIR(): EastIR<I, O>;
29
+ }
30
+ /**
31
+ * Expression representing the Function type.
32
+ * Used for function calls, composition, etc.
33
+ *
34
+ * Supports direct calling of functions using `f(x, y)` syntax instead using a method, like `f.call(x, y)`.
35
+ */
36
+ export type CallableFunctionExpr<I extends any[], O> = FunctionExpr<I, O> & ((...args: {
37
+ [K in keyof I]: SubtypeExprOrValue<I[K]>;
38
+ }) => ExprType<O>);
39
+ /**
40
+ * Factory producing a callable FunctionExpr so users can invoke it directly.
41
+ * Prototype chain preserved for instanceof checks.
42
+ *
43
+ * @internal
44
+ */
45
+ export declare function createFunctionExpr<I extends any[], O extends any>(input_types: I, output_type: O, ast: AST, createExpr: ToExpr): CallableFunctionExpr<I, O>;
46
+ //# sourceMappingURL=function.d.ts.map