From 9d9cd51abc2a5b9f01557d077775a5842f0c7b81 Mon Sep 17 00:00:00 2001 From: Whiteknight Date: Thu, 13 Jan 2011 09:17:34 -0500 Subject: [PATCH] We always need an initial_pf, so just create it when we initialize the interpreter. Then we don't need to be checking for it later --- src/interp/inter_create.c | 1 + src/packfile/api.c | 32 ++++++++++++-------------------- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/src/interp/inter_create.c b/src/interp/inter_create.c index b9788ceee3..f19b0a0cbb 100644 --- a/src/interp/inter_create.c +++ b/src/interp/inter_create.c @@ -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 */ diff --git a/src/packfile/api.c b/src/packfile/api.c index c454c0e186..9ad6ffa025 100644 --- a/src/packfile/api.c +++ b/src/packfile/api.c @@ -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; } @@ -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);