@irrelon/battlescript 3.1.6 → 3.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/bin/functionality.ts +18 -4
- package/bin/index.js +151 -57
- package/bin/index.js.map +1 -1
- package/dist/bin/functionality.d.ts.map +1 -1
- package/dist/index.js +129 -53
- package/dist/index.js.map +1 -1
- package/dist/nativeLibraries/time/index.d.ts +3 -0
- package/dist/nativeLibraries/time/index.d.ts.map +1 -0
- package/dist/services/fullAst/BattleScriptToAST.d.ts +1 -1
- package/dist/services/fullAst/BattleScriptToAST.d.ts.map +1 -1
- package/dist/services/miniAst/BattleScriptToMiniAST.d.ts.map +1 -1
- package/dist/services/parser.d.ts.map +1 -1
- package/dist/tsconfig.types.tsbuildinfo +1 -1
- package/dist/types/ast/nodes/RootNode.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"functionality.d.ts","sourceRoot":"","sources":["../../bin/functionality.ts"],"names":[],"mappings":"AAyBA,wBAAsB,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"functionality.d.ts","sourceRoot":"","sources":["../../bin/functionality.ts"],"names":[],"mappings":"AAyBA,wBAAsB,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,gBAoBjE;AAED,wBAAgB,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,OAoB/D;AAED,wBAAsB,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,iBAYlE;AAED,wBAAsB,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,iBAgBpE;AAED,wBAAsB,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,iBAsBnE;AAED,wBAAsB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,iBAgB1E;AAED,wBAAsB,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,iBAUrE;AAcD,wBAAsB,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,iBAWvE;AAED,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAIxE"}
|
package/dist/index.js
CHANGED
|
@@ -26297,7 +26297,7 @@ var body$2 = [
|
|
|
26297
26297
|
kind: "FUNCTION_DECLARATION",
|
|
26298
26298
|
returnType: {
|
|
26299
26299
|
kind: "DATA_TYPE",
|
|
26300
|
-
value: "
|
|
26300
|
+
value: "void",
|
|
26301
26301
|
meta: {
|
|
26302
26302
|
start: {
|
|
26303
26303
|
line: 1,
|
|
@@ -26306,28 +26306,60 @@ var body$2 = [
|
|
|
26306
26306
|
},
|
|
26307
26307
|
stop: {
|
|
26308
26308
|
line: 1,
|
|
26309
|
-
column:
|
|
26310
|
-
offset:
|
|
26309
|
+
column: 11,
|
|
26310
|
+
offset: 10
|
|
26311
26311
|
}
|
|
26312
26312
|
}
|
|
26313
26313
|
},
|
|
26314
26314
|
id: {
|
|
26315
26315
|
kind: "IDENTIFIER",
|
|
26316
|
-
value: "std::gpio.
|
|
26316
|
+
value: "std::gpio.setPinMode",
|
|
26317
26317
|
meta: {
|
|
26318
26318
|
start: {
|
|
26319
26319
|
line: 1,
|
|
26320
|
-
column:
|
|
26321
|
-
offset:
|
|
26320
|
+
column: 12,
|
|
26321
|
+
offset: 12
|
|
26322
26322
|
},
|
|
26323
26323
|
stop: {
|
|
26324
26324
|
line: 1,
|
|
26325
|
-
column:
|
|
26326
|
-
offset:
|
|
26325
|
+
column: 32,
|
|
26326
|
+
offset: 31
|
|
26327
26327
|
}
|
|
26328
26328
|
}
|
|
26329
26329
|
},
|
|
26330
26330
|
params: [
|
|
26331
|
+
{
|
|
26332
|
+
kind: "IDENTIFIER",
|
|
26333
|
+
value: "newMode",
|
|
26334
|
+
meta: {
|
|
26335
|
+
start: {
|
|
26336
|
+
line: 1,
|
|
26337
|
+
column: 38,
|
|
26338
|
+
offset: 38
|
|
26339
|
+
},
|
|
26340
|
+
stop: {
|
|
26341
|
+
line: 1,
|
|
26342
|
+
column: 45,
|
|
26343
|
+
offset: 44
|
|
26344
|
+
}
|
|
26345
|
+
},
|
|
26346
|
+
type: {
|
|
26347
|
+
kind: "DATA_TYPE",
|
|
26348
|
+
value: "int",
|
|
26349
|
+
meta: {
|
|
26350
|
+
start: {
|
|
26351
|
+
line: 1,
|
|
26352
|
+
column: 34,
|
|
26353
|
+
offset: 34
|
|
26354
|
+
},
|
|
26355
|
+
stop: {
|
|
26356
|
+
line: 1,
|
|
26357
|
+
column: 37,
|
|
26358
|
+
offset: 36
|
|
26359
|
+
}
|
|
26360
|
+
}
|
|
26361
|
+
}
|
|
26362
|
+
}
|
|
26331
26363
|
],
|
|
26332
26364
|
isNative: true,
|
|
26333
26365
|
isPure: false,
|
|
@@ -26339,8 +26371,8 @@ var body$2 = [
|
|
|
26339
26371
|
},
|
|
26340
26372
|
stop: {
|
|
26341
26373
|
line: 1,
|
|
26342
|
-
column:
|
|
26343
|
-
offset:
|
|
26374
|
+
column: 47,
|
|
26375
|
+
offset: 46
|
|
26344
26376
|
}
|
|
26345
26377
|
}
|
|
26346
26378
|
},
|
|
@@ -26348,17 +26380,68 @@ var body$2 = [
|
|
|
26348
26380
|
kind: "FUNCTION_DECLARATION",
|
|
26349
26381
|
returnType: {
|
|
26350
26382
|
kind: "DATA_TYPE",
|
|
26351
|
-
value: "
|
|
26383
|
+
value: "float",
|
|
26352
26384
|
meta: {
|
|
26353
26385
|
start: {
|
|
26354
26386
|
line: 2,
|
|
26355
26387
|
column: 7,
|
|
26356
|
-
offset:
|
|
26388
|
+
offset: 55
|
|
26389
|
+
},
|
|
26390
|
+
stop: {
|
|
26391
|
+
line: 2,
|
|
26392
|
+
column: 12,
|
|
26393
|
+
offset: 59
|
|
26394
|
+
}
|
|
26395
|
+
}
|
|
26396
|
+
},
|
|
26397
|
+
id: {
|
|
26398
|
+
kind: "IDENTIFIER",
|
|
26399
|
+
value: "std::gpio.readPin",
|
|
26400
|
+
meta: {
|
|
26401
|
+
start: {
|
|
26402
|
+
line: 2,
|
|
26403
|
+
column: 13,
|
|
26404
|
+
offset: 61
|
|
26357
26405
|
},
|
|
26358
26406
|
stop: {
|
|
26359
26407
|
line: 2,
|
|
26408
|
+
column: 30,
|
|
26409
|
+
offset: 77
|
|
26410
|
+
}
|
|
26411
|
+
}
|
|
26412
|
+
},
|
|
26413
|
+
params: [
|
|
26414
|
+
],
|
|
26415
|
+
isNative: true,
|
|
26416
|
+
isPure: false,
|
|
26417
|
+
meta: {
|
|
26418
|
+
start: {
|
|
26419
|
+
line: 2,
|
|
26420
|
+
column: 0,
|
|
26421
|
+
offset: 48
|
|
26422
|
+
},
|
|
26423
|
+
stop: {
|
|
26424
|
+
line: 2,
|
|
26425
|
+
column: 34,
|
|
26426
|
+
offset: 81
|
|
26427
|
+
}
|
|
26428
|
+
}
|
|
26429
|
+
},
|
|
26430
|
+
{
|
|
26431
|
+
kind: "FUNCTION_DECLARATION",
|
|
26432
|
+
returnType: {
|
|
26433
|
+
kind: "DATA_TYPE",
|
|
26434
|
+
value: "void",
|
|
26435
|
+
meta: {
|
|
26436
|
+
start: {
|
|
26437
|
+
line: 3,
|
|
26438
|
+
column: 7,
|
|
26439
|
+
offset: 90
|
|
26440
|
+
},
|
|
26441
|
+
stop: {
|
|
26442
|
+
line: 3,
|
|
26360
26443
|
column: 11,
|
|
26361
|
-
offset:
|
|
26444
|
+
offset: 93
|
|
26362
26445
|
}
|
|
26363
26446
|
}
|
|
26364
26447
|
},
|
|
@@ -26367,14 +26450,14 @@ var body$2 = [
|
|
|
26367
26450
|
value: "std::gpio.writePin",
|
|
26368
26451
|
meta: {
|
|
26369
26452
|
start: {
|
|
26370
|
-
line:
|
|
26453
|
+
line: 3,
|
|
26371
26454
|
column: 12,
|
|
26372
|
-
offset:
|
|
26455
|
+
offset: 95
|
|
26373
26456
|
},
|
|
26374
26457
|
stop: {
|
|
26375
|
-
line:
|
|
26458
|
+
line: 3,
|
|
26376
26459
|
column: 30,
|
|
26377
|
-
offset:
|
|
26460
|
+
offset: 112
|
|
26378
26461
|
}
|
|
26379
26462
|
}
|
|
26380
26463
|
},
|
|
@@ -26384,14 +26467,14 @@ var body$2 = [
|
|
|
26384
26467
|
value: "newVal",
|
|
26385
26468
|
meta: {
|
|
26386
26469
|
start: {
|
|
26387
|
-
line:
|
|
26470
|
+
line: 3,
|
|
26388
26471
|
column: 36,
|
|
26389
|
-
offset:
|
|
26472
|
+
offset: 119
|
|
26390
26473
|
},
|
|
26391
26474
|
stop: {
|
|
26392
|
-
line:
|
|
26475
|
+
line: 3,
|
|
26393
26476
|
column: 42,
|
|
26394
|
-
offset:
|
|
26477
|
+
offset: 124
|
|
26395
26478
|
}
|
|
26396
26479
|
},
|
|
26397
26480
|
type: {
|
|
@@ -26399,14 +26482,14 @@ var body$2 = [
|
|
|
26399
26482
|
value: "int",
|
|
26400
26483
|
meta: {
|
|
26401
26484
|
start: {
|
|
26402
|
-
line:
|
|
26485
|
+
line: 3,
|
|
26403
26486
|
column: 32,
|
|
26404
|
-
offset:
|
|
26487
|
+
offset: 115
|
|
26405
26488
|
},
|
|
26406
26489
|
stop: {
|
|
26407
|
-
line:
|
|
26490
|
+
line: 3,
|
|
26408
26491
|
column: 35,
|
|
26409
|
-
offset:
|
|
26492
|
+
offset: 117
|
|
26410
26493
|
}
|
|
26411
26494
|
}
|
|
26412
26495
|
}
|
|
@@ -26416,14 +26499,14 @@ var body$2 = [
|
|
|
26416
26499
|
isPure: false,
|
|
26417
26500
|
meta: {
|
|
26418
26501
|
start: {
|
|
26419
|
-
line:
|
|
26502
|
+
line: 3,
|
|
26420
26503
|
column: 0,
|
|
26421
|
-
offset:
|
|
26504
|
+
offset: 83
|
|
26422
26505
|
},
|
|
26423
26506
|
stop: {
|
|
26424
|
-
line:
|
|
26507
|
+
line: 3,
|
|
26425
26508
|
column: 44,
|
|
26426
|
-
offset:
|
|
26509
|
+
offset: 126
|
|
26427
26510
|
}
|
|
26428
26511
|
}
|
|
26429
26512
|
}
|
|
@@ -27934,7 +28017,7 @@ function getAllNativeLibraryFunctions(rootNode) {
|
|
|
27934
28017
|
];
|
|
27935
28018
|
}
|
|
27936
28019
|
|
|
27937
|
-
var version = "3.1.
|
|
28020
|
+
var version = "3.1.7";
|
|
27938
28021
|
var binaryVersion = 7;
|
|
27939
28022
|
|
|
27940
28023
|
const RootNodeLayout = [{
|
|
@@ -28969,28 +29052,26 @@ class BattleScriptToMiniAST {
|
|
|
28969
29052
|
return requiredCount;
|
|
28970
29053
|
}, 0);
|
|
28971
29054
|
if (functionArgs.length < requiredCount) {
|
|
28972
|
-
functionParams.
|
|
28973
|
-
if (
|
|
28974
|
-
if (!functionArgs[index]) {
|
|
28975
|
-
throw new Error(formatCompilerError(this._filePath, this._sourceCode, "error", node.meta, `Call to function ${prettyPrintFunctionDeclaration(functionNode)} is missing required argument \`${this.nodeResolver.visit(param)}\``));
|
|
28976
|
-
}
|
|
28977
|
-
requiredCount++;
|
|
29055
|
+
functionParams.forEach((param, index) => {
|
|
29056
|
+
if (functionArgs[index]) {
|
|
28978
29057
|
finalArgs.push(functionArgs[index]);
|
|
29058
|
+
return;
|
|
29059
|
+
}
|
|
29060
|
+
if (param.kind === "IDENTIFIER") {
|
|
29061
|
+
throw new Error(formatCompilerError(this._filePath, this._sourceCode, "error", node.meta, `Call to function ${prettyPrintFunctionDeclaration(functionNode)} is missing required argument \`${this.nodeResolver.visit(param)}\``));
|
|
28979
29062
|
}
|
|
28980
29063
|
else if (param.kind === "ASSIGNMENT_PATTERN") {
|
|
28981
|
-
|
|
28982
|
-
|
|
28983
|
-
|
|
28984
|
-
|
|
28985
|
-
|
|
28986
|
-
|
|
28987
|
-
|
|
28988
|
-
|
|
28989
|
-
finalArgs.push(clone(param.right));
|
|
28990
|
-
}
|
|
29064
|
+
// We don't have a value but we do have a default, use it
|
|
29065
|
+
// We use clone here because we want to create an entirely new node entry in the node array
|
|
29066
|
+
// just for this one argument so that we don't point at a node index (the default argument
|
|
29067
|
+
// in the function definition) because that would generate a non-contiguous start index
|
|
29068
|
+
// and count for the function call arguments. However, when the meta array is compiled,
|
|
29069
|
+
// the cloned node will still have the same meta data so will highlight the original
|
|
29070
|
+
// function definition parameter which shows where the value came from.
|
|
29071
|
+
finalArgs.push(clone(param.right));
|
|
28991
29072
|
}
|
|
28992
|
-
return
|
|
28993
|
-
}
|
|
29073
|
+
return;
|
|
29074
|
+
});
|
|
28994
29075
|
}
|
|
28995
29076
|
else {
|
|
28996
29077
|
return functionArgs;
|
|
@@ -39077,8 +39158,6 @@ function fromSourceCodeToFullAst(inputText, options) {
|
|
|
39077
39158
|
const tree = parser.root();
|
|
39078
39159
|
console.log(`[BattleScript ${version}] Transforming source code -> AST...`);
|
|
39079
39160
|
const transformer = new BattleScriptToAST(options?.filePath || "-", inputText, options?.sourceResolver);
|
|
39080
|
-
transformer.filePath(options?.filePath);
|
|
39081
|
-
transformer.sourceCode(inputText);
|
|
39082
39161
|
return transformer.visit(tree, options);
|
|
39083
39162
|
}
|
|
39084
39163
|
function fromFullAstToSourceCode(ast, options = { includeMetaData: true }) {
|
|
@@ -39090,8 +39169,6 @@ function fromSourceCodeToMiniAst(source, options = { includeMetaData: true }) {
|
|
|
39090
39169
|
const ast = fromSourceCodeToFullAst(source, options);
|
|
39091
39170
|
console.log(`[BattleScript ${version}] Transforming AST -> MiniAST...`);
|
|
39092
39171
|
const transformer = new BattleScriptToMiniAST(options?.filePath || "-", source);
|
|
39093
|
-
transformer.filePath(options?.filePath);
|
|
39094
|
-
transformer.sourceCode(source); // Add for debugging purposes
|
|
39095
39172
|
return transformer.transform(ast, options);
|
|
39096
39173
|
}
|
|
39097
39174
|
function fromMiniAstToBinary(miniAst, options = { includeMetaData: true }) {
|
|
@@ -39110,7 +39187,6 @@ function fromSourceCodeToByteCode(source, options = { includeMetaData: true }) {
|
|
|
39110
39187
|
const parser = getParser(source);
|
|
39111
39188
|
const tree = parser.root();
|
|
39112
39189
|
const transformer = new BattleScriptToAST(options?.filePath || "-", source, options?.sourceResolver);
|
|
39113
|
-
transformer.sourceCode(source);
|
|
39114
39190
|
transformer.visit(tree, options);
|
|
39115
39191
|
}
|
|
39116
39192
|
// const transformer = new BattleScriptToByteCode();
|