private void checkSpecialValues(double value) throws AstException { if (Double.isNaN(value)) throw new AstException(this, "NaN cannot be expressed as a floating point literal"); if (Double.isInfinite(value)) throw new AstException(this, "Infinity cannot be expressed as a floating point literal"); if ((Double.doubleToRawLongBits(value) & 0x8000000000000000L) != 0) throw new AstException(this, "Floating Point literals cannot be negative; wrap a literal in a UnaryExpression to accomplish this"); }
@Override public String toString() { if (problemNode == null && getMessage() == null) return "AstException (unknown cause)"; if (problemNode == null) return "AstException: " + getMessage(); String nodeDescription = problemNode == null ? "(null)" : (problemNode.getClass().getName() + "(toString failed)"); try { nodeDescription = problemNode.toString(); } catch (Throwable ignore) { //throwing exceptions in toString() is bad. } if (getMessage() == null) return "AstException at " + nodeDescription; return String.format("AstException: %s (at %s)", getMessage(), nodeDescription); } }
private void checkSpecialValues(double value) throws AstException { if (Double.isNaN(value)) throw new AstException(this, "NaN cannot be expressed as a floating point literal"); if (Double.isInfinite(value)) throw new AstException(this, "Infinity cannot be expressed as a floating point literal"); if ((Double.doubleToRawLongBits(value) & 0x8000000000000000L) != 0) throw new AstException(this, "Floating Point literals cannot be negative; wrap a literal in a UnaryExpression to accomplish this"); }
@Override public String toString() { if (problemNode == null && getMessage() == null) return "AstException (unknown cause)"; if (problemNode == null) return "AstException: " + getMessage(); String nodeDescription = problemNode == null ? "(null)" : (problemNode.getClass().getName() + "(toString failed)"); try { nodeDescription = problemNode.toString(); } catch (Throwable ignore) { //throwing exceptions in toString() is bad. } if (getMessage() == null) return "AstException at " + nodeDescription; return String.format("AstException: %s (at %s)", getMessage(), nodeDescription); } }
private void checkSpecialValues(double value) throws AstException { if (Double.isNaN(value)) throw new AstException(this, "NaN cannot be expressed as a floating point literal"); if (Double.isInfinite(value)) throw new AstException(this, "Infinity cannot be expressed as a floating point literal"); if ((Double.doubleToRawLongBits(value) & 0x8000000000000000L) != 0) throw new AstException(this, "Floating Point literals cannot be negative; wrap a literal in a UnaryExpression to accomplish this"); }
@Override public String toString() { if (problemNode == null && getMessage() == null) return "AstException (unknown cause)"; if (problemNode == null) return "AstException: " + getMessage(); String nodeDescription = problemNode == null ? "(null)" : (problemNode.getClass().getName() + "(toString failed)"); try { nodeDescription = problemNode.toString(); } catch (Throwable ignore) { //throwing exceptions in toString() is bad. } if (getMessage() == null) return "AstException at " + nodeDescription; return String.format("AstException: %s (at %s)", getMessage(), nodeDescription); } }
private static <N extends Node> N process(Source s, String name, Class<N> type) { if (!s.getProblems().isEmpty()) { throw new AstException(null, "Can't parse snippet: " + s.getProblems().get(0).getMessage()); } if (s.getNodes().isEmpty()) return null; if (s.getNodes().size() > 1) throw new AstException(null, "Can't parse snippet: more than one " + name + " in snippet"); Node n = s.getNodes().get(0); if (type.isInstance(n)) return type.cast(n); throw new AstException(null, "Can't parse snippet: Not a " + name); }
private static <N extends Node> N process(Source s, String name, Class<N> type) { if (!s.getProblems().isEmpty()) { throw new AstException(null, "Can't parse snippet: " + s.getProblems().get(0).getMessage()); } if (s.getNodes().isEmpty()) return null; if (s.getNodes().size() > 1) throw new AstException(null, "Can't parse snippet: more than one " + name + " in snippet"); Node n = s.getNodes().get(0); if (type.isInstance(n)) return type.cast(n); throw new AstException(null, "Can't parse snippet: Not a " + name); }
private static <N extends Node> N process(Source s, String name, Class<N> type) { if (!s.getProblems().isEmpty()) { throw new AstException(null, "Can't parse snippet: " + s.getProblems().get(0).getMessage()); } if (s.getNodes().isEmpty()) return null; if (s.getNodes().size() > 1) throw new AstException(null, "Can't parse snippet: more than one " + name + " in snippet"); Node n = s.getNodes().get(0); if (type.isInstance(n)) return type.cast(n); throw new AstException(null, "Can't parse snippet: Not a " + name); }
@CopyMethod static TypeReference getEffectiveTypeReference(VariableDefinitionEntry self) { VariableDefinition parent = self.upToVariableDefinition(); if (parent == null) throw new AstException( self, "Cannot calculate type reference of a VariableDefinitionEntry without a VariableDefinition as parent"); TypeReference typeRef = parent.astTypeReference().copy(); return typeRef.astArrayDimensions(typeRef.astArrayDimensions() + self.astArrayDimensions() + (parent.astVarargs() ? 1 : 0)); }
@CopyMethod static TypeReference getEffectiveTypeReference(VariableDefinitionEntry self) { VariableDefinition parent = self.upToVariableDefinition(); if (parent == null) throw new AstException( self, "Cannot calculate type reference of a VariableDefinitionEntry without a VariableDefinition as parent"); TypeReference typeRef = parent.astTypeReference().copy(); return typeRef.astArrayDimensions(typeRef.astArrayDimensions() + self.astArrayDimensions() + (parent.astVarargs() ? 1 : 0)); }
@CopyMethod static TypeReference getEffectiveTypeReference(VariableDefinitionEntry self) { VariableDefinition parent = self.upToVariableDefinition(); if (parent == null) throw new AstException( self, "Cannot calculate type reference of a VariableDefinitionEntry without a VariableDefinition as parent"); TypeReference typeRef = parent.astTypeReference().copy(); return typeRef.astArrayDimensions(typeRef.astArrayDimensions() + self.astArrayDimensions() + (parent.astVarargs() ? 1 : 0)); }