Code-Inspect / flowr

A program slicer and dataflow analyzer for the R programming language.
https://github.com/Code-Inspect/flowr/wiki
GNU General Public License v3.0
14 stars 2 forks source link

Improve BuiltIn Memory Construction #712

Closed EagleoutIce closed 2 months ago

EagleoutIce commented 3 months ago

Currently we have a block like this:

export const BuiltInMemory = new Map<Identifier, IdentifierDefinition[]>([
    simpleBuiltInConstant('NULL', null),
    simpleBuiltInConstant('NA', null),
    simpleBuiltInConstant('TRUE', true), simpleBuiltInConstant('T', true),
    simpleBuiltInConstant('FALSE', false), simpleBuiltInConstant('F', false),
    // maybe map to a control flow function?
    simpleBuiltInConstant('break', 'break'), simpleBuiltInConstant('next', 'next'),
    ...builtInFunctions('~', '+', '-', '*', '/', '^', '!', '?', '**', '==', '!=', '>', '<', '>=', '<=', '%%', '%/%', '%*%', ':'),
    ...simpleBuiltInFunction(defaultBuiltInFunctionProcessor, { },'cat' /* returns null */),
    ...simpleBuiltInFunction(defaultBuiltInFunctionProcessor, { returnsNthArgument: 1 },'return', 'print', '('),
    ...simpleBuiltInFunction(defaultBuiltInFunctionProcessor, { returnsNthArgument: 'last' as const },'{'),
    ...simpleBuiltInFunction(processSourceCall, { }, 'source'),
    ...simpleBuiltInFunction(processAccess, { treatIndicesAsString: false },'[', '[['),
    ...simpleBuiltInFunction(processAccess, { treatIndicesAsString: true },'$', '@'),
    ...simpleBuiltInFunction(processIfThenElse, { },'if'),
    ...simpleBuiltInFunction(processAssignment, { },'<-', ':=', '=', 'assign', 'delayedAssign'),
    ...simpleBuiltInFunction(processAssignment, { superAssignment: true },'<<-'),
    ...simpleBuiltInFunction(processAssignment, { swapSourceAndTarget: true },'->'),
    ...simpleBuiltInFunction(processAssignment, { superAssignment: true , swapSourceAndTarget: true },'->>'),
    ...simpleBuiltInFunction(processSpecialBinOp, { lazy: true }, '&&', '||', '&', '|'),
    ...simpleBuiltInFunction(processPipe, { }, '|>'),
    ...simpleBuiltInFunction(processForLoop, { }, 'for'),
    ...simpleBuiltInFunction(processRepeatLoop, { }, 'repeat'),
    ...simpleBuiltInFunction(processWhileLoop, { }, 'while')
])

But i want a builder for this which allows a distributed configuration of the built-in environemnt!

EagleoutIce commented 1 month ago

This issue has been resolved in v2.0.0 (see Release v2.0.0 (Dataflow v2)).