Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • sac2c sac2c
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 400
    • Issues 400
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 12
    • Merge requests 12
  • Deployments
    • Deployments
    • Releases
  • Wiki
    • Wiki
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • sac-group
  • sac2csac2c
  • Wiki
  • Tutorials
  • adding a primitive function

adding a primitive function · Changes

Page history
Expanded adding-a-primitive.mdc authored Jun 05, 2025 by Quinten Cabo's avatar Quinten Cabo
Show whitespace changes
Inline Side-by-side
tutorials/adding-a-primitive-function.md 0 → 100644
View page @ f70a8404
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
Clone repository
  • Styleguide
  • concepts
    • Deprecated Modules
    • Globals
    • Intermediate Code Macros
    • Named Tuples
    • Overloading
    • Preprocessor
    • Primitive functions
    • Runtime Representations
    • input stdin
    • phm xt
    • ref counting methods
    • type famlies
    • type patterns
  • error messages
    • Anthropomorphic error essages
View All Pages