Beispiel #1
0
void parameter_print_on(value_t self, print_on_context_t *context) {
  CHECK_FAMILY(ofParameter, self);
  string_buffer_printf(context->buf, "#<parameter: gd@");
  // We know the guard is a guard, not a parameter, so this can't cause a cycle.
  value_print_inner_on(get_parameter_guard(self), context, -1);
  string_buffer_printf(context->buf, ", op@%i, ix@%i>",
      get_parameter_is_optional(self), get_parameter_index(self));
}
Beispiel #2
0
void method_print_on(value_t self, print_on_context_t *context) {
  string_buffer_printf(context->buf, "#<method ");
  value_t signature = get_method_signature(self);
  value_print_inner_on(signature, context, -1);
  string_buffer_printf(context->buf, " ");
  value_t syntax = get_method_syntax(self);
  value_print_inner_on(syntax, context, -1);
  string_buffer_printf(context->buf, ">");
}
Beispiel #3
0
void unbound_module_print_on(value_t value, print_on_context_t *context) {
  string_buffer_printf(context->buf, "#<unbound_module(");
  value_t path = get_unbound_module_path(value);
  value_print_inner_on(path, context, -1);
  string_buffer_printf(context->buf, ") ");
  value_t fragments = get_unbound_module_fragments(value);
  value_print_inner_on(fragments, context, -1);
  string_buffer_printf(context->buf, ">");
}
Beispiel #4
0
void library_print_on(value_t value, print_on_context_t *context) {
  string_buffer_printf(context->buf, "#<library(");
  value_t display_name = get_library_display_name(value);
  value_print_inner_on(display_name, context, -1);
  string_buffer_printf(context->buf, ") ");
  value_t modules = get_library_modules(value);
  value_print_inner_on(modules, context, -1);
  string_buffer_printf(context->buf, ">");
}
Beispiel #5
0
void signature_print_on(value_t self, print_on_context_t *context) {
  string_buffer_printf(context->buf, "#<signature: ");
  for (int64_t i = 0; i < get_signature_parameter_count(self); i++) {
    if (i > 0)
      string_buffer_printf(context->buf, ", ");
    value_print_inner_on(get_signature_tag_at(self, i), context, -1);
    string_buffer_printf(context->buf, ":");
    value_t param = get_signature_parameter_at(self, i);
    value_print_inner_on(get_parameter_guard(param), context, -1);
  }
  string_buffer_printf(context->buf, ">");
}
Beispiel #6
0
void unbound_module_fragment_print_on(value_t value, print_on_context_t *context) {
  string_buffer_printf(context->buf, "#<unbound_module_fragment(");
  value_t stage = get_unbound_module_fragment_stage(value);
  value_print_inner_on(stage, context, -1);
  string_buffer_printf(context->buf, ") imports: ");
  value_t imports = get_unbound_module_fragment_imports(value);
  value_print_inner_on(imports, context, -1);
  string_buffer_printf(context->buf, ") elements: ");
  value_t elements = get_unbound_module_fragment_elements(value);
  value_print_inner_on(elements, context, -1);
  string_buffer_printf(context->buf, ">");
}
Beispiel #7
0
void print_invocation_on(value_t tags, frame_t *frame, string_buffer_t *buf) {
  int64_t arg_count = get_call_tags_entry_count(tags);
  string_buffer_printf(buf, "{");
  for (int64_t i = 0;  i < arg_count; i++) {
    value_t tag = get_call_tags_tag_at(tags, i);
    value_t arg = frame_get_pending_argument_at(frame, tags, i);
    if (i > 0)
      string_buffer_printf(buf, ", ");
    string_buffer_printf(buf, "%v: %v", tag, arg);
  }
  string_buffer_printf(buf, "}");
}
Beispiel #8
0
void call_tags_print_on(value_t self, print_on_context_t *context) {
  string_buffer_printf(context->buf, "{");
  int64_t arg_count = get_call_tags_entry_count(self);
  for (int64_t i = 0; i < arg_count; i++) {
    if (i > 0)
      string_buffer_printf(context->buf, ", ");
    value_t tag = get_call_tags_tag_at(self, i);
    size_t offset = (size_t) get_call_tags_offset_at(self, i);
    value_print_inner_on(tag, context, -1);
    string_buffer_printf(context->buf, "@%i", offset);
  }
  string_buffer_printf(context->buf, "}");
}
Beispiel #9
0
void guard_print_on(value_t self, print_on_context_t *context) {
  CHECK_FAMILY(ofGuard, self);
  switch (get_guard_type(self)) {
    case gtEq:
      string_buffer_printf(context->buf, "eq(");
      value_print_inner_on(get_guard_value(self), context, -1);
      string_buffer_printf(context->buf, ")");
      break;
    case gtIs:
      string_buffer_printf(context->buf, "is(");
      value_print_inner_on(get_guard_value(self), context, -1);
      string_buffer_printf(context->buf, ")");
      break;
    case gtAny:
      string_buffer_printf(context->buf, "any()");
      break;
  }
}
Beispiel #10
0
static void log_lookup_error(value_t condition, value_t tags, frame_t *frame) {
    size_t arg_count = get_call_tags_entry_count(tags);
    string_buffer_t buf;
    string_buffer_init(&buf);
    string_buffer_printf(&buf, "%v: {", condition);
    for (size_t i = 0; i < arg_count; i++) {
        if (i > 0)
            string_buffer_printf(&buf, ", ");
        value_t tag = get_call_tags_tag_at(tags, i);
        value_t value = frame_get_pending_argument_at(frame, tags, i);
        string_buffer_printf(&buf, "%v: %v", tag, value);
    }
    string_buffer_printf(&buf, "}");
    string_t str;
    string_buffer_flush(&buf, &str);
    ERROR("%s", str.chars);
    string_buffer_dispose(&buf);
}
Beispiel #11
0
void value_print_inner_on(value_t value, print_on_context_t *context,
    int32_t delta_depth) {
  size_t new_depth = context->depth + delta_depth;
  if (new_depth == 0) {
    string_buffer_printf(context->buf, kBottomValuePlaceholder);
  } else {
    print_on_context_t new_context = *context;
    new_context.depth = new_depth;
    value_print_on_cycle_detect(value, &new_context);
  }
}
Beispiel #12
0
void operation_print_close_on(value_t self, print_on_context_t *context) {
  value_t value = get_operation_value(self);
  print_on_context_t unquote_context = *context;
  unquote_context.flags |= pfUnquote;
  switch (get_operation_type(self)) {
  case otAssign:
  case otCall:
  case otInfix:
  case otPrefix:
    string_buffer_printf(context->buf, ")");
    break;
  case otIndex:
    string_buffer_printf(context->buf, "]");
    break;
  case otSuffix:
    string_buffer_printf(context->buf, ")");
    value_print_inner_on(value, &unquote_context, -1);
    break;
  default:
    UNREACHABLE("unexpected operation type");
    break;
  }
}
Beispiel #13
0
void operation_print_open_on(value_t self, value_t transport,
    print_on_context_t *context) {
  value_t value = get_operation_value(self);
  print_on_context_t unquote_context = *context;
  unquote_context.flags |= pfUnquote;
  bool is_async = is_same_value(transport, transport_async());
  switch (get_operation_type(self)) {
  case otAssign:
    // Since the operator for the assignment is kind of sort of part of the
    // operator let's not decrease depth. If you make an assignment whose
    // operator is the assignment itself then 1) this will fail and 2) I hate
    // you.
    value_print_inner_on(value, &unquote_context, 0);
    string_buffer_printf(context->buf, ":=(");
    break;
  case otCall:
    string_buffer_printf(context->buf, "(");
    break;
  case otIndex:
    string_buffer_printf(context->buf, "[");
    break;
  case otInfix:
    string_buffer_printf(context->buf, is_async ? "->" : ".");
    value_print_inner_on(value, &unquote_context, -1);
    string_buffer_printf(context->buf, "(");
    break;
  case otPrefix:
    value_print_inner_on(value, &unquote_context, -1);
    string_buffer_printf(context->buf, "(");
    break;
  case otSuffix:
    string_buffer_printf(context->buf, "(");
    break;
  default:
    UNREACHABLE("unexpected operation type");
    break;
  }
}
Beispiel #14
0
void module_loader_print_on(value_t value, print_on_context_t *context) {
  string_buffer_printf(context->buf, "#<module loader ");
  value_t modules = get_module_loader_modules(value);
  value_print_inner_on(modules, context, -1);
  string_buffer_printf(context->buf, ">");
}
Beispiel #15
0
static void condition_print_on(value_t value, string_buffer_t *buf) {
  CHECK_DOMAIN(vdCondition, value);
  condition_cause_t cause = get_condition_cause(value);
  const char *cause_name = get_condition_cause_name(cause);
  string_buffer_printf(buf, "%%<condition: %s(", cause_name);
  uint32_t details = get_condition_details(value);
  switch (cause) {
    case ccInvalidSyntax: {
      invalid_syntax_cause_t cause = (invalid_syntax_cause_t) details;
      string_buffer_printf(buf, "%s", get_invalid_syntax_cause_name(cause));
      break;
    }
    case ccUnsupportedBehavior: {
      unsupported_behavior_details_codec_t codec;
      codec.encoded = details;
      unsupported_behavior_cause_t cause = (unsupported_behavior_cause_t) codec.decoded.cause;
      string_buffer_printf(buf, "%s", get_unsupported_behavior_cause_name(cause));
      value_type_info_t type = value_type_info_decode(codec.decoded.type_info);
      string_buffer_printf(buf, " of %s", value_type_info_name(type));
      break;
    }
    case ccLookupError: {
      lookup_error_cause_t cause = (lookup_error_cause_t) details;
      string_buffer_printf(buf, "%s", get_lookup_error_cause_name(cause));
      break;
    }
    case ccSystemError: {
      system_error_cause_t cause = (system_error_cause_t) details;
      string_buffer_printf(buf, "%s", get_system_error_cause_name(cause));
      break;
    }
    case ccInvalidInput: {
      if (details != 0) {
        // If no hint is given (or the hint it the empty string) the details
        // field will be 0.
        invalid_input_details_codec_t codec;
        codec.encoded = details;
        char hint[7];
        string_hint_to_c_str(codec.decoded, hint);
        string_buffer_printf(buf, "%s", hint);
      }
      break;
    }
    case ccNotSerializable: {
      value_type_info_t type = value_type_info_decode((uint16_t) details);
      string_buffer_printf(buf, "%s", value_type_info_name(type));
      break;
    }
    case ccUnexpectedType: {
      unexpected_type_info_codec_t codec;
      codec.encoded = details;
      value_type_info_t expected = value_type_info_decode(codec.decoded.expected);
      if (!value_type_info_is_empty(expected))
        // It's okay to leave out the expected type, we skip printing it if it's
        // not there.
        string_buffer_printf(buf, "expected: %s, ", value_type_info_name(expected));
      value_type_info_t found = value_type_info_decode(codec.decoded.found);
      string_buffer_printf(buf, "found: %s", value_type_info_name(found));
      break;
    }
    case ccUncaughtSignal: {
      string_buffer_printf(buf, is_uncaught_signal_escape(value) ? "escape" : "non-escape");
      break;
    }
    default: {
      string_buffer_printf(buf, "dt@%i", details);
      break;
    }
  }
  string_buffer_printf(buf, ")>");
}
Beispiel #16
0
static void integer_print_on(value_t value, print_on_context_t *context) {
  CHECK_DOMAIN(vdInteger, value);
  const char *fmt = (context->flags & pfHex) ? "%llx" : "%lli";
  string_buffer_printf(context->buf, fmt, get_integer_value(value));
}
Beispiel #17
0
void builtin_implementation_print_on(value_t self, print_on_context_t *context) {
  CHECK_FAMILY(ofBuiltinImplementation, self);
  string_buffer_printf(context->buf, "#<builtin_implementation ");
  value_print_inner_on(get_builtin_implementation_name(self), context, -1);
  string_buffer_printf(context->buf, ">");
}
Beispiel #18
0
void builtin_marker_print_on(value_t self, print_on_context_t *context) {
  CHECK_FAMILY(ofBuiltinMarker, self);
  string_buffer_printf(context->buf, "#<builtin_marker ");
  value_print_inner_on(get_builtin_marker_name(self), context, -1);
  string_buffer_printf(context->buf, ">");
}
Beispiel #19
0
void stack_piece_print_on(value_t value, print_on_context_t *context) {
  CHECK_FAMILY(ofStackPiece, value);
  string_buffer_printf(context->buf, "#<stack piece ~%w: st@%i>", value,
      get_stack_piece_capacity(value));
}
Beispiel #20
0
void methodspace_print_on(value_t self, print_on_context_t *context) {
  string_buffer_printf(context->buf, "#<methodspace ");
  value_t methods = get_methodspace_methods(self);
  value_print_inner_on(methods, context, -1);
  string_buffer_printf(context->buf, ">");
}