Converts compile-time type instances to their Nim literal constructor syntax for macro code generation.
typePerson=object
name: string
age: intimport pkg/lifter
macrobuildPerson(): untyped=# Create an instance at compile-timelet someone =Person(name: "Alice", age: 30)
# Convert it to AST syntax: Person(name: "Alice", age: 30)result= someone.lift()
let alice =buildPerson()
echo alice # Person(name: "Alice", age: 30)Takes a type instance that exists at compile-time (in a macro) and generates the Nim source code needed to construct it. This is useful for:
- Embedding compile-time computed values into generated code
- Code generation from configuration objects
- Macro-based serialization/deserialization
proctoNimLiteral*[T](x: T): string# Converts a value to its Nim literal string representation# Example: Point(x: 10, y: 20) -> "Point(x: 10, y: 20)"proclift*[T](item: T): NimNode# Converts a value directly to a NimNode# Equivalent to: parseExpr(item.toNimLiteral)No macro invocation needed! Just call lift() or toNimLiteral() directly on any type.
- ✅ Objects, ref objects, ptr objects
- ✅ Strings (with proper escaping)
- ✅ Sequences
- ✅ Primitives (int, float, bool, etc.)
- ❌ NimNode (raises ValueError)
- Support for tables/sets
- Support for tuples
- Reverse lifting (AST → object instances)
- Custom serialization hooks