Skip to content

Compile-time evaluation #5

Open

Description

@jeparlefrancais

Having this feature will open up a lot of new possibilities for this project.

For example, the evaluation of pure functions with constant arguments. This would require some pretty clever evaluation, because the program needs to understand if a function is pure.

More reasonably, the first rules exploiting this feature could be to evaluate binary expressions using constant expressions (like a literal string or a number).

Examples:

Original code Processed code
10 * 50 + 2 502
true or false true
87 == "hello" false

This also opens the possibility to optimize if branches, by evaluating conditions at compile time and stripping unused branches.

Activity

  1. jeparlefrancais commented on Mar 19, 2020

    @jeparlefrancais
    ContributorAuthor

    Now that the Evaluator struct is partly implemented, this issue can be used to keep track of what darklua is currently able to evaluate.

    Values:

    • Boolean
    • Nil
    • String
    • Number
    • Table
    • Variable
    • Parentheses
    • Index
    • Field
    • Function call
    • Binary expression
      • and
      • or
      • ==, ~=
      • <, <=, >, >=
      • +, -, *, /, %, ^
      • ..
    • Unary expression
      • not
      • -
      • # (for strings)
      • # (for tables)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions