Interesting, although too C++ for my taste ;)
METHOD Person, Init, age:BYTE
LOCAL isAlive:DWORD
; Internally the METHOD forms a traditional procedure, so anything that you can
; do in a PROC you can do in a method.
; On entry into any method RCX is a pointer to the instance
; and the correct reference type is assumed.
mov [rcx].human, 1 ; Hence this is possible.
mov (Person PTR [rcx]).human, 1 ; Alternative forms of reference.
mov [rcx].Person.human, 1 ; " "
mov isAlive,0
mov al,age
mov [rcx].age,al
.if( age < 100 )
mov isAlive,1
.endif
; Constructor MUST return thisPtr in rax (the implicit self reference
; passed in RCX).
mov rax,thisPtr
ret
ENDMETHOD
Are this just examples how to do it, or does the library provide some of them? Could you use more assembly-style code like this?
and isAlive,0
mov al,age
mov [rcx].age,al
.if age < 100
inc isAlive
.endif