# HG changeset patch # User Jaroslav Hajek # Date 1265871120 -3600 # Node ID 7b5e8527441e27f7c611f3090617e898a118e793 # Parent d6cdf08d04241b6405b8e30833ebfc0e9c9a40b8 partially revert 2ceae0b40515, implement a better fallback diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2010-02-11 Jaroslav Hajek + + * symtab.cc: Reverse the effect of 2ceae0b40515. + (get_dispatch_type): If btyp_unknown occurs, read the class dispatch + type. + 2010-02-10 John W. Eaton * load-save.cc: If gnulib defines close, undefine it. diff --git a/src/symtab.cc b/src/symtab.cc --- a/src/symtab.cc +++ b/src/symtab.cc @@ -452,10 +452,9 @@ // to btyp_num_types (static constant). Only the leftmost dimension can be // variable in C/C++. Typedefs are boring. -// For safety, we include btyp_unknown in the table -static builtin_type_t (*build_sup_table (void))[btyp_num_types + 1] +static builtin_type_t (*build_sup_table (void))[btyp_num_types] { - static builtin_type_t sup_table[btyp_num_types + 1][btyp_num_types + 1]; + static builtin_type_t sup_table[btyp_num_types][btyp_num_types]; for (int i = 0; i < btyp_num_types; i++) for (int j = 0; j < btyp_num_types; j++) { @@ -473,12 +472,6 @@ sup_table[i][j] = use_j ? jtyp : ityp; } - for (int i = 0; i <= btyp_num_types; i++) - { - sup_table[btyp_unknown][i] = btyp_unknown; - sup_table[i][btyp_unknown] = btyp_unknown; - } - return sup_table; } @@ -486,7 +479,7 @@ get_dispatch_type (const octave_value_list& args, bool& builtin_class) { - static builtin_type_t (*sup_table)[btyp_num_types+1] = build_sup_table (); + static builtin_type_t (*sup_table)[btyp_num_types] = build_sup_table (); std::string dispatch_type; int n = args.length (); @@ -530,20 +523,24 @@ // Use the builtin_type mechanism to do this by one method call per // element. + int i = 0; builtin_type_t btyp = args(0).builtin_type (); - for (int i = 1; i < n; i++) - btyp = sup_table[btyp][args(i).builtin_type ()]; + if (btyp != btyp_unknown) + { + for (i = 1; i < n; i++) + { + builtin_type_t bti = args(i).builtin_type (); + if (bti == btyp_unknown) + break; + btyp = sup_table[btyp][bti]; + } + } - if (btyp != btyp_unknown) + // If there was an unknown type, we just take the class name of that value. + if (i == n) dispatch_type = btyp_class_name[btyp]; else - { - // Basically, this should never happen if all values are defined. - // If not, that's an internal inconsistency. - builtin_class = false; - error ("internal error: undefined or invalid value in argument list"); - } - + dispatch_type = args(i).class_name (); } }