On Wednesday 13 November 2013 12:37:15 Michael Schnell wrote:
> On 11/12/2013 10:19 AM, Martin Schreiber wrote:
> > If it's really bit packed you might get numerical values that require
> > rather complex handling by the compiler:
> >
> > record tr
> >     x1: int64: 2;
> > Invalid because int64 is defined as -800000000000..7fffffffffffffff which
> > does not fit in 2 bits.
>
> That is not the idea. But:
>
> r.x1= 0  => bits = 0, 0
> r.x1= 1  => bits = 0, 1
> r.x1= -1  => bits = 1,1
> r.x1= -2  => bits = 1, 0
>
> other values are truncated accordingly (see below)
>
>
>
> On the contrary the base type needs to provide at least as many bits as
> given after the ":" (otherwise you could never define fields with less
> than 8 bits).
>
> Do you intend to provide a syntax to define bit fields with more bits
> than any integer base type. This in fact would be intersting but would
> need you to provide an arbitrary precision integer arithmetic in the
> RTL. Doable but an "interesting" Task :-) .
>
MSElang definitions of ordinal types is
"
'type'
 TYPENAME '=' (BOOLEANRANGEDEF | CARDINALRANGEDEF | INTEGERRANGEDEF | 
CHARRANGEDEF | FLOATRANGEDEF) [: BITSIZE] ';'
BOOLEANRANGEDEF = MAXCARD  //MAXCARD must be 2^n-1, max 32 bit
CARDINALRANGEDEF = MINCARD 'to' MAXCARD //max 64 bit
INTEGERRANGEDEF = '-'MINCARD 'to' MAXCARD //max 64 bit
CHARRANGEDEF = '#'MINCARD 'to' MAXCARD //max 32 bit
FLOATRANGEDEF = MINFLOAT 'to' MAXFLOAT //32 or 64 bit
"
Without BITSIZE the size will be extended to the next byte boundary, BITSIZE 
must be >= the needed bits to hold the value range.

Examples:
"
type
 b8ty   = $ff;                //a 8 bit boolean
 b16ty  = $ffff;              //a 16 bit boolean
 i16ty  = -$8000 to $7fff;    //a 16 bit integer
 s8ty   = 14 to 15;           //a 8 bit subrange cardinal
 s4ty   = 14 to 15: 4;        //a 4 bit subrange cardinal
 s1ty   = 14 to 15: 1;        //a 1 bit subrange cardinal 0 -> 14, 1 -> 15
 c16ty  = #$0000 to #$ffff;   //a 16 bit character
 f32ty  = -3.4e38 to 3.4e38;  //a single precision float
 f64ty  = -1.7e308 to 1.7e308 //a double precision float
 sf64ty = 0.0 to 10.0: 64;    //a double precision subrange float
"
'integer','cardinal','int8',int16... are *not* part of MSElang!

int64 is defined in systypes.mla:
"
int64 = -$8000000000000000 to $7fffffffffffffff: 64;
"
therefore "int64: 2;" is invalid, it must be written as "-2 to 1" or 
"-2 to 1: 2". Also possible is "100 to 103: 2". :-)

Please see the Wiki:
https://gitorious.org/mseide-msegui/pages/Mselang

Martin

------------------------------------------------------------------------------
DreamFactory - Open Source REST & JSON Services for HTML5 & Native Apps
OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access
Free app hosting. Or install the open source package on any LAMP server.
Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!
http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.clktrk
_______________________________________________
mseide-msegui-talk mailing list
mseide-msegui-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk

Reply via email to