jamesco@cogs.susx.ac.uk (James Cox) writes:
> Date: 15 Nov 1996 16:22:03 GMT
> Organization: University of Sussex
>
> I am currently writing a POP-11 to C translator for my final year project, and
> would like peoples opinions on a particular aspect of this project.
> ...
>
> but in order to do this, the translator has to know what types the arguments
> will be. Instead of mucking about, I'm simply going to add functions
> prototypes to my dialect of POP-11.
> .....
> My first ideas are along these lines:
>
> define prototype simple(int a, int b) -> int result;
>
> and
>
> ;;; prototype simple(int a, int b) -> int result;
If you use the define_form syntax (See HELP DEFINE_FORM) you should
be able to define a format
define :prototype simple(int a, int b) -> int result;
which allows the procedure to compile as a normal Pop-11 procedure
with extra type checks if pop_debugging is true at compile time,
something like this:
define simple(a, b) -> result;
#_IF pop_debugging
checkinteger(a, false, false);
checkinteger(b, false, false);
checkinteger(result, false, false);
#_ENDIF
....
or you could use
if pop_debugging then ...
enabling the checking to be turned on and off after compiling the
procedure.
Either way the procedure define_prototype would simply read
everything in up to the semicolon, analyse the type declarations,
shove the required code (starting with "define" ) back onto
proglist, then invoke pop11_comp_expr() to compile the revised
procedure definition.
Aaron
===
--
Aaron Sloman, ( http://www.cs.bham.ac.uk/~axs )
School of Computer Science, The University of Birmingham, B15 2TT, England
EMAIL A.Sloman@cs.bham.ac.uk
Phone: +44-121-414-4775 (Sec 3711) Fax: +44-121-414-4281
|