Skip to content

Automate evaluate_stack_operator #31

Closed

Description

@Sekqies

Say we want to add a new function, tom(z) = 1 - z. In the current code, we have to:

  1. Create Operator::TOM
  2. Create a FullOperator with the function tom's properties, such as arity, precedence, etc (which will, of course, default to the same as every other unary function)
  3. In our shader code, create a macro #define TOM SHADER_TOM
  4. In our shader code, add a block guard #ifndef SHADER_TOM #define SHADER_TOM 0u #endif
  5. Implement vec2 tom(vec2 z)
  6. Add to evaluate_unary_operator a clause if(op == TOM){return tom(param);}

This makes no sense! There is no good reason for us to do anything but steps 1,2,5. And, since we already have a lot of string manipulation, and a dedicated library (preprocessor/) created just for manipulating shaders at runtime, this process can, and should, very well be optimized.

Another good thing comes from this: we have a "mini-compiler" for our interpreter. I reckon there's some optimizations to be made to make the switch-case and stack manipulation to be made.

Activity

  1. self-assigned this
    on Jan 23, 2026
  2. Sekqies commented on Jan 24, 2026

    @Sekqies
    OwnerAuthor

    Done! Commit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions