Next: , Previous: , Up: compiler   [Index]


17.21 Introducing primitive operation calls

The purpose of this compiler pass is to examine all the function calls:

(?operator ?operand ...)

which, in recordized code, are represented by struct instances of type funcall; everything else is left untouched. If the ?operator is a struct instance of type primref representing a primitive operation: such struct is replaced by an appropriate struct instance of type primopcall. So recordised code like:

(funcall (primref ?name) (?operand ...))

is transformed into:

(primopcall ?name (?operand ...))

If the funcall struct represents a call to a proper lexical core primitive function (not operation): it is left untouched as funcall struct.

The following bindings are exported by the library (vicare compiler).

Function: pass-introduce-primitive-operation-calls input

Perform code transformation traversing the whole hierarchy in input, which must be a codes struct representing recordised code; build and return a new codes struct.

Transform funcall structs representing core primitive operation applications into primopcall structs.

As example, list is both a lexical core function and a core primitive operation which must return a new list at each invocation; so the core language expression:

((primitive list) '1 '2)

is transformed into:

(codes
  ()
  (primopcall list (constant 1) (constant 2)))