[svn:parrot] r47646 - in trunk: src/pmc t/pmc
NotFound at svn.parrot.org
NotFound at svn.parrot.org
Tue Jun 15 19:30:30 UTC 2010
Author: NotFound
Date: Tue Jun 15 19:30:29 2010
New Revision: 47646
URL: https://trac.parrot.org/parrot/changeset/47646
Log:
some code cleanup and a new test in Eval PMC to improve coverage, no functional changes
Modified:
trunk/src/pmc/eval.pmc
trunk/t/pmc/eval.t
Modified: trunk/src/pmc/eval.pmc
==============================================================================
--- trunk/src/pmc/eval.pmc Tue Jun 15 17:35:18 2010 (r47645)
+++ trunk/src/pmc/eval.pmc Tue Jun 15 19:30:29 2010 (r47646)
@@ -57,30 +57,25 @@
{
ASSERT_ARGS(clear_fixups)
- INTVAL i;
- PackFile_ByteCode * const seg = sub_data->seg;
- PackFile_FixupTable *ft;
- PackFile_ConstTable *ct;
-
- if (!seg)
- return;
-
- ft = seg->fixups;
- if (!ft)
- return;
-
- ct = seg->const_table;
- if (!ct)
- return;
+ PackFile_ByteCode * const seg = sub_data->seg;
- for (i = 0; i < ft->fixup_count; ++i) {
- PackFile_FixupEntry * const e = ft->fixups + i;
-
- if (e->type == enum_fixup_sub) {
- opcode_t ci = e->offset;
-
- ct->constants[ci]->u.key = NULL;
- e->type = 0;
+ if (seg) {
+ PackFile_FixupTable * const ft = seg->fixups;
+ if (ft) {
+ PackFile_ConstTable * const ct = seg->const_table;
+ if (ct) {
+ INTVAL i;
+ for (i = 0; i < ft->fixup_count; ++i) {
+ PackFile_FixupEntry * const e = ft->fixups + i;
+
+ if (e->type == enum_fixup_sub) {
+ opcode_t ci = e->offset;
+
+ ct->constants[ci]->u.key = NULL;
+ e->type = 0;
+ }
+ }
+ }
}
}
}
@@ -92,34 +87,29 @@
{
ASSERT_ARGS(get_sub)
- INTVAL i, n;
Parrot_Sub_attributes *sub;
PackFile_ByteCode *seg;
- PackFile_FixupTable *ft;
- PackFile_ConstTable *ct;
PMC_get_sub(interp, self, sub);
seg = sub->seg;
- if (!seg)
- return PMCNULL;
-
- ft = seg->fixups;
- if (!ft)
- return PMCNULL;
-
- ct = seg->const_table;
- if (!ct)
- return PMCNULL;
-
- for (i = n = 0; i < ft->fixup_count; ++i) {
- const PackFile_FixupEntry * const e = ft->fixups + i;
-
- if (e->type == enum_fixup_sub) {
- opcode_t ci = e->offset;
-
- if (n++ == idx)
- return ct->constants[ci]->u.key;
+ if (seg) {
+ PackFile_FixupTable * const ft = seg->fixups;
+ if (ft) {
+ PackFile_ConstTable * const ct = seg->const_table;
+ if (ct) {
+ INTVAL i, n;
+ for (i = n = 0; i < ft->fixup_count; ++i) {
+ const PackFile_FixupEntry * const e = ft->fixups + i;
+
+ if (e->type == enum_fixup_sub) {
+ opcode_t ci = e->offset;
+
+ if (n++ == idx)
+ return ct->constants[ci]->u.key;
+ }
+ }
+ }
}
}
@@ -133,32 +123,27 @@
Parrot_Sub_attributes *sub;
PackFile_ByteCode *seg;
- PackFile_FixupTable *ft;
- PackFile_ConstTable *ct;
- INTVAL i;
PMC_get_sub(interp, self, sub);
seg = sub->seg;
- if (!seg)
- return;
-
- ft = seg->fixups;
- if (!ft)
- return;
-
- ct = seg->const_table;
- if (!ct)
- return;
-
- for (i = 0; i < ft->fixup_count; ++i) {
- const PackFile_FixupEntry * const e = ft->fixups + i;
-
- if (e->type == enum_fixup_sub) {
- opcode_t ci = e->offset;
- PMC *sub = ct->constants[ci]->u.key;
-
- Parrot_gc_mark_PMC_alive(interp, sub);
+ if (seg) {
+ PackFile_FixupTable * const ft = seg->fixups;
+ if (ft) {
+ PackFile_ConstTable * const ct = seg->const_table;
+ if (ct) {
+ INTVAL i;
+ for (i = 0; i < ft->fixup_count; ++i) {
+ const PackFile_FixupEntry * const e = ft->fixups + i;
+
+ if (e->type == enum_fixup_sub) {
+ opcode_t ci = e->offset;
+ PMC *sub = ct->constants[ci]->u.key;
+
+ Parrot_gc_mark_PMC_alive(interp, sub);
+ }
+ }
+ }
}
}
}
@@ -411,26 +396,24 @@
}
VTABLE INTVAL elements() {
- INTVAL i, n;
+ INTVAL n = 0;
Parrot_Sub_attributes *sub;
- PackFile_ByteCode *seg;
- PackFile_FixupTable *ft;
+ PackFile_ByteCode *seg;
PMC_get_sub(INTERP, SELF, sub);
seg = sub->seg;
- if (!seg)
- return 0;
-
- ft = seg->fixups;
- if (!ft)
- return 0;
-
- for (i = n = 0; i < ft->fixup_count; ++i) {
- const PackFile_FixupEntry * const e = ft->fixups + i;
-
- if (e->type == enum_fixup_sub)
- ++n;
+ if (seg) {
+ PackFile_FixupTable *const ft = seg->fixups;
+ if (ft) {
+ INTVAL i;
+ for (i = n = 0; i < ft->fixup_count; ++i) {
+ const PackFile_FixupEntry * const e = ft->fixups + i;
+
+ if (e->type == enum_fixup_sub)
+ ++n;
+ }
+ }
}
return n;
Modified: trunk/t/pmc/eval.t
==============================================================================
--- trunk/t/pmc/eval.t Tue Jun 15 17:35:18 2010 (r47645)
+++ trunk/t/pmc/eval.t Tue Jun 15 19:30:29 2010 (r47646)
@@ -46,11 +46,15 @@
compreg P1, "PASM"
set_args "0", S5
invokecc P1
+ get_results "0", P2
+ elements I0, P2
+ say I0
get_global P0, "_foo"
invokecc P0
print "back\n"
end
CODE
+1
foo
back
OUTPUT
More information about the parrot-commits
mailing list