codecin 6.0.1__tar.gz → 6.2.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (247) hide show
  1. {codecin-6.0.1 → codecin-6.2.2}/CHANGELOG.md +176 -0
  2. {codecin-6.0.1/codecin.egg-info → codecin-6.2.2}/PKG-INFO +49 -1
  3. {codecin-6.0.1 → codecin-6.2.2}/README.md +48 -0
  4. {codecin-6.0.1 → codecin-6.2.2}/codecin/__init__.py +1 -1
  5. {codecin-6.0.1 → codecin-6.2.2}/codecin/cin.py +192 -6
  6. {codecin-6.0.1 → codecin-6.2.2}/codecin/cli.py +5 -0
  7. codecin-6.2.2/codecin/cvm.py +590 -0
  8. {codecin-6.0.1 → codecin-6.2.2}/codecin/isa.py +3 -0
  9. {codecin-6.0.1 → codecin-6.2.2}/codecin/lib/gui.cin +12 -0
  10. codecin-6.2.2/codecin/mkn.py +834 -0
  11. {codecin-6.0.1 → codecin-6.2.2}/codecin/native/compiler/codegen.go +3 -0
  12. {codecin-6.0.1 → codecin-6.2.2}/codecin/native/compiler/syscalls.go +2 -0
  13. {codecin-6.0.1 → codecin-6.2.2}/codecin/native/engine/gui.go +31 -0
  14. {codecin-6.0.1 → codecin-6.2.2}/codecin/native/engine/gui_stub.go +2 -0
  15. {codecin-6.0.1 → codecin-6.2.2}/codecin/native/engine/gui_windows.go +193 -15
  16. {codecin-6.0.1 → codecin-6.2.2}/codecin/native/engine/gui_x11.go +2 -0
  17. {codecin-6.0.1 → codecin-6.2.2}/codecin/native/engine/isa_gen.go +5 -1
  18. {codecin-6.0.1 → codecin-6.2.2}/codecin/native/engine/keyboard_windows_test.go +26 -0
  19. codecin-6.2.2/codecin/native/engine/lineedit.go +262 -0
  20. codecin-6.2.2/codecin/native/engine/lineedit_test.go +105 -0
  21. codecin-6.2.2/codecin/native/engine/lineint_unix.go +17 -0
  22. codecin-6.2.2/codecin/native/engine/lineint_windows.go +19 -0
  23. {codecin-6.0.1 → codecin-6.2.2}/codecin/native/engine/stdin.go +14 -8
  24. {codecin-6.0.1 → codecin-6.2.2}/codecin/native/engine/version_gen.go +1 -1
  25. codecin-6.2.2/codecin/native/engine/vkb_darwin.go +62 -0
  26. codecin-6.2.2/codecin/native/engine/vkb_linux.go +95 -0
  27. codecin-6.2.2/codecin/native/engine/vkb_stub.go +11 -0
  28. {codecin-6.0.1 → codecin-6.2.2}/codecin/native/engine/vm.go +23 -4
  29. codecin-6.2.2/codecin/packaging/__init__.py +46 -0
  30. codecin-6.2.2/codecin/packaging/archive.py +177 -0
  31. codecin-6.2.2/codecin/packaging/model.py +519 -0
  32. codecin-6.2.2/codecin/packaging/store.py +372 -0
  33. codecin-6.2.2/codecin/packaging/toml.py +541 -0
  34. codecin-6.2.2/codecin/packaging/vcs.py +206 -0
  35. codecin-6.2.2/codecin/pic.py +1396 -0
  36. codecin-6.2.2/codecin/pic_api.py +374 -0
  37. codecin-6.2.2/codecin/pic_login.py +519 -0
  38. codecin-6.2.2/codecin/pic_registry.py +386 -0
  39. codecin-6.2.2/codecin/toolkit.py +26 -0
  40. {codecin-6.0.1 → codecin-6.2.2/codecin.egg-info}/PKG-INFO +49 -1
  41. {codecin-6.0.1 → codecin-6.2.2}/codecin.egg-info/SOURCES.txt +27 -0
  42. codecin-6.2.2/codecin.egg-info/entry_points.txt +5 -0
  43. {codecin-6.0.1 → codecin-6.2.2}/pyproject.toml +3 -0
  44. codecin-6.2.2/tests/test_v620_cvm.py +79 -0
  45. codecin-6.2.2/tests/test_v620_import.py +80 -0
  46. codecin-6.2.2/tests/test_v620_mkn.py +118 -0
  47. codecin-6.2.2/tests/test_v620_packaging.py +142 -0
  48. codecin-6.2.2/tests/test_v620_pic.py +113 -0
  49. codecin-6.2.2/tests/test_v620_pic_git.py +63 -0
  50. codecin-6.2.2/tests/test_v620_pic_registry.py +470 -0
  51. codecin-6.0.1/codecin.egg-info/entry_points.txt +0 -2
  52. {codecin-6.0.1 → codecin-6.2.2}/LICENSE +0 -0
  53. {codecin-6.0.1 → codecin-6.2.2}/MANIFEST.in +0 -0
  54. {codecin-6.0.1 → codecin-6.2.2}/codecin/aot.py +0 -0
  55. {codecin-6.0.1 → codecin-6.2.2}/codecin/assembler.py +0 -0
  56. {codecin-6.0.1 → codecin-6.2.2}/codecin/config.py +0 -0
  57. {codecin-6.0.1 → codecin-6.2.2}/codecin/console.py +0 -0
  58. {codecin-6.0.1 → codecin-6.2.2}/codecin/cpu.py +0 -0
  59. {codecin-6.0.1 → codecin-6.2.2}/codecin/crom.py +0 -0
  60. {codecin-6.0.1 → codecin-6.2.2}/codecin/disasm.py +0 -0
  61. {codecin-6.0.1 → codecin-6.2.2}/codecin/environment.py +0 -0
  62. {codecin-6.0.1 → codecin-6.2.2}/codecin/errors.py +0 -0
  63. {codecin-6.0.1 → codecin-6.2.2}/codecin/lib/array.cin +0 -0
  64. {codecin-6.0.1 → codecin-6.2.2}/codecin/lib/bigint.cin +0 -0
  65. {codecin-6.0.1 → codecin-6.2.2}/codecin/lib/bits.cin +0 -0
  66. {codecin-6.0.1 → codecin-6.2.2}/codecin/lib/bitset.cin +0 -0
  67. {codecin-6.0.1 → codecin-6.2.2}/codecin/lib/codec.cin +0 -0
  68. {codecin-6.0.1 → codecin-6.2.2}/codecin/lib/combin.cin +0 -0
  69. {codecin-6.0.1 → codecin-6.2.2}/codecin/lib/conv.cin +0 -0
  70. {codecin-6.0.1 → codecin-6.2.2}/codecin/lib/cppstd.cin +0 -0
  71. {codecin-6.0.1 → codecin-6.2.2}/codecin/lib/cstd.cin +0 -0
  72. {codecin-6.0.1 → codecin-6.2.2}/codecin/lib/csv.cin +0 -0
  73. {codecin-6.0.1 → codecin-6.2.2}/codecin/lib/dp.cin +0 -0
  74. {codecin-6.0.1 → codecin-6.2.2}/codecin/lib/ffi.cin +0 -0
  75. {codecin-6.0.1 → codecin-6.2.2}/codecin/lib/fmt.cin +0 -0
  76. {codecin-6.0.1 → codecin-6.2.2}/codecin/lib/frac.cin +0 -0
  77. {codecin-6.0.1 → codecin-6.2.2}/codecin/lib/gostd.cin +0 -0
  78. {codecin-6.0.1 → codecin-6.2.2}/codecin/lib/graph.cin +0 -0
  79. {codecin-6.0.1 → codecin-6.2.2}/codecin/lib/hash.cin +0 -0
  80. {codecin-6.0.1 → codecin-6.2.2}/codecin/lib/heap.cin +0 -0
  81. {codecin-6.0.1 → codecin-6.2.2}/codecin/lib/io.cin +0 -0
  82. {codecin-6.0.1 → codecin-6.2.2}/codecin/lib/json.cin +0 -0
  83. {codecin-6.0.1 → codecin-6.2.2}/codecin/lib/key.cin +0 -0
  84. {codecin-6.0.1 → codecin-6.2.2}/codecin/lib/math.cin +0 -0
  85. {codecin-6.0.1 → codecin-6.2.2}/codecin/lib/matrix.cin +0 -0
  86. {codecin-6.0.1 → codecin-6.2.2}/codecin/lib/net.cin +0 -0
  87. {codecin-6.0.1 → codecin-6.2.2}/codecin/lib/path.cin +0 -0
  88. {codecin-6.0.1 → codecin-6.2.2}/codecin/lib/queue.cin +0 -0
  89. {codecin-6.0.1 → codecin-6.2.2}/codecin/lib/rand.cin +0 -0
  90. {codecin-6.0.1 → codecin-6.2.2}/codecin/lib/set.cin +0 -0
  91. {codecin-6.0.1 → codecin-6.2.2}/codecin/lib/sort.cin +0 -0
  92. {codecin-6.0.1 → codecin-6.2.2}/codecin/lib/stat.cin +0 -0
  93. {codecin-6.0.1 → codecin-6.2.2}/codecin/lib/str.cin +0 -0
  94. {codecin-6.0.1 → codecin-6.2.2}/codecin/lib/termux.cin +0 -0
  95. {codecin-6.0.1 → codecin-6.2.2}/codecin/lib/test.cin +0 -0
  96. {codecin-6.0.1 → codecin-6.2.2}/codecin/lib/text.cin +0 -0
  97. {codecin-6.0.1 → codecin-6.2.2}/codecin/lib/time.cin +0 -0
  98. {codecin-6.0.1 → codecin-6.2.2}/codecin/lib/token.cin +0 -0
  99. {codecin-6.0.1 → codecin-6.2.2}/codecin/lib/tree.cin +0 -0
  100. {codecin-6.0.1 → codecin-6.2.2}/codecin/lib/unionfind.cin +0 -0
  101. {codecin-6.0.1 → codecin-6.2.2}/codecin/lib/validate.cin +0 -0
  102. {codecin-6.0.1 → codecin-6.2.2}/codecin/lib/vec.cin +0 -0
  103. {codecin-6.0.1 → codecin-6.2.2}/codecin/logger.py +0 -0
  104. {codecin-6.0.1 → codecin-6.2.2}/codecin/memory.py +0 -0
  105. {codecin-6.0.1 → codecin-6.2.2}/codecin/native/aot/aot.go +0 -0
  106. {codecin-6.0.1 → codecin-6.2.2}/codecin/native/aot/stub_main.go.txt +0 -0
  107. {codecin-6.0.1 → codecin-6.2.2}/codecin/native/build.ps1 +0 -0
  108. {codecin-6.0.1 → codecin-6.2.2}/codecin/native/build.sh +0 -0
  109. {codecin-6.0.1 → codecin-6.2.2}/codecin/native/compiler/compile_test.go +0 -0
  110. {codecin-6.0.1 → codecin-6.2.2}/codecin/native/compiler/parser.go +0 -0
  111. {codecin-6.0.1 → codecin-6.2.2}/codecin/native/compiler/tokenizer.go +0 -0
  112. {codecin-6.0.1 → codecin-6.2.2}/codecin/native/compiler/types.go +0 -0
  113. {codecin-6.0.1 → codecin-6.2.2}/codecin/native/engine/args.go +0 -0
  114. {codecin-6.0.1 → codecin-6.2.2}/codecin/native/engine/audio.go +0 -0
  115. {codecin-6.0.1 → codecin-6.2.2}/codecin/native/engine/audio_other.go +0 -0
  116. {codecin-6.0.1 → codecin-6.2.2}/codecin/native/engine/audio_test.go +0 -0
  117. {codecin-6.0.1 → codecin-6.2.2}/codecin/native/engine/audio_windows.go +0 -0
  118. {codecin-6.0.1 → codecin-6.2.2}/codecin/native/engine/canvas.go +0 -0
  119. {codecin-6.0.1 → codecin-6.2.2}/codecin/native/engine/console_other.go +0 -0
  120. {codecin-6.0.1 → codecin-6.2.2}/codecin/native/engine/console_windows.go +0 -0
  121. {codecin-6.0.1 → codecin-6.2.2}/codecin/native/engine/crom.go +0 -0
  122. {codecin-6.0.1 → codecin-6.2.2}/codecin/native/engine/encode.go +0 -0
  123. {codecin-6.0.1 → codecin-6.2.2}/codecin/native/engine/engine_test.go +0 -0
  124. {codecin-6.0.1 → codecin-6.2.2}/codecin/native/engine/ffi_nocgo.go +0 -0
  125. {codecin-6.0.1 → codecin-6.2.2}/codecin/native/engine/ffi_registry.go +0 -0
  126. {codecin-6.0.1 → codecin-6.2.2}/codecin/native/engine/ffi_unix.go +0 -0
  127. {codecin-6.0.1 → codecin-6.2.2}/codecin/native/engine/ffi_windows.go +0 -0
  128. {codecin-6.0.1 → codecin-6.2.2}/codecin/native/engine/gui_test.go +0 -0
  129. {codecin-6.0.1 → codecin-6.2.2}/codecin/native/engine/host_test.go +0 -0
  130. {codecin-6.0.1 → codecin-6.2.2}/codecin/native/engine/hostcrypto.go +0 -0
  131. {codecin-6.0.1 → codecin-6.2.2}/codecin/native/engine/hostdesktop.go +0 -0
  132. {codecin-6.0.1 → codecin-6.2.2}/codecin/native/engine/hostnet.go +0 -0
  133. {codecin-6.0.1 → codecin-6.2.2}/codecin/native/engine/keyboard.go +0 -0
  134. {codecin-6.0.1 → codecin-6.2.2}/codecin/native/engine/keyboard_other.go +0 -0
  135. {codecin-6.0.1 → codecin-6.2.2}/codecin/native/engine/keyboard_stub.go +0 -0
  136. {codecin-6.0.1 → codecin-6.2.2}/codecin/native/engine/keyboard_termios_darwin.go +0 -0
  137. {codecin-6.0.1 → codecin-6.2.2}/codecin/native/engine/keyboard_termios_linux.go +0 -0
  138. {codecin-6.0.1 → codecin-6.2.2}/codecin/native/engine/keyboard_test.go +0 -0
  139. {codecin-6.0.1 → codecin-6.2.2}/codecin/native/engine/keyboard_windows.go +0 -0
  140. {codecin-6.0.1 → codecin-6.2.2}/codecin/native/engine/mem_other.go +0 -0
  141. {codecin-6.0.1 → codecin-6.2.2}/codecin/native/engine/mem_windows.go +0 -0
  142. {codecin-6.0.1 → codecin-6.2.2}/codecin/native/engine/native.go +0 -0
  143. {codecin-6.0.1 → codecin-6.2.2}/codecin/native/engine/netsock.go +0 -0
  144. {codecin-6.0.1 → codecin-6.2.2}/codecin/native/engine/ops_ext.go +0 -0
  145. {codecin-6.0.1 → codecin-6.2.2}/codecin/native/engine/stdin_other.go +0 -0
  146. {codecin-6.0.1 → codecin-6.2.2}/codecin/native/engine/stdin_windows.go +0 -0
  147. {codecin-6.0.1 → codecin-6.2.2}/codecin/native/engine/system.go +0 -0
  148. {codecin-6.0.1 → codecin-6.2.2}/codecin/native/engine/termux.go +0 -0
  149. {codecin-6.0.1 → codecin-6.2.2}/codecin/native/go.mod +0 -0
  150. {codecin-6.0.1 → codecin-6.2.2}/codecin/native/ir/ir.go +0 -0
  151. {codecin-6.0.1 → codecin-6.2.2}/codecin/native/main.go +0 -0
  152. {codecin-6.0.1 → codecin-6.2.2}/codecin/native.py +0 -0
  153. {codecin-6.0.1 → codecin-6.2.2}/codecin/native_codegen.py +0 -0
  154. {codecin-6.0.1 → codecin-6.2.2}/codecin/object.py +0 -0
  155. {codecin-6.0.1 → codecin-6.2.2}/codecin/optimizer.py +0 -0
  156. {codecin-6.0.1 → codecin-6.2.2}/codecin/registers.py +0 -0
  157. {codecin-6.0.1 → codecin-6.2.2}/codecin/stats.py +0 -0
  158. {codecin-6.0.1 → codecin-6.2.2}/codecin/stdlib.py +0 -0
  159. {codecin-6.0.1 → codecin-6.2.2}/codecin/version.py +0 -0
  160. {codecin-6.0.1 → codecin-6.2.2}/codecin.egg-info/dependency_links.txt +0 -0
  161. {codecin-6.0.1 → codecin-6.2.2}/codecin.egg-info/requires.txt +0 -0
  162. {codecin-6.0.1 → codecin-6.2.2}/codecin.egg-info/top_level.txt +0 -0
  163. {codecin-6.0.1 → codecin-6.2.2}/examples/args_demo.cin +0 -0
  164. {codecin-6.0.1 → codecin-6.2.2}/examples/asm_constants.asm +0 -0
  165. {codecin-6.0.1 → codecin-6.2.2}/examples/bitwise_builtins.cin +0 -0
  166. {codecin-6.0.1 → codecin-6.2.2}/examples/control_flow.cin +0 -0
  167. {codecin-6.0.1 → codecin-6.2.2}/examples/enum_range_for.cin +0 -0
  168. {codecin-6.0.1 → codecin-6.2.2}/examples/gui_demo.cin +0 -0
  169. {codecin-6.0.1 → codecin-6.2.2}/examples/literals_types.cin +0 -0
  170. {codecin-6.0.1 → codecin-6.2.2}/examples/local_audio.cin +0 -0
  171. {codecin-6.0.1 → codecin-6.2.2}/examples/modules_demo.cin +0 -0
  172. {codecin-6.0.1 → codecin-6.2.2}/examples/stdlib_demo.cin +0 -0
  173. {codecin-6.0.1 → codecin-6.2.2}/examples/system_interaction.cin +0 -0
  174. {codecin-6.0.1 → codecin-6.2.2}/misc/vim/ftdetect/codecin.vim +0 -0
  175. {codecin-6.0.1 → codecin-6.2.2}/misc/vim/syntax/cin.vim +0 -0
  176. {codecin-6.0.1 → codecin-6.2.2}/misc/vim/syntax/codecinasm.vim +0 -0
  177. {codecin-6.0.1 → codecin-6.2.2}/misc/vscode-cin/.vscodeignore +0 -0
  178. {codecin-6.0.1 → codecin-6.2.2}/misc/vscode-cin/README.md +0 -0
  179. {codecin-6.0.1 → codecin-6.2.2}/misc/vscode-cin/build.bat +0 -0
  180. {codecin-6.0.1 → codecin-6.2.2}/misc/vscode-cin/language-configuration.json +0 -0
  181. {codecin-6.0.1 → codecin-6.2.2}/misc/vscode-cin/package.json +0 -0
  182. {codecin-6.0.1 → codecin-6.2.2}/misc/vscode-cin/snippets/cin.json +0 -0
  183. {codecin-6.0.1 → codecin-6.2.2}/misc/vscode-cin/syntaxes/cin.tmLanguage.json +0 -0
  184. {codecin-6.0.1 → codecin-6.2.2}/script/bump_version.py +0 -0
  185. {codecin-6.0.1 → codecin-6.2.2}/script/check_paths.py +0 -0
  186. {codecin-6.0.1 → codecin-6.2.2}/script/gen_isa_docs.py +0 -0
  187. {codecin-6.0.1 → codecin-6.2.2}/script/gen_native_isa.py +0 -0
  188. {codecin-6.0.1 → codecin-6.2.2}/setup.cfg +0 -0
  189. {codecin-6.0.1 → codecin-6.2.2}/setup.py +0 -0
  190. {codecin-6.0.1 → codecin-6.2.2}/tests/test_aggregate_and_const.py +0 -0
  191. {codecin-6.0.1 → codecin-6.2.2}/tests/test_all_libs_together.py +0 -0
  192. {codecin-6.0.1 → codecin-6.2.2}/tests/test_aot.py +0 -0
  193. {codecin-6.0.1 → codecin-6.2.2}/tests/test_assembler_ext.py +0 -0
  194. {codecin-6.0.1 → codecin-6.2.2}/tests/test_bin_compat.py +0 -0
  195. {codecin-6.0.1 → codecin-6.2.2}/tests/test_cin_host.py +0 -0
  196. {codecin-6.0.1 → codecin-6.2.2}/tests/test_cin_host_ext.py +0 -0
  197. {codecin-6.0.1 → codecin-6.2.2}/tests/test_cin_new_features.py +0 -0
  198. {codecin-6.0.1 → codecin-6.2.2}/tests/test_cin_syntax.py +0 -0
  199. {codecin-6.0.1 → codecin-6.2.2}/tests/test_cin_syntax_ext.py +0 -0
  200. {codecin-6.0.1 → codecin-6.2.2}/tests/test_cin_system.py +0 -0
  201. {codecin-6.0.1 → codecin-6.2.2}/tests/test_cli.py +0 -0
  202. {codecin-6.0.1 → codecin-6.2.2}/tests/test_compiler_errors.py +0 -0
  203. {codecin-6.0.1 → codecin-6.2.2}/tests/test_environment.py +0 -0
  204. {codecin-6.0.1 → codecin-6.2.2}/tests/test_examples.py +0 -0
  205. {codecin-6.0.1 → codecin-6.2.2}/tests/test_features_ab.py +0 -0
  206. {codecin-6.0.1 → codecin-6.2.2}/tests/test_features_import.py +0 -0
  207. {codecin-6.0.1 → codecin-6.2.2}/tests/test_features_importloc.py +0 -0
  208. {codecin-6.0.1 → codecin-6.2.2}/tests/test_ffi_net.py +0 -0
  209. {codecin-6.0.1 → codecin-6.2.2}/tests/test_gui.py +0 -0
  210. {codecin-6.0.1 → codecin-6.2.2}/tests/test_index_subscript_type.py +0 -0
  211. {codecin-6.0.1 → codecin-6.2.2}/tests/test_isa_single_source.py +0 -0
  212. {codecin-6.0.1 → codecin-6.2.2}/tests/test_issue_regress.py +0 -0
  213. {codecin-6.0.1 → codecin-6.2.2}/tests/test_keyboard.py +0 -0
  214. {codecin-6.0.1 → codecin-6.2.2}/tests/test_lib_bigint.py +0 -0
  215. {codecin-6.0.1 → codecin-6.2.2}/tests/test_lib_bitset.py +0 -0
  216. {codecin-6.0.1 → codecin-6.2.2}/tests/test_lib_codec.py +0 -0
  217. {codecin-6.0.1 → codecin-6.2.2}/tests/test_lib_combin.py +0 -0
  218. {codecin-6.0.1 → codecin-6.2.2}/tests/test_lib_compat.py +0 -0
  219. {codecin-6.0.1 → codecin-6.2.2}/tests/test_lib_csv.py +0 -0
  220. {codecin-6.0.1 → codecin-6.2.2}/tests/test_lib_dp.py +0 -0
  221. {codecin-6.0.1 → codecin-6.2.2}/tests/test_lib_fmt.py +0 -0
  222. {codecin-6.0.1 → codecin-6.2.2}/tests/test_lib_frac.py +0 -0
  223. {codecin-6.0.1 → codecin-6.2.2}/tests/test_lib_graph.py +0 -0
  224. {codecin-6.0.1 → codecin-6.2.2}/tests/test_lib_heap.py +0 -0
  225. {codecin-6.0.1 → codecin-6.2.2}/tests/test_lib_path.py +0 -0
  226. {codecin-6.0.1 → codecin-6.2.2}/tests/test_lib_set.py +0 -0
  227. {codecin-6.0.1 → codecin-6.2.2}/tests/test_lib_text.py +0 -0
  228. {codecin-6.0.1 → codecin-6.2.2}/tests/test_lib_token.py +0 -0
  229. {codecin-6.0.1 → codecin-6.2.2}/tests/test_lib_tree.py +0 -0
  230. {codecin-6.0.1 → codecin-6.2.2}/tests/test_lib_unionfind.py +0 -0
  231. {codecin-6.0.1 → codecin-6.2.2}/tests/test_libs.py +0 -0
  232. {codecin-6.0.1 → codecin-6.2.2}/tests/test_libs_ext.py +0 -0
  233. {codecin-6.0.1 → codecin-6.2.2}/tests/test_literals_and_bom.py +0 -0
  234. {codecin-6.0.1 → codecin-6.2.2}/tests/test_native_codegen.py +0 -0
  235. {codecin-6.0.1 → codecin-6.2.2}/tests/test_native_hardening.py +0 -0
  236. {codecin-6.0.1 → codecin-6.2.2}/tests/test_native_lib_lookup.py +0 -0
  237. {codecin-6.0.1 → codecin-6.2.2}/tests/test_nested_subscript_codegen.py +0 -0
  238. {codecin-6.0.1 → codecin-6.2.2}/tests/test_no_go_cli.py +0 -0
  239. {codecin-6.0.1 → codecin-6.2.2}/tests/test_object_link.py +0 -0
  240. {codecin-6.0.1 → codecin-6.2.2}/tests/test_p0_fixes.py +0 -0
  241. {codecin-6.0.1 → codecin-6.2.2}/tests/test_packaging.py +0 -0
  242. {codecin-6.0.1 → codecin-6.2.2}/tests/test_paths_consistency.py +0 -0
  243. {codecin-6.0.1 → codecin-6.2.2}/tests/test_sparse_memory.py +0 -0
  244. {codecin-6.0.1 → codecin-6.2.2}/tests/test_struct_value_semantics.py +0 -0
  245. {codecin-6.0.1 → codecin-6.2.2}/tests/test_switch_semantics.py +0 -0
  246. {codecin-6.0.1 → codecin-6.2.2}/tests/test_version.py +0 -0
  247. {codecin-6.0.1 → codecin-6.2.2}/tests/test_workflows.py +0 -0
