greybel-interpreter 5.0.1 → 5.0.3
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.
|
@@ -327,13 +327,6 @@ class BytecodeExpressionGenerator {
|
|
|
327
327
|
if (item.init instanceof miniscript_core_1.ASTLiteral) {
|
|
328
328
|
defaultValue = (0, utils_1.generateCustomValueFromASTLiteral)(item.init);
|
|
329
329
|
}
|
|
330
|
-
else if (item.init instanceof miniscript_core_1.ASTUnaryExpression &&
|
|
331
|
-
item.init.argument instanceof miniscript_core_1.ASTLiteral) {
|
|
332
|
-
defaultValue = (0, utils_1.generateCustomValueFromASTLiteral)(item.init.argument);
|
|
333
|
-
if (item.init.operator === miniscript_core_1.Operator.Minus) {
|
|
334
|
-
defaultValue = new number_1.CustomNumber(-defaultValue.toNumber());
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
330
|
args.push({
|
|
338
331
|
name: new string_1.CustomString(item.variable.name),
|
|
339
332
|
defaultValue
|
|
@@ -8,12 +8,20 @@ const number_1 = require("../types/number");
|
|
|
8
8
|
const string_1 = require("../types/string");
|
|
9
9
|
function generateCustomValueFromASTLiteral(node) {
|
|
10
10
|
switch (node.type) {
|
|
11
|
-
case miniscript_core_1.ASTType.BooleanLiteral:
|
|
12
|
-
|
|
11
|
+
case miniscript_core_1.ASTType.BooleanLiteral: {
|
|
12
|
+
const booleanLiteralNode = node;
|
|
13
|
+
return new boolean_1.CustomBoolean(booleanLiteralNode.negated
|
|
14
|
+
? -booleanLiteralNode.value
|
|
15
|
+
: booleanLiteralNode.value);
|
|
16
|
+
}
|
|
13
17
|
case miniscript_core_1.ASTType.StringLiteral:
|
|
14
18
|
return new string_1.CustomString(node.value);
|
|
15
|
-
case miniscript_core_1.ASTType.NumericLiteral:
|
|
16
|
-
|
|
19
|
+
case miniscript_core_1.ASTType.NumericLiteral: {
|
|
20
|
+
const numericLiteralNode = node;
|
|
21
|
+
return new number_1.CustomNumber(numericLiteralNode.negated
|
|
22
|
+
? -numericLiteralNode.value
|
|
23
|
+
: numericLiteralNode.value);
|
|
24
|
+
}
|
|
17
25
|
case miniscript_core_1.ASTType.NilLiteral:
|
|
18
26
|
return default_1.DefaultType.Void;
|
|
19
27
|
default:
|
package/dist/types/boolean.d.ts
CHANGED
package/dist/vm/evaluation.js
CHANGED
|
@@ -212,9 +212,7 @@ function evalLessThan(a, b) {
|
|
|
212
212
|
if (b instanceof number_1.CustomNumber)
|
|
213
213
|
return new boolean_1.CustomBoolean(a.toNumber() < b.toNumber());
|
|
214
214
|
}
|
|
215
|
-
else if (a instanceof string_1.CustomString) {
|
|
216
|
-
if (b instanceof nil_1.CustomNil)
|
|
217
|
-
b = new string_1.CustomString('');
|
|
215
|
+
else if (a instanceof string_1.CustomString && b instanceof string_1.CustomString) {
|
|
218
216
|
return new boolean_1.CustomBoolean(a.toString() < b.toString());
|
|
219
217
|
}
|
|
220
218
|
return default_1.DefaultType.Void;
|
|
@@ -227,9 +225,7 @@ function evalLessThanOrEqual(a, b) {
|
|
|
227
225
|
if (b instanceof number_1.CustomNumber)
|
|
228
226
|
return new boolean_1.CustomBoolean(a.toNumber() <= b.toNumber());
|
|
229
227
|
}
|
|
230
|
-
else if (a instanceof string_1.CustomString) {
|
|
231
|
-
if (b instanceof nil_1.CustomNil)
|
|
232
|
-
b = new string_1.CustomString('');
|
|
228
|
+
else if (a instanceof string_1.CustomString && b instanceof string_1.CustomString) {
|
|
233
229
|
return new boolean_1.CustomBoolean(a.toString() <= b.toString());
|
|
234
230
|
}
|
|
235
231
|
return default_1.DefaultType.Void;
|
|
@@ -242,9 +238,7 @@ function evalGreaterThan(a, b) {
|
|
|
242
238
|
if (b instanceof number_1.CustomNumber)
|
|
243
239
|
return new boolean_1.CustomBoolean(a.toNumber() > b.toNumber());
|
|
244
240
|
}
|
|
245
|
-
else if (a instanceof string_1.CustomString) {
|
|
246
|
-
if (b instanceof nil_1.CustomNil)
|
|
247
|
-
b = new string_1.CustomString('');
|
|
241
|
+
else if (a instanceof string_1.CustomString && b instanceof string_1.CustomString) {
|
|
248
242
|
return new boolean_1.CustomBoolean(a.toString() > b.toString());
|
|
249
243
|
}
|
|
250
244
|
return default_1.DefaultType.Void;
|
|
@@ -258,8 +252,6 @@ function evalGreaterThanOrEqual(a, b) {
|
|
|
258
252
|
return new boolean_1.CustomBoolean(a.toNumber() >= b.toNumber());
|
|
259
253
|
}
|
|
260
254
|
else if (a instanceof string_1.CustomString && b instanceof string_1.CustomString) {
|
|
261
|
-
if (b instanceof nil_1.CustomNil)
|
|
262
|
-
b = new string_1.CustomString('');
|
|
263
255
|
return new boolean_1.CustomBoolean(a.toString() >= b.toString());
|
|
264
256
|
}
|
|
265
257
|
return default_1.DefaultType.Void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "greybel-interpreter",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.3",
|
|
4
4
|
"description": "Interpreter",
|
|
5
5
|
"main": "dist/index",
|
|
6
6
|
"typings": "dist/index",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"typescript": "^5.0.4"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"greybel-core": "~2.0.
|
|
52
|
+
"greybel-core": "~2.0.3",
|
|
53
53
|
"hyperid": "^3.2.0",
|
|
54
54
|
"non-blocking-schedule": "^0.1.0"
|
|
55
55
|
},
|