Posted to tcl by mookie at Sat Oct 31 00:45:52 GMT 2026view raw

  1. namespace eval crystal { }
  2. namespace eval crystal::cast { }
  3.  
  4. namespace export {[a-z]*} {
  5. namespace ensemble create }
  6.  
  7. source [dict get $::crystal::vfs b32_load]/cast/procs.ix
  8. source [dict get $::crystal::vfs b32_load]/cast/mem.ix
  9. source [dict get $::crystal::vfs b32_load]/cast/ghui.ix
  10.  
  11. proc crystal::cast {resource_slate resource_level args} {
  12. variable resource_file [crystal::lidx $args 1]
  13. switch [info exist b32_gtx] { 0 { variable b32_vfs [crystal::lidx $args 0] } } ;# end switch :: info exist b32_vfs
  14. switch [info exist b32_vfs] { 1 { variable b32_gtx [crystal::lidx $args 0] } } ;# end switch :: info exist b32_vfs
  15.  
  16. crystal::debug 0 $resource_file "resource_file"
  17. crystal::debug 1 $resource_slate "resource_slate"
  18. crystal::debug 1 $resource_level "esource_level"
  19. crystal::debug 0 $b32_vfs "b32_vfs"
  20.  
  21. ;# Switch :: $b32_resource_slate
  22. ;# control the flow to the resource permission
  23. ;# case :: 00ff
  24. ;# cast file_open on $b32_resource (file)
  25. ;# case :: default
  26. ;# Fatal - Resource state not defined - exit
  27. switch $resource_slate {
  28. 00ff { switch -- $resource_level { 00 { crystal::cast::read_open ${b32_vfs}}
  29. 01 { crystal::cast::soul_create ${resource_file}}
  30. 02 { crystal::memory::close ${resource_slate}} } ;# end switch :: $b32_resource_level
  31. }
  32. 0001 { switch -- $resource_level { 00 { }
  33. 01 { crystal::ghui::construct }
  34. 02 { return ${b32_gtx} } } ;# end switch :: $b32_resource_level
  35. }
  36. default { crystal::debug 1 "FATAL" "invalid cast resource slate" ; exit }
  37. } ;# end switch :: $base32_action
  38. } ;# end proc :: crystal::cast
  39.  
  40. proc crystal::cast::2Base {enc input} {
  41. ;# Everything that comes in b32_enc is what to be converted to
  42. ;# Switch :: $b32_enc
  43. ;# Switch to determine which encoding is the characters set in
  44. ;# Case: 16 - encode it to 16
  45. ;# Case: 32 - encode it to 32
  46. ;# Case: 64 - encode it to 64
  47. proc ::16 {input} { return [binary encode hex [encoding convertto utf-8 "${input}"]] } ;# end proc :: crystal::16
  48. proc ::32 {b32_input} { return ${b32_input} } ;# end proc :: crystal::32
  49. proc ::64 {input} { return [binary encode base64 [encoding convertto utf-8 "${input}"]] } ;# end proc :: crystal::64
  50. switch -- $enc {
  51. 16 { return [::16 ${input}] }
  52. 32 { return [::32 ${input}] }
  53. 64 { return [::64 ${input}] }
  54. } ;# end switch :: $b32_enc
  55. } ;# end proc :: crystal::cast::2Base
  56.  
  57. proc crystal::cast::read_open {resource_file} {
  58. # Open the file. If this fails, the procedure stops here.
  59. set open_file [open [dict get ${::crystal::vfs} b32_load]/${resource_file} r]
  60. try {
  61. variable stream [read ${open_file}]
  62. variable b32_read_file ${stream} ;# assuming our file is in base32 for now
  63. variable b64_read_file [crystal::cast::2Base 64 ${b32_read_file}] ;# encode our crystal to base64
  64. variable b16_read_file [crystal::cast::2Base 16 ${b32_read_file}] ;# encode our crystal to base16
  65. } finally { close $open_file } ; # Runs whether reading succeeds or fails.
  66. dict append 6372797374616c 64 ${b64_read_file}
  67. dict append 6372797374616c 32 ${b32_read_file}
  68. dict append 6372797374616c 16 ${b16_read_file}
  69. return $6372797374616c ;# return crystal with all three based data streams
  70. } ;# end proc :: crystal::cast::file_open
  71.  
  72. proc crystal::cast::soul_create {b32_resource_file} {
  73. crystal::cast::autoload [crystal::memory::create [dict get ${::crystal::vfs} b32_resource]/$b32_resource_file]
  74. } ;# end proc :: crystal::cast::file_open
  75.  
  76. proc crystal::cast::autoload {ctx} {
  77. foreach b32_file [glob -nocomplain -directory [dict get ${::crystal::vfs} b32_load] */*.ix] {
  78. variable b32_module_name [file rootname [string range ${b32_file} [string length [dict get ${::crystal::vfs} b32_load]/] end]]
  79. lassign [split $b32_module_name /] b32_load_library b32_module_name
  80.  
  81. switch -- ${b32_load_library} {
  82. cast {
  83. switch ${b32_module_name} { "cast" { crystal::debug 1 "skipping" "${b32_file}" }
  84. "mem" { crystal::debug 1 "skipping" "${b32_file}" }
  85. "procs" { crystal::debug 1 "skipping" "${b32_file}" }
  86. } ;#end switch :: $b32_module_name
  87. }
  88. default {
  89. crystal::debug 1 "----" "start $b32_load_library"
  90. crystal::debug 1 ${b32_load_library} "b32_load_library"
  91. crystal::debug 1 ${b32_module_name} "b32_module_name"
  92. crystal::debug 0 ${b32_load_library}/${b32_module_name}.ix "b32_load_library/b32_module_name.ix"
  93. crystal::debug 1 "----" "end $b32_load_library"
  94.  
  95. crystal::memory insert ${ctx} ${b32_load_library} ${b32_module_name} [crystal::cast 00ff 00 ${b32_load_library}/${b32_module_name}.ix]
  96. uplevel #0 [dict get [crystal::memory::query single ${ctx} ${b32_load_library} ${b32_module_name}] 32]
  97. }
  98. } ;# end switch :: $b32_load_library
  99. } ;# end foreach :: $b32_file
  100. crystal::cast 00ff 02 ${ctx}
  101. } ;# end proc :: crystal::cast::autoload
  102.  
  103. ====
  104. ;# gtx = our "ghui" interp
  105. variable gtx_01 [crystal::cast 0001 02 [crystal::ghui construct] [variable ctx [crystal::cast 00ff 01 $crystal::vfs system.soul]]]
  106. crystal::debug 1 [crystal::timedate 32] [crystal::timedate 16]
  107.  
  108. variable gtx_02 [crystal::cast 0001 02 [crystal::ghui construct] [variable ctx [crystal::cast 00ff 01 $crystal::vfs tcl.file]]]
  109. crystal::debug 1 [crystal::timedate 32] [crystal::timedate 16]
  110. ====
  111.  
  112. -> crystal.ix
  113. >? latched :: crystal_memory.so
  114. >? GHUI :: awake
  115. >? 0001 :: resource_slate
  116. >? 01 :: resource_level
  117. >? 00ff :: resource_slate
  118. >? 01 :: resource_level
  119. >? /forest/neoncrystal/crystal/resource/system.soul :: Double Dictionary construct. Fabulous. crystal0xef7a11f1aa0
  120. >? ---- :: start boot
  121. >? boot :: b32_load_library
  122. >? procedures :: b32_module_name
  123. >? ---- :: end boot
  124. >? 00ff :: resource_slate
  125. >? 00 :: resource_level
  126. >? skipping :: /forest/neoncrystal/crystal/system/load/cast/cast.ix
  127. >? skipping :: /forest/neoncrystal/crystal/system/load/cast/mem.ix
  128. >? skipping :: /forest/neoncrystal/crystal/system/load/cast/procs.ix
  129. >? ---- :: start dict
  130. >? dict :: b32_load_library
  131. >? hext :: b32_module_name
  132. >? ---- :: end dict
  133. >? 00ff :: resource_slate
  134. >? 00 :: resource_level
  135. >? ---- :: start math
  136. >? math :: b32_load_library
  137. >? hex :: b32_module_name
  138. >? ---- :: end math
  139. >? 00ff :: resource_slate
  140. >? 00 :: resource_level
  141. >? 00ff :: resource_slate
  142. >? 02 :: resource_level
  143. >? 0001 :: resource_slate
  144. >? 02 :: resource_level
  145. >? 2026/10/31 00:40:41 :: 323032362f31302f33312030303a34303a3431
  146.  
  147. >? 0001 :: resource_slate
  148. >? 01 :: resource_level
  149. >? 00ff :: resource_slate
  150. >? 01 :: resource_level
  151. >? /forest/neoncrystal/crystal/resource/tcl.file :: Double Dictionary construct. Fabulous. crystal0xef7a11ccf40
  152. >? ---- :: start boot
  153. >? boot :: b32_load_library
  154. >? procedures :: b32_module_name
  155. >? ---- :: end boot
  156. >? 00ff :: resource_slate
  157. >? 00 :: resource_level
  158. >? skipping :: /forest/neoncrystal/crystal/system/load/cast/cast.ix
  159. >? skipping :: /forest/neoncrystal/crystal/system/load/cast/mem.ix
  160. >? skipping :: /forest/neoncrystal/crystal/system/load/cast/procs.ix
  161. >? ---- :: start dict
  162. >? dict :: b32_load_library
  163. >? hext :: b32_module_name
  164. >? ---- :: end dict
  165. >? 00ff :: resource_slate
  166. >? 00 :: resource_level
  167. >? ---- :: start math
  168. >? math :: b32_load_library
  169. >? hex :: b32_module_name
  170. >? ---- :: end math
  171. >? 00ff :: resource_slate
  172. >? 00 :: resource_level
  173. >? 00ff :: resource_slate
  174. >? 02 :: resource_level
  175. >? 0001 :: resource_slate
  176. >? 02 :: resource_level
  177. >? 2026/10/31 00:40:41 :: 323032362f31302f33312030303a34303a3431
  178.  
  179. NeonCrystal © 2026
  180. Greetings, Tcl from within gtx_01
  181.  
  182. NeonCrystal © 2026
  183. Greetings, Tcl from within gtx_02

Add a comment

Please note that this site uses the meta tags nofollow,noindex for all pages that contain comments.
Items are closed for new comments after 1 week