@@ -5,6 +5,182 @@
5
5
 
6
6
  ---
7
7
 
8
+ ## [6.2.2] - 2026-10-24
9
+
10
+ 一次以「注册服务与输入设备」为主题的小版本:`registry` 服务端由 Go 迁移到
11
+ Python;CIN 的键盘监听与查询输入(`input` / `input_str`)统一为同一套按键
12
+ 事件监听,行输入改由引擎自行编辑;虚拟键盘支持扩展为 Windows / Linux /
13
+ macOS 全平台;修复 `pic publish` 因 Cdifit 认证接口调用方式错误而返回 502
14
+ 的问题。
15
+
16
+ ### 新增 (Added)
17
+
18
+ #### 屏幕/触摸键盘 (虚拟键盘, 全平台)
19
+
20
+ - 新增内建 `vkb_show()` / `vkb_hide()`(SYS 158/159)与标准库包装
21
+ `g_vkb_show()` / `g_vkb_hide()`:弹出/收起当前图形会话的屏幕键盘,
22
+ 成功返回 `0`,不可用返回 `-1`。
23
+ - **Windows**:经 WinRT `IInputPaneInterop` → `IInputPane2::TryShow/TryHide`
24
+ 为顶层窗口弹出/收起系统触摸键盘 (TabTip / 输入体验)。绑定窗口优先
25
+ GUI 窗口;终端 raw 模式绑定可见的控制台窗口,ConPTY (Windows Terminal)
26
+ 或无可控制台时退回前台窗口;GUI 窗口关闭 / 程序退出时自动收起键盘。
27
+ - **Linux**:按 `onboard` → `matchbox-keyboard` → `xvkbd` 顺序探测并启动
28
+ 屏幕键盘;收起时结束本进程启动的实例,并对桌面常驻实例兜底执行
29
+ `onboard -x` / `pkill`。无 `DISPLAY` / `WAYLAND_DISPLAY` 或均未安装时
30
+ 返回 `-1`,程序退出时清理自启进程。
31
+ - **macOS**:以 App 方式打开系统「辅助功能键盘」(Accessibility Keyboard),
32
+ 收起时结束对应进程;系统路径不存在或未启用时返回 `-1`。
33
+ - 键盘监听补全虚拟键盘/输入法输入通道:Windows 窗口过程新增 `WM_UNICHAR`
34
+ (含 `UNICODE_NOCHAR` 能力探测) 与 `WM_IME_CHAR`,与既有
35
+ `WM_KEYDOWN`(VK_PACKET) / `WM_CHAR` 共用同一按键队列,`get_key` /
36
+ `key_wait` 无需区分按键来源;支持代理对与 emoji。
37
+ - 终端侧确认 `VK_PACKET + UnicodeChar` (`KEYEVENTF_UNICODE` 注入) 按字符
38
+ 入队,并补充对应回归测试。
39
+
40
+ #### 统一的交互式行输入 (查询输入)
41
+
42
+ - `input()` / `input_str()`(`IN` 指令 / SYS 131)在真实终端与 GUI 窗口中
43
+ 改由引擎的 **raw 键码队列** 直接读取,与 `get_key` / `key_wait` 使用同一
44
+ 套事件监听:不再临时把终端切回行规程(Windows `ReadConsoleW` / Unix
45
+ canonical 模式),也不再依赖操作系统自带行编辑。
46
+ - 内置跨平台行编辑器:字符输入(UTF-8 / 代理对 / emoji)、退格、Delete、
47
+ 左右方向键、Home/End、Ctrl+A/E/U/K/W、Ctrl+左右(按词移动)、Enter;
48
+ `Ctrl+D` 空行为 EOF,`Ctrl+C` 恢复终端后按 SIGINT / CTRL_C_EVENT 中断。
49
+ Windows 控制台(已开启 VT 输出)与 Unix 终端共用同一套 ANSI 重绘实现,
50
+ CJK 等宽字符按 2 列计算光标。
51
+ - GUI 窗口打开时,窗口过程注入的按键(含虚拟键盘/输入法)直接作为查询
52
+ 输入来源;窗口关闭后 `input()` 立即按 EOF 返回,不再永久阻塞。
53
+ - 无真实终端且无 GUI 窗口(管道 / 重定向 / 测试捕获)时保持原有字节流
54
+ 读取路径,输出字节与旧版本完全一致。
55
+
56
+ ### 变更 (Changed)
57
+
58
+ - 交互式终端上首次执行 `input()` / `input_str()` 时,与键盘监听一样切换为
59
+ **直写输出**:提示与随后的 `print` 立即落到标准输出,不再等程序结束一次
60
+ 性回传;管道 / 重定向 / 测试捕获仍保持纯缓冲语义。
61
+ - **`registry` 服务端由 Go 迁移为 Python**:仅使用标准库 `http.server`
62
+ (`ThreadingHTTPServer`,不依赖 Flask),终端输出与日志由 `rich` 渲染;
63
+ 对外 HTTP API、存储布局与校验规则保持不变,默认监听端口为 `18080`,
64
+ Dockerfile / nginx / systemd 服务文件同步更新。
65
+ - 服务端测试由 Go 改为 `registry/test_server.py`(pytest);部署方式更新为
66
+ Python 3.10+ 虚拟环境 + `requirements.txt`,文档同步改写。
67
+
68
+ ### 修复 (Fixed)
69
+
70
+ - 修复 `pic publish` 提交时返回 **502**:registry 调用 Cdifit 用户信息接口
71
+ 误用了 `POST /api/v4/session/oauth/userinfo`(实际为 `GET`,POST 得到
72
+ `404 page not found`,被服务端包装成 `502 auth_unavailable`)。
73
+ - 修复无效/过期 Token 被误报为 502:Cdifit 以 `HTTP 200 + code=401` 返回
74
+ 鉴权失败,服务端现将其映射为客户端 `401`;`pic_api.userinfo()` 同步改为
75
+ `GET`,并让 `code=401/403` 触发 Token 刷新,而非作为未知状态码上报。
76
+ - 修复 SYS 号 158/159 被 `syscallSupported` 上限拦截,导致 `vkb_show` /
77
+ `vkb_hide` 报 `unsupported SYS call id`。
78
+ - 修正 `registry/README.md` 中 Docker 端口映射为 `18080:18080`。
79
+
80
+ ---
81
+
82
+ ## [6.2.0] - 2026-10-23
83
+
84
+ 一次以「工具链生态」为主题的发布:新增 **mkn**(Maven 风格构建)、**pic**
85
+ (pip 风格包管理,package.codecin.org.cn 中央注册/分发 + Cdifit 浏览器登录)
86
+ 与 **cvm**(JVM 风格虚拟机/模块运行时),三者共享清单、依赖解析与可复现归档格式;
87
+ CIN 语言与 UCBC 指令集不变。
88
+
89
+ ### 新增 (Added)
90
+
91
+ #### mkn:项目构建与依赖 (Maven 风格)
92
+
93
+ - 新增 `codecin/mkn.py` 与 `mkn` 命令:`new` / `init` / `build`(=`compile`) /
94
+ `run` / `test` / `package` / `install` / `deploy` / `add` / `tree` /
95
+ `verify` / `clean` 完整生命周期。
96
+ - `mkn.toml`(`[project]` / `[build]` / `[dependencies]`):标准目录
97
+ `src/main.cin`、`src/test/**`、`target/`;依赖支持版本约束、Git 仓库与本地路径。
98
+ - 依赖统一解析到项目 `pic_modules/`(`mkn` 复用 `pic` 的安装实现),并写入
99
+ `pic.lock`;本地仓库为 `$MKN_HOME/repository/<name>/<version>`。
100
+ - 自动区分应用/库:入口及 import 闭包中没有 `function main` 时,`mkn build`
101
+ 产出可重定位 `.co` 对象而不是误报缺少 `main`。
102
+ - `mkn package` 生成确定性 `.mkn` 归档(含自动生成的 `pic.toml`、源码、
103
+ `target/*.bin|.co` 与 `META-INF/SHA256SUMS`)。
104
+
105
+ #### pic:中央注册/分发 + 浏览器登录 (pip 风格)
106
+
107
+ - 新增 `codecin/pic.py`、`codecin/pic_api.py`、`codecin/pic_login.py`、
108
+ `codecin/pic_registry.py` 与 `pic` 命令:`login` / `logout` / `whoami` /
109
+ `init` / `build` / `publish` / `install` / `uninstall` / `list` / `show` /
110
+ `freeze` / `search` / `registry` / `doctor`。
111
+ - **独立中央服务器 `package.codecin.org.cn`**:新增 `registry/` Go 服务,
112
+ 提供包记录、版本列表、`.cinpkg` 制品上传/下载、yank、搜索与健康检查;
113
+ Cdifit (`https://www.cdifit.cn`) 仅用于登录/Token 校验,不再存储包数据。
114
+ - **首次使用登录**:`pic login` 在 `127.0.0.1` 随机端口启动临时 Web 服务并
115
+ 打开浏览器;登录页使用相对布局(flex + `min(92vw, 26rem)`,无绝对定位),
116
+ 支持密码与 2FA;令牌写入 `$PIC_HOME/auth.json` (0600),服务随后关闭。
117
+ 无 `auth.json` 时首次运行任意 `pic` 命令会自动进入登录流程;`PIC_OFFLINE=1`
118
+ 可离线绕过。
119
+ - **登录安全**:只绑定 loopback;同源 `Origin` + 随机 CSRF 校验;
120
+ `Cache-Control: no-store` / `X-Frame-Options: DENY`;密码不落盘、不写日志。
121
+ - **发布**:`pic publish --repo <git-url> --name <name>` 校验清单、生成
122
+ `.cinpkg`、创建 `v<version>` 标签,向中央服务器提交元数据并上传制品;
123
+ `--push` 推送标签,`--no-tag` 改用 Git 提交记录。
124
+ - **按名称安装**:从中央记录选版本 → 优先下载 `.cinpkg` 并校验 SHA-256,
125
+ 否则回退 Git 拉取 → 重算源码/清单摘要与 `rev` 校验;任一不匹配则删除并拒绝。
126
+ 仍然支持 `name@version`、`git+URL@ref`、本地路径、`.cinpkg`、`--project`
127
+ 与 `-e/--editable`。
128
+ - **详细输出**:`pic publish` 输出 8 步(认证/清单/Git/构建/标签/本地缓存/
129
+ 中央注册/完成),`pic install` 输出解析/锁定/路径/来源/提交/入口/import 提示;
130
+ `search`/`registry list` 显示服务器与结果数。
131
+ - **本地回退**:`PIC_OFFLINE=1` 或 `config.toml` 的 `offline=true` 时使用
132
+ `registry.json` 本地注册表;`pic registry add/remove` 保留为本地回退。
133
+ - 安装存储 `$PIC_HOME`(默认 `~/.pic`):`auth.json`、`config.toml`、
134
+ 带自愈能力的 `index.json`、`packages/<name>/<version>/`、`cache/git/` 与
135
+ `cache/artifacts/`;归档安装前校验 `META-INF/SHA256SUMS`,解包拒绝绝对路径、
136
+ 盘符、`..` 与符号链接。
137
+
138
+ #### CVM:虚拟机与 `.cvm` 模块 (JVM 风格)
139
+
140
+ - 新增 `codecin/cvm.py` 与 `cvm` 命令:`build` / `run` / `inspect` /
141
+ `verify` / `install` / `which` / `list` / `env`;对外运行时概念为 **CVM**,
142
+ `CPU` 仅保留为内部执行核。
143
+ - `.cvm` 模块(zip):`CVM-INF/MANIFEST.TOML` + `code/program.bin` (BIN v3) +
144
+ `META-INF/SHA256SUMS`;清单记录格式版本、引擎、ABI、模块名/版本与构建信息。
145
+ - 模块路径类似 `CLASSPATH`:`CVM_MODULE_PATH` + `$CVM_HOME/modules`;
146
+ `cvm install` / `which` 支持按名称解析模块。
147
+ - 支持从 `.cin/.asm/.pl/.bin` 或含 `mkn.toml` 的项目构建模块;校验和/字节码
148
+ magic 任一不匹配都会在装载阶段失败。
149
+
150
+ #### 包导入与共享基础设施
151
+
152
+ - CIN `import` 新增包解析:`import "hello"` 导入包入口,
153
+ `import "hello/util.cin"` 导入包内文件;搜索顺序为
154
+ 相对路径 → 内置标准库 → 项目 `pic_modules/`/`.mkn/deps`/`.pic/packages` →
155
+ `CIN_PATH` → 全局 `$PIC_HOME/packages/<name>/<current>`。
156
+ - 新增 `codecin/packaging/`:零依赖 TOML 读写(兼容 Python 3.8)、清单与语义化
157
+ 版本约束、包存储、Git 封装、确定性 zip/安全解包/校验和。
158
+ - 新增 `codecin/toolkit.py`:工具 CLI 的 UTF-8 标准输出初始化。
159
+ - 新增 console scripts:`mkn = codecin.mkn:main`、`pic = codecin.pic:main`、
160
+ `cvm = codecin.cvm:main`;`codecin --help` 增加工具链提示。
161
+
162
+ ### 变更 (Changed)
163
+
164
+ - 版本号提升至 **6.2.0**(`codecin/__init__.py` 单一真源,
165
+ `codecin/native/engine/version_gen.go` 同步)。
166
+ - 裸名字 import 仍**优先命中内置标准库**(如 `import "math.cin"`),避免既有程序
167
+ 被同名第三方包劫持;第三方包推荐使用无 `.cin` 后缀的包名形式。
168
+ - `pic` 首次运行(除 `login`/`logout`/`doctor`)要求登录 Cdifit;无 `auth.json`
169
+ 时自动打开临时本地登录页。离线开发/CI 使用 `PIC_OFFLINE=1` 或
170
+ `pic --offline ...` 保持旧行为;`mkn` 按名称解析依赖同样走该登录。
171
+ - `mkn`/`pic`/`cvm` 的错误统一为 `prog: error: ...` 并返回退出码 1,不打印
172
+ Python traceback;`--help`/`--version` 退出码 0。
173
+
174
+ ### 兼容性
175
+
176
+ - 现有 `codecin <program>` 参数、`.cin/.pl/.asm/.bin/.crom/.co/.colib` 格式、
177
+ ABI v2、BIN v3、CROM v4 全部不变;`tests/test_features_import.py` 的原有用例
178
+ 保持通过。
179
+ - 原生库版本自报仍为旧值时不影响执行;`codecin --build-info` 会提示不一致,
180
+ 重建原生库后即可一致。
181
+
182
+ ---
183
+
8
184
  ## [6.0.1] - 2026-10-18
