summaryrefslogtreecommitdiffstats
path: root/llparse-builder/src/code/mul-add.ts
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--llparse-builder/src/code/mul-add.ts28
1 files changed, 28 insertions, 0 deletions
diff --git a/llparse-builder/src/code/mul-add.ts b/llparse-builder/src/code/mul-add.ts
new file mode 100644
index 0000000..fd648ed
--- /dev/null
+++ b/llparse-builder/src/code/mul-add.ts
@@ -0,0 +1,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);
+ }
+}