import simple_print:* obj wDestructor { var data: *char var count: int fun construct(dat:*char):*wDestructor { data = dat count = 0 return this } fun copy_construct(other: *wDestructor):void { data = other->data count = other->count + 1 print("copy_construct ") print(data) print(" : ") print(count) println("!") } fun operator=(other: *wDestructor):void { data = other->data count = other->count + 1 print("copy assign ") print(data) print(" : ") print(count) println("!") } fun destruct():void { print("destroyed ") print(data) print(" : ") print(count) println("!") } } fun inFunction():void { { var func_out.construct("i"): wDestructor { var func_in_block_pre_ret.construct("j"): wDestructor return var func_in_block_post_ret.construct("k"): wDestructor } var func_out_post_ret.construct("l"): wDestructor } } fun inOutFunc(thing: wDestructor):wDestructor { println("in inOutFunc") var toRet.construct("outFunc"): wDestructor return toRet } fun main():int { var outside.construct("a"): wDestructor var outside2.construct("a2"): wDestructor { var simple_block.construct("b"): wDestructor } for (var i = 0; i < 5; i++;) { var in_for_block.construct("c"): wDestructor } for (var i = 0; i < 5; i++;) var in_for_no_block.construct("d"): wDestructor for (var i = 0; i < 5; i++;) { var it_for_pre_break.construct("e"): wDestructor break var it_for_post_break.construct("f"): wDestructor } for (var i = 0; i < 5; i++;) { var it_for_pre_continue.construct("g"): wDestructor continue var it_for_post_continue.construct("h"): wDestructor } /*for (var i.construct("in_for_dec"): wDestructor; i.data == "not_equal"; i.data;) println("should not print")*/ var idx = 0 while (idx++ < 5) { var in_while_block.construct("in_while_block"): wDestructor } idx = 0 while (idx++ < 5) var in_while_no_block.construct("in_while_no_block"): wDestructor idx = 0 while (idx++ < 5) { var it_while_pre_break.construct("it_while_pre_break"): wDestructor break var it_while_post_break.construct("it_while_post_break"): wDestructor } idx = 0 while (idx++ < 5) { var it_while_pre_continue.construct("it_while_pre_continue"): wDestructor continue var it_while_post_continue.construct("it_while_post_continue"): wDestructor } inFunction() var inFunc.construct("inFunc"):wDestructor var outFunc = inOutFunc(inFunc) println("time for the end") return 0 }