Next: compiler type inference, Previous: compiler optimisation, Up: compiler [Index]
References to bindings in recordised code are represented as standalone
prelex structures; assignments to bindings in recordised code
are represented as assign structs:
(assign ?prel ?rhs)
in which ?prel is a prelex structure and the right–hand
side ?rhs is recordised code which, evaluated at run–time, will
return the new binding’s value.
With respect to how references and assignments are actually implemented, there are three kinds of lexical bindings:
library-letrec* core language
forms; Handling of lexical top level
bindings.
let,
letrec and letrec* core language forms and never subjected
to a set! core language form; Handling of lexical local bindings.
let,
letrec and letrec* core language forms and subjected to
one or more set! core language forms; Handling of lexical local bindings.
The following bindings are exported by the library (vicare
compiler).
Perform code transformations traversing the whole hierarchy in input, which must be a struct instance representing recordised code, and building a new hierarchy of recordised code; return the new hierarchy.
Transform references and assignments for top level lexical bindings and
unassigned local lexical bindings according to the implementation of
such operations. Remembering that the actual value of a top level
binding is stored in the value field of a loc gensym, this
function performs the following transformations:
(funcall (primref $symbol-value) (constant ?loc))
which extracts the value from slot value of the loc gensym
?loc.
(funcall (primref $set-symbol-value!)
(constant ?loc)
?rhs)
which stores a new value in the slot value of the log gensym
?loc.
(funcall (primref $init-symbol-value!)
(constant ?loc)
?rhs)
which stores a new value in the slot value of ?loc and,
only if the value is recognised at run–time as being closure object,
also stores value in the slot proc.
(bind ((?prel ?init)) ?body)
→ (bind ((?tmp-prel ?init))
(bind ((?prel (funcall (primref vector)
?tmp-prel)))
?body))
prelex structs to:
(funcall (primref $vector-ref) ?prel (constant 0))
(assign ?prel ?rhs)
→ (funcall (primref $vector-set!)
?prel
(constant 0)
?rhs)
After this compiler pass: there are no more assign structs in
the returned recordised code.
Next: compiler type inference, Previous: compiler optimisation, Up: compiler [Index]