see changelog
This commit is contained in:
@@ -1,3 +1,18 @@
|
||||
19990604-11:50 CET Eddie Runia
|
||||
* source/compiler/harbour.y
|
||||
support for the following syntax added :
|
||||
<object>:<data>[<index>] <assignment> <value>
|
||||
<object>:<method>(<param>)[<index>] <assignment> <value>
|
||||
|
||||
and increment / decrement for <function>(<param>)[<index>],
|
||||
<object>:<data>[<index>] and <object>:<method>(<param>)[<index>]
|
||||
* source/rtl/natmsg/msgdut.c
|
||||
Sunday is the first day ofcourse
|
||||
+ tests/working/objarr.prg
|
||||
tests for object array syntax
|
||||
* tests/working/funcarr.prg
|
||||
tests for function array syntax (inc/dec added)
|
||||
|
||||
19990604-23:15 EDT David G. Holm <dholm@jsd-llc.com>
|
||||
+ include/version.h
|
||||
- New file to specify version info. A future revision will be
|
||||
|
||||
@@ -637,14 +637,14 @@ VarUnary : IDENTIFIER IncDec %prec POST { PushId( $1 ); Duplicate(); $2 ? I
|
||||
| IncDec IDENTIFIER %prec PRE { PushId( $2 ); $1 ? Inc(): Dec(); Duplicate(); PopId( $2 ); }
|
||||
| VarId ArrayIndex IncDec %prec POST { DupPCode( $1 ); GenPCode1( _ARRAYAT ); $3 ? Inc(): Dec(); GenPCode1( _ARRAYPUT ); $3 ? Dec(): Inc(); }
|
||||
| IncDec VarId ArrayIndex %prec PRE { DupPCode( $2 ); GenPCode1( _ARRAYAT ); $1 ? Inc(): Dec(); GenPCode1( _ARRAYPUT ); }
|
||||
| FunArrayCall IncDec %prec POST {}
|
||||
| IncDec FunArrayCall %prec PRE {}
|
||||
| FunArrayCall IncDec %prec POST { GenPCode1( _DUPLTWO ); GenPCode1( _ARRAYAT ); $2 ? Inc(): Dec(); GenPCode1( _ARRAYPUT ); $2 ? Dec(): Inc(); }
|
||||
| IncDec FunArrayCall %prec PRE { GenPCode1( _DUPLTWO ); GenPCode1( _ARRAYAT ); $1 ? Inc(): Dec(); GenPCode1( _ARRAYPUT ); }
|
||||
| ObjectData IncDec %prec POST {}
|
||||
| IncDec ObjectData %prec PRE {}
|
||||
| ObjectData ArrayIndex IncDec %prec POST {}
|
||||
| IncDec ObjectData ArrayIndex %prec PRE {}
|
||||
| ObjectMethod ArrayIndex IncDec %prec POST {}
|
||||
| IncDec ObjectMethod ArrayIndex %prec PRE {}
|
||||
| ObjectData ArrayIndex IncDec %prec POST { GenPCode1( _DUPLTWO ); GenPCode1( _ARRAYAT ); $3 ? Inc(): Dec(); GenPCode1( _ARRAYPUT ); $3 ? Dec(): Inc(); }
|
||||
| IncDec ObjectData ArrayIndex %prec PRE { GenPCode1( _DUPLTWO ); GenPCode1( _ARRAYAT ); $1 ? Inc(): Dec(); GenPCode1( _ARRAYPUT ); }
|
||||
| ObjectMethod ArrayIndex IncDec %prec POST { GenPCode1( _DUPLTWO ); GenPCode1( _ARRAYAT ); $3 ? Inc(): Dec(); GenPCode1( _ARRAYPUT ); $3 ? Dec(): Inc(); }
|
||||
| IncDec ObjectMethod ArrayIndex %prec PRE { GenPCode1( _DUPLTWO ); GenPCode1( _ARRAYAT ); $1 ? Inc(): Dec(); GenPCode1( _ARRAYPUT ); }
|
||||
;
|
||||
|
||||
IncDec : INC { $$ = 1; }
|
||||
@@ -698,19 +698,19 @@ VarAssign : IDENTIFIER INASSIGN Expression { PopId( $1 ); PushId( $1 ); }
|
||||
| ObjectData EXPEQ Expression {}
|
||||
| ObjectData MODEQ Expression {}
|
||||
| ObjectData ArrayIndex INASSIGN Expression { GenPCode1( _ARRAYPUT ); }
|
||||
| ObjectData ArrayIndex PLUSEQ Expression {}
|
||||
| ObjectData ArrayIndex MINUSEQ Expression {}
|
||||
| ObjectData ArrayIndex MULTEQ Expression {}
|
||||
| ObjectData ArrayIndex DIVEQ Expression {}
|
||||
| ObjectData ArrayIndex EXPEQ Expression {}
|
||||
| ObjectData ArrayIndex MODEQ Expression {}
|
||||
| ObjectData ArrayIndex PLUSEQ { GenPCode1( _DUPLTWO ); GenPCode1( _ARRAYAT ); } Expression { GenPCode1( _PLUS ); GenPCode1( _ARRAYPUT ); }
|
||||
| ObjectData ArrayIndex MINUSEQ { GenPCode1( _DUPLTWO ); GenPCode1( _ARRAYAT ); } Expression { GenPCode1( _MINUS ); GenPCode1( _ARRAYPUT ); }
|
||||
| ObjectData ArrayIndex MULTEQ { GenPCode1( _DUPLTWO ); GenPCode1( _ARRAYAT ); } Expression { GenPCode1( _MULT ); GenPCode1( _ARRAYPUT ); }
|
||||
| ObjectData ArrayIndex DIVEQ { GenPCode1( _DUPLTWO ); GenPCode1( _ARRAYAT ); } Expression { GenPCode1( _DIVIDE ); GenPCode1( _ARRAYPUT ); }
|
||||
| ObjectData ArrayIndex EXPEQ { GenPCode1( _DUPLTWO ); GenPCode1( _ARRAYAT ); } Expression { GenPCode1( _POWER ); GenPCode1( _ARRAYPUT ); }
|
||||
| ObjectData ArrayIndex MODEQ { GenPCode1( _DUPLTWO ); GenPCode1( _ARRAYAT ); } Expression { GenPCode1( _MODULUS ); GenPCode1( _ARRAYPUT ); }
|
||||
| ObjectMethod ArrayIndex INASSIGN Expression { GenPCode1( _ARRAYPUT ); }
|
||||
| ObjectMethod ArrayIndex PLUSEQ Expression {}
|
||||
| ObjectMethod ArrayIndex MINUSEQ Expression {}
|
||||
| ObjectMethod ArrayIndex MULTEQ Expression {}
|
||||
| ObjectMethod ArrayIndex DIVEQ Expression {}
|
||||
| ObjectMethod ArrayIndex EXPEQ Expression {}
|
||||
| ObjectMethod ArrayIndex MODEQ Expression {}
|
||||
| ObjectMethod ArrayIndex PLUSEQ { GenPCode1( _DUPLTWO ); GenPCode1( _ARRAYAT ); } Expression { GenPCode1( _PLUS ); GenPCode1( _ARRAYPUT ); }
|
||||
| ObjectMethod ArrayIndex MINUSEQ { GenPCode1( _DUPLTWO ); GenPCode1( _ARRAYAT ); } Expression { GenPCode1( _MINUS ); GenPCode1( _ARRAYPUT ); }
|
||||
| ObjectMethod ArrayIndex MULTEQ { GenPCode1( _DUPLTWO ); GenPCode1( _ARRAYAT ); } Expression { GenPCode1( _MULT ); GenPCode1( _ARRAYPUT ); }
|
||||
| ObjectMethod ArrayIndex DIVEQ { GenPCode1( _DUPLTWO ); GenPCode1( _ARRAYAT ); } Expression { GenPCode1( _DIVIDE ); GenPCode1( _ARRAYPUT ); }
|
||||
| ObjectMethod ArrayIndex EXPEQ { GenPCode1( _DUPLTWO ); GenPCode1( _ARRAYAT ); } Expression { GenPCode1( _POWER ); GenPCode1( _ARRAYPUT ); }
|
||||
| ObjectMethod ArrayIndex MODEQ { GenPCode1( _DUPLTWO ); GenPCode1( _ARRAYAT ); } Expression { GenPCode1( _MODULUS ); GenPCode1( _ARRAYPUT ); }
|
||||
| AliasExp INASSIGN Expression {}
|
||||
;
|
||||
|
||||
|
||||
@@ -8,5 +8,5 @@ char *hb_monthsname[ 12 ] = {
|
||||
"november", "december" };
|
||||
|
||||
char *hb_daysname[ 7 ] = {
|
||||
"maandag", "dinsdag", "woensdag", "donderdag", "vrijdag", "zaterdag",
|
||||
"zondag" };
|
||||
"zondag", "maandag", "dinsdag", "woensdag", "donderdag", "vrijdag", "zaterdag",
|
||||
"zaterdag" };
|
||||
|
||||
@@ -6,34 +6,39 @@ Function Main
|
||||
|
||||
local a
|
||||
|
||||
QOut( aFunc()[1] )
|
||||
QOut( "Direct reference : ", aFunc()[1] )
|
||||
|
||||
a := aFunc()
|
||||
QOut( a[1] )
|
||||
QOut( "Ref via array : ", a[1] )
|
||||
|
||||
aFunc()[1] := "Something different"
|
||||
QOut( aFunc()[1] )
|
||||
QOut( "Assign new text : ", aFunc()[1] )
|
||||
|
||||
aFunc()[1] := 4
|
||||
QOut( aFunc()[1] )
|
||||
QOut( "Assign 4 : ", aFunc()[1] )
|
||||
|
||||
aFunc()[1] += 1
|
||||
QOut( aFunc()[1] )
|
||||
QOut( "Post increment : ", aFunc()[1]++ )
|
||||
QOut( "After : ", aFunc()[1] )
|
||||
QOut( "Pre decrement : ", --aFunc()[1] )
|
||||
QOut( "After : ", aFunc()[1] )
|
||||
|
||||
aFunc()[1] -= 1
|
||||
QOut( aFunc()[1] )
|
||||
aFunc()[1] += 2
|
||||
QOut( "Plus 2 : ", aFunc()[1] )
|
||||
|
||||
aFunc()[1] *= 2
|
||||
QOut( aFunc()[1] )
|
||||
aFunc()[1] -= 3
|
||||
QOut( "Minus 3 : ", aFunc()[1] )
|
||||
|
||||
aFunc()[1] /= 2
|
||||
QOut( aFunc()[1] )
|
||||
aFunc()[1] *= 3
|
||||
QOut( "Times 3 : ", aFunc()[1] )
|
||||
|
||||
aFunc()[1] %= 5
|
||||
QOut( aFunc()[1] )
|
||||
aFunc()[1] /= 1.5
|
||||
QOut( "Divide by 1.5 : ", aFunc()[1] )
|
||||
|
||||
aFunc()[1] %= 4
|
||||
QOut( "Modulus 4 : ", aFunc()[1] )
|
||||
|
||||
aFunc()[1] ^= 3
|
||||
QOut( aFunc()[1] )
|
||||
QOut( "To the power 3 : ", aFunc()[1] )
|
||||
|
||||
QOut( "Global stack" )
|
||||
HBDebug( __aGlobalStack() ) // Please note a is a reference to aArray !
|
||||
|
||||
81
harbour/tests/working/objarr.prg
Normal file
81
harbour/tests/working/objarr.prg
Normal file
@@ -0,0 +1,81 @@
|
||||
//
|
||||
// Object Array syntax test
|
||||
//
|
||||
|
||||
Function Main
|
||||
|
||||
local o := TNumber():New()
|
||||
|
||||
QOut( "Direct reference : ", ToChar( o:x ) )
|
||||
|
||||
o:x[1] := "I am a data"
|
||||
o:Get()[2] := "I am a method"
|
||||
QOut( "Assign text : ", ToChar( o:x ) )
|
||||
|
||||
o:x[1] := 4
|
||||
o:Get()[2] := 4
|
||||
QOut( "Assign 4 : ", ToChar( o:x ) )
|
||||
|
||||
QOut( "Post increment : ", o:x[1]++ , o:Get()[2]++ )
|
||||
QOut( "After : ", o:x[1] , o:Get()[2] )
|
||||
QOut( "Pre decrement : ", --o:x[1] , --o:Get()[2] )
|
||||
QOut( "After : ", o:x[1] , o:Get()[2] )
|
||||
|
||||
o:x[1] += 2
|
||||
o:Get()[2] += 2
|
||||
QOut( "Plus 2 : ", ToChar( o:x ) )
|
||||
|
||||
o:x[1] -= 3
|
||||
o:Get()[2] -= 3
|
||||
QOut( "Minus 3 : ", ToChar( o:x ) )
|
||||
|
||||
o:x[1] *= 3
|
||||
o:Get()[2] *= 3
|
||||
QOut( "Times 3 : ", ToChar( o:x ) )
|
||||
|
||||
o:x[1] /= 1.5
|
||||
o:Get()[2] /= 1.5
|
||||
QOut( "Divide by 1.5 : ", ToChar( o:x ) )
|
||||
|
||||
o:x[1] %= 4
|
||||
o:Get()[2] %= 4
|
||||
QOut( "Modulus 4 : ", ToChar( o:x ) )
|
||||
|
||||
o:x[1] ^= 3
|
||||
o:Get()[2] ^= 3
|
||||
QOut( "To the power 3 : ", ToChar( o:x ) )
|
||||
|
||||
QOut( "Global stack" )
|
||||
HBDebug( __aGlobalStack() ) // Please note a is a reference to aArray !
|
||||
QOut( "Statics")
|
||||
HBDebug( __aStatic() )
|
||||
return NIL
|
||||
|
||||
Function TNumber() // Very simple class
|
||||
|
||||
static oNumber
|
||||
|
||||
if oNumber == NIL
|
||||
oNumber := TClass():New( "TNumber" )
|
||||
|
||||
oNumber:AddData ( "x" )
|
||||
oNumber:AddMethod( "Get", @Get() )
|
||||
oNumber:AddMethod( "New", @New() )
|
||||
oNumber:Create()
|
||||
endif
|
||||
return oNumber:Instance()
|
||||
|
||||
|
||||
static function New()
|
||||
|
||||
local self := QSelf()
|
||||
|
||||
::x := {1,1}
|
||||
return self
|
||||
|
||||
|
||||
static function Get()
|
||||
|
||||
local self := QSelf()
|
||||
|
||||
return ::x
|
||||
Reference in New Issue
Block a user