|
|
There is a tutorial about this in the `sac2clib/tree/prf_info.mac` file.
|
|
|
|
|
|
Also read [Primitive-functions](../concepts/Primitive-functions.md) for more information about primitive functions.
|
|
|
|
|
|
* 1. Add an entry for the primitive to the table below.
|
|
|
* 2. Add a function for the primitive to typecheck/ct_prf.c/h.
|
|
|
* 3. Add a COMPprf... function for the primitive to codegen/compile.c and a ccode entry in this table, below.
|
|
|
* 4. Add an entry for the primitive to memory/alloc.c
|
|
|
* 5. Add entries for the primitive to scanparse/prf.def if the
|
|
|
primitive is intended to be allowed within SAC source code,
|
|
|
and it is being treated as a normal function call. In case you
|
|
|
need a special treatement, like conversion to a specific AST, then
|
|
|
adjust scanparse/parser.c handle_function_call and friends.
|
|
|
* 6. Add a function COxxx to constants/constants.h and write
|
|
|
appropriate evaluation of xxx when all its
|
|
|
arguments are constant.
|
|
|
When doing so, you likely have to add entries to the following:
|
|
|
- zipcv.c
|
|
|
- zipcv.h
|
|
|
- globals.mac
|
|
|
- globals.c
|
|
|
* 7. Run-time: add code to src/runtime/essentials_h/prf.h for the run-time execution code.
|
|
|
* 8. Do a make clean on BOTH sac2c and the stdlib, or you will see VERY strange things happening. I think this is due to assumptions about PRF_PRF values.
|
|
|
|
|
|
\ No newline at end of file |