[m-dev.] Tabling [3/3]

Fergus Henderson fjh at cs.mu.OZ.AU
Tue Mar 31 00:46:00 AEST 1998


On 23-Mar-1998, Oliver Hutchison <ohutch at students.cs.mu.oz.au> wrote:
> table_gen__process_module(Module0, Module) :-
> 	module_info_preds(Module0, Preds0),
> 	map__keys(Preds0, PredIds),
> 	table_gen__process_preds(PredIds, Module0, Module).
> 
> :- pred table_gen__process_preds(list(pred_id), module_info, module_info).
> :- mode table_gen__process_preds(in, in, out) is det.
> 
> table_gen__process_preds([], Module, Module).
> table_gen__process_preds([PredId | PredIds], Module0, Module) :-
> 	table_gen__process_pred(PredId, Module0, Module1),
> 	table_gen__process_preds(PredIds, Module1, Module).

It would be useful to have a comment here explaining why you
don't use passes_aux.m.

> :- pred generate_get_table_goals(map(var, type), map(var, type), varset,
> 		varset, module_info, var, hlds_goal).
> :- mode generate_get_table_goals(in, out, in, out, in, out, out) is det.
> 
> generate_get_table_goals(VarTypes0, VarTypes, VarSet0, VarSet, Module, 
> 		TableVar, Goal) :-
> 	generate_new_table_var(VarTypes0, VarTypes, VarSet0, VarSet, 
> 		TableVar),
> 
> 		% The predicate get_table/1 is used only for its pred_info
> 		% the code is not actualy called.  We have to steal the 

s/actualy/actually/

> New File: runtime/mercury_table_enum.c
...
> TrieNode 
> MR_int_index_lookup_or_add(TrieNode t, Integer key, Integer range)
> {
> 	Word *table = *t;		/* Deref table */
> 	
> 	if (table == NULL) {
> 		*t = table = table_allocate(sizeof(Word*)*range);
> 		memset(table, 0, sizeof(Word*)*range);
> 	}

s/)*range/) * range/
           ^ ^

> New File: runtime/mercury_table_int_float_string.c
...
> /* 
> ** Look to see if the given integer key is in the given table. If it
> ** is return the address of the data pointer associated with the key.
> ** If it is not; create a new element for the key in the table and
> ** return the address of its data pointer
> */
> TrieNode 
> MR_int_hash_lookup_or_add(TrieNode t, Integer key)

Please add a `.' at the of the comment.

> /* 
> ** Look to see if the given float key is in the given table. If it
> ** is return the address of the data pointer associated with the key.
> ** If it is not create a new element for the key in the table and
> ** return the address of its data pointer
> */
> TrieNode 
> MR_float_hash_lookup_or_add(TrieNode t, Float key)

Ditto.

> /* 
> ** Look to see if the given string key is in the given table. If it
> ** is return the address of the data pointer associated with the key.
> ** If it is not create a new element for the key in the table and
> ** return the address of its data pointer
> */
> TrieNode 
> MR_string_hash_lookup_or_add(TrieNode t, String key)

Ditto.

> New File: runtime/mercury_table_int_float_string.h
...
> /* Look to see if the given integer key is in the given table. If it
> ** is return the address of the data pointer associated with the key.
> ** If it is not; create a new element for the key in the table and
> ** return the address of its data pointer
> **/
> TrieNode MR_int_hash_lookup_or_add(TrieNode Table, Integer Key);
> 
> /* Look to see if the given float key is in the given table. If it
> ** is return the address of the data pointer associated with the key.
> ** If it is not create a new element for the key in the table and
> ** return the address of its data pointer
> **/
> TrieNode MR_float_hash_lookup_or_add(TrieNode Table, Float Key);
> 
> /* Look to see if the given string key is in the given table. If it
> ** is return the address of the data pointer associated with the key.
> ** If it is not create a new element for the key in the table and
> ** return the address of its data pointer
> **/
> TrieNode MR_string_hash_lookup_or_add(TrieNode Table, String Key);

Ditto.  Also the comment layout here does not quite match our standard.

> /*
> ** mercury_tabling.h - definitions of some basic macros used by the tabling
> ** code generated by the Mercury compiler and by the Mercury runtime.
> */
> 
> #ifndef MERCURY_TABLING_H
> #define MERCURY_TABLING_H
> 
> #define MR_TABLE_DEBUG

Should MR_TABLE_DEBUG still be defined?

That's it for part 3.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.



More information about the developers mailing list