Author: kjs
Date: Tue Dec 16 06:11:44 2008
New Revision: 33953
Modified:
trunk/compilers/pirc/new/pircompunit.c
trunk/compilers/pirc/new/pircompunit.h
Log:
[pirc] fix some documentation. #define a magic number '4' (number of parrot
types)
Modified: trunk/compilers/pirc/new/pircompunit.c
==============================================================================
--- trunk/compilers/pirc/new/pircompunit.c (original)
+++ trunk/compilers/pirc/new/pircompunit.c Tue Dec 16 06:11:44 2008
@@ -56,9 +56,6 @@
=cut
*/
-/*
-PARROT_DOES_NOT_RETURN
-*/
void
panic(lexer_state * lexer, char const * const message) {
fprintf(stderr, "Fatal: %s\n", message);
@@ -283,7 +280,7 @@
init_hashtable(lexer, &newsub->symbols, HASHTABLE_SIZE_INIT);
init_hashtable(lexer, &newsub->labels, HASHTABLE_SIZE_INIT);
- for (index = 0; index < 4; index++) { /* 4 is the number of Parrot types.
*/
+ for (index = 0; index < NUM_PARROT_TYPES; ++index) {
newsub->registers[index] = NULL; /* set all "register" tables to NULL
*/
newsub->regs_used[index] = 0; /* set all register counts to 0 */
}
@@ -1651,7 +1648,10 @@
=item C<void
remove_all_operands(lexer_state * const lexer)>
-Remove all operands of the current instruction.
+Remove all operands of the current instruction. This is done
+by simply setting the pointer to the operands to NULL; all
+memory for the operands is allocated through PIRC memory
+functions, which is automatically freed after compilation.
=cut
@@ -1668,6 +1668,7 @@
expr_from_key(key * const k)>
Wraps the key C<k> in an C<expression> node and returns that.
+The returned expression node has type EXPR_KEY.
=cut
@@ -2360,11 +2361,10 @@
close_sub(lexer_state * const lexer)>
Finalize the subroutine. Generate the final instructions in the current
-subroutine; if the C<:main> flag was set on the subroutine, this is the
-C<end> instruction; otherwise, a I<normal> C<return> sequence is generated.
-
-Then, all local labels are fixed up; i.e., all label identifiers are converted
-into their offsets.
+subroutine, if needed. Then, all local labels are fixed up; i.e., all
+label identifiers are converted into their offsets. The endoffset of this
+subroutine is stored.
+If register optimization was requested, this is invoked here.
=cut
@@ -2404,7 +2404,7 @@
/*
=item C<void
-update_sub_register_usage(lexer_state * const lexer, unsigned reg_usage[4])>
+update_sub_register_usage(lexer_state * const lexer, unsigned
reg_usage[NUM_PARROT_TYPES])>
Update register usage for the current subroutine with the register usage
information in C<reg_usage>.
@@ -2413,9 +2413,9 @@
*/
void
-update_sub_register_usage(lexer_state * const lexer, unsigned reg_usage[4]) {
+update_sub_register_usage(lexer_state * const lexer, unsigned
reg_usage[NUM_PARROT_TYPES]) {
int i;
- for (i = 0; i < 4; ++i)
+ for (i = 0; i < NUM_PARROT_TYPES; ++i)
CURRENT_SUB(lexer)->regs_used[i] = reg_usage[i];
}
Modified: trunk/compilers/pirc/new/pircompunit.h
==============================================================================
--- trunk/compilers/pirc/new/pircompunit.h (original)
+++ trunk/compilers/pirc/new/pircompunit.h Tue Dec 16 06:11:44 2008
@@ -25,6 +25,8 @@
} pir_type;
+/* Parrot has 4 types */
+#define NUM_PARROT_TYPES 4
/* selector values for the expression value union */
@@ -448,7 +450,8 @@
void set_op_labelflag(struct lexer_state * const lexer, int flag);
void convert_inv_to_instr(struct lexer_state * const lexer, invocation * const
inv);
-void update_sub_register_usage(struct lexer_state * const lexer, unsigned
reg_usage[4]);
+void update_sub_register_usage(struct lexer_state * const lexer,
+ unsigned reg_usage[NUM_PARROT_TYPES]);
void panic(struct lexer_state * lexer, char const * const message);