News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

OO Code with 1.101

Started by DarkWolf, April 12, 2008, 05:45:14 AM

Previous topic - Next topic

DarkWolf

Using v1.101 I get a warning about the use of the THIS keyword.


Compiling "strcls.hla" to "strcls.asm"
Error in file "strcls.hla" at line 24
Misuse of THIS reserved word outside class.
Near: << this >>

Error in file "strcls.hla" at line 24
syntax error, unexpected '.'.
Near: << . >>



procedure create; @nodisplay;
begin create;
push( eax );
if( esi = 0 ) then
mem.alloc( @size( strcls ));
mov( eax, esi );
endif;
mov( &strcls._VMT_, this._pVMT_ );
mov( 0, this.s );
pop( eax );
ret();
end create;


The error points to the line with "this._pVMT_"
All the examples in the HLA reference show it this way.
I am not sure how I am outside of the class.
--
Where's there's smoke, There are mirrors.
Give me Free as in Freedom not Speech or Beer.
Thank You and Welcome to the Internet.

Evenbit

You must pre-pend the classname to any procedure or method declaration that you wish to be associated with a particular class.

procedure strcls.create; @nodisplay;

Nathan.

Evenbit

NB --  This pre-pending doesn't apply to either the 'begin' or 'end' clauses of the declaration.

procedure strcls.create; @nodisplay;
begin create;
push( eax );
if( esi = 0 ) then
mem.alloc( @size( strcls ));
mov( eax, esi );
endif;
mov( &strcls._VMT_, this._pVMT_ );
mov( 0, this.s );
pop( eax );
ret();
end create;


Nathan.

DarkWolf

Nothing like completely missing the obvious.

I have no idea how I missed seeing that.

(is there a smiley for smacking yourself upside the head)
--
Where's there's smoke, There are mirrors.
Give me Free as in Freedom not Speech or Beer.
Thank You and Welcome to the Internet.