9
185
 
10
186
  ### 修复 (Fixed)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: codecin
3
- Version: 6.0.1
3
+ Version: 6.2.2
4
4
  Summary: Code CIN - 高级语言与运行时 (CIN/PL/ASM 工具链 + Go 原生 VM + ARM64/RISC-V/FP/Vector 指令集)
5
5
  Author: ByUsi Studio, 北啊呢
6
6
  License-Expression: MIT
@@ -34,6 +34,54 @@ Code CIN 是一门简洁的类 C 高级语言及其跨平台运行时(VM)。
34
34
 
35
35
  模块化包结构(`codecin/`,Go 侧 `codecin/native/`),全线日志与错误输出基于 **rich**(彩色表格、面板、traceback),`--debug` / `--log-level DEBUG` 提供超详细诊断。
36
36
 
37
+ ## v6.2.0 工具链:mkn / pic / cvm
38
+
39
+ v6.2.0 在 `codecin` 之外提供三个独立命令,覆盖**构建 → 分发 → 运行**:
40
+
41
+ | 命令 | 类比 | 作用 |
42
+ |------|------|------|
43
+ | `mkn` | Maven | 项目清单、标准目录、生命周期、依赖解析、打包与本地仓库 |
44
+ | `pic` | pip | `package.codecin.org.cn` 中央注册/分发 + Cdifit 登录:发布登记标识名/Git 地址/版本列表/安全摘要并上传 `.cinpkg`,安装后可直接 `import` |
45
+ | `cvm` | JVM | Code CIN 虚拟机:构建/校验/运行 `.cvm` 模块,支持模块路径;`CPU` 仅作为内部执行核 |
46
+
47
+ ```bash
48
+ # 项目构建
49
+ mkn new demo && cd demo
50
+ mkn build
51
+ mkn run
52
+ mkn test
53
+ mkn package # target/demo-0.1.0.mkn
54
+
55
+ # 包管理 (首次使用会打开临时本地网页登录 Cdifit)
56
+ pic login
57
+ pic init hello
58
+ pic publish --repo https://github.com/you/cin-hello --name hello
59
+ pic install hello@^1.0 # 或 git+https://...、本地路径、.cinpkg
60
+ pic install hello --project # 安装到项目 pic_modules/,可直接 import
61
+ pic whoami
62
+ pic logout
63
+
64
+ # 虚拟机
65
+ cvm build src/main.cin -o app.cvm
66
+ cvm verify app.cvm
67
+ cvm run app.cvm -- arg1 arg2
68
+ cvm env
69
+ ```
70
+
71
+ `pic` 的中央注册/分发服务器是 **`package.codecin.org.cn`**(元数据、
72
+ `.cinpkg` 制品、版本/安全摘要);**Cdifit (`https://www.cdifit.cn`) 只负责
73
+ 登录和 Token 校验**。服务端实现见 [registry/README.md](registry/README.md),
74
+ 客户端可用 `PIC_REGISTRY_URL` 覆盖服务器地址。
75
+
76
+ 安装后的包无需修改源码即可导入:
77
+
78
+ ```cin
79
+ import "hello" // 包入口 (pic.toml 的 entry)
80
+ import "hello/util.cin" // 包内文件
81
+ ```
82
+
83
+ 完整设计、格式与验收标准见 [V6.2.0-PLAN.md](V6.2.0-PLAN.md)。
84
+
37
85
  ## 文档
