Anonymous function expressions ('fun(...) { ... }') and local functions (no closures yet).

This commit is contained in:
Dmitry Petrov
2016-08-26 12:39:27 +03:00
committed by Dmitry Petrov
parent 83c3bdd788
commit ac80195597
8 changed files with 73 additions and 3 deletions
@@ -0,0 +1 @@
val anonymous = fun() { println() }
@@ -0,0 +1,8 @@
FILE /anonymousFunction.kt
PROPERTY public val anonymous: () -> kotlin.Unit getter=null setter=null
EXPRESSION_BODY
BLOCK type=() -> kotlin.Unit operator=ANONYMOUS_FUNCTION
FUN local final fun <no name provided>(): kotlin.Unit
BLOCK_BODY
CALL .println type=kotlin.Unit operator=null
CALLABLE_REFERENCE local final fun <no name provided>(): kotlin.Unit type=() -> kotlin.Unit
+5
View File
@@ -0,0 +1,5 @@
fun outer() {
var x = 0
fun local() { x++ }
local()
}
+15
View File
@@ -0,0 +1,15 @@
FILE /localFunction.kt
FUN public fun outer(): kotlin.Unit
BLOCK_BODY
VAR var x: kotlin.Int
CONST Int type=kotlin.Int value='0'
FUN local final fun local(): kotlin.Unit
BLOCK_BODY
BLOCK type=kotlin.Int operator=POSTFIX_INCR
VAR val tmp0: kotlin.Int
GET_VAR x type=kotlin.Int operator=POSTFIX_INCR
SET_VAR x type=kotlin.Unit operator=POSTFIX_INCR
CALL .inc type=kotlin.Int operator=POSTFIX_INCR
$this: GET_VAR tmp0 type=kotlin.Int operator=null
GET_VAR tmp0 type=kotlin.Int operator=null
CALL .local type=kotlin.Unit operator=null