A .NET 8 library for building, manipulating, and serialising an object-oriented intermediate representation (IR). Think LLVM IR, but designed from the ground up for OO languages — classes, interfaces, structs, generics, virtual dispatch, and all.
Most compiler toolkits either target a low-level bytecode (too far from OO semantics) or tie you to a specific runtime (too opinionated). ObjectIR.Core gives you a strongly-typed in-memory graph of your program's types and methods that you can:
- Build with a fluent API or parse from a simple text format
- Query for dependencies and do topological analysis
- Compose multiple modules into one
- Serialize to JSON, BSON, or the compact FOB binary format
dotnet add package ObjectIR.Coreusing ObjectIR.Core.Builder;
using ObjectIR.Core.IR;
var module = new IRBuilder("MyApp")
.Class("Animal")
.Field("name", TypeReference.String)
.Access(AccessModifier.Private)
.EndField()
.Method("Speak", TypeReference.String)
.Virtual()
.Body()
.Ldarg(0)
.Ldfld(new FieldReference(TypeReference.FromName("Animal"), "name", TypeReference.String))
.Ret()
.EndBody()
.EndMethod()
.EndClass()
.Build();
Console.WriteLine(module.Name); // MyApp
Console.WriteLine(module.Types[0].Name); // Animal| Page | What's covered |
|---|---|
| Getting Started | Install, first example, what to read next |
| Architecture | Namespaces, layer diagram, design decisions |
| IR Model | Module, type definitions, members, instructions |
| Builder API | Fluent IRBuilder walkthrough with examples |
| Serialization | Text format, JSON/BSON, ModuleLoader |
| Composition | Multi-module merging and dependency resolution |
| FOB Format | Compact binary format spec |
ObjectIR.Core/
├── IR/ # Core data model (Module, TypeDefinition, Instructions …)
├── Builder/ # Fluent IRBuilder API
├── Serialization/ # Text, JSON, BSON serializers and ModuleLoader
├── Composition/ # ModuleComposer, DependencyResolver
├── Compilers/ # Construct-language front-end compiler
├── Parsing/ # Text IR parser
├── Ast/ # AST node types
└── docs/ # This documentation
MIT — see LICENSE for details.