The MASM Forum

64 bit assembler => UASM Assembler Development => Topic started by: johnsa on April 06, 2017, 06:08:42 AM

Title: HJWasm 2.25 Object Orientation Guide
Post by: johnsa on April 06, 2017, 06:08:42 AM
http://www.terraspace.co.uk/HJWasm Object Oriented Language Extension.pdf (http://www.terraspace.co.uk/HJWasm%20Object%20Oriented%20Language%20Extension.pdf)

Included in the packages now too.
Title: Re: HJWasm 2.25 Object Orientation Guide
Post by: jj2007 on April 06, 2017, 01:34:06 PM
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
Title: Re: HJWasm 2.25 Object Orientation Guide
Post by: johnsa on April 06, 2017, 05:55:16 PM
Hey,

That was just an example.

Inside a method you can code it however you like :) It's really just a PROC behind the scenes with this sort of structure :

MyClass_MyMethod PROC FRAME thisPtr:QWORD, <args>
asssume rcx:PTR MyClass
.
.

So you can do whatever you want :) follow the rules, break the rules.. make up new rules lol
Title: Re: HJWasm 2.25 Object Orientation Guide
Post by: mabdelouahab on April 07, 2017, 09:13:18 AM
How I can use it?
... Error A2260: Missing .ENDPROLOG: _Person_Release  ENDCLASS(11)[....
Title: Re: HJWasm 2.25 Object Orientation Guide
Post by: johnsa on April 07, 2017, 07:47:59 PM
There was a small bug in the $DELETE implementation which I've fixed. The new packages are up on the site and Git, dated 7th April.
The packages now include a new sample oo1.asm which demonstrates a few of the new features and using the OO layer.
Title: Re: HJWasm 2.25 Object Orientation Guide
Post by: mabdelouahab on April 07, 2017, 09:33:23 PM
Thank you johnsa