import { isFunction , isVariable , isCall , isConditional , isBinary } from 'src/lib/expressionTypeGuards' ; import { CallExpression , ExecutableCallRegular , ExecutableStepCallRegular , Expression , FunctionExpression , NonExecutableStepCall , StepChild , StepFunction , StepVariable , VariableExpression , VariableWithState , ConditionalExpression , BinaryExpression , StepBinary , StepConditional } from 'src/types/ExpressionTypes' ; function toCrossed ( e , isCallArg ) ; function toCrossed ( e , isCallArg ) ; function toCrossed ( e , isCallArg ) ; function toCrossed ( e , isCallArg ) ; function toCrossed ( e , isCallArg ) ; function toCrossed ( e , isCallArg ) ; function toCrossed ( e , isCallArg ) ; function toCrossed ( e , isCallArg ) { if ( isVariable ( e ) ) { if ( isCallArg ) { return { ... e , highlightType : 'removed' , topLeftBadgeType : 'none' , bottomRightBadgeType : 'callArg' } ; } else { return { ... e , highlightType : 'active' , topLeftBadgeType : 'none' , bottomRightBadgeType : 'none' } ; } } else if ( isFunction ( e ) ) { return { ... e , arg : toCrossed ( e . arg , isCallArg ) , body : toCrossed ( e . body , isCallArg ) } ; } else if ( isCall ( e ) ) { return { ... e , state : 'default' , arg : toCrossed ( e . arg , isCallArg ) , func : toCrossed ( e . func , isCallArg ) } ; } else if ( isConditional ( e ) ) { return { ... e , state : 'default' , condition : toCrossed ( e . condition , isCallArg ) , trueCase : toCrossed ( e . trueCase , isCallArg ) , falseCase : toCrossed ( e . falseCase , isCallArg ) } ; } else if ( isBinary ( e ) ) { return { ... e , state : 'default' , first : toCrossed ( e . first , isCallArg ) , second : toCrossed ( e . second , isCallArg ) } ; } else { throw new Error ( ) ; } } const removeFuncArg = ( e ) : VariableWithState < 'removedFuncArg' > => ( { ... e , highlightType : 'removed' , topLeftBadgeType : 'none' , bottomRightBadgeType : 'funcArg' } ) ; const stepToBetaReducePreviewCrossed = ( e ) : ExecutableStepCallRegular < 'betaReducePreviewCrossed' > => ( { ... e , state : 'betaReducePreviewCrossed' , arg : toCrossed ( e . arg , true ) , func : { ... e . func , arg : removeFuncArg ( e . func . arg ) , body : toCrossed ( e . func . body , false ) } } ) ; export default stepToBetaReducePreviewCrossed ;