Compare commits
4 Commits
75b01b9635
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
052f9191c3 | ||
|
|
a74c4b8c41 | ||
|
|
d639c63fd3 | ||
|
|
ab613e644a |
8
main.py
8
main.py
@@ -11542,7 +11542,7 @@ def _run_docs_tui(
|
||||
"\n"
|
||||
" 5. NASM + LINKER\n"
|
||||
" The assembly is assembled by NASM into an object\n"
|
||||
" file, then linked (via ld or gcc) into the final\n"
|
||||
" file, then linked (via ld or ld.ldd) into the final\n"
|
||||
" binary.\n"
|
||||
"\n"
|
||||
"───────────────────────────────────────────────────────────────\n"
|
||||
@@ -11567,7 +11567,7 @@ def _run_docs_tui(
|
||||
" The CT VM is a stack-based interpreter that runs during\n"
|
||||
" parsing. It maintains:\n"
|
||||
"\n"
|
||||
" - A value stack (Python list of ints/strings/lists)\n"
|
||||
" - A value stack\n"
|
||||
" - A dictionary of CT-callable words\n"
|
||||
" - A return stack for nested calls\n"
|
||||
"\n"
|
||||
@@ -11579,7 +11579,7 @@ def _run_docs_tui(
|
||||
"\n"
|
||||
" When --ct-run-main is used, the CT VM can also JIT-compile\n"
|
||||
" and execute native x86-64 code via the Keystone assembler\n"
|
||||
" engine (for words that need native performance).\n"
|
||||
" engine (for words that need near native performance).\n"
|
||||
"\n"
|
||||
"───────────────────────────────────────────────────────────────\n"
|
||||
"\n"
|
||||
@@ -11641,7 +11641,7 @@ def _run_docs_tui(
|
||||
" just numbers. Type safety is your responsibility.\n"
|
||||
"\n"
|
||||
" - Macro expansion depth: macros can expand macros,\n"
|
||||
" but there's a limit (default 64, configurable via\n"
|
||||
" but there's a limit (default 256, configurable via\n"
|
||||
" --macro-expansion-limit).\n"
|
||||
"\n"
|
||||
" - :py blocks: Python code embedded in :py { ... }\n"
|
||||
|
||||
@@ -326,3 +326,22 @@ word dyn_arr_sorted
|
||||
dyn_arr_clone
|
||||
dyn_arr_sort
|
||||
end
|
||||
|
||||
# arr_contains [*, addr | x] -> [* | bool]
|
||||
word arr_contains
|
||||
over @ >r >r 8 + r> r>
|
||||
for
|
||||
2dup swap @ == if 1 nip nip rdrop ret end
|
||||
swap 8 + swap
|
||||
end 0 nip nip
|
||||
end
|
||||
|
||||
# arr_find [*, addr | x] -> [* | bool]
|
||||
word arr_find
|
||||
over @ >r >r 8 + r> r>
|
||||
0 >r
|
||||
for
|
||||
2dup swap @ == if rswap r> nip nip rdrop ret end
|
||||
swap 8 + swap rswap r> 1 + >r rswap
|
||||
end rdrop -1 nip nip
|
||||
end
|
||||
|
||||
@@ -531,7 +531,26 @@ end
|
||||
# contains [*, addr, len, addr | len] -> [* | bool]
|
||||
word contains
|
||||
2 pick for
|
||||
4dup strcmp 1 == if 1 nip nip nip nip ret end
|
||||
4dup strcmp 1 == if 1 nip nip nip nip rdrop ret end
|
||||
>r >r >r 1 + r> r> r>
|
||||
end 0 nip nip nip nip
|
||||
end
|
||||
|
||||
# find the first occurence of a string inside another string, returns the index
|
||||
# find [*, addr, len, addr | len] -> [* | index]
|
||||
word find
|
||||
0 >r 2 pick for
|
||||
4dup strcmp 1 == if rswap r> nip nip nip nip rdrop ret end
|
||||
>r >r >r 1 + r> r> r> rswap r> 1 + >r rswap
|
||||
end -1 nip nip nip nip
|
||||
end
|
||||
|
||||
# find the last occurence of a string inside another string, returns the index
|
||||
# rfind [*, addr, len, addr | len] -> [* | index]
|
||||
word rfind
|
||||
>r >r dup >r + 1 - r> r> r>
|
||||
2 pick 1 - >r 2 pick for
|
||||
4dup strcmp 1 == if rswap r> nip nip nip nip rdrop ret end
|
||||
>r >r >r 1 - r> r> r> rswap r> 1 - >r rswap
|
||||
end -1 nip nip nip nip
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user