Posted to tcl by mookie at Sat Oct 31 00:45:52 GMT 2026view raw
- namespace eval crystal { }
- namespace eval crystal::cast { }
- namespace export {[a-z]*} {
- namespace ensemble create }
- source [dict get $::crystal::vfs b32_load]/cast/procs.ix
- source [dict get $::crystal::vfs b32_load]/cast/mem.ix
- source [dict get $::crystal::vfs b32_load]/cast/ghui.ix
- proc crystal::cast {resource_slate resource_level args} {
- variable resource_file [crystal::lidx $args 1]
- switch [info exist b32_gtx] { 0 { variable b32_vfs [crystal::lidx $args 0] } } ;# end switch :: info exist b32_vfs
- switch [info exist b32_vfs] { 1 { variable b32_gtx [crystal::lidx $args 0] } } ;# end switch :: info exist b32_vfs
- crystal::debug 0 $resource_file "resource_file"
- crystal::debug 1 $resource_slate "resource_slate"
- crystal::debug 1 $resource_level "esource_level"
- crystal::debug 0 $b32_vfs "b32_vfs"
- ;# Switch :: $b32_resource_slate
- ;# control the flow to the resource permission
- ;# case :: 00ff
- ;# cast file_open on $b32_resource (file)
- ;# case :: default
- ;# Fatal - Resource state not defined - exit
- switch $resource_slate {
- 00ff { switch -- $resource_level { 00 { crystal::cast::read_open ${b32_vfs}}
- 01 { crystal::cast::soul_create ${resource_file}}
- 02 { crystal::memory::close ${resource_slate}} } ;# end switch :: $b32_resource_level
- }
- 0001 { switch -- $resource_level { 00 { }
- 01 { crystal::ghui::construct }
- 02 { return ${b32_gtx} } } ;# end switch :: $b32_resource_level
- }
- default { crystal::debug 1 "FATAL" "invalid cast resource slate" ; exit }
- } ;# end switch :: $base32_action
- } ;# end proc :: crystal::cast
- proc crystal::cast::2Base {enc input} {
- ;# Everything that comes in b32_enc is what to be converted to
- ;# Switch :: $b32_enc
- ;# Switch to determine which encoding is the characters set in
- ;# Case: 16 - encode it to 16
- ;# Case: 32 - encode it to 32
- ;# Case: 64 - encode it to 64
- proc ::16 {input} { return [binary encode hex [encoding convertto utf-8 "${input}"]] } ;# end proc :: crystal::16
- proc ::32 {b32_input} { return ${b32_input} } ;# end proc :: crystal::32
- proc ::64 {input} { return [binary encode base64 [encoding convertto utf-8 "${input}"]] } ;# end proc :: crystal::64
- switch -- $enc {
- 16 { return [::16 ${input}] }
- 32 { return [::32 ${input}] }
- 64 { return [::64 ${input}] }
- } ;# end switch :: $b32_enc
- } ;# end proc :: crystal::cast::2Base
- proc crystal::cast::read_open {resource_file} {
- # Open the file. If this fails, the procedure stops here.
- set open_file [open [dict get ${::crystal::vfs} b32_load]/${resource_file} r]
- try {
- variable stream [read ${open_file}]
- variable b32_read_file ${stream} ;# assuming our file is in base32 for now
- variable b64_read_file [crystal::cast::2Base 64 ${b32_read_file}] ;# encode our crystal to base64
- variable b16_read_file [crystal::cast::2Base 16 ${b32_read_file}] ;# encode our crystal to base16
- } finally { close $open_file } ; # Runs whether reading succeeds or fails.
- dict append 6372797374616c 64 ${b64_read_file}
- dict append 6372797374616c 32 ${b32_read_file}
- dict append 6372797374616c 16 ${b16_read_file}
- return $6372797374616c ;# return crystal with all three based data streams
- } ;# end proc :: crystal::cast::file_open
- proc crystal::cast::soul_create {b32_resource_file} {
- crystal::cast::autoload [crystal::memory::create [dict get ${::crystal::vfs} b32_resource]/$b32_resource_file]
- } ;# end proc :: crystal::cast::file_open
- proc crystal::cast::autoload {ctx} {
- foreach b32_file [glob -nocomplain -directory [dict get ${::crystal::vfs} b32_load] */*.ix] {
- variable b32_module_name [file rootname [string range ${b32_file} [string length [dict get ${::crystal::vfs} b32_load]/] end]]
- lassign [split $b32_module_name /] b32_load_library b32_module_name
- switch -- ${b32_load_library} {
- cast {
- switch ${b32_module_name} { "cast" { crystal::debug 1 "skipping" "${b32_file}" }
- "mem" { crystal::debug 1 "skipping" "${b32_file}" }
- "procs" { crystal::debug 1 "skipping" "${b32_file}" }
- } ;#end switch :: $b32_module_name
- }
- default {
- crystal::debug 1 "----" "start $b32_load_library"
- crystal::debug 1 ${b32_load_library} "b32_load_library"
- crystal::debug 1 ${b32_module_name} "b32_module_name"
- crystal::debug 0 ${b32_load_library}/${b32_module_name}.ix "b32_load_library/b32_module_name.ix"
- crystal::debug 1 "----" "end $b32_load_library"
- crystal::memory insert ${ctx} ${b32_load_library} ${b32_module_name} [crystal::cast 00ff 00 ${b32_load_library}/${b32_module_name}.ix]
- uplevel #0 [dict get [crystal::memory::query single ${ctx} ${b32_load_library} ${b32_module_name}] 32]
- }
- } ;# end switch :: $b32_load_library
- } ;# end foreach :: $b32_file
- crystal::cast 00ff 02 ${ctx}
- } ;# end proc :: crystal::cast::autoload
- ====
- ;# gtx = our "ghui" interp
- variable gtx_01 [crystal::cast 0001 02 [crystal::ghui construct] [variable ctx [crystal::cast 00ff 01 $crystal::vfs system.soul]]]
- crystal::debug 1 [crystal::timedate 32] [crystal::timedate 16]
- variable gtx_02 [crystal::cast 0001 02 [crystal::ghui construct] [variable ctx [crystal::cast 00ff 01 $crystal::vfs tcl.file]]]
- crystal::debug 1 [crystal::timedate 32] [crystal::timedate 16]
- ====
- -> crystal.ix
- >? latched :: crystal_memory.so
- >? GHUI :: awake
- >? 0001 :: resource_slate
- >? 01 :: resource_level
- >? 00ff :: resource_slate
- >? 01 :: resource_level
- >? /forest/neoncrystal/crystal/resource/system.soul :: Double Dictionary construct. Fabulous. crystal0xef7a11f1aa0
- >? ---- :: start boot
- >? boot :: b32_load_library
- >? procedures :: b32_module_name
- >? ---- :: end boot
- >? 00ff :: resource_slate
- >? 00 :: resource_level
- >? skipping :: /forest/neoncrystal/crystal/system/load/cast/cast.ix
- >? skipping :: /forest/neoncrystal/crystal/system/load/cast/mem.ix
- >? skipping :: /forest/neoncrystal/crystal/system/load/cast/procs.ix
- >? ---- :: start dict
- >? dict :: b32_load_library
- >? hext :: b32_module_name
- >? ---- :: end dict
- >? 00ff :: resource_slate
- >? 00 :: resource_level
- >? ---- :: start math
- >? math :: b32_load_library
- >? hex :: b32_module_name
- >? ---- :: end math
- >? 00ff :: resource_slate
- >? 00 :: resource_level
- >? 00ff :: resource_slate
- >? 02 :: resource_level
- >? 0001 :: resource_slate
- >? 02 :: resource_level
- >? 2026/10/31 00:40:41 :: 323032362f31302f33312030303a34303a3431
- >? 0001 :: resource_slate
- >? 01 :: resource_level
- >? 00ff :: resource_slate
- >? 01 :: resource_level
- >? /forest/neoncrystal/crystal/resource/tcl.file :: Double Dictionary construct. Fabulous. crystal0xef7a11ccf40
- >? ---- :: start boot
- >? boot :: b32_load_library
- >? procedures :: b32_module_name
- >? ---- :: end boot
- >? 00ff :: resource_slate
- >? 00 :: resource_level
- >? skipping :: /forest/neoncrystal/crystal/system/load/cast/cast.ix
- >? skipping :: /forest/neoncrystal/crystal/system/load/cast/mem.ix
- >? skipping :: /forest/neoncrystal/crystal/system/load/cast/procs.ix
- >? ---- :: start dict
- >? dict :: b32_load_library
- >? hext :: b32_module_name
- >? ---- :: end dict
- >? 00ff :: resource_slate
- >? 00 :: resource_level
- >? ---- :: start math
- >? math :: b32_load_library
- >? hex :: b32_module_name
- >? ---- :: end math
- >? 00ff :: resource_slate
- >? 00 :: resource_level
- >? 00ff :: resource_slate
- >? 02 :: resource_level
- >? 0001 :: resource_slate
- >? 02 :: resource_level
- >? 2026/10/31 00:40:41 :: 323032362f31302f33312030303a34303a3431
- NeonCrystal © 2026
- Greetings, Tcl from within gtx_01
- NeonCrystal © 2026
- Greetings, Tcl from within gtx_02
Add a comment