[Hugs-users] Hugs Extension Proposed: Introspection Patch (p. 1)

Dimitry Golubovsky dimitry at golubovsky.org
Sat Sep 25 22:47:05 EDT 2004


This message has been split into two because of 5 kb message size 
limitations.

Dear list members,

I am suggesting one more extension to Hugs: a set of introspection
primitives. These primitives extend the existing Hugs.Internals module
allowing a Haskell program see the internal structure of Hugs'
compilation results.

This may be used for various purposes such as externalization of Hugs'
compilation results in some format and using them with alternative
runtime. With the primitives proposed, such an externalization may be
performed by a Haskell program, and the native part of Hugs does not
need to be modified. Also Hugs may be further extended to be able to
load precompiled functions/modules thus increasing the startup speed.

URL of the diff file:

http://www.golubovsky.org/software/hugs-insider/hugs98-intro.diff

I have been working on these extensions since June 2004, and the diff
file is against the July 11 CVS snapshot, but as I can see from
cvs-hugs, there have not been any significant updates in the repository
that might conflict with this patch.

These extensions work only if enabled with --enable-internal-prims
configure options.

Here is the summary of what has been done so far.

Internals.hs: added primitives to access almost all fields of Hugs'
storage objects (classes, instances, tycons, etc.) Also some upper-level
wrappers are provided to represent Hugs internal structures in a more
convenient way. I followed the same pattern which was used for the Name
type already present in Hugs.Internals. I extended the CellKind type
definition adding more data constructors to represent not only Names,
but also classes, instances, type expressions, etc. I added the whatIs
primitive which does not require an IO monad (unlike classifyCell), but
it operates with restricted set of cell kinds which I suppose do not
vary over time, therefore IO monad is not needed. whatIs also does not
have side effects because it never evaluates the cell whose kind it
retrieves. I also fixed the Haskell representation of bytecode
instructions (it looks like some Gofer stuff still was there) and added
the DIGIT bytecode (same as CELL, used for BIGNUMs because I needed to
distinguish between numbers that may go with the CELL instruction, and
numbers that make up big integers). I improved the representation of the
TABLE instruction: now it captures the names of tycon's variants. The
FLOAT instruction was removed as it seems to no longer exist in Hugs.
The TEST instruction now has a Cell as its operand rather than a Name
(which is not sufficient to cover all the variants of TEST). Data types
representing Module, Class, Instance, Tycon are made in the same way as
the data type for Name - "opaque integers". Also  toplevel functions
were added providing convenient representation of Hugs' storage contents
and improved printer for bytecodes.

I added some fields to Hugs storage objects, including name.endCode
which caused changes in the prototype and implementation of codeGen.

(to be continued)



More information about the Hugs-Users mailing list