38
86
 
39
87
  **官方文档站**位于独立仓库
@@ -16,6 +16,54 @@ Code CIN 是一门简洁的类 C 高级语言及其跨平台运行时(VM)。
16
16
 
17
17
  模块化包结构(`codecin/`,Go 侧 `codecin/native/`),全线日志与错误输出基于 **rich**(彩色表格、面板、traceback),`--debug` / `--log-level DEBUG` 提供超详细诊断。
18
18
 
19
+ ## v6.2.0 工具链:mkn / pic / cvm
20
+
21
+ v6.2.0 在 `codecin` 之外提供三个独立命令,覆盖**构建 → 分发 → 运行**:
22
+
23
+ | 命令 | 类比 | 作用 |
24
+ |------|------|------|
25
+ | `mkn` | Maven | 项目清单、标准目录、生命周期、依赖解析、打包与本地仓库 |
26
+ | `pic` | pip | `package.codecin.org.cn` 中央注册/分发 + Cdifit 登录:发布登记标识名/Git 地址/版本列表/安全摘要并上传 `.cinpkg`,安装后可直接 `import` |
27
+ | `cvm` | JVM | Code CIN 虚拟机:构建/校验/运行 `.cvm` 模块,支持模块路径;`CPU` 仅作为内部执行核 |
28
+
29
+ ```bash
30
+ # 项目构建
31
+ mkn new demo && cd demo
32
+ mkn build
33
+ mkn run
34
+ mkn test
35
+ mkn package # target/demo-0.1.0.mkn
36
+
37
+ # 包管理 (首次使用会打开临时本地网页登录 Cdifit)
38
+ pic login
39
+ pic init hello
40
+ pic publish --repo https://github.com/you/cin-hello --name hello
41
+ pic install hello@^1.0 # 或 git+https://...、本地路径、.cinpkg
42
+ pic install hello --project # 安装到项目 pic_modules/,可直接 import
43
+ pic whoami
44
+ pic logout
45
+
46
+ # 虚拟机
47
+ cvm build src/main.cin -o app.cvm
48
+ cvm verify app.cvm
49
+ cvm run app.cvm -- arg1 arg2
50
+ cvm env
51
+ ```
52
+
53
+ `pic` 的中央注册/分发服务器是 **`package.codecin.org.cn`**(元数据、
54
+ `.cinpkg` 制品、版本/安全摘要);**Cdifit (`https://www.cdifit.cn`) 只负责
55
+ 登录和 Token 校验**。服务端实现见 [registry/README.md](registry/README.md),
56
+ 客户端可用 `PIC_REGISTRY_URL` 覆盖服务器地址。
57
+
58
+ 安装后的包无需修改源码即可导入:
59
+
60
+ ```cin
61
+ import "hello" // 包入口 (pic.toml 的 entry)
62
+ import "hello/util.cin" // 包内文件
63
+ ```
64
+
65
+ 完整设计、格式与验收标准见 [V6.2.0-PLAN.md](V6.2.0-PLAN.md)。
66
+
19
67
  ## 文档
