Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/seed/ng/a64/tests/macho/lib/libobjc.om # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / seed / ng / a64 / tests / macho / lib / libobjc.om` 107 lines ยท 2164 bytes Raw Blame History 1 target macos 2 note libobjc: dlopen through libfn 0, then Objective-C messages. [[NSProcessInfo processInfo] processorCount] 3 note must equal sysconf(57), the configured processors. Status 1; 2 to 6 name the step that failed. 4 text s_fnd "/System/Library/Frameworks/Foundation.framework/Foundation" 5 text s_gc "objc_getClass" 6 text s_sr "sel_registerName" 7 text s_ms "objc_msgSend" 8 text s_sc "sysconf" 9 text s_cls "NSProcessInfo" 10 text s_pi "processInfo" 11 text s_pc "processorCount" 12 13 fn p64 b edit uchar 128 o ulong v ulong to void 14 for i ulong 8 15 put b add o i uchar and shr v mul i 8 255 16 end 17 end 18 19 fn g64 b view uchar 128 o ulong to ulong 20 v = ulong 0 21 for i ulong 8 22 v = or v shl ulong get b add o i mul i 8 23 end 24 ret v 25 end 26 27 note the address of the library function named by the n bytes of nm (nm is zero after them) 28 fn sym rg edit uchar 128 nm edit uchar 64 to ulong 29 p64 rg 0 `18446744073709551614` 30 p64 rg 8 ulong libptr nm 0 64 31 ret ulong libcall ulong libfn 1 rg 0 128 32 end 33 34 fn main to int 35 rg = new uchar 128 0 36 nm = new uchar 64 0 37 for i ulong len s_fnd 38 put nm i get s_fnd i 39 end 40 put nm len s_fnd 0 41 p64 rg 0 ulong libptr nm 0 64 42 p64 rg 8 2 43 h = libcall ulong libfn 0 rg 0 128 44 if eq h 0 45 ret 2 46 end 47 for i ulong len s_gc 48 put nm i get s_gc i 49 end 50 put nm len s_gc 0 51 gc = sym rg nm 52 for i ulong len s_sr 53 put nm i get s_sr i 54 end 55 put nm len s_sr 0 56 sr = sym rg nm 57 for i ulong len s_ms 58 put nm i get s_ms i 59 end 60 put nm len s_ms 0 61 ms = sym rg nm 62 for i ulong len s_sc 63 put nm i get s_sc i 64 end 65 put nm len s_sc 0 66 sc = sym rg nm 67 if or or eq gc 0 eq sr 0 or eq ms 0 eq sc 0 68 ret 3 69 end 70 for i ulong len s_cls 71 put nm i get s_cls i 72 end 73 put nm len s_cls 0 74 p64 rg 0 ulong libptr nm 0 64 75 cls = libcall gc rg 0 128 76 if eq cls 0 77 ret 4 78 end 79 for i ulong len s_pi 80 put nm i get s_pi i 81 end 82 put nm len s_pi 0 83 p64 rg 0 ulong libptr nm 0 64 84 sel = libcall sr rg 0 128 85 p64 rg 0 g64 rg 0 86 p64 rg 0 ulong cls 87 p64 rg 8 ulong sel 88 pi = libcall ms rg 0 128 89 if eq pi 0 90 ret 5 91 end 92 for i ulong len s_pc 93 put nm i get s_pc i 94 end 95 put nm len s_pc 0 96 p64 rg 0 ulong libptr nm 0 64 97 sel = libcall sr rg 0 128 98 p64 rg 0 ulong pi 99 p64 rg 8 ulong sel 100 n = libcall ms rg 0 128 101 p64 rg 0 57 102 c = libcall sc rg 0 128 103 if or ne n c le n 0 104 ret 6 105 end 106 ret 1 107 end