1
CALLMETHOD
Nunuhara Cabbage edited this page 2019-11-06 21:41:08 -08:00

CALLMETHOD <fno>

Instruction Arguments

int32 fno - The index of the method to call

Stack Arguments

int32 this - The struct to invoke the method on Followed by the arguments to the method.

Description

Method call. Behaves identically to CALLFUNC, except that the current struct page (see PUSHSTRUCTPAGE, SH_STRUCTREF) is set before calling the function.

Example

; method which returns localpage[0] + structpage[0]
FUNC 0x1         ; declare function 1
SH_STRUCTREF 0x0 ; stack: [v_s], where v_s is structpage[0]
SH_LOCALREF 0x0  ; stack: [v_s, v_l], where v_l is localpage[0]
ADD              ; stack: [v_s+v_l]
RETURN           ; return (v_s + v_l) to caller
...
PUSHSTRUCTPAGE   ; stack: [pageno]
PUSHSTRUCTPAGE   ; stack: [pageno, pageno]
PUSH 0x0         ; stack: [pageno, pageno, 0]
PUSH 0x2         ; stack: [pageno, pageno, 0, 2]
ASSIGN           ; stack: [pageno, 2], and structpage[0] = 2
CALLMETHOD 0x1   ; stack: [4]