/**
   * Emits a type cast for passing an argument to a parameterized type.
   *
   * @param type compound type with parameters
   * @param expr argument expression in type instantiation
   * @param paramIndex index of argument in argument list
   */
  private static boolean emitTypeCast(
      StringBuilder buffer, CompoundType type, Expression expr, int paramIndex) {
    boolean cast = false;
    Parameter param = type.getParameterAt(paramIndex);
    TypeInterface paramType = TypeReference.getBaseType(param.getType());

    if (paramType instanceof StdIntegerType) {
      StdIntegerType intType = (StdIntegerType) paramType;
      switch (intType.getType()) {
        case DataScriptParserTokenTypes.INT8:
          buffer.append("(byte)(");
          cast = true;
          break;

        case DataScriptParserTokenTypes.UINT8:
        case DataScriptParserTokenTypes.INT16:
          buffer.append("(short)(");
          cast = true;
          break;
        default:
          // nothing
      }
    }
    return cast;
  }
 public long getMinVal() {
   if (type instanceof SignedBitFieldType) {
     BitFieldType bitField = (BitFieldType) type;
     return -(1 << bitField.getLength() - 1);
   }
   if (type instanceof BitFieldType) {
     return 0;
   }
   if (type instanceof StdIntegerType) {
     StdIntegerType integerType = (StdIntegerType) type;
     return integerType.getLowerBound().longValue();
   }
   throw new RuntimeException("type of field '" + param.getName() + "' is not a simple type");
 }