refactor: check.c 와 lower.c 를 사람이 머리에 담을 크기로 나눈다
check.c 3,937 줄, lower.c 1,913 줄이었다. 가장 큰 파일이 978 줄이 됐다.
check.c 679 스코프·심볼·흐름·소유권 접착
checkexp.c 739 포매팅 검사와 표현식
checkstm.c 635 문장, 함수, 메서드
checkgen.c 618 제네릭 실체화
checkcal.c 978 유닛 경계 호출과 옵셔널/에러 유니온
checkpro.c 184 선언 패스와 프로그램
lower.c 567 타입·슬롯·지역·블록·mem.*
lowerprn.c 238 포매팅 빌트인 전개
lowerexp.c 468 표현식
lowerstm.c 543 문장·함수·프로그램
줄 범위로 잘랐다. 주제별로 묶는 것보다 정확한데, 한 줄도 잃거나 겹치지
않기 때문이다. 파일 순서가 이미 단계를 따라가서 경계가 실제 이음매에 떨어진다.
모든 정의가 static 을 잃고 비공개 헤더에 프로토타입을 갖는다. 대안 --
static 을 유지하고 #include 로 텍스트만 나누는 것 -- 은 결합을 보여주는 대신
숨긴다.
두 스위트 그대로: 209/209, 21/21.
This commit is contained in:
+89
-1
@@ -26,7 +26,7 @@ prefix db 'ferro: ',0
|
||||
at_word db ' at ',0
|
||||
colon db ':',0
|
||||
newline db 13,10,0
|
||||
numbuf db 16 dup(0)
|
||||
numbuf db 24 dup(0)
|
||||
written dd 0
|
||||
allocs dd 0
|
||||
frees dd 0
|
||||
@@ -210,6 +210,94 @@ fe_rt_frees proc near
|
||||
ret
|
||||
fe_rt_frees endp
|
||||
|
||||
; fe_rt_write_int(handle, value, is_unsigned) -- decimal, with a sign when
|
||||
; the value is negative and signed was asked for.
|
||||
public fe_rt_write_int
|
||||
fe_rt_write_int proc near
|
||||
push ebp
|
||||
mov ebp, esp
|
||||
push ebx
|
||||
push esi
|
||||
push edi
|
||||
mov edi, offset numbuf + 15
|
||||
mov byte ptr [edi], 0
|
||||
mov eax, [ebp+12]
|
||||
xor ebx, ebx ; ebx = 1 when a '-' is needed
|
||||
cmp dword ptr [ebp+16], 0
|
||||
jne int_digits
|
||||
test eax, eax
|
||||
jge int_digits
|
||||
neg eax
|
||||
mov ebx, 1
|
||||
int_digits:
|
||||
mov ecx, 10
|
||||
int_loop:
|
||||
xor edx, edx
|
||||
div ecx
|
||||
add dl, '0'
|
||||
dec edi
|
||||
mov [edi], dl
|
||||
test eax, eax
|
||||
jnz int_loop
|
||||
test ebx, ebx
|
||||
je int_write
|
||||
dec edi
|
||||
mov byte ptr [edi], '-'
|
||||
int_write:
|
||||
mov esi, offset numbuf + 15
|
||||
sub esi, edi
|
||||
push esi
|
||||
push edi
|
||||
push dword ptr [ebp+8]
|
||||
call fe_rt_write
|
||||
add esp, 12
|
||||
pop edi
|
||||
pop esi
|
||||
pop ebx
|
||||
mov esp, ebp
|
||||
pop ebp
|
||||
ret
|
||||
fe_rt_write_int endp
|
||||
|
||||
; fe_rt_write_hex(handle, value)
|
||||
public fe_rt_write_hex
|
||||
fe_rt_write_hex proc near
|
||||
push ebp
|
||||
mov ebp, esp
|
||||
push ebx
|
||||
push esi
|
||||
push edi
|
||||
mov edi, offset numbuf + 15
|
||||
mov byte ptr [edi], 0
|
||||
mov eax, [ebp+12]
|
||||
hex_loop:
|
||||
mov edx, eax
|
||||
and edx, 15
|
||||
cmp dl, 10
|
||||
jb hex_digit
|
||||
add dl, 'a' - 10 - '0'
|
||||
hex_digit:
|
||||
add dl, '0'
|
||||
dec edi
|
||||
mov [edi], dl
|
||||
shr eax, 4
|
||||
test eax, eax
|
||||
jnz hex_loop
|
||||
mov esi, offset numbuf + 15
|
||||
sub esi, edi
|
||||
push esi
|
||||
push edi
|
||||
push dword ptr [ebp+8]
|
||||
call fe_rt_write
|
||||
add esp, 12
|
||||
pop edi
|
||||
pop esi
|
||||
pop ebx
|
||||
mov esp, ebp
|
||||
pop ebp
|
||||
ret
|
||||
fe_rt_write_hex endp
|
||||
|
||||
; fe_rt_exit(code) -- never returns
|
||||
public fe_rt_exit
|
||||
fe_rt_exit proc near
|
||||
|
||||
Reference in New Issue
Block a user