/** Concatenates terms of sort Set to this builder */ public void concatenate(Term... terms) { for (Term term : terms) { if (!term.sort().equals(Sort.SET)) { throw KEMException.criticalError( "unexpected sort " + term.sort() + " of concatenated term " + term + "; expected " + Sort.SET); } if (term instanceof BuiltinSet) { BuiltinSet set = (BuiltinSet) term; elements.addAll(set.elements); patternsBuilder.addAll(set.collectionPatterns); functionsBuilder.addAll(set.collectionFunctions); variablesBuilder.addAll(set.collectionVariables); } else if (term instanceof KItem && ((KLabel) ((KItem) term).kLabel()).isPattern()) { patternsBuilder.add((KItem) term); } else if (term instanceof KItem && ((KLabel) ((KItem) term).kLabel()).isFunction()) { functionsBuilder.add(term); } else if (term instanceof Variable) { variablesBuilder.add((Variable) term); } else { throw KEMException.criticalError("unexpected concatenated term" + term); } } }
static void processErrno(String realMessage, IOException e) throws IOException { if (realMessage.equals("Permission denied")) { throw new IOException("EACCES"); } else if (realMessage.equals("Is a directory")) { throw new IOException("EISDIR"); } else if (realMessage.equals("Too many levels of symbolic links")) { throw new IOException("ELOOP"); } else if (realMessage.equals("File name too long")) { throw new IOException("ENAMETOOLONG"); } else if (realMessage.equals("No such file or directory")) { throw new IOException("ENOENT"); } else if (realMessage.equals("Not a directory")) { throw new IOException("ENOTDIR"); } else if (realMessage.equals("Negative seek offset")) { throw new IOException("EINVAL"); } else if (realMessage.equals("Invalid argument")) { throw new IOException("EINVAL"); } else if (realMessage.equals("Bad file descriptor")) { throw new IOException("EBADF"); } else if (realMessage.equals("Illegal seek")) { throw new IOException("ESPIPE"); } throw KEMException.criticalError( "Unrecognized OS errno. Please file an issue on the K framework issue tracker\n" + "explaining precisely what you were trying to do"); }
/** * Returns the cached instance rather than the de-serialized instance if there is a cached * instance. */ Object readResolve() throws ObjectStreamException { if (cache.containsKey(name) && cache.get(name).ordinal != this.ordinal) { KEMException.criticalError( "The ordinal for sort: " + name + " is " + cache.get(name).ordinal + " in the cache and " + this.ordinal + " serialized."); } // TODO: fix bug: ordinals from deserialized objects may overlap with those of newly created // objects return cache.computeIfAbsent(name, x -> this); }
private static int numOfMultiplicityCellLabels( ListMultimap<CellLabel, Cell> cells, Definition definition) { int count = 0; for (CellLabel cellLabel : cells.keySet()) { if (definition.cellMultiplicity(cellLabel) == ConfigurationInfo.Multiplicity.STAR) { count++; } else { if (cells.get(cellLabel).size() != 1) { throw KEMException.criticalError( "Cell label " + cellLabel + " does not have " + "multiplicity='*', but multiple cells found: " + cells.get(cellLabel) + "\nExamine the last rule applied to determine the source of the error."); } } } assert count <= 1 : "Multiple types of starred cells in one cell collection not supported at present"; return count; }