[m-rev.] for post-commit review: new options for querying the compiler

Zoltan Somogyi zoltan.somogyi at runbox.com
Thu Nov 13 16:25:44 AEDT 2014



On Thu, 13 Nov 2014 16:16:00 +1100 (AEDT), Julien Fischer <jfischer at opturion.com> wrote:
> Agreed, that predicate is becoming increasingly unwieldly.  I think
> a better approach would be to have a separate type that represents
> the different modes of operation of the compiler, e.g. something
> like:
> 
>        :- type mode_of_operation
>  	--->	output_target_arch
>  	;	output_class_dir
>  	;	generate_file_mapping
>  	;	compile_module
>  	... etc etc
> 
> and first convert the all the relevant command line options (and any
> other required information) into a value of the above type.  If the
> options conflict with each other we can then print an error message it
> at that point, if not we can then switch on the new type (which would
> replace the big if-then-else).

One simple way to do that would be to have code that
for each option that calls for such action, adds the
corresponding mode_of_operation to a set. Then,
at the end:

- If the set is empty, do the default action.

- If the set has one entry, do its action.

- If the set has more than one entry, do the action
  corresponding to the first after generating an error message
  for all the others.

The priority among the modes_of_operation would thus be reflected
in the order of the type's function symbols.

Zoltan.




More information about the reviews mailing list