<commit_before>/* subroutine.h
 *  Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
 *  CVS Info
 *     $Id$
 *  Overview:
 *  Data Structure and Algorithms:
 *     Subroutine, coroutine, closure and continuation structures
 *     and related routines.
 *  History:
 *     Initial version by Melvin on on 2002/06/6
 *  Notes:
 *  References:
 */

#if !defined(PARROT_SUB_H_GUARD)
#define PARROT_SUB_GUARD

#include "parrot/parrot.h"

/* Used by Scratchpad PMC */
typedef struct Parrot_Lexicals {
    List * values;    /* lexicals go here */
    List * names;     /* names of lexicals go here */
} * parrot_lexicals_t;

/*
 * Sub, Closure, COntinuation have the same structure
 */
typedef struct Parrot_Sub {
    struct Parrot_Context ctx;
    struct PackFile_ByteCode *seg;
    opcode_t *end;      /* end of bytecode in normal (bounds_check run loop */
    char *packed;       /* to simplify packing Constant Subs */
} * parrot_sub_t;

#define PMC_sub(pmc) ((parrot_sub_t)((pmc)->cache.pmc_val))

/* the first entries must match Parrot_Sub, so we can cast
 * these two to the other type
 */
typedef struct Parrot_Coroutine {
    struct Parrot_Context ctx;
    struct PackFile_ByteCode *seg;
    opcode_t *end;      /* end of bytecode in normal (bounds_check run loop */
    char *packed;       /* to simplify packing Constant Subs */
    struct Stack_Chunk *co_pad_stack;      /* pad stack state of the cor. */
    struct Stack_Chunk *co_control_stack;  /* control stack state of the cor.*/
} * parrot_coroutine_t;

struct Parrot_Sub * new_sub(struct Parrot_Interp * interp, size_t);
struct Parrot_Sub * new_closure(struct Parrot_Interp * interp);
struct Parrot_Sub * new_coroutine(struct Parrot_Interp * interp);
struct Parrot_Sub * new_continuation(struct Parrot_Interp * interp);
struct Parrot_Sub * new_ret_continuation(struct Parrot_Interp * interp);

PMC * new_ret_continuation_pmc(struct Parrot_Interp *, opcode_t * address);

void save_context(struct Parrot_Interp *, struct Parrot_Context *);
void cow_copy_context(struct Parrot_Interp* , struct Parrot_Context *);
void swap_context(struct Parrot_Interp *, PMC *);
void restore_context(struct Parrot_Interp *, struct Parrot_Context *);

PMC * scratchpad_new(struct Parrot_Interp * interp, PMC * base, INTVAL depth);

PMC * scratchpad_get_current(struct Parrot_Interp * interp);
<commit_msg>lvalue cast warnings by <NAME><commit_after>/* subroutine.h
 *  Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
 *  CVS Info
 *     $Id$
 *  Overview:
 *  Data Structure and Algorithms:
 *     Subroutine, coroutine, closure and continuation structures
 *     and related routines.
 *  History:
 *     Initial version by Melvin on on 2002/06/6
 *  Notes:
 *  References:
 */

#if !defined(PARROT_SUB_H_GUARD)
#define PARROT_SUB_GUARD

#include "parrot/parrot.h"

/* Used by Scratchpad PMC */
typedef struct Parrot_Lexicals {
    List * values;    /* lexicals go here */
    List * names;     /* names of lexicals go here */
} * parrot_lexicals_t;

/*
 * Sub, Closure, COntinuation have the same structure
 */
typedef struct Parrot_Sub {
    struct Parrot_Context ctx;
    struct PackFile_ByteCode *seg;
    opcode_t *end;      /* end of bytecode in normal (bounds_check run loop */
    char *packed;       /* to simplify packing Constant Subs */
} * parrot_sub_t;

#define PMC_sub(pmc) (*((parrot_sub_t *)&((pmc)->cache.pmc_val)))

/* the first entries must match Parrot_Sub, so we can cast
 * these two to the other type
 */
typedef struct Parrot_Coroutine {
    struct Parrot_Context ctx;
    struct PackFile_ByteCode *seg;
    opcode_t *end;      /* end of bytecode in normal (bounds_check run loop */
    char *packed;       /* to simplify packing Constant Subs */
    struct Stack_Chunk *co_pad_stack;      /* pad stack state of the cor. */
    struct Stack_Chunk *co_control_stack;  /* control stack state of the cor.*/
} * parrot_coroutine_t;

struct Parrot_Sub * new_sub(struct Parrot_Interp * interp, size_t);
struct Parrot_Sub * new_closure(struct Parrot_Interp * interp);
struct Parrot_Sub * new_coroutine(struct Parrot_Interp * interp);
struct Parrot_Sub * new_continuation(struct Parrot_Interp * interp);
struct Parrot_Sub * new_ret_continuation(struct Parrot_Interp * interp);

PMC * new_ret_continuation_pmc(struct Parrot_Interp *, opcode_t * address);

void save_context(struct Parrot_Interp *, struct Parrot_Context *);
void cow_copy_context(struct Parrot_Interp* , struct Parrot_Context *);
void swap_context(struct Parrot_Interp *, PMC *);
void restore_context(struct Parrot_Interp *, struct Parrot_Context *);

PMC * scratchpad_new(struct Parrot_Interp * interp, PMC * base, INTVAL depth);

PMC * scratchpad_get_current(struct Parrot_Interp * interp);

{'fraction_non_alphanumeric': 0.09240159966322879, 'fraction_numerical': 0.006314460113660282, 'mean_word_length': 4.066098081023454, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 6, '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': '7350459', 'n_tokens_mistral': 1605, 'n_tokens_neox': 1546, 'n_words': 451}