Author: kjs
Date: Mon Dec 29 03:17:15 2008
New Revision: 34566
Modified:
trunk/compilers/pirc/new/bcgen.c
trunk/compilers/pirc/new/pircompunit.c
Log:
[pirc] fix a bug, and add a few comments.
Modified: trunk/compilers/pirc/new/bcgen.c
==============================================================================
--- trunk/compilers/pirc/new/bcgen.c (original)
+++ trunk/compilers/pirc/new/bcgen.c Mon Dec 29 03:17:15 2008
@@ -418,7 +418,7 @@
*/
static PMC *
generate_multi_signature(bytecode * const bc, multi_type * const types,
unsigned type_count) {
- unsigned i;
+ unsigned i;
multi_type *iter;
/* create a FixedPMCArray to store all multi types */
@@ -427,7 +427,10 @@
VTABLE_set_integer_native(bc->interp, multi_signature, type_count);
- if (type_count == 1) { /* no actual types, just empty :multi() flag. */
+ /* A type_count of 1 means there was a :multi flag, but no :multi types.
+ * therefore, create a special signature and return that.
+ */
+ if (type_count == 1) {
STRING * const sig = string_from_literal(bc->interp, "__VOID");
PMC * const sig_pmc = pmc_new(bc->interp, enum_class_String);
@@ -438,6 +441,8 @@
}
iter = types;
+ --type_count; /* type count is 1 too high, fix that now. */
+
/* add all multi types to the PMC array */
for (i = 0; i < type_count; ++i) {
PMC *sig_pmc;
Modified: trunk/compilers/pirc/new/pircompunit.c
==============================================================================
--- trunk/compilers/pirc/new/pircompunit.c (original)
+++ trunk/compilers/pirc/new/pircompunit.c Mon Dec 29 03:17:15 2008
@@ -141,8 +141,8 @@
*/
void
set_sub_multi_types(lexer_state * const lexer, expression * const multitype) {
- /* info.num_types is 1 higher than the actual number of types; n=1 means
:multi() without
- * any types.
+ /* info.num_types is 1 higher than the actual number of types;
+ * n=1 means :multi() without any types; therefore, subtract 1 for actual
number.
*/
unsigned num_types = CURRENT_SUB(lexer)->info.num_multi_types - 1;