The I6 stack

Well, there’s the I7 heap. You can use the LIST_OF_TY_* functions from I6 code to work with lists, so you could make a stack out of a global list of numbers. Or you could even have arbitrarily swappable match lists by copying the match globals to a list:

[code]To save match globals into (L - list of numbers): (- SaveMatchGlobals({-pointer-to:L}); -).
To restore match globals from (L - list of numbers): (- RestoreMatchGlobals({-pointer-to:L}); -).

Include (-
[ SaveMatchGlobals list i j;
LIST_OF_TY_SetLength(list, 3 * number_matched + 5, 0);
LIST_OF_TY_PutItem(list, 1, match_from);
LIST_OF_TY_PutItem(list, 2, token_filter);
LIST_OF_TY_PutItem(list, 3, match_length);
LIST_OF_TY_PutItem(list, 4, number_of_classes);
LIST_OF_TY_PutItem(list, 5, oops_from);
for ( i=0, j=6: i<number_matched: i++ ) {
LIST_OF_TY_PutItem(list, j++, match_list–>i);
LIST_OF_TY_PutItem(list, j++, match_classes–>i);
LIST_OF_TY_PutItem(list, j++, match_scores–>i);
}
];

[ RestoreMatchGlobals list i j;
number_matched = (LIST_OF_TY_GetLength(list) - 5) / 3;
match_from = LIST_OF_TY_GetItem(list, 1);
token_filter = LIST_OF_TY_GetItem(list, 2);
match_length = LIST_OF_TY_GetItem(list, 3);
number_of_classes = LIST_OF_TY_GetItem(list, 4);
oops_from = LIST_OF_TY_GetItem(list, 5);
for ( i=0, j=6: i<number_matched: i++ ) {
match_list–>i = LIST_OF_TY_GetItem(list, j++);
match_classes–>i = LIST_OF_TY_GetItem(list, j++);
match_scores–>i = LIST_OF_TY_GetItem(list, j++);
}
]; -).[/code]

1 Like