Permalink
Browse files

[PMC] replace PMC_struct_val and derivatives with ATTR accessors for …

…the Sub PMC

git-svn-id: https://svn.parrot.org/parrot/trunk@37016 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information...
cotto committed Feb 26, 2009
1 parent 3465ea0 commit 63889c245afc8dccc3591f6f01ffa3441af0143e
@@ -21,6 +21,7 @@
#include "imc.h"
#include "parrot/dynext.h"
#include "parrot/embed.h"
+#include "../../src/pmc/pmc_sub.h"
#include "pbc.h"
#include "parser.h"
#include "optimizer.h"
@@ -694,7 +695,7 @@ imcc_compile(PARROT_INTERP, ARGIN(const char *s), int pasm_file,
* TODO if a sub was denoted :main return that instead
*/
sub = pmc_new(interp, enum_class_Eval);
- sub_data = PMC_sub(sub);
+ PMC_get_sub(interp, sub, sub_data);
sub_data->seg = new_cs;
sub_data->start_offs = 0;
sub_data->end_offs = new_cs->base.size;
View
@@ -6,6 +6,7 @@
#include "imc.h"
#include "pbc.h"
#include "parrot/packfile.h"
+#include "../src/pmc/pmc_sub.h"
/* HEADERIZER HFILE: compilers/imcc/pbc.h */
@@ -101,7 +102,7 @@ PARROT_WARN_UNUSED_RESULT
PARROT_CANNOT_RETURN_NULL
static PMC* create_lexinfo(PARROT_INTERP,
ARGMOD(IMC_Unit *unit),
- ARGIN(PMC *sub),
+ ARGIN(PMC *sub_pmc),
int need_lex)
__attribute__nonnull__(1)
__attribute__nonnull__(2)
@@ -238,7 +239,7 @@ static void verify_signature(PARROT_INTERP,
#define ASSERT_ARGS_create_lexinfo __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(unit) \
- || PARROT_ASSERT_ARG(sub)
+ || PARROT_ASSERT_ARG(sub_pmc)
#define ASSERT_ARGS_find_global_label __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(name) \
@@ -1146,7 +1147,7 @@ current compilation unit.
PARROT_WARN_UNUSED_RESULT
PARROT_CANNOT_RETURN_NULL
static PMC*
-create_lexinfo(PARROT_INTERP, ARGMOD(IMC_Unit *unit), ARGIN(PMC *sub),
+create_lexinfo(PARROT_INTERP, ARGMOD(IMC_Unit *unit), ARGIN(PMC *sub_pmc),
int need_lex)
{
ASSERT_ARGS(create_lexinfo)
@@ -1165,24 +1166,26 @@ create_lexinfo(PARROT_INTERP, ARGMOD(IMC_Unit *unit), ARGIN(PMC *sub),
SymReg *n;
if (!lex_info) {
lex_info = pmc_new_noinit(interp, lex_info_id);
- VTABLE_init_pmc(interp, lex_info, sub);
+ VTABLE_init_pmc(interp, lex_info, sub_pmc);
}
/* at least one lexical name */
n = r->reg;
PARROT_ASSERT(n);
while (n) {
- STRING *lex_name;
- const int k = n->color;
+ STRING *lex_name;
+ const int k = n->color;
+ Parrot_sub *sub;
PARROT_ASSERT(k >= 0);
lex_name = constants[k]->u.string;
PARROT_ASSERT(PObj_is_string_TEST(lex_name));
+ PMC_get_sub(interp, sub_pmc, sub);
IMCC_debug(interp, DEBUG_PBC_CONST,
"add lexical '%s' to sub name '%s'\n",
- n->name, (char*)PMC_sub(sub)->name->strstart);
+ n->name, (char*)sub->name->strstart);
Parrot_PCCINVOKE(interp, lex_info,
string_from_literal(interp, "declare_lex_preg"),
@@ -1197,7 +1200,7 @@ create_lexinfo(PARROT_INTERP, ARGMOD(IMC_Unit *unit), ARGIN(PMC *sub),
if (!lex_info && (unit->outer || need_lex)) {
lex_info = pmc_new_noinit(interp, lex_info_id);
- VTABLE_init_pmc(interp, lex_info, sub);
+ VTABLE_init_pmc(interp, lex_info, sub_pmc);
}
return lex_info;
@@ -1220,10 +1223,11 @@ static PMC*
find_outer(PARROT_INTERP, ARGIN(const IMC_Unit *unit))
{
ASSERT_ARGS(find_outer)
- subs_t *s;
- PMC *current;
- STRING *cur_name;
- size_t len;
+ subs_t *s;
+ PMC *current;
+ STRING *cur_name;
+ Parrot_sub *sub;
+ size_t len;
if (!unit->outer)
return NULL;
@@ -1253,7 +1257,8 @@ find_outer(PARROT_INTERP, ARGIN(const IMC_Unit *unit))
IMCC_fatal(interp, 1, "Undefined :outer sub '%s'.\n",
unit->outer->name);
- cur_name = PMC_sub(current)->name;
+ PMC_get_sub(interp, current, sub);
+ cur_name = sub->name;
if (cur_name->strlen == len
&& (memcmp((char*)cur_name->strstart, unit->outer->name, len) == 0))
@@ -1286,7 +1291,7 @@ add_const_pmc_sub(PARROT_INTERP, ARGMOD(SymReg *r), size_t offs, size_t end)
ASSERT_ARGS(add_const_pmc_sub)
PMC *ns_pmc;
PMC *sub_pmc;
- Parrot_sub *sub;
+ Parrot_sub *sub, *outer_sub;
const int k = add_const_table(interp);
PackFile_ConstTable *ct = interp->code->const_table;
@@ -1348,9 +1353,9 @@ add_const_pmc_sub(PARROT_INTERP, ARGMOD(SymReg *r), size_t offs, size_t end)
}
/* Set flags and get the sub info. */
- PObj_get_FLAGS(sub_pmc) |= (r->pcc_sub->pragma & SUB_FLAG_PF_MASK);
- Sub_comp_get_FLAGS(sub_pmc) |= (r->pcc_sub->pragma & SUB_COMP_FLAG_MASK);
- sub = PMC_sub(sub_pmc);
+ PObj_get_FLAGS(sub_pmc) |= (r->pcc_sub->pragma & SUB_FLAG_PF_MASK);
+ PMC_get_sub(interp, sub_pmc, sub);
+ Sub_comp_get_FLAGS(sub) |= (r->pcc_sub->pragma & SUB_COMP_FLAG_MASK);
r->color = add_const_str(interp, r);
sub->name = ct->constants[r->color]->u.string;
@@ -1471,14 +1476,17 @@ add_const_pmc_sub(PARROT_INTERP, ARGMOD(SymReg *r), size_t offs, size_t end)
pfc->u.key = sub_pmc;
unit->sub_pmc = sub_pmc;
+ if (sub->outer_sub)
+ PMC_get_sub(interp, sub->outer_sub, outer_sub);
+
IMCC_debug(interp, DEBUG_PBC_CONST,
"add_const_pmc_sub '%s' flags %x color %d (%s) "
"lex_info %s :outer(%s)\n",
r->name, r->pcc_sub->pragma, k,
(char *) sub_pmc->vtable->whoami->strstart,
sub->lex_info ? "yes" : "no",
sub->outer_sub ?
- (char *)PMC_sub(sub->outer_sub)->name->strstart :
+ (char *)outer_sub->name->strstart :
"*none*");
/*
View
@@ -9,6 +9,7 @@
#include "parrot/parrot.h"
#include "parrot/interpreter.h"
+#include "../../../src/pmc/pmc_sub.h"
/* #include "parrot/embed.h" */
@@ -791,6 +792,7 @@ static PMC *
find_outer_sub(bytecode * const bc, char const * const outername, struct lexer_state * const lexer)
{
PMC *current;
+ Parrot_sub *sub;
STRING *cur_name;
size_t len;
global_label *outersub;
@@ -836,7 +838,8 @@ find_outer_sub(bytecode * const bc, char const * const outername, struct lexer_s
return NULL;
}
- cur_name = PMC_sub(current)->name;
+ PMC_get_sub(interp, current, sub);
+ cur_name = sub->name;
/* XXX can't this be a call to Parrot_str_compare() ? */
if (cur_name->strlen == len && (memcmp((char *)cur_name->strstart, outername, len) == 0))
@@ -1003,9 +1006,9 @@ add_sub_pmc(bytecode * const bc, sub_info * const info, int needlex, int subprag
interp = bc->interp;
sub_pmc = create_sub_pmc(bc, info->iscoroutine, info->instanceof);
- sub = PMC_sub(sub_pmc);
subname_index = add_string_const(bc, info->subname, "ascii");
subname_const = bc->interp->code->const_table->constants[subname_index];
+ PMC_get_sub(interp, sub_pmc, sub);
/* set start and end offset of this sub in the bytecode.
* This is calculated during the parsing phase.
@@ -1027,8 +1030,8 @@ add_sub_pmc(bytecode * const bc, sub_info * const info, int needlex, int subprag
sub->multi_signature = generate_multi_signature(bc, info->multi_types, info->num_multi_types);
/* copy sub pragma flags such as :immediate etc. */
- PObj_get_FLAGS(sub_pmc) |= subpragmas & SUB_FLAG_PF_MASK;
- Sub_comp_get_FLAGS(sub_pmc) |= subpragmas & SUB_COMP_FLAG_MASK;
+ PObj_get_FLAGS(sub_pmc) |= subpragmas & SUB_FLAG_PF_MASK;
+ Sub_comp_get_FLAGS(sub) |= subpragmas & SUB_COMP_FLAG_MASK;
/* store register usage of this sub. */
@@ -83,7 +83,7 @@ src/piremit$(O): src/piremit.c src/piremit.h
src/hdocprep$(O): src/hdocprep.c src/hdocprep.l
src/pirmacro$(O): src/pirmacro.c src/pirmacro.h
src/pirregalloc$(O): src/pirregalloc.c src/pirregalloc.h
-src/bcgen$(O): src/bcgen.c src/bcgen.h
+src/bcgen$(O): src/bcgen.c src/bcgen.h ../../src/pmc/pmc_sub.h
src/pirpcc$(O): src/pirpcc.c src/pirpcc.h
src/pirerr$(O): src/pirerr.c src/pirerr.h
src/pircapi$(O): src/pircapi.c src/pircapi.h
@@ -609,7 +609,7 @@ PMC2CV := $(PERL) $(BUILD_TOOLS_DIR)/pmc2c.pl --vtable
.pmc.dump :
$(PMC2CD) $<
-.pmc.c :
+.pmc.c : $(SRC_DIR)/pmc/pmc_sub.h
$(PMC2CC) $<
# not all makes might understand this, so the rules are generated
@@ -913,6 +913,7 @@ $(INSTALLABLEDIS) : $(SRC_DIR)/pbc_disassemble$(O) $(LIBPARROT)
#
# Parrot Dump
#
+$(SRC_DIR)/packdump$(O) : $(SRC_DIR)/pmc/pmc_sub.h
$(PDUMP) : $(SRC_DIR)/pbc_dump$(O) $(SRC_DIR)/packdump$(O) $(LIBPARROT)
$(LINK) @ld_out@$@ \
@@ -1013,7 +1014,8 @@ examples/pasm/hello$(EXE): examples/pasm/hello$(O)
$(SRC_DIR)/global_setup$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/global_setup.str
-$(SRC_DIR)/global$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/global.str
+$(SRC_DIR)/global$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/global.str \
+ $(SRC_DIR)/pmc/pmc_sub.h
$(SRC_DIR)/pmc$(O) : $(GENERAL_H_FILES)
@@ -1025,7 +1027,7 @@ $(SRC_DIR)/list$(O) : $(GENERAL_H_FILES)
$(SRC_DIR)/library$(O) : $(GENERAL_H_FILES)
-$(SRC_DIR)/jit$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/jit_emit.h
+$(SRC_DIR)/jit$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/jit_emit.h $(SRC_DIR)/pmc/pmc_sub.h
$(SRC_DIR)/jit_debug$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/debug.str
@@ -1072,12 +1074,13 @@ $(SRC_DIR)/platform$(O) : $(GENERAL_H_FILES)
#IF(platform_asm):
$(SRC_DIR)/core_pmcs$(O) : $(GENERAL_H_FILES)
-$(SRC_DIR)/trace$(O) : $(GENERAL_H_FILES)
+$(SRC_DIR)/trace$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/pmc/pmc_sub.h
$(SRC_DIR)/debug$(O) : $(GENERAL_H_FILES) $(INC_DIR)/debugger.h \
$(SRC_DIR)/debug.str
-$(SRC_DIR)/sub$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/sub.str
+$(SRC_DIR)/sub$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/sub.str \
+ $(SRC_DIR)/pmc/pmc_sub.h
$(SRC_DIR)/string/api$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/string/private_cstring.h
@@ -1091,9 +1094,10 @@ $(SRC_DIR)/exceptions$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/exceptions.str
$(SRC_DIR)/events$(O) : $(GENERAL_H_FILES)
-$(SRC_DIR)/thread$(O) : $(GENERAL_H_FILES)
+$(SRC_DIR)/thread$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/pmc/pmc_sub.h
-$(SRC_DIR)/extend$(O) : $(GENERAL_H_FILES) $(INC_DIR)/extend.h
+$(SRC_DIR)/extend$(O) : $(GENERAL_H_FILES) $(INC_DIR)/extend.h \
+ $(SRC_DIR)/pmc/pmc_sub.h
$(SRC_DIR)/interpreter$(O) : $(SRC_DIR)/interpreter.c $(GENERAL_H_FILES)
@@ -1129,28 +1133,30 @@ $(SRC_DIR)/main$(O) : $(SRC_DIR)/main.c $(GENERAL_H_FILES)
$(SRC_DIR)/pic$(O) : $(GENERAL_H_FILES)
-$(SRC_DIR)/pic_jit$(O) : $(GENERAL_H_FILES)
+$(SRC_DIR)/pic_jit$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/pmc/pmc_sub.h
$(SRC_DIR)/multidispatch$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/multidispatch.str \
- $(SRC_DIR)/pmc/pmc_nci.h
+ $(SRC_DIR)/pmc/pmc_nci.h $(SRC_DIR)/pmc/pmc_sub.h
-$(SRC_DIR)/packfile$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/packfile.str
+$(SRC_DIR)/packfile$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/packfile.str \
+ $(SRC_DIR)/pmc/pmc_sub.h
$(PF_DIR)/pf_items$(O) : $(GENERAL_H_FILES)
$(SRC_DIR)/packout$(O) : $(GENERAL_H_FILES)
$(SRC_DIR)/parrot$(O) : $(GENERAL_H_FILES)
-$(SRC_DIR)/gc/register$(O) : $(GENERAL_H_FILES)
+$(SRC_DIR)/gc/register$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/pmc/pmc_sub.h
$(SRC_DIR)/runops_cores$(O) : $(GENERAL_H_FILES)
$(SRC_DIR)/stacks$(O) : $(GENERAL_H_FILES)
$(SRC_DIR)/tsq$(O) : $(GENERAL_H_FILES)
-$(SRC_DIR)/embed$(O) : $(GENERAL_H_FILES) $(INC_DIR)/debugger.h
+$(SRC_DIR)/embed$(O) : $(GENERAL_H_FILES) $(INC_DIR)/debugger.h \
+ $(SRC_DIR)/pmc/pmc_sub.h
$(SRC_DIR)/dataypes$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/dataypes.c
@@ -1180,7 +1186,8 @@ $(SRC_DIR)/string/encoding$(O) : $(SRC_DIR)/string/encoding.c $(GENERAL_H_FILES)
$(SRC_DIR)/string/charset$(O) : $(SRC_DIR)/string/charset.c $(GENERAL_H_FILES)
-$(SRC_DIR)/pbc_merge$(O) : $(SRC_DIR)/pbc_merge.c $(GENERAL_H_FILES)
+$(SRC_DIR)/pbc_merge$(O) : $(SRC_DIR)/pbc_merge.c $(GENERAL_H_FILES) \
+ $(SRC_DIR)/pmc/pmc_sub.h
$(IO_DIR)/filehandle$(O) : $(SRC_DIR)/pmc/pmc_filehandle.h $(SRC_DIR)/io/io_private.h
@@ -30,6 +30,7 @@ example compiler used by japh16.pasm
#include "parrot/parrot.h"
#include "parrot/embed.h"
+#include "../../src/pmc/pmc_sub.h"
#define C_DEBUG 0
@@ -230,7 +231,7 @@ japh_compiler(PARROT_INTERP, const char *program)
* create sub PMC
*/
sub = pmc_new(interp, enum_class_Eval);
- sub_data = PMC_sub(sub);
+ PMC_get_sub(interp, sub, sub_data);
sub_data->seg = cur_cs;
sub_data->address = cur_cs->base.data;
sub_data->end = cur_cs->base.data + cur_cs->base.size;
View
@@ -92,23 +92,23 @@ PARROT_EXPORT
PARROT_WARN_UNUSED_RESULT
PARROT_CAN_RETURN_NULL
void* Parrot_call_sub(PARROT_INTERP,
- Parrot_PMC sub,
+ Parrot_PMC sub_pmc,
ARGIN(const char *signature),
...)
__attribute__nonnull__(1)
__attribute__nonnull__(3);
PARROT_EXPORT
Parrot_Float Parrot_call_sub_ret_float(PARROT_INTERP,
- Parrot_PMC sub,
+ Parrot_PMC sub_pmc,
ARGIN(const char *signature),
...)
__attribute__nonnull__(1)
__attribute__nonnull__(3);
PARROT_EXPORT
Parrot_Int Parrot_call_sub_ret_int(PARROT_INTERP,
- Parrot_PMC sub,
+ Parrot_PMC sub_pmc,
ARGIN(const char *signature),
...)
__attribute__nonnull__(1)
View
@@ -153,7 +153,7 @@ void Parrot_store_global_s(PARROT_INTERP,
__attribute__nonnull__(1);
PARROT_EXPORT
-void Parrot_store_sub_in_namespace(PARROT_INTERP, ARGIN(PMC *sub))
+void Parrot_store_sub_in_namespace(PARROT_INTERP, ARGIN(PMC *sub_pmc))
__attribute__nonnull__(1)
__attribute__nonnull__(2);
@@ -205,7 +205,7 @@ void Parrot_store_sub_in_namespace(PARROT_INTERP, ARGIN(PMC *sub))
PARROT_ASSERT_ARG(interp)
#define ASSERT_ARGS_Parrot_store_sub_in_namespace __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(sub)
+ || PARROT_ASSERT_ARG(sub_pmc)
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
/* HEADERIZER END: src/global.c */
Oops, something went wrong.

0 comments on commit 63889c2

Please sign in to comment.