diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index afc34fe..75fbe13 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -1,11 +1,15 @@ -name: Cross-Platform PiCo Build +name: Cieto CI -on: [push, pull_request] +on: + push: + pull_request: + workflow_dispatch: jobs: build: name: ${{ matrix.name }} runs-on: ${{ matrix.os }} + timeout-minutes: 20 strategy: fail-fast: false @@ -14,14 +18,16 @@ jobs: - name: Linux Release os: ubuntu-latest preset: release + package: cieto-linux-x86_64 - name: Windows Release os: windows-latest preset: release-windows + package: cieto-windows-x86_64 steps: - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v7 with: submodules: recursive @@ -32,4 +38,50 @@ jobs: run: cmake --build --preset ${{ matrix.preset }} - name: Run tests - run: ctest --preset ${{ matrix.preset }} --output-on-failure \ No newline at end of file + run: ctest --preset ${{ matrix.preset }} --output-on-failure + + - name: Stage install tree + run: cmake --install build/${{ matrix.preset }} --prefix package/cieto + + - name: Create ZIP package + working-directory: package + run: | + cmake -E tar cf ../${{ matrix.package }}.zip cieto + cmake -E tar tf ../${{ matrix.package }}.zip + + - name: Upload ZIP artifact + uses: actions/upload-artifact@v7 + with: + path: ${{ matrix.package }}.zip + archive: false + if-no-files-found: error + retention-days: 14 + + sanitizers: + name: Linux ASan + UBSan + runs-on: ubuntu-latest + timeout-minutes: 20 + env: + ASAN_OPTIONS: detect_leaks=1:halt_on_error=1 + UBSAN_OPTIONS: halt_on_error=1:print_stacktrace=1 + + steps: + - name: Checkout code + uses: actions/checkout@v7 + with: + submodules: recursive + + - name: Configure sanitizers + run: >- + cmake -S . -B build/sanitizers -G Ninja + -DCMAKE_BUILD_TYPE=Debug + -DCMAKE_C_COMPILER=gcc + -DBUILD_TESTING=ON + "-DCMAKE_C_FLAGS=-fsanitize=address,undefined -fno-omit-frame-pointer -fno-sanitize-recover=all" + "-DCMAKE_EXE_LINKER_FLAGS=-fsanitize=address,undefined" + + - name: Build with sanitizers + run: cmake --build build/sanitizers + + - name: Run sanitizer tests + run: ctest --test-dir build/sanitizers --output-on-failure --timeout 180 diff --git a/CMakeLists.txt b/CMakeLists.txt index ca7c5d2..a239312 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,12 +1,12 @@ cmake_minimum_required(VERSION 3.21) -project(PiCo VERSION 0.1.0 LANGUAGES C) +project(Cieto VERSION 0.2.0 LANGUAGES C) include(GNUInstallDirs) if(NOT CMAKE_C_COMPILER_ID MATCHES "GNU") message(FATAL_ERROR - "PiCo requires GCC because it uses GNU C extensions. " + "Cieto requires GCC because it uses GNU C extensions. " "Configure CMake with a GCC-based toolchain or preset." ) endif() @@ -21,7 +21,7 @@ file(GLOB_RECURSE COMPILER_SRC CONFIGURE_DEPENDS "compiler/*.c") file(GLOB_RECURSE STD_SRC CONFIGURE_DEPENDS "std/*.c") file(GLOB_RECURSE CMD_SRC CONFIGURE_DEPENDS "cmd/*.c") -set(PICO_INTERNAL_INCLUDE_DIRS +set(CIETO_INTERNAL_INCLUDE_DIRS cmd core vm @@ -30,17 +30,17 @@ set(PICO_INTERNAL_INCLUDE_DIRS vendor/xxhash ) -set(PICO_API_SRC - api/pico.c +set(CIETO_API_SRC + api/cieto.c ) -set(PICO_VENDOR_SRC +set(CIETO_VENDOR_SRC vendor/xxhash/xxhash.c ) -set(PICO_RUNTIME_SRC - ${PICO_API_SRC} - ${PICO_VENDOR_SRC} +set(CIETO_RUNTIME_SRC + ${CIETO_API_SRC} + ${CIETO_VENDOR_SRC} ${CORE_SRC} ${VM_SRC} ${COMPILER_SRC} @@ -53,39 +53,39 @@ add_compile_options( $<$:-O3> ) -add_library(picort STATIC - ${PICO_RUNTIME_SRC} +add_library(libcieto STATIC + ${CIETO_RUNTIME_SRC} ) -target_include_directories(picort +target_include_directories(libcieto PUBLIC $ $ PRIVATE - ${PICO_INTERNAL_INCLUDE_DIRS} + ${CIETO_INTERNAL_INCLUDE_DIRS} ) -set_target_properties(picort PROPERTIES - OUTPUT_NAME pico +set_target_properties(libcieto PROPERTIES + OUTPUT_NAME cieto ) -target_link_libraries(picort +target_link_libraries(libcieto PRIVATE m ) -add_executable(pico +add_executable(cieto ${CMD_SRC} ) -target_include_directories(pico +target_include_directories(cieto PRIVATE - ${PICO_INTERNAL_INCLUDE_DIRS} + ${CIETO_INTERNAL_INCLUDE_DIRS} ) -target_link_libraries(pico +target_link_libraries(cieto PRIVATE - picort + libcieto ) if(NOT WIN32) @@ -98,60 +98,60 @@ if(NOT WIN32) vendor/linenoise ) - target_compile_definitions(pico + target_compile_definitions(cieto PRIVATE USE_LINENOISE ) - target_link_libraries(pico + target_link_libraries(cieto PRIVATE linenoise_lib ) endif() -add_executable(pico_embed_basic +add_executable(cieto_embed_basic examples/embedding/basic.c ) -target_link_libraries(pico_embed_basic +target_link_libraries(cieto_embed_basic PRIVATE - picort + libcieto ) -add_executable(pico_embed_exit_policy +add_executable(cieto_embed_exit_policy tests/embedding_exit_policy.c ) -target_link_libraries(pico_embed_exit_policy +target_link_libraries(cieto_embed_exit_policy PRIVATE - picort + libcieto ) -add_executable(pico_embed_native_function +add_executable(cieto_embed_native_function tests/embedding_native_function.c ) -target_link_libraries(pico_embed_native_function +target_link_libraries(cieto_embed_native_function PRIVATE - picort + libcieto ) -add_executable(pico_embed_output_callback +add_executable(cieto_embed_output_callback tests/embedding_output_callback.c ) -target_link_libraries(pico_embed_output_callback +target_link_libraries(cieto_embed_output_callback PRIVATE - picort + libcieto ) -add_executable(pico_embed_call_script +add_executable(cieto_embed_call_script tests/embedding_call_script.c ) -target_link_libraries(pico_embed_call_script +target_link_libraries(cieto_embed_call_script PRIVATE - picort + libcieto ) include(CTest) @@ -159,7 +159,7 @@ include(CTest) if(BUILD_TESTING) if(WIN32) find_program( - PICO_BASH_EXECUTABLE + CIETO_BASH_EXECUTABLE NAMES bash.exe PATHS "$ENV{ProgramFiles}/Git/bin" @@ -171,72 +171,72 @@ if(BUILD_TESTING) ) else() find_program( - PICO_BASH_EXECUTABLE + CIETO_BASH_EXECUTABLE NAMES bash ) endif() - if(NOT PICO_BASH_EXECUTABLE) + if(NOT CIETO_BASH_EXECUTABLE) message(FATAL_ERROR "Bash was not found. On Windows, install Git for Windows or MSYS2." ) endif() add_test( - NAME pico_script_tests + NAME cieto_script_tests COMMAND - "${PICO_BASH_EXECUTABLE}" + "${CIETO_BASH_EXECUTABLE}" "${CMAKE_SOURCE_DIR}/tests/run_tests.sh" - "$" + "$" "60" WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/tests" ) add_test( - NAME pico_embedding_basic - COMMAND $ + NAME cieto_embedding_basic + COMMAND $ ) add_test( - NAME pico_embedding_exit_policy - COMMAND $ + NAME cieto_embedding_exit_policy + COMMAND $ ) add_test( - NAME pico_embedding_native_function - COMMAND $ + NAME cieto_embedding_native_function + COMMAND $ ) add_test( - NAME pico_embedding_call_script - COMMAND $ + NAME cieto_embedding_call_script + COMMAND $ ) add_test( - NAME pico_embedding_output_callback - COMMAND $ + NAME cieto_embedding_output_callback + COMMAND $ ) endif() add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure DEPENDS - pico - pico_embed_basic - pico_embed_exit_policy - pico_embed_native_function - pico_embed_call_script - pico_embed_output_callback + cieto + cieto_embed_basic + cieto_embed_exit_policy + cieto_embed_native_function + cieto_embed_call_script + cieto_embed_output_callback WORKING_DIRECTORY ${CMAKE_BINARY_DIR} ) -install(TARGETS pico picort +install(TARGETS cieto libcieto RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ) -install(FILES include/pico.h +install(FILES include/cieto.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) @@ -247,9 +247,9 @@ install(FILES README.md manual.md LICENSE gpl-3.0.txt install(DIRECTORY examples/ DESTINATION ${CMAKE_INSTALL_DOCDIR}/examples FILES_MATCHING - PATTERN "*.pcs" + PATTERN "*.cies" PATTERN "*.c" PATTERN "README.md" ) -message(STATUS "Project 'PiCo' configured to use C Compiler: ${CMAKE_C_COMPILER}") \ No newline at end of file +message(STATUS "Project 'Cieto' configured to use C Compiler: ${CMAKE_C_COMPILER}") diff --git a/Cieto_Rename_Codex_Guide.md b/Cieto_Rename_Codex_Guide.md new file mode 100644 index 0000000..33fa078 --- /dev/null +++ b/Cieto_Rename_Codex_Guide.md @@ -0,0 +1,751 @@ +# PiCo → Cieto Rename Plan + +## Objective + +Rename the existing **PiCo** programming language and virtual machine project to **Cieto** without changing runtime behavior, language semantics, bytecode semantics, performance characteristics, or architecture. + +This must be a **pure naming refactor**. + +The final public naming scheme is: + +| Surface | Old | New | +| ------------------------- | ---------------------------------------- | ---------------------- | +| Project / language | PiCo / Pico / pico | Cieto / cieto | +| CLI executable | `pico` | `cieto` | +| Source extension | `.pcs` | `.cies` | +| Library | `libpico` | `libcieto` | +| Public type prefix | `Pico...` / project-specific equivalent | `Cie...` | +| Public function prefix | `pico_...` / project-specific equivalent | `cie_...` | +| Public macro prefix | `PICO_...` | `CIE_...` | +| Installed header | `pico.h` or equivalent | `cieto.h` | +| Environment/config prefix | `PICO_...` | `CIETO_...` | +| Shebang | `#!/usr/bin/env pico` | `#!/usr/bin/env cieto` | + +Brand rationale: + +> **Cieto** is inspired by the Latin verb *cieō*, “to set in motion.” + +Canonical project description: + +> **A compact C-family scripting language and embeddable register-based virtual machine implemented entirely in C.** + +--- + +# Critical Constraints + +1. **Do not change behavior.** + + - Do not alter syntax. + + - Do not alter parser rules. + + - Do not alter opcode values or layouts. + + - Do not alter bytecode encoding. + + - Do not alter GC behavior. + + - Do not alter module semantics. + + - Do not alter object layouts. + + - Do not alter public function behavior. + + - Do not perform unrelated cleanup or optimization. + +2. **Keep the rename isolated.** + + - Use a dedicated branch such as: + ```bash + git switch -c refactor/rename-to-cieto + ``` + + - Produce one focused commit: + ```text + refactor: rename PiCo to Cieto + ``` + +3. **Do not create, delete, or modify unrelated documentation.** + + - Do not create `systems_interview_notes.md`. + + - Do not delete unrelated files under `docs/`. + + - Do not include unrelated formatting changes. + + - Do not reorganize directories unless the rename itself requires it. + +4. **Do not use blind global replacement.** + + - Inspect every category first. + + - Avoid changing unrelated words containing `pico`. + + - Avoid altering third-party dependency names, URLs, licenses, or historical author names unless they specifically refer to this project. + +5. **Do not add compatibility aliases by default.** + + - This is intended to be a clean rename. + + - Do not keep `pico_*`, `Pico*`, `PICO_*`, the `pico` executable, or `.pcs` aliases unless the repository already has a documented compatibility policy requiring them. + +6. **Preserve project requirements.** + + - C11 plus the GNU extensions already used by the project. + + - GCC remains the required compiler unless the existing build already supports others. + + - Preserve the computed-goto interpreter and all existing low-level implementation choices. + +--- + +# Phase 1: Inventory Before Editing + +Start from a clean worktree: + +```bash +git status --short +``` + +If the worktree is not clean, stop and report the unrelated changes instead of overwriting them. + +Inspect the repository structure and existing build/test commands: + +```bash +find . -maxdepth 3 -type f | sort +``` + +Search all current branding and extensions: + +```bash +rg -n --hidden \ + --glob '!.git/**' \ + 'PiCo|Pico|PICO|pico|\.pcs|libpico|pico\.h|PICO_PATH|#!/usr/bin/env pico' +``` + +Also inspect filenames and directories: + +```bash +find . -depth \ + \( -iname '*pico*' -o -iname '*.pcs' \) \ + -print +``` + +Classify every match into one of these groups before editing: + +1. Public C API +2. Internal C identifiers +3. CLI executable and entry point +4. Build-system targets +5. Installation paths +6. Source-file extension handling +7. Tests and fixtures +8. Examples and benchmarks +9. Documentation +10. CI/release/package configuration +11. Comments, diagnostics, and version strings +12. Historical or unrelated references that must remain unchanged + +Write a short internal checklist from the actual repository contents. Do not invent files or APIs that do not exist. + +--- + +# Phase 2: Apply the Canonical Naming Scheme + +## 2.1 Project and CLI Branding + +Rename user-facing forms consistently: + +```text +PiCo -> Cieto +Pico -> Cieto +pico -> cieto +``` + +This includes, where present: + +- README title +- CLI help text +- version output +- startup banners +- error prefixes +- package descriptions +- CMake project name +- Makefile target names +- install targets +- release archive names +- CI artifact names +- example commands +- shell completions +- man pages + +Expected CLI examples: + +```bash +cieto main.cies +cieto --dump examples/fibonacci.cies +cieto --version +cieto --help +``` + +The executable installed into `PATH` must be named: + +```text +cieto +``` + +Do not leave a second `pico` executable unless compatibility is explicitly requested later. + +--- + +## 2.2 Source Extension + +Rename the language source extension: + +```text +.pcs -> .cies +``` + +Rename all tracked source programs, including: + +- examples +- tests +- benchmarks +- module fixtures +- sample scripts +- documentation snippets +- CI commands + +Use `git mv`, not delete-and-recreate: + +```bash +git mv path/to/example.pcs path/to/example.cies +``` + +Update all extension-sensitive code: + +- command-line validation +- module resolution +- script import resolution +- default file extension constants +- error messages +- syntax-highlighting files +- editor integration +- test discovery +- packaging manifests + +Examples: + +```text +examples/fibonacci.cies +tests/test_gc_mode.cies +tests/test_modules.cies +benchmarks/arithmetic_loop.cies +``` + +Update shebangs: + +```text +#!/usr/bin/env cieto +``` + +Do not change the syntax inside `.cies` files. + +--- + +## 2.3 Public C API + +The public API must use the `Cie` / `cie_` / `CIE_` namespace. + +Map actual existing public names according to these rules: + +```text +PicoVM -> CieVM +PicoValue -> CieValue +PicoResult -> CieResult +PicoConfig -> CieConfig +PicoNativeFn -> CieNativeFn + +pico_* -> cie_* +PICO_* -> CIE_* +``` + +The exact list must come from the real public headers. + +Illustrative target style: + +```c +typedef struct CieVM CieVM; + +typedef enum { + CIE_OK, + CIE_ERR_COMPILE, + CIE_ERR_RUNTIME +} CieResult; + +CieVM *cie_vm_new(const CieConfig *config); +void cie_vm_free(CieVM *vm); + +CieResult cie_eval(CieVM *vm, const char *source); +CieResult cie_run_file(CieVM *vm, const char *path); +``` + +Naming rules: + +- Public opaque types: `Cie...` +- Public functions: `cie_...` +- Public macros and enum constants: `CIE_...` +- No exported `pico_*`, `Pico*`, or `PICO_*` symbols after the rename +- Preserve signatures, ABI-relevant layouts, calling conventions, and behavior except for symbol names + +Header naming: + +- If the project currently installs a flat public header, rename it to: + + ```text + cieto.h + ``` +- If the project already uses a namespaced include directory, use: + + ```c + #include + ``` +- Do not introduce a new include-directory architecture solely for this rename. + +Update: + +- header guards +- export macros +- pkg-config files +- CMake package config +- installed include paths +- examples embedding the VM +- tests of the embedding API + +Example header guard: + +```c +#ifndef CIETO_H +#define CIETO_H + +/* ... */ + +#endif +``` + +--- + +## 2.4 Internal C Identifiers + +Rename internal identifiers only when they encode the old project brand. + +Examples: + +```text +picoMain -> cietoMain +picoVersion -> cietoVersion +PICO_VERSION -> CIETO_VERSION +``` + +Do not rename functional internal terms that do not contain project branding. + +Do not perform broad style changes such as: + +- changing camelCase to snake_case +- restructuring static functions +- renaming generic VM fields +- splitting source files +- moving modules +- rewriting macros + +Static internal symbols that are unrelated to the brand should remain unchanged. + +--- + +## 2.5 Build System + +Inspect the actual build system before editing. + +Rename, where present: + +```text +pico executable target -> cieto +pico library target -> cieto or libcieto +libpico.a -> libcieto.a +libpico.so -> libcieto.so +pico.exe -> cieto.exe +``` + +Update: + +- `CMakeLists.txt` +- Makefiles +- build scripts +- installation scripts +- pkg-config metadata +- CI workflow commands +- release packaging +- Windows target names +- test commands +- benchmark commands + +Preserve compiler flags and implementation requirements. + +After installation, these should resolve to the new names: + +```bash +command -v cieto +cieto --version +``` + +The old binary should not remain installed accidentally. + +If the project supports `make install`, verify installation into a temporary prefix first: + +```bash +make DESTDIR=/tmp/cieto-install install +find /tmp/cieto-install -type f | sort +``` + +Adapt this command to the actual build system rather than inventing a new install flow. + +--- + +## 2.6 Modules and Script Resolution + +Inspect code responsible for: + +- native module registration +- script module loading +- `import` +- source-path resolution +- default extension insertion +- search paths +- diagnostics + +Change only branding and extension data: + +```text +.pcs -> .cies +PICO_PATH -> CIETO_PATH +``` + +If an environment variable like `PICO_PATH` exists, rename it to: + +```text +CIETO_PATH +``` + +Do not change: + +- import scope +- module caching +- native-module lookup +- path normalization behavior +- script-vs-native resolution order +- GC ownership + +Add or update tests proving that imports using `.cies` behave exactly as `.pcs` did before the rename. + +--- + +## 2.7 Bytecode and Dump Output + +The project already supports or is developing `--dump`. + +Update branding and example filenames: + +```bash +cieto --dump examples/fibonacci.cies +``` + +Do not change: + +- opcode values +- instruction formats +- register indexing +- constant-pool behavior +- disassembly semantics +- closure representation +- serialized-format design + +If a speculative compiled artifact such as `.pco` is mentioned only in notes and is not implemented, do not invent or rename it during this task. + +If an implemented artifact format exists, report it separately before changing its extension. + +--- + +## 2.8 Documentation + +Update branding in: + +- README +- build instructions +- installation instructions +- embedding examples +- benchmark commands +- module examples +- release notes +- comments describing the project +- badges and artifact labels + +Recommended README opening: + +```markdown +# Cieto + +A compact C-family scripting language and embeddable register-based virtual machine implemented entirely in C. + +Cieto is inspired by the Latin verb *cieō*, “to set in motion.” +``` + +Example usage: + +```bash +cieto examples/fibonacci.cies +``` + +Embedding example: + +```c +#include + +int main(void) { + CieVM *vm = cie_vm_new(NULL); + if (vm == NULL) { + return 1; + } + + CieResult result = cie_run_file(vm, "main.cies"); + cie_vm_free(vm); + + return result == CIE_OK ? 0 : 1; +} +``` + +Adapt function names to the real API; do not create APIs that the project does not currently provide. + +Historical references may remain when explicitly describing the rename, for example: + +```text +Cieto was previously named PiCo. +``` + +Do not leave PiCo as the current project name anywhere else. + +--- + +# Phase 3: Validation + +## 3.1 Search for Missed Branding + +Run all of the following after editing: + +```bash +rg -n --hidden \ + --glob '!.git/**' \ + 'PiCo|Pico|PICO|pico|\.pcs|libpico|pico\.h|PICO_PATH|#!/usr/bin/env pico' +``` + +Review every remaining match manually. + +Acceptable remaining matches are limited to: + +- an intentional migration note +- immutable historical references +- unrelated third-party text +- Git metadata outside the worktree + +Do not simply suppress remaining matches. + +Also check filenames: + +```bash +find . -depth \ + \( -iname '*pico*' -o -iname '*.pcs' \) \ + -print +``` + +Expected result: no project-owned current files. + +--- + +## 3.2 Build and Test + +Use the repository's existing documented commands and CI configuration. + +At minimum, validate: + +1. Debug build +2. Release build +3. Existing automated tests +4. Script execution +5. Module imports +6. Closures +7. Classes +8. GC mode tests +9. Iterator and slicing tests +10. `--dump` +11. C embedding API +12. Installation +13. Windows/MinGW build if already supported +14. Existing benchmark programs as smoke tests + +Representative smoke tests: + +```bash +./build/debug/cieto examples/fibonacci.cies +./build/release/cieto examples/fibonacci.cies +./build/release/cieto --dump examples/fibonacci.cies +``` + +Adapt paths to the actual build output. + +Run all existing test scripts after renaming them to `.cies`. + +The rename must not change expected output except for intentional project-name or filename text. + +--- + +## 3.3 Public Symbol Audit + +If a library is built, inspect exported symbols: + +```bash +nm -g --defined-only path/to/libcieto.a | sort +``` + +For a shared library, use the platform-appropriate symbol inspection tool. + +Verify: + +- expected `cie_*` public symbols exist +- no old exported `pico_*` symbols remain +- internal symbols did not unintentionally become public +- symbol signatures remain equivalent + +--- + +## 3.4 Runtime String Audit + +Inspect the built binary for stale user-facing branding where practical: + +```bash +strings path/to/cieto | rg 'PiCo|Pico|PICO|pico|\.pcs' +``` + +Review every match. + +Do not treat unrelated compiler paths or embedded source paths as automatic failures, but remove stale project branding from user-facing output. + +--- + +## 3.5 Behavior Comparison + +Before the rename, capture representative outputs if possible: + +- Fibonacci example +- arithmetic benchmark result +- module tests +- GC mode test +- class/closure test +- bytecode dump + +After the rename, compare them. + +Only these differences are expected: + +```text +pico -> cieto +PiCo -> Cieto +.pcs -> .cies +public C API symbol names +``` + +No opcode, runtime result, error classification, benchmark algorithm, or semantic output should change. + +--- + +# Phase 4: Git Review + +Check the final diff: + +```bash +git status --short +git diff --stat +git diff --check +git diff +``` + +The diff should consist only of: + +- file renames +- identifier renames +- build/install target renames +- extension updates +- user-facing branding updates +- directly related tests and documentation + +Reject and revert: + +- unrelated refactors +- whitespace-only rewrites +- mass formatter output +- architecture changes +- performance changes +- new features +- removed unrelated documentation +- speculative compatibility layers + +Commit only after all tests pass: + +```bash +git add -A +git commit -m "refactor: rename PiCo to Cieto" +``` + +Do not push or rename the GitHub repository unless explicitly requested. + +--- + +# Acceptance Criteria + +The rename is complete only when all conditions are true: + +- [ ] Project is branded **Cieto** +- [ ] CLI executable is `cieto` +- [ ] Source files use `.cies` +- [ ] Public C types use `Cie...` +- [ ] Public C functions use `cie_...` +- [ ] Public macros/constants use `CIE_...` +- [ ] Library is named `libcieto` +- [ ] Installed header uses the Cieto name +- [ ] Shebangs use `cieto` +- [ ] Module resolution recognizes `.cies` +- [ ] Existing tests pass +- [ ] Debug and release builds pass +- [ ] `--dump` works with `.cies` +- [ ] Installation produces the expected Cieto files +- [ ] Windows build still passes if previously supported +- [ ] No unintended `pico`, `PiCo`, `Pico`, `PICO`, or `.pcs` references remain +- [ ] No runtime semantics changed +- [ ] No bytecode semantics changed +- [ ] No unrelated files were modified +- [ ] No `systems_interview_notes.md` file was created +- [ ] The work is contained in one focused rename commit + +--- + +# Final Report Required from Codex + +After completing the work, report: + +1. The files and targets renamed +2. The public API mapping applied +3. The source-extension changes +4. The build and test commands run +5. The results of each validation step +6. Any intentionally retained old-name references and why +7. Any items that require manual GitHub-side changes + +Do not merely say “rename complete.” Include concrete evidence from the build, tests, searches, and final diff. diff --git a/README.md b/README.md index e7bcf60..ec53396 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ -# PiCo +# Cieto -A small, compact scripting language and virtual machine implemented in C. pico includes a compiler, virtual machine, REPL, and a set of core modules for working with values, objects, and I/O. +A compact C-family scripting language and embeddable register-based virtual machine implemented entirely in C. + +Cieto is inspired by the Latin verb *cieō*, “to set in motion.” ## Features @@ -13,12 +15,12 @@ A small, compact scripting language and virtual machine implemented in C. pico i - Small standard library - Manual / automatic GC modes -See the included `manual.md` for a detailed language reference and usage examples: [https://github.com/the0cp/pico/blob/master/manual.md](https://github.com/the0cp/pico/blob/master/manual.md) +See the included `manual.md` for a detailed language reference and usage examples: [https://github.com/the0cp/cieto/blob/master/manual.md](https://github.com/the0cp/cieto/blob/master/manual.md) ## What it looks like ```javascript -# A tiny PiCo demo: +# A tiny Cieto demo: func slug(s) { return s.trim().lower().replace(" ", "-"); @@ -46,7 +48,7 @@ for (var topic : topics) { } print "path: ${"examples" / "data" / "sample.txt"}"; -print "slice: ${"register-vm"[0:8]}, reverse: ${"PiCo"[::-1]}"; +print "slice: ${"register-vm"[0:8]}, reverse: ${"Cieto"[::-1]}"; $> echo hello from the host shell print "shell exit code = ${_exit_code}"; @@ -59,9 +61,9 @@ More examples are available in `examples/`. Try more examples: ```sh -./build/debug/pico examples/tour.pcs -./build/debug/pico examples/file_indexer.pcs -./build/debug/pico examples/modules/main.pcs +./build/debug/cieto examples/tour.cies +./build/debug/cieto examples/file_indexer.cies +./build/debug/cieto examples/modules/main.cies # ... ``` @@ -72,7 +74,7 @@ Requirements: gcc and CMake. The code uses GCC-specific techniques such as compu Clone the repo: ```sh -git clone --recursive https://github.com/the0cp/pico.git +git clone --recursive https://github.com/the0cp/cieto.git ``` Configure and build a debug version: @@ -99,14 +101,14 @@ cmake --build --preset release-windows The executable is generated under the corresponding build directory, for example: ```text -build/debug/pico -build/release/pico -build/release-windows/pico.exe +build/debug/cieto +build/release/cieto +build/release-windows/cieto.exe ``` ## Installing -Install PiCo to your local user prefix: +Install Cieto to your local user prefix: ```sh cmake --preset release @@ -120,7 +122,7 @@ Make sure `~/.local/bin` is in your PATH: export PATH="$HOME/.local/bin:$PATH" ``` -Then run PiCo from anywhere. +Then run Cieto from anywhere. To install system-wide: @@ -128,70 +130,70 @@ To install system-wide: sudo cmake --install build/release ``` -## Embedding PiCo in C +## Embedding Cieto in C -PiCo can also be used as an embedded scripting VM inside a C program. The host program owns a `PicoVM`, loads PiCo source code, registers native C functions, calls PiCo functions, and can capture script output and runtime errors. +Cieto can also be used as an embedded scripting VM inside a C program. The host program owns a `CieVM`, loads Cieto source code, registers native C functions, calls Cieto functions, and can capture script output and runtime errors. A minimal embedded program looks like this: ```c #include -#include +#include int main(void){ - PicoVM* vm = pico_vm_create(); + CieVM* vm = cie_vm_create(); if(vm == NULL){ return 1; } - PicoStatus status = pico_vm_eval(vm, + CieStatus status = cie_vm_eval(vm, "func add(a, b){ return a + b; }\n", "" ); - if(status != PICO_STATUS_OK){ - fprintf(stderr, "%s\n", pico_vm_last_error(vm)); - pico_vm_destroy(vm); + if(status != CIE_STATUS_OK){ + fprintf(stderr, "%s\n", cie_vm_last_error(vm)); + cie_vm_destroy(vm); return 1; } - PicoValue args[] = { - pico_value_number(20), - pico_value_number(22) + CieValue args[] = { + cie_value_number(20), + cie_value_number(22) }; - PicoValue result; - status = pico_vm_call(vm, "add", 2, args, &result); + CieValue result; + status = cie_vm_call(vm, "add", 2, args, &result); - if(status == PICO_STATUS_OK && result.type == PICO_VALUE_NUMBER){ + if(status == CIE_STATUS_OK && result.type == CIE_VALUE_NUMBER){ printf("%.14g\n", result.as.number); } - pico_vm_destroy(vm); - return status == PICO_STATUS_OK ? 0 : 1; + cie_vm_destroy(vm); + return status == CIE_STATUS_OK ? 0 : 1; } ``` -The third argument of `pico_vm_eval()` is a diagnostic source name. It does not need to be a real file path; names like `""` or `""` are useful for error messages. +The third argument of `cie_vm_eval()` is a diagnostic source name. It does not need to be a real file path; names like `""` or `""` are useful for error messages. The embedding API currently supports these core operations: -- `pico_vm_create()` / `pico_vm_destroy()` for VM lifetime management -- `pico_vm_eval()` for loading PiCo source code -- `pico_vm_register_native()` for exposing C functions to PiCo -- `pico_vm_call()` for calling global PiCo functions from C -- `pico_vm_set_output()` and `pico_vm_set_error_output()` for capturing `print` output and runtime error output -- `pico_vm_last_error()` for reading the latest compile or runtime error +- `cie_vm_create()` / `cie_vm_destroy()` for VM lifetime management +- `cie_vm_eval()` for loading Cieto source code +- `cie_vm_register_native()` for exposing C functions to Cieto +- `cie_vm_call()` for calling global Cieto functions from C +- `cie_vm_set_output()` and `cie_vm_set_error_output()` for capturing `print` output and runtime error output +- `cie_vm_last_error()` for reading the latest compile or runtime error More complete examples are in `examples/embedding/`. -### Linking against an installed libpico +### Linking against an installed libcieto -After installation, an external C program can include `pico.h` and link against `libpico.a`: +After installation, an external C program can include `cieto.h` and link against `libcieto.a`: ```sh -gcc main.c -I /path/to/pico/include -L /path/to/pico/lib -lpico -lm -o embed_app +gcc main.c -I /path/to/cieto/include -L /path/to/cieto/lib -lcieto -lm -o embed_app ``` On Windows with MinGW, the command is the same except paths usually point to the local install prefix, for example: @@ -200,7 +202,7 @@ On Windows with MinGW, the command is the same except paths usually point to the gcc .\main.c ` -I .\install-debug\include ` -L .\install-debug\lib ` - -lpico ` + -lcieto ` -lm ` -o .\embed_app.exe ``` @@ -224,19 +226,19 @@ ctest --preset release --output-on-failure Run the interactive REPL: ```sh -pico +cieto ``` Run a script: ```sh -pico path/to/script.pcs +cieto path/to/script.cies ``` -Pico scripts can also be executed directly with a Unix shebang: +Cieto scripts can also be executed directly with a Unix shebang: ```sh -#!/usr/bin/env pico +#!/usr/bin/env cieto print("hello from Shebang"); ``` @@ -244,8 +246,8 @@ print("hello from Shebang"); Make it executable and run it: ```sh -chmod +x hello.pcs -./hello.pcs +chmod +x hello.cies +./hello.cies ``` Check `manual.md` for language syntax, built-in functions, and examples. diff --git a/api/pico.c b/api/cieto.c similarity index 62% rename from api/pico.c rename to api/cieto.c index 25a6e1e..3d172be 100644 --- a/api/pico.c +++ b/api/cieto.c @@ -1,4 +1,4 @@ -#include "pico.h" +#include "cieto.h" #include #include @@ -9,24 +9,24 @@ #include "value.h" #include "vm.h" -struct PicoCall{ +struct CieCall{ VM* vm; int argCount; Value* args; Value result; }; -static PicoStatus mapInterpreterStatus(InterpreterStatus status){ +static CieStatus mapInterpreterStatus(InterpreterStatus status){ switch(status){ case VM_OK: - return PICO_STATUS_OK; + return CIE_STATUS_OK; case VM_COMPILE_ERROR: - return PICO_STATUS_COMPILE_ERROR; + return CIE_STATUS_COMPILE_ERROR; case VM_RUNTIME_ERROR: - return PICO_STATUS_RUNTIME_ERROR; + return CIE_STATUS_RUNTIME_ERROR; } - return PICO_STATUS_RUNTIME_ERROR; + return CIE_STATUS_RUNTIME_ERROR; } static Value callHostFunc(VM* vm, int argCount, Value* args){ @@ -45,7 +45,7 @@ static Value callHostFunc(VM* vm, int argCount, Value* args){ return NULL_VAL; } - PicoCall call = { + CieCall call = { .vm = vm, .argCount = argCount, .args = args, @@ -57,11 +57,11 @@ static Value callHostFunc(VM* vm, int argCount, Value* args){ return call.result; } -static bool isValidArgIndex(const PicoCall* call, int index){ +static bool isValidArgIndex(const CieCall* call, int index){ return call != NULL && index >= 0 && index < call->argCount; } -static void setCallResult(PicoCall* call, Value value){ +static void setCallResult(CieCall* call, Value value){ if(call == NULL){ return; } @@ -69,23 +69,23 @@ static void setCallResult(PicoCall* call, Value value){ call->result = value; } -static bool toInternalValue(const PicoValue* publicValue, Value* internalValue){ +static bool toInternalValue(const CieValue* publicValue, Value* internalValue){ if(publicValue == NULL || internalValue == NULL){ return false; } switch(publicValue->type){ - case PICO_VALUE_NULL: + case CIE_VALUE_NULL: *internalValue = NULL_VAL; return true; - case PICO_VALUE_BOOL: + case CIE_VALUE_BOOL: *internalValue = BOOL_VAL(publicValue->as.boolean); return true; - case PICO_VALUE_NUMBER: + case CIE_VALUE_NUMBER: *internalValue = NUM_VAL(publicValue->as.number); return true; - case PICO_VALUE_STRING: - case PICO_VALUE_OTHER: + case CIE_VALUE_STRING: + case CIE_VALUE_OTHER: default: return false; } @@ -93,31 +93,31 @@ static bool toInternalValue(const PicoValue* publicValue, Value* internalValue){ return false; } -static bool fromInternalValue(Value internalValue, PicoValue* publicValue){ +static bool fromInternalValue(Value internalValue, CieValue* publicValue){ if(publicValue == NULL){ return false; } if(IS_NULL(internalValue)){ - *publicValue = pico_value_null(); + *publicValue = cie_value_null(); return true; } if(IS_BOOL(internalValue)){ - *publicValue = pico_value_bool(AS_BOOL(internalValue)); + *publicValue = cie_value_bool(AS_BOOL(internalValue)); return true; } if(IS_NUM(internalValue)){ - *publicValue = pico_value_number(AS_NUM(internalValue)); + *publicValue = cie_value_number(AS_NUM(internalValue)); return true; } - publicValue->type = PICO_VALUE_OTHER; + publicValue->type = CIE_VALUE_OTHER; return false; } -static PicoStatus setApiError(PicoVM* vm, PicoStatus status, const char* message){ +static CieStatus setApiError(CieVM* vm, CieStatus status, const char* message){ if(vm != NULL && message != NULL){ snprintf(vm->lastError, sizeof(vm->lastError), "%s", message); } @@ -125,34 +125,34 @@ static PicoStatus setApiError(PicoVM* vm, PicoStatus status, const char* message return status; } -PicoValue pico_value_null(void){ - PicoValue value = { - .type = PICO_VALUE_NULL +CieValue cie_value_null(void){ + CieValue value = { + .type = CIE_VALUE_NULL }; return value; } -PicoValue pico_value_bool(bool value){ - PicoValue result = { - .type = PICO_VALUE_BOOL, +CieValue cie_value_bool(bool value){ + CieValue result = { + .type = CIE_VALUE_BOOL, .as.boolean = value }; return result; } -PicoValue pico_value_number(double value){ - PicoValue result = { - .type = PICO_VALUE_NUMBER, +CieValue cie_value_number(double value){ + CieValue result = { + .type = CIE_VALUE_NUMBER, .as.number = value }; return result; } -PicoVM* pico_vm_create(void){ - PicoVM* vm = malloc(sizeof(*vm)); +CieVM* cie_vm_create(void){ + CieVM* vm = malloc(sizeof(*vm)); if(vm == NULL){ return NULL; @@ -170,7 +170,7 @@ PicoVM* pico_vm_create(void){ return vm; } -void pico_vm_destroy(PicoVM* vm){ +void cie_vm_destroy(CieVM* vm){ if(vm == NULL){ return; } @@ -179,13 +179,13 @@ void pico_vm_destroy(PicoVM* vm){ free(vm); } -PicoStatus pico_vm_eval( - PicoVM* vm, +CieStatus cie_vm_eval( + CieVM* vm, const char* source, const char* source_name ){ if(vm == NULL || source == NULL){ - return PICO_STATUS_INVALID_ARGUMENT; + return CIE_STATUS_INVALID_ARGUMENT; } if(source_name == NULL){ @@ -196,7 +196,7 @@ PicoStatus pico_vm_eval( return mapInterpreterStatus(status); } -int pico_call_arg_count(const PicoCall* call){ +int cie_call_arg_count(const CieCall* call){ if(call == NULL){ return 0; } @@ -204,7 +204,7 @@ int pico_call_arg_count(const PicoCall* call){ return call->argCount; } -void pico_vm_set_output(PicoVM* vm, PicoWriteFunc func, void* userData){ +void cie_vm_set_output(CieVM* vm, CieWriteFunc func, void* userData){ if(vm == NULL){ return; } @@ -213,7 +213,7 @@ void pico_vm_set_output(PicoVM* vm, PicoWriteFunc func, void* userData){ vm->output.userData = userData; } -void pico_vm_set_error_output(PicoVM* vm, PicoWriteFunc func, void* userData){ +void cie_vm_set_error_output(CieVM* vm, CieWriteFunc func, void* userData){ if(vm == NULL){ return; } @@ -222,33 +222,33 @@ void pico_vm_set_error_output(PicoVM* vm, PicoWriteFunc func, void* userData){ vm->errOutput.userData = userData; } -PicoValueType pico_call_arg_type(const PicoCall* call, int index){ +CieValueType cie_call_arg_type(const CieCall* call, int index){ if(!isValidArgIndex(call, index)){ - return PICO_VALUE_OTHER; + return CIE_VALUE_OTHER; } Value value = call->args[index]; if(IS_NULL(value)){ - return PICO_VALUE_NULL; + return CIE_VALUE_NULL; } if(IS_BOOL(value)){ - return PICO_VALUE_BOOL; + return CIE_VALUE_BOOL; } if(IS_NUM(value)){ - return PICO_VALUE_NUMBER; + return CIE_VALUE_NUMBER; } if(IS_STRING(value)){ - return PICO_VALUE_STRING; + return CIE_VALUE_STRING; } - return PICO_VALUE_OTHER; + return CIE_VALUE_OTHER; } -bool pico_call_get_bool(const PicoCall* call, int index, bool* result){ +bool cie_call_get_bool(const CieCall* call, int index, bool* result){ if(result == NULL || !isValidArgIndex(call, index)){ return false; } @@ -263,7 +263,7 @@ bool pico_call_get_bool(const PicoCall* call, int index, bool* result){ return true; } -bool pico_call_get_number(const PicoCall* call, int index, double* result){ +bool cie_call_get_number(const CieCall* call, int index, double* result){ if(result == NULL || !isValidArgIndex(call, index)){ return false; } @@ -278,7 +278,7 @@ bool pico_call_get_number(const PicoCall* call, int index, double* result){ return true; } -const char* pico_call_get_string(const PicoCall* call, int index, size_t* length){ +const char* cie_call_get_string(const CieCall* call, int index, size_t* length){ if(!isValidArgIndex(call, index)){ return NULL; } @@ -298,30 +298,30 @@ const char* pico_call_get_string(const PicoCall* call, int index, size_t* length return string->chars; } -void pico_call_return_null(PicoCall* call){ +void cie_call_return_null(CieCall* call){ setCallResult(call, NULL_VAL); } -void pico_call_return_bool(PicoCall* call, bool value){ +void cie_call_return_bool(CieCall* call, bool value){ setCallResult(call, BOOL_VAL(value)); } -void pico_call_return_number(PicoCall* call, double value){ +void cie_call_return_number(CieCall* call, double value){ setCallResult(call, NUM_VAL(value)); } -void pico_call_return_string(PicoCall* call, const char* value, size_t length){ +void cie_call_return_string(CieCall* call, const char* value, size_t length){ if(call == NULL){ return; } if(value == NULL){ - pico_call_error(call, "Host function returned a null string pointer."); + cie_call_error(call, "Host function returned a null string pointer."); return; } if(length > INT_MAX){ - pico_call_error(call, "Host function returned a string that is too large."); + cie_call_error(call, "Host function returned a string that is too large."); return; } @@ -330,7 +330,7 @@ void pico_call_return_string(PicoCall* call, const char* value, size_t length){ setCallResult(call, OBJECT_VAL(string)); } -void pico_call_error(PicoCall* call, const char* message){ +void cie_call_error(CieCall* call, const char* message){ if(call == NULL){ return; } @@ -344,9 +344,9 @@ void pico_call_error(PicoCall* call, const char* message){ setCallResult(call, NULL_VAL); } -PicoStatus pico_vm_register_native(PicoVM* vm, const char* name, PicoNativeFunc function, void* user_data){ +CieStatus cie_vm_register_native(CieVM* vm, const char* name, CieNativeFunc function, void* user_data){ if(vm == NULL || name == NULL || name[0] == '\0' || function == NULL){ - return PICO_STATUS_INVALID_ARGUMENT; + return CIE_STATUS_INVALID_ARGUMENT; } ObjectString* key = copyString(vm, name, (int)strlen(name)); @@ -364,35 +364,35 @@ PicoStatus pico_vm_register_native(PicoVM* vm, const char* name, PicoNativeFunc pop(vm); if(!success){ - return PICO_STATUS_RUNTIME_ERROR; + return CIE_STATUS_RUNTIME_ERROR; } - return PICO_STATUS_OK; + return CIE_STATUS_OK; } -PicoStatus pico_vm_call( - PicoVM* vm, - const char* name, +CieStatus cie_vm_call( + CieVM* vm, + const char* name, int argCount, - const PicoValue* args, - PicoValue* result + const CieValue* args, + CieValue* result ){ if(vm == NULL || name == NULL || name[0] == '\0' || argCount < 0){ - return PICO_STATUS_INVALID_ARGUMENT; + return CIE_STATUS_INVALID_ARGUMENT; } if(argCount > 0 && args == NULL){ - return PICO_STATUS_INVALID_ARGUMENT; + return CIE_STATUS_INVALID_ARGUMENT; } if(vm->frameCount != 0){ - return setApiError(vm, PICO_STATUS_RUNTIME_ERROR, "PiCo VM calls are not reentrant."); + return setApiError(vm, CIE_STATUS_RUNTIME_ERROR, "Cieto VM calls are not reentrant."); } size_t nameLength = strlen(name); if(nameLength > INT_MAX){ - return setApiError(vm, PICO_STATUS_INVALID_ARGUMENT, "PiCo function name is too long."); + return setApiError(vm, CIE_STATUS_INVALID_ARGUMENT, "Cieto function name is too long."); } vm->lastError[0] = '\0'; @@ -407,7 +407,7 @@ PicoStatus pico_vm_call( if(!found){ snprintf(vm->lastError, sizeof(vm->lastError), "Global function '%s' is not defined.", name); - return PICO_STATUS_RUNTIME_ERROR; + return CIE_STATUS_RUNTIME_ERROR; } Value* internalArgs = NULL; @@ -416,14 +416,14 @@ PicoStatus pico_vm_call( internalArgs = malloc(sizeof(Value) * (size_t)argCount); if(internalArgs == NULL){ - return setApiError(vm, PICO_STATUS_OUT_OF_MEMORY, "Could not allocate PiCo call arguments."); + return setApiError(vm, CIE_STATUS_OUT_OF_MEMORY, "Could not allocate Cieto call arguments."); } } for(int i = 0; i < argCount; i++){ if(!toInternalValue(&args[i], &internalArgs[i])){ free(internalArgs); - return setApiError(vm, PICO_STATUS_UNSUPPORTED_TYPE, "Arguments contain unsupported value types."); + return setApiError(vm, CIE_STATUS_UNSUPPORTED_TYPE, "Arguments contain unsupported value types."); } } @@ -437,17 +437,17 @@ PicoStatus pico_vm_call( } if(result == NULL){ - return PICO_STATUS_OK; + return CIE_STATUS_OK; } if(!fromInternalValue(internalResult, result)){ - return setApiError(vm, PICO_STATUS_UNSUPPORTED_TYPE, "PiCo function returned an unsupported value type."); + return setApiError(vm, CIE_STATUS_UNSUPPORTED_TYPE, "Cieto function returned an unsupported value type."); } - return PICO_STATUS_OK; + return CIE_STATUS_OK; } -const char* pico_vm_last_error(const PicoVM* vm){ +const char* cie_vm_last_error(const CieVM* vm){ if(vm == NULL || vm->lastError[0] == '\0'){ return NULL; } @@ -455,21 +455,21 @@ const char* pico_vm_last_error(const PicoVM* vm){ return vm->lastError; } -const char* pico_status_string(PicoStatus status){ +const char* cie_status_string(CieStatus status){ switch(status){ - case PICO_STATUS_OK: + case CIE_STATUS_OK: return "OK"; - case PICO_STATUS_COMPILE_ERROR: + case CIE_STATUS_COMPILE_ERROR: return "compile error"; - case PICO_STATUS_RUNTIME_ERROR: + case CIE_STATUS_RUNTIME_ERROR: return "runtime error"; - case PICO_STATUS_INVALID_ARGUMENT: + case CIE_STATUS_INVALID_ARGUMENT: return "invalid argument"; - case PICO_STATUS_OUT_OF_MEMORY: + case CIE_STATUS_OUT_OF_MEMORY: return "out of memory"; - case PICO_STATUS_UNSUPPORTED_TYPE: + case CIE_STATUS_UNSUPPORTED_TYPE: return "unsupported type"; } return "unknown status"; -} \ No newline at end of file +} diff --git a/benchmarks/bench_arithmetic_loop.pcs b/benchmarks/bench_arithmetic_loop.cies similarity index 100% rename from benchmarks/bench_arithmetic_loop.pcs rename to benchmarks/bench_arithmetic_loop.cies diff --git a/benchmarks/bench_function_calls.pcs b/benchmarks/bench_function_calls.cies similarity index 100% rename from benchmarks/bench_function_calls.pcs rename to benchmarks/bench_function_calls.cies diff --git a/benchmarks/bench_gc_churn.pcs b/benchmarks/bench_gc_churn.cies similarity index 100% rename from benchmarks/bench_gc_churn.pcs rename to benchmarks/bench_gc_churn.cies diff --git a/benchmarks/bench_list_ops.pcs b/benchmarks/bench_list_ops.cies similarity index 100% rename from benchmarks/bench_list_ops.pcs rename to benchmarks/bench_list_ops.cies diff --git a/benchmarks/bench_map_ops.pcs b/benchmarks/bench_map_ops.cies similarity index 100% rename from benchmarks/bench_map_ops.pcs rename to benchmarks/bench_map_ops.cies diff --git a/benchmarks/bench_object_dispatch.pcs b/benchmarks/bench_object_dispatch.cies similarity index 100% rename from benchmarks/bench_object_dispatch.pcs rename to benchmarks/bench_object_dispatch.cies diff --git a/benchmarks/bench_string_gc_stats.pcs b/benchmarks/bench_string_gc_stats.cies similarity index 93% rename from benchmarks/bench_string_gc_stats.pcs rename to benchmarks/bench_string_gc_stats.cies index 2c661e1..30f978e 100644 --- a/benchmarks/bench_string_gc_stats.pcs +++ b/benchmarks/bench_string_gc_stats.cies @@ -3,7 +3,7 @@ import "gc"; var total = 0; for (var i = 0; i < 200000; i++) { - var s = "pico-" + i + "-runtime-benchmark"; + var s = "cieto-" + i + "-runtime-benchmark"; total = total + s.len(); total = total + s.find("runtime"); diff --git a/benchmarks/bench_string_ops.pcs b/benchmarks/bench_string_ops.cies similarity index 85% rename from benchmarks/bench_string_ops.pcs rename to benchmarks/bench_string_ops.cies index d81fe7f..09ebf51 100644 --- a/benchmarks/bench_string_ops.pcs +++ b/benchmarks/bench_string_ops.cies @@ -1,7 +1,7 @@ var total = 0; for (var i = 0; i < 200000; i++) { - var s = "pico-" + i + "-runtime-benchmark"; + var s = "cieto-" + i + "-runtime-benchmark"; total = total + s.len(); total = total + s.find("runtime"); diff --git a/cmd/main.c b/cmd/main.c index c16d8aa..b4e60a2 100644 --- a/cmd/main.c +++ b/cmd/main.c @@ -5,25 +5,25 @@ #include "version.h" static void printVersion(void){ - printf("PiCo %s\n", PICO_VERSION); + printf("Cieto %s\n", CIETO_VERSION); } static void printHelp(const char* programName){ - printf("PiCo %s\n", PICO_VERSION); + printf("Cieto %s\n", CIETO_VERSION); printf("\n"); - printf("A small register-based scripting language and virtual machine written in C.\n"); + printf("A compact C-family scripting language and embeddable register-based virtual machine implemented entirely in C.\n"); printf("\n"); printf("Usage:\n"); printf(" %s Start the REPL\n", programName); - printf(" %s [args...] Run a script\n", programName); - printf(" %s run [args...] Run a script\n", programName); - printf(" %s --dump, -d Compile and dump bytecode\n", programName); + printf(" %s [args...] Run a script\n", programName); + printf(" %s run [args...] Run a script\n", programName); + printf(" %s --dump, -d Compile and dump bytecode\n", programName); printf(" %s --help Show this help message\n", programName); printf(" %s --version Show version information\n", programName); printf("\n"); printf("Examples:\n"); - printf(" %s examples/tour.pcs\n", programName); - printf(" %s examples/argv_echo.pcs hello world\n", programName); + printf(" %s examples/tour.cies\n", programName); + printf(" %s examples/argv_echo.cies hello world\n", programName); } int main(int argc, const char* argv[]){ @@ -77,4 +77,4 @@ int main(int argc, const char* argv[]){ freeVM(&vm); return 0; -} \ No newline at end of file +} diff --git a/cmd/repl.c b/cmd/repl.c index 9dc3ec5..4b25369 100644 --- a/cmd/repl.c +++ b/cmd/repl.c @@ -30,7 +30,7 @@ void completion(const char *buf, linenoiseCompletions *lc){ void repl(VM* vm){ #ifdef _WIN32 char line[1024]; - printf("PiCo REPL. Press Ctrl+C to exit.\n"); + printf("Cieto REPL. Press Ctrl+C to exit.\n"); while(true){ printf(">>> "); @@ -50,13 +50,13 @@ void repl(VM* vm){ } #else char* line; - const char* his = ".pico_history"; + const char* his = ".cieto_history"; linenoiseSetCompletionCallback(completion); linenoiseHistorySetMaxLen(100); linenoiseHistoryLoad(his); - printf("PiCo REPL. Press Ctrl+C to exit.\n"); + printf("Cieto REPL. Press Ctrl+C to exit.\n"); while((line = linenoise(">>> ")) != NULL){ if(line[0] != '\0'){ diff --git a/cmd/repl.h b/cmd/repl.h index f35a9e3..e1407f3 100644 --- a/cmd/repl.h +++ b/cmd/repl.h @@ -1,5 +1,5 @@ -#ifndef PICO_REPL_H -#define PICO_REPL_H +#ifndef CIETO_REPL_H +#define CIETO_REPL_H #include #include @@ -9,4 +9,4 @@ typedef struct VM VM; void repl(VM* vm); -#endif // PICO_REPL_H \ No newline at end of file +#endif // CIETO_REPL_H \ No newline at end of file diff --git a/compiler/compiler.h b/compiler/compiler.h index 2b23e8d..1eb10e1 100644 --- a/compiler/compiler.h +++ b/compiler/compiler.h @@ -1,5 +1,5 @@ -#ifndef PICO_COMPILER_H -#define PICO_COMPILER_H +#ifndef CIETO_COMPILER_H +#define CIETO_COMPILER_H #include "vm.h" #include "scanner.h" @@ -165,4 +165,4 @@ static void systemStmt(Compiler* compiler); static void deferStmt(Compiler* compiler); static void returnStmt(Compiler* compiler); -#endif // PICO_COMPILER_H \ No newline at end of file +#endif // CIETO_COMPILER_H \ No newline at end of file diff --git a/compiler/scanner.c b/compiler/scanner.c index 12125e8..943d21d 100644 --- a/compiler/scanner.c +++ b/compiler/scanner.c @@ -111,7 +111,7 @@ static inline void handleBlockComment(){ static bool handleComment(){ if(*sc.cur == '#'){ // This also supports Unix shebang lines, - // e.g. "#!/usr/bin/env pico". + // e.g. "#!/usr/bin/env cieto". if(sc.cur[1] == '{'){ handleBlockComment(); }else{ diff --git a/compiler/scanner.h b/compiler/scanner.h index 9466861..f32a602 100644 --- a/compiler/scanner.h +++ b/compiler/scanner.h @@ -1,5 +1,5 @@ -#ifndef PICO_SCANNER_H -#define PICO_SCANNER_H +#ifndef CIETO_SCANNER_H +#define CIETO_SCANNER_H #include @@ -83,4 +83,4 @@ static inline Token handleIdentifier(); static inline bool isDigit(char c); static inline bool isAlpha(char c); -#endif // PICO_SCANNER_H \ No newline at end of file +#endif // CIETO_SCANNER_H \ No newline at end of file diff --git a/core/chunk.h b/core/chunk.h index 92b6aea..5f23ab5 100644 --- a/core/chunk.h +++ b/core/chunk.h @@ -1,5 +1,5 @@ -#ifndef PICO_CHUNK_H -#define PICO_CHUNK_H +#ifndef CIETO_CHUNK_H +#define CIETO_CHUNK_H #include "common.h" #include "value.h" @@ -21,4 +21,4 @@ void freeChunk(VM* vm, Chunk* chunk); int addConstant(VM* vm, Chunk* chunk, Value value); -#endif // PICO_CHUNK_H \ No newline at end of file +#endif // CIETO_CHUNK_H \ No newline at end of file diff --git a/core/common.h b/core/common.h index 9f75077..473e1f5 100644 --- a/core/common.h +++ b/core/common.h @@ -1,5 +1,5 @@ -#ifndef PICO_COMMON_H -#define PICO_COMMON_H +#ifndef CIETO_COMMON_H +#define CIETO_COMMON_H #include #include @@ -10,4 +10,4 @@ // #define DEBUG_STRESS_GC // #define GC_LOG_ALLOC -#endif // PICO_COMMON_H +#endif // CIETO_COMMON_H diff --git a/core/gc_policy.h b/core/gc_policy.h index 9fafeae..e9e4ad3 100644 --- a/core/gc_policy.h +++ b/core/gc_policy.h @@ -1,5 +1,5 @@ -#ifndef PICO_GC_POLICY_H -#define PICO_GC_POLICY_H +#ifndef CIETO_GC_POLICY_H +#define CIETO_GC_POLICY_H #include #include @@ -34,4 +34,4 @@ void gcWriteBarrier(VM* vm, Object* owner, Value value); bool gcMarkSweep(VM* vm, GCReason reason); -#endif // PICO_GC_POLICY_H \ No newline at end of file +#endif // CIETO_GC_POLICY_H \ No newline at end of file diff --git a/core/gc_types.h b/core/gc_types.h index b764eeb..60f9600 100644 --- a/core/gc_types.h +++ b/core/gc_types.h @@ -1,5 +1,5 @@ -#ifndef PICO_GC_TYPES_H -#define PICO_GC_TYPES_H +#ifndef CIETO_GC_TYPES_H +#define CIETO_GC_TYPES_H typedef enum{ GC_REASON_THRESHOLD, @@ -14,4 +14,4 @@ typedef enum{ GC_MODE_OFF }GCMode; -#endif // PICO_GC_TYPES_H \ No newline at end of file +#endif // CIETO_GC_TYPES_H \ No newline at end of file diff --git a/core/hashtable.h b/core/hashtable.h index 1c70062..268d20a 100644 --- a/core/hashtable.h +++ b/core/hashtable.h @@ -1,5 +1,5 @@ -#ifndef PICO_HASHTABLE_H -#define PICO_HASHTABLE_H +#ifndef CIETO_HASHTABLE_H +#define CIETO_HASHTABLE_H #include "common.h" #include "value.h" diff --git a/core/mem.h b/core/mem.h index b1d79c8..cb96961 100644 --- a/core/mem.h +++ b/core/mem.h @@ -1,5 +1,5 @@ -#ifndef PICO_MEM_H -#define PICO_MEM_H +#ifndef CIETO_MEM_H +#define CIETO_MEM_H #include "common.h" #include "vm.h" diff --git a/core/object.h b/core/object.h index 0dc27df..acaaa54 100644 --- a/core/object.h +++ b/core/object.h @@ -1,5 +1,5 @@ -#ifndef PICO_OBJECT_H -#define PICO_OBJECT_H +#ifndef CIETO_OBJECT_H +#define CIETO_OBJECT_H #include #include @@ -13,9 +13,9 @@ typedef struct VM VM; typedef Value (*CFunc)(VM* vm, int argCount, Value* args); -typedef struct PicoCall PicoCall; +typedef struct CieCall CieCall; -typedef void (*HostCFunc)(PicoCall* call, void* userData); +typedef void (*HostCFunc)(CieCall* call, void* userData); #define OBJECT_TYPE(value) (AS_OBJECT(value)->type) @@ -234,4 +234,4 @@ void objectWrite(Value value, Writer* writer); void freeObject(VM* vm, Object* object); void freeObjects(VM* vm); -#endif // PICO_OBJECT_H +#endif // CIETO_OBJECT_H diff --git a/core/value.c b/core/value.c index 2c4425e..3396391 100644 --- a/core/value.c +++ b/core/value.c @@ -1,4 +1,4 @@ -#define PICO_MAX_SAFE_INT 9007199254740991.0 +#define CIETO_MAX_SAFE_INT 9007199254740991.0 #include @@ -30,14 +30,14 @@ int numToString(double num, char* out, size_t cap){ return 1; } - if(num > 0.0 && num <= PICO_MAX_SAFE_INT){ + if(num > 0.0 && num <= CIETO_MAX_SAFE_INT){ uint64_t n = (uint64_t)num; if((double)n == num){ return u64ToString(n, out); } } - if(num < 0.0 && num >= -PICO_MAX_SAFE_INT){ + if(num < 0.0 && num >= -CIETO_MAX_SAFE_INT){ uint64_t n = (uint64_t)(-num); if((double)(-n) == num){ out[0] = '-'; diff --git a/core/value.h b/core/value.h index 46860a1..b3c4181 100644 --- a/core/value.h +++ b/core/value.h @@ -1,5 +1,5 @@ -#ifndef PICO_VALUE_H -#define PICO_VALUE_H +#ifndef CIE_VALUE_H +#define CIE_VALUE_H #include @@ -74,4 +74,4 @@ void valueWrite(Value value, Writer* writer); ValueType getValueType(Value value); bool isEqual(Value a, Value b); -#endif // PICO_VALUE_H \ No newline at end of file +#endif // CIE_VALUE_H \ No newline at end of file diff --git a/core/version.h b/core/version.h index 06da280..88e2db1 100644 --- a/core/version.h +++ b/core/version.h @@ -1,6 +1,6 @@ -#ifndef PICO_VERSION_H -#define PICO_VERSION_H +#ifndef CIETO_VERSION_H +#define CIETO_VERSION_H -#define PICO_VERSION "0.2.0" +#define CIETO_VERSION "0.2.0" -#endif // PICO_VERSION_H \ No newline at end of file +#endif // CIETO_VERSION_H \ No newline at end of file diff --git a/core/writer.h b/core/writer.h index 3b3a745..327b5e7 100644 --- a/core/writer.h +++ b/core/writer.h @@ -1,5 +1,5 @@ -#ifndef PICO_WRITER_H -#define PICO_WRITER_H +#ifndef CIETO_WRITER_H +#define CIETO_WRITER_H #include @@ -14,4 +14,4 @@ void writerW(Writer* writer, const char* text, size_t length); void writerWCString(Writer* writer, const char* text); void writerWFormat(Writer* writer, const char* format, ...); -#endif // PICO_WRITER_H \ No newline at end of file +#endif // CIETO_WRITER_H \ No newline at end of file diff --git a/examples/argv_echo.pcs b/examples/argv_echo.cies similarity index 78% rename from examples/argv_echo.pcs rename to examples/argv_echo.cies index 4a4c455..8537282 100644 --- a/examples/argv_echo.pcs +++ b/examples/argv_echo.cies @@ -1,5 +1,5 @@ # Run with extra arguments, for example: -# pico examples/argv_echo.pcs hello PiCo 123 +# cieto examples/argv_echo.cies hello Cieto 123 import "os"; diff --git a/examples/data/sample.txt b/examples/data/sample.txt index f48f5a1..889a1a8 100644 --- a/examples/data/sample.txt +++ b/examples/data/sample.txt @@ -1,3 +1,3 @@ -PiCo is a tiny language with a register VM. +Cieto is a tiny language with a register VM. The VM runs bytecode. The language has lists, maps, strings, modules, files, and classes. -PiCo is small enough to study but useful enough to run examples. +Cieto is small enough to study but useful enough to run examples. diff --git a/examples/defer_file.pcs b/examples/defer_file.cies similarity index 92% rename from examples/defer_file.pcs rename to examples/defer_file.cies index 5469990..32efd7f 100644 --- a/examples/defer_file.pcs +++ b/examples/defer_file.cies @@ -7,7 +7,7 @@ func writeLog(path) { var f = fs.open(path, "w"); defer f.close(); - f.write("PiCo log file\n"); + f.write("Cieto log file\n"); f.write("created at: ${time.fmt(time.clock())}\n"); f.write("defer will close this file handle automatically\n"); } diff --git a/examples/embedding/README.md b/examples/embedding/README.md index a9683c4..3a28d32 100644 --- a/examples/embedding/README.md +++ b/examples/embedding/README.md @@ -1,29 +1,29 @@ # Embedding examples -These examples show how to use PiCo as an embedded scripting VM from C. +These examples show how to use Cieto as an embedded scripting VM from C. -- `basic.c`: create a VM and evaluate PiCo source code. -- `native_function.c`: expose a C function to PiCo. -- `call_script.c`: call a PiCo function from C and let the PiCo function call back into C. +- `basic.c`: create a VM and evaluate Cieto source code. +- `native_function.c`: expose a C function to Cieto. +- `call_script.c`: call a Cieto function from C and let the Cieto function call back into C. ## `basic.c` -Creates a VM, evaluates a PiCo source string, and destroys the VM. +Creates a VM, evaluates a Cieto source string, and destroys the VM. ```sh -cmake --build --preset debug --target pico_embed_basic -./build/debug/pico_embed_basic +cmake --build --preset debug --target cieto_embed_basic +./build/debug/cieto_embed_basic ``` ## `native_function.c` -Registers a C function and calls it from PiCo. +Registers a C function and calls it from Cieto. ```c -pico_vm_register_native(vm, "hostAdd", hostAdd, NULL); +cie_vm_register_native(vm, "hostAdd", hostAdd, NULL); ``` -PiCo can then call it as a normal function: +Cieto can then call it as a normal function: ```javascript print hostAdd(20, 22); @@ -31,39 +31,39 @@ print hostAdd(20, 22); ## `call_script.c` -Loads a PiCo function and calls it from C. The PiCo function calls back into a native C function. +Loads a Cieto function and calls it from C. The Cieto function calls back into a native C function. This demonstrates the full embedding loop: ```text -C -> PiCo -> C -> PiCo -> C +C -> Cieto -> C -> Cieto -> C ``` ## `external-cmake/` -A minimal standalone CMake project that links against an installed `libpico.a`. +A minimal standalone CMake project that links against an installed `libcieto.a`. -After installing PiCo into a local prefix, configure it with: +After installing Cieto into a local prefix, configure it with: ```sh -cmake -S examples/embedding/external-cmake -B build/external-pico -DPICO_ROOT=/path/to/pico/install -cmake --build build/external-pico +cmake -S examples/embedding/external-cmake -B build/external-cieto -DCIETO_ROOT=/path/to/cieto/install +cmake --build build/external-cieto ``` On Windows PowerShell, for a local debug install: ```powershell -cmake -S .\examples\embedding\external-cmake -B .\build\external-pico -DPICO_ROOT="$PWD\install-debug" -cmake --build .\build\external-pico -.\build\external-pico\embed_app.exe +cmake -S .\examples\embedding\external-cmake -B .\build\external-cieto -DCIETO_ROOT="$PWD\install-debug" +cmake --build .\build\external-cieto +.\build\external-cieto\embed_app.exe ``` ## Source names -The third argument of `pico_vm_eval()` is a diagnostic name: +The third argument of `cie_vm_eval()` is a diagnostic name: ```c -pico_vm_eval(vm, source, "