2019-01-06 06:49:56 +00:00
|
|
|
# Tool to dump a marshalled version of the janet core to stdout. The
|
2019-01-06 08:23:03 +00:00
|
|
|
# image should eventually allow janet to be started from a pre-compiled
|
2019-01-06 06:49:56 +00:00
|
|
|
# image rather than recompiled every time from the embedded source. More
|
|
|
|
# work will go into shrinking the image (it isn't currently that large but
|
|
|
|
# could be smaller), creating the mechanism to load the image, and modifying
|
2019-01-07 00:33:27 +00:00
|
|
|
# the build process to compile janet with a built image rather than
|
2019-01-06 06:49:56 +00:00
|
|
|
# embedded source.
|
|
|
|
|
|
|
|
# Get image. This image contains as much of the core library and documentation that
|
|
|
|
# can be written to an image (no cfunctions, no abstracts (stdout, stdin, stderr)),
|
2019-01-06 08:23:03 +00:00
|
|
|
# everything else goes. Cfunctions and abstracts will be referenced from a register
|
2019-01-06 06:49:56 +00:00
|
|
|
# table which will be generated on janet startup.
|
2019-01-18 17:24:12 +00:00
|
|
|
(def image (let [env-pairs (pairs (env-lookup *env*))
|
2019-01-06 06:49:56 +00:00
|
|
|
essential-pairs (filter (fn [[k v]] (or (cfunction? v) (abstract? v))) env-pairs)
|
|
|
|
lookup (table ;(mapcat identity essential-pairs))
|
|
|
|
reverse-lookup (invert lookup)]
|
2019-01-18 17:24:12 +00:00
|
|
|
(marshal (table/getproto *env*) reverse-lookup)))
|
2019-01-06 06:49:56 +00:00
|
|
|
|
|
|
|
# Write image
|
|
|
|
(file/write stdout image)
|
|
|
|
(file/flush stdout)
|