← all packages

jsonlite

native: 124 functions analysed · 91 typed · 8 untypeable · 7 timed out · 21 entry points (11 typed) · R: 94 definitions, 26 typed strict, 71 gradual, prelude debt 34 · fuzzing: 29 definitions, 0 unsound, 10 accept calls outside their domain · tyr dc7f1a7 · Rsem 7bcb45f · NativeSem 770a1eb · rstt 2b2696f unpinned

Native functions

C functions reachable from an entry point
124 / 124 (100.0%)
typed
91 / 124 (73.4%)
18 more bound at their declared C signature after inference failed.

Native → R

entry points
21 / 21 (100.0%)
defined in src/
21 / 21 (100.0%)
typed
11 / 21 (52.4%)
bound in R
11 / 21 (52.4%)

R definitions

named top-level definitions
94 / 94 (100.0%)
not blocked by an unbound native symbol
85 / 94 (90.4%)
9 definitions report unbound variable on a native symbol tyr could not bind — the native panel’s loss, arriving here.
typed, gradual
71 / 94 (75.5%)
typed, strict
26 / 94 (27.7%)
34 of the strict failures are a name missing from the prelude.
side
mode
248 / 248

Native functions 124

append_text typed

([*(c_string | c_null), c_string, c_int_na] -> ())&([c_null, c_string, c_int_na] -> empty)
timing: 0.847 s
source
static void append_text(char **cur, const char* val, int n){
  if(n < 0)
    n = strlen(val);
  memcpy(*cur, val, n);
  *cur += n;
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/collapse_pretty.c:12

append_whitespace typed empty return

[c_null, c_int_na, c_char] -> empty
timing: 0.015 s
source
static void append_whitespace(char** cur, size_t n, char indent_char){
  memset(*cur, indent_char, n);
  *cur += n;
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/collapse_pretty.c:6

array_add_value typed

([*struct context_s \ c_null, c_null, *struct yajl_val_s \ c_null] | [*struct context_s \ c_null, c_null, c_null] | [c_null, c_null, *struct yajl_val_s \ c_null] | [c_null, c_null, c_null] -> empty)&([*struct context_s, *struct yajl_val_s, *struct yajl_val_s] & ~[*struct context_s \ c_null, c_null, *struct yajl_val_s \ c_null] & ~[*struct context_s \ c_null, c_null, c_null] & ~[c_null, c_null, *struct yajl_val_s \ c_null] & ~[c_null, c_null, c_null] -> c_int_na)
timing: 0.371 s
source
static int array_add_value (context_t *ctx,
                            yajl_val array, yajl_val value)
{
    yajl_val *tmp;

    /* We're checking for NULL pointers in "context_add_value" or its
     * callers. */
    assert (ctx != NULL);
    assert (array != NULL);
    assert (value != NULL);

    /* "context_add_value" will only call us with array values. */
    assert(YAJL_IS_ARRAY(array));

    tmp = realloc(array->u.array.values,
                  sizeof(*(array->u.array.values)) * (array->u.array.len + 1));
    if (tmp == NULL)
        RETURN_ERROR(ctx, ENOMEM, "Out of memory");
    array->u.array.values = tmp;
    array->u.array.values[array->u.array.len] = value;
    array->u.array.len++;

    return 0;
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl_tree.c:191

C_collapse_array typed entry .Call fuzz ok

([CHR] -> ^CHR1)&([(~CHR)<...> | null | p(CHR) | sym] -> empty)
timing: 0.991 s
fuzzing: 8 inside (8 ok) · 4 outside (4 rejected)
type drawn from: ((x1: CHR) -> ^CHR1) & ((x1: p(CHR) | (~CHR)<...> | sym | null) -> empty)
source
SEXP C_collapse_array(SEXP x) {
  if (!isString(x))
    error("x must be a character vector.");

  int len = length(x);
  size_t nchar_total = 0;

  for (int i=0; i<len; i++) {
    nchar_total += strlen(translateCharUTF8(STRING_ELT(x, i)));
  }

  char *s = malloc(nchar_total+len+3); //if len is 0, we need at least: '[]\0'
  char *olds = s;
  size_t size;

  for (int i=0; i<len; i++) {
    s[0] = ',';
    size = strlen(translateCharUTF8(STRING_ELT(x, i)));
    memcpy(++s, translateCharUTF8(STRING_ELT(x, i)), size);
    s += size;
  }
  if(olds == s) s++;
  olds[0] = '[';
  s[0] = ']';
  s[1] = '\0';

  //get character encoding from first element
  SEXP out = PROTECT(allocVector(STRSXP, 1));
  SET_STRING_ELT(out, 0, mkCharCE(olds,  CE_UTF8));
  UNPROTECT(1);
  free(olds);
  return out;
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/collapse_array.c:5

C_collapse_array_pretty_inner typed entry .Call fuzz ok

([CHR] -> CHR1)&([(~CHR)<...> | null | p(CHR) | sym] -> empty)
timing: 0.597 s
fuzzing: 6 inside (6 ok) · 7 outside (7 rejected)
type drawn from: ((x1: CHR) -> CHR1) & ((x1: p(CHR) | (~CHR)<...> | sym | null) -> empty)
source
SEXP C_collapse_array_pretty_inner(SEXP x) {
  if (!isString(x))
    error("x must character vector.");

  //calculate required space
  size_t len = Rf_length(x);
  size_t nchar_total = 0;
  for (int i=0; i<len; i++) {
    nchar_total += strlen(translateCharUTF8(STRING_ELT(x, i)));
  }

  // n-1 ", " separators
  if(len){
    nchar_total += (len-1)*2;
  }

  //outer parentheses plus terminator
  nchar_total += 3;

  //allocate memory and create a cursor
  char *str = malloc(nchar_total);
  char *cursor = str;
  char **cur = &cursor;

  //init object
  append_text(cur, "[", 1);

  //copy everything
  for (int i=0; i<len; i++) {
    append_text(cur, translateCharUTF8(STRING_ELT(x, i)), -1);
    append_text(cur, ", ", 2);
  }

  //remove trailing ", "
  if(len) {
    cursor -= 2;
  }

  //finish up
  append_text(cur, "]\0", 2);

  //encode as UTF8 string
  SEXP out = PROTECT(allocVector(STRSXP, 1));
  SET_STRING_ELT(out, 0, mkCharCE(str,  CE_UTF8));
  UNPROTECT(1);
  free(str);
  return out;
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/collapse_pretty.c:86

C_collapse_array_pretty_outer typed entry .Call empty return

[(~CHR)<...> | null | p(CHR) | sym, any_sexp] -> empty
timing: 3.98 s
source
SEXP C_collapse_array_pretty_outer(SEXP x, SEXP indent) {
  if (!isString(x))
    error("x must character vector.");

  int len = length(x);
  int ni = asInteger(indent);
  int spaces = asInteger(Rf_getAttrib(indent, Rf_install("indent_spaces")));
  if(ni == NA_INTEGER)
    error("indent must not be NA");
  if(spaces == NA_INTEGER)
    error("spaces must not be NA");
  char indent_char = ' ';
  if(spaces < 0){
    spaces = -1 * spaces;
    indent_char = '\t';
  }

  //calculate required space
  size_t nchar_total = 0;
  for (int i=0; i<len; i++) {
    nchar_total += strlen(translateCharUTF8(STRING_ELT(x, i)));
  }

  //for indent plus ",\n"
  nchar_total += len * (ni + spaces + 2);

  //outer parentheses plus final indent and linebreak and terminator
  nchar_total += ni + 4;

  //allocate memory and create a cursor
  char *str = malloc(nchar_total);
  char *cursor = str;
  char **cur = &cursor;

  //init object
  append_text(cur, "[", 1);
  const char *start = *cur;

  //copy everything
  for (int i=0; i<len; i++) {
    append_text(cur, "\n", 1);
    append_whitespace(cur, ni + spaces, indent_char);
    append_text(cur, translateCharUTF8(STRING_ELT(x, i)), -1);
    append_text(cur, ",", 1);
  }

  //remove trailing ", "
  if(cursor != start){
    cursor[-1] = '\n';
    append_whitespace(cur, ni, indent_char);
  }

  //finish up
  append_text(cur, "]\0", 2);

  //encode as UTF8 string
  SEXP out = PROTECT(allocVector(STRSXP, 1));
  SET_STRING_ELT(out, 0, mkCharCE(str,  CE_UTF8));
  UNPROTECT(1);
  free(str);
  return out;
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/collapse_pretty.c:135

C_collapse_object typed entry .Call fuzz ok

([CHR, CHR] -> ^CHR1)&([CHR, (~CHR)<...> | null | p(CHR) | sym] | [(~CHR)<...> | null | p(CHR) | sym, any_sexp] -> empty)
timing: 4.65 s
fuzzing: 8 inside (4 ok, 4 error pkg) · 7 outside (7 rejected)
type drawn from: ((x1: CHR, x2: CHR) -> ^CHR1) & ((x1: CHR, x2: p(CHR) | (~CHR)<...> | sym | null) | (x1: p(CHR) | (~CHR)<...> | sym | null, x2: any_sexp) -> empty)

Other calls inside the domain

callverdicterror
C_collapse_object(character(0), "é")error_pkg::C_collapse_object: x and y must same length.
C_collapse_object(c("x y", NA_character_), "")error_pkg::C_collapse_object: x and y must same length.
C_collapse_object(c("a", "a", NA_character_, "é", "NA"), c("", "NA"))error_pkg::C_collapse_object: x and y must same length.
C_collapse_object(c("", "a", "NA", "é", ""), "x y")error_pkg::C_collapse_object: x and y must same length.
source
SEXP C_collapse_object(SEXP x, SEXP y) {
  if (!isString(x) || !isString(y))
    error("x and y must character vectors.");

  int len = length(x);
  if (len != length(y))
    error("x and y must same length.");

  size_t nchar_total = 0;

  for (int i=0; i<len; i++) {
    if(STRING_ELT(y, i) == NA_STRING) continue;
    nchar_total += strlen(translateCharUTF8(STRING_ELT(x, i)));
    nchar_total += strlen(translateCharUTF8(STRING_ELT(y, i)));
    nchar_total += 2;
  }

  char *s = malloc(nchar_total + 3); //if len is 0, we need at least: '{}\0'
  char *olds = s;
  size_t size;

  for (int i=0; i<len; i++) {
    if(STRING_ELT(y, i) == NA_STRING) continue;
    s[0] = ',';
    //add x
    size = strlen(translateCharUTF8(STRING_ELT(x, i)));
    memcpy(++s, translateCharUTF8(STRING_ELT(x, i)), size);
    s += size;

    //add :
    s[0] = ':';

    //add y
    size = strlen(translateCharUTF8(STRING_ELT(y, i)));
    memcpy(++s, translateCharUTF8(STRING_ELT(y, i)), size);
    s += size;
  }
  if(olds == s) s++;
  olds[0] = '{';
  s[0] = '}';
  s[1] = '\0';

  //get character encoding from first element
  SEXP out = PROTECT(allocVector(STRSXP, 1));
  SET_STRING_ELT(out, 0, mkCharCE(olds,  CE_UTF8));
  UNPROTECT(1);
  free(olds);
  return out;
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/collapse_object.c:5

C_escape_chars typed entry .Call empty return

[(~CHR)<...> | null | p(CHR) | sym] -> empty
timing: 0.572 s
source
SEXP C_escape_chars(SEXP x) {
  if (!isString(x))
    error("x must be a character vector.");
  if (x == R_NilValue || length(x) == 0)
    return x;

  int len = length(x);
  SEXP out = PROTECT(allocVector(STRSXP, len));

  for (int i=0; i<len; i++) {
    SET_STRING_ELT(out, i, C_escape_chars_one(STRING_ELT(x, i)));
  }
  UNPROTECT(1);
  return out;
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/escape_chars.c:110

C_is_datelist typed entry .Call accepts outside

[(env | externalptr | lang | vec | arrow) | null | p(CHR) | sym] -> ff
timing: 0.313 s
fuzzing: 4 inside (4 ok) · 6 outside (2 rejected, 4 accepted)
type drawn from: (x1: p(CHR) | (env | externalptr | lang | vec | arrow) | sym | null) -> ff

Accepted outside the domain x1: 4

parameterchangecallreturned
x1wrapC_is_datelist(list(new.env()))ff<> with { }
x1wrapC_is_datelist(list(as.name("x")))ff<> with { }
x1wrapC_is_datelist(list(NULL))ff<> with { }
x1wrapC_is_datelist(list(FALSE))ff<> with { }
source
SEXP C_is_datelist(SEXP x) {
  size_t len = Rf_length(x);
  if(!Rf_isVectorList(x) || len == 0)
    return ScalarLogical(FALSE);

  // Need
  int status = FALSE;
  for (size_t i = 0; i < len; i++) {
    SEXP el = VECTOR_ELT(x, i);
    if(Rf_isNull(el))
      continue;
    if(Rf_isString(el) && Rf_length(el) > 0 && !strcmp(CHAR(STRING_ELT(el, 0)), "NA"))
      continue;
    if(Rf_isNumeric(el) && Rf_inherits(el, "POSIXct")){
      status = TRUE; //at least one date
    } else {
      return ScalarLogical(FALSE); // quit immediately
    }
  }

  return ScalarLogical(status);
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/is_datelist.c:5

C_is_recordlist typed entry .Call fuzz ok

([(~(list & ~{ any_sexp }))<...> | null | p(CHR) | sym] -> ^LGL1)&([(~(list & ~{ p(CHR) | (~list)<...> | sym | null }))<...> | null | p(CHR) | sym] -> ff)
timing: 0.050 s
fuzzing: 5 inside (5 ok) · 6 outside (6 rejected)
type drawn from: ((x1: p(CHR) | (~(list & ~{ any_sexp }))<...> | sym | null) -> ^LGL1) & ((x1: p(CHR) | (~(list & ~{ p(CHR) | (~list)<...> | sym | null }))<...> | sym | null) -> ff)
source
SEXP C_is_recordlist(SEXP x){
  return ScalarLogical(is_recordlist(x));
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/is_recordlist.c:43

C_is_scalarlist typed entry .Call fuzz ok

([{ }] -> tt)&([{ any_sexp }] | [(~list)<...> | null | p(CHR) | sym] -> ^LGL1)
timing: 0.909 s
fuzzing: 5 inside (5 ok) · 6 outside (6 rejected)
type drawn from: ((x1: { }) -> tt) & ((x1: { any_sexp }) | (x1: p(CHR) | (~list)<...> | sym | null) -> ^LGL1)
source
SEXP C_is_scalarlist(SEXP x) {

  bool is_scalarlist = true;
  if (TYPEOF(x) != VECSXP){
    is_scalarlist = false;
  } else {
    SEXP el;
    int len = length(x);
    for (int i=0; i<len; i++) {
      el = VECTOR_ELT(x, i);
      switch(TYPEOF(el)) {
        case LGLSXP:
        case INTSXP:
        case REALSXP:
        case STRSXP:
        case NILSXP:
        case RAWSXP: //not used but for compatibility with is.atomic
        case CPLXSXP: //not used but for compatibility with is.atomic
          if(length(el) < 2) continue;
          //else fall through
        default:
          is_scalarlist = false;
          break;
      }
    }
  }

  //get character encoding from first element
  return ScalarLogical(is_scalarlist);
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/is_scalarlist.c:6

context_add_value typed

([c_null, *struct yajl_val_s \ c_null] | [c_null, c_null] -> empty)&([*struct context_s, *struct yajl_val_s] & ~[c_null, *struct yajl_val_s \ c_null] & ~[c_null, c_null] -> c_int_na)
timing: 2.43 s
source
static int context_add_value (context_t *ctx, yajl_val v)
{
    /* We're checking for NULL values in all the calling functions. */
    assert (ctx != NULL);
    assert (v != NULL);

    /*
     * There are three valid states in which this function may be called:
     *   - There is no value on the stack => This is the only value. This is the
     *     last step done when parsing a document. We assign the value to the
     *     "root" member and return.
     *   - The value on the stack is an object. In this case store the key on the
     *     stack or, if the key has already been read, add key and value to the
     *     object.
     *   - The value on the stack is an array. In this case simply add the value
     *     and return.
     */
    if (ctx->stack == NULL)
    {
        assert (ctx->root == NULL);
        ctx->root = v;
        return (0);
    }
    else if (YAJL_IS_OBJECT (ctx->stack->value))
    {
        if (ctx->stack->key == NULL)
        {
            if (!YAJL_IS_STRING (v))
                RETURN_ERROR (ctx, EINVAL, "context_add_value: "
                              "Object key is not a string (%#04x)",
                              v->type);

            ctx->stack->key = v->u.string;
            v->u.string = NULL;
            free(v);
            return (0);
        }
        else /* if (ctx->key != NULL) */
        {
            char * key;

            key = ctx->stack->key;
            ctx->stack->key = NULL;
            return (object_add_keyval (ctx, ctx->stack->value, key, v));
        }
    }
    else if (YAJL_IS_ARRAY (ctx->stack->value))
    {
        return (array_add_value (ctx, ctx->stack->value, v));
    }
    else
    {
        RETURN_ERROR (ctx, EINVAL, "context_add_value: Cannot add value to "
                      "a value of type %#04x (not a composite type)",
                      ctx->stack->value->type);
    }
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl_tree.c:220

context_pop typed

([*struct context_s] -> *struct yajl_val_s)&([c_null] -> empty)
timing: 0.557 s
source
static yajl_val context_pop(context_t *ctx)
{
    stack_elem_t *stack;
    yajl_val v;

    if (ctx->stack == NULL)
        RETURN_ERROR (ctx, NULL, "context_pop: "
                      "Bottom of stack reached prematurely");

    stack = ctx->stack;
    ctx->stack = stack->next;

    v = stack->value;

    free (stack->key);
    free (stack);

    return (v);
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl_tree.c:139

context_push typed

([*struct context_s, c_null] -> c_false | c(12))&([c_null, *struct yajl_val_s] -> empty)
timing: 0.500 s
source
static int context_push(context_t *ctx, yajl_val v)
{
    stack_elem_t *stack;

    stack = malloc (sizeof (*stack));
    if (stack == NULL)
        RETURN_ERROR (ctx, ENOMEM, "Out of memory");
    memset (stack, 0, sizeof (*stack));

    assert ((ctx->stack == NULL)
            || YAJL_IS_OBJECT (v)
            || YAJL_IS_ARRAY (v));

    stack->value = v;
    stack->next = ctx->stack;
    ctx->stack = stack;

    return (0);
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl_tree.c:119

handle_boolean typed

([*struct context_s, c_false] | [*struct context_s, c_int_na \ c_false] -> c_bool)&([c_null, c_false] | [c_null, c_int_na \ c_false] -> c_false)
timing: 0.144 s
source
static int handle_boolean (void *ctx, int boolean_value)
{
    yajl_val v;

    v = value_alloc (boolean_value ? yajl_t_true : yajl_t_false);
    if (v == NULL)
        RETURN_ERROR ((context_t *) ctx, STATUS_ABORT, "Out of memory");

    return ((context_add_value (ctx, v) == 0) ? STATUS_CONTINUE : STATUS_ABORT);
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl_tree.c:385

handle_end_array typed

([*struct context_s] -> c_bool)&([c_null] -> empty)
timing: 0.059 s
source
static int handle_end_array (void *ctx)
{
    yajl_val v;

    v = context_pop (ctx);
    if (v == NULL)
        return (STATUS_ABORT);

    return ((context_add_value (ctx, v) == 0) ? STATUS_CONTINUE : STATUS_ABORT);
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl_tree.c:374

handle_end_map typed

([*struct context_s] -> c_bool)&([c_null] -> empty)
timing: 0.051 s
source
static int handle_end_map (void *ctx)
{
    yajl_val v;

    v = context_pop (ctx);
    if (v == NULL)
        return (STATUS_ABORT);

    return ((context_add_value (ctx, v) == 0) ? STATUS_CONTINUE : STATUS_ABORT);
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl_tree.c:349

handle_null typed

([*struct context_s] -> c_bool)&([c_null] -> c_false)
timing: 0.079 s
source
static int handle_null (void *ctx)
{
    yajl_val v;

    v = value_alloc (yajl_t_null);
    if (v == NULL)
        RETURN_ERROR ((context_t *) ctx, STATUS_ABORT, "Out of memory");

    return ((context_add_value (ctx, v) == 0) ? STATUS_CONTINUE : STATUS_ABORT);
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl_tree.c:396

handle_start_array typed

[c_null] -> c_false
timing: 0.066 s
source
static int handle_start_array (void *ctx)
{
    yajl_val v;

    v = value_alloc(yajl_t_array);
    if (v == NULL)
        RETURN_ERROR ((context_t *) ctx, STATUS_ABORT, "Out of memory");

    v->u.array.values = NULL;
    v->u.array.len = 0;

    return ((context_push (ctx, v) == 0) ? STATUS_CONTINUE : STATUS_ABORT);
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl_tree.c:360

handle_start_map typed

[c_null] -> c_false
timing: 0.084 s
source
static int handle_start_map (void *ctx)
{
    yajl_val v;

    v = value_alloc(yajl_t_object);
    if (v == NULL)
        RETURN_ERROR ((context_t *) ctx, STATUS_ABORT, "Out of memory");

    v->u.object.keys = NULL;
    v->u.object.values = NULL;
    v->u.object.len = 0;

    return ((context_push (ctx, v) == 0) ? STATUS_CONTINUE : STATUS_ABORT);
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl_tree.c:334

is_namedlist typed

([list] -> c_bool)&([(~list)<...> | null | p(CHR) | sym] -> c_false)
timing: 0.103 s
source
static bool is_namedlist(SEXP x) {
  if(TYPEOF(x) == VECSXP && getAttrib(x, R_NamesSymbol) != R_NilValue){
    return true;
  }
  return false;
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/is_recordlist.c:7

is_namedlist_or_null typed

([null] -> c_true)&([(~list)<...> | p(CHR) | sym] -> c_false)&([<...> | p(CHR) | sym] -> c_bool)
timing: 0.027 s
source
static bool is_namedlist_or_null(SEXP x){
  return (is_namedlist(x) || (x == R_NilValue));
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/is_recordlist.c:21

is_recordlist typed

([(~(list & ~{ any_sexp }))<...> | null | p(CHR) | sym] -> c_bool)&([(~(list & ~{ p(CHR) | (~list)<...> | sym | null }))<...> | null | p(CHR) | sym] -> c_false)
timing: 0.511 s
source
static bool is_recordlist(SEXP x){
  bool at_least_one_object = false;
  if(!is_unnamedlist(x)){
    return false;
  }
  int len = length(x);
  if(len < 1){
    return false;
  }
  for (int i=0; i<len; i++) {
    if(!is_namedlist_or_null(VECTOR_ELT(x, i))) return false;
    if(!at_least_one_object && is_namedlist(VECTOR_ELT(x, i))) {
      at_least_one_object = true;
    }
  }
  return at_least_one_object;
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/is_recordlist.c:25

is_unnamedlist typed

([list] -> c_bool)&([(~list)<...> | null | p(CHR) | sym] -> c_false)
timing: 0.076 s
source
static bool is_unnamedlist(SEXP x) {
  if(TYPEOF(x) == VECSXP && getAttrib(x, R_NamesSymbol) == R_NilValue){
    return true;
  }
  return false;
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/is_recordlist.c:14

object_add_keyval typed

([*struct context_s \ c_null, c_null, c_string, *struct yajl_val_s \ c_null] | [*struct context_s \ c_null, c_null, c_string, c_null] | [c_null, c_null, c_string, *struct yajl_val_s \ c_null] | [c_null, c_null, c_string, c_null] -> empty)&([*struct context_s, *struct yajl_val_s, c_string, *struct yajl_val_s] & ~[*struct context_s \ c_null, c_null, c_string, *struct yajl_val_s \ c_null] & ~[*struct context_s \ c_null, c_null, c_string, c_null] & ~[c_null, c_null, c_string, *struct yajl_val_s \ c_null] & ~[c_null, c_null, c_string, c_null] -> c_int_na)
timing: 0.426 s
source
static int object_add_keyval(context_t *ctx,
                             yajl_val obj, char *key, yajl_val value)
{
    const char **tmpk;
    yajl_val *tmpv;

    /* We're checking for NULL in "context_add_value" or its callers. */
    assert (ctx != NULL);
    assert (obj != NULL);
    assert (key != NULL);
    assert (value != NULL);

    /* We're assuring that "obj" is an object in "context_add_value". */
    assert(YAJL_IS_OBJECT(obj));

    tmpk = realloc((void *) obj->u.object.keys, sizeof(*(obj->u.object.keys)) * (obj->u.object.len + 1));
    if (tmpk == NULL)
        RETURN_ERROR(ctx, ENOMEM, "Out of memory");
    obj->u.object.keys = tmpk;

    tmpv = realloc(obj->u.object.values, sizeof (*obj->u.object.values) * (obj->u.object.len + 1));
    if (tmpv == NULL)
        RETURN_ERROR(ctx, ENOMEM, "Out of memory");
    obj->u.object.values = tmpv;

    obj->u.object.keys[obj->u.object.len] = key;
    obj->u.object.values[obj->u.object.len] = value;
    obj->u.object.len++;

    return (0);
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl_tree.c:159

ParseArray typed

([c_null, c_int_na] -> empty)&([*struct yajl_val_s, c_int_na] \ [c_null, c_int_na] -> any_sexp)
timing: 0.024 s
source
static SEXP ParseArray(yajl_val node, int bigint){
  int len = YAJL_GET_ARRAY(node)->len;
  SEXP vec = PROTECT(allocVector(VECSXP, len));
  for (int i = 0; i < len; ++i) {
    SET_VECTOR_ELT(vec, i, ParseValue(YAJL_GET_ARRAY(node)->values[i], bigint));
  }
  UNPROTECT(1);
  return vec;
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/parse.c:105

ParseObject typed

([c_null, c_int_na] -> empty)&([*struct yajl_val_s, c_int_na] \ [c_null, c_int_na] -> any_sexp)
timing: 0.026 s
source
static SEXP ParseObject(yajl_val node, int bigint){
  int len = YAJL_GET_OBJECT(node)->len;
  SEXP keys = PROTECT(allocVector(STRSXP, len));
  SEXP vec = PROTECT(allocVector(VECSXP, len));
  for (int i = 0; i < len; ++i) {
    SET_STRING_ELT(keys, i, mkCharCE(YAJL_GET_OBJECT(node)->keys[i], CE_UTF8));
    SET_VECTOR_ELT(vec, i, ParseValue(YAJL_GET_OBJECT(node)->values[i], bigint));
  }
  setAttrib(vec, R_NamesSymbol, keys);
  UNPROTECT(2);
  return vec;
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/parse.c:92

ParseValue typed

([c_null, c_int_na] -> empty)&([*struct yajl_val_s, c_int_na] \ [c_null, c_int_na] -> any_sexp)
timing: 0.131 s
source
SEXP ParseValue(yajl_val node, int bigint){
  if(YAJL_IS_NULL(node)){
    return R_NilValue;
  }
  if(YAJL_IS_STRING(node)){
    SEXP tmp = PROTECT(allocVector(STRSXP, 1));
    SET_STRING_ELT(tmp, 0, mkCharCE(YAJL_GET_STRING(node),  CE_UTF8));
    UNPROTECT(1);
    return tmp;
  }
  if(YAJL_IS_INTEGER(node)){
    long long int val = YAJL_GET_INTEGER(node);
    /* 2^53 is highest int stored as double without loss */
    if(bigint && (val > 9007199254740992 || val < -9007199254740992)){
      char buf[32];
      snprintf(buf, 32, "%lld", val);
      return mkString(buf);
    /* see .Machine$integer.max in R */
    } else if(val > 2147483647 || val < -2147483647){
      return ScalarReal(val);
    } else {
      return ScalarInteger(val);
    }
  }
  if(YAJL_IS_DOUBLE(node)){
    return(ScalarReal(YAJL_GET_DOUBLE(node)));
  }
  if(YAJL_IS_NUMBER(node)){
    /* A number that is not int or double (very rare) */
    /* This seems to correctly round to Inf/0/-Inf */
    return(ScalarReal(YAJL_GET_DOUBLE(node)));
  }
  if(YAJL_IS_TRUE(node)){
    return(ScalarLogical(1));
  }
  if(YAJL_IS_FALSE(node)){
    return(ScalarLogical(0));
  }
  if(YAJL_IS_OBJECT(node)){
    return(ParseObject(node, bigint));
  }
  if(YAJL_IS_ARRAY(node)){
    return(ParseArray(node, bigint));
  }
  error("Invalid YAJL node type.");
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/parse.c:45

push_parser_get typed

[*struct yajl_handle_t] -> *struct yajl_val_s
timing: 0.052 s
source
yajl_val push_parser_get(yajl_handle handle){
  context_t *ctx = (context_t*) handle->ctx;
  return ctx->root;
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl_tree.c:559

push_parser_new typed

() -> *struct yajl_handle_t
timing: 0.119 s
source
yajl_handle push_parser_new (void) {

  /* init callback handlers */
  yajl_callbacks *callbacks = &mem_callbacks;
  memset(callbacks, 0, sizeof(yajl_callbacks));

  callbacks->yajl_null = handle_null;
  callbacks->yajl_boolean = handle_boolean;
  callbacks->yajl_number = handle_number;
  callbacks->yajl_integer = NULL;
  callbacks->yajl_double = NULL;
  callbacks->yajl_string = handle_string;
  callbacks->yajl_start_map = handle_start_map;
  callbacks->yajl_map_key = handle_string;
  callbacks->yajl_end_map = handle_end_map;
  callbacks->yajl_start_array = handle_start_array;
  callbacks->yajl_end_array = handle_end_array;

  /* init context */
  context_t *ctx = &mem_ctx;
  memset(ctx, 0, sizeof(context_t));

  /* init handle */
  yajl_handle handle = yajl_alloc(callbacks, NULL, ctx);
  yajl_config(handle, yajl_allow_comments, 1);
  return handle;
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl_tree.c:531

R_base64_decode typed entry .Call empty return

[((CHR | CLX | DBL | INT | LGL) | (~vec)<...>) | null | p(CHR) | sym] -> empty
timing: 0.175 s
source
SEXP R_base64_decode(SEXP buf){
  if(TYPEOF(buf) != RAWSXP)
    Rf_error("base64 buf must be raw");
  size_t len = Rf_length(buf);
  size_t outlen = 0;
  unsigned char * out = base64_decode(RAW(buf), len, &outlen);
  if(out == NULL)
    Rf_error("Error in base64 decode");
  SEXP res = allocVector(RAWSXP, outlen);
  memcpy(RAW(res), out, outlen);
  free(out);
  return res;
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/r-base64.c:21

R_base64_encode typed entry .Call empty return

[((CHR | CLX | DBL | INT | LGL) | (~vec)<...>) | null | p(CHR) | sym] -> empty
timing: 0.179 s
source
SEXP R_base64_encode(SEXP buf){
  if(TYPEOF(buf) != RAWSXP)
    Rf_error("base64 buf must be raw");
  size_t len = Rf_length(buf);
  size_t outlen = 0;
  unsigned char * out = base64_encode(RAW(buf), len, &outlen);
  if(out == NULL)
    Rf_error("Error in base64 encode");
  SEXP res = PROTECT(allocVector(STRSXP, 1));
  SET_STRING_ELT(res, 0, mkCharLen((char*) out, outlen));
  free(out);
  UNPROTECT(1);
  return res;
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/r-base64.c:6

R_num_to_char typed entry .Call empty return

[(~(DBL | INT))<...> | null | p(CHR) | sym, any_sexp, any_sexp, any_sexp, any_sexp] -> empty
timing: 3.79 s
source
SEXP R_num_to_char(SEXP x, SEXP digits, SEXP na_as_string, SEXP use_signif, SEXP always_decimal) {
  int len = length(x);
  int na_string = asLogical(na_as_string);
  int signif = asLogical(use_signif);
  int always_dec = asLogical(always_decimal);
  char buf[32];
  SEXP out = PROTECT(allocVector(STRSXP, len));
  if(isInteger(x)){
    for (int i=0; i<len; i++) {
      if(INTEGER(x)[i] == NA_INTEGER){
        if(na_string == NA_LOGICAL){
          SET_STRING_ELT(out, i, NA_STRING);
        } else if(na_string){
          SET_STRING_ELT(out, i, mkChar("\"NA\""));
        } else {
          SET_STRING_ELT(out, i, mkChar("null"));
        }
      } else {
        modp_itoa10(INTEGER(x)[i], buf);
        SET_STRING_ELT(out, i, mkChar(buf));
      }
    }
  } else if(isReal(x)) {
    int precision = asInteger(digits);
    int sig_digits = signif ? ceil(fmin(17, precision)) : 0;
    double * xreal = REAL(x);
    for (int i=0; i<len; i++) {
      double val = xreal[i];
      if(!R_FINITE(val)){
        if(na_string == NA_LOGICAL){
          SET_STRING_ELT(out, i, NA_STRING);
        } else if(na_string){
          if(ISNA(val)){
            SET_STRING_ELT(out, i, mkChar("\"NA\""));
          } else if(ISNAN(val)){
            SET_STRING_ELT(out, i, mkChar("\"NaN\""));
          } else if(val == R_PosInf){
            SET_STRING_ELT(out, i, mkChar("\"Inf\""));
          } else if(val == R_NegInf){
            SET_STRING_ELT(out, i, mkChar("\"-Inf\""));
          } else {
            error("Unrecognized non finite value.");
          }
        } else {
          SET_STRING_ELT(out, i, mkChar("null"));
        }
      } else {
        if(precision == NA_INTEGER){
          snprintf(buf, 32, "%.15g", val);
        } else if(signif){
          //use signifant digits rather than decimal digits
          snprintf(buf, 32, "%.*g", sig_digits, val);
        } else if(precision > -1 && precision < 10 && fabs(val) < 2147483647 && fabs(val) > 1e-5) {
          //preferred method: fast with fixed decimal digits
          //does not support large numbers or scientific notation
          modp_dtoa2(val, buf, precision);
        } else {
          //fall back on sprintf (includes scientific notation)
          //funky formula is mostly to convert decimal digits into significant digits
          int decimals = ceil(fmin(17, fmax(1, log10(fabs(val))) + precision));
          snprintf(buf, 32, "%.*g", decimals, val);
        }
        //if always_decimal = TRUE, then append .0 to whole numbers
        if(always_dec && strspn(buf, "0123456789-") == strlen(buf)){
          strcat(buf, ".0");
        }
        SET_STRING_ELT(out, i, mkChar(buf));
      }
    }
  } else {
    error("num_to_char called with invalid object type.");
  }

  UNPROTECT(1);
  return out;
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/num_to_char.c:6

strreverse typed

[c_string, c_string] -> ()
timing: 0.185 s
source
static void strreverse(char* begin, char* end)
{
	char aux;
	while (end > begin)
		aux = *end, *end-- = *begin, *begin++ = aux;
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/modp_numtoa.c:32

unreadChar typed any: arg 1

∀'a,'b,'c. ([*{ bufOff : 'b & c_double ..}, *('a \ (c(1..) | c_string)) | c_string] -> 'b & c_double)&([*{ bufOff : *('c \ c_string) & 'b ..}, *('a \ (c(1..) | c_string)) | c_string] -> *('c \ c_string) & 'b)&([*{ bufOff : c_int & 'b ..}, *('a \ (c(1..) | c_string)) | c_string] -> c_int & 'b)&([*{ bufOff : c_int_na & 'b ..}, *('a \ (c(1..) | c_string)) | c_string] -> c_int_na & 'b)&([*{ bufOff : c_string & 'b ..}, *('a \ (c(1..) | c_string)) | c_string] -> c_string & 'b)&([any, *(c(1..) & 'a)] -> c_int & 'a)&([any, c_null] -> empty)
timing: 1.04 s
(definition not located in src/)

value_alloc typed

[c(1..8)] -> *struct yajl_val_s
timing: 0.038 s
source
static yajl_val value_alloc (yajl_type type)
{
    yajl_val v;

    v = malloc (sizeof (*v));
    if (v == NULL) return (NULL);
    memset (v, 0, sizeof (*v));
    v->type = type;

    return (v);
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl_tree.c:65

yajl_array_free typed

[c_null] -> ()
timing: 0.019 s
source
static void yajl_array_free (yajl_val v)
{
    size_t i;

    if (!YAJL_IS_ARRAY(v)) return;

    for (i = 0; i < v->u.array.len; i++)
    {
        yajl_tree_free (v->u.array.values[i]);
        v->u.array.values[i] = NULL;
    }

    free(v->u.array.values);
    free(v);
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl_tree.c:96

yajl_bs_current typed

∀'a. ([{ stack : *('a \ c_string) ; used : c(1..) ..}] | [{ stack : *('a \ c_string) ; used : c_int_na \ c(1..) ..}] -> 'a)&([{ stack : *('a \ c_string) | c_string ; used : c(1..) ..}] | [{ stack : *('a \ c_string) | c_string ; used : c_int_na \ c(1..) ..}] -> 'a | c_char)
timing: 0.185 s
(definition not located in src/)

yajl_bs_free typed

[{ stack : c_falsy ..}] -> ()
timing: 0.345 s
(definition not located in src/)

yajl_bs_init typed

∀'a. [record, 'a] -> 'a
timing: 0.018 s
(definition not located in src/)

yajl_bs_pop typed

∀'a,'b. ([{ used : *('b \ c_string) & 'a ..}] -> *('b \ c_string) & 'a)&([{ used : c_int & 'a ..}] -> c_int & 'a)&([{ used : c_int_na & 'a ..}] -> c_int_na & 'a)&([{ used : c_string & 'a ..}] -> c_string & 'a)&([{ used : 'a & c_double ..}] -> 'a & c_double)
timing: 0.239 s
(definition not located in src/)

yajl_bs_set typed any: arg 2

([{ stack : c_null ; used : c_int_na ..}, any] -> empty)&([{ stack : *any ; used : c_int_na ..}, any] | [{ stack : c_string | c_null ; used : c_int_na ..}, c_char] -> ())
timing: 0.202 s
(definition not located in src/)

yajl_buf_alloc typed

[*struct yajl_alloc_funcs] -> *struct yajl_buf_t
timing: 0.019 s
source
yajl_buf yajl_buf_alloc(yajl_alloc_funcs * alloc)
{
    yajl_buf b = YA_MALLOC(alloc, sizeof(struct yajl_buf_t));
    memset((void *) b, 0, sizeof(struct yajl_buf_t));
    b->alloc = alloc;
    return b;
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl_buf.c:66

yajl_buf_append typed empty return

[c_null, c_ptr, c_int_na] -> empty
timing: 0.010 s
source
void yajl_buf_append(yajl_buf buf, const void * data, size_t len)
{
    yajl_buf_ensure_available(buf, len);
    if (len > 0) {
        assert(data != NULL);
        memcpy(buf->data + buf->used, data, len);
        buf->used += len;
        buf->data[buf->used] = 0;
    }
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl_buf.c:81

yajl_buf_clear typed empty return

[c_null] -> empty
timing: 0.196 s
source
void yajl_buf_clear(yajl_buf buf)
{
    buf->used = 0;
    if (buf->data) buf->data[buf->used] = 0;
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl_buf.c:92

yajl_buf_data typed

([*struct yajl_buf_t] -> c_string)&([c_null] -> empty)
timing: 0.025 s
source
const unsigned char * yajl_buf_data(yajl_buf buf)
{
    return buf->data;
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl_buf.c:98

yajl_buf_ensure_available typed empty return

[c_null, c_int_na] -> empty
timing: 1.67 s
source
void yajl_buf_ensure_available(yajl_buf buf, size_t want)
{
    size_t need;
    
    assert(buf != NULL);

    /* first call */
    if (buf->data == NULL) {
        buf->len = YAJL_BUF_INIT_SIZE;
        buf->data = (unsigned char *) YA_MALLOC(buf->alloc, buf->len);
        buf->data[0] = 0;
    }

    need = buf->len;

    if (((buf->used > want) ? buf->used : want) > (size_t)(buf->used + want)) {
        /* We cannot allocate more memory than SIZE_MAX. */
        abort();
    }
    while (want >= (need - buf->used)) {
        if (need >= (size_t)((size_t)(-1)<<1)>>1) {
            /* need would overflow. */
            abort();
        }
        need <<= 1;
    }

    if (need != buf->len) {
        buf->data = (unsigned char *) YA_REALLOC(buf->alloc, buf->data, need);
        buf->len = need;
    }
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl_buf.c:33

yajl_buf_free typed

([*struct yajl_buf_t \ c_null] -> ())&([c_null] -> empty)
timing: 0.241 s
source
void yajl_buf_free(yajl_buf buf)
{
    assert(buf != NULL);
    if (buf->data) YA_FREE(buf->alloc, buf->data);
    YA_FREE(buf->alloc, buf);
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl_buf.c:74

yajl_buf_len typed

([*struct yajl_buf_t] -> c_int_na)&([c_null] -> empty)
timing: 0.023 s
source
size_t yajl_buf_len(yajl_buf buf)
{
    return buf->used;
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl_buf.c:103

yajl_buf_print typed empty return

[c_null, c_string, c_int_na] -> empty
timing: 0.012 s
source
static void yajl_buf_print(void * ctx, const char * str, size_t len)
{
  yajl_buf_append(ctx, str, len);
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl_gen.c:96

yajl_complete_parse typed

([c_null] -> empty)&([*struct yajl_handle_t] \ [c_null] -> c(0..2))
timing: 0.320 s
source
yajl_complete_parse(yajl_handle hand)
{
    /* The lexer is lazy allocated in the first call to parse.  if parse is
     * never called, then no data was provided to parse at all.  This is a
     * "premature EOF" error unless yajl_allow_partial_values is specified.
     * allocating the lexer now is the simplest possible way to handle this
     * case while preserving all the other semantics of the parser
     * (multiple values, partial values, etc). */
    if (hand->lexer == NULL) {
        hand->lexer = yajl_lex_alloc(&(hand->alloc),
                                     hand->flags & yajl_allow_comments,
                                     !(hand->flags & yajl_dont_validate_strings));
    }

    return yajl_do_finish(hand);
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl.c:136

yajl_do_finish typed

[c_null] -> c(1..2)
timing: 0.160 s
source
yajl_do_finish(yajl_handle hand)
{
    yajl_status stat;
    stat = yajl_do_parse(hand,(const unsigned char *) " ",1);

    if (stat != yajl_status_ok) return stat;

    switch(yajl_bs_current(hand->stateStack))
    {
        case yajl_state_parse_error:
        case yajl_state_lexical_error:
            return yajl_status_error;
        case yajl_state_got_value:
        case yajl_state_parse_complete:
            return yajl_status_ok;
        default:
            if (!(hand->flags & yajl_allow_partial_values))
            {
                yajl_bs_set(hand->stateStack, yajl_state_parse_error);
                hand->parseError = "premature EOF";
                return yajl_status_error;
            }
            return yajl_status_ok;
    }
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl_parser.c:159

yajl_free typed empty return

[c_null] -> empty
timing: 0.027 s
source
yajl_free(yajl_handle handle)
{
    yajl_bs_free(handle->stateStack);
    yajl_buf_free(handle->decodeBuf);
    if (handle->lexer) {
        yajl_lex_free(handle->lexer);
        handle->lexer = NULL;
    }
    YA_FREE(&(handle->alloc), handle);
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl.c:106

yajl_free_error typed

([*struct yajl_handle_t, c_string] -> ())&([c_null, c_string] -> empty)
timing: 0.045 s
source
yajl_free_error(yajl_handle hand, unsigned char * str)
{
    /* use memory allocation functions if set */
    YA_FREE(&(hand->alloc), str);
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl.c:169

yajl_gen_alloc typed

[*struct yajl_alloc_funcs \ c_null] | [c_null] -> *struct yajl_gen_t
timing: 0.475 s
source
yajl_gen_alloc(const yajl_alloc_funcs * afs)
{
    yajl_gen g = NULL;
    yajl_alloc_funcs afsBuffer;

    /* first order of business is to set up memory allocation routines */
    if (afs != NULL) {
        if (afs->malloc == NULL || afs->realloc == NULL || afs->free == NULL)
        {
            return NULL;
        }
    } else {
        yajl_set_default_alloc_funcs(&afsBuffer);
        afs = &afsBuffer;
    }

    g = (yajl_gen) YA_MALLOC(afs, sizeof(struct yajl_gen_t));
    if (!g) return NULL;

    memset((void *) g, 0, sizeof(struct yajl_gen_t));
    /* copy in pointers to allocation routines */
    memcpy((void *) &(g->alloc), (void *) afs, sizeof(yajl_alloc_funcs));

    g->print = &yajl_buf_print;
    g->ctx = yajl_buf_alloc(&(g->alloc));
    g->indentString = "    ";

    return g;
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl_gen.c:103

yajl_gen_clear typed empty return

[c_null] -> empty
timing: 0.060 s
source
yajl_gen_clear(yajl_gen g)
{
    if (g->print == &yajl_buf_print) yajl_buf_clear((yajl_buf)g->ctx);
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl_gen.c:364

yajl_gen_config typed

([c_null, c(4)] -> empty)&(~[c_null, c(4)] -> c_int_na)
timing: 0.281 s
source
yajl_gen_config(yajl_gen g, yajl_gen_option opt, ...)
{
    int rv = 1;
    va_list ap;
    va_start(ap, opt);

    switch(opt) {
        case yajl_gen_beautify:
        case yajl_gen_validate_utf8:
        case yajl_gen_escape_solidus:
            if (va_arg(ap, int)) g->flags |= opt;
            else g->flags &= ~opt;
            break;
        case yajl_gen_indent_string: {
            const char *indent = va_arg(ap, const char *);
            g->indentString = indent;
            for (; *indent; indent++) {
                if (*indent != '\n'
                    && *indent != '\v'
                    && *indent != '\f'
                    && *indent != '\t'
                    && *indent != '\r'
                    && *indent != ' ')
                {
                    g->indentString = NULL;
                    rv = 0;
                }
            }
            break;
        }
        case yajl_gen_print_callback:
            yajl_buf_free(g->ctx);
            g->print = va_arg(ap, const yajl_print_t);
            g->ctx = va_arg(ap, void *);
            break;
        default:
            rv = 0;
    }

    va_end(ap);

    return rv;
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl_gen.c:51

yajl_gen_free typed

([*struct yajl_gen_t] -> ())&([c_null] -> empty)
timing: 0.142 s
source
yajl_gen_free(yajl_gen g)
{
    if (g->print == &yajl_buf_print) yajl_buf_free((yajl_buf)g->ctx);
    YA_FREE(&(g->alloc), g);
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl_gen.c:142

yajl_gen_get_buf typed

([*struct yajl_gen_t, *(c_string | c_null), *c_int_na] -> c_false | c(6))&([c_null, *(c_string | c_null), *c_int_na] -> empty)
timing: 0.222 s
source
yajl_gen_get_buf(yajl_gen g, const unsigned char ** buf,
                 size_t * len)
{
    if (g->print != &yajl_buf_print) return yajl_gen_no_buf;
    *buf = yajl_buf_data((yajl_buf)g->ctx);
    *len = yajl_buf_len((yajl_buf)g->ctx);
    return yajl_gen_status_ok;
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl_gen.c:354

YAJL_GET_ARRAY typed

∀'a. ([*{ type : c(4) ; u : { array : 'a ..} ..} \ c_null] -> *('a \ c_string))&([*{ type : ~c(4) ..}] -> c_null)
timing: 0.056 s
(definition not located in src/)

yajl_get_bytes_consumed typed

([*struct yajl_handle_t \ c_null] -> c_int_na)&([c_null] -> c_false)
timing: 0.039 s
source
yajl_get_bytes_consumed(yajl_handle hand)
{
    if (!hand) return 0;
    else return hand->bytesConsumed;
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl.c:161

YAJL_GET_DOUBLE typed

∀'a. [*{ u : { number : { d : 'a ..} ..} ..}] -> 'a
timing: 0.030 s
(definition not located in src/)

yajl_get_error typed

([*struct yajl_handle_t, c_int_na, c_string, c_int_na] -> c_string)&([c_null, c_int_na, c_string, c_int_na] -> empty)
timing: 0.021 s
source
yajl_get_error(yajl_handle hand, int verbose,
               const unsigned char * jsonText, size_t jsonTextLen)
{
    return yajl_render_error_string(hand, jsonText, jsonTextLen, verbose);
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl.c:154

YAJL_GET_INTEGER typed

∀'a. [*{ u : { number : { i : 'a ..} ..} ..}] -> 'a
timing: 0.029 s
(definition not located in src/)

YAJL_GET_OBJECT typed

∀'a. ([*{ type : c(3) ; u : { object : 'a ..} ..} \ c_null] -> *('a \ c_string))&([*{ type : ~c(3) ..}] -> c_null)
timing: 0.057 s
(definition not located in src/)

YAJL_GET_STRING typed

∀'a. ([*{ type : c_true ; u : { string : 'a ..} ..} \ c_null] -> 'a)&([*{ type : ~c_true ..}] -> c_null)
timing: 0.049 s
(definition not located in src/)

yajl_internal_free typed

[c_ptr, c_ptr] -> ()
timing: 0.005 s
source
static void yajl_internal_free(void *ctx, void * ptr)
{
    (void)ctx;
    free(ptr);
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl_alloc.c:39

yajl_internal_malloc typed

[c_ptr, c_int_na] -> c_ptr
timing: 0.005 s
source
static void * yajl_internal_malloc(void *ctx, size_t sz)
{
    (void)ctx;
    return malloc(sz);
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl_alloc.c:26

yajl_internal_realloc typed

[c_ptr, c_ptr, c_int_na] -> c_ptr
timing: 0.006 s
source
static void * yajl_internal_realloc(void *ctx, void * previous,
                                    size_t sz)
{
    (void)ctx;
    return realloc(previous, sz);
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl_alloc.c:32

YAJL_IS_ARRAY typed

([*{ type : c(4) ..} \ c_null] -> c_true)&([*{ type : ~c(4) ..} \ c_null] | [c_null] -> c_false)
timing: 0.051 s
(definition not located in src/)

YAJL_IS_DOUBLE typed

([*{ type : c(2) ; u : { number : { flags : c_int_na ..} ..} ..} \ c_null] -> c_bool)&([*{ type : ~c(2) ..}] -> c_false)
timing: 0.073 s
(definition not located in src/)

YAJL_IS_FALSE typed

([*{ type : c(6) ..} \ c_null] -> c_true)&([*{ type : ~c(6) ..} \ c_null] | [c_null] -> c_false)
timing: 0.049 s
(definition not located in src/)

YAJL_IS_INTEGER typed

([*{ type : c(2) ; u : { number : { flags : c_int_na ..} ..} ..} \ c_null] -> c_bool)&([*{ type : ~c(2) ..}] -> c_false)
timing: 0.071 s
(definition not located in src/)

YAJL_IS_NULL typed

([*{ type : c(7) ..} \ c_null] -> c_true)&([*{ type : ~c(7) ..} \ c_null] | [c_null] -> c_false)
timing: 0.046 s
(definition not located in src/)

YAJL_IS_NUMBER typed

([*{ type : c(2) ..} \ c_null] -> c_true)&([*{ type : ~c(2) ..} \ c_null] | [c_null] -> c_false)
timing: 0.049 s
(definition not located in src/)

YAJL_IS_OBJECT typed

([*{ type : c(3) ..} \ c_null] -> c_true)&([*{ type : ~c(3) ..} \ c_null] | [c_null] -> c_false)
timing: 0.044 s
(definition not located in src/)

YAJL_IS_STRING typed

([*{ type : c_true ..} \ c_null] -> c_true)&([*{ type : ~c_true ..} \ c_null] | [c_null] -> c_false)
timing: 0.051 s
(definition not located in src/)

YAJL_IS_TRUE typed

([*{ type : c(5) ..} \ c_null] -> c_true)&([*{ type : ~c(5) ..} \ c_null] | [c_null] -> c_false)
timing: 0.048 s
(definition not located in src/)

yajl_lex_alloc typed

[*struct yajl_alloc_funcs, c_int_na, c_int_na] -> *struct yajl_lexer_t
timing: 0.049 s
source
yajl_lex_alloc(yajl_alloc_funcs * alloc,
               unsigned int allowComments, unsigned int validateUTF8)
{
    yajl_lexer lxr = (yajl_lexer) YA_MALLOC(alloc, sizeof(struct yajl_lexer_t));
    memset((void *) lxr, 0, sizeof(struct yajl_lexer_t));
    lxr->buf = yajl_buf_alloc(alloc);
    lxr->allowComments = allowComments;
    lxr->validateUTF8 = validateUTF8;
    lxr->alloc = alloc;
    return lxr;
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl_lex.c:104

yajl_lex_comment typed

([*struct yajl_lexer_t, c_string, c_int_na, *c(1..)] -> c(4) | c(14))&([c_null, c_string, c_int_na, *c_int_na] -> c(14))
timing: 0.363 s
source
yajl_lex_comment(yajl_lexer lexer, const unsigned char * jsonText,
                 size_t jsonTextLen, size_t * offset)
{
    unsigned char c;

    yajl_tok tok = yajl_tok_comment;

    RETURN_IF_EOF;
    c = readChar(lexer, jsonText, offset);

    /* either slash or star expected */
    if (c == '/') {
        /* now we throw away until end of line */
        do {
            RETURN_IF_EOF;
            c = readChar(lexer, jsonText, offset);
        } while (c != '\n');
    } else if (c == '*') {
        /* now we throw away until end of comment */
        for (;;) {
            RETURN_IF_EOF;
            c = readChar(lexer, jsonText, offset);
            if (c == '*') {
                RETURN_IF_EOF;
                c = readChar(lexer, jsonText, offset);
                if (c == '/') {
                    break;
                } else {
                    unreadChar(lexer, offset);
                }
            }
        }
    } else {
        lexer->error = yajl_lex_invalid_char;
        tok = yajl_tok_error;
    }

    return tok;
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl_lex.c:458

yajl_lex_error_to_string typed

([c(10)] -> c("probable comment found in input text, comments are not enabled."))&([c(2)] -> c("inside a string, '\\\\' occurs before a character which it may not."))&([c(3)] -> c("invalid character inside string."))&([c(4)] -> c("invalid (non-hex) character occurs after '\\\\u' inside string."))&([c(5)] -> c("invalid char in json text."))&([c(6)] -> c("invalid string in json text."))&([c(7)] -> c("malformed number, a digit is required after the decimal point."))&([c(8)] -> c("malformed number, a digit is required after the exponent."))&([c(9)] -> c("malformed number, a digit is required after the minus sign."))&([c_false] -> c("ok, no error"))&([c_true] -> c("invalid bytes in UTF8 string."))
timing: 0.742 s
source
yajl_lex_error_to_string(yajl_lex_error error)
{
    switch (error) {
        case yajl_lex_e_ok:
            return "ok, no error";
        case yajl_lex_string_invalid_utf8:
            return "invalid bytes in UTF8 string.";
        case yajl_lex_string_invalid_escaped_char:
            return "inside a string, '\\' occurs before a character "
                   "which it may not.";
        case yajl_lex_string_invalid_json_char:
            return "invalid character inside string.";
        case yajl_lex_string_invalid_hex_char:
            return "invalid (non-hex) character occurs after '\\u' inside "
                   "string.";
        case yajl_lex_invalid_char:
            return "invalid char in json text.";
        case yajl_lex_invalid_string:
            return "invalid string in json text.";
        case yajl_lex_missing_integer_after_exponent:
            return "malformed number, a digit is required after the exponent.";
        case yajl_lex_missing_integer_after_decimal:
            return "malformed number, a digit is required after the "
                   "decimal point.";
        case yajl_lex_missing_integer_after_minus:
            return "malformed number, a digit is required after the "
                   "minus sign.";
        case yajl_lex_unallowed_comment:
            return "probable comment found in input text, comments are "
                   "not enabled.";
    }
    return "unknown error code";
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl_lex.c:691

yajl_lex_free typed

([*struct yajl_lexer_t] -> ())&([c_null] -> empty)
timing: 0.092 s
source
yajl_lex_free(yajl_lexer lxr)
{
    yajl_buf_free(lxr->buf);
    YA_FREE(lxr->alloc, lxr);
    return;
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl_lex.c:117

yajl_lex_get_error typed

[*struct yajl_lexer_t \ c_null] -> c(0..10)
timing: 0.041 s
source
yajl_lex_get_error(yajl_lexer lexer)
{
    if (lexer == NULL) return (yajl_lex_error) -1;
    return lexer->error;
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl_lex.c:729

yajl_lex_lex typed

([c_null, c_string, c_int_na, *c_int_na, *(c_string | c_null), *c_int_na] -> empty)&([*struct yajl_lexer_t, c_string, c_int_na, *c_int_na, *(c_string | c_null), *c_int_na] \ [c_null, c_string, c_int_na, *c_int_na, *(c_string | c_null), *c_int_na] -> c(0..14))
timing: 6.40 s
source
yajl_lex_lex(yajl_lexer lexer, const unsigned char * jsonText,
             size_t jsonTextLen, size_t * offset,
             const unsigned char ** outBuf, size_t * outLen)
{
    yajl_tok tok = yajl_tok_error;
    unsigned char c;
    size_t startOffset = *offset;

    *outBuf = NULL;
    *outLen = 0;

    for (;;) {
        assert(*offset <= jsonTextLen);

        if (*offset >= jsonTextLen) {
            tok = yajl_tok_eof;
            goto lexed;
        }

        c = readChar(lexer, jsonText, offset);

        switch (c) {
            case '{':
                tok = yajl_tok_left_bracket;
                goto lexed;
            case '}':
                tok = yajl_tok_right_bracket;
                goto lexed;
            case '[':
                tok = yajl_tok_left_brace;
                goto lexed;
            case ']':
                tok = yajl_tok_right_brace;
                goto lexed;
            case ',':
                tok = yajl_tok_comma;
                goto lexed;
            case ':':
                tok = yajl_tok_colon;
                goto lexed;
            case '\t': case '\n': case '\v': case '\f': case '\r': case ' ':
                startOffset++;
                break;
            case 't': {
                const char * want = "rue";
                do {
                    if (*offset >= jsonTextLen) {
                        tok = yajl_tok_eof;
                        goto lexed;
                    }
                    c = readChar(lexer, jsonText, offset);
                    if (c != *want) {
                        unreadChar(lexer, offset);
                        lexer->error = yajl_lex_invalid_string;
                        tok = yajl_tok_error;
                        goto lexed;
                    }
                } while (*(++want));
                tok = yajl_tok_bool;
                goto lexed;
            }
            case 'f': {
                const char * want = "alse";
                do {
                    if (*offset >= jsonTextLen) {
                        tok = yajl_tok_eof;
                        goto lexed;
                    }
                    c = readChar(lexer, jsonText, offset);
                    if (c != *want) {
                        unreadChar(lexer, offset);
                        lexer->error = yajl_lex_invalid_string;
                        tok = yajl_tok_error;
                        goto lexed;
                    }
                } while (*(++want));
                tok = yajl_tok_bool;
                goto lexed;
            }
            case 'n': {
                const char * want = "ull";
                do {
                    if (*offset >= jsonTextLen) {
                        tok = yajl_tok_eof;
                        goto lexed;
                    }
                    c = readChar(lexer, jsonText, offset);
                    if (c != *want) {
                        unreadChar(lexer, offset);
                        lexer->error = yajl_lex_invalid_string;
                        tok = yajl_tok_error;
                        goto lexed;
                    }
                } while (*(++want));
                tok = yajl_tok_null;
                goto lexed;
            }
            case '"': {
                tok = yajl_lex_string(lexer, (const unsigned char *) jsonText,
                                      jsonTextLen, offset);
                goto lexed;
            }
            case '-':
            case '0': case '1': case '2': case '3': case '4':
            case '5': case '6': case '7': case '8': case '9': {
                /* integer parsing wants to start from the beginning */
                unreadChar(lexer, offset);
                tok = yajl_lex_number(lexer, (const unsigned char *) jsonText,
                                      jsonTextLen, offset);
                goto lexed;
            }
            case '/':
                /* hey, look, a probable comment!  If comments are disabled
                 * it's an error. */
                if (!lexer->allowComments) {
                    unreadChar(lexer, offset);
                    lexer->error = yajl_lex_unallowed_comment;
                    tok = yajl_tok_error;
                    goto lexed;
                }
                /* if comments are enabled, then we should try to lex
                 * the thing.  possible outcomes are
                 * - successful lex (tok_comment, which means continue),
                 * - malformed comment opening (slash not followed by
                 *   '*' or '/') (tok_error)
                 * - eof hit. (tok_eof) */
                tok = yajl_lex_comment(lexer, (const unsigned char *) jsonText,
                                       jsonTextLen, offset);
                if (tok == yajl_tok_comment) {
                    /* "error" is silly, but that's the initial
                     * state of tok.  guilty until proven innocent. */
                    tok = yajl_tok_error;
                    yajl_buf_clear(lexer->buf);
                    lexer->bufInUse = 0;
                    startOffset = *offset;
                    break;
                }
                /* hit error or eof, bail */
                goto lexed;
            default:
                lexer->error = yajl_lex_invalid_char;
                tok = yajl_tok_error;
                goto lexed;
        }
    }


  lexed:
    /* need to append to buffer if the buffer is in use or
     * if it's an EOF token */
    if (tok == yajl_tok_eof || lexer->bufInUse) {
        if (!lexer->bufInUse) yajl_buf_clear(lexer->buf);
        lexer->bufInUse = 1;
        yajl_buf_append(lexer->buf, jsonText + startOffset, *offset - startOffset);
        lexer->bufOff = 0;

        if (tok != yajl_tok_eof) {
            *outBuf = yajl_buf_data(lexer->buf);
            *outLen = yajl_buf_len(lexer->buf);
            lexer->bufInUse = 0;
        }
    } else if (tok != yajl_tok_error) {
        *outBuf = jsonText + startOffset;
        *outLen = *offset - startOffset;
    }

    /* special case for strings. skip the quotes. */
    if (tok == yajl_tok_string || tok == yajl_tok_string_with_escapes)
    {
        assert(*outLen >= 2);
        (*outBuf)++;
        *outLen -= 2;
    }


#ifdef YAJL_LEXER_DEBUG
    if (tok == yajl_tok_error) {
        printf("lexical error: %s\n",
               yajl_lex_error_to_string(yajl_lex_get_error(lexer)));
    } else if (tok == yajl_tok_eof) {
        printf("EOF hit\n");
    } else {
        printf("lexed %s: '", tokToStr(tok));
        fwrite(*outBuf, 1, *outLen, stdout);
        printf("'\n");
    }
#endif

    return tok;
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl_lex.c:499

yajl_lex_string typed

[c_null, c_string, c_int_na, *c_int_na] -> c(0..14)
timing: 11.60 s
source
yajl_lex_string(yajl_lexer lexer, const unsigned char * jsonText,
                size_t jsonTextLen, size_t * offset)
{
    yajl_tok tok = yajl_tok_error;
    int hasEscapes = 0;

    for (;;) {
        unsigned char curChar;

        /* now jump into a faster scanning routine to skip as much
         * of the buffers as possible */
        {
            const unsigned char * p;
            size_t len;

            if ((lexer->bufInUse && yajl_buf_len(lexer->buf) &&
                 lexer->bufOff < yajl_buf_len(lexer->buf)))
            {
                p = ((const unsigned char *) yajl_buf_data(lexer->buf) +
                     (lexer->bufOff));
                len = yajl_buf_len(lexer->buf) - lexer->bufOff;
                lexer->bufOff += yajl_string_scan(p, len, lexer->validateUTF8);
            }
            else if (*offset < jsonTextLen)
            {
                p = jsonText + *offset;
                len = jsonTextLen - *offset;
                *offset += yajl_string_scan(p, len, lexer->validateUTF8);
            }
        }

        STR_CHECK_EOF;

        curChar = readChar(lexer, jsonText, offset);

        /* quote terminates */
        if (curChar == '"') {
            tok = yajl_tok_string;
            break;
        }
        /* backslash escapes a set of control chars, */
        else if (curChar == '\\') {
            hasEscapes = 1;
            STR_CHECK_EOF;

            /* special case \u */
            curChar = readChar(lexer, jsonText, offset);
            if (curChar == 'u') {
                unsigned int i = 0;

                for (i=0;i<4;i++) {
                    STR_CHECK_EOF;
                    curChar = readChar(lexer, jsonText, offset);
                    if (!(charLookupTable[curChar] & VHC)) {
                        /* back up to offending char */
                        unreadChar(lexer, offset);
                        lexer->error = yajl_lex_string_invalid_hex_char;
                        goto finish_string_lex;
                    }
                }
            } else if (!(charLookupTable[curChar] & VEC)) {
                /* back up to offending char */
                unreadChar(lexer, offset);
                lexer->error = yajl_lex_string_invalid_escaped_char;
                goto finish_string_lex;
            }
        }
        /* when not validating UTF8 it's a simple table lookup to determine
         * if the present character is invalid */
        else if(charLookupTable[curChar] & IJC) {
            /* back up to offending char */
            unreadChar(lexer, offset);
            lexer->error = yajl_lex_string_invalid_json_char;
            goto finish_string_lex;
        }
        /* when in validate UTF8 mode we need to do some extra work */
        else if (lexer->validateUTF8) {
            yajl_tok t = yajl_lex_utf8_char(lexer, jsonText, jsonTextLen,
                                            offset, curChar);

            if (t == yajl_tok_eof) {
                tok = yajl_tok_eof;
                goto finish_string_lex;
            } else if (t == yajl_tok_error) {
                lexer->error = yajl_lex_string_invalid_utf8;
                goto finish_string_lex;
            }
        }
        /* accept it, and move on */
    }
  finish_string_lex:
    /* tell our buddy, the parser, wether he needs to process this string
     * again */
    if (hasEscapes && tok == yajl_tok_string) {
        tok = yajl_tok_string_with_escapes;
    }

    return tok;
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl_lex.c:268

yajl_object_free typed

[c_null] -> ()
timing: 0.021 s
source
static void yajl_object_free (yajl_val v)
{
    size_t i;

    if (!YAJL_IS_OBJECT(v)) return;

    for (i = 0; i < v->u.object.len; i++)
    {
        free((char *) v->u.object.keys[i]);
        v->u.object.keys[i] = NULL;
        yajl_tree_free (v->u.object.values[i]);
        v->u.object.values[i] = NULL;
    }

    free((void*) v->u.object.keys);
    free(v->u.object.values);
    free(v);
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl_tree.c:77

yajl_parse typed

([*struct yajl_handle_t, c_string, c_int_na] -> c(0..2))&([c_null, c_string, c_int_na] -> empty)
timing: 0.311 s
source
yajl_parse(yajl_handle hand, const unsigned char * jsonText,
           size_t jsonTextLen)
{
    yajl_status status;

    /* lazy allocation of the lexer */
    if (hand->lexer == NULL) {
        hand->lexer = yajl_lex_alloc(&(hand->alloc),
                                     hand->flags & yajl_allow_comments,
                                     !(hand->flags & yajl_dont_validate_strings));
    }

    status = yajl_do_parse(hand, jsonText, jsonTextLen);
    return status;
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl.c:118

yajl_render_error_string typed

([c_null, c_string, c_int_na, c_int_na] -> empty)&([*struct yajl_handle_t, c_string, c_int_na, c_int_na] \ [c_null, c_string, c_int_na, c_int_na] -> c_string)
timing: 0.401 s
source
yajl_render_error_string(yajl_handle hand, const unsigned char * jsonText,
                         size_t jsonTextLen, int verbose)
{
    size_t offset = hand->bytesConsumed;
    unsigned char * str;
    const char * errorType = NULL;
    const char * errorText = NULL;
    char text[72];
    const char * arrow = "                     (right here) ------^\n";

    if (yajl_bs_current(hand->stateStack) == yajl_state_parse_error) {
        errorType = "parse";
        errorText = hand->parseError;
    } else if (yajl_bs_current(hand->stateStack) == yajl_state_lexical_error) {
        errorType = "lexical";
        errorText = yajl_lex_error_to_string(yajl_lex_get_error(hand->lexer));
    } else {
        errorType = "unknown";
    }

    {
        size_t memneeded = 0;
        memneeded += strlen(errorType);
        memneeded += strlen(" error");
        if (errorText != NULL) {
            memneeded += strlen(": ");
            memneeded += strlen(errorText);
        }
        str = (unsigned char *) YA_MALLOC(&(hand->alloc), memneeded + 2);
        if (!str) return NULL;
        str[0] = 0;
        strcat((char *) str, errorType);
        strcat((char *) str, " error");
        if (errorText != NULL) {
            strcat((char *) str, ": ");
            strcat((char *) str, errorText);
        }
        strcat((char *) str, "\n");
    }

    /* now we append as many spaces as needed to make sure the error
     * falls at char 41, if verbose was specified */
    if (verbose) {
        size_t start, end, i;
        size_t spacesNeeded;

        spacesNeeded = (offset < 30 ? 40 - offset : 10);
        start = (offset >= 30 ? offset - 30 : 0);
        end = (offset + 30 > jsonTextLen ? jsonTextLen : offset + 30);

        for (i=0;i<spacesNeeded;i++) text[i] = ' ';

        for (;start < end;start++, i++) {
            if (jsonText[start] != '\n' && jsonText[start] != '\r')
            {
                text[i] = jsonText[start];
            }
            else
            {
                text[i] = ' ';
            }
        }
        assert(i <= 71);
        text[i++] = '\n';
        text[i] = 0;
        {
            char * newStr = (char *)
                YA_MALLOC(&(hand->alloc), (unsigned int)(strlen((char *) str) +
                                                         strlen((char *) text) +
                                                         strlen(arrow) + 1));
            if (newStr) {
                newStr[0] = 0;
                strcat((char *) newStr, (char *) str);
                strcat((char *) newStr, text);
                strcat((char *) newStr, arrow);
            }
            YA_FREE(&(hand->alloc), str);
            str = (unsigned char *) newStr;
        }
    }
    return str;
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl_parser.c:65

yajl_set_default_alloc_funcs typed

([*struct yajl_alloc_funcs] -> ())&([c_null] -> empty)
timing: 0.203 s
source
void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf)
{
    yaf->malloc = yajl_internal_malloc;
    yaf->free = yajl_internal_free;
    yaf->realloc = yajl_internal_realloc;
    yaf->ctx = NULL;
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl_alloc.c:45

yajl_string_decode typed empty return

[c_null, c_string, c_int_na] -> empty
timing: 0.204 s
source
void yajl_string_decode(yajl_buf buf, const unsigned char * str,
                        size_t len)
{
    size_t beg = 0;
    size_t end = 0;    

    while (end < len) {
        if (str[end] == '\\') {
            char utf8Buf[5];
            const char * unescaped = "?";
            yajl_buf_append(buf, str + beg, end - beg);
            switch (str[++end]) {
                case 'r': unescaped = "\r"; break;
                case 'n': unescaped = "\n"; break;
                case '\\': unescaped = "\\"; break;
                case '/': unescaped = "/"; break;
                case '"': unescaped = "\""; break;
                case 'f': unescaped = "\f"; break;
                case 'b': unescaped = "\b"; break;
                case 't': unescaped = "\t"; break;
                case 'u': {
                    unsigned int codepoint = 0;
                    hexToDigit(&codepoint, str + ++end);
                    end+=3;
                    /* check if this is a surrogate */
                    if ((codepoint & 0xFC00) == 0xD800) {
                        if (end + 2 < len && str[end + 1] == '\\' && str[end + 2] == 'u') {
                            end++;
                            unsigned int surrogate = 0;
                            hexToDigit(&surrogate, str + end + 2);
                            codepoint =
                                (((codepoint & 0x3F) << 10) | 
                                 ((((codepoint >> 6) & 0xF) + 1) << 16) | 
                                 (surrogate & 0x3FF));
                            end += 5;
                        } else {
                            unescaped = "?";
                            break;
                        }
                    }
                    
                    Utf32toUtf8(codepoint, utf8Buf);
                    unescaped = utf8Buf;

                    if (codepoint == 0) {
                        yajl_buf_append(buf, unescaped, 1);
                        beg = ++end;
                        continue;
                    }

                    break;
                }
                default:
                    assert("this should never happen" == NULL);
            }
            yajl_buf_append(buf, unescaped, (unsigned int)strlen(unescaped));
            beg = ++end;
        } else {
            end++;
        }
    }
    yajl_buf_append(buf, str + beg, end - beg);
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl_encode.c:116

yajl_tree_free typed

[c_null] -> ()
timing: 0.039 s
source
void yajl_tree_free (yajl_val v)
{
    if (v == NULL) return;

    if (YAJL_IS_STRING(v))
    {
        free(v->u.string);
        free(v);
    }
    else if (YAJL_IS_NUMBER(v))
    {
        free(v->u.number.r);
        free(v);
    }
    else if (YAJL_GET_OBJECT(v))
    {
        yajl_object_free(v);
    }
    else if (YAJL_GET_ARRAY(v))
    {
        yajl_array_free(v);
    }
    else /* if (yajl_t_true or yajl_t_false or yajl_t_null) */
    {
        free(v);
    }
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl_tree.c:496

base64_decode C signature

[c_string, c_int_na, *c_int_na] --> c_string
untypeable application
error detail
function: ([*('I23591 \ c_string), c_int_na, 'I23591] --> *('I23591 \ c_string)) & ([c_null, c_int_na, any] --> empty) & ([c_string, c_int_na, c_char] --> c_string)
argument: [(c_string | c_null) | 'I23571, c_char, c_int]
timing: 0.160 s
source
unsigned char * base64_decode(const unsigned char *src, size_t len,
			      size_t *out_len)
{
	unsigned char dtable[256], *out, *pos, in[4], block[4], tmp;
	size_t i, count;

	memset(dtable, 0x80, 256);
	for (i = 0; i < sizeof(base64_table); i++)
		dtable[base64_table[i]] = i;
	dtable['='] = 0;

	count = 0;
	for (i = 0; i < len; i++) {
		if (dtable[src[i]] != 0x80)
			count++;
	}

	if (count % 4)
		return NULL;

	pos = out = malloc(count);
	if (out == NULL)
		return NULL;

	count = 0;
	for (i = 0; i < len; i++) {
		tmp = dtable[src[i]];
		if (tmp == 0x80)
			continue;

		in[count] = src[i];
		block[count] = tmp;
		count++;
		if (count == 4) {
			*pos++ = (block[0] << 2) | (block[1] >> 4);
			*pos++ = (block[1] << 4) | (block[2] >> 2);
			*pos++ = (block[2] << 6) | block[3];
			count = 0;
		}
	}

	if (pos > out) {
		if (in[2] == '=')
			pos -= 2;
		else if (in[3] == '=')
			pos--;
	}

	*out_len = pos - out;
	return out;
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/base64.c:92

base64_encode C signature

[c_string, c_int_na, *c_int_na] --> c_string
untypeable application
error detail
function: ([c_int_na, c_int] --> c_int) & ([c_int_na, c_int_na] --> c_int_na)
argument: ['I23314 | c_char, c(2)]
timing: 0.664 s
source
unsigned char * base64_encode(const unsigned char *src, size_t len,
			      size_t *out_len)
{
	unsigned char *out, *pos;
	const unsigned char *end, *in;
	size_t olen;
	int line_len;

	olen = len * 4 / 3 + 4; /* 3-byte blocks to 4-byte */
	olen += olen / 72; /* line feeds */
	olen++; /* nul termination */
	out = malloc(olen);
	if (out == NULL)
		return NULL;

	end = src + len;
	in = src;
	pos = out;
	line_len = 0;
	while (end - in >= 3) {
		*pos++ = base64_table[in[0] >> 2];
		*pos++ = base64_table[((in[0] & 0x03) << 4) | (in[1] >> 4)];
		*pos++ = base64_table[((in[1] & 0x0f) << 2) | (in[2] >> 6)];
		*pos++ = base64_table[in[2] & 0x3f];
		in += 3;
		line_len += 4;
		if (line_len >= 72) {
			*pos++ = '\n';
			line_len = 0;
		}
	}

	if (end - in) {
		*pos++ = base64_table[in[0] >> 2];
		if (end - in == 1) {
			*pos++ = base64_table[(in[0] & 0x03) << 4];
			*pos++ = '=';
		} else {
			*pos++ = base64_table[((in[0] & 0x03) << 4) |
					      (in[1] >> 4)];
			*pos++ = base64_table[(in[1] & 0x0f) << 2];
		}
		*pos++ = '=';
		line_len += 4;
	}

	//if (line_len)
	//	*pos++ = '\n';

	*pos = '\0';
	if (out_len)
		*out_len = pos - out;
	return out;
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/base64.c:26

handle_number C signature

[c_ptr, c_string, c_int_na] --> c_int_na
untypeable application
error detail
function: ([*('I19734 \ c_string), c_int_na, 'I19734] --> *('I19734 \ c_string)) & ([c_null, c_int_na, any] --> empty) & ([c_string, c_int_na, c_char] --> c_string)
argument: [c_string, c_int_na & 'I19386, c_false]
timing: 0.252 s
source
static int handle_number (void *ctx, const char *string, size_t string_length)
{
    yajl_val v;
    char *endptr;

    v = value_alloc(yajl_t_number);
    if (v == NULL)
        RETURN_ERROR((context_t *) ctx, STATUS_ABORT, "Out of memory");

    v->u.number.r = malloc(string_length + 1);
    if (v->u.number.r == NULL)
    {
        free(v);
        RETURN_ERROR((context_t *) ctx, STATUS_ABORT, "Out of memory");
    }
    memcpy(v->u.number.r, string, string_length);
    v->u.number.r[string_length] = 0;

    v->u.number.flags = 0;

    errno = 0;
    v->u.number.i = yajl_parse_integer((const unsigned char *) v->u.number.r,
                                       strlen(v->u.number.r));
    if (errno == 0)
        v->u.number.flags |= YAJL_NUMBER_INT_VALID;

    endptr = NULL;
    errno = 0;
    v->u.number.d = strtod(v->u.number.r, &endptr);
    if ((errno == 0) && (endptr != NULL) && (*endptr == 0))
        v->u.number.flags |= YAJL_NUMBER_DOUBLE_VALID;

    return ((context_add_value(ctx, v) == 0) ? STATUS_CONTINUE : STATUS_ABORT);
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl_tree.c:299

handle_string C signature

[c_ptr, c_string, c_int_na] --> c_int_na
untypeable application
error detail
function: ([*('I20335 \ c_string), c_int_na, 'I20335] --> *('I20335 \ c_string)) & ([c_null, c_int_na, any] --> empty) & ([c_string, c_int_na, c_char] --> c_string)
argument: [c_string, c_int_na & 'I20128, c_false]
timing: 0.264 s
source
static int handle_string (void *ctx,
                          const unsigned char *string, size_t string_length)
{
    yajl_val v;

    v = value_alloc (yajl_t_string);
    if (v == NULL)
        RETURN_ERROR ((context_t *) ctx, STATUS_ABORT, "Out of memory");

    v->u.string = malloc (string_length + 1);
    if (v->u.string == NULL)
    {
        free (v);
        RETURN_ERROR ((context_t *) ctx, STATUS_ABORT, "Out of memory");
    }
    memcpy(v->u.string, string, string_length);
    v->u.string[string_length] = 0;

    return ((context_add_value (ctx, v) == 0) ? STATUS_CONTINUE : STATUS_ABORT);
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl_tree.c:278

hexToDigit C signature

[*c_int_na, c_string] --> c_void
untypeable application
error detail
function: ([c_int_na, c_int] --> c_int) & ([c_int_na, c_int_na] --> c_int_na)
argument: [c_char, c_int]
timing: 0.022 s
source
static void hexToDigit(unsigned int * val, const unsigned char * hex)
{
    unsigned int i;
    for (i=0;i<4;i++) {
        unsigned char c = hex[i];
        if (c >= 'A') c = (c & ~0x20) - 7;
        c -= '0';
        assert(!(c & 0xF0));
        *val = (*val << 4) | c;
    }
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl_encode.c:78

modp_dtoa2 C signature

[c_double, c_string, c_int_na] --> c_int_na
untypeable application
error detail
function: [c_int, c_int] --> c_int
argument: [c_int_na, c(10)]
timing: 12.70 s
source
size_t modp_dtoa2(double value, char* str, int prec)
{
	/* Hacky test for NaN
	 * under -fast-math this won't work, but then you also won't
	 * have correct nan values anyways.  The alternative is
	 * to link with libmath (bad) or hack IEEE double bits (bad)
	 */
	if (! (value == value)) {
		str[0] = 'n'; str[1] = 'a'; str[2] = 'n'; str[3] = '\0';
		return (size_t) 3;
	}

	/* if input is larger than thres_max, revert to exponential */
	const double thres_max = (double)(0x7FFFFFFF);

	double diff = 0.0;
	char* wstr = str;

	if (prec < 0) {
		prec = 0;
	} else if (prec > 9) {
		/* precision of >= 10 can lead to overflow errors */
		prec = 9;
	}

	/* we'll work in positive values and deal with the
	   negative sign issue later */
	int neg = 0;
	if (value < 0) {
		neg = 1;
		value = -value;
	}

	int whole = (int) value;
	double tmp = (value - whole) * powers_of_10[prec];
	uint32_t frac = (uint32_t)(tmp);
	diff = tmp - frac;

	if (diff > 0.5) {
		++frac;
		/* handle rollover, e.g.  case 0.99 with prec 1 is 1.0  */
		if (frac >= powers_of_10[prec]) {
			frac = 0;
			++whole;
		}
	} else if (diff == 0.5 && prec > 0 && (frac & 1)) {
		/* if halfway, round up if odd, OR
		   if last digit is 0.  That last part is strange */
		++frac;
		if (frac >= powers_of_10[prec]) {
			frac = 0;
			++whole;
		}
	} else if (diff == 0.5 && prec == 0 && (whole & 1)) {
		++frac;
		if (frac >= powers_of_10[prec]) {
			frac = 0;
			++whole;
		}
	}

	/* for very large numbers switch back to native sprintf for exponentials.
	   anyone want to write code to replace this? */
	/*
	   normal printf behavior is to print EVERY whole number digit
	   which can be 100s of characters overflowing your buffers == bad
	   */
	if (value > thres_max) {
	  snprintf(str, 13, "%e", neg ? -value : value);
		return strlen(str);
	}

	int has_decimal = 0;
	int count = prec;

	/* Remove ending zeros */
	if (prec > 0) {
		while (count > 0 && ((frac % 10) == 0)) {
			count--;
			frac /= 10;
		}
	}

	while (count > 0) {
		--count;
		*wstr++ = (char)(48 + (frac % 10));
		frac /= 10;
		has_decimal = 1;
	}

	if (frac > 0) {
		++whole;
	}

	/* add decimal */
	if (has_decimal) {
		*wstr++ = '.';
	}
	/* do whole part
	 * Take care of sign conversion
	 * Number is reversed.
	 */
	do *wstr++ = (char)(48 + (whole % 10)); while (whole /= 10);
	if (neg) {
		*wstr++ = '-';
	}
	*wstr='\0';
	strreverse(str, wstr-1);
	return (size_t)(wstr - str);
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/modp_numtoa.c:201

modp_itoa10 C signature

[c_int_na, c_string] --> c_int_na
untypeable application
error detail
function: [c_int, c_int] --> c_int
argument: [c_int_na, c(10)]
timing: 0.122 s
source
size_t modp_itoa10(int32_t value, char* str)
{
	char* wstr=str;
	/* Take care of sign */
	uint32_t uvalue = (value < 0) ? (uint32_t)(-value) : (uint32_t)(value);
	/* Conversion. Number is reversed. */
	do *wstr++ = (char)(48 + (uvalue % 10)); while(uvalue /= 10);
	if (value < 0) *wstr++ = '-';
	*wstr='\0';

	/* Reverse string */
	strreverse(str,wstr-1);
	return (size_t)(wstr - str);
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/modp_numtoa.c:39

modp_litoa10 C signature

[c_int_na, c_string] --> c_int_na
untypeable application
error detail
function: [c_int, c_int] --> c_int
argument: [c_int_na, c(10)]
timing: 0.126 s
source
size_t modp_litoa10(int64_t value, char* str)
{
	char* wstr=str;
	uint64_t uvalue = (value < 0) ? (uint64_t)(-value) : (uint64_t)(value);

	/* Conversion. Number is reversed. */
	do *wstr++ = (char)(48 + (uvalue % 10)); while(uvalue /= 10);
	if (value < 0) *wstr++ = '-';
	*wstr='\0';

	/* Reverse string */
	strreverse(str,wstr-1);
	return (size_t)(wstr - str);
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/modp_numtoa.c:65

Utf32toUtf8 C signature

[c_int_na, c_string] --> c_void
untypeable application
error detail
function: ([*('I7042 \ c_string), c_int_na, 'I7042] --> *('I7042 \ c_string)) & ([c_null, c_int_na, any] --> empty) & ([c_string, c_int_na, c_char] --> c_string)
argument: [c_string, c_true, c_false]
timing: 3.41 s
source
static void Utf32toUtf8(unsigned int codepoint, char * utf8Buf) 
{
    if (codepoint < 0x80) {
        utf8Buf[0] = (char) codepoint;
        utf8Buf[1] = 0;
    } else if (codepoint < 0x0800) {
        utf8Buf[0] = (char) ((codepoint >> 6) | 0xC0);
        utf8Buf[1] = (char) ((codepoint & 0x3F) | 0x80);
        utf8Buf[2] = 0;
    } else if (codepoint < 0x10000) {
        utf8Buf[0] = (char) ((codepoint >> 12) | 0xE0);
        utf8Buf[1] = (char) (((codepoint >> 6) & 0x3F) | 0x80);
        utf8Buf[2] = (char) ((codepoint & 0x3F) | 0x80);
        utf8Buf[3] = 0;
    } else if (codepoint < 0x200000) {
        utf8Buf[0] =(char)((codepoint >> 18) | 0xF0);
        utf8Buf[1] =(char)(((codepoint >> 12) & 0x3F) | 0x80);
        utf8Buf[2] =(char)(((codepoint >> 6) & 0x3F) | 0x80);
        utf8Buf[3] =(char)((codepoint & 0x3F) | 0x80);
        utf8Buf[4] = 0;
    } else {
        utf8Buf[0] = '?';
        utf8Buf[1] = 0;
    }
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl_encode.c:90

YA_FREE C signature

tuple2 --> any
untypeable application
error detail
function: any
argument: ['I2076, 'I2074]
timing: 0.060 s
(definition not located in src/)

YA_MALLOC C signature

tuple2 --> any
untypeable application
error detail
function: any
argument: ['I2094, 'I2092]
timing: 0.035 s
(definition not located in src/)

YA_REALLOC C signature

tuple3 --> any
untypeable application
error detail
function: any
argument: ['I2058, 'I2055, 'I2056]
timing: 0.033 s
(definition not located in src/)

yajl_alloc C signature

[*struct yajl_callbacks, *struct yajl_alloc_funcs, c_ptr] --> *struct yajl_handle_t
untypeable application
error detail
function: [record, 'I3347] --> 'I3347
argument: [struct yajl_bytestack_t, *struct yajl_alloc_funcs]
timing: 4.47 s
source
yajl_alloc(const yajl_callbacks * callbacks,
           yajl_alloc_funcs * afs,
           void * ctx)
{
    yajl_handle hand = NULL;
    yajl_alloc_funcs afsBuffer;

    /* first order of business is to set up memory allocation routines */
    if (afs != NULL) {
        if (afs->malloc == NULL || afs->realloc == NULL || afs->free == NULL)
        {
            return NULL;
        }
    } else {
        yajl_set_default_alloc_funcs(&afsBuffer);
        afs = &afsBuffer;
    }

    hand = (yajl_handle) YA_MALLOC(afs, sizeof(struct yajl_handle_t));

    /* copy in pointers to allocation routines */
    memcpy((void *) &(hand->alloc), (void *) afs, sizeof(yajl_alloc_funcs));

    hand->callbacks = callbacks;
    hand->ctx = ctx;
    hand->lexer = NULL; 
    hand->bytesConsumed = 0;
    hand->decodeBuf = yajl_buf_alloc(&(hand->alloc));
    hand->flags	    = 0;
    yajl_bs_init(hand->stateStack, &(hand->alloc));
    yajl_bs_push(hand->stateStack, yajl_state_start);

    return hand;
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl.c:46

yajl_config C signature

any --> c_int_na
unbound variable
error detail
name: int
timing: 0.015 s
source
yajl_config(yajl_handle h, yajl_option opt, ...)
{
    int rv = 1;
    va_list ap;
    va_start(ap, opt);

    switch(opt) {
        case yajl_allow_comments:
        case yajl_dont_validate_strings:
        case yajl_allow_trailing_garbage:
        case yajl_allow_multiple_values:
        case yajl_allow_partial_values:
            if (va_arg(ap, int)) h->flags |= opt;
            else h->flags &= ~opt;
            break;
        default:
            rv = 0;
    }
    va_end(ap);

    return rv;
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl.c:82

yajl_lex_utf8_char C signature

[*struct yajl_lexer_t, c_string, c_int_na, *c_int_na, c_char] --> c(0..14)
untypeable application
error detail
function: ([c_int_na, c_int] --> c_int) & ([c_int_na, c_int_na] --> c_int_na)
argument: ['I5615 & c_char, c(5)]
timing: 0.035 s
source
yajl_lex_utf8_char(yajl_lexer lexer, const unsigned char * jsonText,
                   size_t jsonTextLen, size_t * offset,
                   unsigned char curChar)
{
    if (curChar <= 0x7f) {
        /* single byte */
        return yajl_tok_string;
    } else if ((curChar >> 5) == 0x6) {
        /* two byte */
        UTF8_CHECK_EOF;
        curChar = readChar(lexer, jsonText, offset);
        if ((curChar >> 6) == 0x2) return yajl_tok_string;
    } else if ((curChar >> 4) == 0x0e) {
        /* three byte */
        UTF8_CHECK_EOF;
        curChar = readChar(lexer, jsonText, offset);
        if ((curChar >> 6) == 0x2) {
            UTF8_CHECK_EOF;
            curChar = readChar(lexer, jsonText, offset);
            if ((curChar >> 6) == 0x2) return yajl_tok_string;
        }
    } else if ((curChar >> 3) == 0x1e) {
        /* four byte */
        UTF8_CHECK_EOF;
        curChar = readChar(lexer, jsonText, offset);
        if ((curChar >> 6) == 0x2) {
            UTF8_CHECK_EOF;
            curChar = readChar(lexer, jsonText, offset);
            if ((curChar >> 6) == 0x2) {
                UTF8_CHECK_EOF;
                curChar = readChar(lexer, jsonText, offset);
                if ((curChar >> 6) == 0x2) return yajl_tok_string;
            }
        }
    }

    return yajl_tok_error;
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl_lex.c:195

yajl_parse_integer C signature

[c_string, c_int_na] --> c_int_na
unbound variable
error detail
name: MAX_VALUE_TO_MULTIPLY
timing: 0.571 s
source
yajl_parse_integer(const unsigned char *number, unsigned int length)
{
    long long ret  = 0;
    long sign = 1;
    const unsigned char *pos = number;
    if (*pos == '-') { pos++; sign = -1; }
    if (*pos == '+') { pos++; }

    while (pos < number + length) {
        if ( ret > MAX_VALUE_TO_MULTIPLY ) {
            errno = ERANGE;
            return sign == 1 ? LLONG_MAX : LLONG_MIN;
        }
        ret *= 10;
        if (LLONG_MAX - ret < (*pos - '0')) {
            errno = ERANGE;
            return sign == 1 ? LLONG_MAX : LLONG_MIN;
        }
        if (*pos < '0' || *pos > '9') {
            errno = ERANGE;
            return sign == 1 ? LLONG_MAX : LLONG_MIN;
        }
        ret += (*pos++ - '0');
    }

    return sign * ret;
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl_parser.c:36

yajl_string_scan C signature

[c_string, c_int_na, c_int_na] --> c_int_na
untypeable application
error detail
function: ([*('I5748 \ c_string), c_int_na] --> 'I5748) & ([c_null, c_int_na] --> empty) & ([c_string, c_int_na] --> c_char)
argument: [c_string, 'I5742 | c_char]
timing: 0.105 s
source
yajl_string_scan(const unsigned char * buf, size_t len, int utf8check)
{
    unsigned char mask = IJC|NFP|(utf8check ? NUC : 0);
    size_t skip = 0;
    while (skip < len && !(charLookupTable[*buf] & mask))
    {
        skip++;
        buf++;
    }
    return skip;
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl_lex.c:255

yajl_tree_parse C signature

[c_string, c_string, c_int_na] --> *struct yajl_val_s
untypeable application
error detail
function: [c_null] --> ()
argument: [*struct yajl_val_s]
timing: 0.459 s
source
yajl_val yajl_tree_parse (const char *input,
                          char *error_buffer, size_t error_buffer_size)
{
    static const yajl_callbacks callbacks =
        {
            /* null        = */ handle_null,
            /* boolean     = */ handle_boolean,
            /* integer     = */ NULL,
            /* double      = */ NULL,
            /* number      = */ handle_number,
            /* string      = */ handle_string,
            /* start map   = */ handle_start_map,
            /* map key     = */ handle_string,
            /* end map     = */ handle_end_map,
            /* start array = */ handle_start_array,
            /* end array   = */ handle_end_array
        };

    yajl_handle handle;
    yajl_status status;
    char * internal_err_str;
	context_t ctx = { NULL, NULL, NULL, 0 };

	ctx.errbuf = error_buffer;
	ctx.errbuf_size = error_buffer_size;

    if (error_buffer != NULL)
        memset (error_buffer, 0, error_buffer_size);

    handle = yajl_alloc (&callbacks, NULL, &ctx);
    yajl_config(handle, yajl_allow_comments, 1);

    status = yajl_parse(handle,
                        (unsigned char *) input,
                        strlen (input));

    //fix by jeroen
    if(status == yajl_status_ok){
      status = yajl_complete_parse (handle);
    }
    //end of fix
    if (status != yajl_status_ok) {
        if (error_buffer != NULL && error_buffer_size > 0) {
               internal_err_str = (char *) yajl_get_error(handle, 1,
                     (const unsigned char *) input,
                     strlen(input));
             snprintf(error_buffer, error_buffer_size, "%s", internal_err_str);
             YA_FREE(&(handle->alloc), internal_err_str);
        }
        while(ctx.stack != NULL) {
             yajl_val v = context_pop(&ctx);
             yajl_tree_free(v);
        }
        yajl_free (handle);
        //If the requested memory is not released in time, it will cause memory leakage
        if(ctx.root)
             yajl_tree_free(ctx.root);
        return NULL;
    }

    yajl_free (handle);
    return (ctx.root);
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl_tree.c:410

C_row_collapse_array untypeable entry .Call

untypeable application
error detail
function: ([INT] --> *c_int_na) & ([^INT1] --> *c_int)
argument: [INT | null]
timing: 0.027 s
source
SEXP C_row_collapse_array(SEXP m, SEXP indent){
  //get matrix dimensions
  int *dims = INTEGER(getAttrib(m, R_DimSymbol));
  int x = dims[0];
  int y = dims[1];

  //allocate the output vector
  SEXP out = PROTECT(allocVector(STRSXP, x));
  SEXP vec = PROTECT(allocVector(STRSXP, y));
  for(int i = 0; i < x; i++) {
    for(int j = 0; j < y; j++) {
      SET_STRING_ELT(vec, j, STRING_ELT(m, j*x + i));
    }
    if(asInteger(indent) == NA_INTEGER){
      SET_STRING_ELT(out, i, STRING_ELT(C_collapse_array(vec), 0));
    } else {
      SET_STRING_ELT(out, i, STRING_ELT(C_collapse_array_pretty_inner(vec), 0));
    }
  }
  UNPROTECT(2);
  return out;
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/row_collapse.c:34

C_row_collapse_object untypeable entry .Call

untypeable application
error detail
function: ([INT] --> *c_int_na) & ([^INT1] --> *c_int)
argument: [INT | null]
timing: 0.028 s
source
SEXP C_row_collapse_object(SEXP names, SEXP m, SEXP indent){
  //get matrix dimensions
  int *dims = INTEGER(getAttrib(m, R_DimSymbol));
  int x = dims[0];
  int y = dims[1];

  //allocate the output vector
  SEXP out = PROTECT(allocVector(STRSXP, x));
  SEXP vec = PROTECT(allocVector(STRSXP, y));
  for(int i = 0; i < x; i++) {
    for(int j = 0; j < y; j++) {
      SET_STRING_ELT(vec, j, STRING_ELT(m, j*x + i));
    }
    if(asInteger(indent) == NA_INTEGER){
      SET_STRING_ELT(out, i, STRING_ELT(C_collapse_object(names, vec), 0));
    } else {
      SET_STRING_ELT(out, i, STRING_ELT(C_collapse_object_pretty(names, vec, indent), 0));
    }
  }
  UNPROTECT(2);
  return out;
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/row_collapse.c:10

C_transpose_list untypeable entry .Call

untypeable application
error detail
function: [CHR & v('I28014), c_int] --> prim & 'I28014
argument: [CHR | null, c_int]
timing: 1.60 s
source
SEXP C_transpose_list(SEXP x, SEXP names) {
  size_t ncol = Rf_length(names);
  size_t nrow = Rf_length(x);
  SEXP out = PROTECT(allocVector(VECSXP, ncol));
  for(size_t i = 0; i < ncol; i++){
    const char * targetname = CHAR(STRING_ELT(names, i));
    SEXP col = PROTECT(allocVector(VECSXP, nrow));
    for(size_t j = 0; j < nrow; j++){
      //search for 'targetname' in each record j
      SEXP list = VECTOR_ELT(x, j);
      SEXP listnames = getAttrib(list, R_NamesSymbol);
      for(size_t k = 0; k < Rf_length(listnames); k++){
        if(!strcmp(CHAR(STRING_ELT(listnames, k)), targetname)){
          SET_VECTOR_ELT(col, j, VECTOR_ELT(list, k));
          break;
        }
      }
    }
    SET_VECTOR_ELT(out, i, col);
    UNPROTECT(1);
  }
  //setAttrib(out, R_NamesSymbol, names);
  UNPROTECT(1);
  return out;
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/transpose_list.c:4

R_integer64_to_char untypeable entry .Call

unbound variable
error detail
name: LLONG_MIN
timing: 0.189 s
source
SEXP R_integer64_to_char(SEXP x, SEXP na_as_string){
  int len = length(x);
  int na_string = asLogical(na_as_string);
  long long * xint = (long long *) REAL(x);
  char buf[32];
  SEXP out = PROTECT(allocVector(STRSXP, len));
  for (int i = 0; i < len; i++) {
    if(xint[i] == NA_INTEGER64){
      if(na_string == NA_LOGICAL){
        SET_STRING_ELT(out, i, NA_STRING);
      } else if(na_string){
        SET_STRING_ELT(out, i, mkChar("\"NA\""));
      } else {
        SET_STRING_ELT(out, i, mkChar("null"));
      }
    } else {
      #ifdef _WIN32
        snprintf(buf, 32, "%lld", xint[i]);
      #else
        //snprintf(buf, 32, "%lld", xint[i]);
        //modp is faster (but does not work on windows)
        modp_litoa10(xint[i], buf);
      #endif
      SET_STRING_ELT(out, i, mkChar(buf));
    }
  }
  UNPROTECT(1);
  return out;
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/integer64_to_na.c:5

R_parse untypeable entry .Call

untypeable application
error detail
function: [c_string, c_string, c_int_na] --> *struct yajl_val_s
argument: [(c_string | c_null) | (*('I24673 \ c_string) | c_string) & 'I24638, c_string | c_null, c_int]
timing: 1.20 s
source
SEXP R_parse(SEXP x, SEXP bigint_as_char) {
    /* get data from R */
    const char* json = translateCharUTF8(asChar(x));
    const int bigint = asLogical(bigint_as_char);

    /* ignore BOM as suggested by RFC */
    if(json[0] == '\xEF' && json[1] == '\xBB' && json[2] == '\xBF'){
      warningcall(R_NilValue, "JSON string contains (illegal) UTF8 byte-order-mark!");
      json = json + 3;
    }

    /* ignore rfc7464 record separator */
    if(json[0] == '\x1E'){
      json = json + 1;
    }

    /* parse json */
    char errbuf[1024];
    yajl_val node = yajl_tree_parse(json, errbuf, sizeof(errbuf));

    /* parser error */
    if (!node) {
      Rf_errorcall(R_NilValue, "%s", errbuf);
    }
    SEXP out = ParseValue(node, bigint);
    yajl_tree_free(node);
    return(out);
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/parse.c:16

R_parse_connection untypeable entry .Call

untypeable application
error detail
function: [raw] --> *c_int
argument: [any_sexp]
timing: 0.359 s
source
SEXP R_parse_connection(SEXP sConn, SEXP bigint_as_char){
  int first = 1;
  char errbuf[bufsize];
  unsigned char * errstr;
  yajl_handle push_parser = push_parser_new();
  SEXP call = PROTECT(Rf_lang4(
    PROTECT(Rf_install("readBin")),
    sConn,
    PROTECT(Rf_allocVector(RAWSXP, 0)),
    PROTECT(Rf_ScalarInteger(bufsize))));
  while(1){
    SEXP out = PROTECT(Rf_eval(call, R_BaseEnv));
    int len = Rf_length(out);
    if(len <= 0){
      UNPROTECT(1);
      break;
    }
    unsigned char * ptr = RAW(out);

    //strip off BOM
    if(first && len > 3 && ptr[0] == 239 && ptr[1] == 187 && ptr[2] == 191){
      warningcall(R_NilValue, "JSON string contains (illegal) UTF8 byte-order-mark!");
      ptr += 3;
      len -= 3;
    }

    //strip off rfc7464 record separator
    if(first && len > 1 && ptr[0] == 30){
      ptr += 1;
      len -= 1;
    }

    first = 0;

    /* parse and check for errors */
    if (yajl_parse(push_parser, ptr, len) != yajl_status_ok){
      errstr = yajl_get_error(push_parser, 1, ptr, len);
      goto JSON_FAIL;
    }
    UNPROTECT(1);
  }
  UNPROTECT(4);

  /* complete parse */
  if (yajl_complete_parse(push_parser) != yajl_status_ok){
    errstr = yajl_get_error(push_parser, 1, NULL, 0);
    goto JSON_FAIL;
  }

  /* get output */
  yajl_val tree = push_parser_get(push_parser);
  SEXP out = PROTECT(ParseValue(tree, asLogical(bigint_as_char)));
  yajl_tree_free(tree);
  yajl_free(push_parser);
  UNPROTECT(1);
  return out;

  JSON_FAIL:
    strncpy(errbuf, (char *) errstr, bufsize - 1);
    yajl_free_error(push_parser, errstr);
    yajl_free(push_parser);
    Rf_error("%s", errbuf);
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/push_parser.c:10

R_reformat untypeable entry .Call

untypeable application
error detail
function: [c_null] --> empty
argument: [*struct yajl_gen_t]
timing: 5.46 s
source
SEXP R_reformat(SEXP x, SEXP pretty, SEXP indent_string) {
    yajl_status stat;
    yajl_handle hand;
    yajl_gen g;
    SEXP output;

    /* init generator */
    g = yajl_gen_alloc(NULL);
    yajl_gen_config(g, yajl_gen_beautify, asInteger(pretty));
    yajl_gen_config(g, yajl_gen_indent_string, translateCharUTF8(asChar(indent_string)));
    yajl_gen_config(g, yajl_gen_validate_utf8, 0);
    yajl_gen_config(g, yajl_gen_escape_solidus, 1); //modified to only escape for "</"

    /* init parser */
    hand = yajl_alloc(&callbacks, NULL, (void *) g);
    yajl_config(hand, yajl_allow_comments, 1);

    /* get data from R */
    const char* json = translateCharUTF8(asChar(x));

    /* ignore BOM */
    if(json[0] == '\xEF' && json[1] == '\xBB' && json[2] == '\xBF'){
      json = json + 3;
    }

    /* Get length (after removing bom) */
    const size_t rd = strlen(json);

    /* parse */
    stat = yajl_parse(hand, (const unsigned char*) json, rd);
    if(stat == yajl_status_ok) {
      stat = yajl_complete_parse(hand);
    }

    //error message
    if (stat != yajl_status_ok) {
      unsigned char* str = yajl_get_error(hand, 1, (const unsigned char*) json, rd);
      output = PROTECT(mkString((const char*) str));
      yajl_free_error(hand, str);
    } else {
      //create R object
      const unsigned char* buf;
      size_t len;
      yajl_gen_get_buf(g, &buf, &len);

      //force as UTF8 string
      output = PROTECT(allocVector(STRSXP, 1));
      SET_STRING_ELT(output, 0, mkCharCE((const char*) buf, CE_UTF8));
      setAttrib(output, R_ClassSymbol, mkString("json"));
    }

    /* clean up */
    yajl_gen_clear(g);
    yajl_gen_free(g);
    yajl_free(hand);

    /* return boolean vec (0 means no errors, means is valid) */
    SEXP vec = PROTECT(allocVector(VECSXP, 2));
    SET_VECTOR_ELT(vec, 0, ScalarInteger(stat));
    SET_VECTOR_ELT(vec, 1, output);
    UNPROTECT(2);
    return vec;
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/prettify.c:87

R_validate untypeable entry .Call

untypeable application
error detail
function: [c_null] --> empty
argument: [*struct yajl_handle_t]
timing: 1.24 s
source
SEXP R_validate(SEXP x) {
    /* get data from R */
    const char* json = translateCharUTF8(asChar(x));

    /* test for BOM */
    if(json[0] == '\xEF' && json[1] == '\xBB' && json[2] == '\xBF'){
      SEXP output = PROTECT(duplicate(ScalarLogical(0)));
      SEXP msg = PROTECT(Rf_mkString("JSON string contains UTF8 byte-order-mark."));
      setAttrib(output, install("err"), msg);
      UNPROTECT(2);
      return(output);
    }

    /* allocate a parser */
    yajl_handle hand = yajl_alloc(NULL, NULL, NULL);

    /* parser options */
    //yajl_config(hand, yajl_dont_validate_strings, 1);

    /* go parse */
    const size_t rd = strlen(json);
    yajl_status stat = yajl_parse(hand, (const unsigned char*) json, rd);
    if(stat == yajl_status_ok) {
      stat = yajl_complete_parse(hand);
    }

    SEXP output = PROTECT(duplicate(ScalarLogical(!stat)));

    //error message
    if (stat != yajl_status_ok) {
        unsigned char* str = yajl_get_error(hand, 1, (const unsigned char*) json, rd);
        SEXP errstr = PROTECT(mkString((const char *) str));
        SEXP offset = PROTECT(ScalarInteger(yajl_get_bytes_consumed(hand)));
        yajl_free_error(hand, str);
        setAttrib(output, install("offset"), offset);
        setAttrib(output, install("err"), errstr);
        UNPROTECT(2);
    }

    /* return boolean vec (0 means no errors, means is valid) */
    yajl_free(hand);
    UNPROTECT(1);
    return output;
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/validate.c:5

C_collapse_object_pretty timeout entry .Call

timing: 20.00 s
source
SEXP C_collapse_object_pretty(SEXP x, SEXP y, SEXP indent) {
  if (!isString(x) || !isString(y))
    error("x and y must character vectors.");
  int ni = asInteger(indent);
  int spaces = asInteger(Rf_getAttrib(indent, Rf_install("indent_spaces")));
  if(ni == NA_INTEGER)
    error("indent must not be NA");
  if(spaces == NA_INTEGER)
    error("ni_inside must not be NA");
  char indent_char = ' ';
  if(spaces < 0){
    spaces = -1 * spaces;
    indent_char = '\t';
  }

  int len = length(x);
  if (len != length(y))
    error("x and y must have same length.");

  //calculate required space
  size_t nchar_total = 0;
  for (int i=0; i<len; i++) {
    if(STRING_ELT(y, i) == NA_STRING) continue;
    nchar_total += strlen(translateCharUTF8(STRING_ELT(x, i)));
    nchar_total += strlen(translateCharUTF8(STRING_ELT(y, i)));
    nchar_total += ni + spaces + 4; //indent plus plus ": " and ",\n"
  }

  //final indent plus curly braces and linebreak and terminator
  nchar_total += (ni + 2 + 2);

  //allocate memory and create a cursor
  char *str = malloc(nchar_total);
  char *cursor = str;
  char **cur = &cursor;

  //init object
  append_text(cur, "{", 1);
  const char *start = *cur;

  //copy everything
  for (int i=0; i<len; i++) {
    if(STRING_ELT(y, i) == NA_STRING) continue;
    append_text(cur, "\n", 1);
    append_whitespace(cur, ni + spaces, indent_char);
    append_text(cur, translateCharUTF8(STRING_ELT(x, i)), -1);
    append_text(cur, ": ", 2);
    append_text(cur, translateCharUTF8(STRING_ELT(y, i)), -1);
    append_text(cur, ",", 1);
  }

  //finalize object
  if(cursor != start){
    cursor[-1] = '\n';
    append_whitespace(cur, ni, indent_char);
  }
  append_text(cur, "}\0", 2);

  //encode as UTF8 string
  SEXP out = PROTECT(allocVector(STRSXP, 1));
  SET_STRING_ELT(out, 0, mkCharCE(str,  CE_UTF8));
  UNPROTECT(1);
  free(str);
  return out;
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/collapse_pretty.c:20

C_escape_chars_one timeout

timing: 20.00 s
source
SEXP C_escape_chars_one(SEXP x) {

  // Make a cursor pointer
  const char * cur = CHAR(x);
  const char * end = CHAR(x) + Rf_length(x);

  // Count the number of matches
  int matches = 0;
  while (cur < end) {
    switch(*cur) {
      case '\\':
      case '"':
      case '\n':
      case '\r':
      case '\t':
      case '\b':
      case '\f':
        matches++;
        break;
      case '/':
        if(cur > CHAR(x) && cur[-1] == '<')
          matches++;
        break;
      default:
        if (*cur >= 0x00 && *cur <= 0x1f)
          matches += 5; //needs explicit \u00xx escaping
    }
    cur++;
  }

  // Calculate output length, 2 for double quotes
  size_t outlen = Rf_length(x) + matches + 2;
  char * newstr = malloc(outlen);

  // Reset cursor to beginning
  cur = CHAR(x);

  // Allocate string memory; add 2 for start and end quotes.
  char * outcur = newstr;
  *outcur++ = '"';

  while(cur < end) {
    switch(*cur) {
      case '\\':
        *outcur++ = '\\';
        *outcur = '\\';
        break;
      case '"':
        *outcur++ = '\\';
        *outcur = '"';
        break;
      case '\n':
        *outcur++ = '\\';
        *outcur = 'n';
        break;
      case '\r':
        *outcur++ = '\\';
        *outcur = 'r';
        break;
      case '\t':
        *outcur++ = '\\';
        *outcur = 't';
        break;
      case '\b':
        *outcur++ = '\\';
        *outcur = 'b';
        break;
      case '\f':
        *outcur++ = '\\';
        *outcur = 'f';
        break;
      case '/':
        if(cur > CHAR(x) && cur[-1] == '<'){
          *outcur++ = '\\';
          *outcur = '/';
          break;
        } //FALL THROUGH!
      default:
        //control characters need explicit \u00xx escaping
        if (*cur >= 0x00 && *cur <= 0x1f){
          snprintf(outcur, 7, "\\u%04x", *cur);
          outcur += 5; //extra length
          break;
        }
        //simply copy char from input
        *outcur = *cur;
    }

    //increment input and output cursors to next character
    cur++;
    outcur++;
  }

  //Close quote and create R string
  *outcur = '"';
  SEXP out = mkCharLenCE(newstr, outlen, getCharCE(x));
  free(newstr);
  return out;
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/escape_chars.c:10

C_null_to_na timeout entry .Call

timing: 20.00 s
source
SEXP C_null_to_na(SEXP x) {
  int len = length(x);
  if(len == 0) return x;

  //null always turns into NA
  bool looks_like_character_vector = false;
  for (int i=0; i<len; i++) {
    if(VECTOR_ELT(x, i) == R_NilValue) {
      SET_VECTOR_ELT(x, i, ScalarLogical(NA_LOGICAL));
    } else if(!looks_like_character_vector && TYPEOF(VECTOR_ELT(x, i)) == STRSXP){
      if((strcmp("NA", CHAR(STRING_ELT(VECTOR_ELT(x, i), 0))) == 0) ||
         (strcmp("NaN", CHAR(STRING_ELT(VECTOR_ELT(x, i), 0))) == 0) ||
         (strcmp("Inf", CHAR(STRING_ELT(VECTOR_ELT(x, i), 0))) == 0) ||
         (strcmp("-Inf", CHAR(STRING_ELT(VECTOR_ELT(x, i), 0))) == 0)) continue;
      looks_like_character_vector = true;
    }
  }

  // if this is a character vector, do not parse NA strings.
  if(looks_like_character_vector) return(x);

  //parse NA strings
  for (int i=0; i<len; i++) {
    if(TYPEOF(VECTOR_ELT(x, i)) == STRSXP){
      if(strcmp("NA", CHAR(STRING_ELT(VECTOR_ELT(x, i), 0))) == 0) {
        SET_VECTOR_ELT(x, i, ScalarLogical(NA_LOGICAL));
        continue;
      }
      if(strcmp("NaN", CHAR(STRING_ELT(VECTOR_ELT(x, i), 0))) == 0) {
        SET_VECTOR_ELT(x, i, ScalarReal(R_NaN));
        continue;
      }
      if(strcmp("Inf", CHAR(STRING_ELT(VECTOR_ELT(x, i), 0))) == 0) {
        SET_VECTOR_ELT(x, i, ScalarReal(R_PosInf));
        continue;
      }
      if(strcmp("-Inf", CHAR(STRING_ELT(VECTOR_ELT(x, i), 0))) == 0) {
        SET_VECTOR_ELT(x, i, ScalarReal(R_NegInf));
        continue;
      }
    }
  }

  //return updated list
  return x;
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/null_to_na.c:14

readChar timeout

timing: 20.00 s
(definition not located in src/)

yajl_bs_push timeout

timing: 20.00 s
(definition not located in src/)

yajl_do_parse timeout

timing: 20.00 s
source
yajl_do_parse(yajl_handle hand, const unsigned char * jsonText,
              size_t jsonTextLen)
{
    yajl_tok tok;
    const unsigned char * buf;
    size_t bufLen;
    size_t * offset = &(hand->bytesConsumed);

    *offset = 0;

  around_again:
    switch (yajl_bs_current(hand->stateStack)) {
        case yajl_state_parse_complete:
            if (hand->flags & yajl_allow_multiple_values) {
                yajl_bs_set(hand->stateStack, yajl_state_got_value);
                goto around_again;
            }
            if (!(hand->flags & yajl_allow_trailing_garbage)) {
                if (*offset != jsonTextLen) {
                    tok = yajl_lex_lex(hand->lexer, jsonText, jsonTextLen,
                                       offset, &buf, &bufLen);
                    if (tok != yajl_tok_eof) {
                        yajl_bs_set(hand->stateStack, yajl_state_parse_error);
                        hand->parseError = "trailing garbage";
                    }
                    goto around_again;
                }
            }
            return yajl_status_ok;
        case yajl_state_lexical_error:
        case yajl_state_parse_error:
            return yajl_status_error;
        case yajl_state_start:
        case yajl_state_got_value:
        case yajl_state_map_need_val:
        case yajl_state_array_need_val:
        case yajl_state_array_start:  {
            /* for arrays and maps, we advance the state for this
             * depth, then push the state of the next depth.
             * If an error occurs during the parsing of the nesting
             * enitity, the state at this level will not matter.
             * a state that needs pushing will be anything other
             * than state_start */

            yajl_state stateToPush = yajl_state_start;

            tok = yajl_lex_lex(hand->lexer, jsonText, jsonTextLen,
                               offset, &buf, &bufLen);

            switch (tok) {
                case yajl_tok_eof:
                    return yajl_status_ok;
                case yajl_tok_error:
                    yajl_bs_set(hand->stateStack, yajl_state_lexical_error);
                    goto around_again;
                case yajl_tok_string:
                    if (hand->callbacks && hand->callbacks->yajl_string) {
                        _CC_CHK(hand->callbacks->yajl_string(hand->ctx,
                                                             buf, bufLen));
                    }
                    break;
                case yajl_tok_string_with_escapes:
                    if (hand->callbacks && hand->callbacks->yajl_string) {
                        yajl_buf_clear(hand->decodeBuf);
                        yajl_string_decode(hand->decodeBuf, buf, bufLen);
                        _CC_CHK(hand->callbacks->yajl_string(
                                    hand->ctx, yajl_buf_data(hand->decodeBuf),
                                    yajl_buf_len(hand->decodeBuf)));
                    }
                    break;
                case yajl_tok_bool:
                    if (hand->callbacks && hand->callbacks->yajl_boolean) {
                        _CC_CHK(hand->callbacks->yajl_boolean(hand->ctx,
                                                              *buf == 't'));
                    }
                    break;
                case yajl_tok_null:
                    if (hand->callbacks && hand->callbacks->yajl_null) {
                        _CC_CHK(hand->callbacks->yajl_null(hand->ctx));
                    }
                    break;
                case yajl_tok_left_bracket:
                    if (hand->callbacks && hand->callbacks->yajl_start_map) {
                        _CC_CHK(hand->callbacks->yajl_start_map(hand->ctx));
                    }
                    stateToPush = yajl_state_map_start;
                    break;
                case yajl_tok_left_brace:
                    if (hand->callbacks && hand->callbacks->yajl_start_array) {
                        _CC_CHK(hand->callbacks->yajl_start_array(hand->ctx));
                    }
                    stateToPush = yajl_state_array_start;
                    break;
                case yajl_tok_integer:
                    if (hand->callbacks) {
                        if (hand->callbacks->yajl_number) {
                            _CC_CHK(hand->callbacks->yajl_number(
                                        hand->ctx,(const char *) buf, bufLen));
                        } else if (hand->callbacks->yajl_integer) {
                            long long int i = 0;
                            errno = 0;
                            i = yajl_parse_integer(buf, bufLen);
                            if ((i == LLONG_MIN || i == LLONG_MAX) &&
                                errno == ERANGE)
                            {
                                yajl_bs_set(hand->stateStack,
                                            yajl_state_parse_error);
                                hand->parseError = "integer overflow" ;
                                /* try to restore error offset */
                                if (*offset >= bufLen) *offset -= bufLen;
                                else *offset = 0;
                                goto around_again;
                            }
                            _CC_CHK(hand->callbacks->yajl_integer(hand->ctx,
                                                                  i));
                        }
                    }
                    break;
                case yajl_tok_double:
                    if (hand->callbacks) {
                        if (hand->callbacks->yajl_number) {
                            _CC_CHK(hand->callbacks->yajl_number(
                                        hand->ctx, (const char *) buf, bufLen));
                        } else if (hand->callbacks->yajl_double) {
                            double d = 0.0;
                            yajl_buf_clear(hand->decodeBuf);
                            yajl_buf_append(hand->decodeBuf, buf, bufLen);
                            buf = yajl_buf_data(hand->decodeBuf);
                            errno = 0;
                            d = strtod((char *) buf, NULL);
                            if ((d == HUGE_VAL || d == -HUGE_VAL) &&
                                errno == ERANGE)
                            {
                                yajl_bs_set(hand->stateStack,
                                            yajl_state_parse_error);
                                hand->parseError = "numeric (floating point) "
                                    "overflow";
                                /* try to restore error offset */
                                if (*offset >= bufLen) *offset -= bufLen;
                                else *offset = 0;
                                goto around_again;
                            }
                            _CC_CHK(hand->callbacks->yajl_double(hand->ctx,
                                                                 d));
                        }
                    }
                    break;
                case yajl_tok_right_brace: {
                    if (yajl_bs_current(hand->stateStack) ==
                        yajl_state_array_start)
                    {
                        if (hand->callbacks &&
                            hand->callbacks->yajl_end_array)
                        {
                            _CC_CHK(hand->callbacks->yajl_end_array(hand->ctx));
                        }
                        yajl_bs_pop(hand->stateStack);
                        goto around_again;
                    }
                    /* intentional fall-through */
                }
                case yajl_tok_colon:
                case yajl_tok_comma:
                case yajl_tok_right_bracket:
                    yajl_bs_set(hand->stateStack, yajl_state_parse_error);
                    hand->parseError =
                        "unallowed token at this point in JSON text";
                    goto around_again;
                default:
                    yajl_bs_set(hand->stateStack, yajl_state_parse_error);
                    hand->parseError = "invalid token, internal error";
                    goto around_again;
            }
            /* got a value.  transition depends on the state we're in. */
            {
                yajl_state s = yajl_bs_current(hand->stateStack);
                if (s == yajl_state_start || s == yajl_state_got_value) {
                    yajl_bs_set(hand->stateStack, yajl_state_parse_complete);
                } else if (s == yajl_state_map_need_val) {
                    yajl_bs_set(hand->stateStack, yajl_state_map_got_val);
                } else {
                    yajl_bs_set(hand->stateStack, yajl_state_array_got_val);
                }
            }
            if (stateToPush != yajl_state_start) {
                yajl_bs_push(hand->stateStack, stateToPush);
            }

            goto around_again;
        }
        case yajl_state_map_start:
        case yajl_state_map_need_key: {
            /* only difference between these two states is that in
             * start '}' is valid, whereas in need_key, we've parsed
             * a comma, and a string key _must_ follow */
            tok = yajl_lex_lex(hand->lexer, jsonText, jsonTextLen,
                               offset, &buf, &bufLen);
            switch (tok) {
                case yajl_tok_eof:
                    return yajl_status_ok;
                case yajl_tok_error:
                    yajl_bs_set(hand->stateStack, yajl_state_lexical_error);
                    goto around_again;
                case yajl_tok_string_with_escapes:
                    if (hand->callbacks && hand->callbacks->yajl_map_key) {
                        yajl_buf_clear(hand->decodeBuf);
                        yajl_string_decode(hand->decodeBuf, buf, bufLen);
                        buf = yajl_buf_data(hand->decodeBuf);
                        bufLen = yajl_buf_len(hand->decodeBuf);
                    }
                    /* intentional fall-through */
                case yajl_tok_string:
                    if (hand->callbacks && hand->callbacks->yajl_map_key) {
                        _CC_CHK(hand->callbacks->yajl_map_key(hand->ctx, buf,
                                                              bufLen));
                    }
                    yajl_bs_set(hand->stateStack, yajl_state_map_sep);
                    goto around_again;
                case yajl_tok_right_bracket:
                    if (yajl_bs_current(hand->stateStack) ==
                        yajl_state_map_start)
                    {
                        if (hand->callbacks && hand->callbacks->yajl_end_map) {
                            _CC_CHK(hand->callbacks->yajl_end_map(hand->ctx));
                        }
                        yajl_bs_pop(hand->stateStack);
                        goto around_again;
                    }
                default:
                    yajl_bs_set(hand->stateStack, yajl_state_parse_error);
                    hand->parseError =
                        "invalid object key (must be a string)";
                    goto around_again;
            }
        }
        case yajl_state_map_sep: {
            tok = yajl_lex_lex(hand->lexer, jsonText, jsonTextLen,
                               offset, &buf, &bufLen);
            switch (tok) {
                case yajl_tok_colon:
                    yajl_bs_set(hand->stateStack, yajl_state_map_need_val);
                    goto around_again;
                case yajl_tok_eof:
                    return yajl_status_ok;
                case yajl_tok_error:
                    yajl_bs_set(hand->stateStack, yajl_state_lexical_error);
                    goto around_again;
                default:
                    yajl_bs_set(hand->stateStack, yajl_state_parse_error);
                    hand->parseError = "object key and value must "
                        "be separated by a colon (':')";
                    goto around_again;
            }
        }
        case yajl_state_map_got_val: {
            tok = yajl_lex_lex(hand->lexer, jsonText, jsonTextLen,
                               offset, &buf, &bufLen);
            switch (tok) {
                case yajl_tok_right_bracket:
                    if (hand->callbacks && hand->callbacks->yajl_end_map) {
                        _CC_CHK(hand->callbacks->yajl_end_map(hand->ctx));
                    }
                    yajl_bs_pop(hand->stateStack);
                    goto around_again;
                case yajl_tok_comma:
                    yajl_bs_set(hand->stateStack, yajl_state_map_need_key);
                    goto around_again;
                case yajl_tok_eof:
                    return yajl_status_ok;
                case yajl_tok_error:
                    yajl_bs_set(hand->stateStack, yajl_state_lexical_error);
                    goto around_again;
                default:
                    yajl_bs_set(hand->stateStack, yajl_state_parse_error);
                    hand->parseError = "after key and value, inside map, "
                                       "I expect ',' or '}'";
                    /* try to restore error offset */
                    if (*offset >= bufLen) *offset -= bufLen;
                    else *offset = 0;
                    goto around_again;
            }
        }
        case yajl_state_array_got_val: {
            tok = yajl_lex_lex(hand->lexer, jsonText, jsonTextLen,
                               offset, &buf, &bufLen);
            switch (tok) {
                case yajl_tok_right_brace:
                    if (hand->callbacks && hand->callbacks->yajl_end_array) {
                        _CC_CHK(hand->callbacks->yajl_end_array(hand->ctx));
                    }
                    yajl_bs_pop(hand->stateStack);
                    goto around_again;
                case yajl_tok_comma:
                    yajl_bs_set(hand->stateStack, yajl_state_array_need_val);
                    goto around_again;
                case yajl_tok_eof:
                    return yajl_status_ok;
                case yajl_tok_error:
                    yajl_bs_set(hand->stateStack, yajl_state_lexical_error);
                    goto around_again;
                default:
                    yajl_bs_set(hand->stateStack, yajl_state_parse_error);
                    hand->parseError =
                        "after array element, I expect ',' or ']'";
                    goto around_again;
            }
        }
    }

    //comment out by jeroen for R CMD check
    //abort();
    return yajl_status_error;
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl_parser.c:186

yajl_lex_number timeout

timing: 20.00 s
source
yajl_lex_number(yajl_lexer lexer, const unsigned char * jsonText,
                size_t jsonTextLen, size_t * offset)
{
    /** XXX: numbers are the only entities in json that we must lex
     *       _beyond_ in order to know that they are complete.  There
     *       is an ambiguous case for integers at EOF. */

    unsigned char c;

    yajl_tok tok = yajl_tok_integer;

    RETURN_IF_EOF;
    c = readChar(lexer, jsonText, offset);

    /* optional leading minus */
    if (c == '-') {
        RETURN_IF_EOF;
        c = readChar(lexer, jsonText, offset);
    }

    /* a single zero, or a series of integers */
    if (c == '0') {
        RETURN_IF_EOF;
        c = readChar(lexer, jsonText, offset);
    } else if (c >= '1' && c <= '9') {
        do {
            RETURN_IF_EOF;
            c = readChar(lexer, jsonText, offset);
        } while (c >= '0' && c <= '9');
    } else {
        unreadChar(lexer, offset);
        lexer->error = yajl_lex_missing_integer_after_minus;
        return yajl_tok_error;
    }

    /* optional fraction (indicates this is floating point) */
    if (c == '.') {
        int numRd = 0;

        RETURN_IF_EOF;
        c = readChar(lexer, jsonText, offset);

        while (c >= '0' && c <= '9') {
            numRd++;
            RETURN_IF_EOF;
            c = readChar(lexer, jsonText, offset);
        }

        if (!numRd) {
            unreadChar(lexer, offset);
            lexer->error = yajl_lex_missing_integer_after_decimal;
            return yajl_tok_error;
        }
        tok = yajl_tok_double;
    }

    /* optional exponent (indicates this is floating point) */
    if (c == 'e' || c == 'E') {
        RETURN_IF_EOF;
        c = readChar(lexer, jsonText, offset);

        /* optional sign */
        if (c == '+' || c == '-') {
            RETURN_IF_EOF;
            c = readChar(lexer, jsonText, offset);
        }

        if (c >= '0' && c <= '9') {
            do {
                RETURN_IF_EOF;
                c = readChar(lexer, jsonText, offset);
            } while (c >= '0' && c <= '9');
        } else {
            unreadChar(lexer, offset);
            lexer->error = yajl_lex_missing_integer_after_exponent;
            return yajl_tok_error;
        }
        tok = yajl_tok_double;
    }

    /* we always go "one too far" */
    unreadChar(lexer, offset);

    return tok;
}
/__w/r-typing/r-typing/work/sources/jsonlite/src/yajl/yajl_lex.c:371

R definitions 124

R/apply_by_pages.R

apply_by_pages untypeable

unbound variable (line 2)
unbound: is.data.frame — a name the prelude does not declare
error detail
name: is.data.frame
timing: 0.148 s
source
apply_by_pages <- function(x, FUN, pagesize, verbose, ...) {
  stopifnot(is.data.frame(x))
  nr <- nrow(x)
  npages <- nr %/% pagesize
  lastpage <- nr %% pagesize

  out <- as.list(rep(NA, npages + as.logical(lastpage)))
  for (i in seq_len(npages)) {
    from <- pagesize * (i - 1) + 1
    to <- pagesize * i
    out[[i]] <- FUN(x[from:to, , drop = FALSE], ...)
    if (verbose) cat("\rProcessed", i * pagesize, "rows...")
  }

  if (lastpage) {
    from <- nr - lastpage + 1
    out[[npages + 1]] <- FUN(x[from:nr, , drop = FALSE], ...)
  }
  if (verbose) cat("\rComplete! Processed total of", nr, "rows.\n")
  out
}
R/apply_by_pages.R:1

apply_by_pages2 untypeable

untypeable application of base::seq_len (line 25)
error detail
argument: @(INT1<> | null)
failing call: base::seq_len(NULL)
timing: 0.059 s
source
apply_by_pages2 <- function(x, FUN, pagesize, verbose, ...) {
  x2 <- split(x, seq_len(nrow(x)) %/% pagesize)
  for (page in x2) {
    if (verbose) message("Writing ", nrow(page), " lines (", ").")
    FUN(page)
  }
  invisible()
}
R/apply_by_pages.R:24

[.json untypeabletyped

unbound variable (line 35)
unbound: NextMethod — a name the prelude does not declare
error detail
name: NextMethod
gradual mode: typed
((x: any, i: any) -> any)<>
timing: 0.008 s
source
`[.json` <- function(x, i) {
  structure(NextMethod("["), class = c("json", "character"))
}
R/apply_by_pages.R:34
R/is.recordlist.R

is_recordlist_c typed fuzz ok

(((x: p(CHR) | (~(list & ~{ any_sexp }))<...> | sym | null) -> ^LGL1)&((x: p(CHR) | (~(list & ~{ p(CHR) | (~list)<...> | sym | null }))<...> | sym | null) -> ff))<>
timing: 0.057 s
fuzzing: 6 inside (6 ok) · 7 outside (7 rejected)
source
is_recordlist_c <- function(x) {
  .Call(C_is_recordlist, x)
}
R/is.recordlist.R:2

is.namedlist typed any: x fuzz ok

((x: any) -> LGL1<>)<>
timing: 0.074 s
fuzzing: 5 inside (5 ok) · 6 outside (6 rejected)
source
is.namedlist <- function(x) {
  isTRUE(is.list(x) && !is.null(names(x)))
}
R/is.recordlist.R:20

is.unnamedlist typed any: x fuzz ok

((x: any) -> LGL1<>)<>
timing: 0.049 s
fuzzing: 8 inside (8 ok) · 4 outside (4 rejected)
source
is.unnamedlist <- function(x) {
  isTRUE(is.list(x) && is.null(names(x)))
}
R/is.recordlist.R:24

is_recordlist_r typed accepts outside

(((x: vec | { ~null }) | (x: { null }) -> ff<> | tt<>)&((x: { }) -> ff<>))<>
timing: 0.699 s
fuzzing: 5 inside (5 ok) · 7 outside (2 rejected, 5 accepted)

Accepted outside the domain x: 5

parameterchangecallreturned
xkind:funis_recordlist_r("x" = function(...) NULL)ff<> with { }
xkind:langis_recordlist_r(quote(f(x)))ff<> with { }
xkind:nullis_recordlist_r("x" = NULL)ff<> with { }
xkind:symis_recordlist_r(as.name("x"))ff<> with { }
xkind:symis_recordlist_r("x" = as.name("x"))ff<> with { }
source
is_recordlist_r <- function(x) {
  if (!(is.unnamedlist(x) && length(x))) {
    return(FALSE)
  }
  at_least_one_object = FALSE
  for (i in x) {
    if (!(is.namedlist(i) || is.null(i))) return(FALSE)
    if (!at_least_one_object && is.namedlist(i)) at_least_one_object <- TRUE
  }
  return(at_least_one_object)
}
R/is.recordlist.R:6

is.recordlist typed fuzz ok

(((x: p(CHR) | (~(list & ~{ any_sexp }))<...> | sym | null) -> ^LGL1)&((x: p(CHR) | (~(list & ~{ p(CHR) | (~list)<...> | sym | null }))<...> | sym | null) -> ff))<>
timing: 0.020 s
fuzzing: 6 inside (6 ok) · 7 outside (7 rejected)
source
is.recordlist <- is_recordlist_c
R/is.recordlist.R:18
R/as.scalar.R

as.scalar typed no call in domain

∀'a. ((obj: 'a<...>) -> 'a<...>)<>
timing: 0.334 s
fuzzing: 0 inside (none) · 0 outside (none)
type drawn from: ((obj: 'I28807<...>) -> 'I28807<...>)<>
source
as.scalar <- function(obj) {
  # Lists can never be a scalar (this can arise if a dataframe contains a column
  # with lists)
  if (length(dim(obj)) > 1) {
    if (!identical(nrow(obj), 1L)) {
      warning("Tried to use as.scalar on an array or dataframe with ", nrow(obj), " rows.", call. = FALSE)
      return(obj)
    }
  } else if (!identical(length(obj), 1L)) {
    warning("Tried to use as.scalar on an object of length ", length(obj), call. = FALSE)
    return(obj)
  } else if (is.namedlist(obj)) {
    warning("Tried to use as.scalar on a named list.", call. = FALSE)
    return(obj)
  }

  class(obj) <- c("scalar", class(obj))
  return(obj)
}
R/as.scalar.R:1
R/asJSON.AAAgeneric.R

<statement> untypeabletyped

unbound variable (line 2)
unbound: standardGeneric — a name the prelude does not declare
error detail
name: standardGeneric
gradual mode: typed
timing: 0.003 s
source
setGeneric("asJSON", function(x, ...) {
  standardGeneric("asJSON")
})
R/asJSON.AAAgeneric.R:1

<statement> untypeabletyped

unbound variable (line 5)
unbound: getRversion — a name the prelude does not declare
error detail
name: getRversion
gradual mode: typed
timing: 0.012 s
source
if (getRversion() < "4") {
  setOldClass("AsIs")
  setOldClass("integer64")
  setOldClass(c("hms", "difftime"))
  setOldClass("ITime")
  setOldClass("json")
  setOldClass("pairlist")
  setOldClass("scalar")
  setOldClass("sf")
  setOldClass("sfc")
}
R/asJSON.AAAgeneric.R:5
R/stop.R

stop skipped

error detail
Failure("Unsupported argument after an ellipsis.")
timing: 0.000 s
source
stop <- function(..., call. = FALSE) {
  base::stop(..., call. = FALSE)
}
R/stop.R:1
R/asJSON.ANY.R

<statement> untypeabletyped

unbound variable (line 3)
unbound: isS4 — a name the prelude does not declare
error detail
name: isS4
gradual mode: typed
timing: 0.133 s
source
setMethod("asJSON", "ANY", function(x, force = FALSE, ...) {
  if (isS4(x) && !is(x, "classRepresentation")) {
    if (isTRUE(force)) {
      return(asJSON(attributes(x), force = force, ...))
    } else {
      stop("No method for S4 class:", class(x))
    }
  } else if (length(class(x)) > 1) {
    # If an object has multiple classes, we recursively try the next class. This is
    # S3 style dispatching that doesn't work by default for formal method definitions
    # There should be a more native way to accomplish this
    return(asJSON(structure(x, class = class(x)[-1]), force = force, ...))
  } else if (isTRUE(force) && existsMethod("asJSON", class(unclass(x))[1])) {
    # As a last resort we can force encoding using the unclassed object
    return(asJSON(unclass(x), force = force, ...))
  } else if (isTRUE(force)) {
    return(asJSON(NULL))
    warning("No method asJSON S3 class: ", class(x))
  } else {
    # If even that doesn't work, we give up.
    stop("No method asJSON S3 class: ", class(x))
  }
})
R/asJSON.ANY.R:2
R/asJSON.AsIs.R

<statement> untypeabletyped

unbound variable (line 5)
unbound: is.atomic — a name the prelude does not declare
error detail
name: is.atomic
gradual mode: typed
timing: 0.070 s
source
setMethod("asJSON", "AsIs", function(x, auto_unbox = FALSE, ...) {
  # Strip off the AsIs class so we can dispatch to other asJSON methods.
  class(x) <- setdiff(class(x), "AsIs")

  if (is.atomic(x) && length(x) == 1) {
    # Never auto_unbox single values when wrapped with I()
    asJSON(x, auto_unbox = FALSE, ...)
  } else {
    asJSON(x, auto_unbox = auto_unbox, ...)
  }
})
R/asJSON.AsIs.R:1
R/asJSON.Date.R

<statement> untypeabletyped

unbound variable (line 1)
unbound: setMethod — a name the prelude does not declare
error detail
name: setMethod
gradual mode: typed
timing: 0.189 s
source
setMethod("asJSON", "Date", function(x, Date = c("ISO8601", "epoch"), always_decimal = FALSE, ...) {
  # Validate argument
  Date <- match.arg(Date)

  # select a schema
  output <- switch(
    Date,
    ISO8601 = format(x),
    epoch = unclass(x),
    default = stop("Invalid argument for 'Date':", Date)
  )

  # Dispatch to character encoding
  asJSON(output, always_decimal = FALSE, ...)
})
R/asJSON.Date.R:1
R/asJSON.ITime.R

<statement> untypeabletyped

unbound variable (line 2)
unbound: asJSON — a name the prelude does not declare
error detail
name: asJSON
gradual mode: typed
timing: 0.023 s
source
setMethod("asJSON", "ITime", function(x, ...) {
  asJSON(as.character(x), ...)
})
R/asJSON.ITime.R:1
R/asJSON.NULL.R

<statement> untypeabletyped

unbound variable (line 2)
unbound: setMethod — a name the prelude does not declare
error detail
name: setMethod
gradual mode: typed
timing: 0.070 s
source
setMethod("asJSON", "NULL", function(x, null = "list", ...) {
  if (null == "null") {
    return("null")
  } else {
    return("{}")
  }
})
R/asJSON.NULL.R:2
R/toJSON.R

indent_init typed accepts outside

(((pretty: DBL | INT) -> INT)&((pretty: ~dbl) -> (INT1 \ ^INT1)<>))<>
timing: 5.19 s
fuzzing: 7 inside (3 ok, 4 error pkg) · 8 outside (7 rejected, 1 accepted)

Accepted outside the domain pretty: 1

parameterchangecallreturned
prettyretype:dbl>lglindent_init("pretty" = c(FALSE, TRUE))(INT1 \ ^INT1)<> with { }

Other calls inside the domain

callverdicterror
indent_init(c(2L, 1000000L, NA_integer_, 42L, 2L))error_pkgjsonlite::indent_init: abs(pretty) < 20 are not all TRUE
indent_init("pretty" = c(42L, -2147483647L))error_pkgjsonlite::indent_init: abs(pretty) < 20 are not all TRUE
indent_init("pretty" = c(Inf, 42))error_pkgjsonlite::indent_init: abs(pretty) < 20 are not all TRUE
indent_init("pretty" = NA_integer_)error_pkgjsonlite::indent_init: abs(pretty) < 20 is not TRUE
source
indent_init <- function(pretty) {
  # default is 2 spaces
  if (isTRUE(pretty)) {
    pretty <- 2L
  }

  # Start with indent of 0
  if (is.numeric(pretty)) {
    stopifnot(abs(pretty) < 20)
    structure(0L, indent_spaces = as.integer(pretty))
  } else {
    NA_integer_
  }
}
R/toJSON.R:51

toJSON untypeable

untypeable application (line 45)
error detail
function: ((pretty: DBL | INT) --> INT) & ((pretty: ~dbl) --> (INT1 \ ^INT1)<>)
argument: @(ff<> | 'pretty)
argument (not in the domain) may be: (FALSE)
timing: 14.93 s
source
toJSON <- function(
  x,
  dataframe = c("rows", "columns", "values"),
  matrix = c("rowmajor", "columnmajor"),
  Date = c("ISO8601", "epoch"),
  POSIXt = c("string", "ISO8601", "epoch", "mongo"),
  factor = c("string", "integer"),
  complex = c("string", "list"),
  raw = c("base64", "hex", "mongo", "int", "js"),
  null = c("list", "null"),
  na = c("null", "string"),
  auto_unbox = FALSE,
  digits = 4,
  pretty = FALSE,
  force = FALSE,
  ...
) {
  # validate args
  dataframe <- match.arg(dataframe)
  matrix <- match.arg(matrix)
  Date <- match.arg(Date)
  POSIXt <- match.arg(POSIXt)
  factor <- match.arg(factor)
  complex <- match.arg(complex)
  raw <- match.arg(raw)
  null <- match.arg(null)

  # Temp workaround for 'mongopipe' unit test
  if (pretty == 2 && identical(x, list()) && identical(Sys.getenv('TESTTHAT_PKG'), 'mongopipe')) {
    return('[\n\n]')
  }

  # force
  x <- force(x)

  #this is just to check, we keep method-specific defaults
  if (!missing(na)) {
    na <- match.arg(na)
  } else {
    na <- NULL
  }

  # dispatch
  indent <- indent_init(pretty)
  ans <- asJSON(x, dataframe = dataframe, Date = Date, POSIXt = POSIXt, factor = factor, complex = complex, raw = raw, matrix = matrix, auto_unbox = auto_unbox, digits = digits, na = na, null = null, force = force, indent = indent, ...)
  class(ans) <- "json"
  return(ans)
}
R/toJSON.R:2

indent_increment typed accepts outside

∀'a,`a. (((indent: (INT | dbl & v('a))<@"+", `a> with { indent_spaces: (dbl & v('a))<`a>, any }) -> (INT | (DBL | INT) & v('a))<`a> | (INT1 \ ^INT1)<>)&((indent: <@"+", ...> with { indent_spaces: (dbl & v('a))<`a>, any }) | (indent: <@"+", ...> with { indent_spaces: dbl1<`a>, any }) -> (DBL | INT)<difftime> | (INT1 \ ^INT1)<> | LGL<> | dbl<Date, ...> | <POSIXt, ...>)&((indent: DBL1<@"+", `a> with { indent_spaces: dbl1<`a>, any }) | (indent: dbl1<@"+", `a> with { indent_spaces: DBL1<`a>, any }) -> DBL1<`a> | (INT1 \ ^INT1)<>)&((indent: dbl1<@"+", `a> with { indent_spaces: dbl1<`a>, any }) -> (DBL1 | INT1)<`a> | (INT1 \ ^INT1)<>)&((indent: dbl<@"+", `a> with { indent_spaces: dbl1<`a>, any }) -> (DBL | INT)<`a> | (INT1 \ ^INT1)<>))<>
timing: 11.27 s
fuzzing: 16 inside (12 ok, 4 error type) · 8 outside (1 rejected, 7 accepted)
type drawn from: (((indent: (INT | dbl & v('I29324))<@"+", `I122> with { indent_spaces: (dbl & v('I29324))<`I122>, any }) -> (INT | (DBL | INT) & v('I29324))<`I122> | (INT1 \ ^INT1)<>) & ((indent: <@"+", ...> with { indent_spaces: (dbl & v('I29324))<`I122>, any }) | (indent: <@"+", ...> with { indent_spaces: dbl1<`I122>, any }) -> (DBL | INT)<difftime> | (INT1 \ ^INT1)<> | LGL<> | dbl<Date, ...> | <POSIXt, ...>) & ((indent: DBL1<@"+", `I122> with { indent_spaces: dbl1<`I122>, any }) | (indent: dbl1<@"+", `I122> with { indent_spaces: DBL1<`I122>, any }) -> DBL1<`I122> | (INT1 \ ^INT1)<>) & ((indent: dbl1<@"+", `I122> with { indent_spaces: dbl1<`I122>, any }) -> (DBL1 | INT1)<`I122> | (INT1 \ ^INT1)<>) & ((indent: dbl<@"+", `I122> with { indent_spaces: dbl1<`I122>, any }) -> (DBL | INT)<`I122> | (INT1 \ ^INT1)<>))<>

Accepted outside the domain indent: 7

parameterchangecallreturned
indentattr:drop:indent_spacesindent_increment("indent" = NA_integer_)(INT1 \ ^INT1)<> with { }
indentkind:funindent_increment("indent" = function(...) NULL)(INT1 \ ^INT1)<> with { }
indentkind:listindent_increment(list())(INT1 \ ^INT1)<> with { }
indentretype:dbl>clxindent_increment(structure(c(complex(real = 0, imaginary = 0), complex(real = 1, imaginary = -2)), "indent_spaces" = TRUE))(CLX & ~vec1)<> with { indent_spaces: tt<> with { } }
indentwrapindent_increment("indent" = list(structure(0L, "indent_spaces" = -2.5)))(INT1 \ ^INT1)<> with { }
indentwrapindent_increment(list(structure(numeric(0), "indent_spaces" = numeric(0))))(INT1 \ ^INT1)<> with { }
and 1 more

Other calls inside the domain

callverdicterror
indent_increment("indent" = structure(NA_integer_, "indent_spaces" = as.raw(c(0))))error_typebase::abs: non-numeric argument to mathematical function
indent_increment("indent" = structure(as.raw(c(0)), "indent_spaces" = FALSE))error_typebase::+: non-numeric argument to binary operator
indent_increment(structure(as.raw(c(255)), "indent_spaces" = Inf))error_typebase::+: non-numeric argument to binary operator
indent_increment("indent" = structure(as.raw(c(0)), "indent_spaces" = 0.5))error_typebase::+: non-numeric argument to binary operator
source
indent_increment <- function(indent) {
  indent_spaces <- attr(indent, 'indent_spaces')
  if (length(indent_spaces)) {
    indent + abs(indent_spaces)
  } else {
    NA_integer_
  }
}
R/toJSON.R:66
R/collapse.R

collapse typed empty return any: inner

((x: p(CHR) | (~CHR)<...> | sym | null, inner: any?, indent: any_sexp?) -> empty)<>
timing: 0.423 s
source
collapse <- function(x, inner = TRUE, indent = 0L) {
  if (is.na(indent)) {
    .Call(C_collapse_array, x)
  } else if (isTRUE(inner)) {
    .Call(C_collapse_array_pretty_inner, x)
  } else {
    .Call(C_collapse_array_pretty_outer, x, indent)
  }
}
R/collapse.R:2

row_collapse untypeabletyped

unbound variable (line 14)
unbound: C_row_collapse_array — a native symbol tyr could not bind
error detail
name: C_row_collapse_array
gradual mode: typed
((m: any, indent: any?) -> any)<>
timing: 0.007 s
source
row_collapse <- function(m, indent = NA_integer_) {
  .Call(C_row_collapse_array, m, indent = indent)
}
R/collapse.R:13

collapse_array untypeabletimeout

unbound variable (line 26)
unbound: apply — a name the prelude does not declare
error detail
name: apply
gradual mode: timeout
timing: 0.546 s
source
collapse_array <- function(x, columnmajor = FALSE, indent) {
  # dimensionality of the array
  n <- length(dim(x))

  # Collapse the inner vectors
  dim <- 1:(n - 1) + as.numeric(columnmajor)
  x <- apply(x, dim, collapse, inner = TRUE, indent = indent)

  # Collapse higher dimensions
  for (i in rev(seq_along(dim(x)))[-1]) {
    dim <- 1:(length(dim(x)) - 1) + as.numeric(columnmajor)
    x <- apply(x, dim, collapse, inner = FALSE, indent = indent_increment(indent) * i)
  }
  x
}
R/collapse.R:20
R/asJSON.POSIXt.R

<statement> untypeable

unbound variable (line 10)
unbound: asJSON_posix_mongo — one of the package’s own names, itself untyped
error detail
name: asJSON_posix_mongo
timing: 0.239 s
source
setMethod("asJSON", "POSIXt", function(x, POSIXt = c("string", "ISO8601", "epoch", "mongo"), UTC = FALSE, digits, time_format = NULL, always_decimal = FALSE, ...) {
  # note: UTC argument doesn't seem to be working consistently maybe use ?format
  # instead of ?as.character

  # Validate
  POSIXt <- match.arg(POSIXt)

  # Encode based on a schema
  if (POSIXt == "mongo") {
    return(asJSON_posix_mongo(x, ...))
  }

  # Epoch millis
  if (POSIXt == "epoch") {
    return(asJSON(floor(unclass(as.POSIXct(x)) * 1000), digits = digits, always_decimal = FALSE, ...))
  }

  # Strings
  if (is.null(time_format)) {
    time_format <- if (POSIXt == "string") {
      ""
    } else if (isTRUE(UTC)) {
      "%Y-%m-%dT%H:%M:%SZ"
    } else {
      "%Y-%m-%dT%H:%M:%S"
    }
  }

  if (isTRUE(UTC)) {
    asJSON(format(x, format = time_format, tz = "UTC"), ...)
  } else {
    asJSON(format(x, format = time_format), ...)
  }
})
R/asJSON.POSIXt.R:1

asJSON_posix_mongo skipped

error detail
Failure("Unsupported argument after an ellipsis.")
timing: 0.003 s
source
asJSON_posix_mongo <- function(x, collapse = TRUE, indent = NA_integer_, ...) {
  if (inherits(x, "POSIXlt")) {
    x <- as.POSIXct(x)
  }
  df <- data.frame("$date" = floor(unclass(x) * 1000), check.names = FALSE)
  if (inherits(x, "scalar")) class(df) <- c("scalar", class(df))
  tmp <- asJSON(df, digits = NA, always_decimal = FALSE, ..., collapse = FALSE)
  tmp[is.na(x)] <- asJSON(NA_character_, collapse = FALSE, ...)
  if (isTRUE(collapse)) {
    collapse(tmp, inner = FALSE, indent = indent)
  } else {
    tmp
  }
}
R/asJSON.POSIXt.R:36
R/asJSON.array.R

asjson_array_fun untypeable

untypeable application (line 11)
error detail
function: ((indent: (INT | dbl & v('I29580))<@"+", `I151> with { indent_spaces: (dbl & v('I29580))<`I151>, any }) --> (INT | (DBL | INT) & v('I29580))<`I151> | (INT1 \ ^INT1)<>) & ((indent: <@"+", ...> with { indent_spaces: (dbl & v('I29580))<`I151>, any }) | (indent: <@"+", ...> with { indent_spaces: dbl1<`I151>, any }) --> (DBL | INT)<difftime> | (INT1 \ ^INT1)<> | LGL<> | dbl<Date, ...> | <POSIXt, ...>) & ((indent: DBL1<@"+", `I151> with { indent_spaces: dbl1<`I151>, any }) | (indent: dbl1<@"+", `I151> with { indent_spaces: DBL1<`I151>, any }) --> DBL1<`I151> | (INT1 \ ^INT1)<>) & ((indent: dbl1<@"+", `I151> with { indent_spaces: dbl1<`I151>, any }) --> (DBL1 | INT1)<`I151> | (INT1 \ ^INT1)<>) & ((indent: dbl<@"+", `I151> with { indent_spaces: dbl1<`I151>, any }) --> (DBL | INT)<`I151> | (INT1 \ ^INT1)<>)
argument: @((INT1 & ~^INT1)<> | 'indent)
argument (not in the domain) may be: (new.env())
timing: 12.64 s
source
asjson_array_fun <- function(x, collapse = TRUE, na = NULL, oldna = NULL, matrix = c("rowmajor", "columnmajor"), auto_unbox = FALSE, keep_vec_names = FALSE, indent = NA_integer_, ...) {
  matrix <- match.arg(matrix)

  # reset na arg when called from data frame
  if (identical(na, "NA")) {
    na <- oldna
  }

  # 1D arrays are vectors
  if (length(dim(x)) < 2) {
    return(asJSON(c(x), matrix = matrix, na = na, indent = indent_increment(indent), ...))
  }

  # if collapse == FALSE, then this matrix is nested inside a data frame,
  # and therefore row major must be forced to match dimensions
  if (identical(matrix, "columnmajor") && collapse == FALSE) {
    return(apply(x, 1, asJSON, matrix = matrix, na = na, indent = indent_increment(indent), ...))
  }

  # dont pass auto_unbox (never unbox within matrix)
  m <- asJSON(c(x), collapse = FALSE, matrix = matrix, na = na, ...)
  dim(m) <- dim(x)
  tmp <- if (length(dim(x)) == 2 && identical(matrix, "rowmajor")) {
    # Faster special case for 2D matrices
    row_collapse(m, indent = indent_increment(indent))
  } else {
    collapse_array(m, columnmajor = identical(matrix, "columnmajor"), indent = indent)
  }

  # collapse it
  if (collapse) {
    collapse(tmp, inner = FALSE, indent = indent)
  } else {
    tmp
  }
}
R/asJSON.array.R:1

<statement> untypeabletyped

unbound variable (line 39)
unbound: asjson_array_fun — one of the package’s own names, itself untyped
error detail
name: asjson_array_fun
gradual mode: typed
timing: 0.001 s
source
setMethod("asJSON", "array", asjson_array_fun)
R/asJSON.array.R:39

<statement> untypeabletyped

unbound variable (line 40)
unbound: asjson_array_fun — one of the package’s own names, itself untyped
error detail
name: asjson_array_fun
gradual mode: typed
timing: 0.000 s
source
setMethod("asJSON", "matrix", asjson_array_fun)
R/asJSON.array.R:40
R/deparse_vector.R

deparse_vector_c typed empty return

((x: p(CHR) | (~CHR)<...> | sym | null) -> empty)<>
timing: 0.014 s
source
deparse_vector_c <- function(x) {
  .Call(C_escape_chars, x)
}
R/deparse_vector.R:2

deparse_vector_r typed fuzz ok

∀'a. (((x: 'a & clx) -> CHR<> | vec & 'a)&((x: 'a & clx1) -> CHR1<> | (CHR | vec1) & 'a)&((x: CHR1<> | 'a & CHR1) -> CHR1<> | 'a \ (CHR & ~vec1))&((x: CHR<> | 'a & CHR) -> CHR<> | 'a))<>
timing: 0.565 s
fuzzing: 18 inside (8 ok, 10 error pkg) · 8 outside (8 rejected)
type drawn from: (((x: 'x & clx) -> CHR<> | vec & 'x) & ((x: 'x & clx1) -> CHR1<> | (CHR | vec1) & 'x) & ((x: CHR1<> | 'x & CHR1) -> CHR1<> | 'x \ (CHR & ~vec1)) & ((x: CHR<> | 'x & CHR) -> CHR<> | 'x))<>

Other calls inside the domain

callverdicterror
deparse_vector_r("x" = FALSE)error_pkgjsonlite::deparse_vector_r: is.character(x) is not TRUE
deparse_vector_r(NA)error_pkgjsonlite::deparse_vector_r: is.character(x) is not TRUE
deparse_vector_r("x" = c(1000000L, NA_integer_, 1000000L, 42L, 0L))error_pkgjsonlite::deparse_vector_r: is.character(x) is not TRUE
deparse_vector_r("x" = 2147483647L)error_pkgjsonlite::deparse_vector_r: is.character(x) is not TRUE
deparse_vector_r("x" = NaN)error_pkgjsonlite::deparse_vector_r: is.character(x) is not TRUE
deparse_vector_r(0.5)error_pkgjsonlite::deparse_vector_r: is.character(x) is not TRUE
and 4 more
source
deparse_vector_r <- function(x) {
  stopifnot(is.character(x))
  if (!length(x)) return(x)
  x <- gsub("\\", "\\\\", x, fixed = TRUE)
  x <- gsub("\"", "\\\"", x, fixed = TRUE)
  x <- gsub("\n", "\\n", x, fixed = TRUE)
  x <- gsub("\r", "\\r", x, fixed = TRUE)
  x <- gsub("\t", "\\t", x, fixed = TRUE)
  x <- gsub("\b", "\\b", x, fixed = TRUE)
  x <- gsub("\f", "\\f", x, fixed = TRUE)
  paste0("\"", x, "\"")
}
R/deparse_vector.R:6

deparse_vector typed empty return

((x: p(CHR) | (~CHR)<...> | sym | null) -> empty)<>
timing: 0.006 s
source
deparse_vector <- deparse_vector_c
R/deparse_vector.R:20

deparse_vector_old untypeabletyped

unbound variable (line 26)
unbound: deparse — a name the prelude does not declare
error detail
name: deparse
gradual mode: typed
((x: CHR) | (x: clx) -> any)<>
timing: 0.066 s
source
deparse_vector_old <- function(x) {
  stopifnot(is.character(x))
  x <- gsub("[\v\a]", "", x)
  vapply(x, deparse, character(1), USE.NAMES = FALSE)
}
R/deparse_vector.R:23
R/warn_keep_vec_names.R

warn_keep_vec_names untypeabletyped

unbound variable (line 2)
unbound: message — a name the prelude does not declare
error detail
name: message
gradual mode: typed
(() -> any)<>
timing: 0.002 s
source
warn_keep_vec_names <- function() {
  message("Input to asJSON(keep_vec_names=TRUE) is a named vector. ", "In a future version of jsonlite, this option will not be supported, ", "and named vectors will be translated into arrays instead of objects. ", "If you want JSON object output, please use a named list instead. See ?toJSON.")
}
R/warn_keep_vec_names.R:1
R/asJSON.character.R

<statement> untypeable

unbound variable (line 4)
unbound: enc2utf8 — a name the prelude does not declare
error detail
name: enc2utf8
timing: 0.195 s
source
setMethod("asJSON", "character", function(x, collapse = TRUE, na = c("null", "string", "NA"), auto_unbox = FALSE, keep_vec_names = FALSE, indent = NA_integer_, ...) {
  # Needed for multi-byte Windows locales
  # See: https://github.com/jeroen/jsonlite/issues/329
  x <- enc2utf8(x)

  # shiny legacy exception
  if (isTRUE(keep_vec_names) && length(names(x))) {
    warn_keep_vec_names()
    return(asJSON(as.list(x), na = na, auto_unbox = TRUE, collapse = collapse, ...))
  }

  # vectorized escaping
  tmp <- deparse_vector(x)

  # this was used with deparse_vector_old
  #if(identical(Encoding(x), "UTF-8")){
  #  if(!grepl("UTF", Sys.getlocale("LC_CTYPE"), ignore.case=TRUE)){
  #    tmp <- utf8conv(tmp);
  #  }
  #}

  # validate NA
  if (any(missings <- which(is.na(x)))) {
    na <- match.arg(na)
    if (na %in% c("null")) {
      tmp[missings] <- "null"
    } else if (na %in% "string") {
      tmp[missings] <- "\"NA\""
    } else {
      tmp[missings] <- NA_character_
    }
  }

  if (isTRUE(auto_unbox) && length(tmp) == 1) {
    return(tmp)
  }

  # this is almost always true, except for class 'scalar'
  if (isTRUE(collapse)) {
    collapse(tmp, indent = indent)
  } else {
    tmp
  }
})
R/asJSON.character.R:1
R/asJSON.classRepresentation.R

<statement> untypeabletyped

unbound variable (line 9)
unbound: asJSON — a name the prelude does not declare
error detail
name: asJSON
gradual mode: typed
timing: 0.207 s
source
setMethod("asJSON", "classRepresentation", function(x, ...) {
  return(asJSON(attributes(x)$slots, ...))
})
R/asJSON.classRepresentation.R:8
R/asJSON.complex.R

<statement> untypeable

unbound variable (line 9)
unbound: prettyNum — a name the prelude does not declare
error detail
name: prettyNum
timing: 0.338 s
source
setMethod("asJSON", "complex", function(x, digits = 5, collapse = TRUE, complex = c("string", "list"), na = c("string", "null", "NA"), oldna = NULL, ...) {
  # validate
  na <- match.arg(na)
  complex <- match.arg(complex)

  #turn into strings
  if (complex == "string") {
    #default NA is "NA"
    mystring <- prettyNum(x = x, digits = digits)
    if (any(missings <- which(!is.finite(x)))) {
      if (na %in% c("null", "NA")) {
        mystring[missings] <- NA_character_
      }
    }
    asJSON(mystring, collapse = collapse, na = na, ...)
  } else {
    if (na == "NA") {
      na <- oldna
    }
    asJSON(list(real = Re(x), imaginary = Im(x)), na = na, digits = digits, ...)
  }
})
R/asJSON.complex.R:1
R/cleannames.R

cleannames untypeabletyped

unbound variable (line 6)
unbound: make.unique — a name the prelude does not declare
error detail
name: make.unique
gradual mode: typed
((objnames: "", no_dots: any?) | (objnames: vec & ~"", no_dots: any?) -> any)<>
timing: 0.581 s
source
cleannames <- function(objnames, no_dots = FALSE) {
  objnames[objnames == ""] <- NA_character_
  is_missing <- is.na(objnames)
  objnames[is_missing] <- as.character(seq_len(length(objnames)))[is_missing]
  if (isTRUE(no_dots)) objnames <- gsub(".", "_", objnames, fixed = TRUE)
  make.unique(objnames)
}
R/cleannames.R:1
R/collapse_object.R

collapse_object untypeabletyped

unbound variable (line 6)
unbound: C_collapse_object_pretty — a native symbol tyr could not bind
error detail
name: C_collapse_object_pretty
gradual mode: typed
((x: any_sexp, y: any_sexp, indent: any?) -> any)<>
timing: 0.165 s
source
collapse_object <- function(x, y, indent = 0L) {
  if (is.na(indent)) {
    .Call(C_collapse_object, x, y)
  } else {
    .Call(C_collapse_object_pretty, x, y, indent)
  }
}
R/collapse_object.R:2

row_collapse_object untypeabletyped

unbound variable (line 12)
unbound: C_row_collapse_object — a native symbol tyr could not bind
error detail
name: C_row_collapse_object
gradual mode: typed
((x: any, m: any, indent: any?) -> any)<>
timing: 0.009 s
source
row_collapse_object <- function(x, m, indent = NA_integer_) {
  .Call(C_row_collapse_object, x, m, indent = indent)
}
R/collapse_object.R:11
R/asJSON.data.frame.R

<statement> skipped

error detail
Failure("Unsupported argument after an ellipsis.")
timing: 0.006 s
source
setMethod("asJSON", "data.frame", function(x, na = c("NA", "null", "string"), collapse = TRUE, dataframe = c("rows", "columns", "values"), complex = "string", oldna = NULL, rownames = NULL, keep_vec_names = FALSE, indent = NA_integer_, no_dots = FALSE, ...) {
  # Coerse pairlist if needed
  if (is.pairlist(x)) {
    x <- as.vector(x, mode = "list")
  }

  # Validate some args
  dataframe <- match.arg(dataframe)
  has_names <- identical(length(names(x)), ncol(x))

  # Default to adding row names only if they are strings and not just stringified numbers
  if (isTRUE(rownames) || (is.null(rownames) && is.character(attr(x, "row.names")) && !all(grepl("^\\d+$", row.names(x))))) {
    # we don't use row.names() because this converts numbers to strings,
    # which will break sorting
    if (has_names) {
      x[["_row"]] <- attr(x, "row.names")
    }
  }

  # Unname named lists columns. These are very rare.
  namedlistvars <- which(vapply(x, is.namedlistnotdf, logical(1)))
  for (i in namedlistvars) {
    x[[i]] <- unname(x[[i]])
  }

  # Convert POSIXlt to POSIXct before we start messing with lists
  posvars <- which(vapply(x, is, logical(1), "POSIXlt"))
  for (i in posvars) {
    x[[i]] <- as.POSIXct(x[[i]])
  }

  # Column based is same as list. Do not pass collapse arg because it is a named list.
  if (dataframe == "columns") {
    return(asJSON(as.list(x), is_df = TRUE, na = na, dataframe = dataframe, complex = complex, rownames = rownames, indent = indent, no_dots = no_dots, ...))
  }

  # Determine "oldna". This is needed when the data frame contains a list column
  if (missing(na) || !length(na) || identical(na, "NA")) {
    oldna <- NULL
  } else {
    oldna <- na
  }

  # Set default for row based, don't do it earlier because it will affect 'oldna' or dataframe="columns"
  if (dataframe == "rows" && has_names) {
    na <- match.arg(na)
  }

  # no records
  if (!nrow(x)) {
    return(asJSON(list(), collapse = collapse, indent = indent))
  }

  # Convert raw vectors
  rawvars <- which(vapply(x, is.raw, logical(1)))
  for (i in rawvars) {
    x[[i]] <- as.character.hexmode(x[[i]])
  }

  # Turn complex vectors into data frames
  if (complex == "list") {
    complxvars <- which(vapply(x, is.complex, logical(1)))
    for (i in complxvars) {
      x[[i]] <- data.frame(real = Re(x[[i]]), imaginary = Im(x[[i]]))
    }
  }

  #create a matrix of json elements
  dfnames <- deparse_vector(cleannames(names(x), no_dots = no_dots))
  out <- vapply(x, asJSON, character(nrow(x)), collapse = FALSE, complex = complex, na = na, oldna = oldna, rownames = rownames, dataframe = dataframe, indent = indent_increment(indent), no_dots = no_dots, ..., USE.NAMES = FALSE)

  # This would be another way of doing the missing values
  # This does not require the individual classes to support na="NA"
  #if(identical(na, "NA")){
  #  namatrix <- vapply(x, is.na, logical(nrow(x)))
  #  out[namatrix] <- NA;
  #}

  #this is a workaround for vapply simplifying into a vector for n=1 (not for n=0 surprisingly)
  if (!is.matrix(out)) {
    out <- t(out)
  }

  # turn the matrix into json records
  # note: special row_collapse functions because apply is slow!
  tmp <- if (dataframe == "rows" && (length(dfnames) == ncol(out))) {
    #apply(out, 1, collapse_object, x = dfnames, indent = indent + 2L);
    row_collapse_object(dfnames, out, indent = indent_increment(indent))
  } else {
    # for dataframe = "values"
    #apply(out, 1, collapse, indent = indent);
    row_collapse(out, indent = indent)
  }

  #collapse
  if (isTRUE(collapse)) {
    collapse(tmp, inner = FALSE, indent = indent)
  } else {
    tmp
  }
})
R/asJSON.data.frame.R:1

is.namedlistnotdf untypeabletyped

unbound variable (line 104)
unbound: is.data.frame — a name the prelude does not declare
error detail
name: is.data.frame
gradual mode: typed
((x: any) -> LGL1<>)<>
timing: 0.041 s
source
is.namedlistnotdf <- function(x) {
  isTRUE(is.list(x) && !is.data.frame(x) && !is.null(names(x)))
}
R/asJSON.data.frame.R:103
R/asJSON.difftime.R

<statement> untypeabletyped

unbound variable (line 2)
unbound: as.vector — a name the prelude does not declare
error detail
name: as.vector
gradual mode: typed
timing: 0.004 s
source
setMethod("asJSON", "ts", function(x, ...) {
  asJSON(as.vector(x), ...)
})
R/asJSON.difftime.R:1

<statement> untypeable

untypeable application of base::as.numeric (line 7)
error detail
argument: @('x & (vec | null), units: "secs"<>)
failing call: base::as.numeric(as.raw(0), units = "secs")
timing: 0.091 s
source
setMethod("asJSON", "hms", function(x, hms = c("string", "secs"), ...) {
  hms <- match.arg(hms)
  output <- switch(hms, string = as.character(x), secs = as.numeric(x, units = "secs"))
  output[is.na(x)] <- NA
  asJSON(output, ...)
})
R/asJSON.difftime.R:5
R/asJSON.factor.R

<statement> untypeabletyped

unbound variable (line 8)
unbound: asJSON — a name the prelude does not declare
error detail
name: asJSON
gradual mode: typed
timing: 0.110 s
source
setMethod("asJSON", "factor", function(x, factor = c("string", "integer"), keep_vec_names = FALSE, ...) {
  # validate
  factor <- match.arg(factor)

  # dispatch
  if (factor == "integer") {
    # encode factor as enum
    asJSON(unclass(x), ...)
  } else {
    # encode as strings
    xc <- as.character(x)
    if (isTRUE(keep_vec_names)) {
      names(xc) <- names(x)
    }
    asJSON(xc, keep_vec_names = keep_vec_names, ...)
  }
})
R/asJSON.factor.R:1
R/asJSON.function.R

<statement> untypeabletyped

unbound variable (line 6)
unbound: deparse — a name the prelude does not declare
error detail
name: deparse
gradual mode: typed
timing: 0.072 s
source
setMethod("asJSON", "function", function(x, collapse = TRUE, fun = c("source", "list"), ...) {
  # validate
  fun <- match.arg(fun)

  if (fun == "source") {
    return(asJSON(deparse(x), ...))
  } else {
    return(asJSON(as.list(x), ...))
  }
})
R/asJSON.function.R:1
R/asJSON.json.R

<statement> untypeabletyped

unbound variable (line 6)
unbound: asJSON — a name the prelude does not declare
error detail
name: asJSON
gradual mode: typed
timing: 0.047 s
source
setMethod("asJSON", "json", function(x, json_verbatim = FALSE, ...) {
  if (isTRUE(json_verbatim)) {
    x
  } else {
    asJSON(as.character(x), ...)
  }
})
R/asJSON.json.R:2
R/asJSON.list.R

<statement> skipped

error detail
Failure("Unsupported positional argument after a named one.")
timing: 0.003 s
source
setMethod("asJSON", "list", function(x, collapse = TRUE, na = NULL, oldna = NULL, is_df = FALSE, auto_unbox = FALSE, indent = NA_integer_, no_dots = FALSE, ...) {
  # reset na arg when called from data frame
  if (identical(na, "NA")) {
    na <- oldna
  }

  # coerse pairlist if needed
  if (is.pairlist(x)) {
    x <- as.vector(x, mode = "list")
  }

  # empty vector
  #if (!length(x)) {
  #  if(collapse) {
  #    return(if (is.null(names(x))) "[]" else "{}")
  #  } else {
  #    return(character())
  #  }
  #}

  # this condition appears when a dataframe contains a column with lists we need to
  # do this, because the [ operator always returns a list of length 1
  # if (length(x) == 1 && is.null(names(x)) && collapse == FALSE) {
  #   return(asJSON(x[[1]], ...))
  # }

  # note we are NOT passing on the container argument.
  tmp <- if (is_df && auto_unbox) {
    vapply(
      x,
      function(y, ...) {
        asJSON(y, auto_unbox = is.list(y), ...)
      },
      character(1),
      na = na,
      indent = indent_increment(indent),
      no_dots = no_dots,
      ...
    )
  } else {
    vapply(x, asJSON, character(1), na = na, auto_unbox = auto_unbox, indent = indent_increment(indent), no_dots = no_dots, ...)
  }

  if (!is.null(names(x))) {
    if (!collapse) {
      #this should never happen
      warning("collapse=FALSE called for named list.")
    }
    #in case of named list:
    objnames <- deparse_vector(cleannames(names(x), no_dots = no_dots))
    collapse_object(objnames, tmp, indent)
  } else {
    #in case of unnamed list:
    if (collapse) {
      collapse(tmp, inner = FALSE, indent)
    } else {
      tmp
    }
  }
})
R/asJSON.list.R:1
R/asJSON.logical.R

<statement> untypeable

unbound variable (line 4)
unbound: warn_keep_vec_names — one of the package’s own names, itself untyped
error detail
name: warn_keep_vec_names
timing: 0.279 s
source
setMethod("asJSON", "logical", function(x, collapse = TRUE, na = c("null", "string", "NA"), auto_unbox = FALSE, keep_vec_names = FALSE, indent = NA_integer_, ...) {
  # shiny legacy exception
  if (isTRUE(keep_vec_names) && length(names(x))) {
    warn_keep_vec_names()
    return(asJSON(as.list(x), collapse = collapse, na = na, auto_unbox = TRUE, ...))
  }

  # validate arg
  na <- match.arg(na)

  # json true/false
  tmp <- ifelse(x, "true", "false")

  # replace missing values, unless na="NA"
  if (!identical(na, "NA")) {
    # logical values can have NA (but not Inf/NaN). Default is to encode as null.
    if (any(missings <- which(is.na(x)))) {
      tmp[missings] <- ifelse(identical(na, "string"), "\"NA\"", "null")
    }
  }

  #this is needed when !length(tmp) or all(is.na(tmp))
  if (!is.character(tmp)) {
    tmp <- as.character(tmp)
  }

  if (isTRUE(auto_unbox) && length(tmp) == 1) {
    return(tmp)
  }

  # collapse it
  if (collapse) {
    collapse(tmp, indent = indent)
  } else {
    tmp
  }
})
R/asJSON.logical.R:1
R/helpfunctions.R

S4tolist untypeabletyped

unbound variable (line 6)
unbound: slotNames — a name the prelude does not declare
error detail
name: slotNames
gradual mode: typed
((x: any) -> any)<>
timing: 0.004 s
source
S4tolist <- function(x) {
  structure(lapply(slotNames(x), slot, object = x), .Names = slotNames(x))
}
R/helpfunctions.R:5

givename typed any: obj fuzz ok

∀'a,'b. (((obj: any) -> any)&((obj: v('b)) -> v('b))&((obj: { 'a }) -> { 'a }))<>
timing: 0.090 s
fuzzing: 20 inside (10 ok, 5 error type, 5 invalid) · 8 outside (8 rejected)
type drawn from: (((obj: any) -> any) & ((obj: v('I30147)) -> v('I30147)) & ((obj: { 'I30146 }) -> { 'I30146 }))<>

Other calls inside the domain

callverdicterror
givename("obj" = list(NA))invalid
givename(NULL)error_typebase::structure: attempt to set an attribute on NULL
givename("obj" = list(c(2147483647L, 2147483647L)))invalid
givename(new.env())error_typebase::<-: names() applied to a non-vector
givename(list(-1))invalid
givename(function(...) local({ p <- unserialize(serialize(new("externalptr"), NULL)); attributes(p) <- NULL; p }))error_typebase::<-: names() applied to a non-vector
and 4 more
source
givename <- function(obj) {
  return(structure(obj, names = as.character(names(obj))))
}
R/helpfunctions.R:12

trim typed accepts outside

(((x: vec) -> CHR<>)&((x: vec1) -> CHR1<>))<>
timing: 0.046 s
fuzzing: 8 inside (8 ok) · 8 outside (2 rejected, 6 accepted)

Accepted outside the domain x: 6

parameterchangecallreturned
xkind:langtrim(quote(f(x)))(CHR & ~vec1)<> with { }
xkind:langtrim("x" = quote(f(x)))(CHR & ~vec1)<> with { }
xkind:listtrim("x" = list())(CHR & ~vec1)<> with { }
xwraptrim(list(c("é", NA_character_, NA_character_, "", "NA")))"c(\"\195\169\", NA, NA, \"\", \"NA\")"<> with { }
xwraptrim("x" = list(as.raw(c(255, 0, 0, 0, 255))))"as.raw(c(0xff, 0x00, 0x00, 0x00, 0xff))"<> with { }
xwraptrim("x" = list(complex(real = 1, imaginary = -2)))"1-2i"<> with { }
source
trim <- function(x) {
  gsub("(^[[:space:]]+|[[:space:]]+$)", "", x)
}
R/helpfunctions.R:17

wrapinquotes typed any: x fuzz ok

(((x: any) -> CHR<>)&((x: vec1) -> CHR1<>))<>
timing: 0.038 s
fuzzing: 7 inside (6 ok, 1 error type) · 8 outside (8 rejected)

Other calls inside the domain

callverdicterror
wrapinquotes("x" = local({ p <- unserialize(serialize(new("externalptr"), NULL)); attributes(p) <- NULL; p }))error_typebase::paste: cannot coerce type 'externalptr' to vector of type 'character'
source
wrapinquotes <- function(x) {
  paste("\"", x, "\"", sep = "")
}
R/helpfunctions.R:22

evaltext untypeabletyped

unbound variable (line 28)
unbound: parse — a name the prelude does not declare
error detail
name: parse
gradual mode: typed
((text: any) -> any)<>
timing: 0.004 s
source
evaltext <- function(text) {
  return(eval(parse(text = text)))
}
R/helpfunctions.R:27
R/num_to_char.R

num_to_char untypeable

untypeable application of base::is.numeric (line 5)
error detail
argument: @(((INT1 & ~^INT1)<> | (LGL1 & ~^LGL1)<>) | 'digits)
timing: 0.865 s
source
num_to_char <- function(x, digits = NA, na_as_string = NA, use_signif = FALSE, always_decimal = FALSE) {
  if (is.na(digits)) digits <- NA_integer_
  stopifnot(is.numeric(x))
  stopifnot(is.numeric(digits))
  stopifnot(is.logical(na_as_string))
  .Call(R_num_to_char, x, digits, na_as_string, use_signif, always_decimal)
}
R/num_to_char.R:2

integer64_to_char untypeabletyped

unbound variable (line 12)
unbound: R_integer64_to_char — a native symbol tyr could not bind
error detail
name: R_integer64_to_char
gradual mode: typed
((x: any, na_as_string: any?) -> any)<>
timing: 0.006 s
source
integer64_to_char <- function(x, na_as_string = TRUE) {
  .Call(R_integer64_to_char, x, na_as_string)
}
R/num_to_char.R:11

num_to_char_R untypeable

untypeable application of base::is.numeric (line 18)
error detail
argument: @(((INT1 & ~^INT1)<> | (LGL1 & ~^LGL1)<>) | 'digits)
timing: 0.734 s
source
num_to_char_R <- function(x, digits = NA, na_as_string = NA) {
  if (is.na(digits)) digits <- NA_integer_
  stopifnot(is.numeric(x))
  stopifnot(is.numeric(digits))
  stopifnot(is.logical(na_as_string))
  if (!is.integer(x) && !is.null(digits) && !is.na(digits)) {
    x <- round(x, digits)
  }

  #convert to strings
  tmp <- as.character(x)

  # in numeric variables, NA, NaN, Inf are replaced by character strings
  if (any(missings <- which(!is.finite(x)))) {
    if (is.na(na_as_string)) {
      tmp[missings] <- NA_character_
    } else if (na_as_string) {
      tmp[missings] <- wrapinquotes(x[missings])
    } else {
      tmp[missings] <- "null"
    }
  }

  #returns a character vector
  return(tmp)
}
R/num_to_char.R:15
R/asJSON.numeric.R

asjson_numeric_fun skipped

error detail
Failure("Unsupported positional argument after a named one.")
timing: 0.003 s
source
asjson_numeric_fun <- function(x, digits = 5, use_signif = is(digits, "AsIs"), na = c("string", "null", "NA"), auto_unbox = FALSE, collapse = TRUE, keep_vec_names = FALSE, indent = NA_integer_, always_decimal = FALSE, ...) {
  # shiny legacy exception
  if (isTRUE(keep_vec_names) && length(names(x))) {
    warn_keep_vec_names()
    return(asJSON(as.list(x), digits = digits, use_signif = use_signif, na = na, auto_unbox = TRUE, collapse = collapse, ...))
  }

  na <- match.arg(na)
  na_as_string <- switch(na, "string" = TRUE, "null" = FALSE, "NA" = NA, stop("invalid na_as_string"))

  # old R implementation
  # tmp <- num_to_char_R(x, digits, na_as_string);

  # fast C implementation
  tmp <- if (is(x, "integer64")) {
    integer64_to_char(x, na_as_string)
  } else {
    num_to_char(x, digits, na_as_string, use_signif, always_decimal)
  }

  if (isTRUE(auto_unbox) && length(tmp) == 1) {
    return(tmp)
  }

  if (collapse) {
    collapse(tmp, indent = indent)
  } else {
    tmp
  }
}
R/asJSON.numeric.R:1

<statement> untypeabletyped

unbound variable (line 33)
unbound: asjson_numeric_fun — one of the package’s own names, itself untyped
error detail
name: asjson_numeric_fun
gradual mode: typed
timing: 0.001 s
source
setMethod("asJSON", "numeric", asjson_numeric_fun)
R/asJSON.numeric.R:33

<statement> untypeabletyped

unbound variable (line 34)
unbound: asjson_numeric_fun — one of the package’s own names, itself untyped
error detail
name: asjson_numeric_fun
gradual mode: typed
timing: 0.000 s
source
setMethod("asJSON", "integer64", asjson_numeric_fun)
R/asJSON.numeric.R:34
R/asJSON.pairlist.R

<statement> untypeabletyped

unbound variable (line 2)
unbound: as.vector — a name the prelude does not declare
error detail
name: as.vector
gradual mode: typed
timing: 0.005 s
source
setMethod("asJSON", "pairlist", function(x, ...) {
  asJSON(as.vector(x, mode = "list"), ...)
})
R/asJSON.pairlist.R:1
R/base64.R

base64_dec untypeabletyped

unbound variable (line 21)
unbound: charToRaw — a name the prelude does not declare
error detail
name: charToRaw
gradual mode: typed
((input: p(CHR) | (~(CHR | RAW))<...> | sym | null) -> empty)<>
timing: 0.041 s
source
base64_dec <- function(input) {
  if (is.character(input)) {
    input <- charToRaw(paste(input, collapse = "\n"))
  }
  stopifnot(is.raw(input))
  .Call(R_base64_decode, input)
}
R/base64.R:19

base64_enc typed fuzz ok

((input: null) -> na_string<>)<>
gradual mode: typed
(((input: null) -> na_string<>)&((input: p(CHR) | (~(CHR | RAW))<...> | sym) -> empty))<>
timing: 0.084 s
fuzzing: 2 inside (2 ok) · 8 outside (8 rejected)
source
base64_enc <- function(input) {
  if (is.null(input)) return(NA_character_)
  if (is.character(input)) {
    input <- charToRaw(paste(input, collapse = "\n"))
  }
  stopifnot(is.raw(input))
  .Call(R_base64_encode, input)
}
R/base64.R:30

base64url_enc untypeabletyped

unbound variable (line 43)
unbound: chartr — a name the prelude does not declare
error detail
name: chartr
gradual mode: typed
(((input: p(CHR) | (~(CHR | RAW))<...> | sym) -> empty)&((input: p(CHR) | (~(CHR | RAW))<...> | sym | null) -> any))<>
timing: 0.013 s
source
base64url_enc <- function(input) {
  text <- base64_enc(input)
  sub("=+$", "", chartr('+/', '-_', text))
}
R/base64.R:41

fix_padding typed accepts outside

((text: vec) -> CHR1<>)<>
timing: 0.297 s
fuzzing: 6 inside (3 ok, 3 error type) · 8 outside (4 rejected, 4 accepted)

Accepted outside the domain text: 4

parameterchangecallreturned
textkind:langfix_padding("text" = quote(f(x)))"f==="<> with { }
textwrapfix_padding("text" = list(c("NA", NA_character_)))"c(\"NA\", NA)="<> with { }
textwrapfix_padding(list(c(NA, FALSE, NA, TRUE, TRUE)))"c(NA, FALSE, NA, TRUE, TRUE)"<> with { }
textwrapfix_padding(list(logical(0)))"logical(0)=="<> with { }

Other calls inside the domain

callverdicterror
fix_padding(c(NA, FALSE, NA, TRUE, TRUE))error_typebase::if: missing value where TRUE/FALSE needed
fix_padding("text" = NA_character_)error_typebase::if: missing value where TRUE/FALSE needed
fix_padding(logical(0))error_typebase::[[: subscript out of bounds
source
fix_padding <- function(text) {
  text <- gsub("[\r\n]", "", text)[[1]]
  mod <- nchar(text) %% 4
  if (mod > 0) {
    padding <- paste(rep("=", (4 - mod)), collapse = "")
    text <- paste0(text, padding)
  }
  text
}
R/base64.R:54

base64url_dec untypeabletyped

unbound variable (line 49)
unbound: chartr — a name the prelude does not declare
error detail
name: chartr
gradual mode: typed
((input: any) -> any)<>
timing: 0.004 s
source
base64url_dec <- function(input) {
  text <- fix_padding(chartr('-_', '+/', input))
  base64_dec(text)
}
R/base64.R:48
R/asJSON.raw.R

<statement> untypeabletyped

unbound variable (line 4)
unbound: asJSON — a name the prelude does not declare
error detail
name: asJSON
gradual mode: typed
timing: 0.124 s
source
setMethod("asJSON", "blob", function(x, raw = "base64", ...) {
  if (identical(raw, "base64")) {
    str <- vapply(x, base64_enc, character(1))
    return(asJSON(str, ...))
  }
  asJSON(as.list(x), raw = raw, ...)
})
R/asJSON.raw.R:1

<statement> untypeable

unbound variable (line 15)
unbound: ifelse — a name the prelude does not declare
error detail
name: ifelse
timing: 0.237 s
source
setMethod("asJSON", "raw", function(x, raw = c("base64", "hex", "mongo", "int", "js"), ...) {
  # validate
  raw <- match.arg(raw)

  # encode based on schema
  if (raw == "mongo") {
    type <- ifelse(length(attr(x, "type")), attr(x, "type"), 5)
    return(asJSON(list(`$binary` = as.scalar(base64_enc(x)), `$type` = as.scalar(as.character(type)))))
  } else if (raw == "hex") {
    return(asJSON(as.character.hexmode(x), ...))
  } else if (raw == "int") {
    return(asJSON(as.integer(x), ...))
  } else if (raw == "js") {
    paste0('(new Uint8Array(', asJSON(as.integer(x), collapse = TRUE), '))')
  } else {
    # no as scalar here!
    return(asJSON(base64_enc(x), ...))
  }
})
R/asJSON.raw.R:9
R/asJSON.scalar.R

<statement> untypeabletyped

unbound variable (line 10)
unbound: asJSON — a name the prelude does not declare
error detail
name: asJSON
gradual mode: typed
timing: 0.141 s
source
setMethod("asJSON", "scalar", function(x, collapse, ...) {
  # TODO: There must be a way to do this with NextMethod()
  if (length(class(x)) > 1) {
    class(x) <- class(x)[-1]
  } else {
    x <- unclass(x)
  }

  # Print JSON without []
  return(asJSON(x, collapse = FALSE, ...))
})
R/asJSON.scalar.R:1
R/unbox.R

unbox typed fuzz ok

∀'a. ((x: 'a & null) -> 'a)<>
gradual mode: typed
∀'a,'b. (((x: 'a & 'b<...>) -> 'b<...>)&((x: 'a & null) -> 'a))<>
timing: 0.179 s
fuzzing: 2 inside (2 ok) · 8 outside (8 rejected)
type drawn from: ((x: 'x & null) -> 'x)<>
source
unbox <- function(x) {
  if (is.null(x)) {
    return(x)
  }
  if (is.data.frame(x)) {
    if (nrow(x) == 1) {
      return(as.scalar(x))
    } else {
      stop("Tried to unbox dataframe with ", nrow(x), " rows.")
    }
  }
  if (length(x) == 1L && inherits(x, "POSIXt")) {
    return(as.scalar(x))
  }
  if (is.null(x) || !is.atomic(x) || length(dim(x)) > 1) {
    stop("Only atomic vectors of length 1 or data frames with 1 row can be unboxed.")
  }
  if (identical(length(x), 1L)) {
    return(as.scalar(x))
  } else {
    stop("Tried to unbox a vector of length ", length(x))
  }
}
R/unbox.R:33
R/asJSON.sf.R

<statement> untypeabletyped

unbound variable (line 5)
unbound: callNextMethod — a name the prelude does not declare
error detail
name: callNextMethod
gradual mode: typed
timing: 0.083 s
source
setMethod("asJSON", "sf", function(x, sf = c("dataframe", "features", "geojson"), ...) {
  sf <- match.arg(sf)
  if (sf == 'dataframe') {
    callNextMethod()
  } else {
    sf_column <- attr(x, 'sf_column')
    if (!length(sf_column)) sf_column <- 'geometry'
    geometry <- x[[sf_column]]
    input <- as.data.frame(x)
    features <- data.frame(type = rep('Feature', nrow(input)), stringsAsFactors = FALSE)
    features$properties = input[names(input) != sf_column]
    features$geometry = geometry
    if (sf == 'features') {
      asJSON(features, sf = sf, ...)
    } else {
      output <- list(
        type = unbox('FeatureCollection'),
        name = unbox('sfdata'),
        features = features
      )
      asJSON(output, sf = sf, ...)
    }
  }
})
R/asJSON.sf.R:2

<statement> untypeabletyped

unbound variable (line 28)
unbound: geom_to_geojson — one of the package’s own names, itself untyped
error detail
name: geom_to_geojson
gradual mode: typed
timing: 0.011 s
source
setMethod("asJSON", "sfc", function(x, ...) {
  y <- lapply(unclass(x), geom_to_geojson)
  asJSON(y, ...)
})
R/asJSON.sf.R:27

sf_to_titlecase untypeabletyped

unbound variable (line 48)
unbound: match — a name the prelude does not declare
error detail
name: match
gradual mode: typed
((x: vec | null) -> any)<>
timing: 0.112 s
source
sf_to_titlecase <- function(x) {
  sf_types <-
    c("Point", "LineString", "Polygon", "MultiPoint", "MultiLineString", "MultiPolygon", "GeometryCollection", "CircularString", "CompoundCurve", "CurvePolygon", "MultiCurve", "MultiSurface", "Curve", "Surface", "PolyhedralSurface", "TIN", "Triangle")
  matches <- match(as.character(x), toupper(sf_types))
  sf_types[matches]
}
R/asJSON.sf.R:45

geom_to_geojson untypeable

unbound variable (line 34)
unbound: sf_to_titlecase — one of the package’s own names, itself untyped
error detail
name: sf_to_titlecase
timing: 0.024 s
source
geom_to_geojson <- function(x) {
  val <- list(
    type = unbox(sf_to_titlecase(class(x)[2])) # see: sf::st_geometry_type
  )
  if (inherits(x, "GEOMETRYCOLLECTION")) {
    val$geometries = lapply(x, geom_to_geojson)
  } else {
    val$coordinates = unclass(x)
  }
  return(val)
}
R/asJSON.sf.R:32
R/asJSON.vctrs.R

<statement> untypeabletyped

unbound variable (line 4)
unbound: asJSON — a name the prelude does not declare
error detail
name: asJSON
gradual mode: typed
timing: 0.035 s
source
setMethod("asJSON", "vctrs_vctr", function(x, ...) {
  # dispatch based on the underlying type
  class(x) <- setdiff(class(x), 'vctrs_vctr')
  asJSON(x, ...)
})
R/asJSON.vctrs.R:1
R/fixNativeSymbol.R

fixNativeSymbol untypeabletimeout

unbound variable (line 2)
unbound: is — a name the prelude does not declare
error detail
name: is
gradual mode: timeout
timing: 0.039 s
source
fixNativeSymbol <- function(symbol) {
  if (is(symbol, "NativeSymbolInfo")) {
    # method depends on version
    rVersion <- getRversion()

    if (rVersion >= "3.0") {
      # in R 3.0 determine the dll that the symbol lives in
      name <- ifelse(is.null(symbol$package), symbol$dll[["name"]], symbol$package[["name"]])

      # load package if not yet loaded
      try(getNamespace(name))
      pkgDLL <- getLoadedDLLs()[[name]]

      # reconstruct the native symbol address
      newsymbol <- getNativeSymbolInfo(name = symbol$name, PACKAGE = pkgDLL, withRegistrationInfo = TRUE)
      symbol$address <- newsymbol$address
      return(symbol)
    } else if (rVersion >= "2.14") {
      return(getNativeSymbolInfo(symbol$name))
    }
  } else {
    return(symbol)
  }
}
R/fixNativeSymbol.R:1
R/flatten.R

flatten untypeable

unbound variable (line 30)
unbound: is.data.frame — a name the prelude does not declare
error detail
name: is.data.frame
timing: 0.192 s
source
flatten <- function(x, recursive = TRUE) {
  stopifnot(is.data.frame(x))
  nr <- nrow(x)
  dfcolumns <- vapply(x, is.data.frame, logical(1))
  if (!any(dfcolumns)) {
    return(x)
  }
  x <- if (recursive) {
    c(x[!dfcolumns], do.call(c, lapply(x[dfcolumns], flatten)))
  } else {
    c(x[!dfcolumns], do.call(c, x[dfcolumns]))
  }
  class(x) <- "data.frame"
  row.names(x) <- if (!nr) character(0) else 1:nr
  x
}
R/flatten.R:29
R/push_parser.R

parse_con untypeabletyped

unbound variable (line 4)
unbound: isOpen — a name the prelude does not declare
error detail
name: isOpen
gradual mode: typed
((con: <connection, ...>, bigint_as_char: any) -> any)<>
timing: 0.027 s
source
parse_con <- function(con, bigint_as_char) {
  stopifnot(inherits(con, "connection"))
  if (!isOpen(con)) {
    on.exit(close(con)) # also destroy con if 'open' fails
    open(con, "rb")
  }
  .Call(R_parse_connection, con, bigint_as_char)
}
R/push_parser.R:2
R/parseJSON.R

parse_string untypeabletyped

unbound variable (line 14)
unbound: R_parse — a native symbol tyr could not bind
error detail
name: R_parse
gradual mode: typed
((txt: any, bigint_as_char: any) -> any)<>
timing: 0.040 s
source
parse_string <- function(txt, bigint_as_char) {
  if (length(txt) > 1) {
    txt <- paste(txt, collapse = "\n")
  }
  .Call(R_parse, txt, bigint_as_char)
}
R/parseJSON.R:10

parseJSON untypeabletyped

unbound variable (line 3)
unbound: parse_con — one of the package’s own names, itself untyped
error detail
name: parse_con
gradual mode: typed
((txt: <connection, ...>, bigint_as_char: any?) -> any)<>
timing: 0.025 s
source
parseJSON <- function(txt, bigint_as_char = FALSE) {
  if (inherits(txt, "connection")) {
    parse_con(txt, bigint_as_char)
  } else {
    parse_string(txt, bigint_as_char)
  }
}
R/parseJSON.R:1
R/is.scalarlist.R

is_scalarlist_r untypeabletyped

unbound variable (line 4)
unbound: is.atomic — a name the prelude does not declare
error detail
name: is.atomic
gradual mode: typed
(((x: list | vec) -> ff<> | tt<>)&((x: { }) -> tt<>))<>
timing: 0.113 s
source
is_scalarlist_r <- function(x) {
  if (!is.list(x)) return(FALSE)
  for (i in x) {
    if (!is.atomic(i) || length(i) > 1) return(FALSE)
  }
  return(TRUE)
}
R/is.scalarlist.R:1

is_scalarlist_c typed fuzz ok

(((x: p(CHR) | (~(list & ~{ any_sexp }))<...> | sym | null) -> ^LGL1)&((x: { }) -> tt))<>
timing: 0.044 s
fuzzing: 5 inside (5 ok) · 6 outside (6 rejected)
source
is_scalarlist_c <- function(x) {
  .Call(C_is_scalarlist, x)
}
R/is.scalarlist.R:10

is.scalarlist typed fuzz ok

(((x: p(CHR) | (~(list & ~{ any_sexp }))<...> | sym | null) -> ^LGL1)&((x: { }) -> tt))<>
timing: 0.016 s
fuzzing: 6 inside (6 ok) · 7 outside (7 rejected)
source
is.scalarlist <- is_scalarlist_c
R/is.scalarlist.R:14
R/null_to_na.R

null_to_na untypeabletyped

unbound variable (line 3)
unbound: C_null_to_na — a native symbol tyr could not bind
error detail
name: C_null_to_na
gradual mode: typed
((x: any) -> any)<>
timing: 0.001 s
source
null_to_na <- function(x) {
  .Call(C_null_to_na, x)
}
R/null_to_na.R:2

is_datelist typed accepts outside

((x: p(CHR) | (env | externalptr | lang | vec | arrow) | sym | null) -> ff)<>
timing: 0.024 s
fuzzing: 6 inside (6 ok) · 8 outside (4 rejected, 4 accepted)

Accepted outside the domain x: 4

parameterchangecallreturned
xkind:listis_datelist("x" = list())ff<> with { }
xwrapis_datelist(list(function(...) quote(f(x))))ff<> with { }
xwrapis_datelist("x" = list(new.env()))ff<> with { }
xwrapis_datelist(list(function(...) list()))ff<> with { }
source
is_datelist <- function(x) {
  .Call(C_is_datelist, x)
}
R/null_to_na.R:7
R/list_to_vec.R

list_to_vec untypeable

unbound variable (line 3)
unbound: null_to_na — one of the package’s own names, itself untyped
error detail
name: null_to_na
timing: 0.062 s
source
list_to_vec <- function(x) {
  isdates <- is_datelist(x)
  out <- unlist(null_to_na(x), recursive = FALSE, use.names = FALSE)
  if (isdates && is.numeric(out)) {
    structure(out, class = c("POSIXct", "POSIXt"))
  } else {
    out
  }
}
R/list_to_vec.R:1
R/transpose_list.R

transpose_list untypeabletyped

unbound variable (line 3)
unbound: C_transpose_list — a native symbol tyr could not bind
error detail
name: C_transpose_list
gradual mode: typed
((x: any, names: any) -> any)<>
timing: 0.003 s
source
transpose_list <- function(x, names) {
  .Call(C_transpose_list, x, names)
}
R/transpose_list.R:2
R/simplifyDataFrame.R

simplifyDataFrame untypeable

unbound variable (line 5)
unbound: as.data.frame — a name the prelude does not declare
error detail
name: as.data.frame
timing: 0.350 s
source
simplifyDataFrame <- function(recordlist, columns, flatten, simplifyMatrix) {
  # no records at all
  if (!length(recordlist)) {
    if (!missing(columns)) {
      return(as.data.frame(matrix(ncol = length(columns), nrow = 0, dimnames = list(NULL, columns))))
    } else {
      return(data.frame())
    }
  }

  # only empty records and unknown columns
  if (!any(vapply(recordlist, length, integer(1), USE.NAMES = FALSE)) && missing(columns)) {
    return(data.frame(matrix(nrow = length(recordlist), ncol = 0)))
  }

  # find columns if not specified
  if (missing(columns)) {
    columns <- unique(unlist(lapply(recordlist, names), recursive = FALSE, use.names = FALSE))
  }

  # Convert row lists to column lists. This is the heavy lifting
  # columnlist <- lapply(columns, function(x) lapply(recordlist, "[[", x))
  # Now slighlty optimized
  columnlist <- transpose_list(recordlist, columns)

  # simplify vectors and nested data frames
  columnlist <- lapply(columnlist, simplify, simplifyVector = TRUE, simplifyDataFrame = TRUE, simplifyMatrix = FALSE, simplifySubMatrix = simplifyMatrix, flatten = flatten)

  # check that all elements have equal length
  columnlengths <- unlist(vapply(
    columnlist,
    function(z) {
      ifelse(length(dim(z)) > 1, nrow(z), length(z))
    },
    integer(1)
  ))
  n <- unique(columnlengths)
  if (length(n) > 1) {
    stop("Elements not of equal length: ", paste(columnlengths, collapse = " "))
  }

  # add the column names before flattening
  names(columnlist) <- columns

  # flatten nested data frames
  if (isTRUE(flatten)) {
    dfcolumns <- vapply(columnlist, is.data.frame, logical(1))
    if (any(dfcolumns)) {
      columnlist <- c(columnlist[!dfcolumns], do.call(c, columnlist[dfcolumns]))
    }
  }

  # make into data frame
  class(columnlist) <- "data.frame"

  # set row names
  if ("_row" %in% names(columnlist)) {
    rn <- columnlist[["_row"]]
    columnlist["_row"] <- NULL

    # row.names() casts double to character which is undesired.
    if (is.double(rn)) {
      rn <- as.integer(rn)
    }

    # Replace missing values with numbers
    rn_na <- is.na(rn)
    if (sum(rn_na) > 0) {
      rn[rn_na] <- paste0("NA_", seq_len(sum(rn_na)))
    }

    # data frames MUST have row names
    if (any(duplicated(rn))) {
      warning('Duplicate names in "_row" field. Data frames must have unique row names.', call. = FALSE)
      if (is.character(rn)) {
        row.names(columnlist) <- make.unique(rn)
      } else {
        row.names(columnlist) <- seq_len(n)
      }
    } else {
      row.names(columnlist) <- rn
    }
  } else {
    row.names(columnlist) <- seq_len(n)
  }

  return(columnlist)
}
R/simplifyDataFrame.R:1
R/simplify.R

all_identical typed accepts outside

((x: list<@"[", ...> | vec<@"[", ...>) | (x: list<~@"[", ...>) | (x: vec<~@"[", ...>) -> ff<> | tt<>)<>
timing: 0.343 s
fuzzing: 8 inside (3 ok, 5 error type) · 7 outside (5 rejected, 2 accepted)

Accepted outside the domain x: 2

parameterchangecallreturned
xkind:nullall_identical("x" = NULL)ff<> with { }
xkind:nullall_identical(NULL)ff<> with { }

Other calls inside the domain

callverdicterror
all_identical("x" = list(NULL, c(NA_character_, "")))error_typebase::if: argument is of length zero
all_identical("x" = list(list(NULL, quote(f(x)))))error_typebase::!=: comparison of these types is not implemented
all_identical(NA_complex_)error_typebase::if: missing value where TRUE/FALSE needed
all_identical(NA)error_typebase::if: missing value where TRUE/FALSE needed
all_identical(list(list(), list(function(...) list(), new.env())))error_typebase::if: argument is of length zero
source
all_identical <- function(x) {
  if (!length(x)) return(FALSE)
  for (i in x) {
    if (x[1] != i) return(FALSE)
  }
  return(TRUE)
}
R/simplify.R:136

is.arraylist untypeabletyped

unbound variable (line 109)
unbound: is.array — a name the prelude does not declare
error detail
name: is.array
gradual mode: typed
((x: list) | (x: vec) -> LGL1<>)<>
timing: 0.167 s
source
is.arraylist <- function(x) {
  isTRUE(
    is.list(x) &&
      length(x) &&
      is.null(names(x)) &&
      all(vapply(x, is.array, logical(1))) &&
      all_identical(vapply(
        x,
        function(y) {
          paste(dim(y), collapse = "-")
        },
        character(1)
      ))
  )
}
R/simplify.R:104

is.datelist typed accepts outside

((x: (CLX | LGL | RAW)<~@"[[", ...>) | (x: (DBL | INT)<~@"[[", ...>) | (x: <@"[[", ...>) | (x: CHR<~@"[[", ...>) | (x: { $date: CHR, any }<~@"[[", ...>) | (x: { $date: DBL | INT, any }<~@"[[", ...>) | (x: { $date: ~(CHR | DBL | INT), any }<~@"[[", ...>) | (x: { ~(CHR | DBL | INT) }<~@"[[", ...>) -> LGL1<>)<>
timing: 7.73 s
fuzzing: 8 inside (8 ok) · 6 outside (3 rejected, 3 accepted)

Accepted outside the domain x: 3

parameterchangecallreturned
xkind:envis.datelist("x" = new.env())ff<> with { }
xkind:nullis.datelist("x" = NULL)ff<> with { }
xkind:symis.datelist("x" = as.name("x"))ff<> with { }
source
is.datelist <- function(x) {
  isTRUE(is.list(x) && identical(names(x), "$date") && (is.numeric(x[["$date"]]) || is.character(x[["$date"]])))
}
R/simplify.R:120

is.matrixlist untypeabletyped

unbound variable (line 99)
unbound: is.atomic — a name the prelude does not declare
error detail
name: is.atomic
gradual mode: typed
((x: list) | (x: vec) -> LGL1<>)<>
timing: 0.160 s
source
is.matrixlist <- function(x) {
  isTRUE(
    is.list(x) && length(x) && is.null(names(x)) && all(vapply(x, is.atomic, logical(1))) && all_identical(vapply(x, length, integer(1)))
    #&& all_identical(vapply(x, mode, character(1))) #this fails for: [ [ 1, 2 ], [ "NA", "NA" ] ]
  )
}
R/simplify.R:97

parse_date typed fuzz ok

∀'a. (((x: 'a & (DBL | INT)<@"/", ~Date, ~POSIXt, ~difftime, ~factor, ...>) -> DBL | LGL)&((x: 'a & (DBL | INT)<~Date, ~POSIXt, ~@"/", ~difftime, ~factor, ...>) -> DBL)&((x: 'a & (DBL<@"/", ...> | INT<@"/", ...>)) -> (DBL | LGL) | 'a)&((x: 'a & (DBL<~@"/", ...> | INT<~@"/", ...>)) -> DBL | 'a)&((x: 'a \ (CHR | DBL | INT)) -> 'a))<>
gradual mode: typed
∀'a. (((x: 'a & CHR) -> any)&((x: 'a & (DBL | INT)<@"/", ~Date, ~POSIXt, ~difftime, ~factor, ...>) -> DBL | LGL)&((x: 'a & (DBL | INT)<~Date, ~POSIXt, ~@"/", ~difftime, ~factor, ...>) -> DBL)&((x: 'a & (DBL<@"/", ...> | INT<@"/", ...>)) -> (DBL | LGL) | 'a)&((x: 'a & (DBL<~@"/", ...> | INT<~@"/", ...>)) -> DBL | 'a)&((x: 'a \ (CHR | DBL | INT)) -> 'a))<>
timing: 1.87 s
fuzzing: 16 inside (16 ok) · 8 outside (8 rejected)
type drawn from: (((x: 'x & (DBL | INT)<@"/", ~Date, ~POSIXt, ~difftime, ~factor, ...>) -> DBL | LGL) & ((x: 'x & (DBL | INT)<~Date, ~POSIXt, ~@"/", ~difftime, ~factor, ...>) -> DBL) & ((x: 'x & (DBL<@"/", ...> | INT<@"/", ...>)) -> (DBL | LGL) | 'x) & ((x: 'x & (DBL<~@"/", ...> | INT<~@"/", ...>)) -> DBL | 'x) & ((x: 'x \ (CHR | DBL | INT)) -> 'x))<>
source
parse_date <- function(x) {
  if (is.numeric(x)) {
    return(structure(x / 1000, class = c("POSIXct", "POSIXt")))
  } else if (is.character(x)) {
    #tz is not vectorized, so assume all() are the same
    is_utc <- ifelse(all(grepl("Z$", x)), "UTC", "")
    return(as.POSIXct(strptime(x, format = '%Y-%m-%dT%H:%M:%OS', tz = is_utc)))
  } else {
    return(x)
  }
}
R/simplify.R:124

simplify untypeable

unbound variable (line 18)
unbound: list_to_vec — one of the package’s own names, itself untyped
error detail
name: list_to_vec
timing: 4.81 s
source
simplify <- function(x, simplifyVector = TRUE, simplifyDataFrame = TRUE, simplifyMatrix = TRUE, simplifyDate = simplifyVector, homoList = TRUE, flatten = FALSE, columnmajor = FALSE, simplifySubMatrix = simplifyMatrix) {
  #This includes '[]' and '{}')
  if (!is.list(x) || !length(x)) {
    return(x)
  }

  # list can be a dataframe recordlist
  if (isTRUE(simplifyDataFrame) && is.recordlist(x)) {
    mydf <- simplifyDataFrame(x, flatten = flatten, simplifyMatrix = simplifySubMatrix)
    if (isTRUE(simplifyDate) && is.data.frame(mydf) && is.datelist(mydf)) {
      return(parse_date(mydf[["$date"]]))
    }
    return(mydf)
  }

  # or a scalar list (atomic vector)
  if (isTRUE(simplifyVector) && is.null(names(x)) && is.scalarlist(x)) {
    return(list_to_vec(x))
  }

  # apply recursively
  out <- lapply(x, simplify, simplifyVector = simplifyVector, simplifyDataFrame = simplifyDataFrame, simplifyMatrix = simplifySubMatrix, columnmajor = columnmajor, flatten = flatten)

  # fix for mongo style dates turning into scalars *after* simplifying
  # only happens when simplifyDataframe=FALSE
  if (isTRUE(simplifyVector) && is.scalarlist(out) && all(vapply(out, inherits, logical(1), "POSIXt"))) {
    return(structure(list_to_vec(out), class = c("POSIXct", "POSIXt")))
  }

  # test for matrix. Note that we have to take another look at x (before
  # list_to_vec on its elements) to differentiate between matrix and vector.
  if (isTRUE(simplifyMatrix) && isTRUE(simplifyVector) && is.matrixlist(out) && all(unlist(vapply(x, is.scalarlist, logical(1))))) {
    if (isTRUE(columnmajor)) {
      return(do.call(cbind, out))
    } else {
      #this is currently the default
      return(do.call(rbind, out))
    }
  }

  # Simplify higher arrays
  if (isTRUE(simplifyMatrix) && is.arraylist(out)) {
    if (isTRUE(columnmajor)) {
      return(array(
        data = do.call(cbind, out),
        dim = c(dim(out[[1]]), length(out))
      ))
    } else {
      #this is currently the default
      return(array(
        data = do.call(rbind, lapply(out, as.vector)),
        dim = c(length(out), dim(out[[1]]))
      ))
    }
  }

  # try to enfoce homoList on unnamed lists
  if (isTRUE(homoList) && is.null(names(out))) {
    # coerse empty lists, caused by the ambiguous fromJSON('[]')
    isemptylist <- vapply(out, identical, logical(1), list())
    if (any(isemptylist) & !all(isemptylist)) {
      # if all the others look like data frames, coerse to data frames!
      if (all(vapply(out[!isemptylist], is.data.frame, logical(1)))) {
        for (i in which(isemptylist)) {
          out[[i]] <- data.frame()
        }
        return(out)
      }

      # if all others look like atomic vectors, unlist all
      if (
        all(vapply(
          out[!isemptylist],
          function(z) {
            isTRUE(is.vector(z) && is.atomic(z))
          },
          logical(1)
        ))
      ) {
        for (i in which(isemptylist)) {
          out[[i]] <- vector(mode = typeof(out[[which(!isemptylist)[1]]]))
        }
        return(out)
      }
    }
  }

  # convert date object
  if (isTRUE(simplifyDate) && is.datelist(out)) {
    return(parse_date(out[["$date"]]))
  }

  # return object
  return(out)
}
R/simplify.R:1
R/validate.R

validate untypeabletyped

unbound variable (line 18)
unbound: R_validate — a native symbol tyr could not bind
error detail
name: R_validate
gradual mode: typed
((txt: CHR) | (txt: ~CHR) -> any)<>
timing: 0.031 s
source
validate <- function(txt) {
  stopifnot(is.character(txt))
  txt <- paste(txt, collapse = "\n")
  .Call(R_validate, as.character(txt))
}
R/validate.R:15
R/fromJSON.R

parse_and_simplify untypeabletyped

unbound variable (line 105)
unbound: message — a name the prelude does not declare
error detail
name: message
gradual mode: typed
((txt: <connection, ...>, simplifyVector: any?, simplifyDataFrame: any?, simplifyMatrix: any?, flatten: any?, unicode: any?, validate: any?, bigint_as_char: any?, ...: any) -> any)<>
timing: 0.190 s
source
parse_and_simplify <- function(txt, simplifyVector = TRUE, simplifyDataFrame = simplifyVector, simplifyMatrix = simplifyVector, flatten = FALSE, unicode = TRUE, validate = TRUE, bigint_as_char = FALSE, ...) {
  if (!missing(unicode)) {
    message("Argument unicode has been deprecated. YAJL always parses unicode.")
  }

  if (!missing(validate)) {
    message("Argument validate has been deprecated. YAJL automatically validates json while parsing.")
  }

  # parse
  obj <- parseJSON(txt, bigint_as_char)

  # post processing
  if (any(isTRUE(simplifyVector), isTRUE(simplifyDataFrame), isTRUE(simplifyMatrix))) {
    return(simplify(obj, simplifyVector = simplifyVector, simplifyDataFrame = simplifyDataFrame, simplifyMatrix = simplifyMatrix, flatten = flatten, ...))
  } else {
    return(obj)
  }
}
R/fromJSON.R:103

fromJSON untypeable

unbound variable (line 85)
unbound: validate — one of the package’s own names, itself untyped
error detail
name: validate
timing: 0.888 s
source
fromJSON <- function(txt, simplifyVector = TRUE, simplifyDataFrame = simplifyVector, simplifyMatrix = simplifyVector, flatten = FALSE, ...) {
  # check type
  if (!is.character(txt) && !inherits(txt, "connection")) {
    stop("Argument 'txt' must be a JSON string, URL or file.")
  }

  # overload for URL or path
  if (is.character(txt) && length(txt) == 1 && nchar(txt, type = "bytes") < 2084 && !validate(txt)) {
    if (grepl("^https?://", txt, useBytes = TRUE)) {
      txt <- if (R.version$major < 4) {
        base::url(txt)
      } else {
        base::url(txt, headers = c(Accept = "application/json, text/*, */*"))
      }
    } else if (file.exists(txt)) {
      # With files we can never know for sure the encoding. Lets try UTF8 first.
      # txt <- raw_to_json(readBin(txt, raw(), file.info(txt)$size));
      txt <- file(txt)
    }
  }

  # call the actual function (with deprecated arguments)
  parse_and_simplify(txt = txt, simplifyVector = simplifyVector, simplifyDataFrame = simplifyDataFrame, simplifyMatrix = simplifyMatrix, flatten = flatten, ...)
}
R/fromJSON.R:78

fromJSON_string untypeabletyped

unbound variable (line 125)
unbound: parse_and_simplify — one of the package’s own names, itself untyped
error detail
name: parse_and_simplify
gradual mode: typed
((txt: <connection, ...>, simplifyVector: any?, simplifyDataFrame: any?, simplifyMatrix: any?, flatten: any?, unicode: any?, validate: any?, bigint_as_char: any?, ...: any) -> any)<>
timing: 0.000 s
source
fromJSON_string <- parse_and_simplify
R/fromJSON.R:125
R/json_gzip.R

as_gzjson_raw untypeabletyped

unbound variable (line 22)
unbound: toJSON — one of the package’s own names, itself untyped
error detail
name: toJSON
gradual mode: typed
((x: any, ...: any) -> any)<>
timing: 0.005 s
source
as_gzjson_raw <- function(x, ...) {
  json <- toJSON(x = x, ...)
  memCompress(json, 'gzip')
}
R/json_gzip.R:21

as_gzjson_b64 untypeable

unbound variable (line 29)
unbound: as_gzjson_raw — one of the package’s own names, itself untyped
error detail
name: as_gzjson_raw
timing: 0.004 s
source
as_gzjson_b64 <- function(x, ...) {
  buf <- as_gzjson_raw(x = x, ...)
  base64_enc(buf)
}
R/json_gzip.R:28

parse_gzjson_raw untypeabletyped

unbound variable (line 37)
unbound: memDecompress — a name the prelude does not declare
error detail
name: memDecompress
gradual mode: typed
((buf: any, ...: any) -> any)<>
timing: 0.005 s
source
parse_gzjson_raw <- function(buf, ...) {
  json <- rawToChar(memDecompress(buf, 'gzip'))
  fromJSON(json, ...)
}
R/json_gzip.R:36

parse_gzjson_b64 untypeabletyped

unbound variable (line 45)
unbound: base64_dec — one of the package’s own names, itself untyped
error detail
name: base64_dec
gradual mode: typed
((b64: p(CHR) | (~(CHR | RAW))<...> | sym | null, ...: any) -> empty)<>
timing: 0.004 s
source
parse_gzjson_b64 <- function(b64, ...) {
  parse_gzjson_raw(base64_dec(b64), ...)
}
R/json_gzip.R:44
R/loadpkg.R

loadpkg untypeabletyped

unbound variable (line 2)
unbound: getNamespace — a name the prelude does not declare
error detail
name: getNamespace
gradual mode: typed
((pkg: any) -> any)<>
timing: 0.006 s
source
loadpkg <- function(pkg) {
  tryCatch(getNamespace(pkg), error = function(e) {
    stop("Required package ", pkg, " not found. Please run: install.packages('", pkg, "')", call. = FALSE)
  })
}
R/loadpkg.R:1
R/makesymbol.R

makesymbol untypeabletyped

unbound variable (line 5)
unbound: substitute — a name the prelude does not declare
error detail
name: substitute
gradual mode: typed
((x: vec) -> any)<>
timing: 0.071 s
source
makesymbol <- function(x) {
  if (missing(x) || nchar(x) == 0) {
    return(substitute())
  } else {
    as.name(x)
  }
}
R/makesymbol.R:3
R/pack.R

pack skipped

error detail
Failure("Unsupported positional argument after a named one.")
timing: 0.001 s
source
pack <- function(obj, ...) {
  # encode by storage mode
  encoding.mode <- typeof(obj)

  # null may not have attributes
  if (encoding.mode == "NULL" || identical(obj, as.name('\001NULL\001'))) {
    return(list(type = as.scalar("NULL")))
  }

  # needed because formals become attributes, etc
  if (encoding.mode == "closure") {
    obj <- as.list(obj)
  }

  # special exception
  if (encoding.mode == "environment" && isNamespace(obj)) {
    encoding.mode <- "namespace"
  }

  # Strip off 'class' from S4 attributes
  attrib <- attributes(obj)
  if (isS4(obj)) {
    encoding.mode <- "S4"
    if (".Data" %in% slotNames(obj)) {
      attrib[[".Data"]] = obj@.Data
    }
    attrib <- attrib[slotNames(obj)]
    names(attrib) <- slotNames(obj)
  }

  # encode recursively
  list(
    type = as.scalar(encoding.mode),
    attributes = givename(lapply(attrib, pack, ...)),
    value = switch(
      encoding.mode,
      environment = NULL,
      externalptr = NULL,
      namespace = lapply(as.list(getNamespaceInfo(obj, "spec")), as.scalar),
      S4 = list(class = as.scalar(class(obj)), package = as.scalar(attr(class(obj), "package"))),
      raw = as.scalar(base64_enc(unclass(obj))),
      logical = as.vector(unclass(obj), mode = "logical"),
      integer = as.vector(unclass(obj), mode = "integer"),
      numeric = as.vector(unclass(obj), mode = "numeric"),
      double = as.vector(unclass(obj), mode = "double"),
      character = as.vector(unclass(obj), mode = "character"),
      complex = as.vector(unclass(obj), mode = "complex"),
      list = unname(lapply(unclass(obj), pack, ...)),
      pairlist = unname(lapply(as.vector(obj, mode = "list"), pack, ...)),
      closure = unname(lapply(obj, pack, ...)),
      builtin = as.scalar(base64_enc(serialize(unclass(obj), NULL))),
      special = as.scalar(base64_enc(serialize(unclass(obj), NULL))),
      language = deparse(unclass(obj)),
      name = deparse(unclass(obj)),
      symbol = deparse(unclass(obj)),
      expression = deparse(obj[[1]]),
      warning("No encoding has been defined for objects with storage mode ", encoding.mode, " and will be skipped.")
    )
  )
}
R/pack.R:3

load_s4_class untypeabletyped

unbound variable (line 140)
unbound: getClassDef — a name the prelude does not declare
error detail
name: getClassDef
gradual mode: typed
((name: any, package: any) -> null)<>
timing: 0.017 s
source
load_s4_class <- function(name, package) {
  cls <- tryCatch(
    {
      getClassDef(name, package = package)
    },
    error = function(e) {
      stop(sprintf("Failed to load S4 class definition '%s' from '%s' (%s)", name, package, e$message), call. = FALSE)
    }
  )
}
R/pack.R:137

unpack skipped

error detail
Failure("Unsupported positional argument after a named one.")
timing: 0.002 s
source
unpack <- function(obj) {
  encoding.mode <- obj$type

  # functions are special
  if (encoding.mode == "NULL") {
    return(NULL)
  }

  if (identical(encoding.mode, "S4")) {
    obj_class <- load_s4_class(obj$value$class, package = obj$value$package)
    obj_data <- lapply(obj$attributes, unpack)
    if (!length(obj_class)) obj_class <- obj$value$class
    return(do.call(new, c(Class = obj_class, obj_data)))
  }

  newdata <- c(
    list(
      .Data = switch(
        encoding.mode,
        environment = new.env(parent = emptyenv()),
        namespace = getNamespace(obj$value$name),
        externalptr = NULL,
        raw = base64_dec(obj$value),
        logical = as.logical(list_to_vec(obj$value)),
        integer = as.integer(list_to_vec(obj$value)),
        numeric = as.numeric(list_to_vec(obj$value)),
        double = as.double(list_to_vec(obj$value)),
        character = as.character(list_to_vec(obj$value)),
        complex = as.complex(list_to_vec(obj$value)),
        list = lapply(obj$value, unpack),
        pairlist = lapply(obj$value, unpack),
        symbol = makesymbol(x = unlist(obj$value)),
        name = makesymbol(x = unlist(obj$value)),
        expression = parse(text = obj$value),
        language = as.call(parse(text = unlist(obj$value)))[[1]],
        special = unserialize(base64_dec(obj$value)),
        builtin = unserialize(base64_dec(obj$value)),
        closure = lapply(obj$value, unpack),
        stop("Switch falling through for encode.mode: ", encoding.mode)
      )
    ),
    lapply(obj$attributes, unpack)
  )

  # this is for serializing functions arguments: as.list(lm)$data
  if (identical(newdata[[1]], substitute())) {
    return(substitute())
  }

  # build the output object
  output <- do.call("structure", newdata, quote = TRUE)

  # functions are special
  if (encoding.mode == "closure") {
    myfn <- as.function(output)
    environment(myfn) <- globalenv()
    return(myfn)
  }

  # functions are special
  if (encoding.mode == "pairlist") {
    return(as.pairlist(output))
  }

  # try to fix native symbols
  if (is(output, "NativeSymbolInfo")) {
    try(output <- fixNativeSymbol(output))
  }

  # return
  return(output)
}
R/pack.R:64
R/prettify.R

reformat untypeabletyped

unbound variable (line 30)
unbound: R_reformat — a native symbol tyr could not bind
error detail
name: R_reformat
gradual mode: typed
((x: any, pretty: any, indent_string: any?) -> any)<>
timing: 3.84 s
source
reformat <- function(x, pretty, indent_string = "") {
  out <- .Call(R_reformat, x, pretty, indent_string = indent_string)
  if (out[[1]] == 0) {
    return(out[[2]])
  } else {
    stop(out[[2]], call. = FALSE)
  }
}
R/prettify.R:29

prettify untypeabletyped

unbound variable (line 18)
unbound: ifelse — a name the prelude does not declare
error detail
name: ifelse
gradual mode: typed
((txt: any, indent: (DBL | INT)?) -> any)<>
timing: 0.115 s
source
prettify <- function(txt, indent = 4) {
  stopifnot(is.numeric(indent))
  txt <- paste(txt, collapse = "\n")
  indent_char <- ifelse(indent > 0, " ", "\t")
  indent_string <- paste(rep(indent_char, as.integer(abs(indent))), collapse = "")
  reformat(txt, TRUE, indent_string)
}
R/prettify.R:15

minify untypeabletyped

unbound variable (line 26)
unbound: reformat — one of the package’s own names, itself untyped
error detail
name: reformat
gradual mode: typed
((txt: any) -> any)<>
timing: 0.009 s
source
minify <- function(txt) {
  txt <- paste(txt, collapse = "\n")
  reformat(txt, FALSE)
}
R/prettify.R:24
R/print.R

print.json typed any: x fuzz ok

((x: any, ...: any) -> null)<>
timing: 0.011 s
fuzzing: 8 inside (6 ok, 2 error type) · 5 outside (5 rejected)

Other calls inside the domain

callverdicterror
print.json("x" = list(new.env(), local({ p <- unserialize(serialize(new("externalptr"), NULL)); attributes(p) <- NULL; p })), "fuzz_dot1" = NULL)error_typebase::cat: argument 1 (type 'list') cannot be handled by 'cat'
print.json("x" = function(...) list(function(...) function(...) function(...) 0L), "fuzz_dot1" = quote(f(x)), "fuzz_dot2" = quote(f(x)))error_typebase::cat: argument 1 (type 'closure') cannot be handled by 'cat'
source
print.json <- function(x, ...) {
  cat(x, "\n")
}
R/print.R:3

print.scalar untypeabletyped

unbound variable (line 12)
unbound: is.data.frame — a name the prelude does not declare
error detail
name: is.data.frame
gradual mode: typed
∀'a. ((x: 'a & <...>, ...: any) -> 'a)<>
timing: 0.051 s
source
print.scalar <- function(x, ...) {
  original <- x
  class(x) <- class(x)[-1]
  if (is.data.frame(x)) {
    row.names(x) <- "[x]"
    print(x)
  } else {
    cat("[x] ", asJSON(x, collapse = FALSE), "\n", sep = "")
  }
  invisible(original)
}
R/print.R:9
R/raw_to_json.R

raw_to_json untypeabletyped

unbound variable (line 5)
unbound: rawToChar — a name the prelude does not declare
error detail
name: rawToChar
gradual mode: typed
((x: any) -> any)<>
timing: 0.047 s
source
raw_to_json <- function(x) {
  txt <- rawToChar(x)
  Encoding(txt) <- "UTF-8"
  isvalid <- validate(txt)
  if (!isvalid && grepl("invalid bytes in UTF8", attr(isvalid, "err"), fixed = TRUE, useBytes = TRUE)) {
    warning("The json string is not valid UTF-8. Assuming native encoding.", call. = FALSE)
    Encoding(txt) <- ""
  }
  return(txt)
}
R/raw_to_json.R:4
R/rbind_pages.R

rbind_pages untypeabletyped

unbound variable (line 38)
unbound: loadpkg — one of the package’s own names, itself untyped
error detail
name: loadpkg
gradual mode: typed
((pages: any) -> any)<>
timing: 0.010 s
source
rbind_pages <- function(pages) {
  loadpkg("vctrs")

  #validate input
  stopifnot(is.list(pages))

  # All elements must be data frames or NULL.
  pages <- Filter(
    function(x) {
      !is.null(x)
    },
    pages
  )
  stopifnot(all(vapply(pages, is.data.frame, logical(1))))

  do.call(vctrs::vec_rbind, pages)
}
R/rbind_pages.R:37
R/read_json.R

parse_json untypeabletyped

unbound variable (line 28)
unbound: parse_and_simplify — one of the package’s own names, itself untyped
error detail
name: parse_and_simplify
gradual mode: typed
((json: <connection, ...>, simplifyVector: any?, ...: (absent, any)) -> any)<>
timing: 0.008 s
source
parse_json <- function(json, simplifyVector = FALSE, ...) {
  parse_and_simplify(json, simplifyVector = simplifyVector, ...)
}
R/read_json.R:27

read_json untypeabletyped

unbound variable (line 21)
unbound: file — a name the prelude does not declare
error detail
name: file
gradual mode: typed
((path: any, simplifyVector: any?, ...: any) -> any)<>
timing: 0.007 s
source
read_json <- function(path, simplifyVector = FALSE, ...) {
  parse_json(file(path), simplifyVector = simplifyVector, ...)
}
R/read_json.R:20

write_json untypeabletyped

unbound variable (line 36)
unbound: jsonlite::toJSON — a name the prelude does not declare
error detail
name: jsonlite::toJSON
gradual mode: typed
((x: any, path: any, ...: any) -> any)<>
timing: 0.006 s
source
write_json <- function(x, path, ...) {
  json <- jsonlite::toJSON(x, ...)
  writeLines(json, path, useBytes = TRUE)
}
R/read_json.R:35
R/serializeJSON.R

serializeJSON untypeable

unbound variable (line 37)
unbound: is — a name the prelude does not declare
error detail
name: is
timing: 0.014 s
source
serializeJSON <- function(x, digits = 8, pretty = FALSE) {
  # just to verify that obj exists
  is(x)

  # we pass arguments both to asJSON as well as packaging object.
  indent <- indent_init(pretty)
  ans <- asJSON(pack(x), digits = digits, indent = indent)
  class(ans) <- "json"
  return(ans)
}
R/serializeJSON.R:35

unserializeJSON untypeabletyped

unbound variable (line 49)
unbound: parseJSON — one of the package’s own names, itself untyped
error detail
name: parseJSON
gradual mode: typed
((txt: <connection, ...>) -> any)<>
timing: 0.002 s
source
unserializeJSON <- function(txt) {
  unpack(parseJSON(txt))
}
R/serializeJSON.R:48
R/stream.R

post_process untypeabletyped

unbound variable (line 179)
unbound: simplify — one of the package’s own names, itself untyped
error detail
name: simplify
gradual mode: typed
((x: any, simplifyVector: any?, simplifyDataFrame: any?, simplifyMatrix: any?, flatten: any?) -> any)<>
timing: 0.047 s
source
post_process <- function(x, simplifyVector = TRUE, simplifyDataFrame = simplifyVector, simplifyMatrix = simplifyVector, flatten = FALSE) {
  out <- simplify(x, simplifyVector = simplifyVector, simplifyDataFrame = simplifyDataFrame, simplifyMatrix = simplifyMatrix, flatten = flatten)

  # We assume ndjson with objects
  if (isTRUE(simplifyDataFrame)) {
    return(as.data.frame(out))
  } else {
    out
  }
}
R/stream.R:178

stream_in skipped

error detail
Failure("Invalid left value.")
timing: 0.000 s
source
stream_in <- function(con, handler = NULL, pagesize = 500, verbose = TRUE, ...) {
  # Maybe also handle URLs here in future.
  if (!is(con, "connection")) {
    stop("Argument 'con' must be a connection.")
  }

  # Same as mongolite
  count <- 0
  cb <- if (is.null(handler)) {
    out <- new.env()
    function(x) {
      if (length(x)) {
        count <<- count + length(x)
        out[[as.character(count)]] <<- x
      }
    }
  } else {
    if (verbose) message("using a custom handler function.")
    function(x) {
      handler(post_process(x, ...))
      count <<- count + length(x)
    }
  }

  if (!isOpen(con, "r")) {
    if (verbose) message("opening ", is(con), " input connection.")

    # binary connection prevents recoding of utf8 to latin1 on windows
    open(con, "rb")
    on.exit({
      if (verbose) message("closing ", is(con), " input connection.")
      close(con)
    })
  }

  # Read data page by page
  repeat {
    page <- readLines(con, n = pagesize, encoding = "UTF-8")
    if (length(page)) {
      cleanpage <- Filter(nchar, page)
      cb(lapply(cleanpage, parseJSON))
      if (verbose) cat("\r Found", count, "records...")
    }
    if (length(page) < pagesize) break
  }

  # Either return a big data frame, or nothing.
  if (is.null(handler)) {
    if (verbose) cat("\r Imported", count, "records. Simplifying...\n")
    out <- as.list(out, sorted = FALSE)
    post_process(unlist(out[order(as.numeric(names(out)))], FALSE, FALSE), ...)
  } else {
    invisible()
  }
}
R/stream.R:122

stream_out_page untypeabletyped

unbound variable (line 212)
unbound: asJSON — a name the prelude does not declare
error detail
name: asJSON
gradual mode: typed
((page: any, con: any, prefix: CHR<@"[", ...>, ...: any) | (page: any, con: any, prefix: CHR<~@"[", ...>, ...: any) | (page: any, con: any, prefix: ~CHR, ...: any) -> any)<>
timing: 0.065 s
source
stream_out_page <- function(page, con, prefix, ...) {
  # useBytes can sometimes prevent recoding of utf8 to latin1 on windows.
  # on windows there is a bug when useBytes is used with a (non binary) text connection.
  str <- enc2utf8(asJSON(page, collapse = FALSE, ...))
  if (is.character(prefix) && length(prefix) && nchar(prefix)) str <- paste0(prefix[1], str)
  writeLines(str, con = con, useBytes = TRUE)
}
R/stream.R:209

stream_out untypeabletyped

unbound variable (line 192)
unbound: is — a name the prelude does not declare
error detail
name: is
gradual mode: typed
((x: any, con: <connection, ...>?, pagesize: any?, verbose: any?, prefix: any?, ...: any) -> any)<>
timing: 0.062 s
source
stream_out <- function(x, con = stdout(), pagesize = 500, verbose = TRUE, prefix = "", ...) {
  if (!is(con, "connection")) {
    # Maybe handle URLs here in future.
    stop("Argument 'con' must be a connection.")
  }

  if (!isOpen(con, "w")) {
    if (verbose) message("opening ", is(con), " output connection.")
    open(con, "wb")
    on.exit({
      if (verbose) message("closing ", is(con), " output connection.")
      close(con)
    })
  }

  invisible(apply_by_pages(x, stream_out_page, pagesize = pagesize, con = con, verbose = verbose, prefix = prefix, ...))
}
R/stream.R:191
R/unescape_unicode.R

unescape_unicode untypeable

unbound variable (line 6)
unbound: gregexpr — a name the prelude does not declare
error detail
name: gregexpr
timing: 0.057 s
source
unescape_unicode <- function(x) {
  #single string only
  stopifnot(is.character(x) && length(x) == 1)

  #find matches
  m <- gregexpr("(\\\\)+u[0-9a-z]{4}", x, ignore.case = TRUE)

  if (m[[1]][1] > -1) {
    #parse matches
    p <- vapply(
      regmatches(x, m)[[1]],
      function(txt) {
        gsub("\\", "\\\\", parse(text = paste0('"', txt, '"'))[[1]], fixed = TRUE, useBytes = TRUE)
      },
      character(1),
      USE.NAMES = FALSE
    )

    #substitute parsed into original
    regmatches(x, m) <- list(p)
  }

  x
}
R/unescape_unicode.R:1
R/utf8conv.R

utf8conv typed accepts outside

(((x: vec) -> CHR<>)&((x: vec1) -> CHR1<>))<>
timing: 0.053 s
fuzzing: 7 inside (7 ok) · 8 outside (5 rejected, 3 accepted)

Accepted outside the domain x: 3

parameterchangecallreturned
xkind:langutf8conv("x" = quote(f(x)))(CHR & ~vec1)<> with { }
xkind:langutf8conv(quote(f(x)))(CHR & ~vec1)<> with { }
xwraputf8conv("x" = list(NA_character_))na_string<> with { }
source
utf8conv <- function(x) {
  gsub("<U\\+([0-9A-F]{4})>", "\\\\u\\1", x)
}
R/utf8conv.R:1