Console function calls#454
Merged
Perryvw merged 5 commits intoTypeScriptToLua:masterfrom Feb 27, 2019
Merged
Conversation
Perryvw
reviewed
Feb 26, 2019
Member
Perryvw
left a comment
There was a problem hiding this comment.
This looks good! I have some superficial comments regarding formatting and readability, but overall I think this is a good first iteration. There are some areas that could be improved, like the lualib stuff you mentioned (lualib would also allow us to deep-print tables which might be nice), but I would be happy merging the current functionality as is and then iterating on it in a next PR.
src/LuaTransformer.ts
Outdated
| ); | ||
| case "trace": | ||
| if (expression.arguments.length > 0) { | ||
| if (this.isStringFormatTemplate(expression.arguments[0])) { |
Member
There was a problem hiding this comment.
Might as well merge these two if statements into one with a && (JS short-circuits if the left hand side fails, so it functions exactly the same)
src/LuaTransformer.ts
Outdated
| tstl.createTableIndexExpression( | ||
| tstl.createIdentifier("debug"), | ||
| tstl.createStringLiteral("traceback")), | ||
| [tstl.createCallExpression( |
Member
There was a problem hiding this comment.
This formatting is a little confusing, maybe adding some intermediate variables would help.
Perryvw
approved these changes
Feb 27, 2019
tomblind
approved these changes
Feb 27, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Continued from #443 as a partial solution for #439.
For the case below, the code doesn't work.
I looked into implementing these functions into LuaLibs since what happens is figured out at runtime, however something like:
Transpiles to lua with
unpack. Which means the solution won't work for all lua targets.This is only a partial implementation of
console.log,console.assertandconsole.tracesince the full solution would likely be implemented in a LuaLib.Submitting this PR just to show what I have and see if it is acceptable for now.