Created
October 13, 2016 19:08
-
-
Save anonymous/21acafc69dea8e3e44c0efde8009c016 to your computer and use it in GitHub Desktop.
Swift-AST-Property
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Swift-AST-Property | |
// generate ivar of type int with setter and getter | |
(var_decl "variable" type='Int' access=internal storage_kind=stored_with_trivial_accessors | |
// generate curried getter | |
// func getter(self: Struct) -> () -> Int { | |
// return { self._backed_ivar } | |
// } | |
(func_decl implicit 'anonname=0x7feeaa0b9730' type='(Struct) -> () -> Int' access=internal getter_for=variable | |
(parameter_list | |
(parameter "self" type='Struct')) | |
(parameter_list) | |
(brace_stmt | |
(return_stmt | |
(member_ref_expr implicit type='Int' decl=Struct.(file).Struct.variable@Struct.swift:10:9 direct_to_storage | |
(declref_expr implicit type='Struct' decl=Struct.(file).Struct.func decl.self@Struct.swift:10:9 specialized=no))))) | |
// generate curried setter | |
// func setter(inout self: Struct) -> (Int) -> () { | |
// return { self._backed_ivar = $0 } | |
// } | |
(func_decl implicit 'anonname=0x7feeaa0b9990' type='(inout Struct) -> (Int) -> ()' access=internal setter_for=variable | |
(parameter_list | |
(parameter "self" type='inout Struct' mutable)) | |
(parameter_list | |
(parameter "value" type='Int')) | |
(brace_stmt | |
(assign_expr | |
(member_ref_expr implicit type='@lvalue Int' accessKind=write decl=Struct.(file).Struct.variable@Struct.swift:10:9 direct_to_storage | |
(declref_expr implicit type='@lvalue Struct' accessKind=readwrite decl=Struct.(file).Struct.func decl.self@Struct.swift:10:9 specialized=no)) | |
(declref_expr implicit type='Int' decl=Struct.(file).Struct.func decl.value@Struct.swift:10:9 specialized=no)))) | |
// Generate curried function | |
// func function(self: Struct) -> () -> Int { | |
// return { 2 } | |
// } | |
(func_decl "function()" type='(Struct) -> () -> Int' access=internal | |
(parameter_list | |
(parameter "self" type='Struct')) | |
(parameter_list) | |
(result | |
(type_ident | |
(component id='Int' bind=Swift.(file).Int))) | |
(brace_stmt | |
(return_stmt | |
(call_expr implicit type='Int' location=Struct.swift:13:16 range=[Struct.swift:13:16 - line:13:16] nothrow | |
(constructor_ref_call_expr implicit type='(_builtinIntegerLiteral: Int2048) -> Int' location=Struct.swift:13:16 range=[Struct.swift:13:16 - line:13:16] nothrow | |
(declref_expr implicit type='Int.Type -> (_builtinIntegerLiteral: Int2048) -> Int' location=Struct.swift:13:16 range=[Struct.swift:13:16 - line:13:16] decl=Swift.(file).Int.init(_builtinIntegerLiteral:) specialized=no) | |
(type_expr implicit type='Int.Type' location=Struct.swift:13:16 range=[Struct.swift:13:16 - line:13:16] typerepr='Int')) | |
(tuple_expr implicit type='(_builtinIntegerLiteral: Int2048)' location=Struct.swift:13:16 range=[Struct.swift:13:16 - line:13:16] names=_builtinIntegerLiteral | |
(integer_literal_expr type='Int2048' location=Struct.swift:13:16 range=[Struct.swift:13:16 - line:13:16] value=2)))))) | |
// Not a member, so not curried | |
// func globalFunction(value: Struct) -> Int { | |
// return function(value)() | |
// } | |
(func_decl "globalFunction(_:)" type='(Struct) -> Int' access=internal | |
(parameter_list | |
(parameter "value" type='Struct')) | |
(result | |
(type_ident | |
(component id='Int' bind=Swift.(file).Int))) | |
(brace_stmt | |
(return_stmt | |
(call_expr type='Int' location=Struct.swift:18:18 range=[Struct.swift:18:12 - line:18:27] nothrow | |
(dot_syntax_call_expr type='() -> Int' location=Struct.swift:18:18 range=[Struct.swift:18:12 - line:18:18] nothrow | |
(declref_expr type='(Struct) -> () -> Int' location=Struct.swift:18:18 range=[Struct.swift:18:18 - line:18:18] decl=Struct.(file).Struct.function()@Struct.swift:12:10 specialized=no) | |
(declref_expr type='Struct' location=Struct.swift:18:12 range=[Struct.swift:18:12 - line:18:12] decl=Struct.(file).func decl.value@Struct.swift:17:21 specialized=no)) | |
(tuple_expr type='()' location=Struct.swift:18:26 range=[Struct.swift:18:26 - line:18:27])))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment