How rohinthan/cco-lang works
Cco is a statically typed compiled language whose compiler takes source through lexical and syntactic analysis, module and semantic resolution, then IR lowering and optimization before selecting a C11 or native x86-64 output path. The native path includes instruction selection, encoding, ELF generation and linking; the C11 path emits portable C for a host compiler. The README documents additional language capabilities represented as frontend/semantic subsystems. Some subsystem paths are directories because their detailed implementation was not excerpted; edges reflect README statements or visible source-index references.
Main entry points: main.c Compiler driver · x86_64_codegen.c x86-64 codegen · parser.c Parser and AST · ir_lower.c IR lowering
Components 24
Frontend
- Lexer
src/frontend/lexer.c - Parser and AST
src/frontend/parser.c - Module resolver
src/frontend/module_resolver.c - Scope analysis
src/frontend/scope_analysis.c - Class declarations
src/frontend/class_decl.c - Trait resolution
src/frontend/trait_resolver.c
IR and Optimization
- IR lowering
src/ir/ir_lower.c - IR representation
src/ir/ir.c - IR verification
src/ir/ir_verify.c - SSA construction
src/ir/ir_ssa.c - SSA optimization
src/ir/ir_ssa_opt.c - IR optimization
src/ir/ir_opt.c - Interprocedural analysis
src/ir/ir_ipa.c
C11 Backend
- C code generation
src/backend/c11/codegen.c
Native Backend
- x86-64 codegen
src/backend/x86_64/x86_64_codegen.c - Register allocation
src/backend/x86_64/x86_64_regalloc.c - Instruction representation
src/backend/x86_64/x86_64_instr.c - Machine encoding
src/backend/x86_64/x86_64_encode.c - ELF object writer
src/backend/x86_64/x86_64_elf.c - Native linker
src/backend/x86_64/x86_64_link.c - Freestanding runtime
src/runtime/runtime_start_data.h
Other components
- Cco programmer
- Compiler driver
src/main.c - Host C compiler
Connections 23
- Cco programmer → Compiler driver: provides source
- Compiler driver → Lexer: starts lexing
src/main.c - Compiler driver → Parser and AST: parses tokens
src/main.c - Compiler driver → Module resolver: resolves imports
src/main.c - Compiler driver → Scope analysis: checks scopes
src/main.c - Compiler driver → Trait resolution: resolves traits
src/main.c - Parser and AST → Class declarations: builds declarations
- Compiler driver → IR lowering: lowers AST
src/main.c - IR lowering → IR representation: creates IR
- Compiler driver → IR verification: verifies IR
src/main.c - Compiler driver → SSA construction: builds SSA
- Compiler driver → SSA optimization: optimizes SSA
src/main.c - Compiler driver → IR optimization: optimizes IR
- Compiler driver → Interprocedural analysis: runs IPA
- Compiler driver → C code generation: selects C11 path
src/main.c - C code generation → Host C compiler: emits C for
- Compiler driver → x86-64 codegen: selects native path
src/main.c - x86-64 codegen → Register allocation: uses allocation
src/backend/x86_64/x86_64_codegen.c - x86-64 codegen → Instruction representation: emits instructions
src/backend/x86_64/x86_64_codegen.c - x86-64 codegen → Machine encoding: encodes instructions
src/backend/x86_64/x86_64_codegen.c - x86-64 codegen → ELF object writer: writes object
src/backend/x86_64/x86_64_codegen.c - Compiler driver → Native linker: invokes linking
src/main.c - Native linker → Freestanding runtime: embeds startup
src/backend/x86_64/x86_64_link.c