summaryrefslogtreecommitdiffstats
path: root/llparse-builder/src/code/mul-add.ts
blob: fd648ed4549d5f2c2679c2fc12cfa313958bdde8 (plain)
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
import { Field } from './field';

/**
 * Options for `code.mulAdd()`.
 */
export interface IMulAddOptions {
  /** Value to multiply the property with in the first step */
  readonly base: number;

  /**
   * Maximum value of the property. If at any point of computation the
   * intermediate result exceeds it - `mulAdd` returns 1 (overflow).
   */
  readonly max?: number;

  /**
   * If `true` - all arithmetics perfomed by `mulAdd` will be signed.
   *
   * Default value: `false`
   */
  readonly signed?: boolean;
}

export class MulAdd extends Field {
  constructor(field: string, public readonly options: IMulAddOptions) {
    super('value', 'mul_add', field);
  }
}