Implement delegate.ptr and delegate.funcptr as new ast classes instead of using casting and pointer arithmetic

See also #2200