├── rustfmt.toml ├── crosscut ├── src │ ├── util │ │ ├── mod.rs │ │ └── form.rs │ ├── language │ │ ├── editor │ │ │ ├── tests │ │ │ │ └── mod.rs │ │ │ ├── input.rs │ │ │ └── mod.rs │ │ ├── compiler │ │ │ ├── mod.rs │ │ │ └── expression.rs │ │ ├── tests │ │ │ ├── mod.rs │ │ │ ├── math.rs │ │ │ ├── infra.rs │ │ │ └── commands.rs │ │ ├── mod.rs │ │ ├── runtime │ │ │ ├── mod.rs │ │ │ ├── effect.rs │ │ │ └── state.rs │ │ └── code │ │ │ ├── nodes_uniform │ │ │ ├── mod.rs │ │ │ ├── nodes.rs │ │ │ └── located.rs │ │ │ ├── nodes_typed │ │ │ ├── mod.rs │ │ │ ├── binding.rs │ │ │ └── tuple.rs │ │ │ ├── mod.rs │ │ │ └── types.rs │ ├── game_engine │ │ ├── editor │ │ │ └── mod.rs │ │ ├── graphics │ │ │ ├── mod.rs │ │ │ ├── shader.wgsl │ │ │ └── background.rs │ │ ├── mod.rs │ │ └── camera.rs │ ├── main.rs │ ├── terminal │ │ └── mod.rs │ └── lib.rs └── Cargo.toml ├── clippy.toml ├── archive └── prototypes │ ├── 10 │ ├── .gitignore │ ├── capi-debug │ │ ├── tailwind.css │ │ ├── tailwind.config.js │ │ ├── src │ │ │ └── components │ │ │ │ ├── mod.rs │ │ │ │ └── panel.rs │ │ ├── index.html │ │ └── Cargo.toml │ ├── capi-runtime │ │ ├── src │ │ │ ├── runtime.rs │ │ │ ├── debugger │ │ │ │ ├── mod.rs │ │ │ │ └── event.rs │ │ │ ├── syntax │ │ │ │ ├── mod.rs │ │ │ │ ├── script.rs │ │ │ │ └── location.rs │ │ │ ├── lib.rs │ │ │ ├── code.rs │ │ │ └── breakpoints.rs │ │ └── Cargo.toml │ └── capi │ │ ├── src │ │ ├── effects.rs │ │ └── main.rs │ │ └── Cargo.toml │ ├── 11 │ ├── crosscut │ │ ├── debugger │ │ │ ├── src │ │ │ │ ├── model │ │ │ │ │ ├── tests │ │ │ │ │ │ ├── mod.rs │ │ │ │ │ │ └── suite │ │ │ │ │ │ │ ├── mod.rs │ │ │ │ │ │ │ └── basic_state.rs │ │ │ │ │ ├── user_action.rs │ │ │ │ │ ├── mod.rs │ │ │ │ │ ├── breakpoints.rs │ │ │ │ │ └── code.rs │ │ │ │ ├── ui │ │ │ │ │ ├── mod.rs │ │ │ │ │ ├── components │ │ │ │ │ │ ├── mod.rs │ │ │ │ │ │ ├── panel.rs │ │ │ │ │ │ ├── button.rs │ │ │ │ │ │ ├── control_panel.rs │ │ │ │ │ │ └── stack_explorer.rs │ │ │ │ │ ├── actions.rs │ │ │ │ │ └── init.rs │ │ │ │ ├── commands.rs │ │ │ │ └── main.rs │ │ │ └── Cargo.toml │ │ ├── ffi │ │ │ ├── src │ │ │ │ └── lib.rs │ │ │ └── Cargo.toml │ │ ├── host │ │ │ ├── src │ │ │ │ ├── lib.rs │ │ │ │ └── ffi_out.rs │ │ │ └── Cargo.toml │ │ ├── compiler │ │ │ ├── src │ │ │ │ ├── tests │ │ │ │ │ └── suite │ │ │ │ │ │ ├── mod.rs │ │ │ │ │ │ └── functions.rs │ │ │ │ ├── code │ │ │ │ │ ├── syntax │ │ │ │ │ │ ├── repr │ │ │ │ │ │ │ ├── mod.rs │ │ │ │ │ │ │ ├── types.rs │ │ │ │ │ │ │ └── expression.rs │ │ │ │ │ │ └── location │ │ │ │ │ │ │ ├── binding.rs │ │ │ │ │ │ │ ├── mod.rs │ │ │ │ │ │ │ ├── expression.rs │ │ │ │ │ │ │ └── named_function.rs │ │ │ │ │ ├── types │ │ │ │ │ │ └── infer │ │ │ │ │ │ │ ├── mod.rs │ │ │ │ │ │ │ └── stack.rs │ │ │ │ │ ├── identifiers │ │ │ │ │ │ └── mod.rs │ │ │ │ │ ├── tokens │ │ │ │ │ │ ├── mod.rs │ │ │ │ │ │ └── tokens.rs │ │ │ │ │ ├── mod.rs │ │ │ │ │ ├── hash.rs │ │ │ │ │ └── functions.rs │ │ │ │ ├── tests.rs │ │ │ │ ├── passes │ │ │ │ │ ├── mod.rs │ │ │ │ │ └── generate_instructions │ │ │ │ │ │ └── mod.rs │ │ │ │ └── lib.rs │ │ │ └── Cargo.toml │ │ ├── watch │ │ │ ├── src │ │ │ │ └── lib.rs │ │ │ └── Cargo.toml │ │ ├── game-engine │ │ │ ├── src │ │ │ │ ├── lib.rs │ │ │ │ ├── command.rs │ │ │ │ ├── memory.rs │ │ │ │ └── display.rs │ │ │ └── Cargo.toml │ │ ├── cli │ │ │ ├── src │ │ │ │ ├── server │ │ │ │ │ ├── mod.rs │ │ │ │ │ └── tests.rs │ │ │ │ └── main.rs │ │ │ ├── Cargo.toml │ │ │ └── build.rs │ │ ├── runtime │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ ├── lib.rs │ │ │ │ ├── heap.rs │ │ │ │ └── operands.rs │ │ └── protocol │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ ├── command.rs │ │ │ └── host_state.rs │ ├── .gitignore │ ├── tools │ │ └── builder │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ ├── export.rs │ │ │ └── main.rs │ └── Cargo.toml │ ├── 12 │ ├── src │ │ ├── io │ │ │ ├── editor │ │ │ │ └── mod.rs │ │ │ └── mod.rs │ │ ├── language │ │ │ ├── compiler │ │ │ │ ├── tests │ │ │ │ │ ├── mod.rs │ │ │ │ │ └── infra.rs │ │ │ │ └── mod.rs │ │ │ ├── tests │ │ │ │ ├── mod.rs │ │ │ │ ├── commands.rs │ │ │ │ └── intrinsic_functions.rs │ │ │ ├── code │ │ │ │ ├── errors.rs │ │ │ │ └── mod.rs │ │ │ ├── mod.rs │ │ │ └── host.rs │ │ ├── game_engine │ │ │ ├── terminal_editor │ │ │ │ └── mod.rs │ │ │ └── mod.rs │ │ └── main.rs │ ├── shell.nix │ └── Cargo.toml │ ├── 13 │ ├── src │ │ ├── io │ │ │ ├── editor │ │ │ │ └── mod.rs │ │ │ └── mod.rs │ │ ├── game_engine │ │ │ ├── editor │ │ │ │ └── mod.rs │ │ │ └── mod.rs │ │ ├── language │ │ │ ├── compiler │ │ │ │ └── mod.rs │ │ │ ├── mod.rs │ │ │ ├── tests │ │ │ │ ├── mod.rs │ │ │ │ ├── math.rs │ │ │ │ ├── functions.rs │ │ │ │ └── commands.rs │ │ │ ├── runtime │ │ │ │ ├── mod.rs │ │ │ │ ├── effect.rs │ │ │ │ └── state.rs │ │ │ ├── code │ │ │ │ ├── nodes │ │ │ │ │ ├── mod.rs │ │ │ │ │ └── nodes.rs │ │ │ │ ├── mod.rs │ │ │ │ ├── intrinsics.rs │ │ │ │ └── errors.rs │ │ │ └── editor │ │ │ │ └── mod.rs │ │ └── main.rs │ ├── shell.nix │ └── Cargo.toml │ ├── 00 │ ├── .gitignore │ ├── index.html │ ├── src │ │ ├── language │ │ │ └── values.rs │ │ └── html.rs │ ├── css │ │ └── main.css │ └── Cargo.toml │ ├── 06 │ ├── .gitignore │ ├── src │ │ ├── cp │ │ │ ├── code │ │ │ │ ├── intrinsics │ │ │ │ │ └── mod.rs │ │ │ │ ├── mod.rs │ │ │ │ └── std.rs │ │ │ ├── runtime │ │ │ │ └── mod.rs │ │ │ ├── pipeline │ │ │ │ ├── ir │ │ │ │ │ ├── mod.rs │ │ │ │ │ ├── syntax.rs │ │ │ │ │ └── tokens.rs │ │ │ │ ├── mod.rs │ │ │ │ ├── stages │ │ │ │ │ ├── mod.rs │ │ │ │ │ └── d_evaluator.rs │ │ │ │ └── error.rs │ │ │ ├── namespace │ │ │ │ ├── mod.rs │ │ │ │ ├── function.rs │ │ │ │ └── bindings.rs │ │ │ └── mod.rs │ │ ├── main.rs │ │ └── ui │ │ │ ├── pass_fail.rs │ │ │ ├── test_report.rs │ │ │ ├── test_run_result.rs │ │ │ ├── code_editor.rs │ │ │ ├── function_list.rs │ │ │ └── mod.rs │ ├── tailwind.css │ ├── tailwind.config.js │ ├── Cargo.toml │ └── index.html │ ├── 09 │ ├── .gitignore │ ├── Cargo.toml │ ├── capi-runtime │ │ ├── src │ │ │ ├── lib.rs │ │ │ ├── macros.rs │ │ │ ├── ffi_out.rs │ │ │ └── lang │ │ │ │ ├── data_stack.rs │ │ │ │ └── builtins.rs │ │ └── Cargo.toml │ └── capi-builder │ │ └── Cargo.toml │ ├── 07 │ ├── capi-web │ │ ├── .gitignore │ │ ├── tailwind.css │ │ ├── index.html │ │ ├── tailwind.config.js │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── main.rs │ │ ├── README.md │ │ └── build.rs │ ├── examples │ │ ├── number.capi │ │ ├── hello.capi │ │ ├── function.capi │ │ ├── loop-named.capi │ │ ├── loop-anon.capi │ │ └── blocks.capi │ ├── tests │ │ ├── fn.capi │ │ ├── binding.capi │ │ ├── basics.capi │ │ ├── if.capi │ │ ├── text.capi │ │ ├── symbol.capi │ │ ├── block.capi │ │ ├── bool.capi │ │ └── array.capi │ ├── Trunk.toml │ ├── capi-core │ │ ├── src │ │ │ ├── repr │ │ │ │ ├── eval │ │ │ │ │ ├── mod.rs │ │ │ │ │ └── fragments │ │ │ │ │ │ ├── mod.rs │ │ │ │ │ │ ├── fragment.rs │ │ │ │ │ │ ├── id.rs │ │ │ │ │ │ └── replacements.rs │ │ │ │ ├── mod.rs │ │ │ │ └── tokens.rs │ │ │ ├── pipeline │ │ │ │ ├── stages │ │ │ │ │ └── mod.rs │ │ │ │ ├── mod.rs │ │ │ │ ├── scripts.rs │ │ │ │ └── run.rs │ │ │ ├── runtime │ │ │ │ └── mod.rs │ │ │ ├── platform │ │ │ │ └── mod.rs │ │ │ └── lib.rs │ │ └── Cargo.toml │ ├── Cargo.toml │ ├── capi-desktop │ │ ├── src │ │ │ ├── loader │ │ │ │ ├── mod.rs │ │ │ │ └── channel.rs │ │ │ ├── lib.rs │ │ │ ├── args.rs │ │ │ └── bin │ │ │ │ └── capi.rs │ │ └── Cargo.toml │ ├── shell.nix │ ├── capi-tests │ │ ├── Cargo.toml │ │ └── src │ │ │ └── lib.rs │ ├── lib │ │ └── std.capi │ └── tests.capi │ ├── 08 │ ├── .gitignore │ ├── Cargo.toml │ ├── capi-runtime │ │ ├── src │ │ │ ├── lib.rs │ │ │ ├── input.rs │ │ │ ├── ffi_out.rs │ │ │ ├── cells.rs │ │ │ └── state.rs │ │ └── Cargo.toml │ ├── capi-vm │ │ ├── src │ │ │ ├── lib.rs │ │ │ ├── opcode.rs │ │ │ └── code.rs │ │ └── Cargo.toml │ ├── capi-assembler │ │ └── Cargo.toml │ ├── snake.asm.capi │ └── capi-builder │ │ └── Cargo.toml │ ├── 05 │ ├── src │ │ ├── cp │ │ │ ├── runtime │ │ │ │ └── mod.rs │ │ │ ├── pipeline │ │ │ │ ├── ir │ │ │ │ │ ├── mod.rs │ │ │ │ │ ├── syntax.rs │ │ │ │ │ └── tokens.rs │ │ │ │ ├── mod.rs │ │ │ │ ├── stages │ │ │ │ │ ├── mod.rs │ │ │ │ │ └── d_evaluator.rs │ │ │ │ └── error.rs │ │ │ ├── namespace │ │ │ │ ├── mod.rs │ │ │ │ ├── function.rs │ │ │ │ └── bindings.rs │ │ │ ├── code │ │ │ │ ├── mod.rs │ │ │ │ └── std.rs │ │ │ └── mod.rs │ │ ├── main.rs │ │ ├── test_report.rs │ │ └── repl.rs │ ├── Cargo.toml │ └── TASKS.md │ ├── 04 │ ├── src │ │ ├── cp │ │ │ ├── pipeline │ │ │ │ └── mod.rs │ │ │ ├── chars.rs │ │ │ ├── syntax.rs │ │ │ ├── mod.rs │ │ │ └── functions.rs │ │ ├── main.rs │ │ └── tests.rs │ └── Cargo.toml │ ├── 02 │ ├── src │ │ ├── ui │ │ │ ├── mod.rs │ │ │ ├── vector.rs │ │ │ ├── area.rs │ │ │ └── border.rs │ │ ├── main.rs │ │ └── cp │ │ │ ├── pipeline │ │ │ └── mod.rs │ │ │ ├── keywords.rs │ │ │ ├── functions.rs │ │ │ ├── call_stack.rs │ │ │ ├── expressions.rs │ │ │ ├── syntax.rs │ │ │ └── mod.rs │ ├── TASKS.md │ └── Cargo.toml │ ├── 03 │ ├── Cargo.toml │ ├── src │ │ ├── main.rs │ │ ├── cp │ │ │ ├── pipeline │ │ │ │ └── mod.rs │ │ │ ├── keywords.rs │ │ │ ├── values.rs │ │ │ ├── call_stack.rs │ │ │ ├── expressions.rs │ │ │ ├── syntax.rs │ │ │ └── functions.rs │ │ ├── functions.rs │ │ └── test_report.rs │ └── TASKS.md │ └── 01 │ ├── Cargo.toml │ ├── src │ ├── cp │ │ ├── functions │ │ │ ├── function.rs │ │ │ └── registry.rs │ │ ├── bindings.rs │ │ ├── mod.rs │ │ └── tokenizer.rs │ └── ui │ │ ├── generations.rs │ │ ├── vector.rs │ │ ├── mod.rs │ │ └── border.rs │ └── TASKS.md ├── .gitignore ├── tools ├── daily │ ├── Cargo.toml │ └── src │ │ └── main.rs └── website │ ├── Cargo.toml │ └── src │ └── main.rs ├── .vscode ├── extensions.json └── settings.json ├── games └── trial-of-the-caterpillar │ ├── src │ └── main.rs │ └── Cargo.toml ├── Cargo.toml ├── shell.nix ├── .zed └── settings.json └── LICENSE.md /rustfmt.toml: -------------------------------------------------------------------------------- 1 | max_width = 80 2 | -------------------------------------------------------------------------------- /crosscut/src/util/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod form; 2 | -------------------------------------------------------------------------------- /clippy.toml: -------------------------------------------------------------------------------- 1 | allow-private-module-inception = true 2 | -------------------------------------------------------------------------------- /archive/prototypes/00/.gitignore: -------------------------------------------------------------------------------- 1 | # Trunk 2 | /dist 3 | -------------------------------------------------------------------------------- /archive/prototypes/06/.gitignore: -------------------------------------------------------------------------------- 1 | # Trunk 2 | /dist 3 | -------------------------------------------------------------------------------- /archive/prototypes/09/.gitignore: -------------------------------------------------------------------------------- 1 | # Cargo 2 | /target 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Cargo 2 | /target 3 | 4 | # Vim 5 | .*.swp 6 | -------------------------------------------------------------------------------- /archive/prototypes/07/capi-web/.gitignore: -------------------------------------------------------------------------------- 1 | # Trunk 2 | /dist 3 | -------------------------------------------------------------------------------- /archive/prototypes/10/.gitignore: -------------------------------------------------------------------------------- 1 | # Trunk 2 | /capi-debug/dist 3 | -------------------------------------------------------------------------------- /archive/prototypes/07/examples/number.capi: -------------------------------------------------------------------------------- 1 | :main { 1 2 + print } fn 2 | -------------------------------------------------------------------------------- /crosscut/src/language/editor/tests/mod.rs: -------------------------------------------------------------------------------- 1 | mod add; 2 | mod navigate; 3 | -------------------------------------------------------------------------------- /archive/prototypes/07/tests/fn.capi: -------------------------------------------------------------------------------- 1 | :f { true } fn 2 | "fn" { f } test 3 | -------------------------------------------------------------------------------- /crosscut/src/game_engine/editor/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod input; 2 | pub mod output; 3 | -------------------------------------------------------------------------------- /archive/prototypes/07/Trunk.toml: -------------------------------------------------------------------------------- 1 | [build] 2 | target = "capi-web/index.html" 3 | -------------------------------------------------------------------------------- /archive/prototypes/07/examples/hello.capi: -------------------------------------------------------------------------------- 1 | :main { "Hello, world!" print } fn 2 | -------------------------------------------------------------------------------- /archive/prototypes/08/.gitignore: -------------------------------------------------------------------------------- 1 | /snake.bc.capi 2 | 3 | # Cargo 4 | /target 5 | -------------------------------------------------------------------------------- /archive/prototypes/12/src/io/editor/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod input; 2 | pub mod output; 3 | -------------------------------------------------------------------------------- /archive/prototypes/12/src/io/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod editor; 2 | pub mod game_engine; 3 | -------------------------------------------------------------------------------- /archive/prototypes/13/src/io/editor/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod input; 2 | pub mod output; 3 | -------------------------------------------------------------------------------- /archive/prototypes/13/src/io/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod editor; 2 | pub mod game_engine; 3 | -------------------------------------------------------------------------------- /archive/prototypes/06/src/cp/code/intrinsics/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod code; 2 | pub mod tests; 3 | -------------------------------------------------------------------------------- /archive/prototypes/05/src/cp/runtime/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod data_stack; 2 | pub mod evaluate; 3 | -------------------------------------------------------------------------------- /archive/prototypes/06/src/cp/runtime/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod data_stack; 2 | pub mod evaluate; 3 | -------------------------------------------------------------------------------- /archive/prototypes/07/tests/binding.capi: -------------------------------------------------------------------------------- 1 | "binding" { true false => [ :t :f ] t } test 2 | -------------------------------------------------------------------------------- /archive/prototypes/11/crosscut/debugger/src/model/tests/mod.rs: -------------------------------------------------------------------------------- 1 | mod infra; 2 | mod suite; 3 | -------------------------------------------------------------------------------- /archive/prototypes/11/crosscut/ffi/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod framed_buffer; 2 | pub mod shared; 3 | -------------------------------------------------------------------------------- /archive/prototypes/11/crosscut/host/src/lib.rs: -------------------------------------------------------------------------------- 1 | mod ffi_in; 2 | mod ffi_out; 3 | mod host; 4 | -------------------------------------------------------------------------------- /archive/prototypes/13/src/game_engine/editor/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod input; 2 | pub mod output; 3 | -------------------------------------------------------------------------------- /archive/prototypes/07/capi-core/src/repr/eval/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod fragments; 2 | pub mod value; 3 | -------------------------------------------------------------------------------- /archive/prototypes/12/src/language/compiler/tests/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod infra; 2 | pub mod suite; 3 | -------------------------------------------------------------------------------- /archive/prototypes/06/tailwind.css: -------------------------------------------------------------------------------- 1 | @tailwind base; 2 | @tailwind components; 3 | @tailwind utilities; -------------------------------------------------------------------------------- /archive/prototypes/12/src/game_engine/terminal_editor/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod input; 2 | pub mod output; 3 | -------------------------------------------------------------------------------- /archive/prototypes/07/capi-core/src/repr/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod eval; 2 | pub mod syntax; 3 | pub mod tokens; 4 | -------------------------------------------------------------------------------- /archive/prototypes/11/crosscut/ffi/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "crosscut-ffi" 3 | edition = "2021" 4 | -------------------------------------------------------------------------------- /archive/prototypes/07/examples/function.capi: -------------------------------------------------------------------------------- 1 | :print_number { 1 2 + print } fn 2 | :main { print_number } fn 3 | -------------------------------------------------------------------------------- /archive/prototypes/07/tests/basics.capi: -------------------------------------------------------------------------------- 1 | "drop" { true false drop } test 2 | "clone" { true clone drop } test 3 | -------------------------------------------------------------------------------- /archive/prototypes/04/src/cp/pipeline/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod a_tokenizer; 2 | pub mod b_parser; 3 | pub mod d_evaluator; 4 | -------------------------------------------------------------------------------- /archive/prototypes/05/src/cp/pipeline/ir/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod analyzer_output; 2 | pub mod syntax; 3 | pub mod tokens; 4 | -------------------------------------------------------------------------------- /archive/prototypes/06/src/cp/pipeline/ir/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod analyzer_output; 2 | pub mod syntax; 3 | pub mod tokens; 4 | -------------------------------------------------------------------------------- /archive/prototypes/09/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | resolver = "2" 3 | members = ["capi-builder", "capi-runtime"] 4 | -------------------------------------------------------------------------------- /archive/prototypes/11/.gitignore: -------------------------------------------------------------------------------- 1 | # Cargo 2 | /target 3 | 4 | # Crosscut 5 | /export 6 | 7 | # Vim 8 | .*.swp 9 | -------------------------------------------------------------------------------- /archive/prototypes/05/src/cp/pipeline/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod channel; 2 | pub mod error; 3 | pub mod ir; 4 | pub mod stages; 5 | -------------------------------------------------------------------------------- /archive/prototypes/06/src/cp/pipeline/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod channel; 2 | pub mod error; 3 | pub mod ir; 4 | pub mod stages; 5 | -------------------------------------------------------------------------------- /archive/prototypes/06/tailwind.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | content: ["./src/**/*.rs", "./index.html"] 3 | }; 4 | -------------------------------------------------------------------------------- /archive/prototypes/11/crosscut/compiler/src/tests/suite/mod.rs: -------------------------------------------------------------------------------- 1 | mod code_update; 2 | mod functions; 3 | mod local_functions; 4 | -------------------------------------------------------------------------------- /archive/prototypes/07/tests/if.capi: -------------------------------------------------------------------------------- 1 | "then" { true { true } { false } if } test 2 | "else" { false { false } { true } if } test 3 | -------------------------------------------------------------------------------- /archive/prototypes/09/capi-runtime/src/lib.rs: -------------------------------------------------------------------------------- 1 | #[macro_use] 2 | mod macros; 3 | 4 | mod ffi_in; 5 | mod ffi_out; 6 | mod lang; 7 | -------------------------------------------------------------------------------- /archive/prototypes/11/crosscut/debugger/src/model/tests/suite/mod.rs: -------------------------------------------------------------------------------- 1 | mod basic_state; 2 | mod breakpoints; 3 | mod call_stack; 4 | -------------------------------------------------------------------------------- /archive/prototypes/08/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | resolver = "2" 3 | members = ["capi-assembler", "capi-builder", "capi-runtime", "capi-vm"] 4 | -------------------------------------------------------------------------------- /archive/prototypes/05/src/cp/pipeline/stages/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod a_tokenizer; 2 | pub mod b_parser; 3 | pub mod c_analyzer; 4 | pub mod d_evaluator; 5 | -------------------------------------------------------------------------------- /archive/prototypes/06/src/cp/pipeline/stages/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod a_tokenizer; 2 | pub mod b_parser; 3 | pub mod c_analyzer; 4 | pub mod d_evaluator; 5 | -------------------------------------------------------------------------------- /archive/prototypes/07/tests/text.capi: -------------------------------------------------------------------------------- 1 | "=" { "a" "a" = } test 2 | "= not" { "a" "b" = not } test 3 | "tokenization" { "a""a"="b""b"= and } test 4 | -------------------------------------------------------------------------------- /archive/prototypes/07/capi-web/tailwind.css: -------------------------------------------------------------------------------- 1 | @config "./tailwind.config.js"; 2 | 3 | @tailwind base; 4 | @tailwind components; 5 | @tailwind utilities; -------------------------------------------------------------------------------- /archive/prototypes/10/capi-debug/tailwind.css: -------------------------------------------------------------------------------- 1 | @config "./tailwind.config.js"; 2 | 3 | @tailwind base; 4 | @tailwind components; 5 | @tailwind utilities; -------------------------------------------------------------------------------- /archive/prototypes/11/crosscut/watch/src/lib.rs: -------------------------------------------------------------------------------- 1 | mod debounce; 2 | mod watcher; 3 | 4 | pub use self::{debounce::DebouncedChanges, watcher::Watcher}; 5 | -------------------------------------------------------------------------------- /archive/prototypes/10/capi-debug/tailwind.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | content: [ 3 | "./capi/capi-debug/src/**/*.rs", 4 | ], 5 | }; 6 | -------------------------------------------------------------------------------- /archive/prototypes/11/crosscut/compiler/src/code/syntax/repr/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod expression; 2 | pub mod function; 3 | pub mod syntax_tree; 4 | pub mod types; 5 | -------------------------------------------------------------------------------- /archive/prototypes/11/crosscut/game-engine/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod command; 2 | pub mod display; 3 | pub mod game_engine; 4 | pub mod host; 5 | pub mod memory; 6 | -------------------------------------------------------------------------------- /tools/daily/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "daily" 3 | edition = "2021" 4 | publish = false 5 | 6 | [dependencies] 7 | anyhow = "*" 8 | chrono = "*" 9 | -------------------------------------------------------------------------------- /archive/prototypes/11/crosscut/compiler/src/tests.rs: -------------------------------------------------------------------------------- 1 | //! # End-to-end testing for `crosscut-compiler` and `crosscut-runtime` 2 | 3 | mod infra; 4 | mod suite; 5 | -------------------------------------------------------------------------------- /archive/prototypes/11/crosscut/debugger/src/ui/mod.rs: -------------------------------------------------------------------------------- 1 | mod actions; 2 | mod components; 3 | mod init; 4 | 5 | pub use self::{actions::ActionsTx, init::init}; 6 | -------------------------------------------------------------------------------- /archive/prototypes/12/src/language/compiler/mod.rs: -------------------------------------------------------------------------------- 1 | mod compile; 2 | 3 | #[cfg(test)] 4 | pub mod tests; 5 | 6 | pub use self::compile::compile_and_replace; 7 | -------------------------------------------------------------------------------- /tools/website/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "website" 3 | edition = "2021" 4 | publish = false 5 | 6 | [dependencies] 7 | anyhow = "*" 8 | walkdir = "*" 9 | -------------------------------------------------------------------------------- /archive/prototypes/11/crosscut/cli/src/server/mod.rs: -------------------------------------------------------------------------------- 1 | mod server; 2 | mod start; 3 | 4 | pub use self::start::{start, Event}; 5 | 6 | #[cfg(test)] 7 | mod tests; 8 | -------------------------------------------------------------------------------- /archive/prototypes/02/src/ui/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod area; 2 | pub mod border; 3 | pub mod buffer; 4 | pub mod vector; 5 | 6 | pub use self::{buffer::Buffer, vector::Vector}; 7 | -------------------------------------------------------------------------------- /archive/prototypes/07/tests/symbol.capi: -------------------------------------------------------------------------------- 1 | # Make sure that special characters are processed eagerly around symbols. 2 | "tokenization" {:f{ true } swap drop eval } test 3 | -------------------------------------------------------------------------------- /archive/prototypes/09/capi-runtime/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "capi-runtime" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [lib] 7 | crate-type = ["cdylib"] 8 | -------------------------------------------------------------------------------- /archive/prototypes/12/src/language/tests/mod.rs: -------------------------------------------------------------------------------- 1 | mod commands; 2 | mod edit; 3 | mod host_functions; 4 | mod intrinsic_functions; 5 | mod other; 6 | mod runtime_update; 7 | -------------------------------------------------------------------------------- /crosscut/src/game_engine/graphics/mod.rs: -------------------------------------------------------------------------------- 1 | mod background; 2 | mod quads; 3 | mod renderer; 4 | mod text; 5 | 6 | pub use self::{quads::Instance, renderer::Renderer}; 7 | -------------------------------------------------------------------------------- /crosscut/src/language/compiler/mod.rs: -------------------------------------------------------------------------------- 1 | mod compiler; 2 | mod expression; 3 | mod replace; 4 | 5 | pub use self::compiler::Compiler; 6 | 7 | #[cfg(test)] 8 | mod tests; 9 | -------------------------------------------------------------------------------- /archive/prototypes/02/TASKS.md: -------------------------------------------------------------------------------- 1 | # Tasks 2 | 3 | - Color test output. 4 | - Print error location with error message. 5 | - Prevent shadowing between functions and bindings. 6 | -------------------------------------------------------------------------------- /archive/prototypes/07/tests/block.capi: -------------------------------------------------------------------------------- 1 | "eval" { { true } eval } test 2 | "lazy evaluation" { true { drop } drop } test 3 | "tokenization" { {true}eval{true}eval and } test 4 | -------------------------------------------------------------------------------- /crosscut/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() -> anyhow::Result<()> { 2 | let init = Box::new(crosscut::PureCrosscutGameInit::default()); 3 | crosscut::start_and_wait(init) 4 | } 5 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "tamasfe.even-better-toml", 4 | "rust-lang.rust-analyzer", 5 | "denoland.vscode-deno" 6 | ] 7 | } -------------------------------------------------------------------------------- /archive/prototypes/07/capi-core/src/pipeline/stages/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod a_tokenizer; 2 | pub mod b_parser; 3 | pub mod c_simplifier; 4 | pub mod d_analyzer; 5 | pub mod e_evaluator; 6 | -------------------------------------------------------------------------------- /archive/prototypes/07/examples/loop-named.capi: -------------------------------------------------------------------------------- 1 | :loop 2 | { 3 | print 4 | 200 delay_ms 5 | 1 + 6 | loop 7 | } 8 | fn 9 | 10 | :main { 0 loop } fn 11 | -------------------------------------------------------------------------------- /archive/prototypes/13/src/language/compiler/mod.rs: -------------------------------------------------------------------------------- 1 | mod compiler; 2 | mod replace; 3 | mod token; 4 | 5 | pub use self::compiler::Compiler; 6 | 7 | #[cfg(test)] 8 | mod tests; 9 | -------------------------------------------------------------------------------- /archive/prototypes/10/capi-runtime/src/runtime.rs: -------------------------------------------------------------------------------- 1 | use std::collections::VecDeque; 2 | 3 | use crate::InstructionAddress; 4 | 5 | pub type Function = VecDeque; 6 | -------------------------------------------------------------------------------- /crosscut/src/language/tests/mod.rs: -------------------------------------------------------------------------------- 1 | mod commands; 2 | mod editing; 3 | mod functions; 4 | mod host; 5 | mod intrinsics; 6 | mod math; 7 | mod tuples; 8 | 9 | pub mod infra; 10 | -------------------------------------------------------------------------------- /archive/prototypes/05/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "cp5" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | anyhow = "*" 8 | crossterm = "*" 9 | thiserror = "*" 10 | -------------------------------------------------------------------------------- /archive/prototypes/05/TASKS.md: -------------------------------------------------------------------------------- 1 | # Tasks 2 | 3 | - Prevent shadowing between functions and bindings 4 | - Add support for nested modules 5 | - Add support for namespaces and tie those to modules 6 | -------------------------------------------------------------------------------- /archive/prototypes/07/capi-core/src/runtime/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod call_stack; 2 | pub mod data_stack; 3 | pub mod evaluator; 4 | pub mod interpreter; 5 | pub mod namespaces; 6 | pub mod test_runner; 7 | -------------------------------------------------------------------------------- /archive/prototypes/07/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | resolver = "2" 3 | members = ["capi-core", "capi-desktop", "capi-tests", "capi-web"] 4 | default-members = ["capi-core", "capi-desktop", "capi-tests"] 5 | -------------------------------------------------------------------------------- /archive/prototypes/08/capi-runtime/src/lib.rs: -------------------------------------------------------------------------------- 1 | mod cells; 2 | mod ffi_in; 3 | mod ffi_out; 4 | mod input; 5 | mod render_target; 6 | mod state; 7 | mod world; 8 | 9 | pub use capi_vm as vm; 10 | -------------------------------------------------------------------------------- /archive/prototypes/03/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "cp3" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | anyhow = "*" 8 | crossterm = "*" 9 | map-macro = "*" 10 | thiserror = "*" 11 | -------------------------------------------------------------------------------- /archive/prototypes/13/src/language/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod code; 2 | pub mod compiler; 3 | pub mod editor; 4 | pub mod language; 5 | pub mod packages; 6 | pub mod runtime; 7 | 8 | #[cfg(test)] 9 | pub mod tests; 10 | -------------------------------------------------------------------------------- /archive/prototypes/13/src/language/tests/mod.rs: -------------------------------------------------------------------------------- 1 | mod commands; 2 | mod editing; 3 | mod errors; 4 | mod functions; 5 | mod host; 6 | mod intrinsics; 7 | mod math; 8 | mod tuples; 9 | 10 | pub mod infra; 11 | -------------------------------------------------------------------------------- /games/trial-of-the-caterpillar/src/main.rs: -------------------------------------------------------------------------------- 1 | mod game; 2 | 3 | fn main() -> anyhow::Result<()> { 4 | let init = Box::new(game::TrialOfTheCaterpillarInit::default()); 5 | crosscut::start_and_wait(init) 6 | } 7 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | resolver = "2" 3 | members = [ 4 | "crosscut", 5 | "games/trial-of-the-caterpillar", 6 | "tools/daily", 7 | "tools/website", 8 | ] 9 | default-members = ["crosscut"] 10 | -------------------------------------------------------------------------------- /archive/prototypes/08/capi-vm/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![cfg_attr(not(feature = "std"), no_std)] 2 | 3 | mod code; 4 | mod data; 5 | mod evaluator; 6 | 7 | pub mod opcode; 8 | 9 | pub use self::evaluator::Evaluator; 10 | -------------------------------------------------------------------------------- /crosscut/src/language/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod code; 2 | pub mod compiler; 3 | pub mod editor; 4 | pub mod language; 5 | pub mod runtime; 6 | 7 | #[cfg(test)] 8 | mod import; 9 | 10 | #[cfg(test)] 11 | pub mod tests; 12 | -------------------------------------------------------------------------------- /archive/prototypes/07/capi-desktop/src/loader/mod.rs: -------------------------------------------------------------------------------- 1 | mod channel; 2 | mod loader; 3 | mod script_loader; 4 | mod watch; 5 | 6 | pub use self::{ 7 | channel::{Update, UpdateReceiver}, 8 | loader::Loader, 9 | }; 10 | -------------------------------------------------------------------------------- /archive/prototypes/09/capi-runtime/src/macros.rs: -------------------------------------------------------------------------------- 1 | macro_rules! println { 2 | ($($arg:tt)*) => {{ 3 | let s = core::format_args!($($arg)*).to_string(); 4 | $crate::ffi_out::console_log(&s); 5 | }}; 6 | } 7 | -------------------------------------------------------------------------------- /archive/prototypes/11/crosscut/compiler/src/passes/mod.rs: -------------------------------------------------------------------------------- 1 | mod detect_changes; 2 | mod generate_instructions; 3 | 4 | pub use { 5 | detect_changes::detect_changes, 6 | generate_instructions::generate_instructions, 7 | }; 8 | -------------------------------------------------------------------------------- /archive/prototypes/08/capi-runtime/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "capi-runtime" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [lib] 7 | crate-type = ["cdylib"] 8 | 9 | [dependencies.capi-vm] 10 | path = "../capi-vm" 11 | -------------------------------------------------------------------------------- /archive/prototypes/10/capi-debug/src/components/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod call_stack; 2 | pub mod control_panel; 3 | pub mod execution_context; 4 | pub mod function; 5 | pub mod memory_explorer; 6 | pub mod panel; 7 | pub mod stack_explorer; 8 | -------------------------------------------------------------------------------- /archive/prototypes/11/crosscut/compiler/src/code/types/infer/mod.rs: -------------------------------------------------------------------------------- 1 | mod context; 2 | mod function; 3 | mod infer; 4 | mod signature; 5 | mod stack; 6 | mod types; 7 | 8 | pub use self::infer::{infer, CompilerContext, InferenceOutput}; 9 | -------------------------------------------------------------------------------- /games/trial-of-the-caterpillar/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "trial-of-the-caterpillar" 3 | edition = "2024" 4 | 5 | [dependencies] 6 | anyhow = "*" 7 | rand = "*" 8 | 9 | [dependencies.crosscut] 10 | path = "../../crosscut" 11 | -------------------------------------------------------------------------------- /archive/prototypes/02/src/main.rs: -------------------------------------------------------------------------------- 1 | mod cp; 2 | mod event_loop; 3 | mod terminal; 4 | mod tests; 5 | mod ui; 6 | 7 | #[tokio::main] 8 | async fn main() -> anyhow::Result<()> { 9 | event_loop::run().await?; 10 | Ok(()) 11 | } 12 | -------------------------------------------------------------------------------- /archive/prototypes/07/capi-core/src/platform/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod core; 2 | 3 | mod platform; 4 | 5 | pub use self::platform::{ 6 | BuiltinFn, BuiltinFnError, BuiltinFnResult, BuiltinFnState, BuiltinFns, 7 | CoreContext, Platform, 8 | }; 9 | -------------------------------------------------------------------------------- /archive/prototypes/10/capi-runtime/src/debugger/mod.rs: -------------------------------------------------------------------------------- 1 | mod event; 2 | mod execution_context; 3 | mod expression; 4 | 5 | pub use self::{ 6 | event::DebugEvent, execution_context::ExecutionContext, 7 | expression::Expression, 8 | }; 9 | -------------------------------------------------------------------------------- /archive/prototypes/11/crosscut/compiler/src/passes/generate_instructions/mod.rs: -------------------------------------------------------------------------------- 1 | mod compile_cluster; 2 | mod compile_function; 3 | mod compile_functions; 4 | mod generate_instructions; 5 | 6 | pub use self::generate_instructions::generate_instructions; 7 | -------------------------------------------------------------------------------- /archive/prototypes/05/src/main.rs: -------------------------------------------------------------------------------- 1 | mod cp; 2 | mod repl; 3 | mod test_report; 4 | 5 | fn main() -> anyhow::Result<()> { 6 | let (mut functions, mut tests) = cp::define_code()?; 7 | repl::run(&mut functions, &mut tests)?; 8 | Ok(()) 9 | } 10 | -------------------------------------------------------------------------------- /archive/prototypes/11/crosscut/debugger/src/ui/components/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod active_functions; 2 | pub mod button; 3 | pub mod control_panel; 4 | pub mod debugger; 5 | pub mod function; 6 | pub mod memory_explorer; 7 | pub mod panel; 8 | pub mod stack_explorer; 9 | -------------------------------------------------------------------------------- /archive/prototypes/12/src/language/code/errors.rs: -------------------------------------------------------------------------------- 1 | #[derive(Clone, Debug, Eq, PartialEq)] 2 | pub enum CodeError { 3 | IntegerOverflow, 4 | MissingArgument, 5 | MultiResolvedIdentifier, 6 | UnexpectedToken, 7 | UnresolvedIdentifier, 8 | } 9 | -------------------------------------------------------------------------------- /shell.nix: -------------------------------------------------------------------------------- 1 | { pkgs ? import { } }: 2 | 3 | let 4 | libPath = with pkgs; lib.makeLibraryPath [ 5 | libxkbcommon 6 | vulkan-loader 7 | wayland 8 | ]; 9 | in 10 | pkgs.mkShell { 11 | LD_LIBRARY_PATH = "${libPath}"; 12 | } 13 | -------------------------------------------------------------------------------- /archive/prototypes/05/src/cp/namespace/mod.rs: -------------------------------------------------------------------------------- 1 | mod bindings; 2 | mod function; 3 | mod functions; 4 | 5 | pub use self::{ 6 | bindings::Bindings, 7 | function::{Function, FunctionBody, Intrinsic}, 8 | functions::{Functions, Module}, 9 | }; 10 | -------------------------------------------------------------------------------- /archive/prototypes/06/src/cp/namespace/mod.rs: -------------------------------------------------------------------------------- 1 | mod bindings; 2 | mod function; 3 | mod functions; 4 | 5 | pub use self::{ 6 | bindings::Bindings, 7 | function::{Function, FunctionBody, Intrinsic}, 8 | functions::{Functions, Module}, 9 | }; 10 | -------------------------------------------------------------------------------- /archive/prototypes/11/crosscut/compiler/src/code/syntax/location/binding.rs: -------------------------------------------------------------------------------- 1 | use crate::code::syntax::Binding; 2 | 3 | use super::{located::HasLocation, ParameterLocation}; 4 | 5 | impl HasLocation for Binding { 6 | type Location = ParameterLocation; 7 | } 8 | -------------------------------------------------------------------------------- /archive/prototypes/00/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Caterpillar 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /archive/prototypes/07/examples/loop-anon.capi: -------------------------------------------------------------------------------- 1 | :loop 2 | { 3 | over eval 4 | loop 5 | } 6 | fn 7 | 8 | :main 9 | { 10 | { 11 | print 12 | 200 delay_ms 13 | 1 + 14 | } 15 | 0 16 | loop 17 | } 18 | fn 19 | -------------------------------------------------------------------------------- /archive/prototypes/09/capi-runtime/src/ffi_out.rs: -------------------------------------------------------------------------------- 1 | pub fn console_log(s: &str) { 2 | unsafe { ffi::console_log(s.as_ptr(), s.len()) }; 3 | } 4 | 5 | mod ffi { 6 | extern "C" { 7 | pub fn console_log(ptr: *const u8, len: usize); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /archive/prototypes/11/crosscut/cli/src/main.rs: -------------------------------------------------------------------------------- 1 | mod build_game; 2 | mod cli; 3 | mod export; 4 | mod files; 5 | mod headless; 6 | mod server; 7 | 8 | #[tokio::main] 9 | async fn main() -> anyhow::Result<()> { 10 | cli::run().await?; 11 | Ok(()) 12 | } 13 | -------------------------------------------------------------------------------- /archive/prototypes/04/src/main.rs: -------------------------------------------------------------------------------- 1 | mod cp; 2 | mod test_report; 3 | mod tests; 4 | 5 | #[tokio::main] 6 | async fn main() -> anyhow::Result<()> { 7 | let test_reports = tests::run().await?; 8 | test_report::print(&test_reports); 9 | 10 | Ok(()) 11 | } 12 | -------------------------------------------------------------------------------- /archive/prototypes/02/src/cp/pipeline/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod a_tokenizer; 2 | pub mod b_parser; 3 | pub mod c_analyzer; 4 | pub mod d_evaluator; 5 | 6 | pub use self::{ 7 | a_tokenizer::tokenize, b_parser::parse, c_analyzer::analyze, 8 | d_evaluator::evaluate, 9 | }; 10 | -------------------------------------------------------------------------------- /archive/prototypes/07/capi-core/src/pipeline/mod.rs: -------------------------------------------------------------------------------- 1 | mod module; 2 | mod run; 3 | mod scripts; 4 | mod stages; 5 | 6 | pub use self::{ 7 | module::{Function, Module}, 8 | run::{run, PipelineError, PipelineOutput}, 9 | scripts::{ScriptPath, Scripts}, 10 | }; 11 | -------------------------------------------------------------------------------- /archive/prototypes/12/shell.nix: -------------------------------------------------------------------------------- 1 | { pkgs ? import { } }: 2 | 3 | let 4 | libPath = with pkgs; lib.makeLibraryPath [ 5 | libxkbcommon 6 | vulkan-loader 7 | wayland 8 | ]; 9 | in 10 | pkgs.mkShell { 11 | LD_LIBRARY_PATH = "${libPath}"; 12 | } 13 | -------------------------------------------------------------------------------- /archive/prototypes/12/src/game_engine/mod.rs: -------------------------------------------------------------------------------- 1 | mod game_engine; 2 | mod terminal_editor; 3 | 4 | pub use self::{ 5 | game_engine::{GameEngine, GameInput, GameOutput}, 6 | terminal_editor::input::TerminalInputEvent, 7 | }; 8 | 9 | #[cfg(test)] 10 | mod tests; 11 | -------------------------------------------------------------------------------- /archive/prototypes/13/shell.nix: -------------------------------------------------------------------------------- 1 | { pkgs ? import { } }: 2 | 3 | let 4 | libPath = with pkgs; lib.makeLibraryPath [ 5 | libxkbcommon 6 | vulkan-loader 7 | wayland 8 | ]; 9 | in 10 | pkgs.mkShell { 11 | LD_LIBRARY_PATH = "${libPath}"; 12 | } 13 | -------------------------------------------------------------------------------- /archive/prototypes/00/src/language/values.rs: -------------------------------------------------------------------------------- 1 | use std::collections::VecDeque; 2 | 3 | pub enum Value { 4 | Array(VecDeque), 5 | Color(Color), 6 | U8(u8), 7 | } 8 | 9 | pub struct Color { 10 | pub r: u8, 11 | pub g: u8, 12 | pub b: u8, 13 | } 14 | -------------------------------------------------------------------------------- /archive/prototypes/10/capi-runtime/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "capi-runtime" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | serde-big-array = "*" 8 | thiserror = "*" 9 | 10 | [dependencies.serde] 11 | version = "*" 12 | features = ["derive"] 13 | -------------------------------------------------------------------------------- /.zed/settings.json: -------------------------------------------------------------------------------- 1 | // Folder-specific settings 2 | // 3 | // For a full list of overridable settings, and general information on folder-specific settings, 4 | // see the documentation: https://zed.dev/docs/configuring-zed#settings-files 5 | { 6 | "file_scan_exclusions": ["archive/**"] 7 | } 8 | -------------------------------------------------------------------------------- /archive/prototypes/07/capi-core/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "capi-core" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | blake3 = "*" 8 | enum_variant_type = "*" 9 | thiserror = "*" 10 | tracing = "*" 11 | 12 | 13 | [dev-dependencies] 14 | anyhow = "*" 15 | -------------------------------------------------------------------------------- /archive/prototypes/07/tests/bool.capi: -------------------------------------------------------------------------------- 1 | "true" { true } test 2 | "false not" { false not } test 3 | "and - true true" { true true and } test 4 | "and - true false" { true false and not } test 5 | "and - false true" { false true and not } test 6 | "and - false false" { false false and not } test 7 | -------------------------------------------------------------------------------- /archive/prototypes/05/src/cp/pipeline/error.rs: -------------------------------------------------------------------------------- 1 | use super::channel::NoMoreInput; 2 | 3 | #[derive(Debug, thiserror::Error)] 4 | pub enum PipelineError { 5 | #[error(transparent)] 6 | NotEnoughInput(#[from] NoMoreInput), 7 | 8 | #[error(transparent)] 9 | Stage(T), 10 | } 11 | -------------------------------------------------------------------------------- /archive/prototypes/06/src/cp/pipeline/error.rs: -------------------------------------------------------------------------------- 1 | use super::channel::NoMoreInput; 2 | 3 | #[derive(Debug, thiserror::Error)] 4 | pub enum PipelineError { 5 | #[error(transparent)] 6 | NotEnoughInput(#[from] NoMoreInput), 7 | 8 | #[error(transparent)] 9 | Stage(T), 10 | } 11 | -------------------------------------------------------------------------------- /archive/prototypes/11/crosscut/compiler/src/code/identifiers/mod.rs: -------------------------------------------------------------------------------- 1 | mod bindings; 2 | mod function_calls; 3 | mod identifiers; 4 | 5 | pub use self::{ 6 | bindings::{Bindings, Environment}, 7 | function_calls::FunctionCalls, 8 | identifiers::{IdentifierTarget, Identifiers}, 9 | }; 10 | -------------------------------------------------------------------------------- /archive/prototypes/13/src/language/runtime/mod.rs: -------------------------------------------------------------------------------- 1 | mod effect; 2 | mod evaluator; 3 | mod intrinsics; 4 | mod state; 5 | mod value; 6 | 7 | pub use self::{ 8 | effect::Effect, evaluator::Evaluator, intrinsics::apply_intrinsic_function, 9 | state::RuntimeState, value::Value, 10 | }; 11 | -------------------------------------------------------------------------------- /crosscut/src/language/runtime/mod.rs: -------------------------------------------------------------------------------- 1 | mod effect; 2 | mod eval_step; 3 | mod evaluator; 4 | mod intrinsics; 5 | mod state; 6 | mod value; 7 | 8 | pub use self::{ 9 | effect::Effect, evaluator::Evaluator, intrinsics::apply_intrinsic_function, 10 | state::RuntimeState, value::Value, 11 | }; 12 | -------------------------------------------------------------------------------- /archive/prototypes/13/src/language/code/nodes/mod.rs: -------------------------------------------------------------------------------- 1 | mod children; 2 | mod hash; 3 | mod node; 4 | mod nodes; 5 | mod path; 6 | 7 | pub use self::{ 8 | children::Children, 9 | hash::NodeHash, 10 | node::Node, 11 | nodes::Nodes, 12 | path::{LocatedNode, NodePath, SiblingIndex}, 13 | }; 14 | -------------------------------------------------------------------------------- /archive/prototypes/08/capi-assembler/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "capi-assembler" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | 7 | [dependencies] 8 | thiserror = "*" 9 | 10 | [dependencies.capi-vm] 11 | path = "../capi-vm" 12 | features = ["std"] 13 | 14 | 15 | [dev-dependencies] 16 | anyhow = "*" 17 | -------------------------------------------------------------------------------- /archive/prototypes/08/capi-runtime/src/input.rs: -------------------------------------------------------------------------------- 1 | use std::collections::VecDeque; 2 | 3 | pub struct Input { 4 | pub events: VecDeque, 5 | } 6 | 7 | #[derive(Eq, PartialEq)] 8 | #[repr(i32)] 9 | pub enum InputEvent { 10 | Up = 0, 11 | Left = 1, 12 | Down = 2, 13 | Right = 3, 14 | } 15 | -------------------------------------------------------------------------------- /archive/prototypes/03/src/main.rs: -------------------------------------------------------------------------------- 1 | mod cp; 2 | mod functions; 3 | mod test_report; 4 | mod tests; 5 | 6 | fn main() -> anyhow::Result<()> { 7 | let mut functions = functions::define()?; 8 | let test_reports = tests::run(&mut functions)?; 9 | test_report::print(&test_reports); 10 | 11 | Ok(()) 12 | } 13 | -------------------------------------------------------------------------------- /archive/prototypes/13/src/language/editor/mod.rs: -------------------------------------------------------------------------------- 1 | mod editor; 2 | mod input_buffer; 3 | mod layout; 4 | 5 | pub use self::{ 6 | editor::{Editor, EditorCommand}, 7 | input_buffer::{EditorInputBuffer, EditorInputEvent}, 8 | layout::{EditorLayout, EditorLine}, 9 | }; 10 | 11 | #[cfg(test)] 12 | mod tests; 13 | -------------------------------------------------------------------------------- /crosscut/src/terminal/mod.rs: -------------------------------------------------------------------------------- 1 | mod input; 2 | mod output; 3 | mod thread; 4 | 5 | pub use self::{ 6 | output::{Cursor, RawTerminalAdapter, TerminalOutputAdapter}, 7 | thread::{ChannelDisconnected, Receiver, start}, 8 | }; 9 | 10 | #[cfg(test)] 11 | pub use self::output::{DebugOutputAdapter, StringOutputAdapter}; 12 | -------------------------------------------------------------------------------- /archive/prototypes/04/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "cp4" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | anyhow = "*" 8 | async-recursion = "*" 9 | async-trait = "*" 10 | crossterm = "*" 11 | futures = "*" 12 | thiserror = "*" 13 | 14 | [dependencies.tokio] 15 | version = "*" 16 | features = ["full"] 17 | -------------------------------------------------------------------------------- /archive/prototypes/07/shell.nix: -------------------------------------------------------------------------------- 1 | { pkgs ? import { } }: 2 | 3 | let 4 | libPath = with pkgs; lib.makeLibraryPath [ 5 | libxkbcommon 6 | vulkan-loader 7 | wayland 8 | ]; 9 | in 10 | pkgs.mkShell { 11 | packages = with pkgs; [ 12 | trunk 13 | ]; 14 | 15 | LD_LIBRARY_PATH = "${libPath}"; 16 | } 17 | -------------------------------------------------------------------------------- /archive/prototypes/11/crosscut/debugger/src/commands.rs: -------------------------------------------------------------------------------- 1 | use crosscut_protocol::command::SerializedCommandToRuntime; 2 | use tokio::sync::mpsc; 3 | 4 | pub type CommandsToRuntimeRx = 5 | mpsc::UnboundedReceiver; 6 | pub type CommandsToRuntimeTx = 7 | mpsc::UnboundedSender; 8 | -------------------------------------------------------------------------------- /crosscut/src/language/editor/input.rs: -------------------------------------------------------------------------------- 1 | #[derive(Debug, Eq, PartialEq)] 2 | pub enum EditorInput { 3 | Insert { ch: char }, 4 | MoveCursorLeft, 5 | MoveCursorRight, 6 | MoveCursorUp, 7 | MoveCursorDown, 8 | RemoveLeft { whole_node: bool }, 9 | RemoveRight { whole_node: bool }, 10 | Submit, 11 | } 12 | -------------------------------------------------------------------------------- /crosscut/src/language/editor/mod.rs: -------------------------------------------------------------------------------- 1 | mod editor; 2 | mod input; 3 | mod input_buffer; 4 | mod layout; 5 | 6 | pub use self::{ 7 | editor::{Editor, EditorCommand}, 8 | input::EditorInput, 9 | input_buffer::EditorInputBuffer, 10 | layout::{EditorLayout, EditorLine}, 11 | }; 12 | 13 | #[cfg(test)] 14 | mod tests; 15 | -------------------------------------------------------------------------------- /archive/prototypes/01/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "cp1" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | 7 | [dependencies] 8 | anyhow = "*" 9 | futures = "*" 10 | 11 | [dependencies.crossterm] 12 | version = "*" 13 | features = ["event-stream"] 14 | 15 | [dependencies.tokio] 16 | version = "*" 17 | features = ["full"] 18 | -------------------------------------------------------------------------------- /archive/prototypes/07/capi-web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /archive/prototypes/11/crosscut/debugger/src/main.rs: -------------------------------------------------------------------------------- 1 | mod code; 2 | mod commands; 3 | mod debugger; 4 | mod ffi; 5 | mod model; 6 | mod ui; 7 | 8 | fn main() { 9 | console_error_panic_hook::set_once(); 10 | console_log::init_with_level(log::Level::Error) 11 | .expect("Failed to initialize logging to console"); 12 | } 13 | -------------------------------------------------------------------------------- /archive/prototypes/12/src/language/mod.rs: -------------------------------------------------------------------------------- 1 | //! Core components that are independent of a specific host and platform 2 | 3 | pub mod code; 4 | pub mod compiler; 5 | pub mod editor; 6 | pub mod host; 7 | pub mod interpreter; 8 | 9 | mod instance; 10 | 11 | pub use self::instance::Language; 12 | 13 | #[cfg(test)] 14 | mod tests; 15 | -------------------------------------------------------------------------------- /archive/prototypes/13/src/language/runtime/effect.rs: -------------------------------------------------------------------------------- 1 | use crate::language::{code::Type, packages::FunctionId}; 2 | 3 | use super::Value; 4 | 5 | #[derive(Clone, Debug, Eq, PartialEq)] 6 | pub enum Effect { 7 | ProvidedFunction { id: FunctionId, input: Value }, 8 | UnexpectedInput { expected: Type, actual: Value }, 9 | } 10 | -------------------------------------------------------------------------------- /crosscut/src/language/runtime/effect.rs: -------------------------------------------------------------------------------- 1 | use crate::language::code::Type; 2 | 3 | use super::Value; 4 | 5 | #[derive(Clone, Debug, Eq, PartialEq)] 6 | pub enum Effect { 7 | ApplyProvidedFunction { name: String, input: Value }, 8 | ProvidedFunctionNotFound, 9 | UnexpectedInput { expected: Type, actual: Value }, 10 | } 11 | -------------------------------------------------------------------------------- /archive/prototypes/07/capi-tests/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "capi-tests" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | 7 | [dev-dependencies] 8 | anyhow = "*" 9 | crossbeam-channel = "*" 10 | 11 | [dev-dependencies.capi-core] 12 | path = "../capi-core" 13 | 14 | [dev-dependencies.capi-desktop] 15 | path = "../capi-desktop" 16 | -------------------------------------------------------------------------------- /archive/prototypes/08/capi-runtime/src/ffi_out.rs: -------------------------------------------------------------------------------- 1 | extern "C" { 2 | fn print_ffi(ptr: *const u8, len: usize); 3 | fn random_ffi() -> f32; 4 | } 5 | 6 | pub fn print(s: &str) { 7 | unsafe { 8 | print_ffi(s.as_ptr(), s.len()); 9 | } 10 | } 11 | 12 | pub fn random() -> f32 { 13 | unsafe { random_ffi() } 14 | } 15 | -------------------------------------------------------------------------------- /archive/prototypes/11/crosscut/game-engine/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "crosscut-game-engine" 3 | edition = "2021" 4 | 5 | [dependencies] 6 | num_enum = "*" 7 | serde = "*" 8 | serde-big-array = "*" 9 | 10 | [dependencies.crosscut-compiler] 11 | path = "../compiler" 12 | 13 | [dependencies.crosscut-runtime] 14 | path = "../runtime" 15 | -------------------------------------------------------------------------------- /archive/prototypes/13/src/language/tests/math.rs: -------------------------------------------------------------------------------- 1 | use crate::language::{language::Language, runtime::Value}; 2 | 3 | #[test] 4 | fn add() { 5 | let mut language = Language::from_code("1\n2 tuple +"); 6 | 7 | assert_eq!( 8 | language.step_until_finished().unwrap(), 9 | Value::Integer { value: 3 }, 10 | ); 11 | } 12 | -------------------------------------------------------------------------------- /archive/prototypes/11/crosscut/compiler/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod code; 2 | pub mod host; 3 | pub mod intrinsics; 4 | pub mod source_map; 5 | 6 | mod compiler; 7 | mod instructions; 8 | mod passes; 9 | 10 | #[cfg(test)] 11 | mod tests; 12 | 13 | pub use self::{ 14 | compiler::{Compiler, CompilerOutput}, 15 | instructions::Instructions, 16 | }; 17 | -------------------------------------------------------------------------------- /archive/prototypes/11/crosscut/watch/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "crosscut-watch" 3 | edition = "2021" 4 | 5 | [dependencies] 6 | anyhow = "*" 7 | tracing = "*" 8 | 9 | [dependencies.notify] 10 | version = "*" 11 | default-features = false 12 | 13 | [dependencies.tokio] 14 | version = "*" 15 | features = ["process", "rt", "sync", "time"] 16 | -------------------------------------------------------------------------------- /archive/prototypes/02/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "cp2" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | 7 | [dependencies] 8 | anyhow = "*" 9 | futures = "*" 10 | thiserror = "*" 11 | 12 | [dependencies.crossterm] 13 | version = "*" 14 | features = ["event-stream"] 15 | 16 | [dependencies.tokio] 17 | version = "*" 18 | features = ["full"] 19 | -------------------------------------------------------------------------------- /archive/prototypes/03/TASKS.md: -------------------------------------------------------------------------------- 1 | # Tasks 2 | 3 | - Print error location with error message 4 | - Prevent shadowing between functions and bindings 5 | - Add support for nested modules 6 | - Add support for namespaces and tie those to modules 7 | - Create wrapper types for `u8` that define the behavior of arithmetic 8 | So far, it's just implicitly saturating. 9 | -------------------------------------------------------------------------------- /archive/prototypes/07/capi-core/src/repr/eval/fragments/mod.rs: -------------------------------------------------------------------------------- 1 | mod address; 2 | mod fragment; 3 | mod fragments; 4 | mod id; 5 | mod payload; 6 | mod replacements; 7 | 8 | pub use self::{ 9 | address::FragmentAddress, fragment::Fragment, fragments::Fragments, 10 | id::FragmentId, payload::FragmentPayload, replacements::Replacement, 11 | }; 12 | -------------------------------------------------------------------------------- /archive/prototypes/07/capi-desktop/src/loader/channel.rs: -------------------------------------------------------------------------------- 1 | use std::path::PathBuf; 2 | 3 | use capi_core::repr::eval::fragments::FragmentId; 4 | use crossbeam_channel::{Receiver, Sender}; 5 | 6 | pub type Update = anyhow::Result<(PathBuf, Option, String)>; 7 | pub type UpdateSender = Sender; 8 | pub type UpdateReceiver = Receiver; 9 | -------------------------------------------------------------------------------- /archive/prototypes/08/snake.asm.capi: -------------------------------------------------------------------------------- 1 | set_pixel: 2 | set_green: 3 | clone 4 | push 8 5 | rol 6 | or 7 | set_blue: 8 | clone 9 | push 0x000000ff 10 | and 11 | push 16 12 | rol 13 | or 14 | set_alpha: 15 | push 0xff000000 16 | or 17 | store: 18 | swap 19 | store 20 | terminate: 21 | terminate 22 | -------------------------------------------------------------------------------- /archive/prototypes/10/capi-runtime/src/syntax/mod.rs: -------------------------------------------------------------------------------- 1 | mod builder; 2 | mod expression; 3 | mod functions; 4 | mod location; 5 | mod script; 6 | 7 | pub use self::{ 8 | builder::SyntaxBuilder, 9 | expression::{Expression, ExpressionKind}, 10 | functions::{Function, Functions}, 11 | location::Location, 12 | script::Script, 13 | }; 14 | -------------------------------------------------------------------------------- /archive/prototypes/07/capi-web/tailwind.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | // I have no idea which path this is relative to. Seemingly neither the 3 | // project root nor the `capi-web` directory. 4 | // 5 | // Anyway, as best as I can tell, the following over-general path specifier 6 | // seems to work. 7 | content: ["./**/src/**/*.rs"] 8 | }; 9 | -------------------------------------------------------------------------------- /archive/prototypes/07/lib/std.capi: -------------------------------------------------------------------------------- 1 | :times 2 | { 3 | => [ :block :num_times ] 4 | 5 | num_times 0 > 6 | { 7 | block eval 8 | block 9 | num_times 1 - 10 | times 11 | } 12 | {} 13 | if 14 | } 15 | fn 16 | 17 | "times" 18 | { 19 | 0 { 1 + } 5 times 20 | 5 = 21 | } 22 | test 23 | -------------------------------------------------------------------------------- /archive/prototypes/10/capi-runtime/src/syntax/script.rs: -------------------------------------------------------------------------------- 1 | use super::{Functions, SyntaxBuilder}; 2 | 3 | #[derive(Default)] 4 | pub struct Script { 5 | pub functions: Functions, 6 | } 7 | 8 | impl Script { 9 | pub fn function(&mut self, name: &str, f: impl FnOnce(&mut SyntaxBuilder)) { 10 | self.functions.define(name, f) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /archive/prototypes/06/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "cp6" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | anyhow = "*" 8 | console_error_panic_hook = "*" 9 | console_log = "*" 10 | js-sys = "*" 11 | log = "*" 12 | sycamore = "*" 13 | thiserror = "*" 14 | 15 | [dependencies.web-sys] 16 | version = "*" 17 | features = ["KeyboardEvent"] 18 | -------------------------------------------------------------------------------- /archive/prototypes/11/crosscut/game-engine/src/command.rs: -------------------------------------------------------------------------------- 1 | use crosscut_compiler::Instructions; 2 | 3 | #[derive(Clone, Debug, serde::Deserialize, serde::Serialize)] 4 | pub enum Command { 5 | ClearBreakpointAndContinue, 6 | ClearBreakpointAndEvaluateNextInstruction, 7 | Reset, 8 | Stop, 9 | UpdateCode { instructions: Instructions }, 10 | } 11 | -------------------------------------------------------------------------------- /archive/prototypes/06/src/main.rs: -------------------------------------------------------------------------------- 1 | mod cp; 2 | mod ui; 3 | 4 | fn main() -> anyhow::Result<()> { 5 | console_error_panic_hook::set_once(); 6 | console_log::init_with_level(log::Level::Debug) 7 | .expect("Error initializing logging"); 8 | 9 | let test_runner = cp::TestRunner::new()?; 10 | ui::render(test_runner); 11 | 12 | Ok(()) 13 | } 14 | -------------------------------------------------------------------------------- /tools/daily/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::fs::File; 2 | 3 | use chrono::Local; 4 | 5 | fn main() -> anyhow::Result<()> { 6 | let date = Local::now().format("%Y-%m-%d"); 7 | let path = format!("website/content/daily/{date}.md"); 8 | 9 | File::create_new(&path)?; 10 | println!(); 11 | println!("\t{path}"); 12 | println!(); 13 | 14 | Ok(()) 15 | } 16 | -------------------------------------------------------------------------------- /archive/prototypes/08/capi-vm/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "capi-vm" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [features] 7 | std = ["thiserror"] 8 | 9 | 10 | [dependencies.thiserror] 11 | version = "*" 12 | optional = true 13 | 14 | 15 | [dev-dependencies] 16 | anyhow = "*" 17 | 18 | [dev-dependencies.capi-vm] 19 | path = "." 20 | features = ["std"] 21 | -------------------------------------------------------------------------------- /archive/prototypes/10/capi-debug/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Caterpillar 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /archive/prototypes/03/src/cp/pipeline/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod a_tokenizer; 2 | pub mod b_parser; 3 | pub mod c_analyzer; 4 | pub mod d_evaluator; 5 | 6 | pub use self::{ 7 | a_tokenizer::Tokenizer, 8 | b_parser::parse, 9 | c_analyzer::analyze, 10 | d_evaluator::{evaluate, Error as EvaluatorError}, 11 | }; 12 | 13 | pub struct Pipeline { 14 | pub tokenizer: Tokenizer, 15 | } 16 | -------------------------------------------------------------------------------- /archive/prototypes/08/capi-builder/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "capi-builder" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | 7 | [dependencies] 8 | anyhow = "*" 9 | notify-debouncer-mini = "*" 10 | rocket = "*" 11 | tempfile = "*" 12 | 13 | [dependencies.capi-assembler] 14 | path = "../capi-assembler" 15 | 16 | [dependencies.tokio] 17 | version = "*" 18 | features = ["full"] 19 | -------------------------------------------------------------------------------- /archive/prototypes/11/crosscut/debugger/src/model/user_action.rs: -------------------------------------------------------------------------------- 1 | use crosscut_compiler::code::syntax::MemberLocation; 2 | 3 | #[derive(Clone)] 4 | pub enum UserAction { 5 | BreakpointClear { expression: MemberLocation }, 6 | BreakpointSet { expression: MemberLocation }, 7 | Continue, 8 | Reset, 9 | StepIn, 10 | StepOut, 11 | StepOver, 12 | Stop, 13 | } 14 | -------------------------------------------------------------------------------- /archive/prototypes/11/crosscut/runtime/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "crosscut-runtime" 3 | edition = "2021" 4 | 5 | [dependencies.serde] 6 | version = "*" 7 | default-features = false 8 | features = ["alloc", "derive"] 9 | 10 | [dependencies.thiserror] 11 | version = "*" 12 | default-features = false 13 | 14 | [dependencies.udigest] 15 | version = "*" 16 | features = ["derive"] 17 | -------------------------------------------------------------------------------- /crosscut/src/language/code/nodes_uniform/mod.rs: -------------------------------------------------------------------------------- 1 | mod children; 2 | mod hash; 3 | mod located; 4 | mod nodes; 5 | mod path; 6 | mod syntax_node; 7 | 8 | pub use self::{ 9 | children::{ChildIndex, Children}, 10 | hash::{NodeByHash, NodeHash}, 11 | located::LocatedNode, 12 | nodes::Nodes, 13 | path::NodePath, 14 | syntax_node::{NodeAsUniform, SyntaxNode}, 15 | }; 16 | -------------------------------------------------------------------------------- /archive/prototypes/02/src/cp/keywords.rs: -------------------------------------------------------------------------------- 1 | #[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd)] 2 | pub enum Keyword { 3 | Fn, 4 | Test, 5 | } 6 | 7 | impl Keyword { 8 | pub fn parse(s: &str) -> Option { 9 | match s { 10 | "fn" => Some(Self::Fn), 11 | "test" => Some(Self::Test), 12 | _ => None, 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /archive/prototypes/11/crosscut/compiler/src/code/syntax/location/mod.rs: -------------------------------------------------------------------------------- 1 | mod located; 2 | 3 | mod binding; 4 | mod branch; 5 | mod expression; 6 | mod function; 7 | mod member; 8 | mod named_function; 9 | mod parameter; 10 | 11 | pub use self::{ 12 | branch::BranchLocation, function::FunctionLocation, located::Located, 13 | member::MemberLocation, parameter::ParameterLocation, 14 | }; 15 | -------------------------------------------------------------------------------- /archive/prototypes/10/capi-runtime/src/debugger/event.rs: -------------------------------------------------------------------------------- 1 | use crate::InstructionAddress; 2 | 3 | #[derive(Clone, Debug, serde::Deserialize, serde::Serialize)] 4 | pub enum DebugEvent { 5 | Continue { 6 | and_stop_at: Option, 7 | }, 8 | Reset, 9 | Step, 10 | Stop, 11 | ToggleBreakpoint { 12 | address: InstructionAddress, 13 | }, 14 | } 15 | -------------------------------------------------------------------------------- /archive/prototypes/00/css/main.css: -------------------------------------------------------------------------------- 1 | html, 2 | body { 3 | height: 100%; 4 | margin: 0; 5 | } 6 | 7 | body>* { 8 | width: 50%; 9 | height: 100%; 10 | } 11 | 12 | div.editor { 13 | display: inline-block; 14 | } 15 | 16 | div.editor textarea { 17 | width: 100%; 18 | height: 100%; 19 | 20 | margin: 0; 21 | border-width: 0; 22 | padding: 0; 23 | 24 | resize: none; 25 | } -------------------------------------------------------------------------------- /archive/prototypes/04/src/cp/chars.rs: -------------------------------------------------------------------------------- 1 | use std::collections::VecDeque; 2 | 3 | pub struct Chars { 4 | inner: VecDeque, 5 | } 6 | 7 | impl Chars { 8 | pub fn new(code: &str) -> Self { 9 | Self { 10 | inner: code.chars().collect(), 11 | } 12 | } 13 | 14 | pub async fn next(&mut self) -> Option { 15 | self.inner.pop_front() 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /crosscut/src/language/code/nodes_typed/mod.rs: -------------------------------------------------------------------------------- 1 | mod apply; 2 | mod binding; 3 | mod body; 4 | mod children; 5 | mod function; 6 | mod tuple; 7 | mod typed_node; 8 | 9 | pub use self::{ 10 | apply::Apply, 11 | binding::Binding, 12 | body::Body, 13 | children::{TypedChild, TypedChildren}, 14 | function::Function, 15 | tuple::Tuple, 16 | typed_node::{Expression, TypedNode}, 17 | }; 18 | -------------------------------------------------------------------------------- /archive/prototypes/11/crosscut/game-engine/src/memory.rs: -------------------------------------------------------------------------------- 1 | /// Linear memory that games can access 2 | #[derive(Clone, Debug, Eq, PartialEq, serde::Deserialize, serde::Serialize)] 3 | pub struct Memory { 4 | #[serde(with = "serde_big_array::BigArray")] 5 | pub inner: [u8; 256], 6 | } 7 | 8 | impl Default for Memory { 9 | fn default() -> Self { 10 | Self { inner: [0; 256] } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /archive/prototypes/08/capi-vm/src/opcode.rs: -------------------------------------------------------------------------------- 1 | pub const TERMINATE: u8 = 0x00; 2 | pub const JUMP: u8 = 0x01; 3 | pub const CALL: u8 = 0x02; 4 | pub const PUSH: u8 = 0x03; 5 | pub const DROP: u8 = 0x04; 6 | // 0x05 reserved for `load` 7 | pub const STORE: u8 = 0x06; 8 | pub const CLONE: u8 = 0x07; 9 | pub const SWAP: u8 = 0x08; 10 | pub const AND: u8 = 0x09; 11 | pub const OR: u8 = 0x0a; 12 | pub const ROL: u8 = 0x0b; 13 | -------------------------------------------------------------------------------- /archive/prototypes/01/src/cp/functions/function.rs: -------------------------------------------------------------------------------- 1 | use crate::cp::{parse, tokenize, Expressions}; 2 | 3 | pub struct Function { 4 | pub name: String, 5 | pub body: Expressions, 6 | } 7 | 8 | impl Function { 9 | pub fn new(name: impl Into, body: &str) -> Self { 10 | Function { 11 | name: name.into(), 12 | body: parse(tokenize(body)), 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /archive/prototypes/10/capi-debug/src/components/panel.rs: -------------------------------------------------------------------------------- 1 | use leptos::{component, view, Children, IntoView}; 2 | 3 | #[component] 4 | pub fn Panel(children: Children, class: &'static str) -> impl IntoView { 5 | let class = 6 | format!("mx-1 my-3 border p-1 relative overflow-y-auto {class}"); 7 | 8 | view! { 9 |
10 | {children()} 11 |
12 | } 13 | } 14 | -------------------------------------------------------------------------------- /archive/prototypes/05/src/cp/code/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod intrinsics; 2 | pub mod std; 3 | pub mod tests; 4 | 5 | use super::Functions; 6 | 7 | pub fn define_code() -> anyhow::Result<(Functions, Functions)> { 8 | let mut functions = Functions::new(); 9 | intrinsics::define(&mut functions); 10 | std::define(&mut functions)?; 11 | 12 | let tests = tests::define(&mut functions)?; 13 | 14 | Ok((functions, tests)) 15 | } 16 | -------------------------------------------------------------------------------- /archive/prototypes/11/crosscut/host/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "crosscut-host" 3 | edition = "2021" 4 | 5 | [dependencies] 6 | anyhow = "*" 7 | ron = "*" 8 | 9 | [dependencies.crosscut-game-engine] 10 | path = "../game-engine" 11 | 12 | [dependencies.crosscut-ffi] 13 | path = "../ffi" 14 | 15 | [dependencies.crosscut-protocol] 16 | path = "../protocol" 17 | 18 | [dependencies.crosscut-runtime] 19 | path = "../runtime" 20 | -------------------------------------------------------------------------------- /archive/prototypes/11/crosscut/protocol/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "crosscut-protocol" 3 | edition = "2021" 4 | 5 | [dependencies] 6 | ron = "*" 7 | 8 | [dependencies.crosscut-compiler] 9 | path = "../compiler" 10 | 11 | [dependencies.crosscut-game-engine] 12 | path = "../game-engine" 13 | 14 | [dependencies.crosscut-runtime] 15 | path = "../runtime" 16 | 17 | [dependencies.serde] 18 | version = "*" 19 | features = ["derive"] 20 | -------------------------------------------------------------------------------- /archive/prototypes/12/src/language/code/mod.rs: -------------------------------------------------------------------------------- 1 | mod body; 2 | mod codebase; 3 | mod errors; 4 | mod fragments; 5 | mod location; 6 | mod replacements; 7 | 8 | pub use self::{ 9 | body::Body, 10 | codebase::{Codebase, Expression, FunctionCallTarget, Literal}, 11 | errors::CodeError, 12 | fragments::{Node, NodeError, NodeId, NodeKind, Nodes}, 13 | location::{Located, Location}, 14 | replacements::Replacements, 15 | }; 16 | -------------------------------------------------------------------------------- /archive/prototypes/03/src/cp/keywords.rs: -------------------------------------------------------------------------------- 1 | #[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd)] 2 | pub enum Keyword { 3 | Fn, 4 | Mod, 5 | Test, 6 | } 7 | 8 | impl Keyword { 9 | pub fn parse(s: &str) -> Option { 10 | match s { 11 | "fn" => Some(Self::Fn), 12 | "mod" => Some(Self::Mod), 13 | "test" => Some(Self::Test), 14 | _ => None, 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /archive/prototypes/03/src/functions.rs: -------------------------------------------------------------------------------- 1 | use crate::cp; 2 | 3 | pub fn define() -> anyhow::Result { 4 | let mut functions = cp::Functions::new(); 5 | 6 | let code = r#" 7 | "#; 8 | 9 | let data_stack = cp::execute(code.chars(), &mut functions)?; 10 | if !data_stack.is_empty() { 11 | anyhow::bail!("Defining functions left values on stack: {data_stack:?}") 12 | } 13 | 14 | Ok(functions) 15 | } 16 | -------------------------------------------------------------------------------- /crosscut/src/language/tests/math.rs: -------------------------------------------------------------------------------- 1 | use crate::language::{language::Language, runtime::Value}; 2 | 3 | #[test] 4 | fn add() { 5 | let mut language = Language::new(); 6 | language 7 | .code("apply") 8 | .down() 9 | .code("+") 10 | .down() 11 | .code("tuple 1\n2"); 12 | 13 | assert_eq!( 14 | language.step_until_finished().unwrap(), 15 | Value::Integer { value: 3 }, 16 | ); 17 | } 18 | -------------------------------------------------------------------------------- /archive/prototypes/13/src/game_engine/mod.rs: -------------------------------------------------------------------------------- 1 | mod editor; 2 | mod game_engine; 3 | 4 | pub use self::{ 5 | editor::input::TerminalInputEvent, 6 | game_engine::{GameEngine, GameInput, GameOutput}, 7 | }; 8 | 9 | #[cfg(test)] 10 | #[allow(unused)] // used only intermittently, to debug tests 11 | pub use self::editor::output::codebase_to_stdout; 12 | 13 | #[cfg(test)] 14 | pub use self::editor::output::codebase_to_string; 15 | 16 | #[cfg(test)] 17 | mod tests; 18 | -------------------------------------------------------------------------------- /archive/prototypes/06/src/cp/code/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod intrinsics; 2 | pub mod std; 3 | 4 | use super::Functions; 5 | 6 | pub fn define_code() -> anyhow::Result<(Functions, Functions)> { 7 | let mut functions = Functions::new(); 8 | let mut tests = Functions::new(); 9 | 10 | intrinsics::code::define(&mut functions)?; 11 | intrinsics::tests::define(&mut functions, &mut tests)?; 12 | std::define(&mut functions, &mut tests)?; 13 | 14 | Ok((functions, tests)) 15 | } 16 | -------------------------------------------------------------------------------- /archive/prototypes/10/capi-debug/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "capi-debug" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | console_error_panic_hook = "*" 8 | futures = "*" 9 | gloo = "*" 10 | log = "*" 11 | ron = "*" 12 | web-sys = "*" 13 | 14 | [dependencies.capi-runtime] 15 | path = "../capi-runtime" 16 | 17 | [dependencies.console_log] 18 | version = "*" 19 | features = ["color"] 20 | 21 | [dependencies.leptos] 22 | version = "*" 23 | features = ["csr"] 24 | -------------------------------------------------------------------------------- /archive/prototypes/07/tests/array.capi: -------------------------------------------------------------------------------- 1 | "len" 2 | { 3 | [ 0 1 ] len 4 | [ :result ] bind 5 | drop 6 | 7 | result 2 = 8 | } 9 | test 10 | 11 | "unwrap" 12 | { 13 | [ true false ] 14 | unwrap 15 | drop 16 | } 17 | test 18 | 19 | "eager evaluation" 20 | { 21 | true 22 | false 23 | [ drop ] 24 | drop 25 | } 26 | test 27 | 28 | "tokenization" 29 | { 30 | [true]unwrap[true]unwrap and 31 | } 32 | test 33 | -------------------------------------------------------------------------------- /crosscut/src/language/code/nodes_typed/binding.rs: -------------------------------------------------------------------------------- 1 | use crate::language::code::{NodeHash, Nodes, SyntaxNode}; 2 | 3 | #[derive(Debug)] 4 | pub struct Binding { 5 | pub name: String, 6 | } 7 | 8 | impl Binding { 9 | pub fn from_hash(hash: &NodeHash, nodes: &Nodes) -> Self { 10 | let SyntaxNode::Binding { name } = nodes.get(hash) else { 11 | panic!("Expected node to be a binding."); 12 | }; 13 | 14 | Self { name: name.clone() } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /archive/prototypes/05/src/cp/namespace/function.rs: -------------------------------------------------------------------------------- 1 | use crate::cp::{ 2 | pipeline::ir::analyzer_output::AnalyzerOutput, Evaluator, EvaluatorError, 3 | }; 4 | 5 | #[derive(Clone, Debug)] 6 | pub struct Function { 7 | pub module: String, 8 | pub body: FunctionBody, 9 | } 10 | 11 | #[derive(Clone, Debug)] 12 | pub enum FunctionBody { 13 | Intrinsic(Intrinsic), 14 | UserDefined(AnalyzerOutput), 15 | } 16 | 17 | pub type Intrinsic = fn(&mut Evaluator) -> Result<(), EvaluatorError>; 18 | -------------------------------------------------------------------------------- /archive/prototypes/12/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | 3 | [package] 4 | name = "crosscut" 5 | edition = "2021" 6 | 7 | [dependencies] 8 | anyhow = "*" 9 | base64 = "*" 10 | crossbeam-channel = "*" 11 | crossterm = "*" 12 | itertools = "*" 13 | pollster = "*" 14 | pretty_assertions = "*" 15 | thiserror = "*" 16 | wgpu = "*" 17 | winit = "*" 18 | 19 | [dependencies.blake3] 20 | version = "*" 21 | features = ["traits-preview"] 22 | 23 | [dependencies.udigest] 24 | version = "*" 25 | features = ["derive"] 26 | -------------------------------------------------------------------------------- /archive/prototypes/07/capi-core/src/lib.rs: -------------------------------------------------------------------------------- 1 | // I don't see the point of this lint. That weird case they present in its 2 | // documentation certainly doesn't apply to me, and I've also never seen it 3 | // anywhere else. 4 | // 5 | // We have a `clippy.toml` that is supposed to allow this for private modules, 6 | // but it doesn't seem to work. Or I'm holding it wrong. I don't know. 7 | #![allow(clippy::module_inception)] 8 | 9 | pub mod pipeline; 10 | pub mod platform; 11 | pub mod repr; 12 | pub mod runtime; 13 | -------------------------------------------------------------------------------- /archive/prototypes/11/crosscut/debugger/src/ui/components/panel.rs: -------------------------------------------------------------------------------- 1 | use leptos::{ 2 | children::Children, 3 | component, 4 | prelude::{ClassAttribute, ElementChild}, 5 | view, IntoView, 6 | }; 7 | 8 | #[component] 9 | pub fn Panel(children: Children, class: &'static str) -> impl IntoView { 10 | let class = 11 | format!("mx-1 my-3 border p-1 relative overflow-y-auto {class}"); 12 | 13 | view! { 14 |
15 | {children()} 16 |
17 | } 18 | } 19 | -------------------------------------------------------------------------------- /crosscut/src/util/form.rs: -------------------------------------------------------------------------------- 1 | use std::marker::PhantomData; 2 | 3 | pub trait Form { 4 | type Form; 5 | } 6 | 7 | #[derive(Debug)] 8 | pub struct Owned; 9 | 10 | impl Form for Owned { 11 | type Form = T; 12 | } 13 | 14 | pub struct Ref<'r>(PhantomData<&'r ()>); 15 | 16 | impl<'r> Form for Ref<'r> { 17 | type Form = &'r T; 18 | } 19 | 20 | pub struct RefMut<'r>(PhantomData<&'r mut ()>); 21 | 22 | impl<'r> Form for RefMut<'r> { 23 | type Form = &'r mut T; 24 | } 25 | -------------------------------------------------------------------------------- /crosscut/src/language/code/mod.rs: -------------------------------------------------------------------------------- 1 | mod changes; 2 | mod codebase; 3 | mod nodes_typed; 4 | mod nodes_uniform; 5 | mod types; 6 | 7 | pub use self::{ 8 | changes::{Changes, NewChangeSet}, 9 | codebase::Codebase, 10 | nodes_typed::{Apply, Body, Expression, Function, Tuple, TypedNode}, 11 | nodes_uniform::{ 12 | ChildIndex, LocatedNode, NodeAsUniform, NodeByHash, NodeHash, NodePath, 13 | Nodes, SyntaxNode, 14 | }, 15 | types::{Type, display_tuple}, 16 | }; 17 | 18 | #[cfg(test)] 19 | mod tests; 20 | -------------------------------------------------------------------------------- /archive/prototypes/09/capi-runtime/src/lang/data_stack.rs: -------------------------------------------------------------------------------- 1 | #[derive(Debug)] 2 | pub struct DataStack { 3 | values: Vec, 4 | } 5 | 6 | impl DataStack { 7 | pub fn new() -> Self { 8 | Self { values: Vec::new() } 9 | } 10 | 11 | pub fn push(&mut self, value: usize) { 12 | self.values.push(value); 13 | } 14 | 15 | pub fn pop(&mut self) -> usize { 16 | self.values.pop().unwrap() 17 | } 18 | 19 | pub fn num_values(&self) -> usize { 20 | self.values.len() 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /archive/prototypes/11/crosscut/compiler/src/code/tokens/mod.rs: -------------------------------------------------------------------------------- 1 | //! # A basic code representation, mirroring the raw input 2 | //! 3 | //! Tokens almost fully mirror the raw text that the developer inputs, only 4 | //! ignoring whitespace. They are the first semi-structured code representation 5 | //! that the compiler produces, laying the groundwork for parsing. 6 | 7 | mod token; 8 | mod tokenize; 9 | mod tokens; 10 | 11 | pub use self::{ 12 | token::{Keyword, Punctuator, Token}, 13 | tokens::{NoMoreTokens, Tokens}, 14 | }; 15 | -------------------------------------------------------------------------------- /archive/prototypes/13/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | members = ["tools/daily", "tools/website"] 3 | 4 | [package] 5 | name = "crosscut" 6 | edition = "2024" 7 | 8 | [dependencies] 9 | anyhow = "*" 10 | base64 = "*" 11 | crossbeam-channel = "*" 12 | crossterm = "*" 13 | itertools = "*" 14 | panic-message = "*" 15 | pollster = "*" 16 | thiserror = "*" 17 | wgpu = "*" 18 | winit = "*" 19 | 20 | [dependencies.blake3] 21 | version = "*" 22 | features = ["traits-preview"] 23 | 24 | [dependencies.udigest] 25 | version = "*" 26 | features = ["derive"] 27 | -------------------------------------------------------------------------------- /archive/prototypes/13/src/language/code/mod.rs: -------------------------------------------------------------------------------- 1 | mod changes; 2 | mod codebase; 3 | mod errors; 4 | mod intrinsics; 5 | mod nodes; 6 | mod types; 7 | 8 | pub use self::{ 9 | changes::{Changes, NewChangeSet}, 10 | codebase::Codebase, 11 | errors::{CandidateForResolution, CodeError, Errors, Literal}, 12 | intrinsics::IntrinsicFunction, 13 | nodes::{ 14 | Children, LocatedNode, Node, NodeHash, NodePath, Nodes, SiblingIndex, 15 | }, 16 | types::{Type, display_tuple}, 17 | }; 18 | 19 | #[cfg(test)] 20 | mod tests; 21 | -------------------------------------------------------------------------------- /archive/prototypes/02/src/cp/functions.rs: -------------------------------------------------------------------------------- 1 | use std::collections::BTreeMap; 2 | 3 | use super::expressions::ExpressionGraph; 4 | 5 | #[derive(Debug, Eq, PartialEq, Ord, PartialOrd)] 6 | pub struct Functions { 7 | pub registry: BTreeMap, 8 | } 9 | 10 | impl Functions { 11 | pub fn new() -> Self { 12 | Self { 13 | registry: BTreeMap::new(), 14 | } 15 | } 16 | } 17 | 18 | #[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd)] 19 | pub struct Function { 20 | pub body: ExpressionGraph, 21 | } 22 | -------------------------------------------------------------------------------- /archive/prototypes/03/src/cp/values.rs: -------------------------------------------------------------------------------- 1 | use super::expressions::ExpressionGraph; 2 | 3 | #[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Debug)] 4 | pub enum Value { 5 | Array(Vec), 6 | Block { expressions: ExpressionGraph }, 7 | Bool(bool), 8 | String(String), 9 | U8(u8), 10 | } 11 | 12 | impl From for Value { 13 | fn from(value: bool) -> Self { 14 | Self::Bool(value) 15 | } 16 | } 17 | 18 | impl From for Value { 19 | fn from(value: u8) -> Self { 20 | Self::U8(value) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /archive/prototypes/03/src/cp/call_stack.rs: -------------------------------------------------------------------------------- 1 | use std::collections::BTreeMap; 2 | 3 | use super::values::Value; 4 | 5 | pub struct CallStack; 6 | 7 | impl CallStack { 8 | pub fn new_stack_frame(&mut self) -> StackFrame { 9 | StackFrame::new() 10 | } 11 | } 12 | 13 | pub struct StackFrame { 14 | pub bindings: Bindings, 15 | } 16 | 17 | impl StackFrame { 18 | pub fn new() -> Self { 19 | Self { 20 | bindings: Bindings::new(), 21 | } 22 | } 23 | } 24 | 25 | pub type Bindings = BTreeMap; 26 | -------------------------------------------------------------------------------- /archive/prototypes/02/src/cp/call_stack.rs: -------------------------------------------------------------------------------- 1 | use std::collections::BTreeMap; 2 | 3 | use super::data_stack::Value; 4 | 5 | pub struct CallStack; 6 | 7 | impl CallStack { 8 | pub fn new_stack_frame(&mut self) -> StackFrame { 9 | StackFrame::new() 10 | } 11 | } 12 | 13 | pub struct StackFrame { 14 | pub bindings: Bindings, 15 | } 16 | 17 | impl StackFrame { 18 | pub fn new() -> Self { 19 | Self { 20 | bindings: Bindings::new(), 21 | } 22 | } 23 | } 24 | 25 | pub type Bindings = BTreeMap; 26 | -------------------------------------------------------------------------------- /archive/prototypes/01/src/cp/bindings.rs: -------------------------------------------------------------------------------- 1 | use std::collections::BTreeMap; 2 | 3 | use super::Value; 4 | 5 | pub struct Bindings { 6 | inner: BTreeMap, 7 | } 8 | 9 | impl Bindings { 10 | pub fn new() -> Self { 11 | Self { 12 | inner: BTreeMap::new(), 13 | } 14 | } 15 | 16 | pub fn create(&mut self, name: String, value: Value) { 17 | self.inner.insert(name, value); 18 | } 19 | 20 | pub fn resolve(&self, name: &str) -> Option { 21 | self.inner.get(name).cloned() 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /archive/prototypes/01/src/cp/functions/registry.rs: -------------------------------------------------------------------------------- 1 | use super::Function; 2 | 3 | pub struct Registry { 4 | inner: Vec, 5 | } 6 | 7 | impl Registry { 8 | pub fn new() -> Self { 9 | let inner = Vec::new(); 10 | Self { inner } 11 | } 12 | 13 | pub fn define(&mut self, name: impl Into, body: &str) { 14 | self.inner.push(Function::new(name, body)); 15 | } 16 | 17 | pub fn resolve(&self, name: &str) -> Option<&Function> { 18 | self.inner.iter().find(|function| function.name == name) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /archive/prototypes/07/capi-web/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "capi-web" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | 7 | [dependencies] 8 | anyhow = "*" 9 | async-channel = "*" 10 | chrono = "*" 11 | console_error_panic_hook = "*" 12 | futures = "*" 13 | sycamore = "*" 14 | tracing = "*" 15 | tracing-wasm = "*" 16 | wasm-bindgen-futures = "*" 17 | web-sys = "*" 18 | 19 | [dependencies.capi-core] 20 | path = "../capi-core" 21 | 22 | [dependencies.gloo-timers] 23 | version = "*" 24 | features = ["futures"] 25 | 26 | 27 | [build-dependencies] 28 | anyhow = "*" 29 | -------------------------------------------------------------------------------- /archive/prototypes/11/crosscut/debugger/src/ui/actions.rs: -------------------------------------------------------------------------------- 1 | use tokio::sync::mpsc; 2 | 3 | use crate::model::UserAction; 4 | 5 | pub type ActionsTx = mpsc::UnboundedSender; 6 | 7 | pub async fn send_action(action: UserAction, actions: ActionsTx) { 8 | if let Err(err) = actions.send(action) { 9 | log::error!( 10 | "Sending a UI action failed, as the receive is no longer \ 11 | available: {err:#?}\n\ 12 | \n\ 13 | This is most likely a bug in the Crosscut debugger." 14 | ); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /archive/prototypes/11/crosscut/debugger/src/ui/init.rs: -------------------------------------------------------------------------------- 1 | use leptos::prelude::ReadSignal; 2 | 3 | use crate::{ 4 | model::{PersistentState, TransientState}, 5 | ui::components::debugger::Debugger, 6 | }; 7 | 8 | use super::ActionsTx; 9 | 10 | pub fn init( 11 | state: ReadSignal<(PersistentState, TransientState)>, 12 | actions: ActionsTx, 13 | ) { 14 | leptos::mount::mount_to_body(move || { 15 | leptos::view! { 16 | 19 | } 20 | }); 21 | } 22 | -------------------------------------------------------------------------------- /archive/prototypes/11/tools/builder/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "builder" 3 | edition = "2021" 4 | publish = false 5 | 6 | [dependencies] 7 | anyhow = "*" 8 | tempfile = "*" 9 | tracing = "*" 10 | walkdir = "*" 11 | wasm-bindgen-cli-support = "*" 12 | 13 | [dependencies.crosscut-watch] 14 | path = "../../crosscut/watch" 15 | 16 | [dependencies.clap] 17 | version = "*" 18 | features = ["derive"] 19 | 20 | [dependencies.tokio] 21 | version = "*" 22 | features = ["full"] 23 | 24 | [dependencies.tracing-subscriber] 25 | version = "*" 26 | features = ["env-filter"] 27 | -------------------------------------------------------------------------------- /archive/prototypes/06/src/cp/namespace/function.rs: -------------------------------------------------------------------------------- 1 | use crate::cp::{ 2 | pipeline::ir::analyzer_output::AnalyzerOutput, Evaluator, EvaluatorError, 3 | }; 4 | 5 | #[derive(Clone, Debug, Eq, PartialEq)] 6 | pub struct Function { 7 | pub module: String, 8 | pub name: String, 9 | pub body: FunctionBody, 10 | pub is_test: bool, 11 | } 12 | 13 | #[derive(Clone, Debug, Eq, PartialEq)] 14 | pub enum FunctionBody { 15 | Intrinsic(Intrinsic), 16 | UserDefined(AnalyzerOutput), 17 | } 18 | 19 | pub type Intrinsic = fn(&mut Evaluator) -> Result<(), EvaluatorError>; 20 | -------------------------------------------------------------------------------- /archive/prototypes/07/capi-desktop/src/lib.rs: -------------------------------------------------------------------------------- 1 | // I don't see the point of this lint. That weird case they present in its 2 | // documentation certainly doesn't apply to me, and I've also never seen it 3 | // anywhere else. 4 | // 5 | // We have a `clippy.toml` that is supposed to allow this for private modules, 6 | // but it doesn't seem to work. Or I'm holding it wrong. I don't know. 7 | #![allow(clippy::module_inception)] 8 | 9 | pub mod args; 10 | pub mod display; 11 | pub mod loader; 12 | pub mod platform; 13 | pub mod thread; 14 | 15 | pub use self::thread::DesktopThread; 16 | -------------------------------------------------------------------------------- /archive/prototypes/00/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | 3 | [package] 4 | name = "caterpillar" 5 | version = "0.1.0" 6 | edition = "2021" 7 | 8 | [dependencies] 9 | anyhow = "1.0.68" 10 | console_error_panic_hook = "0.1.7" 11 | log = "0.4.17" 12 | raw-window-handle = "0.5.0" 13 | sycamore = "0.8.2" 14 | wasm-bindgen-futures = "0.4.33" 15 | web-sys = "0.3.60" 16 | wasm-bindgen = "0.2.83" 17 | futures = "0.3.25" 18 | gloo = "0.8.0" 19 | 20 | [dependencies.console_log] 21 | version = "0.2.0" 22 | features = ["color"] 23 | 24 | [dependencies.wgpu] 25 | version = "0.15.0" 26 | features = ["webgl"] 27 | -------------------------------------------------------------------------------- /archive/prototypes/00/src/html.rs: -------------------------------------------------------------------------------- 1 | use sycamore::prelude::*; 2 | 3 | use crate::language::Interpreter; 4 | 5 | pub fn render(canvas_id: u32, interpreter: Interpreter) { 6 | sycamore::render(|cx| { 7 | let code = create_signal(cx, String::new()); 8 | create_effect(cx, move || { 9 | interpreter.interpret(&code.get()); 10 | }); 11 | 12 | view! { cx, 13 | div(class="editor") { 14 | textarea(bind:value=code) {} 15 | } 16 | canvas(data-raw-handle=(canvas_id)) {} 17 | } 18 | }); 19 | } 20 | -------------------------------------------------------------------------------- /crosscut/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "crosscut" 3 | edition = "2024" 4 | 5 | [dependencies] 6 | anyhow = "*" 7 | async-trait = "*" 8 | base64 = "*" 9 | crossbeam-channel = "*" 10 | crossterm = "*" 11 | glam = "*" 12 | glyphon = "*" 13 | itertools = "*" 14 | panic-message = "*" 15 | pollster = "*" 16 | thiserror = "*" 17 | wgpu = "*" 18 | winit = "*" 19 | 20 | [dependencies.blake3] 21 | version = "*" 22 | features = ["traits-preview"] 23 | 24 | [dependencies.bytemuck] 25 | version = "*" 26 | features = ["derive"] 27 | 28 | [dependencies.udigest] 29 | version = "*" 30 | features = ["derive"] 31 | -------------------------------------------------------------------------------- /archive/prototypes/11/crosscut/compiler/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "crosscut-compiler" 3 | edition = "2021" 4 | 5 | 6 | [dependencies] 7 | array-util = "*" 8 | itertools = "*" 9 | petgraph = "*" 10 | 11 | [dependencies.blake3] 12 | version = "*" 13 | features = ["serde", "traits-preview"] 14 | 15 | [dependencies.crosscut-runtime] 16 | path = "../runtime" 17 | 18 | [dependencies.serde] 19 | version = "*" 20 | features = ["derive"] 21 | 22 | [dependencies.thiserror] 23 | version = "*" 24 | default-features = false 25 | 26 | [dependencies.udigest] 27 | version = "*" 28 | features = ["derive"] 29 | -------------------------------------------------------------------------------- /archive/prototypes/10/capi-runtime/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod debugger; 2 | pub mod syntax; 3 | 4 | mod breakpoints; 5 | mod builtins; 6 | mod call_stack; 7 | mod code; 8 | mod compiler; 9 | mod data_stack; 10 | mod evaluator; 11 | mod instructions; 12 | mod program; 13 | mod runtime; 14 | mod source_map; 15 | 16 | pub use self::{ 17 | builtins::BuiltinEffect, 18 | compiler::compile, 19 | data_stack::{DataStack, Value}, 20 | evaluator::{Evaluator, EvaluatorEffectKind}, 21 | instructions::InstructionAddress, 22 | program::{Program, ProgramEffect, ProgramEffectKind, ProgramState}, 23 | }; 24 | -------------------------------------------------------------------------------- /archive/prototypes/09/capi-builder/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "capi-builder" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | anyhow = "*" 8 | futures = "*" 9 | http = "0.2" # needs to be in sync with warp 10 | tempfile = "*" 11 | warp = "*" 12 | 13 | [dependencies.notify] 14 | version = "*" 15 | default-features = false # `crossbeam` feature can conflict with Tokio 16 | 17 | [dependencies.notify-debouncer-mini] 18 | version = "*" 19 | default-features = false # `crossbeam` feature can conflict with Tokio 20 | 21 | [dependencies.tokio] 22 | version = "*" 23 | features = ["full"] 24 | -------------------------------------------------------------------------------- /archive/prototypes/07/tests.capi: -------------------------------------------------------------------------------- 1 | # This is an entry point script that includes all Caterpillar scripts that have 2 | # tests in them. It is intended to be run like this: 3 | # 4 | # ``` 5 | # capi tests.capi test 6 | # ``` 7 | # 8 | # Or, if you haven't `cargo install`ed `capi`, like this: 9 | # 10 | # ``` 11 | # cargo run -- tests.capi test 12 | # ``` 13 | 14 | [ :lib :std ] mod 15 | [ :tests :array ] mod 16 | [ :tests :basics ] mod 17 | [ :tests :binding ] mod 18 | [ :tests :block ] mod 19 | [ :tests :bool ] mod 20 | [ :tests :fn ] mod 21 | [ :tests :if ] mod 22 | [ :tests :symbol ] mod 23 | [ :tests :text ] mod 24 | -------------------------------------------------------------------------------- /archive/prototypes/05/src/cp/mod.rs: -------------------------------------------------------------------------------- 1 | mod code; 2 | mod execute; 3 | mod namespace; 4 | mod pipeline; 5 | mod runtime; 6 | mod test_runner; 7 | 8 | pub use self::{ 9 | code::{define_code, intrinsics, std, tests}, 10 | execute::{execute, Error}, 11 | namespace::{ 12 | Bindings, Function, FunctionBody, Functions, Intrinsic, Module, 13 | }, 14 | pipeline::{error::PipelineError, ir::analyzer_output::AnalyzerEvent}, 15 | runtime::{ 16 | data_stack::{DataStack, DataStackError}, 17 | evaluate::{Evaluator, EvaluatorError}, 18 | }, 19 | test_runner::{run_tests, TestReport}, 20 | }; 21 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "editor.formatOnPaste": true, 3 | "editor.formatOnSave": true, 4 | "rust-analyzer.check.command": "clippy", 5 | "rust-analyzer.showUnlinkedFileNotification": false, 6 | "search.exclude": { 7 | "archive/**": true 8 | }, 9 | "deno.enablePaths": [ 10 | "./website" 11 | ], 12 | "deno.config": "./website/deno.json", 13 | "typescript.format.enable": true, 14 | "[html]": { 15 | "editor.defaultFormatter": "denoland.vscode-deno" 16 | }, 17 | "[typescript]": { 18 | "editor.defaultFormatter": "denoland.vscode-deno" 19 | }, 20 | } 21 | -------------------------------------------------------------------------------- /archive/prototypes/11/crosscut/runtime/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![cfg_attr(not(test), no_std)] 2 | 3 | extern crate alloc; 4 | 5 | mod effects; 6 | mod evaluator; 7 | mod function; 8 | mod heap; 9 | mod instructions; 10 | mod operands; 11 | mod runtime; 12 | mod stack; 13 | mod value; 14 | 15 | pub use self::{ 16 | effects::{Effect, TriggerResult, TriggeredEffect}, 17 | function::{Branch, Function, Pattern}, 18 | heap::Heap, 19 | instructions::{Instruction, InstructionAddress, Instructions}, 20 | operands::{Operands, PopOperandError}, 21 | runtime::{Runtime, RuntimeState}, 22 | stack::Stack, 23 | value::Value, 24 | }; 25 | -------------------------------------------------------------------------------- /archive/prototypes/11/crosscut/debugger/src/model/mod.rs: -------------------------------------------------------------------------------- 1 | mod active_functions; 2 | mod branch; 3 | mod breakpoints; 4 | mod code; 5 | mod function; 6 | mod member; 7 | mod state; 8 | mod user_action; 9 | 10 | #[cfg(test)] 11 | mod tests; 12 | 13 | pub use self::{ 14 | active_functions::{ActiveFunctions, ActiveFunctionsEntry}, 15 | branch::{DebugBranch, DebugParameter}, 16 | breakpoints::Breakpoints, 17 | code::DebugCode, 18 | function::{DebugFunction, DebugNamedFunction}, 19 | member::{DebugMember, DebugMemberData, DebugMemberKind}, 20 | state::{PersistentState, TransientState}, 21 | user_action::UserAction, 22 | }; 23 | -------------------------------------------------------------------------------- /archive/prototypes/12/src/language/compiler/tests/infra.rs: -------------------------------------------------------------------------------- 1 | use crate::language::{ 2 | code::{Body, Codebase, Node, NodeKind}, 3 | compiler, 4 | host::Host, 5 | }; 6 | 7 | pub fn compile_all(input: &str, host: &Host, code: &mut Codebase) { 8 | for token in input.split_whitespace() { 9 | let to_replace = code.append_to( 10 | &code.find_innermost_fragment_with_valid_body(), 11 | Node { 12 | kind: NodeKind::Empty, 13 | body: Body::default(), 14 | }, 15 | ); 16 | 17 | compiler::compile_and_replace(token, &to_replace, host, code); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /archive/prototypes/13/src/language/code/intrinsics.rs: -------------------------------------------------------------------------------- 1 | use crate::language::packages::Function; 2 | 3 | #[derive( 4 | Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd, udigest::Digestable, 5 | )] 6 | pub enum IntrinsicFunction { 7 | Add, 8 | Drop, 9 | Eval, 10 | Identity, 11 | } 12 | 13 | impl Function for IntrinsicFunction { 14 | fn name(&self) -> &str { 15 | match self { 16 | IntrinsicFunction::Add => "+", 17 | IntrinsicFunction::Drop => "drop", 18 | IntrinsicFunction::Eval => "eval", 19 | IntrinsicFunction::Identity => "identity", 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /archive/prototypes/11/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | resolver = "2" 3 | members = [ 4 | "crosscut/cli", 5 | "crosscut/compiler", 6 | "crosscut/debugger", 7 | "crosscut/ffi", 8 | "crosscut/game-engine", 9 | "crosscut/host", 10 | "crosscut/protocol", 11 | "crosscut/runtime", 12 | "crosscut/watch", 13 | 14 | "tools/builder", 15 | ] 16 | default-members = ["tools/builder"] 17 | 18 | 19 | [profile.dev] 20 | opt-level = 3 # otherwise interpreted code becomes unbearably slow 21 | 22 | [profile.release] 23 | opt-level = "s" # results in the smallest code size for `crosscut-host.wasm` 24 | strip = "symbols" 25 | lto = "fat" 26 | -------------------------------------------------------------------------------- /archive/prototypes/06/src/ui/pass_fail.rs: -------------------------------------------------------------------------------- 1 | use sycamore::{component, reactive::Scope, view, view::View, web::Html}; 2 | 3 | #[component] 4 | pub fn PassFail(cx: Scope, props: Props) -> View { 5 | let class = { 6 | let color = if props.pass { 7 | "text-green-500" 8 | } else { 9 | "text-red-500" 10 | }; 11 | 12 | format!("font-bold mx-2 {color}") 13 | }; 14 | let text = if props.pass { "PASS" } else { "FAIL" }; 15 | 16 | view! { cx, 17 | span(class=class) { (text) } 18 | } 19 | } 20 | 21 | #[derive(sycamore::Prop)] 22 | pub struct Props { 23 | pass: bool, 24 | } 25 | -------------------------------------------------------------------------------- /archive/prototypes/07/capi-desktop/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "capi-desktop" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | 7 | [dependencies] 8 | anyhow = "*" 9 | crossbeam-channel = "*" 10 | crossterm = "*" 11 | error_reporter = "*" 12 | notify = "*" 13 | notify-debouncer-mini = "*" 14 | pixels = "*" 15 | tracing = "*" 16 | walkdir = "*" 17 | 18 | [dependencies.capi-core] 19 | path = "../capi-core" 20 | 21 | [dependencies.clap] 22 | version = "*" 23 | features = ["derive"] 24 | 25 | [dependencies.tracing-subscriber] 26 | version = "*" 27 | features = ["env-filter"] 28 | 29 | [dependencies.winit] 30 | version = "*" 31 | features = ["rwh_05"] 32 | -------------------------------------------------------------------------------- /archive/prototypes/07/capi-core/src/pipeline/scripts.rs: -------------------------------------------------------------------------------- 1 | use std::collections::BTreeMap; 2 | 3 | use crate::repr::eval::value; 4 | 5 | #[derive(Debug, Default)] 6 | pub struct Scripts { 7 | pub entry_script_path: ScriptPath, 8 | pub inner: BTreeMap, 9 | } 10 | 11 | /// The path of a script, represented as a series of symbols 12 | /// 13 | /// This is a platform-independent way to represent the script path. We can't 14 | /// use an actual `Path` (or `PathBuf`, rather), because there might not be a 15 | /// file system available where we're running this (in the browser, for 16 | /// example). 17 | pub type ScriptPath = Vec; 18 | -------------------------------------------------------------------------------- /archive/prototypes/06/src/cp/mod.rs: -------------------------------------------------------------------------------- 1 | mod code; 2 | mod execute; 3 | mod formatter; 4 | mod namespace; 5 | mod pipeline; 6 | mod runtime; 7 | mod test_runner; 8 | 9 | pub use self::{ 10 | code::define_code, 11 | execute::{execute, Error}, 12 | formatter::Formatter, 13 | namespace::{ 14 | Bindings, Function, FunctionBody, Functions, Intrinsic, Module, 15 | }, 16 | pipeline::{error::PipelineError, ir::analyzer_output::AnalyzerEvent}, 17 | runtime::{ 18 | data_stack::{DataStack, DataStackError}, 19 | evaluate::{Evaluator, EvaluatorError}, 20 | }, 21 | test_runner::{SingleTestReport, TestReports, TestRunner}, 22 | }; 23 | -------------------------------------------------------------------------------- /archive/prototypes/07/capi-desktop/src/args.rs: -------------------------------------------------------------------------------- 1 | use std::path::PathBuf; 2 | 3 | /// Interactive Caterpillar Runtime 4 | #[derive(clap::Parser)] 5 | pub struct Args { 6 | /// Path to the Caterpillar script that serves as the program's entry point 7 | pub entry_script: PathBuf, 8 | 9 | #[clap(subcommand)] 10 | pub command: Command, 11 | } 12 | 13 | impl Args { 14 | pub fn parse() -> Self { 15 | ::parse() 16 | } 17 | } 18 | 19 | #[derive(clap::Subcommand)] 20 | pub enum Command { 21 | /// Run the Caterpillar script 22 | Run, 23 | 24 | /// Run all tests from the Caterpillar script 25 | Test, 26 | } 27 | -------------------------------------------------------------------------------- /archive/prototypes/11/crosscut/protocol/src/command.rs: -------------------------------------------------------------------------------- 1 | use crosscut_game_engine::command::Command; 2 | 3 | pub trait CommandExt { 4 | fn deserialize(bytes: SerializedCommandToRuntime) -> Self; 5 | fn serialize(&self) -> SerializedCommandToRuntime; 6 | } 7 | 8 | impl CommandExt for Command { 9 | fn deserialize(bytes: SerializedCommandToRuntime) -> Self { 10 | let string = std::str::from_utf8(&bytes).unwrap(); 11 | ron::from_str(string).unwrap() 12 | } 13 | 14 | fn serialize(&self) -> SerializedCommandToRuntime { 15 | ron::to_string(self).unwrap().into_bytes() 16 | } 17 | } 18 | 19 | pub type SerializedCommandToRuntime = Vec; 20 | -------------------------------------------------------------------------------- /crosscut/src/game_engine/mod.rs: -------------------------------------------------------------------------------- 1 | mod camera; 2 | mod editor; 3 | mod game; 4 | mod game_engine; 5 | mod graphics; 6 | mod start; 7 | 8 | pub use self::{ 9 | camera::{Camera, OrthographicProjection}, 10 | editor::input::TerminalInput, 11 | game::{Game, Init, PureCrosscutGame, PureCrosscutGameInit}, 12 | graphics::{Instance, Renderer}, 13 | start::start_and_wait, 14 | }; 15 | 16 | #[cfg(test)] 17 | #[allow(unused)] // used only intermittently, to debug tests 18 | pub use self::editor::output::node_to_stdout; 19 | 20 | #[cfg(test)] 21 | #[allow(unused)] // user was removed; but likely to become used again soon 22 | pub use self::editor::output::node_to_string; 23 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # Zero-Clause BSD License 2 | 3 | Permission to use, copy, modify, and/or distribute this software for any purpose 4 | with or without fee is hereby granted. 5 | 6 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 7 | REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 8 | FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 9 | INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 10 | OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 11 | TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF 12 | THIS SOFTWARE. 13 | -------------------------------------------------------------------------------- /archive/prototypes/10/capi-runtime/src/syntax/location.rs: -------------------------------------------------------------------------------- 1 | #[derive( 2 | Clone, 3 | Debug, 4 | Eq, 5 | PartialEq, 6 | Ord, 7 | PartialOrd, 8 | serde::Deserialize, 9 | serde::Serialize, 10 | )] 11 | pub struct Location { 12 | function: String, 13 | index: u32, 14 | } 15 | 16 | impl Location { 17 | pub fn function(&self) -> &str { 18 | &self.function 19 | } 20 | 21 | pub fn first_in_function(function: String) -> Self { 22 | Self { function, index: 0 } 23 | } 24 | 25 | pub fn increment(&mut self) -> Self { 26 | let self_ = self.clone(); 27 | self.index += 1; 28 | self_ 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /archive/prototypes/05/src/test_report.rs: -------------------------------------------------------------------------------- 1 | use crossterm::style::Stylize; 2 | 3 | use crate::cp; 4 | 5 | pub fn print(test_reports: &[cp::TestReport]) { 6 | for test_report in test_reports { 7 | match &test_report.result { 8 | Ok(()) => { 9 | print!("{}", "PASS".bold().green()); 10 | } 11 | Err(_) => { 12 | print!("{}", "FAIL".bold().red()); 13 | } 14 | } 15 | 16 | print!(" {} - {}", test_report.module, test_report.name); 17 | 18 | if let Err(err) = &test_report.result { 19 | print!("\n {err}"); 20 | } 21 | 22 | println!(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /archive/prototypes/08/capi-runtime/src/cells.rs: -------------------------------------------------------------------------------- 1 | use std::iter; 2 | 3 | use crate::render_target::RenderTarget; 4 | 5 | pub struct Cells { 6 | pub buffer: Vec, 7 | pub cell_size: usize, 8 | pub size: [usize; 2], 9 | } 10 | 11 | impl Cells { 12 | pub fn new(draw_target: &RenderTarget) -> Self { 13 | let cell_size = 32; 14 | 15 | let width = draw_target.width / cell_size; 16 | let height = draw_target.height / cell_size; 17 | 18 | let buffer = iter::repeat(0).take(width * height).collect(); 19 | 20 | Self { 21 | buffer, 22 | cell_size, 23 | size: [width, height], 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /archive/prototypes/11/crosscut/cli/src/server/tests.rs: -------------------------------------------------------------------------------- 1 | use std::path::PathBuf; 2 | 3 | use super::Event; 4 | 5 | #[tokio::test] 6 | async fn basic_build() -> anyhow::Result<()> { 7 | tracing_subscriber::fmt().init(); 8 | 9 | let games_dir = PathBuf::from("../../games"); 10 | let address = "[::1]:34481".parse()?; 11 | 12 | let mut events = crate::server::start(games_dir, address).await?; 13 | 14 | // Wait for server to be ready. 15 | while let Some(event) = events.recv().await { 16 | if let Event::ServerReady = event { 17 | break; 18 | } 19 | } 20 | 21 | reqwest::get("http://[::1]:34481/code").await?; 22 | 23 | Ok(()) 24 | } 25 | -------------------------------------------------------------------------------- /archive/prototypes/10/capi/src/effects.rs: -------------------------------------------------------------------------------- 1 | use std::sync::mpsc; 2 | 3 | pub struct EffectsTx { 4 | pub inner: mpsc::Sender, 5 | } 6 | 7 | impl EffectsTx { 8 | pub fn send(&self, effect: DisplayEffect) { 9 | // This produces an error, if the other end has hung up, which happens 10 | // during shutdown. We can safely ignore that. 11 | let _ = self.inner.send(effect); 12 | } 13 | } 14 | 15 | pub type EffectsRx = mpsc::Receiver; 16 | 17 | #[derive(Debug)] 18 | pub enum DisplayEffect { 19 | SetTile { x: u8, y: u8, value: u8 }, 20 | SubmitTiles { reply: mpsc::Sender<()> }, 21 | ReadInput { reply: mpsc::Sender }, 22 | } 23 | -------------------------------------------------------------------------------- /archive/prototypes/11/tools/builder/src/export.rs: -------------------------------------------------------------------------------- 1 | use tokio::process::Command; 2 | 3 | use crate::build::build_once; 4 | 5 | pub async fn run() -> anyhow::Result<()> { 6 | let optimize = true; 7 | let files = build_once(optimize).await?; 8 | 9 | if let Some(files) = files { 10 | Command::new("cargo") 11 | .arg("run") 12 | .args(["--package", "crosscut-cli"]) 13 | .arg("--") 14 | .arg("export") 15 | .args(["--path", "export"]) 16 | .env("FILES", files.path().display().to_string()) 17 | .kill_on_drop(true) 18 | .status() 19 | .await?; 20 | } 21 | 22 | Ok(()) 23 | } 24 | -------------------------------------------------------------------------------- /archive/prototypes/08/capi-runtime/src/state.rs: -------------------------------------------------------------------------------- 1 | use crate::{ 2 | cells::Cells, render_target::RenderTarget, vm::Evaluator, world::World, 3 | }; 4 | 5 | pub struct State { 6 | pub evaluator: Evaluator, 7 | pub world: World, 8 | pub render_target: RenderTarget, 9 | } 10 | 11 | impl State { 12 | pub fn new(width: usize, height: usize, data: &[u8]) -> Self { 13 | let render_target = RenderTarget::new(width, height); 14 | let cells = Cells::new(&render_target); 15 | let state = World::new(cells); 16 | 17 | Self { 18 | evaluator: Evaluator::new(data), 19 | world: state, 20 | render_target, 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /archive/prototypes/12/src/language/tests/commands.rs: -------------------------------------------------------------------------------- 1 | use crate::language::{self, editor::Command, host::Host}; 2 | 3 | #[test] 4 | fn reset_interpreter_on_reset_command() { 5 | // If the reset command is given, the interpreter should begin again from 6 | // the start. 7 | 8 | let host = Host::empty(); 9 | let mut lang = language::Language::new(); 10 | 11 | lang.on_input("1", &host); 12 | lang.run_until_finished(); 13 | assert!(lang.state().is_finished()); 14 | 15 | lang.on_command(Command::Reset); 16 | assert!(lang.state().is_running()); 17 | 18 | let start = lang.code.root().node.body.ids().next().unwrap(); 19 | assert_eq!(lang.interpreter.next(), Some(start)); 20 | } 21 | -------------------------------------------------------------------------------- /archive/prototypes/10/capi/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "capi" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | anyhow = "*" 8 | futures = "*" 9 | pixels = "*" 10 | rand = "*" 11 | ron = "*" 12 | serde = "*" 13 | tower = "*" 14 | tracing = "*" 15 | 16 | [dependencies.axum] 17 | version = "*" 18 | features = ["ws"] 19 | 20 | [dependencies.capi-runtime] 21 | path = "../capi-runtime" 22 | 23 | [dependencies.tokio] 24 | version = "*" 25 | features = ["full"] 26 | 27 | [dependencies.tower-http] 28 | version = "*" 29 | features = ["trace"] 30 | 31 | [dependencies.tracing-subscriber] 32 | version = "*" 33 | features = ["env-filter"] 34 | 35 | [dependencies.winit] 36 | version = "*" 37 | features = ["rwh_05"] 38 | -------------------------------------------------------------------------------- /archive/prototypes/11/crosscut/protocol/src/host_state.rs: -------------------------------------------------------------------------------- 1 | use crosscut_runtime::{Effect, InstructionAddress, Value}; 2 | 3 | /// # The current state of the runtime 4 | #[derive(Clone, Debug, serde::Deserialize, serde::Serialize)] 5 | pub enum HostState { 6 | /// # The process is currently running 7 | Running, 8 | 9 | /// # The process has finished 10 | Finished, 11 | 12 | /// # The process is currently stopped 13 | Stopped { 14 | /// # The triggered effect 15 | effect: Option, 16 | 17 | /// # The active instructions 18 | active_instructions: Vec, 19 | 20 | /// # The operands in the current stack frame 21 | current_operands: Vec, 22 | }, 23 | } 24 | -------------------------------------------------------------------------------- /archive/prototypes/11/crosscut/debugger/src/ui/components/button.rs: -------------------------------------------------------------------------------- 1 | use leptos::{ 2 | component, 3 | prelude::{ClassAttribute, OnAttribute}, 4 | view, IntoView, 5 | }; 6 | 7 | use crate::{ 8 | model::UserAction, 9 | ui::{actions::send_action, ActionsTx}, 10 | }; 11 | 12 | #[component] 13 | pub fn Button( 14 | label: &'static str, 15 | action: UserAction, 16 | actions: ActionsTx, 17 | ) -> impl IntoView { 18 | let on_click = move |_| { 19 | leptos::task::spawn_local(send_action(action.clone(), actions.clone())); 20 | }; 21 | 22 | view! { 23 | 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /archive/prototypes/06/src/ui/test_report.rs: -------------------------------------------------------------------------------- 1 | use sycamore::{component, reactive::Scope, view, view::View, web::Html}; 2 | 3 | use crate::{cp, ui::pass_fail::PassFail}; 4 | 5 | #[component] 6 | pub fn TestReport(cx: Scope, props: Props) -> View { 7 | view! { cx, 8 | PassFail(pass=props.test_report.result.is_ok()) 9 | (props.test_report.module) " - " (props.test_report.name) 10 | span( 11 | class="\ 12 | test-update-indicator \ 13 | inline-block mx-2 w-2 h-2 bg-black rounded-full\ 14 | ", 15 | data-timestamp=props.test_report.timestamp 16 | ) 17 | } 18 | } 19 | 20 | #[derive(sycamore::Prop)] 21 | pub struct Props { 22 | test_report: cp::SingleTestReport, 23 | } 24 | -------------------------------------------------------------------------------- /archive/prototypes/11/crosscut/compiler/src/code/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod syntax; 2 | 3 | mod dependencies; 4 | mod identifiers; 5 | mod recursion; 6 | mod tail_expressions; 7 | mod tokens; 8 | mod types; 9 | 10 | mod changes; 11 | mod functions; 12 | mod hash; 13 | mod index; 14 | 15 | pub use self::{ 16 | changes::{Changes, FunctionInUpdate, FunctionUpdate}, 17 | dependencies::{Dependencies, DependencyCluster}, 18 | functions::Functions, 19 | hash::Hash, 20 | identifiers::{ 21 | Bindings, Environment, FunctionCalls, IdentifierTarget, Identifiers, 22 | }, 23 | index::{Index, IndexMap}, 24 | recursion::Recursion, 25 | tail_expressions::TailExpressions, 26 | tokens::{Token, Tokens}, 27 | types::{Signature, Type, TypeAnnotations, Types}, 28 | }; 29 | -------------------------------------------------------------------------------- /archive/prototypes/11/crosscut/compiler/src/code/syntax/location/expression.rs: -------------------------------------------------------------------------------- 1 | use crate::code::syntax::{Expression, Function}; 2 | 3 | use super::{ 4 | located::HasLocation, member::MemberLocation, FunctionLocation, Located, 5 | }; 6 | 7 | impl HasLocation for Expression { 8 | type Location = MemberLocation; 9 | } 10 | 11 | impl<'r> Located<&'r Expression> { 12 | /// # Convert the located expression into a located local function 13 | pub fn into_local_function(self) -> Option> { 14 | self.fragment.as_local_function().map(|function| Located { 15 | fragment: function, 16 | location: FunctionLocation::Local { 17 | location: self.location.clone(), 18 | }, 19 | }) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /archive/prototypes/05/src/repl.rs: -------------------------------------------------------------------------------- 1 | use std::io::stdin; 2 | 3 | use crate::{cp, test_report}; 4 | 5 | pub fn run( 6 | functions: &mut cp::Functions, 7 | tests: &mut cp::Functions, 8 | ) -> anyhow::Result<()> { 9 | let test_reports = cp::run_tests(functions, tests)?; 10 | test_report::print(&test_reports); 11 | 12 | let mut data_stack = cp::DataStack::new(); 13 | let mut bindings = cp::Bindings::new(); 14 | 15 | for input in stdin().lines() { 16 | let input = input?; 17 | 18 | cp::execute(&input, &mut data_stack, &mut bindings, functions, tests)?; 19 | 20 | println!("{data_stack}"); 21 | 22 | let test_reports = cp::run_tests(functions, tests)?; 23 | test_report::print(&test_reports); 24 | } 25 | 26 | Ok(()) 27 | } 28 | -------------------------------------------------------------------------------- /archive/prototypes/07/capi-web/src/main.rs: -------------------------------------------------------------------------------- 1 | mod platform; 2 | mod run; 3 | mod ui; 4 | 5 | include!(concat!(env!("OUT_DIR"), "/script.rs")); 6 | 7 | fn main() { 8 | console_error_panic_hook::set_once(); 9 | tracing_wasm::set_as_global_default(); 10 | 11 | let (code_tx, code_rx) = async_channel::unbounded(); 12 | let (output_tx, output_rx) = async_channel::unbounded(); 13 | 14 | wasm_bindgen_futures::spawn_local(async { 15 | if let Err(err) = run::run(SCRIPT, code_rx, output_tx).await { 16 | panic!("Platform error: {err:?}"); 17 | } 18 | }); 19 | wasm_bindgen_futures::spawn_local(async { 20 | if let Err(err) = ui::render(SCRIPT, code_tx, output_rx).await { 21 | panic!("UI error: {err:?}"); 22 | } 23 | }); 24 | } 25 | -------------------------------------------------------------------------------- /archive/prototypes/10/capi-runtime/src/code.rs: -------------------------------------------------------------------------------- 1 | use std::collections::BTreeMap; 2 | 3 | use crate::{ 4 | instructions::{Instruction, Instructions}, 5 | runtime, InstructionAddress, 6 | }; 7 | 8 | #[derive( 9 | Clone, Debug, Eq, PartialEq, Default, serde::Deserialize, serde::Serialize, 10 | )] 11 | pub struct Code { 12 | pub instructions: Instructions, 13 | pub functions: BTreeMap, 14 | } 15 | 16 | impl Code { 17 | pub fn new() -> Self { 18 | Self::default() 19 | } 20 | 21 | pub fn next_address(&self) -> InstructionAddress { 22 | self.instructions.next_address() 23 | } 24 | 25 | pub fn push(&mut self, instruction: Instruction) -> InstructionAddress { 26 | self.instructions.push(instruction) 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /archive/prototypes/01/src/cp/mod.rs: -------------------------------------------------------------------------------- 1 | mod bindings; 2 | mod builtins; 3 | mod data_stack; 4 | mod evaluator; 5 | mod functions; 6 | mod parser; 7 | mod tokenizer; 8 | 9 | pub use self::{ 10 | bindings::Bindings, 11 | data_stack::{DataStack, Value}, 12 | evaluator::evaluate, 13 | functions::Functions, 14 | parser::{parse, Expression, Expressions}, 15 | tokenizer::{tokenize, Token, Tokens}, 16 | }; 17 | 18 | pub struct Interpreter { 19 | pub functions: Functions, 20 | pub data_stack: DataStack, 21 | pub bindings: Bindings, 22 | } 23 | 24 | impl Interpreter { 25 | pub fn new() -> Self { 26 | Self { 27 | functions: Functions::new(), 28 | data_stack: DataStack::new(), 29 | bindings: Bindings::new(), 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /archive/prototypes/02/src/cp/expressions.rs: -------------------------------------------------------------------------------- 1 | use std::vec; 2 | 3 | #[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Debug)] 4 | pub struct ExpressionGraph(Vec); 5 | 6 | impl From> for ExpressionGraph { 7 | fn from(expressions: Vec) -> Self { 8 | Self(expressions) 9 | } 10 | } 11 | 12 | impl IntoIterator for ExpressionGraph { 13 | type Item = Expression; 14 | type IntoIter = vec::IntoIter; 15 | 16 | fn into_iter(self) -> Self::IntoIter { 17 | self.0.into_iter() 18 | } 19 | } 20 | 21 | #[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Debug)] 22 | pub enum Expression { 23 | Binding(Vec), 24 | Array { syntax_tree: ExpressionGraph }, 25 | Block { syntax_tree: ExpressionGraph }, 26 | Word(String), 27 | } 28 | -------------------------------------------------------------------------------- /archive/prototypes/11/crosscut/debugger/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "crosscut-debugger" 3 | edition = "2021" 4 | 5 | 6 | [dependencies] 7 | anyhow = "*" 8 | console_error_panic_hook = "*" 9 | console_log = "*" 10 | gloo-net = "*" 11 | log = "*" 12 | ron = "*" 13 | 14 | [dependencies.crosscut-compiler] 15 | path = "../compiler" 16 | 17 | [dependencies.crosscut-game-engine] 18 | path = "../game-engine" 19 | 20 | [dependencies.crosscut-ffi] 21 | path = "../ffi" 22 | 23 | [dependencies.crosscut-protocol] 24 | path = "../protocol" 25 | 26 | [dependencies.crosscut-runtime] 27 | path = "../runtime" 28 | 29 | [dependencies.leptos] 30 | version = "*" 31 | features = ["csr"] 32 | 33 | [dependencies.tokio] 34 | version = "*" 35 | features = ["macros", "sync"] 36 | 37 | 38 | [dev-dependencies] 39 | itertools = "*" 40 | -------------------------------------------------------------------------------- /crosscut/src/language/code/nodes_uniform/nodes.rs: -------------------------------------------------------------------------------- 1 | use std::collections::BTreeMap; 2 | 3 | use super::{NodeHash, SyntaxNode}; 4 | 5 | #[derive(Clone, Debug, Default, Eq, PartialEq)] 6 | pub struct Nodes { 7 | inner: BTreeMap, 8 | } 9 | 10 | impl Nodes { 11 | pub fn get(&self, hash: &NodeHash) -> &SyntaxNode { 12 | let Some(node) = self.inner.get(hash) else { 13 | unreachable!( 14 | "This is an append-only data structure. All hashes that were \ 15 | ever created must be valid." 16 | ); 17 | }; 18 | 19 | node 20 | } 21 | 22 | pub fn insert(&mut self, node: SyntaxNode) -> NodeHash { 23 | let hash = NodeHash::new(&node); 24 | self.inner.insert(hash, node); 25 | hash 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /archive/prototypes/07/capi-web/README.md: -------------------------------------------------------------------------------- 1 | # Caterpillar - Web Platform 2 | 3 | A browser-based Caterpillar platform. 4 | 5 | To try this out, run the following command from the repository root (required 6 | [Trunk](https://trunkrs.dev/)): 7 | 8 | ```shell 9 | trunk serve 10 | ``` 11 | 12 | By default, the runner bundles a simple "Hello, world!" script. To bundle a 13 | different script, pass its path at build time using an environment variable: 14 | 15 | ```shell 16 | CAPI_SCRIPT=../path/to/script.capi trunk serve 17 | ``` 18 | 19 | The path must be relative to the `capi-web/` directory. If you're building 20 | without Trunk, you can use the environment variable with `cargo build` (or any 21 | Cargo command) instead. 22 | 23 | For more information about Caterpillar, check out the 24 | [top-level README](../README.md). 25 | -------------------------------------------------------------------------------- /archive/prototypes/01/src/cp/tokenizer.rs: -------------------------------------------------------------------------------- 1 | pub type Tokens = Vec; 2 | 3 | #[derive(Clone, Eq, PartialEq)] 4 | pub enum Token { 5 | Fn(String), 6 | Name(String), 7 | BlockOpen, 8 | BlockClose, 9 | ListOpen, 10 | ListClose, 11 | } 12 | 13 | pub fn tokenize(code: &str) -> Tokens { 14 | code.split_whitespace() 15 | .map(|token| match token { 16 | "{" => Token::BlockOpen, 17 | "}" => Token::BlockClose, 18 | "[" => Token::ListOpen, 19 | "]" => Token::ListClose, 20 | token => { 21 | if let Some(name) = token.strip_prefix(':') { 22 | return Token::Name(name.to_string()); 23 | } 24 | 25 | Token::Fn(token.to_string()) 26 | } 27 | }) 28 | .collect() 29 | } 30 | -------------------------------------------------------------------------------- /archive/prototypes/03/src/cp/expressions.rs: -------------------------------------------------------------------------------- 1 | use std::vec; 2 | 3 | #[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Debug)] 4 | pub struct ExpressionGraph(Vec); 5 | 6 | impl From> for ExpressionGraph { 7 | fn from(expressions: Vec) -> Self { 8 | Self(expressions) 9 | } 10 | } 11 | 12 | impl IntoIterator for ExpressionGraph { 13 | type Item = Expression; 14 | type IntoIter = vec::IntoIter; 15 | 16 | fn into_iter(self) -> Self::IntoIter { 17 | self.0.into_iter() 18 | } 19 | } 20 | 21 | #[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Debug)] 22 | pub enum Expression { 23 | Binding(Vec), 24 | Array { syntax_tree: ExpressionGraph }, 25 | Block { syntax_tree: ExpressionGraph }, 26 | String(String), 27 | Word(String), 28 | } 29 | -------------------------------------------------------------------------------- /archive/prototypes/06/src/cp/pipeline/stages/d_evaluator.rs: -------------------------------------------------------------------------------- 1 | use crate::cp::{ 2 | pipeline::{channel::StageInput, ir::analyzer_output::AnalyzerEvent}, 3 | runtime::evaluate::Evaluator, 4 | Bindings, DataStack, EvaluatorError, Functions, PipelineError, 5 | }; 6 | 7 | pub fn evaluate( 8 | mut expressions: StageInput, 9 | data_stack: &mut DataStack, 10 | bindings: &mut Bindings, 11 | functions: &Functions, 12 | ) -> Result<(), PipelineError> { 13 | let expression = expressions.read()?; 14 | 15 | let mut evaluator = Evaluator { 16 | data_stack, 17 | bindings, 18 | functions, 19 | }; 20 | evaluator 21 | .evaluate_expression(expression) 22 | .map_err(PipelineError::Stage)?; 23 | 24 | expressions.take(); 25 | Ok(()) 26 | } 27 | -------------------------------------------------------------------------------- /archive/prototypes/11/crosscut/host/src/ffi_out.rs: -------------------------------------------------------------------------------- 1 | pub fn on_panic(message: &str) { 2 | // Sound, as the `on_panic` function immediately builds and logs a 3 | // JavaScript string, and the pointer it not kept around after that. 4 | unsafe { 5 | ffi::on_panic(message.as_ptr(), message.len()); 6 | } 7 | } 8 | 9 | #[allow(unused)] // for debugging; might not always be in use 10 | pub fn print(message: &str) { 11 | // Sound, as the `on_panic` function immediately builds and logs a 12 | // JavaScript string, and the pointer it not kept around after that. 13 | unsafe { 14 | ffi::print(message.as_ptr(), message.len()); 15 | } 16 | } 17 | 18 | mod ffi { 19 | extern "C" { 20 | pub fn on_panic(ptr: *const u8, len: usize); 21 | pub fn print(ptr: *const u8, len: usize); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /archive/prototypes/11/tools/builder/src/main.rs: -------------------------------------------------------------------------------- 1 | mod build; 2 | mod export; 3 | mod serve; 4 | 5 | #[tokio::main] 6 | async fn main() -> anyhow::Result<()> { 7 | use anyhow::Context; 8 | use clap::Parser; 9 | 10 | tracing_subscriber::fmt().init(); 11 | 12 | let args = Args::parse(); 13 | match args.command { 14 | Some(Command::Export) => { 15 | export::run().await.context("Running `export` command")?; 16 | } 17 | None | Some(Command::Serve) => { 18 | serve::start().await.context("Running `serve` command")?; 19 | } 20 | } 21 | 22 | Ok(()) 23 | } 24 | 25 | #[derive(clap::Parser)] 26 | struct Args { 27 | #[command(subcommand)] 28 | command: Option, 29 | } 30 | 31 | #[derive(clap::Subcommand)] 32 | enum Command { 33 | Export, 34 | Serve, 35 | } 36 | -------------------------------------------------------------------------------- /archive/prototypes/10/capi/src/main.rs: -------------------------------------------------------------------------------- 1 | mod display; 2 | mod effects; 3 | mod runner; 4 | mod server; 5 | mod snake; 6 | mod updates; 7 | 8 | fn main() -> anyhow::Result<()> { 9 | tracing_subscriber::fmt() 10 | .with_env_filter("tower_http::trace=info") 11 | .init(); 12 | 13 | let mut script = capi_runtime::syntax::Script::default(); 14 | snake::snake(&mut script); 15 | let program = capi_runtime::compile(script, "main"); 16 | 17 | let (events_tx, events_rx) = tokio::sync::mpsc::unbounded_channel(); 18 | let (updates_tx, updates_rx) = tokio::sync::watch::channel(program.clone()); 19 | 20 | let updates_tx = updates::UpdatesTx::new(updates_tx); 21 | 22 | server::start(updates_rx, events_tx); 23 | let runner = runner::RunnerThread::start(program, events_rx, updates_tx); 24 | display::run(runner) 25 | } 26 | -------------------------------------------------------------------------------- /archive/prototypes/05/src/cp/namespace/bindings.rs: -------------------------------------------------------------------------------- 1 | use std::collections::{BTreeMap, BTreeSet}; 2 | 3 | use crate::cp::runtime::data_stack::Value; 4 | 5 | #[derive(Default)] 6 | pub struct Bindings { 7 | declarations: BTreeSet, 8 | definitions: BTreeMap, 9 | } 10 | 11 | impl Bindings { 12 | pub fn new() -> Self { 13 | Self::default() 14 | } 15 | 16 | pub fn declare(&mut self, name: String) { 17 | self.declarations.insert(name); 18 | } 19 | 20 | pub fn define(&mut self, name: String, value: Value) { 21 | self.definitions.insert(name, value); 22 | } 23 | 24 | pub fn is_declared(&self, name: &str) -> bool { 25 | self.declarations.contains(name) 26 | } 27 | 28 | pub fn get(&self, name: &str) -> Option<&Value> { 29 | self.definitions.get(name) 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /archive/prototypes/12/src/language/host.rs: -------------------------------------------------------------------------------- 1 | use std::collections::BTreeMap; 2 | 3 | pub struct Host { 4 | pub functions_by_id: BTreeMap, 5 | pub functions_by_name: BTreeMap, 6 | } 7 | 8 | impl Host { 9 | pub fn empty() -> Self { 10 | Self { 11 | functions_by_id: BTreeMap::new(), 12 | functions_by_name: BTreeMap::new(), 13 | } 14 | } 15 | 16 | pub fn from_functions( 17 | names: impl IntoIterator>, 18 | ) -> Self { 19 | let mut host = Host::empty(); 20 | 21 | for (id, name) in names.into_iter().enumerate() { 22 | let name = name.into(); 23 | 24 | host.functions_by_id.insert(id, name.clone()); 25 | host.functions_by_name.insert(name, id); 26 | } 27 | 28 | host 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /archive/prototypes/05/src/cp/code/std.rs: -------------------------------------------------------------------------------- 1 | use crate::cp; 2 | 3 | pub fn define(functions: &mut cp::Functions) -> anyhow::Result<()> { 4 | let code = r#" 5 | fn times { 6 | => block num . 7 | num 0 = 8 | {} 9 | { 10 | block eval 11 | num 1 - => num . 12 | block num times 13 | } 14 | if 15 | } 16 | "#; 17 | 18 | let mut data_stack = cp::DataStack::new(); 19 | let mut bindings = cp::Bindings::new(); 20 | let mut tests = cp::Functions::new(); 21 | 22 | cp::execute(code, &mut data_stack, &mut bindings, functions, &mut tests)?; 23 | 24 | if !data_stack.is_empty() { 25 | anyhow::bail!("Defining `std` left values on stack: {data_stack:?}") 26 | } 27 | 28 | Ok(()) 29 | } 30 | -------------------------------------------------------------------------------- /archive/prototypes/06/src/cp/namespace/bindings.rs: -------------------------------------------------------------------------------- 1 | use std::collections::{BTreeMap, BTreeSet}; 2 | 3 | use crate::cp::runtime::data_stack::Value; 4 | 5 | #[derive(Clone, Default)] 6 | pub struct Bindings { 7 | declarations: BTreeSet, 8 | definitions: BTreeMap, 9 | } 10 | 11 | impl Bindings { 12 | pub fn new() -> Self { 13 | Self::default() 14 | } 15 | 16 | pub fn declare(&mut self, name: String) { 17 | self.declarations.insert(name); 18 | } 19 | 20 | pub fn define(&mut self, name: String, value: Value) { 21 | self.definitions.insert(name, value); 22 | } 23 | 24 | pub fn is_declared(&self, name: &str) -> bool { 25 | self.declarations.contains(name) 26 | } 27 | 28 | pub fn get(&self, name: &str) -> Option<&Value> { 29 | self.definitions.get(name) 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /archive/prototypes/07/capi-core/src/repr/eval/fragments/fragment.rs: -------------------------------------------------------------------------------- 1 | use super::{FragmentAddress, FragmentId, FragmentPayload}; 2 | 3 | #[derive(Clone, Debug, Eq, PartialEq)] 4 | pub struct Fragment { 5 | pub address: FragmentAddress, 6 | pub payload: FragmentPayload, 7 | } 8 | 9 | impl Fragment { 10 | pub fn new(address: FragmentAddress, payload: FragmentPayload) -> Self { 11 | Self { address, payload } 12 | } 13 | 14 | pub fn id(&self) -> FragmentId { 15 | let hash = { 16 | let mut hasher = blake3::Hasher::new(); 17 | 18 | self.address.hash(&mut hasher); 19 | self.payload.hash(&mut hasher); 20 | 21 | hasher.finalize() 22 | }; 23 | 24 | FragmentId { hash } 25 | } 26 | 27 | pub fn next(&self) -> Option { 28 | self.address.next 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /archive/prototypes/11/crosscut/cli/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "crosscut-cli" 3 | edition = "2021" 4 | 5 | 6 | [dependencies] 7 | anyhow = "*" 8 | rand = "*" 9 | thiserror = "*" 10 | tracing = "*" 11 | tracing-subscriber = "*" 12 | 13 | [dependencies.axum] 14 | version = "*" 15 | features = ["ws"] 16 | 17 | [dependencies.crosscut-compiler] 18 | path = "../compiler" 19 | 20 | [dependencies.crosscut-game-engine] 21 | path = "../game-engine" 22 | 23 | [dependencies.crosscut-protocol] 24 | path = "../protocol" 25 | 26 | [dependencies.crosscut-watch] 27 | path = "../watch" 28 | 29 | [dependencies.clap] 30 | version = "*" 31 | features = ["derive"] 32 | 33 | [dependencies.tokio] 34 | version = "*" 35 | features = ["full"] 36 | 37 | 38 | [dev-dependencies.reqwest] 39 | version = "*" 40 | default-features = false 41 | 42 | 43 | [build-dependencies] 44 | anyhow = "*" 45 | -------------------------------------------------------------------------------- /crosscut/src/language/code/nodes_typed/tuple.rs: -------------------------------------------------------------------------------- 1 | use crate::{ 2 | language::code::{NodeByHash, Nodes, SyntaxNode}, 3 | util::form::{Form, Owned}, 4 | }; 5 | 6 | use super::{Body, TypedChild}; 7 | 8 | #[derive(Debug)] 9 | pub struct Tuple { 10 | pub values: T::Form>, 11 | } 12 | 13 | impl Tuple { 14 | pub fn empty() -> Self { 15 | Self { 16 | values: Body::empty(), 17 | } 18 | } 19 | 20 | pub fn into_syntax_node(self, nodes: &mut Nodes) -> SyntaxNode { 21 | let values = { 22 | let node = self.values.into_syntax_node(nodes); 23 | nodes.insert(node) 24 | }; 25 | 26 | SyntaxNode::Tuple { values } 27 | } 28 | } 29 | 30 | impl Tuple { 31 | pub fn values(&self) -> TypedChild { 32 | TypedChild::new(self.values, 0) 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /archive/prototypes/05/src/cp/pipeline/stages/d_evaluator.rs: -------------------------------------------------------------------------------- 1 | use crate::cp::{ 2 | pipeline::{channel::StageInput, ir::analyzer_output::AnalyzerEvent}, 3 | runtime::evaluate::Evaluator, 4 | Bindings, DataStack, EvaluatorError, Functions, PipelineError, 5 | }; 6 | 7 | pub fn evaluate( 8 | mut expressions: StageInput, 9 | data_stack: &mut DataStack, 10 | bindings: &mut Bindings, 11 | functions: &Functions, 12 | tests: &Functions, 13 | ) -> Result<(), PipelineError> { 14 | let expression = expressions.read()?; 15 | 16 | let mut evaluator = Evaluator { 17 | data_stack, 18 | bindings, 19 | functions, 20 | tests, 21 | }; 22 | evaluator 23 | .evaluate_expression(expression) 24 | .map_err(PipelineError::Stage)?; 25 | 26 | expressions.take(); 27 | Ok(()) 28 | } 29 | -------------------------------------------------------------------------------- /archive/prototypes/07/capi-core/src/repr/tokens.rs: -------------------------------------------------------------------------------- 1 | use enum_variant_type::EnumVariantType; 2 | 3 | use super::eval::value::ValuePayload; 4 | 5 | #[derive(Clone, Debug, Eq, PartialEq, EnumVariantType)] 6 | #[evt(module = "token")] 7 | pub enum Token { 8 | Binding, 9 | 10 | CurlyBracketOpen, 11 | CurlyBracketClose, 12 | 13 | SquareBracketOpen, 14 | SquareBracketClose, 15 | 16 | /// A literal value 17 | /// 18 | /// This variant can represent `Token`s that are not actually valid, as 19 | /// [`ValueKind`] can be a block, but blocks don't exist on the token level. 20 | /// 21 | /// Such an invalid `Token` is never produced by the tokenizer, and doing it 22 | /// like this makes the code handling `Token`s simpler, and that's probably 23 | /// worth the small inconsistency. 24 | Literal(ValuePayload), 25 | 26 | Word(String), 27 | } 28 | -------------------------------------------------------------------------------- /archive/prototypes/11/crosscut/debugger/src/ui/components/control_panel.rs: -------------------------------------------------------------------------------- 1 | use leptos::{component, view, IntoView}; 2 | 3 | use crate::{ 4 | model::UserAction, 5 | ui::{ 6 | components::{button::Button, panel::Panel}, 7 | ActionsTx, 8 | }, 9 | }; 10 | 11 | #[component] 12 | pub fn ControlPanel(actions: ActionsTx) -> impl IntoView { 13 | view! { 14 | 15 |