20
68
 
21
69
  **官方文档站**位于独立仓库
@@ -1,4 +1,4 @@
1
- __version__ = "6.0.1"
1
+ __version__ = "6.2.2"
2
2
  __author__ = "ByUsi Studio"
3
3
 
4
4
  from .config import Config
@@ -253,6 +253,9 @@ HOST_BUILTINS = {
253
253
  'mouse_x': (Syscall.MOUSEX, 0, 'int'),
254
254
  'mouse_y': (Syscall.MOUSEY, 0, 'int'),
255
255
  'mouse_button': (Syscall.MOUSEBTN, 0, 'int'),
256
+ # 虚拟键盘 (Windows 屏幕/触摸键盘 TabTip; 其他平台 -1)
257
+ 'vkb_show': (Syscall.VKBSHOW, 0, 'int'),
258
+ 'vkb_hide': (Syscall.VKBHIDE, 0, 'int'),
256
259
  # 音频扩展 (播放进度与蜂鸣合成)
257
260
  'audio_pos': (Syscall.AUDIOPOS, 0, 'int'),
258
261
  'beep': (Syscall.AUDIOBEEP, 2, 'int'),
@@ -590,7 +593,9 @@ def tokenize(source: str,
590
593
  # ==================== import 预处理 (B3) ====================
591
594
  # import "path.cin" 仅在文件顶部/列首识别。解析规则:
592
595
  # * "./x.cin" / "../x.cin" -> 相对当前 .cin 文件所在目录;
593
- # * 其余形式 -> codecin 内置标准库 codecin/lib/。
596
+ # * 其余形式 -> 依次查找 codecin 内置标准库、项目依赖目录、
597
+ # CIN_PATH、已安装的 pic 包;
598
+ # * 包名 (无 .cin 后缀) 直接 import 该包的入口 (v6.2.0)。
594
599
  # 同一文件每个编译仅包含一次, 循环引用报错。
595
600
 
596
601
  _IMPORT_RE = re.compile(r'^import\s+["\']([^"\']+)["\']\s*;?\s*$')
@@ -603,19 +608,193 @@ _LIB_DIR = os.path.join(_CODECIN_ROOT, 'lib')
603
608
  #: 相对引用的前缀: 必须以 "." 开头
604
609
  _RELATIVE_PREFIXES = ('./', '../', '.\\', '..\\')
605
610
 
611
+ #: 项目内依赖目录 (按优先级): mkn / pic --project / 旧式隐藏目录
612
+ _PROJECT_DEP_DIRS = ('pic_modules', os.path.join('.mkn', 'deps'),
613
+ os.path.join('.pic', 'packages'))
614
+
615
+ #: 包名合法性 (与 packaging.model 保持一致, 这里不 import 以避免启动开销)
616
+ _PKG_NAME_RE = re.compile(r'^[A-Za-z][A-Za-z0-9_-]{0,63}$')
617
+
606
618
 
607
619
  def _is_relative_import(name: str) -> bool:
608
620
  """``import "./x.cin"`` / ``import "../x.cin"`` 视为相对引用。"""
609
621
  return name.startswith(_RELATIVE_PREFIXES)
610
622
 
611
623
 
624
+ def _cin_path_dirs() -> List[str]:
625
+ """``CIN_PATH`` 环境变量中的 import 搜索目录 (``os.pathsep`` 分隔)。"""
626
+ raw = os.environ.get('CIN_PATH', '')
627
+ return [os.path.abspath(p) for p in raw.split(os.pathsep) if p.strip()]
628
+
629
+
630
+ def _project_roots(source_dir: str) -> List[str]:
631
+ """从源文件目录向上收集包含 mkn.toml / pic.toml 的项目根 (近到远)。"""
632
+ roots: List[str] = []
633
+ path = os.path.abspath(source_dir)
634
+ while True:
635
+ if (os.path.isfile(os.path.join(path, 'mkn.toml'))
636
+ or os.path.isfile(os.path.join(path, 'pic.toml'))):
637
+ roots.append(path)
638
+ parent = os.path.dirname(path)
639
+ if parent == path:
640
+ break
641
+ path = parent
642
+ return roots
643
+
644
+
645
+ def _package_roots(source_dir: str) -> List[str]:
646
+ """候选包根目录 (按优先级): 项目依赖 -> CIN_PATH -> 全局 pic 存储。"""
647
+ roots: List[str] = []
648
+ for project in _project_roots(source_dir):
649
+ for rel in _PROJECT_DEP_DIRS:
650
+ candidate = os.path.join(project, rel)
651
+ if os.path.isdir(candidate):
652
+ roots.append(candidate)
653
+ roots.extend(_cin_path_dirs())
654
+
655
+ home = os.environ.get('PIC_HOME') or os.path.join(
656
+ os.path.expanduser('~'), '.pic')
657
+ packages = os.path.join(home, 'packages')
658
+ if os.path.isdir(packages):
659
+ # 全局存储是 <name>/<version>/; 具体版本由解析器按 current 选择
660
+ roots.append(packages)
661
+ return roots
662
+
663
+
664
+ def _entry_from_package(pkg_dir: str, pkg: str,
665
+ hinted_file: Optional[str] = None) -> Optional[str]:
666
+ """在包目录中解析入口文件: pic.toml 的 entry 优先, 再按约定回退。"""
667
+ base = pkg_dir
668
+ link = os.path.join(base, '.pic-link')
669
+ if os.path.isfile(link):
670
+ try:
671
+ with open(link, encoding='utf-8') as f:
672
+ target = f.read().strip()
673
+ if target:
674
+ base = os.path.abspath(target)
675
+ except OSError:
676
+ pass
677
+ if not os.path.isdir(base):
678
+ return None
679
+
680
+ if hinted_file:
681
+ for rel in (hinted_file, os.path.join('src', hinted_file)):
682
+ candidate = os.path.normpath(os.path.join(base, rel))
683
+ if os.path.isfile(candidate):
684
+ return candidate
685
+
686
+ manifest = os.path.join(base, 'pic.toml')
687
+ if os.path.isfile(manifest):
688
+ try:
689
+ from .packaging.model import load_package_manifest
690
+ meta = load_package_manifest(base, require_entry=False)
691
+ if meta.entry_path:
692
+ return meta.entry_path
693
+ except Exception:
694
+ # 清单损坏不应让 import 变成不可诊断的异常:
695
+ # 继续按目录约定查找, 最终在找不到时给出统一错误
696
+ pass
697
+
698
+ mkn_manifest = os.path.join(base, 'mkn.toml')
699
+ if os.path.isfile(mkn_manifest):
700
+ try:
701
+ from .packaging.model import load_mkn_manifest
702
+ project = load_mkn_manifest(base)
703
+ entry = project.entry_path
704
+ if entry:
705
+ return entry
706
+ except Exception:
707
+ pass
708
+
709
+ for rel in (os.path.join('src', f'{pkg}.cin'), f'{pkg}.cin',
710
+ os.path.join('src', 'main.cin'), 'main.cin'):
711
+ candidate = os.path.normpath(os.path.join(base, rel))
712
+ if os.path.isfile(candidate):
713
+ return candidate
714
+ return None
715
+
716
+
717
+ def _version_dirs(pkg_dir: str, root: str) -> List[str]:
718
+ """全局存储 ``<name>/<version>`` 下的版本目录 (current 优先)。"""
719
+ try:
720
+ versions = [
721
+ v for v in os.listdir(pkg_dir)
722
+ if os.path.isdir(os.path.join(pkg_dir, v))
723
+ and re.fullmatch(r'\d+\.\d+\.\d+(?:[-+].*)?', v)
724
+ ]
725
+ except OSError:
726
+ return []
727
+ current = None
728
+ if os.path.basename(root) == 'packages':
729
+ index_path = os.path.join(os.path.dirname(root), 'index.json')
730
+ try:
731
+ import json
732
+ with open(index_path, encoding='utf-8') as f:
733
+ index = json.load(f)
734
+ record = (index.get('packages') or {}).get(
735
+ os.path.basename(pkg_dir)) or {}
736
+ current = record.get('current')
737
+ except (OSError, ValueError, TypeError):
738
+ current = None
739
+ versions.sort(reverse=True)
740
+ if current in versions:
741
+ versions.remove(current)
742
+ versions.insert(0, current)
743
+ return [os.path.join(pkg_dir, v) for v in versions]
744
+
745
+
746
+ def _resolve_package_import(name: str,
747
+ source_dir: str) -> Optional[str]:
748
+ """按包名解析 import; 找不到返回 None。"""
749
+ normalized = name.replace('\\', '/')
750
+ parts = [p for p in normalized.split('/') if p]
751
+ if not parts:
752
+ return None
753
+
754
+ pkg = parts[0]
755
+ hinted: Optional[str] = None
756
+ if len(parts) == 1 and pkg.endswith('.cin'):
757
+ # `import "hello.cin"` 也允许命中名为 hello 的包
758
+ pkg = pkg[:-4]
759
+ hinted = parts[0]
760
+ if not _PKG_NAME_RE.match(pkg):
761
+ return None
762
+ sub = '/'.join(parts[1:]) if len(parts) > 1 else ''
763
+
764
+ for root in _package_roots(source_dir):
765
+ pkg_dir = os.path.join(root, pkg)
766
+ if not os.path.isdir(pkg_dir):
767
+ continue
768
+ version_dirs = _version_dirs(pkg_dir, root)
769
+ if sub:
770
+ for base in [pkg_dir, os.path.join(pkg_dir, 'src'),
771
+ *(os.path.join(v, 'src') for v in version_dirs),
772
+ *version_dirs]:
773
+ candidate = os.path.normpath(
774
+ os.path.join(base, *sub.split('/')))
775
+ if os.path.isfile(candidate):
776
+ return candidate
777
+ continue
778
+ entry = _entry_from_package(pkg_dir, pkg, hinted)
779
+ if entry:
780
+ return entry
781
+ for version_dir in version_dirs:
782
+ entry = _entry_from_package(version_dir, pkg, hinted)
783
+ if entry:
784
+ return entry
785
+ return None
786
+
787
+
612
788
  def _resolve_import(name: str, source_dir: str) -> str:
613
789
  """解析 import 目标路径。
614
790
 
615
- 规则 (B3):
791
+ 规则 (B3 + v6.2.0 包导入):
616
792
  * ``import "./x.cin"`` / ``import "../x.cin"`` —— 相对**当前 .cin 文件**所在目录;
617
- * 其余任何形式 (``import "x.cin"``、``import "lib/x.cin"``) —— 直接解析到
618
- **codecin 内置标准库** ``codecin/lib/`` (``lib/`` 前缀保留为兼容写法)。
793
+ * 其余形式先查 **codecin 内置标准库** ``codecin/lib/`` (``lib/`` 前缀保留
794
+ 为兼容写法), 保持 "裸名字不会命中兄弟文件" 的既有语义;
795
+ * 再查项目依赖目录 (``pic_modules`` / ``.mkn/deps`` / ``.pic/packages``)、
796
+ ``CIN_PATH`` 与全局 pic 包存储; ``import "hello"`` 直接导入包入口,
797
+ ``import "hello/util.cin"`` 导入包内文件。
619
798
  """
620
799
  if _is_relative_import(name):
621
800
  cand = os.path.normpath(os.path.join(source_dir, name))
@@ -630,9 +809,16 @@ def _resolve_import(name: str, source_dir: str) -> str:
630
809
  for cand in candidates:
631
810
  if os.path.isfile(cand):
632
811
  return cand
812
+
813
+ package = _resolve_package_import(name, source_dir)
814
+ if package:
815
+ return package
816
+
633
817
  raise CompilerError(
634
- f"Import file not found: {name!r} (内置标准库, 已查找 "
635
- f"{os.path.join(_LIB_DIR, name)})")
818
+ f"Import file not found: {name!r} (内置标准库已查找 "
819
+ f"{os.path.join(_LIB_DIR, name)}; 也未在项目 pic_modules/"
820
+ f"CIN_PATH/已安装 pic 包中找到)。"
821
+ f"如需导入第三方包, 先运行 `pic install <name>`。")
636
822
 
637
823
 
638
824
  def _collect_module_lines(path: str, loaded: set, active: set,
@@ -28,6 +28,11 @@ HELP_INTRO = f"""{Colors.colorize(f'Code CIN v{__version__}', Colors.CYAN, True)
28
28
  .pl Code CIN 汇编语言 (PL 关键字风格)
29
29
  .asm Code CIN 汇编
30
30
  .bin UCBC 字节码 (由 --compile 生成)
31
+
32
+ {Colors.colorize('Toolchain (v6.2.0):', Colors.YELLOW)}
33
+ mkn 项目构建/依赖 (Maven 风格)
34
+ pic 去中心化包管理 (pip 风格, 安装后可直接 import)
35
+ cvm CVM 虚拟机/模块运行时 (JVM 风格)
31
36
  """
32
37
 
33
38