Languages Features Creators CSV Resources Challenges Add Language
GitHub icon


SIL - Intermediate representation language

< >

SIL, aka Swift Intermediate Language, is an intermediate representation language created in 2012.

#490on PLDB 11Years Old 0Books

Example from the web:
// SIL is reliant on Swift's type system and declarations, so SIL syntax is an extension of Swift's. A .sil file is a Swift source file with added SIL definitions. The Swift source is parsed only for its declarations; Swift func bodies (except for nested declarations) and top-level code are ignored by the SIL parser. In a .sil file, there are no implicit imports; the swift and/or Builtin standard modules must be imported explicitly if used. sil_stage canonical import Swift // Define types used by the SIL function. struct Point { var x : Double var y : Double } class Button { func onClick() func onMouseDown() func onMouseUp() } // Declare a Swift function. The body is ignored by SIL. func taxicabNorm(_ a:Point) -> Double { return a.x + a.y } // Define a SIL function. // The name @_T5norms11taxicabNormfT1aV5norms5Point_Sd is the mangled name // of the taxicabNorm Swift function. sil @_T5norms11taxicabNormfT1aV5norms5Point_Sd : $(Point) -> Double { bb0(%0 : $Point): // func Swift.+(Double, Double) -> Double %1 = function_ref @_Tsoi1pfTSdSd_Sd %2 = struct_extract %0 : $Point, #Point.x %3 = struct_extract %0 : $Point, #Point.y %4 = apply %1(%2, %3) : $(Double, Double) -> Double return %4 : Double } // Define a SIL vtable. This matches dynamically-dispatched method // identifiers to their implementations for a known static class type. sil_vtable Button { #Button.onClick: @_TC5norms6Button7onClickfS0_FT_T_ #Button.onMouseDown: @_TC5norms6Button11onMouseDownfS0_FT_T_ #Button.onMouseUp: @_TC5norms6Button9onMouseUpfS0_FT_T_ }
Example from hello-world:
print Hello World

Language features

Feature Supported Token Example
Print() Debugging print
// A comment
Line Comments //
// A comment
Semantic Indentation X
openvera.html · swift-il.html · rpl.html

View source

- Build the next great programming language · Search · Day 213 · About · Blog · Acknowledgements · Traffic · Traffic Today · GitHub ·