Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constant expression elimination #20

Open
ikskuh opened this issue Aug 25, 2020 · 0 comments
Open

Constant expression elimination #20

ikskuh opened this issue Aug 25, 2020 · 0 comments
Labels
compiler This issue is related to the compiler. feature New feature or request

Comments

@ikskuh
Copy link
Owner

ikskuh commented Aug 25, 2020

Allow the compiler to precalculate constant expressions to reduce runtime overhead.

Example:

var foo = 10 * 3 + 2;

can be optimized to

var foo = 32;

This can even propagate through variables as the compiler can detect whether variables will be reassigned or not, allowing global constant folding:

var PI = 3.14;

function Rad2Deg(r) {
    return r * 180 / PI; // this can be folded into a single multiplication
}
@ikskuh ikskuh added feature New feature or request compiler This issue is related to the compiler. labels Aug 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler This issue is related to the compiler. feature New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant