|
1 | 1 | ## Operators Implementation |
2 | | -The implementation of the operators (+, -, *, /, ==, ===, !=, !==, &&, ||, !) are implemented in [decompiler](https://github.com/microsoft/pxt/blob/master/pxtcompiler/emitter/decompiler.ts). |
3 | | -They are implemented by using a map, which includes the type of the operator and where it belongs. |
| 2 | +The implementation of the operators (+, -, *, /, ==, ===, !=, !==, &&, ||, !) are implemented in the [decompiler](https://github.com/microsoft/pxt/blob/master/pxtcompiler/emitter/decompiler.ts). |
| 3 | +They are implemented by using a map, which includes the type of the operator and where it belongs: |
| 4 | +``` ts |
| 5 | + const ops: pxt.Map<{ type: string; op?: string; leftName?: string; rightName?: string }> = { |
| 6 | + "+": { type: "math_arithmetic", op: "ADD" }, |
| 7 | + "-": { type: "math_arithmetic", op: "MINUS" }, |
| 8 | + "/": { type: "math_arithmetic", op: "DIVIDE" }, |
| 9 | + "*": { type: "math_arithmetic", op: "MULTIPLY" }, |
| 10 | + "**": { type: "math_arithmetic", op: "POWER" }, |
| 11 | + "%": { type: "math_modulo", leftName: "DIVIDEND", rightName: "DIVISOR" }, |
| 12 | + "<": { type: "logic_compare", op: "LT" }, |
| 13 | + "<=": { type: "logic_compare", op: "LTE" }, |
| 14 | + ">": { type: "logic_compare", op: "GT" }, |
| 15 | + ">=": { type: "logic_compare", op: "GTE" }, |
| 16 | + "==": { type: "logic_compare", op: "EQ" }, |
| 17 | + "===": { type: "logic_compare", op: "EQ" }, |
| 18 | + "!=": { type: "logic_compare", op: "NEQ" }, |
| 19 | + "!==": { type: "logic_compare", op: "NEQ" }, |
| 20 | + "&&": { type: "logic_operation", op: "AND" }, |
| 21 | + "||": { type: "logic_operation", op: "OR" }, |
| 22 | + } |
| 23 | +``` |
0 commit comments