@@ -28,6 +28,7 @@ import type { NoInfo, RNode } from '../r-bridge/lang-4.x/ast/model/model';
2828import type { RSymbol } from '../r-bridge/lang-4.x/ast/model/nodes/r-symbol' ;
2929import type { BuiltInProcessorMapper } from '../dataflow/environments/built-in' ;
3030import type { RExpressionList } from '../r-bridge/lang-4.x/ast/model/nodes/r-expression-list' ;
31+ import { EmptyArgument } from '../r-bridge/lang-4.x/ast/model/nodes/r-function-call' ;
3132
3233
3334export interface SemanticCfgGuidedVisitorConfiguration <
@@ -213,8 +214,25 @@ export class SemanticCfgGuidedVisitor<
213214 return this . onSourceCall ( { call } ) ;
214215 case 'builtin:access' :
215216 return this . onAccessCall ( { call } ) ;
216- case 'builtin:if-then-else' :
217- return this . onIfThenElseCall ( { call, condition : call . args [ 0 ] , then : call . args [ 1 ] , else : call . args [ 2 ] } ) ;
217+ case 'builtin:if-then-else' : {
218+ // recover dead arguments from ast
219+ const ast = this . getNormalizedAst ( call . id ) ;
220+ if ( ! ast || ast . type !== RType . IfThenElse ) {
221+ return this . onIfThenElseCall ( {
222+ call,
223+ condition : call . args [ 0 ] === EmptyArgument ? undefined : call . args [ 0 ] . nodeId ,
224+ then : call . args [ 1 ] === EmptyArgument ? undefined : call . args [ 1 ] . nodeId ,
225+ else : call . args [ 2 ] === EmptyArgument ? undefined : call . args [ 2 ] . nodeId
226+ } ) ;
227+ } else {
228+ return this . onIfThenElseCall ( {
229+ call,
230+ condition : ast . condition . info . id ,
231+ then : ast . then . info . id ,
232+ else : ast . otherwise ?. info . id
233+ } ) ;
234+ }
235+ }
218236 case 'builtin:get' :
219237 return this . onGetCall ( { call } ) ;
220238 case 'builtin:rm' :
@@ -440,7 +458,7 @@ export class SemanticCfgGuidedVisitor<
440458 *
441459 * @protected
442460 */
443- protected onIfThenElseCall ( _data : { call : DataflowGraphVertexFunctionCall , condition : FunctionArgument , then : FunctionArgument , else : FunctionArgument | undefined } ) {
461+ protected onIfThenElseCall ( _data : { call : DataflowGraphVertexFunctionCall , condition : NodeId | undefined , then : NodeId | undefined , else : NodeId | undefined } ) {
444462 }
445463
446464 /**
0 commit comments