Почему не так:
function _toCode(data:PScData; toType:byte):PScData;
begin
Result := data;
case toType of
data_str:
if data.getType <> data_code then
Result := MakeData(data.toStr)
else
case data.getSubType of
data_int:
begin
Result := MakeData('int2str(', true);
Result.AddValue(data, true);
Result.AddValue(MakeData(')', true), true);
end;
data_real:
begin
Result := MakeData('str2double(', true);
Result.AddValue(data, true);
Result.AddValue(MakeData(')', true), true);
end;
end;
...