Compilation unit isolation ========================== Can we ("stage1"-)compile a file without looking at other files? What can definitiely NOT be done: - struct member offset - struct member types (= and expression target type and type scopes for assignment) - function argument types (= and expression target type and type scopes) (i.e. we can not generate a usual object file) (even if we skip target types and type scopes, we still need to know struct member types and offsets) (on the other hand, bundling partial definitions in imports could be useful, e.g. "import func work(int, ref Something)" ) What CAN be done: - generate list of 1) imported symbols and members / arguments / typescope members 2) exports 3) functions, with some kind of IR (with spotty type info) 4) type definitions (with spotty type info) 5) data / variable definitions Simply generating a file with all definitions could potentially make incremental compilation faster: - If interface is unchanged, don't update file or touch mtime. - When compiling a file, only the interfaces of the other files needs to be read. - There could be an index/cache file for all interfaces combined. Alternative approach to fast incremental compilation - Copy (or hash) a all definitions that the compilation unit depends on - When the dependencies are updated, compare against the copies/hashes. If they are identical, then no recompilation is needed. - For minor changes (like a changed enum constant, or re-ordered struct), perhaps we simply update some info in the compiled file? Defintions "binary header" file ------------------------------- We can have one for exports (read when compiling other source files) and one for imports (compared with other headers when checking whether a recompilation of this source file is needed) byte[8] "LRL-BH\x0A\0" le_uint32 num type symbols le_uint32 num function/data symbols for imports header: - list of imported files (for re-reading those headers, if their timestamp is never, OR removing symbols if deleted) tree type symbols (pointers) tree function/data symbols (pointers) bucket[] bucket data Each bucket contains: - number of symbols in bucket - symbols Each symbol contains: - name - symbol definition -- type (primitive/func/ref/struct/class struct/enum/array/optional/etc...) -- data for this type