UNPKG

@eagleoutice/flowr-dev

Version:

Static Dataflow Analyzer and Program Slicer for the R Programming Language

61 lines (60 loc) 2.61 kB
import type { BuiltInEvalHandlerArgs } from '../../environments/built-in'; import { type Value } from '../values/r-value'; /** `strings` marks the operators that also fold for two strings; the ordering ones do not, as R compares them by locale collation */ export declare const ComparisonOps: { readonly '==': { readonly apply: (a: number | string, b: number | string) => boolean; readonly strings: true; }; readonly '!=': { readonly apply: (a: number | string, b: number | string) => boolean; readonly strings: true; }; readonly '<': { readonly apply: (a: number | string, b: number | string) => boolean; readonly strings: false; }; readonly '>': { readonly apply: (a: number | string, b: number | string) => boolean; readonly strings: false; }; readonly '<=': { readonly apply: (a: number | string, b: number | string) => boolean; readonly strings: false; }; readonly '>=': { readonly apply: (a: number | string, b: number | string) => boolean; readonly strings: false; }; }; /** * Resolves a comparison operator on two scalars of the same kind to a {@link Value} logical, with a logical counting as * its `0`/`1`. Operands of different kinds stay Top, as R would coerce them to a common type first. */ export declare function resolveAsComparison(args: BuiltInEvalHandlerArgs): Value; /** `decidedBy` is the lhs that fixes the result of the short-circuiting `&&`/`||` on its own; `&`/`|` vectorize, so they need both sides */ export declare const LogicalOps: { readonly '&&': { readonly apply: (a: boolean, b: boolean) => boolean; readonly decidedBy: false; }; readonly '||': { readonly apply: (a: boolean, b: boolean) => boolean; readonly decidedBy: true; }; readonly '&': { readonly apply: (a: boolean, b: boolean) => boolean; readonly decidedBy: undefined; }; readonly '|': { readonly apply: (a: boolean, b: boolean) => boolean; readonly decidedBy: undefined; }; }; /** * Resolves the unary `!` and the binary {@link LogicalOps} on scalar logicals to a {@link Value} logical. * `NA` and any operand that does not fold keep the result Top, unless the lhs alone already decides it. */ export declare function resolveAsLogical(args: BuiltInEvalHandlerArgs): Value; /** Resolves `(x)` to the {@link Value} of `x`, so that a parenthesized sub-expression folds like the expression itself. */ export declare function resolveAsGroup(args: BuiltInEvalHandlerArgs): Value;