[M3devel] load and store should take TypeUID parameters

Jay K jay.krell at cornell.edu
Tue Mar 12 06:31:13 CET 2013


load and store should take TypeUID parameters



There are multiple reasons for this.



Given:
TYPE Color = {Red,Blue};
PROCEDURE P1() = VAR v1 := Color.Red; BEGIN END P1;



I would like to generate:


preamble in all files:
typedef unsigned char UINT8;
typedef unsigned short UINT16;
typedef unsigned int UINT32;
typedef unsigned long long UINT64;


(This is not quite right.)


#if __GNUC__ /* >= ? */
#define M3_ENUM_SIZE
#define M3_ENUM_MODE8 __attribute__((__mode__(__QI__)))
#define M3_ENUM_MODE16 __attribute__((__mode__(__HI__)))
#define M3_ENUM_MODE32 __attribute__((__mode__(__SI__)))
#define M3_ENUM_MODE64 __attribute__((__mode__(__DI__)))
#else
#define M3_ENUM_MODE8 /* nothing */
#define M3_ENUM_MODE16 /* nothing */
#define M3_ENUM_MODE32 /* nothing */
#define M3_ENUM_MODE64 /* nothing */
#endif
#if _MSC_VER >= 1400 && defined(__cplusplus)
#define M3_ENUM_SIZE
#define M3_ENUM_BASE8  : UINT8
#define M3_ENUM_BASE16 : UINT16
#define M3_ENUM_BASE32 : UINT32
#define M3_ENUM_BASE64 : UINT64
#else
#define M3_ENUM_BASE8  /* nothing */
#define M3_ENUM_BASE16 /* nothing */
#define M3_ENUM_BASE32 /* nothing */
#define M3_ENUM_BASE64 /* nothing */
#endif


and then:


given TypeUID = 123


// declare enum
#if M3_ENUM_SIZE
M3_ENUM_MODE8 enum M123 M3_ENUM_MODE8 { M123_Red, M123_Blue, M123_Green };
#else
typedef UINT8 M123;
#define M123_Red ((M123)0)
#define M123_Blue ((M123)1)
#define M123_Green ((M123)2)
#endif


// declare typename
typedef M123 Color;


// smart compiler recognizes left and right are enums perhaps and therefore:
#define Color_Red M123_Red
#define Color_Blue M123_Blue
#define Color_Green M123_Green



Color v1 = M123_Red;
or perhaps:
Color v1 = Color_Red;


or perhaps merely:
Color v1 = (Color)0;


and really, ideally NOT
Color v1;
*(UINT8*)&v1 = (UINT8)0;



The readability of the right hand side isn't the most critical.
What is more critical is the readability of v1 in a debugger.



The last form is what we are stuck with.



Similarly, given:


PROCEDURE P2(VAR a: INTEGER);
PROCEDURE P3(VAR a: INTEGER) = BEGIN P2(b); END P3;



I want:
  void P2(INTEGER* a); 
  void P3(INTEGER* a) { P2(a); }  



no casts.



Today, I make all pointers "ADDRESS" which
is void* or char*. I don't remember all the reasons why.


I guess I should just get over the cast happiness and ugly C implied by using C as a backend.
But I do want things to look right in a debugger. I'll iterate more..later...


 - Jay
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20130312/53006d1a/attachment-0001.html>


More information about the M3devel mailing list