public CPUResource getCPUResource() { if (resource instanceof CPUResource) { return (CPUResource) resource; } else { throw new InternalException(66, "Thread is not running on a CPU"); } }
@Override public String toString() { Formatter f = new Formatter(); f.format("Internal %04d: %s", number, getMessage()); String tmp = f.out().toString(); f.close(); return tmp; } }
println(e.toString()); } catch (Throwable e)
public void setTypeQualifier(List<PType> types) { if (hashcode != 0) { if (typeQualifier == null && types != null || typeQualifier != null && !typeQualifier.equals(types)) { throw new InternalException(2, "Cannot change type qualifier: " + this + " to " + types); } } typeQualifier = types; }
@Override public Object clone() { try { return new NaturalOneValue(longVal); } catch (Exception e) { throw new InternalException(5, "Illegal clone"); } } }
@Override public Object clone() { try { return new IntegerValue(longVal); } catch (Exception e) { throw new InternalException(5, "Illegal clone"); } } }
@Override public Object clone() { try { return new NaturalValue(longVal); } catch (Exception e) { throw new InternalException(5, "Illegal clone"); } } }
public Object newInstance() { try { return delegateClass.newInstance(); } catch (NullPointerException e) { throw new InternalException(63, "No delegate class found: " + name); } catch (InstantiationException e) { throw new InternalException(54, "Cannot instantiate native object: " + e.getMessage()); } catch (IllegalAccessException e) { throw new InternalException(55, "Cannot access native object: " + e.getMessage()); } }
protected void errorResponse(DBGPErrorCode errorCode, String reason) { try { StringBuilder sb = new StringBuilder(); sb.append("<error code=\""); sb.append(errorCode.value); sb.append("\" apperr=\"\"><message>"); sb.append(quote(reason)); sb.append("</message></error>"); response(null, sb); } catch (SocketException e) { // Do not report these since the socket connection is down. } catch (IOException e) { throw new InternalException(29, "DBGP: " + reason); } }
/** * Report a warning. Unlike errors, this does no token recovery. */ protected void warning(int no, String msg, ILexLocation location) { VDMWarning vdmwarning = new VDMWarning(no, msg, location); warnings.add(vdmwarning); if (warnings.size() >= MAX - 1) { errors.add(new VDMError(9, "Too many warnings", location)); throw new InternalException(9, "Too many warnings"); } }
private Method getJavaDelegateMethod(String mname, List<Class<?>> ptypes) { Method m; try { Class<?>[] array = new Class<?>[0]; m = delegateClass.getMethod(mname, ptypes.toArray(array)); if (!m.getReturnType().equals(Value.class)) { throw new InternalException(58, "Native method does not return Value: " + m); } } catch (SecurityException e) { throw new InternalException(60, "Cannot access native method: " + e.getMessage()); } catch (NoSuchMethodException e) { throw new InternalException(61, "Cannot find native method: " + e.getMessage()); } return m; }
public static void report(int number, String problem, ILexLocation location) { if (suppress) return; VDMError error = new VDMError(number, problem, location); // System.out.println(error.toString()); errors.add(error); lastMessage = error; for (IStatusListener listner : listners) { listner.report(error); } if (errors.size() >= MAX - 1) { errors.add(new VDMError(10, "Too many type checking errors", location)); throw new InternalException(10, "Too many type checking errors"); } }
/** * Create an object to read the file name passed with the given charset. * * @param file * The filename to open * @param charset */ public BacktrackInputReader(File file, String charset) { try { InputStreamReader isr = readerFactory(file, charset); char[] buffer = new char[readerLength(file, isr)]; max = isr.read(buffer); data = Arrays.copyOf(buffer, max); pos = 0; isr.close(); } catch (IOException e) { throw new InternalException(0, e.getMessage()); } }
throw new InternalException(9, "Too many syntax errors");
throw new InternalException(65, "Illegal Lock state");
public static ADefPatternBind newADefPatternBind(ILexLocation location, Object patternOrBind) { ADefPatternBind result = new ADefPatternBind(); result.setLocation(location); if (patternOrBind instanceof PPattern) { result.setPattern((PPattern) patternOrBind); result.setBind(null); } else if (patternOrBind instanceof PBind) { result.setPattern(null); result.setBind((PBind) patternOrBind); } else { throw new InternalException(3, "PatternBind passed " + patternOrBind.getClass().getName()); } return result; }
@Override public ExitStatus typeCheck() { try { classes.add(AstFactoryTC.newACpuClassDefinition(assistantFactory)); classes.add(AstFactoryTC.newABusClassDefinition(assistantFactory)); } catch (Exception e) { throw new InternalException(11, "CPU or BUS creation failure"); } return super.typeCheck(); } }
} catch (Exception e) throw new InternalException(5, "Illegal clone: " + e);
throw new InternalException(64, "Native method should be static: " + m.getName()); } catch (IllegalArgumentException e) throw new InternalException(62, "Cannot invoke native method: " + e.getMessage()); } catch (IllegalAccessException e) throw new InternalException(62, "Cannot invoke native method: " + e.getMessage()); } catch (InvocationTargetException e) strOut.append(e.getTargetException().getMessage()+"\n"); e.getTargetException().printStackTrace(new PrintWriter(strOut)); throw new InternalException(59, "Failed in native method: " + strOut);
/** * This first prints out the current breakpoint source location before calling the superclass' run method. The * synchronization prevents more than one debugging session on the console. * * @return the exit status */ public ExitStatus run() { synchronized (DebuggerReader.class) // Only one console! { println("Stopped " + breakpoint); println(interpreter.getSourceLine(breakpoint.location)); try { interpreter.setDefaultName(breakpoint.location.getModule()); } catch (Exception e) { throw new InternalException(52, "Cannot set default name at breakpoint"); } ExitStatus status = super.run(new Vector<File>()); return status; } }