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

Verify parameter count for operators #143

Open
21 tasks
kindlich opened this issue Jun 1, 2024 · 0 comments
Open
21 tasks

Verify parameter count for operators #143

kindlich opened this issue Jun 1, 2024 · 0 comments
Labels
Milestone

Comments

@kindlich
Copy link
Member

kindlich commented Jun 1, 2024

Currently, it is possible to define an operator with any number of arguments.
However, we only support the operators:

  • Unary operators (whose header does not accept any parameter) public !(): Money
    • NEG, INVERT, NOT
  • binary operators (whose header accepts a single parameter) public +(other: Money): Money
    • ADD, SUB, MUL, DIV, MOD, CAT, OR, AND, XOR, INDEXGET, CONTAINS, COMPARE, EQUALS, NOTEQUALS, SHL, SHR, (MEMBERGETTER)
    • Their xxxAssign variants (ADD_ASSIGN, ...)
  • The MEMBERSETTER ternary operator (whose header accepts 2 parameters) public .=(name: string, amount: Money): void
  • Special Case: The indexSet operator can be registered to accept 2 or more parameters, with the last one being the value being set and all before the (multi-dim) indices
    • public []=(index: usize, value: bool): void
      is called using flags[10] = true;
    • public []=(x: usize, y: usize: value: bool): void
      is called using quadrantChecked[1, 3] = true
    • ...

If a user writes a script where they attempt to create an operator with an invalid parameter count, then the validator should log an error and no scripts should be executed.

CompileExceptionCode: INVALID_PARAMETER_COUNT
Message: "operator parameter count mismatched, X operator only supports Y paremters"

public +(other as int, other_other as int) {

}

Acceptance criteria:

  • For each below, write two tests, one that creates the operator with the proper parameters and has the script executed, and one that uses an invalid number of parameters and therefore fails
    • ADD
    • SUB
    • MUL
    • DIV
    • MOD
    • CAT
    • OR
    • AND
    • XOR
    • NEG
    • INVERT
    • NOT
    • INDEXSET (with 1 index variable, 2 index variables and check if overload of is possible)
    • INDEXGET
    • CONTAINS
    • COMPARE
    • EQUALS
    • NOTEQUALS
    • SHL
    • SHR
    • MEMBERGETTER Operator not yet implemted, this is outside the scope of this task
    • MEMBERSETTER Operator not yet implemted, this is outside the scope of this task
@kindlich kindlich added this to the v1.0.0 milestone Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant