Skip to content

Add range assetion instruction for quick parameter validation #3158

@DigitalCodeCrafter

Description

@DigitalCodeCrafter

Add a new opcode assertrange that checks whether the top-of-stack value is within a specified range.
The ML format would be assertrange <min> <max>.

It verifies that the top value of the stack is inside the specified range without consuming it.
This can be used to verify function parameters or array indexes.

This is faster than an if statement and reduces the compiled machine code size.

Optional

if null / PseudoNull is used in place of either min or max, the range is left open.
Example: assertrange 0 null will only assert that the value is positive.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions