Skip to content

Commit

Permalink
We always need an initial_pf, so just create it when we initialize th…
Browse files Browse the repository at this point in the history
…e interpreter. Then we don't need to be checking for it later
  • Loading branch information
Whiteknight committed Jan 13, 2011
1 parent fa6d538 commit 9d9cd51
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 20 deletions.
1 change: 1 addition & 0 deletions src/interp/inter_create.c
Expand Up @@ -256,6 +256,7 @@ initialize_interpreter(PARROT_INTERP, ARGIN(void *stacktop))
interp->all_op_libs = NULL;
interp->evc_func_table = NULL;
interp->evc_func_table_size = 0;
interp->initial_pf = PackFile_new(interp, 0);
interp->code = NULL;

/* And a dynamic environment stack */
Expand Down
32 changes: 12 additions & 20 deletions src/packfile/api.c
Expand Up @@ -1773,27 +1773,18 @@ PackFile_ByteCode *
PF_create_default_segs(PARROT_INTERP, ARGIN(STRING *file_name), int add)
{
ASSERT_ARGS(PF_create_default_segs)
PackFile * const pf = interp->initial_pf;
PackFile_ByteCode * const cur_cs =
(PackFile_ByteCode *)create_seg(interp, &pf->directory,
PF_BYTEC_SEG, BYTE_CODE_SEGMENT_NAME, file_name, add);

/* create an initial_pf if we don't already have one */
if (!interp->initial_pf) {
PackFile * const pf = PackFile_new(interp, 0);
interp->initial_pf = pf;
}

{
PackFile * const pf = interp->initial_pf;
PackFile_ByteCode * const cur_cs =
(PackFile_ByteCode *)create_seg(interp, &pf->directory,
PF_BYTEC_SEG, BYTE_CODE_SEGMENT_NAME, file_name, add);
cur_cs->const_table =
(PackFile_ConstTable *)create_seg(interp, &pf->directory,
PF_CONST_SEG, CONSTANT_SEGMENT_NAME, file_name, add);

cur_cs->const_table =
(PackFile_ConstTable *)create_seg(interp, &pf->directory,
PF_CONST_SEG, CONSTANT_SEGMENT_NAME, file_name, add);
cur_cs->const_table->code = cur_cs;

cur_cs->const_table->code = cur_cs;

return cur_cs;
}
return cur_cs;
}


Expand Down Expand Up @@ -4341,12 +4332,13 @@ static PackFile *
PackFile_append(PARROT_INTERP, ARGIN_NULLOK(PackFile * const pf))
{
ASSERT_ARGS(PackFile_append)
PARROT_ASSERT(interp->initial_pf);

if (pf) {
if (!interp->initial_pf) {
if (!interp->code) {
STRING * const name = CONST_STRING(interp, "dummy");
interp->code = PF_create_default_segs(interp, name, 1);
PARROT_ASSERT(interp->initial_pf);
PARROT_ASSERT(interp->code);
}
PackFile_add_segment(interp, &interp->initial_pf->directory,
&pf->directory.base);
Expand Down

0 comments on commit 9d9cd51

Please sign in to comment.