https://github.com/thinknathan/tstl-simple-const-unroller
TypeScriptToLua plugin that performs constant folding for simple numeric expressions
https://github.com/thinknathan/tstl-simple-const-unroller
lua tstl tstl-extension tstl-plugin typescript
Last synced: 4 months ago
JSON representation
TypeScriptToLua plugin that performs constant folding for simple numeric expressions
- Host: GitHub
- URL: https://github.com/thinknathan/tstl-simple-const-unroller
- Owner: thinknathan
- License: cc0-1.0
- Created: 2023-11-16T03:01:18.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-12-06T07:04:08.000Z (over 1 year ago)
- Last Synced: 2023-12-07T03:00:25.432Z (over 1 year ago)
- Topics: lua, tstl, tstl-extension, tstl-plugin, typescript
- Language: TypeScript
- Homepage:
- Size: 12.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tstl-simple-const-unroller
TypeScriptToLua plugin that performs [constant folding](https://en.wikipedia.org/wiki/Constant_folding) for simple numeric expressions:
- Addition (+)
- Subtraction (-)
- Multiplication (\*)
- Division (/)
- Modulo (%)
- Exponentiation (\*\*)All parts of the expression must be numeric literals.
Redundancy warning: Your target Lua runtime may already perform constant folding.
## Example
```ts
const hour = 60 * 60;
```Becomes:
```lua
local hour = 3600
```## Installation
Requires a modern version of TSTL. Tested on TSTL >= 1.22.0.
1. Install this plugin
```bash
yarn add git+https://[email protected]/thinknathan/tstl-simple-const-unroller.git#^1.0.0 -D
# or
npm install git+https://[email protected]/thinknathan/tstl-simple-const-unroller.git#^1.0.0 --save-dev
```2. Add `tstl-simple-const-unroller` to `tstl.luaPlugins` in `tsconfig.json`
```diff
{
"tstl": {
"luaPlugins": [
+ { "name": "tstl-simple-const-unroller" }
],
}
}
```## License
CC0