codegen: patch method calls on-demand via traps