package com.microchip.mplab.ipelib.device; import com.microchip.crownking.Pair; import com.microchip.mplab.crownkingx.xMemoryPartition; import com.microchip.mplab.crownkingx.xPIC; import com.microchip.mplab.ipelib.common.SharedData; import com.microchip.mplab.mdbcore.OptSupport.RuntimeProperties; import java.util.ArrayList; import java.util.Arrays; public class InstRamStringValidator extends PgmRangeStringValidator { @Override public boolean isValid(String arg0) { boolean RetVal = false; if (arg0.isEmpty()) { return false; } else { try { RuntimeProperties rtp = new RuntimeProperties(SharedData.getSingletonObject().getAssemblySession()); xPIC pic = rtp.getPic(); long Boundary = rtp.getProgramChunkSize(); ArrayList> Ranges = new ArrayList<>(); xMemoryPartition XMP = pic.getMainPartition(); String RangeString = arg0.replace(" ", ""); RangeString = RangeString.replace("0x", ""); String[] AddrGroup = RangeString.split(","); ArrayList AddrStrings = new ArrayList<>(); AddrStrings.addAll(Arrays.asList(AddrGroup)); ArrayList StringsToRemove = new ArrayList<>(); if (AddrStrings.isEmpty()) { throw new Exception(); } try { if (XMP != null) { Ranges.clear(); Pair Range = XMP.getInstRange(); Ranges.add(new Pair(Range.first, Range.second)); for (Pair R : Ranges) { StringsToRemove.clear(); long Start = (Long)R.first; long End = (Long)R.second - 1L; if ((Long)Range.second != 0L) { for (String S : AddrStrings) { try { this.CheckRangesFromRangeString(S, Start, End, Boundary); StringsToRemove.add(S); } catch (Exception var23) { } } for (String Str : StringsToRemove) { AddrStrings.remove(Str); } } } } } catch (Exception var24) { } if (AddrStrings.isEmpty()) { RetVal = true; } } catch (Exception var25) { } return RetVal; } } }