protected List < AVarDeclIR > replaceArgsWithVars ( SStmIR callStm ) { List < AVarDeclIR > decls = new LinkedList < AVarDeclIR > ( ) ; if ( Settings . dialect != Dialect . VDM_SL ) { return decls ; } List < SExpIR > args = null ; if ( callStm instanceof SCallStmIR ) { args = ( ( SCallStmIR ) callStm ) . getArgs ( ) ; } else if ( callStm instanceof ACallObjectExpStmIR ) { args = ( ( ACallObjectExpStmIR ) callStm ) . getArgs ( ) ; } else { log . error ( "Expected a call statement or call object statement. Got: " + callStm ) ; return decls ; } for ( SExpIR arg : args ) { String argName = getInfo ( ) . getTempVarNameGen ( ) . nextVarName ( traceTrans . getTracePrefixes ( ) . callStmArgNamePrefix ( ) ) ; STypeIR type = arg . getType ( ) ; AVarDeclIR argDecl = getTransAssist ( ) . consDecl ( argName , type . clone ( ) , arg . clone ( ) ) ; argDecl . setFinal ( true ) ; decls . add ( argDecl ) ; getTransAssist ( ) . replaceNodeWith ( arg , getInfo ( ) . getExpAssistant ( ) . consIdVar ( argName , type . clone ( ) ) ) ; } return decls ; }
Assumes dialect is VDM - SL . This method does not work with store lookups for local variables and since code generated VDM - SL traces do not rely on this then it is safe to use this method for this dialect .