add skill and some adjustments
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -3,3 +3,4 @@
|
||||
references/processed_visuals
|
||||
build
|
||||
bootslop.proj
|
||||
clay_ui_temp
|
||||
|
||||
@@ -27,17 +27,15 @@ This document outlines the strict C style and architectural conventions expected
|
||||
* **Case:** Strictly use `lower_snake_case` for all functions and variables.
|
||||
* **Types:** Use `PascalCase` for type names (`FArena`, `SWord_Tag`).
|
||||
* **WinAPI Symbols:** When declaring foreign Win32 symbols, prefix the C function name with `ms_` (using `lower_snake_case`) and use the `asm("SymbolName")` attribute to link it to the actual DLL export.
|
||||
* *Correct:* `WinAPI U2 ms_register_class(const MS_WNDCLASSA* lpWndClass) asm("RegisterClassA");`
|
||||
* *Correct:* `WinAPI U2 ms_register_class_a(const MS_WNDCLASSA* lpWndClass) asm("RegisterClassA");`
|
||||
* *Incorrect:* `WinAPI U2 RegisterClassA(...);`
|
||||
|
||||
## 4. Memory Management
|
||||
## 4. Formatting & Layout
|
||||
* **Vertical Alignment:** Align related variable declarations, struct fields, and function prototypes into columns to create a "sheet-like" layout. This improves visual parsing.
|
||||
* **Brace Style:** Use Allman style (braces on a new line) for function bodies control block (`if`, `for`, `switch`, etc.) that spans more than 50 lines or contains nested logic.
|
||||
* **Conditionals:** Always place `else if` and `else` statements on a new line, un-nested from the previous closing brace.
|
||||
|
||||
## 5. Memory Management
|
||||
* **No Standard Library:** The environment is built with `-nostdlib` and `-ffreestanding`. Never include `<stdlib.h>`, `<string.h>`, etc.
|
||||
* **Arenas over Malloc:** Use `FArena` and its associated macros (`farena_push`, `farena_push_type`, `farena_reset`) for all dynamic memory allocations. Do not use raw pointers with manual arithmetic when an arena can handle it.
|
||||
* **Memory Ops:** Use `mem_fill` and `mem_copy` instead of standard `memset`/`memcpy` within the application logic. (A minimal `memset`/`memcpy` shim is only provided to satisfy compiler intrinsic struct zeroing under `-nostdlib`).
|
||||
|
||||
## 5. Modifiers
|
||||
* `internal`: Static functions.
|
||||
* `global`: Global state variables.
|
||||
* `IA_`: Internal Always Inline.
|
||||
* `I_`: Internal Inline.
|
||||
* Pointers use `*r` (restrict) or `*v` (volatile) macros where applicable.
|
||||
* **Memory Ops:** Use `mem_fill` and `mem_copy` instead of standard `memset`/`memcpy` within the application logic.
|
||||
|
||||
@@ -182,6 +182,24 @@ IA_ U8 align_pow2(U8 x, U8 b) {
|
||||
return ((x + b - 1) & (~(b - 1)));
|
||||
}
|
||||
|
||||
#if 0
|
||||
#pragma clang optimize off
|
||||
// TODO(Ed): Replace these later (only matters if CRT is not used)
|
||||
void* memset(void* dest, int c, U8 count) {
|
||||
U1* bytes = (U1*)dest;
|
||||
while (count--) *bytes++ = (U1)c;
|
||||
return dest;
|
||||
}
|
||||
|
||||
void* memcpy(void* dest, const void* src, U8 count) {
|
||||
U1* d = (U1*)dest;
|
||||
const U1* s = (const U1*)src;
|
||||
while (count--) *d++ = *s++;
|
||||
return dest;
|
||||
}
|
||||
#pragma clang optimize on
|
||||
#endif
|
||||
|
||||
IA_ U8 mem_copy (U8 dest, U8 src, U8 len) { return (U8)(__builtin_memcpy ((void*)dest, (void const*)src, len)); }
|
||||
IA_ U8 mem_copy_overlapping(U8 dest, U8 src, U8 len) { return (U8)(__builtin_memmove((void*)dest, (void const*)src, len)); }
|
||||
IA_ U8 mem_fill (U8 dest, U8 value, U8 len) { return (U8)(__builtin_memset ((void*)dest, (int) value, len)); }
|
||||
|
||||
109
attempt_1/main.c
109
attempt_1/main.c
@@ -93,21 +93,6 @@ typedef struct {
|
||||
global DictEntry dict[256];
|
||||
global U8 dict_count = 0;
|
||||
|
||||
#pragma clang optimize off
|
||||
void* memset(void* dest, int c, U8 count) {
|
||||
U1* bytes = (U1*)dest;
|
||||
while (count--) *bytes++ = (U1)c;
|
||||
return dest;
|
||||
}
|
||||
|
||||
void* memcpy(void* dest, const void* src, U8 count) {
|
||||
U1* d = (U1*)dest;
|
||||
const U1* s = (const U1*)src;
|
||||
while (count--) *d++ = *s++;
|
||||
return dest;
|
||||
}
|
||||
#pragma clang optimize on
|
||||
|
||||
IA_ void scatter(U4 token, const char* anno_str) {
|
||||
if (tape_arena.used + sizeof(U4) <= tape_arena.capacity && anno_arena.used + sizeof(U8) <= anno_arena.capacity) {
|
||||
U4*r ptr = C_(U4*r, tape_arena.start + tape_arena.used);
|
||||
@@ -578,54 +563,54 @@ S8 win_proc(void* hwnd, U4 msg, U8 wparam, S8 lparam) {
|
||||
|
||||
// Render VM State
|
||||
ms_set_text_color(hdc, 0x00FFFFFF);
|
||||
char jit_str[64] = "Mode: Incremental | JIT Size: 0x000 bytes";
|
||||
if (run_full) mem_copy(u8_(jit_str + 6), u8_("Full "), 11);
|
||||
u64_to_hex(code_arena.used, jit_str + 32, 3);
|
||||
ms_text_out_a(hdc, 40, 520, jit_str, 41);
|
||||
|
||||
char state_str[64] = "RAX: 00000000 | RDX: 00000000";
|
||||
u64_to_hex(vm_rax, state_str + 5, 8);
|
||||
u64_to_hex(vm_rdx, state_str + 21, 8);
|
||||
ms_set_text_color(hdc, 0x0094BAA1); // Number green
|
||||
ms_text_out_a(hdc, 40, 550, state_str, 29);
|
||||
char jit_str[64] = "Mode: Incremental | JIT Size: 0x000 bytes";
|
||||
if (run_full) mem_copy(u8_(jit_str + 6), u8_("Full "), 11);
|
||||
u64_to_hex(code_arena.used, jit_str + 32, 3);
|
||||
ms_text_out_a(hdc, 40, 520, jit_str, 41);
|
||||
|
||||
// HUD: Display Current Token Meaning
|
||||
if (tape_count > 0 && cursor_idx < tape_count) {
|
||||
U4 cur_tag = UNPACK_TAG(tape_ptr[cursor_idx]);
|
||||
const char* tag_name = tag_names[cur_tag];
|
||||
U4 cur_color = tag_colors[cur_tag];
|
||||
|
||||
char semantics_str[64] = "Current Tag: ";
|
||||
U4 name_len = 0;
|
||||
while (tag_name[name_len]) {
|
||||
semantics_str[13 + name_len] = tag_name[name_len];
|
||||
name_len++;
|
||||
}
|
||||
semantics_str[13 + name_len] = '\0';
|
||||
|
||||
ms_set_text_color(hdc, cur_color);
|
||||
ms_text_out_a(hdc, 40, 580, semantics_str, 13 + name_len);
|
||||
}
|
||||
|
||||
ms_set_text_color(hdc, 0x00C8C8C8);
|
||||
ms_text_out_a(hdc, 400, 520, "Global Memory (Contiguous Array):", 33);
|
||||
for (int i=0; i<4; i++) {
|
||||
char glob_str[32] = "[0]: 00000000";
|
||||
glob_str[1] = '0' + i;
|
||||
u64_to_hex(vm_globals[i], glob_str + 5, 8);
|
||||
ms_set_text_color(hdc, 0x00D6A454); // Soft blue
|
||||
ms_text_out_a(hdc, 400, 550 + (i * 25), glob_str, 13);
|
||||
}
|
||||
|
||||
// Print Log
|
||||
ms_set_text_color(hdc, 0x00C8C8C8);
|
||||
ms_text_out_a(hdc, 750, 520, "Print Log:", 10);
|
||||
for (int i=0; i<log_count && i<4; i++) {
|
||||
char log_str[32] = "00000000";
|
||||
u64_to_hex(log_buffer[i], log_str, 8);
|
||||
ms_set_text_color(hdc, 0x0094BAA1);
|
||||
ms_text_out_a(hdc, 750, 550 + (i * 25), log_str, 8);
|
||||
}
|
||||
char state_str[64] = "RAX: 00000000 | RDX: 00000000";
|
||||
u64_to_hex(vm_rax, state_str + 5, 8);
|
||||
u64_to_hex(vm_rdx, state_str + 21, 8);
|
||||
ms_set_text_color(hdc, 0x0094BAA1); // Number green
|
||||
ms_text_out_a(hdc, 40, 550, state_str, 29);
|
||||
|
||||
// HUD: Display Current Token Meaning
|
||||
if (tape_count > 0 && cursor_idx < tape_count) {
|
||||
U4 cur_tag = UNPACK_TAG(tape_ptr[cursor_idx]);
|
||||
const char* tag_name = tag_names[cur_tag];
|
||||
U4 cur_color = tag_colors[cur_tag];
|
||||
|
||||
char semantics_str[64] = "Current Tag: ";
|
||||
U4 name_len = 0;
|
||||
while (tag_name[name_len]) {
|
||||
semantics_str[13 + name_len] = tag_name[name_len];
|
||||
name_len++;
|
||||
}
|
||||
semantics_str[13 + name_len] = '\0';
|
||||
|
||||
ms_set_text_color(hdc, cur_color);
|
||||
ms_text_out_a(hdc, 40, 580, semantics_str, 13 + name_len);
|
||||
}
|
||||
|
||||
ms_set_text_color(hdc, 0x00C8C8C8);
|
||||
ms_text_out_a(hdc, 400, 520, "Global Memory (Contiguous Array):", 33);
|
||||
for (int i=0; i<4; i++) {
|
||||
char glob_str[32] = "[0]: 00000000";
|
||||
glob_str[1] = '0' + i;
|
||||
u64_to_hex(vm_globals[i], glob_str + 5, 8);
|
||||
ms_set_text_color(hdc, 0x00D6A454); // Soft blue
|
||||
ms_text_out_a(hdc, 400, 550 + (i * 25), glob_str, 13);
|
||||
}
|
||||
|
||||
// Print Log
|
||||
ms_set_text_color(hdc, 0x00C8C8C8);
|
||||
ms_text_out_a(hdc, 750, 520, "Print Log:", 10);
|
||||
for (int i=0; i<log_count && i<4; i++) {
|
||||
char log_str[32] = "00000000";
|
||||
u64_to_hex(log_buffer[i], log_str, 8);
|
||||
ms_set_text_color(hdc, 0x0094BAA1);
|
||||
ms_text_out_a(hdc, 750, 550 + (i * 25), log_str, 8);
|
||||
}
|
||||
ms_select_object(hdc, hOldFont);
|
||||
ms_delete_object(hBgBrush);
|
||||
ms_delete_object(hBrushEdit);
|
||||
|
||||
BIN
colorforth-nudge.skill
Normal file
BIN
colorforth-nudge.skill
Normal file
Binary file not shown.
31
colorforth-nudge/SKILL.md
Normal file
31
colorforth-nudge/SKILL.md
Normal file
@@ -0,0 +1,31 @@
|
||||
---
|
||||
name: colorforth-nudge
|
||||
description: "Interactive mentor for building a sourceless, zero-overhead ColorForth derivative. Use when the user wants to work on the 'bootslop' project, providing guided nudges and architectural validation based on the Lottes/Onat paradigm."
|
||||
---
|
||||
|
||||
# ColorForth Nudge & Review Skill
|
||||
|
||||
This skill transforms Gemini CLI into a highly contextualized mentor for building a specific type of zero-overhead, sourceless ColorForth derivative.
|
||||
|
||||
## Workflow Trigger
|
||||
|
||||
This skill should be activated when the user expresses intent to work on the "bootslop" or "ColorForth" project.
|
||||
|
||||
## Your Role: The Mentor
|
||||
|
||||
Your primary goal is to *guide*, not *do*. The user is learning how to build this system from scratch. Your task is to provide architectural validation, specific tactical assistance when requested, and "guided nudges" to help them get to the next step.
|
||||
|
||||
## Session Start Procedure
|
||||
|
||||
On activation, immediately perform the following steps:
|
||||
|
||||
1. **Refresh Context:** Read the following two files from the project root to load the complete architectural blueprint into your context:
|
||||
* `C:/projects/forth/bootslop/CONVENTIONS.md`
|
||||
* `C:/projects/forth/bootslop/references/Architectural_Consolidation.md`
|
||||
|
||||
2. **Analyze Current State:**
|
||||
* List the contents of the `attempt_1/` directory.
|
||||
* Read the `attempt_1/main.c` file.
|
||||
|
||||
3. **Prompt for Nudge:** Conclude your first response with a summary of the project's current state and ask the user for the next step.
|
||||
* **Example:** *"The context is loaded. The current prototype has a working JIT compiler, a modal editor, and a 2-character dictionary resolver. The editor supports keyboard input and visualizes the sourceless token array. What is the next implementation step you'd like me to guide you through?"*
|
||||
@@ -51,8 +51,8 @@ $compiler_args += $flag_no_optimization
|
||||
$compiler_args += $flag_diagnostics_absolute_paths
|
||||
$compiler_args += $flag_exceptions_disabled
|
||||
$compiler_args += ($flag_include + (join-path $path_root "attempt_1"))
|
||||
$compiler_args += "-nostdlib"
|
||||
$compiler_args += "-ffreestanding"
|
||||
# $compiler_args += "-nostdlib"
|
||||
# $compiler_args += "-ffreestanding"
|
||||
$compiler_args += $flag_compile
|
||||
$compiler_args += $flag_path_output, $object
|
||||
$compiler_args += $unit_source
|
||||
@@ -73,7 +73,7 @@ $linker_args += $flag_link_win_debug
|
||||
$linker_args += $flag_link_win_pdb + $pdb
|
||||
$linker_args += $flag_link_mapfile + $map
|
||||
$linker_args += $flag_link_win_subsystem_console
|
||||
$linker_args += "/nodefaultlib"
|
||||
# $linker_args += "/nodefaultlib"
|
||||
$linker_args += "kernel32.lib"
|
||||
$linker_args += "user32.lib"
|
||||
$linker_args += "gdi32.lib"
|
||||
|
||||
Reference in New Issue
Block a user