<commit_before>/*
 * Copyright (C) 2002-2010, Parrot Foundation.
 */

/*

=head1 NAME

compilers/imcc/debug.c

=head1 DESCRIPTION

print debug info of various structures

handle info/error/warning messages from imcc

=head2 Functions

=over 4

=cut

*/

#include "imc.h"
#include "parrot/io.h"

/* HEADERIZER HFILE: compilers/imcc/debug.h */
/* HEADERIZER BEGIN: static */
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */

PARROT_CANNOT_RETURN_NULL
static STRING * IMCC_get_err_location(ARGMOD(imc_info_t *imcc))
        __attribute__nonnull__(1)
        FUNC_MODIFIES(*imcc);

#define ASSERT_ARGS_IMCC_get_err_location __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
       PARROT_ASSERT_ARG(imcc))
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
/* HEADERIZER END: static */

/*

=item C<void IMCC_fatal(imc_info_t * imcc, int code, const char *fmt, ...)>

Prints out a fatal error message from IMCC and throws an
IMCC_FATAL_EXCEPTION.

=cut

*/

PARROT_DOES_NOT_RETURN
void
IMCC_fatal(ARGMOD(imc_info_t * imcc), SHIM(int code), ARGIN(const char *fmt), ...)
{
    ASSERT_ARGS(IMCC_fatal)
    STRING * location = STRINGNULL;
    va_list ap;

    va_start(ap, fmt);
    imcc->error_message = Parrot_vsprintf_c(imcc->interp, fmt, ap);
    va_end(ap);
    location = IMCC_get_err_location(imcc);
    Parrot_ex_throw_from_c_args(imcc->interp, NULL, IMCC_FATAL_EXCEPTION,
        "error:imcc:%Ss\n\t%Ss", imcc->error_message, location);
}

/*

=item C<void IMCC_fataly(imc_info_t * imcc, int code, const char *fmt, ...)>

Throws an IMCC_FATALY_EXCEPTION.

=cut

*/

PARROT_DOES_NOT_RETURN
void
IMCC_fataly(ARGMOD(imc_info_t * imcc), SHIM(int code), ARGIN(const char *fmt), ...)
{
    ASSERT_ARGS(IMCC_fataly)
    STRING * location;
    va_list ap;

    va_start(ap, fmt);
    imcc->error_message = Parrot_vsprintf_c(imcc->interp, fmt, ap);
    va_end(ap);
    location = IMCC_get_err_location(imcc);
    Parrot_ex_throw_from_c_args(imcc->interp, NULL, IMCC_FATALY_EXCEPTION,
        "error:imcc:%Ss\n\t%Ss", imcc->error_message, location);
}

/*
<commit_msg>- Fix IMCC_fataly<commit_after>/*
 * Copyright (C) 2002-2010, Parrot Foundation.
 */

/*

=head1 NAME

compilers/imcc/debug.c

=head1 DESCRIPTION

print debug info of various structures

handle info/error/warning messages from imcc

=head2 Functions

=over 4

=cut

*/

#include "imc.h"
#include "parrot/io.h"

/* HEADERIZER HFILE: compilers/imcc/debug.h */
/* HEADERIZER BEGIN: static */
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */

PARROT_CANNOT_RETURN_NULL
static STRING * IMCC_get_err_location(ARGMOD(imc_info_t *imcc))
        __attribute__nonnull__(1)
        FUNC_MODIFIES(*imcc);

#define ASSERT_ARGS_IMCC_get_err_location __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
       PARROT_ASSERT_ARG(imcc))
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
/* HEADERIZER END: static */

/*

=item C<void IMCC_fatal(imc_info_t * imcc, int code, const char *fmt, ...)>

Prints out a fatal error message from IMCC and throws an
IMCC_FATAL_EXCEPTION.

=cut

*/

PARROT_DOES_NOT_RETURN
void
IMCC_fatal(ARGMOD(imc_info_t * imcc), SHIM(int code), ARGIN(const char *fmt), ...)
{
    ASSERT_ARGS(IMCC_fatal)
    STRING * location = STRINGNULL;
    va_list ap;

    va_start(ap, fmt);
    imcc->error_message = Parrot_vsprintf_c(imcc->interp, fmt, ap);
    va_end(ap);
    location = IMCC_get_err_location(imcc);
    Parrot_ex_throw_from_c_args(imcc->interp, NULL, IMCC_FATAL_EXCEPTION,
        "error:imcc:%Ss\n\t%Ss", imcc->error_message, location);
}

/*

=item C<void IMCC_fataly(imc_info_t * imcc, int code, const char *fmt, ...)>

Throws an IMCC_FATALY_EXCEPTION.

=cut

*/

PARROT_DOES_NOT_RETURN
void
IMCC_fataly(ARGMOD(imc_info_t * imcc), SHIM(int code), ARGIN(const char *fmt), ...)
{
    ASSERT_ARGS(IMCC_fataly)
    STRING * location;
    va_list ap;

    va_start(ap, fmt);
    location = IMCC_get_err_location(imcc);
    imcc->error_message = Parrot_str_concat(imcc->interp,
        imcc->error_message,
        Parrot_sprintf_c(imcc->interp, "error:imcc:%Ss\n\t%Ss",
        Parrot_vsprintf_c(imcc->interp, fmt, ap),
        location));
    va_end(ap);
    Parrot_ex_throw_from_c_args(imcc->interp, NULL, IMCC_FATALY_EXCEPTION,
        "%Ss", imcc->error_message);
}

/*

{'fraction_non_alphanumeric': 0.1211708645336964, 'fraction_numerical': 0.0058997050147492625, 'mean_word_length': 4.049255441008018, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3476700', 'n_tokens_mistral': 1797, 'n_tokens_neox': 1746, 'n_words': 348}