Skip to content

mlvea/SwiftPrism

Repository files navigation

Swift Prism

Swift Prism is a macOS app for exploring how source code becomes a running program. It is built for learning and investigation: you can watch a small teaching language move through a full compiler pipeline, or capture output from a real Swift toolchain installed on your Mac.

https://apps.apple.com/sg/app/compiler-prism/id6782965485

Swift Prism Lab workspace

Lab — source, pipeline map, stage output, and inspector.

Dual mode

Swift Prism uses two modes on purpose. They solve different problems, and the app keeps them clearly separate so results are never mixed up.

Teaching mode (Prism language)

The Prism language is a small language designed for education. It is not Swift. Every compiler stage is open to inspection:

  1. Read source — tokens and structure linked back to the text you wrote
  2. Check meaning — names, types, scopes, and errors
  3. Lower to intermediate form — a simplified internal representation
  4. Optional teaching optimizations — for example folding constants, with a clear before/after record
  5. Lower to bytecode — instructions for Prism’s own virtual machine
  6. Run and step — Trace mode lets you step, rewind, and inspect values

Use teaching mode when you want to learn how a compiler is put together, or to follow a program line by line without installing multiple Swift versions.

Authentic Swift mode (your toolchains)

On macOS, Prism can run a real Swift compiler you already have—typically from Xcode or Swiftly. That path does not reimplement Swift. It records what the real compiler produces:

  • Diagnostics (errors and notes)
  • Frontend structure summaries
  • SIL (Swift Intermediate Language) as text, with a high-level function/block overview when possible
  • LLVM IR and assembly as text dumps
  • Diff — compare the same stage across two toolchains side by side

Dumps are cleaned up where possible (paths, ordering) so comparisons are more stable. Structure for SIL is a summary, not a full model of every SIL type and ownership detail.

Use authentic mode when you want evidence from the real toolchain—for example comparing two Swift versions, or browsing SIL differences in a visual workspace.

How the modes fit together

Workspace Role
Lab Edit source and inspect the teaching pipeline
Architecture Map of compiler phases (teaching and authentic)
Diff Compare authentic Swift output across toolchains
Trace Step the teaching language’s virtual machine

Teaching results are never presented as “live Swift compilation.” Authentic output is labeled as coming from a real toolchain.

Swift Prism Diff comparing Swift intermediate language across toolchains

Diff — compare real toolchain output (for example SIL) across versions.

Highlights

  • Native macOS app (SwiftUI)
  • Teaching compiler with inspectable stages and a stepable virtual machine
  • Real Swift toolchain capture and multi-toolchain Diff
  • Toolchain discovery and optional Swiftly install management
  • Clear UI about what is fully inspectable versus raw compiler text

Requirements

  • macOS 14 or later
  • Xcode (or Command Line Tools) for the macOS SDK when using authentic Swift stages
  • Optional: Swiftly for managing Swift toolchains

Build and run

# Run package tests
cd CompilerAtlas
swift test
# Open the app in Xcode (scheme: Prism)
open CompilerAtlas.xcodeproj

Or build from the command line:

xcodebuild -project CompilerAtlas.xcodeproj -scheme Prism -configuration Debug build

Project layout

Path Purpose
CompilerAtlas/ Shared Swift package (language, tools, UI library, tests)
CompilerAtlasMac/ macOS application target
CompilerAtlas.xcodeproj Xcode project — scheme Prism
docs/images/ Screenshots used in this README
docs/privacy-policy.md Privacy policy
docs/ROADMAP.md Possible future work
LICENSE Dual license terms

Privacy

Swift Prism is designed to keep your work on your machine. See docs/privacy-policy.md.

Contributing

Ideas and pull requests are welcome. Longer-term ideas are listed in docs/ROADMAP.md.

License

See LICENSE for full dual-license terms (noncommercial public use and separate commercial licensing).

About

GUI for refraction of compiler pipeline

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages