Skip to content

Instantly share code, notes, and snippets.

Created November 4, 2016 16:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/8ff0b4ce6ed30c31f4beb4aa84b6c57d to your computer and use it in GitHub Desktop.
Save anonymous/8ff0b4ce6ed30c31f4beb4aa84b6c57d to your computer and use it in GitHub Desktop.
StoredProperty
SOURCE:
struct StoredProperty {
var variable: Int
mutating func function() {
self.variable = 1
}
}
SWIFTC:
swiftc -dump-ast StoredProperty.swift
AST:
(source_file
(struct_decl "StoredProperty" type='StoredProperty.Type' access=internal @_fixed_layout
(pattern_binding_decl
(pattern_typed type='Int'
(pattern_named type='Int' 'variable')
(type_ident
(component id='Int' bind=Swift.(file).Int))))
(var_decl "variable" type='Int' access=internal storage_kind=stored_with_trivial_accessors
(func_decl implicit 'anonname=0x7fd68b8947b0' type='(StoredProperty) -> () -> Int' access=internal getter_for=variable
(parameter_list
(parameter "self" type='StoredProperty'))
(parameter_list)
(brace_stmt
(return_stmt
(member_ref_expr implicit type='Int' decl=StoredProperty.(file).StoredProperty.variable@StoredProperty.swift:10:9 direct_to_storage
(declref_expr implicit type='StoredProperty' decl=StoredProperty.(file).StoredProperty.func decl.self@StoredProperty.swift:10:9 specialized=no)))))
(func_decl implicit 'anonname=0x7fd68b894a10' type='(inout StoredProperty) -> (Int) -> ()' access=internal setter_for=variable
(parameter_list
(parameter "self" type='inout StoredProperty' mutable))
(parameter_list
(parameter "value" type='Int'))
(brace_stmt
(assign_expr
(member_ref_expr implicit type='@lvalue Int' accessKind=write decl=StoredProperty.(file).StoredProperty.variable@StoredProperty.swift:10:9 direct_to_storage
(declref_expr implicit type='@lvalue StoredProperty' accessKind=readwrite decl=StoredProperty.(file).StoredProperty.func decl.self@StoredProperty.swift:10:9 specialized=no))
(declref_expr implicit type='Int' decl=StoredProperty.(file).StoredProperty.func decl.value@StoredProperty.swift:10:9 specialized=no))))
(func_decl implicit 'anonname=0x7fd68b895c20' type='(inout StoredProperty) -> (Builtin.RawPointer, inout Builtin.UnsafeValueBuffer) -> (Builtin.RawPointer, (@convention(thin) (Builtin.RawPointer, inout Builtin.UnsafeValueBuffer, inout StoredProperty, @thick StoredProperty.Type) -> ())?)' access=internal materializeForSet_for=variable
(parameter_list
(parameter "self" type='inout StoredProperty' mutable))
(parameter_list
(parameter "buffer" type='Builtin.RawPointer')
(parameter "callbackStorage" type='inout Builtin.UnsafeValueBuffer' mutable))))
(func_decl "function()" type='(inout StoredProperty) -> () -> ()' access=internal
(parameter_list
(parameter "self" type='inout StoredProperty' mutable))
(parameter_list)
(brace_stmt
(assign_expr
(member_ref_expr type='@lvalue Int' accessKind=write location=StoredProperty.swift:13:14 range=[StoredProperty.swift:13:9 - line:13:14] decl=StoredProperty.(file).StoredProperty.variable@StoredProperty.swift:10:9 direct_to_storage
(declref_expr type='@lvalue StoredProperty' accessKind=readwrite location=StoredProperty.swift:13:9 range=[StoredProperty.swift:13:9 - line:13:9] decl=StoredProperty.(file).StoredProperty.func decl.self@StoredProperty.swift:12:19 specialized=no))
(call_expr implicit type='Int' location=StoredProperty.swift:13:25 range=[StoredProperty.swift:13:25 - line:13:25] nothrow
(constructor_ref_call_expr implicit type='(_builtinIntegerLiteral: Int2048) -> Int' location=StoredProperty.swift:13:25 range=[StoredProperty.swift:13:25 - line:13:25] nothrow
(declref_expr implicit type='Int.Type -> (_builtinIntegerLiteral: Int2048) -> Int' location=StoredProperty.swift:13:25 range=[StoredProperty.swift:13:25 - line:13:25] decl=Swift.(file).Int.init(_builtinIntegerLiteral:) specialized=no)
(type_expr implicit type='Int.Type' location=StoredProperty.swift:13:25 range=[StoredProperty.swift:13:25 - line:13:25] typerepr='Int'))
(tuple_expr implicit type='(_builtinIntegerLiteral: Int2048)' location=StoredProperty.swift:13:25 range=[StoredProperty.swift:13:25 - line:13:25] names=_builtinIntegerLiteral
(integer_literal_expr type='Int2048' location=StoredProperty.swift:13:25 range=[StoredProperty.swift:13:25 - line:13:25] value=1))))))
(func_decl implicit 'anonname=0x7fd68b8947b0' type='(StoredProperty) -> () -> Int' access=internal getter_for=variable
(parameter_list
(parameter "self" type='StoredProperty'))
(parameter_list)
(brace_stmt
(return_stmt
(member_ref_expr implicit type='Int' decl=StoredProperty.(file).StoredProperty.variable@StoredProperty.swift:10:9 direct_to_storage
(declref_expr implicit type='StoredProperty' decl=StoredProperty.(file).StoredProperty.func decl.self@StoredProperty.swift:10:9 specialized=no)))))
(func_decl implicit 'anonname=0x7fd68b894a10' type='(inout StoredProperty) -> (Int) -> ()' access=internal setter_for=variable
(parameter_list
(parameter "self" type='inout StoredProperty' mutable))
(parameter_list
(parameter "value" type='Int'))
(brace_stmt
(assign_expr
(member_ref_expr implicit type='@lvalue Int' accessKind=write decl=StoredProperty.(file).StoredProperty.variable@StoredProperty.swift:10:9 direct_to_storage
(declref_expr implicit type='@lvalue StoredProperty' accessKind=readwrite decl=StoredProperty.(file).StoredProperty.func decl.self@StoredProperty.swift:10:9 specialized=no))
(declref_expr implicit type='Int' decl=StoredProperty.(file).StoredProperty.func decl.value@StoredProperty.swift:10:9 specialized=no))))
(func_decl implicit 'anonname=0x7fd68b895c20' type='(inout StoredProperty) -> (Builtin.RawPointer, inout Builtin.UnsafeValueBuffer) -> (Builtin.RawPointer, (@convention(thin) (Builtin.RawPointer, inout Builtin.UnsafeValueBuffer, inout StoredProperty, @thick StoredProperty.Type) -> ())?)' access=internal materializeForSet_for=variable
(parameter_list
(parameter "self" type='inout StoredProperty' mutable))
(parameter_list
(parameter "buffer" type='Builtin.RawPointer')
(parameter "callbackStorage" type='inout Builtin.UnsafeValueBuffer' mutable)))
(constructor_decl implicit "init(variable:)" type='StoredProperty.Type -> (variable: Int) -> StoredProperty' access=internal designated
(parameter_list
(parameter "self" type='inout StoredProperty' mutable))
(parameter_list
(parameter "variable" apiName=variable type='Int')))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment