|
|
|
|
|
static unsigned int frame_size; |
|
|
|
|
|
static char * p4_mstring_comma (const char *addr, size_t len) { char *p = (char *) DP; char *limit; if (len >= MAX_DATA_STR) p4_throw (P4_ON_SCOUNT_OVERFLOW); *P4_VAR(MCount*,DP)++ = (MCount) len; |
static char * p4_parse_mstring_comma (char del) { |
|
void
p4_clear_str_space (StrSpace *space)
{
size_t fstack_offset = ALIGNTO_CELL (sizeof (*space));
size_t fstack_size = space->numframes * sizeof (StrFrame);
space->fbreak = (void *) space + fstack_offset;
space->fp0 = space->fp = (void *) space->fbreak + fstack_size;
space->buf = space->sbreak = (void *)space->fp0;
space->sp0 = space->sp = (void *) space->buf + space->size;
space->cat_str = NULL;
space->garbage_flag = space->garbage_lock = 0;
*space->sp0 = NULL; |
|
StrSpace * p4_make_str_space (size_t size, size_t frames) { StrSpace *space; size_t fstack_offset = ALIGNTO_CELL (sizeof (*space)); size_t fstack_size = frames * sizeof (StrFrame); size = ALIGNTO_CELL (size); space = (StrSpace *) p4_xalloc (size + PFE_SIZEOF_CELL + fstack_offset + fstack_size); if (space == NULL) p4_throw (P4_ON_OUT_OF_MEMORY); space->size = size; space->numframes = frames; p4_clear_str_space ( space ); return space; } |
|
int p4_collect_garbage (void) { DStr *next, *target; MStr **sstack; char *p, *q, *limit; if ( !GARBAGE_FLAG ) return 0; |
|
MStr * p4_pop_str (void) { MStr **strsp = SSP; if (strsp == SSP0) p4_throw (P4_ON_SSTACK_UNDERFLOW); SSP += 1; if ( *strsp >= (MStr *) SBUFFER && *strsp < (MStr *) SBREAK && *((p4cell **) (*strsp)-1) == (p4cell *) strsp ) { *((p4cell **) (*strsp)-1) = NULL; GARBAGE_FLAG = ~0; }; return *strsp; } |
|
void
p4_drop_all_strings (StrSpace *space)
{
int depth = space->sp0 - space->sp;
int i;
space->fp = space->fp0; |
|
void p4_push_str_copy (char *addr, size_t len) { char *buf; Q_CAT; |
|
int p4_find_arg (char *nm, int l) { MStr **ssp = SFSP->top; MStr *p; int i; for (i = 0; i < SFSP->num; i++) { p = *(ssp++); if (l == MLEN (p) && memcmp (nm, MADDR (p), l) == 0) return i; } return -1; } |
|
void p4_make_str_frame (p4ucell n) { if (SFSP == SFBREAK) p4_throw (P4_ON_SFRAME_OVERFLOW); if (n > (SFSP - (StrFrame *) SSP)) p4_throw (P4_ON_SFRAME_ITEMS); SFSP -= 1 ; SFSP->top = SSP; SFSP->num = n; } |
|
FCode_XE (p4_marg_execution) { FX_USE_CODE_ADDR PUSH_STR ((MStr *) (SFSP->top)[(p4cell) *IP++]); FX (p4_cat); } |
|
static p4xt* p4_marg_SEE (p4xt* ip, char* p, p4_Semant* s) { sprintf (p, |
P4COMPILES (p4_marg_execution, p4_marg_execution, p4_marg_SEE, P4_DEFAULT_STYLE); |
|
struct p4_MStr p4_empty_str = { 0, |
struct p4_MStr p4_newline_str = { 1, |
/** EMPTY$ |
|
|
|
|
|
FCode (p4_str_gc_off) { GARBAGE_LOCK = ~0; } |
|
FCode (p4_str_gc_on) { GARBAGE_LOCK = 0; } |
|
FCode (p4_str_unused) { *--SP = (p4cell) SSP - (p4cell) SBREAK; } |
|
FCode_XE (p4_str_quote_execution) { FX_USE_CODE_ADDR PUSH_STR ((MStr *) IP); FX_SKIP_MSTRING; } |
static p4xt* |
P4COMPILES (p4_str_quote, p4_str_quote_execution, p4_lit_mstring_SEE, P4_DEFAULT_STYLE); |
FCode_RT (p4_str_constant_RT) { FX_USE_BODY_ADDR PUSH_STR ((MStr *) FX_POP_BODY_ADDR[0]); } |
P4RUNTIME1(p4_str_constant, p4_str_constant_RT); |
|
|
if (i) { p4_make_str_frame (i); FX_COMPILE(p4_args_brace); FX_UCOMMA (i); MARGS_FLAG = ~0; FX_PUSH (PFE.semicolon_code); FX_PUSH (P4_MARGS_MAGIC); PFE.semicolon_code = p4_margs_EXIT; } |
} |
FCode_XE (p4_make_str_frame_execution) { FX_USE_CODE_ADDR p4_make_str_frame ((p4ucell) *IP++); } |
static p4xt* p4_make_str_frame_SEE (p4xt* ip, char* p, p4_Semant* s) { int i; |
P4COMPILES(p4_args_brace, p4_make_str_frame_execution, p4_make_str_frame_SEE, P4_LOCALS_STYLE); |
FCode_XE (p4_cat_quote_execution) { FX_USE_CODE_ADDR PUSH_STR ((MStr *) IP); FX_SKIP_MSTRING; FX (p4_cat); } |
P4COMPILES (p4_cat_quote, p4_cat_quote_execution, p4_lit_mstring_SEE, P4_DEFAULT_STYLE); |
static p4xt* |
P4COMPILES (p4_cat_back_tick, p4_cat_quote_execution, p4_lit_mstring_back_tick_SEE, P4_DEFAULT_STYLE); |
|
/** $2DROP |
/** $DEPTH |
/** $DROP |
|
/** $@ |
|
|
P4COMPILES(p4_do_drop_str_frame, p4_drop_str_frame, P4_SKIPS_NOTHING, P4_DEFAULT_STYLE); |
|
FCode (per_str_space) { *--SP = DSTRINGS->size; } |
FCode (per_str_space_header) { *--SP = sizeof (StrSpace); } |
FCode (str_break) { *--SP = (p4cell) SBREAK; } |
FCode (str_buffer) { *--SP = (p4cell) SBUFFER; } |
FCode (str_sp) { *--SP = (p4cell) SSP; } |
FCode (str_sp0) { *--SP = (p4cell) SSP0; } |
FCode (frame_depth) { *--SP = ((p4ucell) SFSP0 - (p4ucell) SFSP) / sizeof (StrFrame); } |
FCode (num_frames) { *--SP = DSTRINGS->numframes; } |
FCode (per_frame_stack) { *--SP = sizeof (StrFrame) * DSTRINGS->numframes; } |
FCode (sf_break) { *--SP = (p4cell) SFBREAK; } |
FCode (sf_sp) { *--SP = (p4cell) SFSP; } |
FCode (sf_sp0) { *--SP = (p4cell) SFSP0; } |
FCode (zero_str_space) { p4_clear_str_space (DSTRINGS); } |
|
|
|
|
|
static p4ucell FXCode (interpret_dstrings) |
static FCode (drop_all_strings) { p4_drop_all_strings (p4_DSTRINGS); } |
static FCode(dstrings_deinit) { PFE.interpret[6] = 0; PFE.abort[3] = 0; if (PFE.dstrings) { p4_xfree (PFE.dstrings); PFE.dstrings = 0; } } |
static FCode(dstrings_init) { |
|