From b7e74c73488e0d45c9398445816d567b45ec3c62 Mon Sep 17 00:00:00 2001 From: xiangnan <280145668@qq.com> Date: Mon, 7 Oct 2024 15:52:33 +0800 Subject: [PATCH] fix:a.b.c() --- README.md | 18 ++++++------------ README.template.md | 3 +++ makeDocs.js | 2 ++ package-lock.json | 4 ++-- package.json | 4 ++-- src/js2lua.mjs | 1 + 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 811b63e..a38df34 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,9 @@ where options are: ```js const defaultOptions = { debug: false, + tagArrayExpression: true, importStatementHoisting: true, + transform$SymbolToDollar: true, transformToString: true, transformString: true, transformJSONStringify: true, @@ -53,6 +55,7 @@ js2lua(`let a = 1`, {importStatementHoisting:true}) ``` ## see also [lua2js](https://xiangnanscu.github.io/lua2js/) transform lua to js +[lua-resty-array](https://github.com/xiangnanscu/lua-resty-array) lua version of JS Array (feature tagArrayExpression) # Features * [assignment](#assignment) @@ -265,15 +268,9 @@ Position:echoInsCount() p1:echoPosition() p2:echoPosition() p1:say("hello") -(function() - local __tmp = p1.say - return __tmp(p2) -end)() +p1.say(p2) p1:echoNumbersLength("a", "b", "c") -(function() - local __tmp = p1.echoNumbersLength - return __tmp(p2, unpack(array {1, 2})) -end)() +p1.echoNumbersLength(p2, unpack(array {1, 2})) ``` ## export @@ -1109,10 +1106,7 @@ local cjson = require("cjson") local a = {b = ""} tostring(1) -(function() - local __tmp = a.b - return tostring(__tmp) -end)() +tostring(a.b) cjson.encode({}) cjson.decode("{}") tonumber("2") diff --git a/README.template.md b/README.template.md index d962e48..bce8bd9 100644 --- a/README.template.md +++ b/README.template.md @@ -15,7 +15,9 @@ where options are: ```js const defaultOptions = { debug: false, + tagArrayExpression: true, importStatementHoisting: true, + transform$SymbolToDollar: true, transformToString: true, transformString: true, transformJSONStringify: true, @@ -53,6 +55,7 @@ js2lua(`let a = 1`, {importStatementHoisting:true}) ``` ## see also [lua2js](https://xiangnanscu.github.io/lua2js/) transform lua to js +[lua-resty-array](https://github.com/xiangnanscu/lua-resty-array) lua version of JS Array (feature tagArrayExpression) # Features [CODE_TABLE] \ No newline at end of file diff --git a/makeDocs.js b/makeDocs.js index 6d82882..02ee42b 100644 --- a/makeDocs.js +++ b/makeDocs.js @@ -7,7 +7,9 @@ const folderPath = './test'; const markdown = fs.readFileSync('./README.template.md', 'utf8'); const files = fs.readdirSync(folderPath); const opts = { + tagArrayExpression: true, importStatementHoisting: true, + transform$SymbolToDollar: true, transformToString: true, transformString: true, transformJSONStringify: true, diff --git a/package-lock.json b/package-lock.json index 8276688..7b0fb69 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@xiangnanscu/js2lua", - "version": "0.36.0", + "version": "0.37.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@xiangnanscu/js2lua", - "version": "0.36.0", + "version": "0.37.0", "license": "MIT", "dependencies": { "@babel/parser": "^7.22.14", diff --git a/package.json b/package.json index e82389b..5ef003f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@xiangnanscu/js2lua", - "version": "0.36.0", + "version": "0.37.0", "type": "module", "description": "Writing LuaJIT with the expressiveness of JavaScript.", "main": "src/js2lua.mjs", @@ -25,7 +25,7 @@ "push": "yarn commit", "postpush": "while true; do git push && { echo 'Git push succeeded'; break; } || echo 'Git push failed, retrying in 1 seconds'; sleep 1; done", "pull": "while true; do git pull && { echo 'Git pull succeeded'; break; } || echo 'Git pull failed, retrying in 1 seconds'; sleep 1; done", - "prerelease": "npm --no-git-tag-version version minor", + "prerelease": "npm --no-git-tag-version version minor; node ./makeDocs.js", "release": "node makeDocs.js && push_option=release npm run push", "rc": "yarn release", "replace": "find . -type d \\( -name .git -o -name node_modules \\) -prune -o -type f -exec sed -i s/js2lua/field/g {} \\;", diff --git a/src/js2lua.mjs b/src/js2lua.mjs index 5e37473..23d1da4 100644 --- a/src/js2lua.mjs +++ b/src/js2lua.mjs @@ -498,6 +498,7 @@ function ast2lua(ast, opts = {}) { case "CallExpression": { if ( ast.callee.type == "MemberExpression" && + ast.callee.object.type !== "MemberExpression" && ast.callee.object.type !== "Identifier" && ast.callee.object.type !== "Super" ) {