-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
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 usingflags[10] = true;public []=(x: usize, y: usize: value: bool): void
is called usingquadrantChecked[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
MEMBERGETTEROperator not yet implemted, this is outside the scope of this taskMEMBERSETTEROperator not yet implemted, this is outside the scope of this task