Skip to content

Commit

Permalink
Add main_sub to BytecodeSegment
Browse files Browse the repository at this point in the history
  • Loading branch information
bacek committed Jan 5, 2011
1 parent 81e718d commit 55002ed
Showing 1 changed file with 39 additions and 2 deletions.
41 changes: 39 additions & 2 deletions src/pmc/packfilebytecodesegment.pmc
Expand Up @@ -29,8 +29,9 @@ spec.
#include "pmc/pmc_packfileopmap.h"

pmclass PackfileBytecodeSegment auto_attrs extends PackfileSegment {
ATTR PMC *ops; /* RIA of executable opcodes */
ATTR PMC *op_map; /* OpMap PMC */
ATTR PMC *ops; /* RIA of executable opcodes */
ATTR PMC *op_map; /* OpMap PMC */
ATTR INTVAL main_sub; /* Index of :main sub */



Expand Down Expand Up @@ -98,6 +99,7 @@ Return a pointer to a PackFile_ByteCode* built from this PMC's data.
bc->base.type = PF_BYTEC_SEG;

/* Create proper ByteCode structure from internal PMCs */
GET_ATTR_main_sub(INTERP, SELF, bc->main_sub);

/* Copy ops into ByteCode */
GET_ATTR_ops(INTERP, SELF, ops);
Expand Down Expand Up @@ -261,6 +263,41 @@ Fetch an integer's worth of data from the segment.

/*

=item C<INTVAL elements()>

=item C<INTVAL get_integer()>

=item C<INTVAL get_number()>

Get the number of elements in the array.

=cut

*/
VTABLE INTVAL elements() {
return VTABLE_elements(INTERP,
PARROT_PACKFILEBYTECODESEGMENT(SELF)->ops);
}

VTABLE INTVAL get_integer() {
return STATICSELF.elements();
}

VTABLE FLOATVAL get_number() {
return STATICSELF.elements();
}


METHOD main_sub(INTVAL main_sub :optional, INTVAL got_main :opt_flag) {
if (got_main) {
SET_ATTR_main_sub(INTERP, SELF, main_sub);
}
GET_ATTR_main_sub(INTERP, SELF, main_sub);
RETURN(INTVAL main_sub);
}

/*

=back

=cut
Expand Down

0 comments on commit 55002ed

Please sign in to comment.