test88

Undocumented in source.
immutable
auto test88 = q{--- test88 // function pointer alias i32_funType = i32 function(); alias i32ptr_funType = i32* function(); enum i32_funType funPtrEnum = &i32Fun; enum i32 function() inlinefunPtrEnum = &i32Fun; // i32_funType funPtrGlobal = &i32Fun; // TODO: globals are uninitialized now // i32 function() inlinefunPtrGlobal = &i32Fun; // TODO: globals are uninitialized now i32 i32Fun() { return 42; } i32_funType retFuncPtr() { return &i32Fun; } i32 test() { i32_funType funPtr = retFuncPtr(); // call by ptr (may be optimized to direct call later) i32 function() inlinefunPtr = &i32Fun; // direct call return funPtr() + inlinefunPtr(); } i32 test2() { return funPtrEnum() + inlinefunPtrEnum(); // direct call is performed } i32 sum(i32 a, i32 b) { return a + b; } // pass ptr to function with parameters i32 callFunc(i32 function(i32, i32) func, i32 a, i32 b) { return func(a, b); } i32 test3() { return callFunc(&sum, 10, 40); } i32 callFunc2(i32 a1, i32 a2, i32 a3, i32 a4, i32 a5, i32 a6, i32 function(i32, i32) func) { return func(a1, a2); } // test push function address i32 test4() { return callFunc2(1, 2, 3, 4, 5, 6, &sum); } };

Meta