-
Notifications
You must be signed in to change notification settings - Fork 0
Standard Library and C API
james-yusuke edited this page Jul 16, 2026
·
1 revision
YCPLは高水準APIとraw foreign APIをdirectoryで分離します。
stl/
├─ std/ YCPL言語レベルの標準API
└─ c/ C、POSIX、runtime、LLVMのraw ABI宣言
主なmodule:
-
std/fmt: print、println、printf -
std/array: 旧slice container互換API -
std/bytes: binary buffer -
std/text: string builderと検索 -
std/json: JSON view/parser -
std/map:Map<string,T>helper -
std/fs: file操作 -
std/os: process/environment -
std/hex、std/base32、std/base64、std/hash -
std/mem: runtime-managed低水準互換API -
std/unsafe/mem: 明示的unsafe raw allocation wrapper -
std/llvm: 既存コード向けLLVM互換wrapper
新しい可変長containerにはstd/arrayではなく、言語組み込みのVec<T>を
推奨します。
c/
├─ stdlib
├─ string
├─ stdio
├─ math
├─ unistd
├─ fcntl
├─ sys/stat
├─ llvm
└─ yc_runtime
import "c/string" as cstr
fn main() i32 {
return cstr.strcmp("YCPL", "YCPL")
}
c/*はraw pointerやforeign lifetimeを扱うため、安全なownershipを自動付与しません。
新しいraw C/LLVM bindingはstl/cへ追加し、stl/stdには高水準wrapperを置きます。
c/llvmはLLVM APIが要求する連続したreference列をVec<i64>から渡す専用bridgeを
持ちますが、一般のYCPLプログラムへVecのraw pointer変換を公開しません。
ycc buildはmanaged C runtimeをnative binaryへstatic linkします。runtimeの探索順:
YCPL_RUNTIME_LIB- compiler executable隣接の
libyc_runtime.a -
YCPL_RUNTIME_SRCが示すdevelopment runtime source
標準ライブラリrootはYCPL_STL_ROOTでoverrideできます。