Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | 3x 3x 3x 11x 11x 11x 3x 11x 11x 1x 1x 1x | import * as util from '../util';
import {Expression, type ExpressionResult} from '../codegen-steps';
import type * as types from '../types';
const binaryOperands = (
expr: types.BinaryExpression<any>,
ctx: types.OperatorEvalCtx,
): [left: unknown, right: unknown] => {
const left = ctx.eval(expr[1], ctx);
const right = ctx.eval(expr[2], ctx);
return [left, right];
};
export const binaryOperators: types.OperatorDefinition<any>[] = [
[
'u8',
[],
2,
(expr: types.ExprU8, ctx) => {
const [bin, index] = binaryOperands(expr, ctx);
return util.u8(bin, index);
},
(ctx: types.OperatorCodegenCtx<types.ExprU8>): ExpressionResult => {
ctx.link(util.u8, 'u8');
const js = `u8((${ctx.operands[0]}),(${ctx.operands[1]}))`;
return new Expression(js);
},
] as types.OperatorDefinition<types.ExprU8>,
];
|