UNPKG

@eagleoutice/flowr

Version:

Static Dataflow Analyzer and Program Slicer for the R Programming Language

69 lines 2.59 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DataFrameDomain = void 0; const positive_interval_domain_1 = require("../domains/positive-interval-domain"); const product_domain_1 = require("../domains/product-domain"); const set_range_domain_1 = require("../domains/set-range-domain"); /** * The data frame abstract domain as product domain of a column names domain, column count domain, and row count domain. */ class DataFrameDomain extends product_domain_1.ProductDomain { create(value) { return new DataFrameDomain(value); } /** * The current abstract value of the column names domain. */ get colnames() { return this.value.colnames; } /** * The current abstract value of the column count domain. */ get cols() { return this.value.cols; } /** * The current abstract value of the row count domain. */ get rows() { return this.value.rows; } static bottom(maxColNames) { return new DataFrameDomain({ colnames: set_range_domain_1.SetRangeDomain.bottom(maxColNames), cols: positive_interval_domain_1.PosIntervalDomain.bottom(), rows: positive_interval_domain_1.PosIntervalDomain.bottom() }); } static top(maxColNames) { return new DataFrameDomain({ colnames: set_range_domain_1.SetRangeDomain.top(maxColNames), cols: positive_interval_domain_1.PosIntervalDomain.top(), rows: positive_interval_domain_1.PosIntervalDomain.top() }); } reduce(value) { if (value.colnames.isValue() && value.cols.isValue()) { if (value.colnames.value.min.size >= value.cols.value[1]) { value = { ...value, colnames: value.colnames.meet({ min: new Set(), range: value.colnames.value.min }) }; } } if (value.colnames.isValue() && value.cols.isValue()) { const minColNames = value.colnames.value.min.size; const maxColNames = value.colnames.isFinite() ? value.colnames.value.min.size + value.colnames.value.range.size : Infinity; if (minColNames > value.cols.value[0] || maxColNames < value.cols.value[1]) { value = { ...value, cols: value.cols.meet([minColNames, maxColNames]) }; } } return value; } } exports.DataFrameDomain = DataFrameDomain; //# sourceMappingURL=dataframe-domain.js.map