feat(builtin): path_exists 추가 + file_exists fopen→S_ISREG 백엔드 통일#2160
Merged
Conversation
canonical 파일존재 3분법(Go/Rust)에 맞춤:
· path_exists(path)->bool 신규 = stat 기반, 존재하면 정규파일·디렉터리 무관 true
(Rust Path::exists() / Go os.Stat+!IsNotExist). C impl = stat()==0.
· file_exists 백엔드 불일치 버그 수정 = self/build_c.hexa 의 fopen(path,"rb")
(Linux서 디렉터리에 true) → stat+S_ISREG 로 교체, runtime_core_emit.hexa 의
S_ISREG 구현과 일치(정규파일 전용 = is_file).
결과: path_exists=exists(any) · file_exists=is_file(정규파일만) · dir_exists=is_dir.
등록 전수성(@l3) — file_exists 가 등록된 모든 백엔드 site 에 path_exists 동반 등록:
bind.hexa(빌트인 목록) · arm64_darwin(name→rt) · build_c(emit+C impl+Int반환) ·
runtime_core_emit(rt_path_exists C impl+decl) · codegen(emit+is-builtin) ·
rt_symbols · env · lsp · rt/io · rt/fs · runtime/io(pub fn) · native_build ·
hexa_repl · runtime.h(forward decl). 누락 없음 = unknown-builtin 없음.
검증: hexa 자기호스팅 재빌드(LOCAL_BUILD Mac) 부트스트랩 PASS · 6-case
(path_exists dir/file=T·missing=F · file_exists dir=F·file=T·missing=F) PASS ·
test/runtime/io_test 10/10 회귀 PASS.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
요약
hexa 파일존재 빌트인을 canonical(Go/Rust) 3분법에 맞춘다.
path_exists(path) -> bool신규 추가 — stat 기반, 경로가 존재하면 정규파일·디렉터리·그외 무관 true. RustPath::exists()/ Goos.Stat+!IsNotExist의미. C impl =struct stat st; return (stat(path,&st)==0)?1:0;file_exists백엔드 불일치 버그 수정 —self/build_c.hexa의hexa_file_exists가fopen(path,"rb")로 구현돼 Linux서 디렉터리에 true 를 반환했다.stat+S_ISREG로 교체해self/runtime_core_emit.hexa의 기존 S_ISREG 구현과 일치(정규파일 전용 = is_file).결과 canonical 매핑:
path_exists=exists(any) ·file_exists=is_file(정규파일만) ·dir_exists=is_dir(디렉터리만).기존 갭(walkie-hexa #292서 발견): hexa엔 generic exists 가 없어
.git(clone=dir, worktree=gitfile) 확인에 shelltest -e우회가 필요했다. path_exists 가 그 갭을 메운다.등록 전수성 (@l3)
자기호스팅 컴파일러라 빌트인은 모든 백엔드 site 에 등록해야 unknown-builtin 이 안 난다.
file_exists가 등록된 모든 자리에path_exists동반 등록:compiler/check/bind.hexacompiler/codegen/arm64_darwin.hexart_path_exists)self/build_c.hexaself/runtime_core_emit.hexaself/codegen.hexaself/codegen/rt_symbols.hexaself/env.hexa·self/lsp.hexa·tool/hexa_repl.hexaself/rt/io.hexa·self/rt/fs.hexaself/runtime/io.hexatest -e)tool/native_build.hexaself/runtime.hcompiler/intrinsics/intrinsics.hexa의 기존pub fn path_exists(import용 v0)와 충돌 없음 — 빌트인은 always-in-scope, local pub fn 이 shadow (file_exists 와 동일 패턴, 다수 local fn 공존 확인).검증
[0-pre]runtime_core.c regen →[3/5]main 재트랜스파일 →[5/5]smoke OK(--version·parse·build round-trip). 부트스트랩 PASS.test/runtime/io_test.hexa10/10 PASS (file_exists·dir_exists·dir_exists(file)==false 커버).53 insertions / 5 deletions, 14 files — 단일 PR (<200 LOC, @l6).
🤖 Generated with Claude Code