@jspicl/core 4.0.0-alpha.3 → 4.0.0-alpha.4

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.
@@ -1 +1 @@
1
- {"version":3,"file":"returnStatement.d.ts","sourceRoot":"","sources":["../../../src/ast/statements/returnStatement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,OAAO,EAAE,cAAc,EAAC,MAAM,gBAAgB,CAAC;AAE5D,eAAO,MAAM,iBAAiB,GAC5B,OAAO,OAAO,GAAG,IAAI,KACpB,IAAI,IAAI,eAAmD,CAAC;AAE/D,eAAO,MAAM,eAAe,EAAE,cAAc,CAAC,eAAe,CAO3D,CAAC"}
1
+ {"version":3,"file":"returnStatement.d.ts","sourceRoot":"","sources":["../../../src/ast/statements/returnStatement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,OAAO,EAAE,cAAc,EAAC,MAAM,gBAAgB,CAAC;AAE5D,eAAO,MAAM,iBAAiB,GAC5B,OAAO,OAAO,GAAG,IAAI,KACpB,IAAI,IAAI,eAAmD,CAAC;AAE/D,eAAO,MAAM,eAAe,EAAE,cAAc,CAAC,eAAe,CAmB3D,CAAC"}
@@ -1,5 +1,14 @@
1
1
  export const isReturnStatement = (node) => node?.type === "ReturnStatement";
2
2
  export const ReturnStatement = ({ argument }, { transpile }) => {
3
+ // It's common for minification of Javascript to yield return statements like `return (a, b, c)`,
4
+ // which is a sequence expression. In Lua, we need to split the sequence expression into multiple lines and return the last expression.
5
+ if (argument?.type === "SequenceExpression") {
6
+ const lastExpression = argument.expressions[argument.expressions.length - 1];
7
+ const expressions = argument.expressions.slice(0, -1);
8
+ const transpiledExpressions = transpile(expressions);
9
+ const transpiledLastExpresion = transpile(lastExpression);
10
+ return `${transpiledExpressions}\nreturn ${transpiledLastExpresion}`;
11
+ }
3
12
  const value = transpile(argument);
4
13
  return value ? `return ${value}` : "do return end";
5
14
  };
@@ -1 +1 @@
1
- {"version":3,"file":"returnStatement.js","sourceRoot":"","sources":["../../../src/ast/statements/returnStatement.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,IAAqB,EACI,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,iBAAiB,CAAC;AAE/D,MAAM,CAAC,MAAM,eAAe,GAAoC,CAC9D,EAAC,QAAQ,EAAC,EACV,EAAC,SAAS,EAAC,EACX,EAAE;IACF,MAAM,KAAK,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;IAElC,OAAO,KAAK,CAAC,CAAC,CAAC,UAAU,KAAK,EAAE,CAAC,CAAC,CAAC,eAAe,CAAC;AACrD,CAAC,CAAC"}
1
+ {"version":3,"file":"returnStatement.js","sourceRoot":"","sources":["../../../src/ast/statements/returnStatement.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,IAAqB,EACI,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,iBAAiB,CAAC;AAE/D,MAAM,CAAC,MAAM,eAAe,GAAoC,CAC9D,EAAC,QAAQ,EAAC,EACV,EAAC,SAAS,EAAC,EACX,EAAE;IACF,iGAAiG;IACjG,uIAAuI;IACvI,IAAI,QAAQ,EAAE,IAAI,KAAK,oBAAoB,EAAE,CAAC;QAC5C,MAAM,cAAc,GAClB,QAAQ,CAAC,WAAW,CAAC,QAAQ,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACxD,MAAM,WAAW,GAAG,QAAQ,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QACtD,MAAM,qBAAqB,GAAG,SAAS,CAAC,WAAW,CAAC,CAAC;QACrD,MAAM,uBAAuB,GAAG,SAAS,CAAC,cAAc,CAAC,CAAC;QAE1D,OAAO,GAAG,qBAAqB,YAAY,uBAAuB,EAAE,CAAC;IACvE,CAAC;IAED,MAAM,KAAK,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;IAElC,OAAO,KAAK,CAAC,CAAC,CAAC,UAAU,KAAK,EAAE,CAAC,CAAC,CAAC,eAAe,CAAC;AACrD,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jspicl/core",
3
- "version": "4.0.0-alpha.3",
3
+ "version": "4.0.0-alpha.4",
4
4
  "description": "A javascript to PICO-8 LUA converter",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -70,5 +70,5 @@
70
70
  "engines": {
71
71
  "node": ">=22"
72
72
  },
73
- "stableVersion": "4.0.0-alpha.2"
73
+ "stableVersion": "4.0.0-alpha.4"
74
74
  }