UNPKG

@eagleoutice/flowr

Version:

Static Dataflow Analyzer and Program Slicer for the R Programming Language

51 lines 2.54 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.DfShapeQueryDefinition = void 0; const joi_1 = __importDefault(require("joi")); const slice_query_parser_1 = require("../../../cli/repl/parser/slice-query-parser"); const ansi_1 = require("../../../util/text/ansi"); const time_1 = require("../../../util/text/time"); const df_shape_query_executor_1 = require("./df-shape-query-executor"); const abstract_domain_1 = require("../../../abstract-interpretation/domains/abstract-domain"); function dfShapeQueryLineParser(_output, line, _config) { const criterion = (0, slice_query_parser_1.sliceCriterionParser)(line[0]); return { query: { type: 'df-shape', criterion: criterion }, rCode: criterion ? line[1] : line[0] }; } exports.DfShapeQueryDefinition = { executor: df_shape_query_executor_1.executeDfShapeQuery, asciiSummarizer: (formatter, _analyzer, queryResults, result) => { const out = queryResults; const domains = out.domains instanceof abstract_domain_1.AbstractDomain ? out.domains.value : out.domains; result.push(`Query: ${(0, ansi_1.bold)('df-shape', formatter)} (${(0, time_1.printAsMs)(out['.meta'].timing, 0)})`); result.push(...domains.entries().take(20).map(([key, domain]) => { return ` ╰ ${key}: ${domain?.toString()}`; })); if (domains.size > 20) { result.push(' ╰ ... (see JSON)'); } return true; }, jsonFormatter: (queryResults) => { const { domains, ...out } = queryResults; const state = domains instanceof abstract_domain_1.AbstractDomain ? domains.value : domains; const json = Object.fromEntries(state.entries().map(([key, domain]) => [key, domain?.toJson() ?? null])); const result = { domains: json, ...out }; return result; }, fromLine: dfShapeQueryLineParser, schema: joi_1.default.object({ type: joi_1.default.string().valid('df-shape').required().description('The type of the query.'), criterion: joi_1.default.string().optional().description('The slicing criterion of the node to get the dataframe shape for.') }).description('The df-shape query retrieves information on the shape of dataframes'), flattenInvolvedNodes: () => [] }; //# sourceMappingURL=df-shape-query-format.js.map