# undef NULL
# define NULL 0
#endif
-typedef unsigned int nameKey_Name;
+#define _decl_C
-# define nameKey_NulName 0
-typedef struct symbolKey__T8_r symbolKey__T8;
-
-typedef symbolKey__T8 *symbolKey_symbolTree;
-
-typedef struct mcPretty_writeProc_p mcPretty_writeProc;
-
-typedef struct mcPretty_writeLnProc_p mcPretty_writeLnProc;
-
-typedef unsigned int FIO_File;
-
-extern FIO_File FIO_StdOut;
-# define symbolKey_NulKey NULL
-typedef struct symbolKey_performOperation_p symbolKey_performOperation;
-
-# define ASCII_tab ASCII_ht
-# define ASCII_ht (char) 011
-# define ASCII_lf ASCII_nl
-# define ASCII_nl (char) 012
-typedef struct Indexing_IndexProcedure_p Indexing_IndexProcedure;
+#include "Gdecl.h"
+# include "GASCII.h"
+# include "GsymbolKey.h"
+# include "GmcDebug.h"
+# include "GStorage.h"
+# include "GnameKey.h"
+# include "GSFIO.h"
+# include "GFIO.h"
+# include "GDynamicStrings.h"
+# include "GStringConvert.h"
+# include "GmcOptions.h"
+# include "GFormatStrings.h"
+# include "Glibc.h"
+# include "GmcMetaError.h"
+# include "GmcError.h"
+# include "GmcLexBuf.h"
+# include "GmcComment.h"
+# include "GStrLib.h"
+# include "GmcPretty.h"
+# include "GIndexing.h"
+# include "Galists.h"
+# include "Gwlists.h"
+# include "Gkeyc.h"
+# include "GmcStream.h"
+# include "GM2RTS.h"
typedef struct decl_isNodeF_p decl_isNodeF;
-# define SYSTEM_BITSPERBYTE 8
-# define SYSTEM_BYTESPERWORD 4
-typedef struct M2RTS_ArgCVEnvP_p M2RTS_ArgCVEnvP;
-
-typedef struct symbolKey_isSymbol_p symbolKey_isSymbol;
-
-# define ASCII_nul (char) 000
-# define ASCII_soh (char) 001
-# define ASCII_stx (char) 002
-# define ASCII_etx (char) 003
-# define ASCII_eot (char) 004
-# define ASCII_enq (char) 005
-# define ASCII_ack (char) 006
-# define ASCII_bel (char) 007
-# define ASCII_bs (char) 010
-# define ASCII_vt (char) 013
-# define ASCII_np (char) 014
-# define ASCII_cr (char) 015
-# define ASCII_so (char) 016
-# define ASCII_si (char) 017
-# define ASCII_dle (char) 020
-# define ASCII_dc1 (char) 021
-# define ASCII_dc2 (char) 022
-# define ASCII_dc3 (char) 023
-# define ASCII_dc4 (char) 024
-# define ASCII_nak (char) 025
-# define ASCII_syn (char) 026
-# define ASCII_etb (char) 027
-# define ASCII_can (char) 030
-# define ASCII_em (char) 031
-# define ASCII_sub (char) 032
-# define ASCII_esc (char) 033
-# define ASCII_fs (char) 034
-# define ASCII_gs (char) 035
-# define ASCII_rs (char) 036
-# define ASCII_us (char) 037
-# define ASCII_sp (char) 040
-# define ASCII_ff ASCII_np
-# define ASCII_eof ASCII_eot
-# define ASCII_del (char) 0177
-# define ASCII_EOL ASCII_nl
-extern FIO_File FIO_StdErr;
-extern FIO_File FIO_StdIn;
-typedef long int libc_time_t;
-
-typedef struct libc_tm_r libc_tm;
-
-typedef libc_tm *libc_ptrToTM;
-
-typedef struct libc_timeb_r libc_timeb;
-
-typedef struct libc_exitP_p libc_exitP;
-
-typedef struct mcError__T11_r mcError__T11;
-
-typedef mcError__T11 *mcError_error;
-
-extern int mcLexBuf_currentinteger;
-extern unsigned int mcLexBuf_currentcolumn;
-extern void * mcLexBuf_currentstring;
-typedef struct alists_performOperation_p alists_performOperation;
-
-typedef struct wlists_performOperation_p wlists_performOperation;
-
-typedef struct StdIO_ProcWrite_p StdIO_ProcWrite;
-
-typedef struct StdIO_ProcRead_p StdIO_ProcRead;
-
# define indentation 3
# define indentationC 2
# define debugScopes false
# define enableDefForCStrings false
# define enableMemsetOnAllocation true
# define forceQualified true
+# define debugOpaque false
typedef struct decl_nodeRec_r decl_nodeRec;
+typedef struct decl_opaqueCastState_r decl_opaqueCastState;
+
+typedef struct decl_opaquecastT_r decl_opaquecastT;
+
typedef struct decl_intrinsicT_r decl_intrinsicT;
typedef struct decl_fixupInfo_r decl_fixupInfo;
typedef struct decl_cnameT_r decl_cnameT;
-typedef struct decl__T15_r decl__T15;
+typedef struct decl__T1_r decl__T1;
-typedef decl__T15 *decl_group;
+typedef decl__T1 *decl_group;
-# define MaxBuf 127
-# define maxNoOfElements 5
-typedef enum {decl_explist, decl_funccall, decl_exit, decl_return, decl_stmtseq, decl_comment, decl_halt, decl_new, decl_dispose, decl_inc, decl_dec, decl_incl, decl_excl, decl_length, decl_nil, decl_true, decl_false, decl_address, decl_loc, decl_byte, decl_word, decl_csizet, decl_cssizet, decl_char, decl_cardinal, decl_longcard, decl_shortcard, decl_integer, decl_longint, decl_shortint, decl_real, decl_longreal, decl_shortreal, decl_bitset, decl_boolean, decl_proc, decl_ztype, decl_rtype, decl_complex, decl_longcomplex, decl_shortcomplex, decl_type, decl_record, decl_varient, decl_var, decl_enumeration, decl_subrange, decl_array, decl_subscript, decl_string, decl_const, decl_literal, decl_varparam, decl_param, decl_varargs, decl_optarg, decl_pointer, decl_recordfield, decl_varientfield, decl_enumerationfield, decl_set, decl_proctype, decl_procedure, decl_def, decl_imp, decl_module, decl_loop, decl_while, decl_for, decl_repeat, decl_case, decl_caselabellist, decl_caselist, decl_range, decl_assignment, decl_if, decl_elsif, decl_constexp, decl_neg, decl_cast, decl_val, decl_plus, decl_sub, decl_div, decl_mod, decl_mult, decl_divide, decl_in, decl_adr, decl_size, decl_tsize, decl_ord, decl_float, decl_trunc, decl_chr, decl_abs, decl_cap, decl_high, decl_throw, decl_unreachable, decl_cmplx, decl_re, decl_im, decl_min, decl_max, decl_componentref, decl_pointerref, decl_arrayref, decl_deref, decl_equal, decl_notequal, decl_less, decl_greater, decl_greequal, decl_lessequal, decl_lsl, decl_lsr, decl_lor, decl_land, decl_lnot, decl_lxor, decl_and, decl_or, decl_not, decl_identlist, decl_vardecl, decl_setvalue} decl_nodeT;
+typedef enum {decl_explist, decl_funccall, decl_exit, decl_return, decl_stmtseq, decl_comment, decl_halt, decl_new, decl_dispose, decl_inc, decl_dec, decl_incl, decl_excl, decl_length, decl_nil, decl_true, decl_false, decl_address, decl_loc, decl_byte, decl_word, decl_csizet, decl_cssizet, decl_char, decl_cardinal, decl_longcard, decl_shortcard, decl_integer, decl_longint, decl_shortint, decl_real, decl_longreal, decl_shortreal, decl_bitset, decl_boolean, decl_proc, decl_ztype, decl_rtype, decl_complex, decl_longcomplex, decl_shortcomplex, decl_type, decl_record, decl_varient, decl_var, decl_enumeration, decl_subrange, decl_array, decl_subscript, decl_string, decl_const, decl_literal, decl_varparam, decl_param, decl_varargs, decl_optarg, decl_pointer, decl_recordfield, decl_varientfield, decl_enumerationfield, decl_set, decl_proctype, decl_procedure, decl_def, decl_imp, decl_module, decl_loop, decl_while, decl_for, decl_repeat, decl_case, decl_caselabellist, decl_caselist, decl_range, decl_assignment, decl_if, decl_elsif, decl_constexp, decl_neg, decl_cast, decl_val, decl_plus, decl_sub, decl_div, decl_mod, decl_mult, decl_divide, decl_in, decl_adr, decl_size, decl_tsize, decl_ord, decl_float, decl_trunc, decl_chr, decl_abs, decl_cap, decl_high, decl_throw, decl_unreachable, decl_cmplx, decl_re, decl_im, decl_min, decl_max, decl_componentref, decl_pointerref, decl_arrayref, decl_deref, decl_equal, decl_notequal, decl_less, decl_greater, decl_greequal, decl_lessequal, decl_lsl, decl_lsr, decl_lor, decl_land, decl_lnot, decl_lxor, decl_and, decl_or, decl_not, decl_identlist, decl_vardecl, decl_setvalue, decl_opaquecast} decl_nodeT;
-# define MaxnoOfelements 5
-typedef enum {mcReserved_eoftok, mcReserved_plustok, mcReserved_minustok, mcReserved_timestok, mcReserved_dividetok, mcReserved_becomestok, mcReserved_ambersandtok, mcReserved_periodtok, mcReserved_commatok, mcReserved_semicolontok, mcReserved_lparatok, mcReserved_rparatok, mcReserved_lsbratok, mcReserved_rsbratok, mcReserved_lcbratok, mcReserved_rcbratok, mcReserved_uparrowtok, mcReserved_singlequotetok, mcReserved_equaltok, mcReserved_hashtok, mcReserved_lesstok, mcReserved_greatertok, mcReserved_lessgreatertok, mcReserved_lessequaltok, mcReserved_greaterequaltok, mcReserved_ldirectivetok, mcReserved_rdirectivetok, mcReserved_periodperiodtok, mcReserved_colontok, mcReserved_doublequotestok, mcReserved_bartok, mcReserved_andtok, mcReserved_arraytok, mcReserved_begintok, mcReserved_bytok, mcReserved_casetok, mcReserved_consttok, mcReserved_definitiontok, mcReserved_divtok, mcReserved_dotok, mcReserved_elsetok, mcReserved_elsiftok, mcReserved_endtok, mcReserved_excepttok, mcReserved_exittok, mcReserved_exporttok, mcReserved_finallytok, mcReserved_fortok, mcReserved_fromtok, mcReserved_iftok, mcReserved_implementationtok, mcReserved_importtok, mcReserved_intok, mcReserved_looptok, mcReserved_modtok, mcReserved_moduletok, mcReserved_nottok, mcReserved_oftok, mcReserved_ortok, mcReserved_packedsettok, mcReserved_pointertok, mcReserved_proceduretok, mcReserved_qualifiedtok, mcReserved_unqualifiedtok, mcReserved_recordtok, mcReserved_remtok, mcReserved_repeattok, mcReserved_retrytok, mcReserved_returntok, mcReserved_settok, mcReserved_thentok, mcReserved_totok, mcReserved_typetok, mcReserved_untiltok, mcReserved_vartok, mcReserved_whiletok, mcReserved_withtok, mcReserved_asmtok, mcReserved_volatiletok, mcReserved_periodperiodperiodtok, mcReserved_datetok, mcReserved_linetok, mcReserved_filetok, mcReserved_attributetok, mcReserved_builtintok, mcReserved_inlinetok, mcReserved_integertok, mcReserved_identtok, mcReserved_realtok, mcReserved_stringtok, mcReserved_commenttok} mcReserved_toktype;
-
-extern mcReserved_toktype mcLexBuf_currenttoken;
typedef enum {decl_ansiC, decl_ansiCP, decl_pim4} decl_language;
typedef enum {decl_completed, decl_blocked, decl_partial, decl_recursive} decl_dependentState;
typedef enum {decl_text, decl_punct, decl_space} decl_outputStates;
-typedef decl_nodeRec *decl_node;
-
-typedef struct Indexing__T5_r Indexing__T5;
-
-typedef struct mcComment__T6_r mcComment__T6;
-
-typedef enum {mcComment_unknown, mcComment_procedureHeading, mcComment_inBody, mcComment_afterStatement} mcComment_commentType;
-
-typedef struct DynamicStrings_stringRecord_r DynamicStrings_stringRecord;
-
-typedef struct DynamicStrings_Contents_r DynamicStrings_Contents;
-
-typedef struct wlists__T9_r wlists__T9;
-
-typedef struct alists__T13_r alists__T13;
-
-typedef struct mcPretty__T12_r mcPretty__T12;
-
-typedef struct wlists__T10_a wlists__T10;
-
-typedef Indexing__T5 *Indexing_Index;
-
-typedef struct DynamicStrings__T7_a DynamicStrings__T7;
-
-typedef struct alists__T14_a alists__T14;
-
-typedef mcComment__T6 *mcComment_commentDesc;
-
-extern mcComment_commentDesc mcLexBuf_currentcomment;
-extern mcComment_commentDesc mcLexBuf_lastcomment;
-typedef DynamicStrings_stringRecord *DynamicStrings_String;
-
-typedef wlists__T9 *wlists_wlist;
-
-typedef alists__T13 *alists_alist;
-
-typedef mcPretty__T12 *mcPretty_pretty;
-
-struct symbolKey__T8_r {
- nameKey_Name name;
- void *key;
- symbolKey_symbolTree left;
- symbolKey_symbolTree right;
- };
-
-typedef void (*mcPretty_writeProc_t) (char);
-struct mcPretty_writeProc_p { mcPretty_writeProc_t proc; };
-
-typedef void (*mcPretty_writeLnProc_t) (void);
-struct mcPretty_writeLnProc_p { mcPretty_writeLnProc_t proc; };
-
-typedef void (*symbolKey_performOperation_t) (void *);
-struct symbolKey_performOperation_p { symbolKey_performOperation_t proc; };
-
-typedef void (*Indexing_IndexProcedure_t) (void *);
-struct Indexing_IndexProcedure_p { Indexing_IndexProcedure_t proc; };
-
-typedef bool (*decl_isNodeF_t) (decl_node);
-struct decl_isNodeF_p { decl_isNodeF_t proc; };
-
-typedef void (*M2RTS_ArgCVEnvP_t) (int, void *, void *);
-struct M2RTS_ArgCVEnvP_p { M2RTS_ArgCVEnvP_t proc; };
-
-typedef bool (*symbolKey_isSymbol_t) (void *);
-struct symbolKey_isSymbol_p { symbolKey_isSymbol_t proc; };
-
-struct libc_tm_r {
- int tm_sec;
- int tm_min;
- int tm_hour;
- int tm_mday;
- int tm_mon;
- int tm_year;
- int tm_wday;
- int tm_yday;
- int tm_isdst;
- long int tm_gmtoff;
- void *tm_zone;
- };
-
-struct libc_timeb_r {
- libc_time_t time_;
- short unsigned int millitm;
- short unsigned int timezone;
- short unsigned int dstflag;
- };
-
-typedef int (*libc_exitP_t) (void);
-typedef libc_exitP_t libc_exitP_C;
-
-struct libc_exitP_p { libc_exitP_t proc; };
-
-struct mcError__T11_r {
- mcError_error parent;
- mcError_error child;
- mcError_error next;
- bool fatal;
- DynamicStrings_String s;
- unsigned int token;
- };
-
-typedef void (*alists_performOperation_t) (void *);
-struct alists_performOperation_p { alists_performOperation_t proc; };
-
-typedef void (*wlists_performOperation_t) (unsigned int);
-struct wlists_performOperation_p { wlists_performOperation_t proc; };
-
-typedef void (*StdIO_ProcWrite_t) (char);
-struct StdIO_ProcWrite_p { StdIO_ProcWrite_t proc; };
+typedef decl_nodeRec *decl_node__opaque;
-typedef void (*StdIO_ProcRead_t) (char *);
-struct StdIO_ProcRead_p { StdIO_ProcRead_t proc; };
+struct decl_opaqueCastState_r {
+ bool opaque;
+ bool voidStar;
+ };
struct decl_fixupInfo_r {
unsigned int count;
};
struct decl_setvalueT_r {
- decl_node type;
+ decl_node__opaque type;
Indexing_Index values;
};
};
struct decl_exitT_r {
- decl_node loop;
+ decl_node__opaque loop;
};
struct decl_vardeclT_r {
wlists_wlist names;
- decl_node type;
- decl_node scope;
+ decl_node__opaque type;
+ decl_node__opaque scope;
};
struct decl_typeT_r {
nameKey_Name name;
- decl_node type;
- decl_node scope;
+ decl_node__opaque type;
+ decl_node__opaque scope;
+ bool isOpaque;
bool isHidden;
bool isInternal;
};
struct decl_recordT_r {
symbolKey_symbolTree localSymbols;
Indexing_Index listOfSons;
- decl_node scope;
+ decl_node__opaque scope;
};
struct decl_varientT_r {
Indexing_Index listOfSons;
- decl_node varient;
- decl_node tag;
- decl_node scope;
+ decl_node__opaque varient;
+ decl_node__opaque tag;
+ decl_node__opaque scope;
};
struct decl_enumerationT_r {
unsigned int noOfElements;
symbolKey_symbolTree localSymbols;
Indexing_Index listOfSons;
- decl_node low;
- decl_node high;
- decl_node scope;
+ decl_node__opaque low;
+ decl_node__opaque high;
+ decl_node__opaque scope;
};
struct decl_subrangeT_r {
- decl_node low;
- decl_node high;
- decl_node type;
- decl_node scope;
+ decl_node__opaque low;
+ decl_node__opaque high;
+ decl_node__opaque type;
+ decl_node__opaque scope;
};
struct decl_subscriptT_r {
- decl_node type;
- decl_node expr;
+ decl_node__opaque type;
+ decl_node__opaque expr;
};
-struct decl_arrayT_r {
- decl_node subr;
- decl_node type;
- decl_node scope;
- bool isUnbounded;
- };
-
struct decl_stringT_r {
nameKey_Name name;
unsigned int length;
struct decl_literalT_r {
nameKey_Name name;
- decl_node type;
+ decl_node__opaque type;
};
struct decl_constT_r {
nameKey_Name name;
- decl_node type;
- decl_node value;
- decl_node scope;
- };
-
-struct decl_varparamT_r {
- decl_node namelist;
- decl_node type;
- decl_node scope;
- bool isUnbounded;
- bool isForC;
- bool isUsed;
- };
-
-struct decl_paramT_r {
- decl_node namelist;
- decl_node type;
- decl_node scope;
- bool isUnbounded;
- bool isForC;
- bool isUsed;
+ decl_node__opaque type;
+ decl_node__opaque value;
+ decl_node__opaque scope;
};
struct decl_varargsT_r {
- decl_node scope;
+ decl_node__opaque scope;
};
struct decl_optargT_r {
- decl_node namelist;
- decl_node type;
- decl_node scope;
- decl_node init;
+ decl_node__opaque namelist;
+ decl_node__opaque type;
+ decl_node__opaque scope;
+ decl_node__opaque init;
};
-struct decl_pointerT_r {
- decl_node type;
- decl_node scope;
- };
-
struct decl_varientfieldT_r {
nameKey_Name name;
- decl_node parent;
- decl_node varient;
+ decl_node__opaque parent;
+ decl_node__opaque varient;
bool simple;
Indexing_Index listOfSons;
- decl_node scope;
+ decl_node__opaque scope;
};
struct decl_setT_r {
- decl_node type;
- decl_node scope;
+ decl_node__opaque type;
+ decl_node__opaque scope;
};
-struct decl_componentrefT_r {
- decl_node rec;
- decl_node field;
- decl_node resultType;
- };
-
-struct decl_pointerrefT_r {
- decl_node ptr;
- decl_node field;
- decl_node resultType;
- };
-
-struct decl_arrayrefT_r {
- decl_node array;
- decl_node index;
- decl_node resultType;
- };
-
struct decl_commentPair_r {
- decl_node after;
- decl_node body;
+ decl_node__opaque after;
+ decl_node__opaque body;
};
struct decl_loopT_r {
- decl_node statements;
+ decl_node__opaque statements;
unsigned int labelno;
};
struct decl_caseT_r {
- decl_node expression;
+ decl_node__opaque expression;
Indexing_Index caseLabelList;
- decl_node else_;
+ decl_node__opaque else_;
};
struct decl_caselabellistT_r {
- decl_node caseList;
- decl_node statements;
+ decl_node__opaque caseList;
+ decl_node__opaque statements;
};
struct decl_caselistT_r {
};
struct decl_rangeT_r {
- decl_node lo;
- decl_node hi;
+ decl_node__opaque lo;
+ decl_node__opaque hi;
};
struct decl_forT_r {
- decl_node des;
- decl_node start;
- decl_node end;
- decl_node increment;
- decl_node statements;
+ decl_node__opaque des;
+ decl_node__opaque start;
+ decl_node__opaque end;
+ decl_node__opaque increment;
+ decl_node__opaque statements;
};
struct decl_statementT_r {
Indexing_Index variables;
};
-struct decl_proctypeT_r {
- Indexing_Index parameters;
- bool returnopt;
- bool vararg;
- decl_node optarg_;
- decl_node scope;
- decl_node returnType;
- };
-
struct decl_binaryT_r {
- decl_node left;
- decl_node right;
- decl_node resultType;
+ decl_node__opaque left;
+ decl_node__opaque right;
+ decl_node__opaque resultType;
};
struct decl_unaryT_r {
- decl_node arg;
- decl_node resultType;
+ decl_node__opaque arg;
+ decl_node__opaque resultType;
};
struct decl_where_r {
bool init;
};
-struct decl__T15_r {
- alists_alist todoQ;
- alists_alist partialQ;
- alists_alist doneQ;
- decl_group next;
- };
-
-struct Indexing__T5_r {
- void *ArrayStart;
- unsigned int ArraySize;
- unsigned int Used;
- unsigned int Low;
- unsigned int High;
- bool Debug;
- unsigned int Map;
- };
+struct decl__T1_r {
+ alists_alist todoQ;
+ alists_alist partialQ;
+ alists_alist doneQ;
+ decl_group next;
+ };
-struct mcComment__T6_r {
- mcComment_commentType type;
- DynamicStrings_String content;
- nameKey_Name procName;
- bool used;
- };
+struct decl_opaquecastT_r {
+ decl_node__opaque exp;
+ decl_opaqueCastState opaqueState;
+ };
-struct wlists__T10_a { unsigned int array[maxNoOfElements-1+1]; };
-struct DynamicStrings__T7_a { char array[(MaxBuf-1)+1]; };
-struct alists__T14_a { void * array[MaxnoOfelements-1+1]; };
struct decl_intrinsicT_r {
- decl_node args;
+ decl_node__opaque args;
unsigned int noArgs;
- decl_node type;
+ decl_node__opaque type;
decl_commentPair intrinsicComment;
bool postUnreachable;
};
struct decl_funccallT_r {
- decl_node function;
- decl_node args;
- decl_node type;
+ decl_node__opaque function;
+ decl_node__opaque args;
+ decl_node__opaque type;
decl_commentPair funccallComment;
+ decl_opaqueCastState opaqueState;
};
struct decl_returnT_r {
- decl_node exp;
- decl_node scope;
+ decl_node__opaque exp;
+ decl_node__opaque scope;
decl_commentPair returnComment;
};
struct decl_varT_r {
nameKey_Name name;
- decl_node type;
- decl_node decl;
- decl_node scope;
+ decl_node__opaque type;
+ decl_node__opaque decl;
+ decl_node__opaque scope;
bool isInitialised;
bool isParameter;
bool isVarParameter;
bool isUsed;
decl_cnameT cname;
+ decl_opaqueCastState opaqueState;
};
+struct decl_arrayT_r {
+ decl_node__opaque subr;
+ decl_node__opaque type;
+ decl_node__opaque scope;
+ bool isUnbounded;
+ decl_opaqueCastState opaqueState;
+ };
+
+struct decl_varparamT_r {
+ decl_node__opaque namelist;
+ decl_node__opaque type;
+ decl_node__opaque scope;
+ bool isUnbounded;
+ bool isForC;
+ bool isUsed;
+ decl_opaqueCastState opaqueState;
+ };
+
+struct decl_paramT_r {
+ decl_node__opaque namelist;
+ decl_node__opaque type;
+ decl_node__opaque scope;
+ bool isUnbounded;
+ bool isForC;
+ bool isUsed;
+ decl_opaqueCastState opaqueState;
+ };
+
+struct decl_pointerT_r {
+ decl_node__opaque type;
+ decl_node__opaque scope;
+ decl_opaqueCastState opaqueState;
+ };
+
struct decl_recordfieldT_r {
nameKey_Name name;
- decl_node type;
+ decl_node__opaque type;
bool tag;
- decl_node parent;
- decl_node varient;
- decl_node scope;
+ decl_node__opaque parent;
+ decl_node__opaque varient;
+ decl_node__opaque scope;
decl_cnameT cname;
+ decl_opaqueCastState opaqueState;
};
struct decl_enumerationfieldT_r {
nameKey_Name name;
- decl_node type;
- decl_node scope;
+ decl_node__opaque type;
+ decl_node__opaque scope;
unsigned int value;
decl_cnameT cname;
};
+struct decl_componentrefT_r {
+ decl_node__opaque rec;
+ decl_node__opaque field;
+ decl_node__opaque resultType;
+ decl_opaqueCastState opaqueState;
+ };
+
+struct decl_pointerrefT_r {
+ decl_node__opaque ptr;
+ decl_node__opaque field;
+ decl_node__opaque resultType;
+ decl_opaqueCastState opaqueState;
+ };
+
+struct decl_arrayrefT_r {
+ decl_node__opaque array;
+ decl_node__opaque index;
+ decl_node__opaque resultType;
+ decl_opaqueCastState opaqueState;
+ };
+
struct decl_assignmentT_r {
- decl_node des;
- decl_node expr;
+ decl_node__opaque des;
+ decl_node__opaque expr;
decl_commentPair assignComment;
};
struct decl_ifT_r {
- decl_node expr;
- decl_node elsif;
- decl_node then;
- decl_node else_;
+ decl_node__opaque expr;
+ decl_node__opaque elsif;
+ decl_node__opaque then;
+ decl_node__opaque else_;
decl_commentPair ifComment;
decl_commentPair elseComment;
decl_commentPair endComment;
};
struct decl_elsifT_r {
- decl_node expr;
- decl_node elsif;
- decl_node then;
- decl_node else_;
+ decl_node__opaque expr;
+ decl_node__opaque elsif;
+ decl_node__opaque then;
+ decl_node__opaque else_;
decl_commentPair elseComment;
};
struct decl_whileT_r {
- decl_node expr;
- decl_node statements;
+ decl_node__opaque expr;
+ decl_node__opaque statements;
decl_commentPair doComment;
decl_commentPair endComment;
};
struct decl_repeatT_r {
- decl_node expr;
- decl_node statements;
+ decl_node__opaque expr;
+ decl_node__opaque statements;
decl_commentPair repeatComment;
decl_commentPair untilComment;
};
struct decl_procedureT_r {
nameKey_Name name;
decl_scopeT decls;
- decl_node scope;
+ decl_node__opaque scope;
Indexing_Index parameters;
bool isForC;
bool built;
bool noreturnused;
bool noreturn;
unsigned int paramcount;
- decl_node optarg_;
- decl_node returnType;
- decl_node beginStatements;
+ decl_node__opaque optarg_;
+ decl_node__opaque returnType;
+ decl_node__opaque beginStatements;
decl_cnameT cname;
mcComment_commentDesc defComment;
mcComment_commentDesc modComment;
+ decl_opaqueCastState opaqueState;
};
+struct decl_proctypeT_r {
+ Indexing_Index parameters;
+ bool returnopt;
+ bool vararg;
+ decl_node__opaque optarg_;
+ decl_node__opaque scope;
+ decl_node__opaque returnType;
+ decl_opaqueCastState opaqueState;
+ };
+
struct decl_moduleT_r {
nameKey_Name name;
nameKey_Name source;
decl_fixupInfo constFixup;
decl_fixupInfo enumFixup;
decl_scopeT decls;
- decl_node beginStatements;
- decl_node finallyStatements;
+ decl_node__opaque beginStatements;
+ decl_node__opaque finallyStatements;
bool enumsComplete;
bool constsComplete;
bool visited;
Indexing_Index importedModules;
decl_fixupInfo constFixup;
decl_fixupInfo enumFixup;
- decl_node beginStatements;
- decl_node finallyStatements;
- decl_node definitionModule;
+ decl_node__opaque beginStatements;
+ decl_node__opaque finallyStatements;
+ decl_node__opaque definitionModule;
decl_scopeT decls;
bool enumsComplete;
bool constsComplete;
decl_commentPair com;
};
-struct DynamicStrings_Contents_r {
- DynamicStrings__T7 buf;
- unsigned int len;
- DynamicStrings_String next;
- };
-
-struct wlists__T9_r {
- unsigned int noOfElements;
- wlists__T10 elements;
- wlists_wlist next;
- };
-
-struct alists__T13_r {
- unsigned int noOfelements;
- alists__T14 elements;
- alists_alist next;
- };
-
-struct mcPretty__T12_r {
- mcPretty_writeProc write_;
- mcPretty_writeLnProc writeln;
- bool needsSpace;
- bool needsIndent;
- unsigned int seekPos;
- unsigned int curLine;
- unsigned int curPos;
- unsigned int indent;
- mcPretty_pretty stacked;
- };
-
-typedef struct DynamicStrings_descriptor_r DynamicStrings_descriptor;
-
-typedef DynamicStrings_descriptor *DynamicStrings_Descriptor;
-
-typedef struct DynamicStrings_DebugInfo_r DynamicStrings_DebugInfo;
-
-typedef enum {DynamicStrings_inuse, DynamicStrings_marked, DynamicStrings_onlist, DynamicStrings_poisoned} DynamicStrings_desState;
-
-struct DynamicStrings_descriptor_r {
- bool charStarUsed;
- void *charStar;
- unsigned int charStarSize;
- bool charStarValid;
- DynamicStrings_desState state;
- DynamicStrings_String garbage;
- };
-
-struct DynamicStrings_DebugInfo_r {
- DynamicStrings_String next;
- void *file;
- unsigned int line;
- void *proc;
- };
-
struct decl_nodeRec_r {
decl_nodeT kind; /* case tag */
union {
decl_vardeclT vardeclF;
decl_funccallT funccallF;
decl_setvalueT setvalueF;
+ decl_opaquecastT opaquecastF;
};
decl_where at;
};
-struct DynamicStrings_stringRecord_r {
- DynamicStrings_Contents contents;
- DynamicStrings_Descriptor head;
- DynamicStrings_DebugInfo debug;
- };
-
static decl_group freeGroup;
static decl_group globalGroup;
static FIO_File outputFile;
static decl_language lang;
-static decl_node bitsperunitN;
-static decl_node bitsperwordN;
-static decl_node bitspercharN;
-static decl_node unitsperwordN;
-static decl_node mainModule;
-static decl_node currentModule;
-static decl_node defModule;
-static decl_node systemN;
-static decl_node addressN;
-static decl_node locN;
-static decl_node byteN;
-static decl_node wordN;
-static decl_node csizetN;
-static decl_node cssizetN;
-static decl_node adrN;
-static decl_node sizeN;
-static decl_node tsizeN;
-static decl_node newN;
-static decl_node disposeN;
-static decl_node lengthN;
-static decl_node incN;
-static decl_node decN;
-static decl_node inclN;
-static decl_node exclN;
-static decl_node highN;
-static decl_node m2rtsN;
-static decl_node haltN;
-static decl_node throwN;
-static decl_node chrN;
-static decl_node capN;
-static decl_node absN;
-static decl_node floatN;
-static decl_node truncN;
-static decl_node ordN;
-static decl_node valN;
-static decl_node minN;
-static decl_node maxN;
-static decl_node booleanN;
-static decl_node procN;
-static decl_node charN;
-static decl_node integerN;
-static decl_node cardinalN;
-static decl_node longcardN;
-static decl_node shortcardN;
-static decl_node longintN;
-static decl_node shortintN;
-static decl_node bitsetN;
-static decl_node bitnumN;
-static decl_node ztypeN;
-static decl_node rtypeN;
-static decl_node complexN;
-static decl_node longcomplexN;
-static decl_node shortcomplexN;
-static decl_node cmplxN;
-static decl_node reN;
-static decl_node imN;
-static decl_node realN;
-static decl_node longrealN;
-static decl_node shortrealN;
-static decl_node nilN;
-static decl_node trueN;
-static decl_node falseN;
+static decl_node__opaque bitsperunitN;
+static decl_node__opaque bitsperwordN;
+static decl_node__opaque bitspercharN;
+static decl_node__opaque unitsperwordN;
+static decl_node__opaque mainModule;
+static decl_node__opaque currentModule;
+static decl_node__opaque defModule;
+static decl_node__opaque systemN;
+static decl_node__opaque addressN;
+static decl_node__opaque locN;
+static decl_node__opaque byteN;
+static decl_node__opaque wordN;
+static decl_node__opaque csizetN;
+static decl_node__opaque cssizetN;
+static decl_node__opaque adrN;
+static decl_node__opaque sizeN;
+static decl_node__opaque tsizeN;
+static decl_node__opaque newN;
+static decl_node__opaque disposeN;
+static decl_node__opaque lengthN;
+static decl_node__opaque incN;
+static decl_node__opaque decN;
+static decl_node__opaque inclN;
+static decl_node__opaque exclN;
+static decl_node__opaque highN;
+static decl_node__opaque m2rtsN;
+static decl_node__opaque haltN;
+static decl_node__opaque throwN;
+static decl_node__opaque chrN;
+static decl_node__opaque capN;
+static decl_node__opaque absN;
+static decl_node__opaque floatN;
+static decl_node__opaque truncN;
+static decl_node__opaque ordN;
+static decl_node__opaque valN;
+static decl_node__opaque minN;
+static decl_node__opaque maxN;
+static decl_node__opaque booleanN;
+static decl_node__opaque procN;
+static decl_node__opaque charN;
+static decl_node__opaque integerN;
+static decl_node__opaque cardinalN;
+static decl_node__opaque longcardN;
+static decl_node__opaque shortcardN;
+static decl_node__opaque longintN;
+static decl_node__opaque shortintN;
+static decl_node__opaque bitsetN;
+static decl_node__opaque bitnumN;
+static decl_node__opaque ztypeN;
+static decl_node__opaque rtypeN;
+static decl_node__opaque complexN;
+static decl_node__opaque longcomplexN;
+static decl_node__opaque shortcomplexN;
+static decl_node__opaque cmplxN;
+static decl_node__opaque reN;
+static decl_node__opaque imN;
+static decl_node__opaque realN;
+static decl_node__opaque longrealN;
+static decl_node__opaque shortrealN;
+static decl_node__opaque nilN;
+static decl_node__opaque trueN;
+static decl_node__opaque falseN;
static Indexing_Index scopeStack;
static Indexing_Index defUniverseI;
static Indexing_Index modUniverseI;
static bool mustVisitScope;
static bool simplified;
static unsigned int tempCount;
-static decl_node globalNode;
-extern "C" void SYSTEM_ShiftVal (unsigned int *s, unsigned int _s_high, unsigned int *d, unsigned int _d_high, unsigned int SetSizeInBits, int ShiftCount);
-extern "C" void SYSTEM_ShiftLeft (unsigned int *s, unsigned int _s_high, unsigned int *d, unsigned int _d_high, unsigned int SetSizeInBits, unsigned int ShiftCount);
-extern "C" void SYSTEM_ShiftRight (unsigned int *s, unsigned int _s_high, unsigned int *d, unsigned int _d_high, unsigned int SetSizeInBits, unsigned int ShiftCount);
-extern "C" void SYSTEM_RotateVal (unsigned int *s, unsigned int _s_high, unsigned int *d, unsigned int _d_high, unsigned int SetSizeInBits, int RotateCount);
-extern "C" void SYSTEM_RotateLeft (unsigned int *s, unsigned int _s_high, unsigned int *d, unsigned int _d_high, unsigned int SetSizeInBits, unsigned int RotateCount);
-extern "C" void SYSTEM_RotateRight (unsigned int *s, unsigned int _s_high, unsigned int *d, unsigned int _d_high, unsigned int SetSizeInBits, unsigned int RotateCount);
-extern "C" void M2RTS_ConstructModules (void * applicationmodule, void * libname, void * overrideliborder, int argc, void * argv, void * envp);
-extern "C" void M2RTS_DeconstructModules (void * applicationmodule, void * libname, int argc, void * argv, void * envp);
-extern "C" void M2RTS_RegisterModule (void * name, void * libname, M2RTS_ArgCVEnvP init, M2RTS_ArgCVEnvP fini, PROC dependencies);
-extern "C" void M2RTS_RequestDependant (void * modulename, void * libname, void * dependantmodule, void * dependantlibname);
-extern "C" bool M2RTS_InstallTerminationProcedure (PROC p);
-extern "C" void M2RTS_ExecuteInitialProcedures (void);
-extern "C" bool M2RTS_InstallInitialProcedure (PROC p);
-extern "C" void M2RTS_ExecuteTerminationProcedures (void);
-extern "C" void M2RTS_Terminate (void) __attribute__ ((noreturn));
-extern "C" void M2RTS_HALT (int exitcode) __attribute__ ((noreturn));
-extern "C" void M2RTS_Halt (const char *description_, unsigned int _description_high, const char *filename_, unsigned int _filename_high, const char *function_, unsigned int _function_high, unsigned int line) __attribute__ ((noreturn));
-extern "C" void M2RTS_HaltC (void * description, void * filename, void * function, unsigned int line) __attribute__ ((noreturn));
-extern "C" void M2RTS_ExitOnHalt (int e);
-extern "C" void M2RTS_ErrorMessage (const char *message_, unsigned int _message_high, const char *filename_, unsigned int _filename_high, unsigned int line, const char *function_, unsigned int _function_high) __attribute__ ((noreturn));
-extern "C" unsigned int M2RTS_Length (const char *a_, unsigned int _a_high);
-extern "C" void M2RTS_AssignmentException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
-extern "C" void M2RTS_ReturnException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
-extern "C" void M2RTS_IncException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
-extern "C" void M2RTS_DecException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
-extern "C" void M2RTS_InclException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
-extern "C" void M2RTS_ExclException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
-extern "C" void M2RTS_ShiftException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
-extern "C" void M2RTS_RotateException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
-extern "C" void M2RTS_StaticArraySubscriptException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
-extern "C" void M2RTS_DynamicArraySubscriptException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
-extern "C" void M2RTS_ForLoopBeginException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
-extern "C" void M2RTS_ForLoopToException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
-extern "C" void M2RTS_ForLoopEndException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
-extern "C" void M2RTS_PointerNilException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
-extern "C" void M2RTS_NoReturnException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
-extern "C" void M2RTS_CaseException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
-extern "C" void M2RTS_WholeNonPosDivException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
-extern "C" void M2RTS_WholeNonPosModException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
-extern "C" void M2RTS_WholeZeroDivException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
-extern "C" void M2RTS_WholeZeroRemException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
-extern "C" void M2RTS_WholeValueException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
-extern "C" void M2RTS_RealValueException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
-extern "C" void M2RTS_ParameterException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
-extern "C" void M2RTS_NoException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
+static decl_node__opaque globalNode;
/*
getDeclaredMod - returns the token number associated with the nodes declaration
extern "C" bool decl_hasHidden (decl_node n);
+/*
+ putTypeOpaque - marks type, des, as being an opaque type.
+ TYPE des ;
+*/
+
+extern "C" void decl_putTypeOpaque (decl_node des);
+
+/*
+ isTypeOpaque - returns TRUE if type, n, is an opaque type.
+*/
+
+extern "C" bool decl_isTypeOpaque (decl_node n);
+
/*
isVar - returns TRUE if node, n, is a type.
*/
extern "C" decl_node decl_makeProcType (void);
/*
- putReturnType - sets the return type of procedure or proctype, proc, to, type.
+ putReturnType - sets the return type of procedure or proctype proc to type.
*/
extern "C" void decl_putReturnType (decl_node proc, decl_node type);
*/
extern "C" void decl_out (void);
-extern "C" nameKey_Name nameKey_makeKey (const char *a_, unsigned int _a_high);
-extern "C" nameKey_Name nameKey_makekey (void * a);
-extern "C" void nameKey_getKey (nameKey_Name key, char *a, unsigned int _a_high);
-extern "C" unsigned int nameKey_lengthKey (nameKey_Name key);
-extern "C" bool nameKey_isKey (const char *a_, unsigned int _a_high);
-extern "C" void nameKey_writeKey (nameKey_Name key);
-extern "C" bool nameKey_isSameExcludingCase (nameKey_Name key1, nameKey_Name key2);
-extern "C" void * nameKey_keyToCharStar (nameKey_Name key);
-extern "C" symbolKey_symbolTree symbolKey_initTree (void);
-extern "C" void symbolKey_killTree (symbolKey_symbolTree *t);
-extern "C" void * symbolKey_getSymKey (symbolKey_symbolTree t, nameKey_Name name);
-extern "C" void symbolKey_putSymKey (symbolKey_symbolTree t, nameKey_Name name, void * key);
/*
- delSymKey - deletes an entry in the binary tree.
-
- NB in order for this to work we must ensure that the InitTree sets
- both left and right to NIL.
+ newNode - create and return a new node of kind k.
*/
-extern "C" void symbolKey_delSymKey (symbolKey_symbolTree t, nameKey_Name name);
+static decl_node__opaque newNode (decl_nodeT k);
/*
- isEmptyTree - returns true if symbolTree, t, is empty.
+ disposeNode - dispose node, n.
*/
-extern "C" bool symbolKey_isEmptyTree (symbolKey_symbolTree t);
+static void disposeNode (decl_node__opaque *n);
/*
- doesTreeContainAny - returns true if symbolTree, t, contains any
- symbols which in turn return true when procedure,
- p, is called with a symbol as its parameter.
- The symbolTree root is empty apart from the field,
- left, hence we need two procedures.
+ newGroup -
*/
-extern "C" bool symbolKey_doesTreeContainAny (symbolKey_symbolTree t, symbolKey_isSymbol p);
+static void newGroup (decl_group *g);
/*
- foreachNodeDo - for each node in symbolTree, t, a procedure, p,
- is called with the node symbol as its parameter.
- The tree root node only contains a legal left pointer,
- therefore we need two procedures to examine this tree.
+ initGroup - returns a group which with all lists initialized.
*/
-extern "C" void symbolKey_foreachNodeDo (symbolKey_symbolTree t, symbolKey_performOperation p);
+static decl_group initGroup (void);
/*
- initComment - the start of a new comment has been seen by the lexical analyser.
- A new comment block is created and all addText contents are placed
- in this block. onlySpaces indicates whether we have only seen
- spaces on this line.
+ killGroup - deallocate the group and place the group record into the freeGroup list.
*/
-extern "C" mcComment_commentDesc mcComment_initComment (bool onlySpaces);
+static void killGroup (decl_group *g);
/*
- addText - cs is a C string (null terminated) which contains comment text.
- This is appended to the comment, cd.
+ dupGroup - If g is not NIL then destroy g.
+ Return a duplicate of GlobalGroup (not g).
*/
-extern "C" void mcComment_addText (mcComment_commentDesc cd, void * cs);
+static decl_group dupGroup (decl_group g);
/*
- getContent - returns the content of comment, cd.
+ equalGroup - return TRUE if group left = right.
*/
-extern "C" DynamicStrings_String mcComment_getContent (mcComment_commentDesc cd);
+static bool equalGroup (decl_group left, decl_group right);
/*
- getCommentCharStar - returns the C string content of comment, cd.
+ isLocal - returns TRUE if symbol, n, is locally declared in a procedure.
*/
-extern "C" void * mcComment_getCommentCharStar (mcComment_commentDesc cd);
+static bool isLocal (decl_node__opaque n);
/*
- setProcedureComment - changes the type of comment, cd, to a
- procedure heading comment,
- providing it has the procname as the first word.
+ importEnumFields - if, n, is an enumeration type import the all fields into module, m.
*/
-extern "C" void mcComment_setProcedureComment (mcComment_commentDesc cd, nameKey_Name procname);
+static void importEnumFields (decl_node__opaque m, decl_node__opaque n);
/*
- getProcedureComment - returns the current procedure comment if available.
+ isComplex - returns TRUE if, n, is the complex type.
*/
-extern "C" DynamicStrings_String mcComment_getProcedureComment (mcComment_commentDesc cd);
+static bool isComplex (decl_node__opaque n);
/*
- getAfterStatementComment - returns the current statement after comment if available.
+ isLongComplex - returns TRUE if, n, is the longcomplex type.
*/
-extern "C" DynamicStrings_String mcComment_getAfterStatementComment (mcComment_commentDesc cd);
+static bool isLongComplex (decl_node__opaque n);
/*
- getInbodyStatementComment - returns the current statement after comment if available.
+ isShortComplex - returns TRUE if, n, is the shortcomplex type.
*/
-extern "C" DynamicStrings_String mcComment_getInbodyStatementComment (mcComment_commentDesc cd);
+static bool isShortComplex (decl_node__opaque n);
/*
- isProcedureComment - returns TRUE if, cd, is a procedure comment.
+ isAProcType - returns TRUE if, n, is a proctype or proc node.
*/
-extern "C" bool mcComment_isProcedureComment (mcComment_commentDesc cd);
+static bool isAProcType (decl_node__opaque n);
/*
- isBodyComment - returns TRUE if, cd, is a body comment.
+ initFixupInfo - initialize the fixupInfo record.
*/
-extern "C" bool mcComment_isBodyComment (mcComment_commentDesc cd);
+static decl_fixupInfo initFixupInfo (void);
/*
- isAfterComment - returns TRUE if, cd, is an after comment.
+ makeDef - returns a definition module node named, n.
*/
-extern "C" bool mcComment_isAfterComment (mcComment_commentDesc cd);
-extern "C" void mcDebug_assert (bool q);
-extern "C" void mcDebug_writeDebug (const char *a_, unsigned int _a_high);
-extern "C" void Storage_ALLOCATE (void * *a, unsigned int Size);
-extern "C" void Storage_DEALLOCATE (void * *a, unsigned int Size);
-extern "C" void Storage_REALLOCATE (void * *a, unsigned int Size);
-extern "C" bool Storage_Available (unsigned int Size);
-extern "C" bool SFIO_Exists (DynamicStrings_String fname);
-extern "C" FIO_File SFIO_OpenToRead (DynamicStrings_String fname);
-extern "C" FIO_File SFIO_OpenToWrite (DynamicStrings_String fname);
-extern "C" FIO_File SFIO_OpenForRandom (DynamicStrings_String fname, bool towrite, bool newfile);
-extern "C" DynamicStrings_String SFIO_WriteS (FIO_File file, DynamicStrings_String s);
-extern "C" DynamicStrings_String SFIO_ReadS (FIO_File file);
-extern "C" bool FIO_IsNoError (FIO_File f);
-extern "C" bool FIO_IsActive (FIO_File f);
-extern "C" bool FIO_Exists (const char *fname_, unsigned int _fname_high);
-extern "C" FIO_File FIO_OpenToRead (const char *fname_, unsigned int _fname_high);
-extern "C" FIO_File FIO_OpenToWrite (const char *fname_, unsigned int _fname_high);
-extern "C" FIO_File FIO_OpenForRandom (const char *fname_, unsigned int _fname_high, bool towrite, bool newfile);
-extern "C" void FIO_Close (FIO_File f);
-extern "C" bool FIO_exists (void * fname, unsigned int flength);
-extern "C" FIO_File FIO_openToRead (void * fname, unsigned int flength);
-extern "C" FIO_File FIO_openToWrite (void * fname, unsigned int flength);
-extern "C" FIO_File FIO_openForRandom (void * fname, unsigned int flength, bool towrite, bool newfile);
-extern "C" void FIO_FlushBuffer (FIO_File f);
-extern "C" unsigned int FIO_ReadNBytes (FIO_File f, unsigned int nBytes, void * dest);
-extern "C" void FIO_ReadAny (FIO_File f, unsigned char *a, unsigned int _a_high);
-extern "C" unsigned int FIO_WriteNBytes (FIO_File f, unsigned int nBytes, void * src);
-extern "C" void FIO_WriteAny (FIO_File f, unsigned char *a, unsigned int _a_high);
-extern "C" void FIO_WriteChar (FIO_File f, char ch);
-extern "C" bool FIO_EOF (FIO_File f);
-extern "C" bool FIO_EOLN (FIO_File f);
-extern "C" bool FIO_WasEOLN (FIO_File f);
-extern "C" char FIO_ReadChar (FIO_File f);
-extern "C" void FIO_UnReadChar (FIO_File f, char ch);
-extern "C" void FIO_WriteLine (FIO_File f);
-extern "C" void FIO_WriteString (FIO_File f, const char *a_, unsigned int _a_high);
-extern "C" void FIO_ReadString (FIO_File f, char *a, unsigned int _a_high);
-extern "C" void FIO_WriteCardinal (FIO_File f, unsigned int c);
-extern "C" unsigned int FIO_ReadCardinal (FIO_File f);
-extern "C" int FIO_GetUnixFileDescriptor (FIO_File f);
-extern "C" void FIO_SetPositionFromBeginning (FIO_File f, long int pos);
-extern "C" void FIO_SetPositionFromEnd (FIO_File f, long int pos);
-extern "C" long int FIO_FindPosition (FIO_File f);
-extern "C" void FIO_GetFileName (FIO_File f, char *a, unsigned int _a_high);
-extern "C" void * FIO_getFileName (FIO_File f);
-extern "C" unsigned int FIO_getFileNameLength (FIO_File f);
-extern "C" void FIO_FlushOutErr (void);
+static decl_node__opaque makeDef (nameKey_Name n);
/*
- InitString - creates and returns a String type object.
- Initial contents are, a.
+ makeImp - returns an implementation module node named, n.
*/
-extern "C" DynamicStrings_String DynamicStrings_InitString (const char *a_, unsigned int _a_high);
+static decl_node__opaque makeImp (nameKey_Name n);
/*
- KillString - frees String, s, and its contents.
- NIL is returned.
+ makeModule - returns a module node named, n.
*/
-extern "C" DynamicStrings_String DynamicStrings_KillString (DynamicStrings_String s);
+static decl_node__opaque makeModule (nameKey_Name n);
/*
- Fin - finishes with a string, it calls KillString with, s.
- The purpose of the procedure is to provide a short cut
- to calling KillString and then testing the return result.
+ isDefForC - returns TRUE if the definition module was defined FOR "C".
*/
-extern "C" void DynamicStrings_Fin (DynamicStrings_String s);
+static bool isDefForC (decl_node__opaque n);
/*
- InitStringCharStar - initializes and returns a String to contain the C string.
+ initDecls - initialize the decls, scopeT.
*/
-extern "C" DynamicStrings_String DynamicStrings_InitStringCharStar (void * a);
+static void initDecls (decl_scopeT *decls);
/*
- InitStringChar - initializes and returns a String to contain the single character, ch.
+ addTo - adds node, d, to scope decls and returns, d.
+ It stores, d, in the symbols tree associated with decls.
*/
-extern "C" DynamicStrings_String DynamicStrings_InitStringChar (char ch);
+static decl_node__opaque addTo (decl_scopeT *decls, decl_node__opaque d);
/*
- Mark - marks String, s, ready for garbage collection.
+ export - export node, n, from definition module, d.
*/
-extern "C" DynamicStrings_String DynamicStrings_Mark (DynamicStrings_String s);
+static void export_ (decl_node__opaque d, decl_node__opaque n);
/*
- Length - returns the length of the String, s.
+ addToScope - adds node, n, to the current scope and returns, n.
*/
-extern "C" unsigned int DynamicStrings_Length (DynamicStrings_String s);
+static decl_node__opaque addToScope (decl_node__opaque n);
/*
- ConCat - returns String, a, after the contents of, b, have been appended.
+ addModuleToScope - adds module, i, to module, m, scope.
*/
-extern "C" DynamicStrings_String DynamicStrings_ConCat (DynamicStrings_String a, DynamicStrings_String b);
+static void addModuleToScope (decl_node__opaque m, decl_node__opaque i);
/*
- ConCatChar - returns String, a, after character, ch, has been appended.
+ completedEnum - assign boolean enumsComplete to TRUE if a definition,
+ implementation or module symbol.
*/
-extern "C" DynamicStrings_String DynamicStrings_ConCatChar (DynamicStrings_String a, char ch);
+static void completedEnum (decl_node__opaque n);
/*
- Assign - assigns the contents of, b, into, a.
- String, a, is returned.
+ setUnary - sets a unary node to contain, arg, a, and type, t.
*/
-extern "C" DynamicStrings_String DynamicStrings_Assign (DynamicStrings_String a, DynamicStrings_String b);
+static void setUnary (decl_node__opaque u, decl_nodeT k, decl_node__opaque a, decl_node__opaque t);
/*
- ReplaceChar - returns string s after it has changed all occurances of from to to.
+ putVarBool - assigns the four booleans associated with a variable.
*/
-extern "C" DynamicStrings_String DynamicStrings_ReplaceChar (DynamicStrings_String s, char from, char to);
+static void putVarBool (decl_node__opaque v, bool init, bool param, bool isvar, bool isused);
/*
- Dup - duplicate a String, s, returning the copy of s.
+ checkPtr - in C++ we need to create a typedef for a pointer
+ in case we need to use reinterpret_cast.
*/
-extern "C" DynamicStrings_String DynamicStrings_Dup (DynamicStrings_String s);
+static decl_node__opaque checkPtr (decl_node__opaque n);
/*
- Add - returns a new String which contains the contents of a and b.
+ isVarDecl - returns TRUE if, n, is a vardecl node.
*/
-extern "C" DynamicStrings_String DynamicStrings_Add (DynamicStrings_String a, DynamicStrings_String b);
+static bool isVarDecl (decl_node__opaque n);
/*
- Equal - returns TRUE if String, a, and, b, are equal.
+ makeVariablesFromParameters - creates variables which are really parameters.
*/
-extern "C" bool DynamicStrings_Equal (DynamicStrings_String a, DynamicStrings_String b);
+static void makeVariablesFromParameters (decl_node__opaque proc, decl_node__opaque id, decl_node__opaque type, bool isvar, bool isused);
/*
- EqualCharStar - returns TRUE if contents of String, s, is the same as the
- string, a.
+ addProcedureToScope - add a procedure name n and node d to the
+ current scope.
*/
-extern "C" bool DynamicStrings_EqualCharStar (DynamicStrings_String s, void * a);
+static decl_node__opaque addProcedureToScope (decl_node__opaque d, nameKey_Name n);
/*
- EqualArray - returns TRUE if contents of String, s, is the same as the
- string, a.
+ putProcTypeReturn - sets the return type of, proc, to, type.
*/
-extern "C" bool DynamicStrings_EqualArray (DynamicStrings_String s, const char *a_, unsigned int _a_high);
+static void putProcTypeReturn (decl_node__opaque proc, decl_node__opaque type);
/*
- Mult - returns a new string which is n concatenations of String, s.
+ putProcTypeOptReturn - sets, proc, to have an optional return type.
*/
-extern "C" DynamicStrings_String DynamicStrings_Mult (DynamicStrings_String s, unsigned int n);
+static void putProcTypeOptReturn (decl_node__opaque proc);
/*
- Slice - returns a new string which contains the elements
- low..high-1
-
- strings start at element 0
- Slice(s, 0, 2) will return elements 0, 1 but not 2
- Slice(s, 1, 3) will return elements 1, 2 but not 3
- Slice(s, 2, 0) will return elements 2..max
- Slice(s, 3, -1) will return elements 3..max-1
- Slice(s, 4, -2) will return elements 4..max-2
+ makeOptParameter - creates and returns an optarg.
*/
-extern "C" DynamicStrings_String DynamicStrings_Slice (DynamicStrings_String s, int low, int high);
+static decl_node__opaque makeOptParameter (decl_node__opaque l, decl_node__opaque type, decl_node__opaque init);
/*
- Index - returns the indice of the first occurance of, ch, in
- String, s. -1 is returned if, ch, does not exist.
- The search starts at position, o.
+ setwatch - assign the globalNode to n.
*/
-extern "C" int DynamicStrings_Index (DynamicStrings_String s, char ch, unsigned int o);
+static bool setwatch (decl_node__opaque n);
/*
- RIndex - returns the indice of the last occurance of, ch,
- in String, s. The search starts at position, o.
- -1 is returned if, ch, is not found. The search
- is performed left to right.
+ runwatch - set the globalNode to an identlist.
*/
-extern "C" int DynamicStrings_RIndex (DynamicStrings_String s, char ch, unsigned int o);
+static bool runwatch (void);
/*
- ReverseIndex - returns the indice of the last occurance of ch
- in String s. The search starts at position o
- and searches from right to left. The start position
- may be indexed negatively from the right (-1 is the
- last index).
- The return value if ch is found will always be positive.
- -1 is returned if ch is not found.
+ isIdentList - returns TRUE if, n, is an identlist.
*/
-extern "C" int DynamicStrings_ReverseIndex (DynamicStrings_String s, char ch, int o);
+static bool isIdentList (decl_node__opaque n);
/*
- RemoveComment - assuming that, comment, is a comment delimiter
- which indicates anything to its right is a comment
- then strip off the comment and also any white space
- on the remaining right hand side.
- It leaves any white space on the left hand side alone.
+ identListLen - returns the length of identlist.
*/
-extern "C" DynamicStrings_String DynamicStrings_RemoveComment (DynamicStrings_String s, char comment);
+static unsigned int identListLen (decl_node__opaque n);
/*
- RemoveWhitePrefix - removes any leading white space from String, s.
- A new string is returned.
+ checkParameters - placeholder for future parameter checking.
*/
-extern "C" DynamicStrings_String DynamicStrings_RemoveWhitePrefix (DynamicStrings_String s);
+static void checkParameters (decl_node__opaque p, decl_node__opaque i, decl_node__opaque type, bool isvar, bool isused);
/*
- RemoveWhitePostfix - removes any leading white space from String, s.
- A new string is returned.
+ checkMakeVariables - create shadow local variables for parameters providing that
+ procedure n has not already been built and we are compiling
+ a module or an implementation module.
*/
-extern "C" DynamicStrings_String DynamicStrings_RemoveWhitePostfix (DynamicStrings_String s);
+static void checkMakeVariables (decl_node__opaque n, decl_node__opaque i, decl_node__opaque type, bool isvar, bool isused);
/*
- ToUpper - returns string, s, after it has had its lower case characters
- replaced by upper case characters.
- The string, s, is not duplicated.
+ makeVarientField - create a varient field within varient, v,
+ The new varient field is returned.
*/
-extern "C" DynamicStrings_String DynamicStrings_ToUpper (DynamicStrings_String s);
+static decl_node__opaque makeVarientField (decl_node__opaque v, decl_node__opaque p);
/*
- ToLower - returns string, s, after it has had its upper case characters
- replaced by lower case characters.
- The string, s, is not duplicated.
+ putFieldVarient - places the field varient, f, as a brother to, the
+ varient symbol, v, and also tells, f, that its varient
+ parent is, v.
*/
-extern "C" DynamicStrings_String DynamicStrings_ToLower (DynamicStrings_String s);
+static void putFieldVarient (decl_node__opaque f, decl_node__opaque v);
/*
- CopyOut - copies string, s, to a.
+ putFieldRecord - create a new recordfield and place it into record r.
+ The new field has a tagname and type and can have a
+ variant field v.
*/
-extern "C" void DynamicStrings_CopyOut (char *a, unsigned int _a_high, DynamicStrings_String s);
+static decl_node__opaque putFieldRecord (decl_node__opaque r, nameKey_Name tag, decl_node__opaque type, decl_node__opaque v);
/*
- char - returns the character, ch, at position, i, in String, s.
+ ensureOrder - ensures that, a, and, b, exist in, i, and also
+ ensure that, a, is before, b.
*/
-extern "C" char DynamicStrings_char (DynamicStrings_String s, int i);
+static void ensureOrder (Indexing_Index i, decl_node__opaque a, decl_node__opaque b);
/*
- string - returns the C style char * of String, s.
+ putVarientTag - places tag into variant v.
*/
-extern "C" void * DynamicStrings_string (DynamicStrings_String s);
+static void putVarientTag (decl_node__opaque v, decl_node__opaque tag);
/*
- InitStringDB - the debug version of InitString.
+ getParent - returns the parent field of recordfield or varientfield symbol, n.
*/
-extern "C" DynamicStrings_String DynamicStrings_InitStringDB (const char *a_, unsigned int _a_high, const char *file_, unsigned int _file_high, unsigned int line);
+static decl_node__opaque getParent (decl_node__opaque n);
/*
- InitStringCharStarDB - the debug version of InitStringCharStar.
+ getRecord - returns the record associated with node, n.
+ (Parental record).
*/
-extern "C" DynamicStrings_String DynamicStrings_InitStringCharStarDB (void * a, const char *file_, unsigned int _file_high, unsigned int line);
+static decl_node__opaque getRecord (decl_node__opaque n);
/*
- InitStringCharDB - the debug version of InitStringChar.
+ isConstExp - return TRUE if the node kind is a constexp.
*/
-extern "C" DynamicStrings_String DynamicStrings_InitStringCharDB (char ch, const char *file_, unsigned int _file_high, unsigned int line);
+static bool isConstExp (decl_node__opaque c);
/*
- MultDB - the debug version of MultDB.
+ addEnumToModule - adds enumeration type, e, into the list of enums
+ in module, m.
*/
-extern "C" DynamicStrings_String DynamicStrings_MultDB (DynamicStrings_String s, unsigned int n, const char *file_, unsigned int _file_high, unsigned int line);
+static void addEnumToModule (decl_node__opaque m, decl_node__opaque e);
/*
- DupDB - the debug version of Dup.
+ getNextFixup - return the next fixup from from f.
*/
-extern "C" DynamicStrings_String DynamicStrings_DupDB (DynamicStrings_String s, const char *file_, unsigned int _file_high, unsigned int line);
+static decl_node__opaque getNextFixup (decl_fixupInfo *f);
/*
- SliceDB - debug version of Slice.
+ doMakeEnum - create an enumeration type and add it to the current module.
*/
-extern "C" DynamicStrings_String DynamicStrings_SliceDB (DynamicStrings_String s, int low, int high, const char *file_, unsigned int _file_high, unsigned int line);
+static decl_node__opaque doMakeEnum (void);
/*
- PushAllocation - pushes the current allocation/deallocation lists.
+ doMakeEnumField - create an enumeration field name and add it to enumeration e.
+ Return the new field.
*/
-extern "C" void DynamicStrings_PushAllocation (void);
+static decl_node__opaque doMakeEnumField (decl_node__opaque e, nameKey_Name n);
/*
- PopAllocation - test to see that all strings are deallocated since
- the last push. Then it pops to the previous
- allocation/deallocation lists.
-
- If halt is true then the application terminates
- with an exit code of 1.
+ getExpList - returns the, n, th argument in an explist.
*/
-extern "C" void DynamicStrings_PopAllocation (bool halt);
+static decl_node__opaque getExpList (decl_node__opaque p, unsigned int n);
/*
- PopAllocationExemption - test to see that all strings are deallocated, except
- string e since the last push.
- Post-condition: it pops to the previous allocation/deallocation
- lists.
-
- If halt is true then the application terminates
- with an exit code of 1.
+ expListLen - returns the length of explist, p.
*/
-extern "C" DynamicStrings_String DynamicStrings_PopAllocationExemption (bool halt, DynamicStrings_String e);
-extern "C" DynamicStrings_String StringConvert_IntegerToString (int i, unsigned int width, char padding, bool sign, unsigned int base, bool lower);
-extern "C" DynamicStrings_String StringConvert_CardinalToString (unsigned int c, unsigned int width, char padding, unsigned int base, bool lower);
-extern "C" int StringConvert_StringToInteger (DynamicStrings_String s, unsigned int base, bool *found);
-extern "C" unsigned int StringConvert_StringToCardinal (DynamicStrings_String s, unsigned int base, bool *found);
-extern "C" DynamicStrings_String StringConvert_LongIntegerToString (long int i, unsigned int width, char padding, bool sign, unsigned int base, bool lower);
-extern "C" long int StringConvert_StringToLongInteger (DynamicStrings_String s, unsigned int base, bool *found);
-extern "C" DynamicStrings_String StringConvert_LongCardinalToString (long unsigned int c, unsigned int width, char padding, unsigned int base, bool lower);
-extern "C" long unsigned int StringConvert_StringToLongCardinal (DynamicStrings_String s, unsigned int base, bool *found);
-extern "C" DynamicStrings_String StringConvert_ShortCardinalToString (short unsigned int c, unsigned int width, char padding, unsigned int base, bool lower);
-extern "C" short unsigned int StringConvert_StringToShortCardinal (DynamicStrings_String s, unsigned int base, bool *found);
-extern "C" int StringConvert_stoi (DynamicStrings_String s);
-extern "C" DynamicStrings_String StringConvert_itos (int i, unsigned int width, char padding, bool sign);
-extern "C" DynamicStrings_String StringConvert_ctos (unsigned int c, unsigned int width, char padding);
-extern "C" unsigned int StringConvert_stoc (DynamicStrings_String s);
-extern "C" int StringConvert_hstoi (DynamicStrings_String s);
-extern "C" int StringConvert_ostoi (DynamicStrings_String s);
-extern "C" int StringConvert_bstoi (DynamicStrings_String s);
-extern "C" unsigned int StringConvert_hstoc (DynamicStrings_String s);
-extern "C" unsigned int StringConvert_ostoc (DynamicStrings_String s);
-extern "C" unsigned int StringConvert_bstoc (DynamicStrings_String s);
-extern "C" long double StringConvert_StringToLongreal (DynamicStrings_String s, bool *found);
-extern "C" DynamicStrings_String StringConvert_LongrealToString (long double x, unsigned int TotalWidth, unsigned int FractionWidth);
-extern "C" double StringConvert_stor (DynamicStrings_String s);
-extern "C" long double StringConvert_stolr (DynamicStrings_String s);
-extern "C" DynamicStrings_String StringConvert_ToSigFig (DynamicStrings_String s, unsigned int n);
-extern "C" DynamicStrings_String StringConvert_ToDecimalPlaces (DynamicStrings_String s, unsigned int n);
-extern "C" DynamicStrings_String mcOptions_handleOptions (void);
-extern "C" bool mcOptions_getQuiet (void);
-extern "C" bool mcOptions_getVerbose (void);
-extern "C" bool mcOptions_getInternalDebugging (void);
-extern "C" DynamicStrings_String mcOptions_getCppCommandLine (void);
-extern "C" DynamicStrings_String mcOptions_getOutputFile (void);
-extern "C" bool mcOptions_getExtendedOpaque (void);
-extern "C" void mcOptions_setDebugTopological (bool value);
-extern "C" bool mcOptions_getDebugTopological (void);
-extern "C" DynamicStrings_String mcOptions_getHPrefix (void);
-extern "C" bool mcOptions_getIgnoreFQ (void);
-extern "C" bool mcOptions_getGccConfigSystem (void);
-extern "C" bool mcOptions_getScaffoldDynamic (void);
-extern "C" bool mcOptions_getScaffoldMain (void);
-extern "C" void mcOptions_writeGPLheader (FIO_File f);
-extern "C" void mcOptions_setSuppressNoReturn (bool value);
-extern "C" bool mcOptions_getSuppressNoReturn (void);
-extern "C" bool mcOptions_useBool (void);
-extern "C" DynamicStrings_String mcOptions_getCRealType (void);
-extern "C" DynamicStrings_String mcOptions_getCLongRealType (void);
-extern "C" DynamicStrings_String mcOptions_getCShortRealType (void);
-extern "C" DynamicStrings_String FormatStrings_Sprintf0 (DynamicStrings_String fmt);
-extern "C" DynamicStrings_String FormatStrings_Sprintf1 (DynamicStrings_String fmt, const unsigned char *w_, unsigned int _w_high);
-extern "C" DynamicStrings_String FormatStrings_Sprintf2 (DynamicStrings_String fmt, const unsigned char *w1_, unsigned int _w1_high, const unsigned char *w2_, unsigned int _w2_high);
-extern "C" DynamicStrings_String FormatStrings_Sprintf3 (DynamicStrings_String fmt, const unsigned char *w1_, unsigned int _w1_high, const unsigned char *w2_, unsigned int _w2_high, const unsigned char *w3_, unsigned int _w3_high);
-extern "C" DynamicStrings_String FormatStrings_Sprintf4 (DynamicStrings_String fmt, const unsigned char *w1_, unsigned int _w1_high, const unsigned char *w2_, unsigned int _w2_high, const unsigned char *w3_, unsigned int _w3_high, const unsigned char *w4_, unsigned int _w4_high);
-extern "C" DynamicStrings_String FormatStrings_HandleEscape (DynamicStrings_String s);
-extern "C" ssize_t libc_write (int d, void * buf, size_t nbytes);
-extern "C" ssize_t libc_read (int d, void * buf, size_t nbytes);
-extern "C" int libc_system (void * a);
-extern "C" void libc_abort (void) __attribute__ ((noreturn));
-extern "C" void * libc_malloc (size_t size);
-extern "C" void libc_free (void * ptr);
-extern "C" void * libc_realloc (void * ptr, size_t size);
-extern "C" int libc_isatty (int fd);
-extern "C" void libc_exit (int r) __attribute__ ((noreturn));
-extern "C" void * libc_getenv (void * s);
-extern "C" int libc_putenv (void * s);
-extern "C" int libc_getpid (void);
-extern "C" int libc_dup (int d);
-extern "C" int libc_close (int d);
-extern "C" int libc_open (void * filename, int oflag, ...);
-extern "C" int libc_creat (void * filename, unsigned int mode);
-extern "C" ssize_t libc_lseek (int fd, ssize_t offset, int whence);
-extern "C" void libc_perror (const char *string_, unsigned int _string_high);
-extern "C" int libc_readv (int fd, void * v, int n);
-extern "C" int libc_writev (int fd, void * v, int n);
-extern "C" void * libc_getcwd (void * buf, size_t size);
-extern "C" int libc_chown (void * filename, int uid, int gid);
-extern "C" size_t libc_strlen (void * a);
-extern "C" void * libc_strcpy (void * dest, void * src);
-extern "C" void * libc_strncpy (void * dest, void * src, unsigned int n);
-extern "C" int libc_unlink (void * file);
-extern "C" void * libc_memcpy (void * dest, void * src, size_t size);
-extern "C" void * libc_memset (void * s, int c, size_t size);
-extern "C" void * libc_memmove (void * dest, void * src, size_t size);
-extern "C" int libc_printf (const char *format_, unsigned int _format_high, ...);
-extern "C" int libc_snprintf (void * dest, size_t size, const char *format_, unsigned int _format_high, ...);
-extern "C" int libc_setenv (void * name, void * value, int overwrite);
-extern "C" void libc_srand (int seed);
-extern "C" int libc_rand (void);
-extern "C" libc_time_t libc_time (void * a);
-extern "C" void * libc_localtime (libc_time_t *t);
-extern "C" int libc_ftime (libc_timeb *t);
-extern "C" int libc_shutdown (int s, int how);
-extern "C" int libc_rename (void * oldpath, void * newpath);
-extern "C" int libc_setjmp (void * env);
-extern "C" void libc_longjmp (void * env, int val);
-extern "C" int libc_atexit (libc_exitP_C proc);
-extern "C" void * libc_ttyname (int filedes);
-extern "C" unsigned int libc_sleep (unsigned int seconds);
-extern "C" int libc_execv (void * pathname, void * argv);
-extern "C" void mcMetaError_metaError1 (const char *m_, unsigned int _m_high, const unsigned char *s_, unsigned int _s_high);
-extern "C" void mcMetaError_metaError2 (const char *m_, unsigned int _m_high, const unsigned char *s1_, unsigned int _s1_high, const unsigned char *s2_, unsigned int _s2_high);
-extern "C" void mcMetaError_metaError3 (const char *m_, unsigned int _m_high, const unsigned char *s1_, unsigned int _s1_high, const unsigned char *s2_, unsigned int _s2_high, const unsigned char *s3_, unsigned int _s3_high);
-extern "C" void mcMetaError_metaError4 (const char *m_, unsigned int _m_high, const unsigned char *s1_, unsigned int _s1_high, const unsigned char *s2_, unsigned int _s2_high, const unsigned char *s3_, unsigned int _s3_high, const unsigned char *s4_, unsigned int _s4_high);
-extern "C" void mcMetaError_metaErrors1 (const char *m1_, unsigned int _m1_high, const char *m2_, unsigned int _m2_high, const unsigned char *s_, unsigned int _s_high);
-extern "C" void mcMetaError_metaErrors2 (const char *m1_, unsigned int _m1_high, const char *m2_, unsigned int _m2_high, const unsigned char *s1_, unsigned int _s1_high, const unsigned char *s2_, unsigned int _s2_high);
-extern "C" void mcMetaError_metaErrors3 (const char *m1_, unsigned int _m1_high, const char *m2_, unsigned int _m2_high, const unsigned char *s1_, unsigned int _s1_high, const unsigned char *s2_, unsigned int _s2_high, const unsigned char *s3_, unsigned int _s3_high);
-extern "C" void mcMetaError_metaErrors4 (const char *m1_, unsigned int _m1_high, const char *m2_, unsigned int _m2_high, const unsigned char *s1_, unsigned int _s1_high, const unsigned char *s2_, unsigned int _s2_high, const unsigned char *s3_, unsigned int _s3_high, const unsigned char *s4_, unsigned int _s4_high);
-extern "C" void mcMetaError_metaErrorT1 (unsigned int tok, const char *m_, unsigned int _m_high, const unsigned char *s_, unsigned int _s_high);
-extern "C" void mcMetaError_metaErrorT2 (unsigned int tok, const char *m_, unsigned int _m_high, const unsigned char *s1_, unsigned int _s1_high, const unsigned char *s2_, unsigned int _s2_high);
-extern "C" void mcMetaError_metaErrorT3 (unsigned int tok, const char *m_, unsigned int _m_high, const unsigned char *s1_, unsigned int _s1_high, const unsigned char *s2_, unsigned int _s2_high, const unsigned char *s3_, unsigned int _s3_high);
-extern "C" void mcMetaError_metaErrorT4 (unsigned int tok, const char *m_, unsigned int _m_high, const unsigned char *s1_, unsigned int _s1_high, const unsigned char *s2_, unsigned int _s2_high, const unsigned char *s3_, unsigned int _s3_high, const unsigned char *s4_, unsigned int _s4_high);
-extern "C" void mcMetaError_metaErrorsT1 (unsigned int tok, const char *m1_, unsigned int _m1_high, const char *m2_, unsigned int _m2_high, const unsigned char *s_, unsigned int _s_high);
-extern "C" void mcMetaError_metaErrorsT2 (unsigned int tok, const char *m1_, unsigned int _m1_high, const char *m2_, unsigned int _m2_high, const unsigned char *s1_, unsigned int _s1_high, const unsigned char *s2_, unsigned int _s2_high);
-extern "C" void mcMetaError_metaErrorsT3 (unsigned int tok, const char *m1_, unsigned int _m1_high, const char *m2_, unsigned int _m2_high, const unsigned char *s1_, unsigned int _s1_high, const unsigned char *s2_, unsigned int _s2_high, const unsigned char *s3_, unsigned int _s3_high);
-extern "C" void mcMetaError_metaErrorsT4 (unsigned int tok, const char *m1_, unsigned int _m1_high, const char *m2_, unsigned int _m2_high, const unsigned char *s1_, unsigned int _s1_high, const unsigned char *s2_, unsigned int _s2_high, const unsigned char *s3_, unsigned int _s3_high, const unsigned char *s4_, unsigned int _s4_high);
-extern "C" void mcMetaError_metaErrorString1 (DynamicStrings_String m, const unsigned char *s_, unsigned int _s_high);
-extern "C" void mcMetaError_metaErrorString2 (DynamicStrings_String m, const unsigned char *s1_, unsigned int _s1_high, const unsigned char *s2_, unsigned int _s2_high);
-extern "C" void mcMetaError_metaErrorString3 (DynamicStrings_String m, const unsigned char *s1_, unsigned int _s1_high, const unsigned char *s2_, unsigned int _s2_high, const unsigned char *s3_, unsigned int _s3_high);
-extern "C" void mcMetaError_metaErrorString4 (DynamicStrings_String m, const unsigned char *s1_, unsigned int _s1_high, const unsigned char *s2_, unsigned int _s2_high, const unsigned char *s3_, unsigned int _s3_high, const unsigned char *s4_, unsigned int _s4_high);
-extern "C" void mcMetaError_metaErrorStringT1 (unsigned int tok, DynamicStrings_String m, const unsigned char *s_, unsigned int _s_high);
-extern "C" void mcMetaError_metaErrorStringT2 (unsigned int tok, DynamicStrings_String m, const unsigned char *s1_, unsigned int _s1_high, const unsigned char *s2_, unsigned int _s2_high);
-extern "C" void mcMetaError_metaErrorStringT3 (unsigned int tok, DynamicStrings_String m, const unsigned char *s1_, unsigned int _s1_high, const unsigned char *s2_, unsigned int _s2_high, const unsigned char *s3_, unsigned int _s3_high);
-extern "C" void mcMetaError_metaErrorStringT4 (unsigned int tok, DynamicStrings_String m, const unsigned char *s1_, unsigned int _s1_high, const unsigned char *s2_, unsigned int _s2_high, const unsigned char *s3_, unsigned int _s3_high, const unsigned char *s4_, unsigned int _s4_high);
+static unsigned int expListLen (decl_node__opaque p);
/*
- internalError - displays an internal error message together with the compiler source
- file and line number.
- This function is not buffered and is used when the compiler is about
- to give up.
+ getConstExpComplete - gets the field from the def or imp or module, n.
*/
-extern "C" void mcError_internalError (const char *a_, unsigned int _a_high, const char *file_, unsigned int _file_high, unsigned int line);
+static bool getConstExpComplete (decl_node__opaque n);
/*
- writeFormat0 - displays the source module and line together
- with the encapsulated format string.
- Used for simple error messages tied to the current token.
+ addConstToModule - adds const exp, e, into the list of constant
+ expressions in module, m.
*/
-extern "C" void mcError_writeFormat0 (const char *a_, unsigned int _a_high);
+static void addConstToModule (decl_node__opaque m, decl_node__opaque e);
/*
- writeFormat1 - displays the source module and line together
- with the encapsulated format string.
- Used for simple error messages tied to the current token.
+ doMakeConstExp - create a constexp node and add it to the current module.
*/
-extern "C" void mcError_writeFormat1 (const char *a_, unsigned int _a_high, const unsigned char *w_, unsigned int _w_high);
+static decl_node__opaque doMakeConstExp (void);
/*
- writeFormat2 - displays the module and line together with the encapsulated
- format strings.
- Used for simple error messages tied to the current token.
+ isAnyType - return TRUE if node n is any type kind.
*/
-extern "C" void mcError_writeFormat2 (const char *a_, unsigned int _a_high, const unsigned char *w1_, unsigned int _w1_high, const unsigned char *w2_, unsigned int _w2_high);
+static bool isAnyType (decl_node__opaque n);
/*
- writeFormat3 - displays the module and line together with the encapsulated
- format strings.
- Used for simple error messages tied to the current token.
+ makeVal - creates a VAL (type, expression) node.
*/
-extern "C" void mcError_writeFormat3 (const char *a_, unsigned int _a_high, const unsigned char *w1_, unsigned int _w1_high, const unsigned char *w2_, unsigned int _w2_high, const unsigned char *w3_, unsigned int _w3_high);
+static decl_node__opaque makeVal (decl_node__opaque params);
/*
- newError - creates and returns a new error handle.
+ makeCast - creates a cast node TYPENAME (expr).
*/
-extern "C" mcError_error mcError_newError (unsigned int atTokenNo);
+static decl_node__opaque makeCast (decl_node__opaque c, decl_node__opaque p);
+static decl_node__opaque makeIntrinsicProc (decl_nodeT k, unsigned int noArgs, decl_node__opaque p);
/*
- newWarning - creates and returns a new error handle suitable for a warning.
- A warning will not stop compilation.
+ makeIntrinsicUnaryType - create an intrisic unary type.
*/
-extern "C" mcError_error mcError_newWarning (unsigned int atTokenNo);
+static decl_node__opaque makeIntrinsicUnaryType (decl_nodeT k, decl_node__opaque paramList, decl_node__opaque returnType);
/*
- chainError - creates and returns a new error handle, this new error
- is associated with, e, and is chained onto the end of, e.
- If, e, is NIL then the result to NewError is returned.
+ makeIntrinsicBinaryType - create an intrisic binary type.
*/
-extern "C" mcError_error mcError_chainError (unsigned int atTokenNo, mcError_error e);
-extern "C" void mcError_errorFormat0 (mcError_error e, const char *a_, unsigned int _a_high);
-extern "C" void mcError_errorFormat1 (mcError_error e, const char *a_, unsigned int _a_high, const unsigned char *w_, unsigned int _w_high);
-extern "C" void mcError_errorFormat2 (mcError_error e, const char *a_, unsigned int _a_high, const unsigned char *w1_, unsigned int _w1_high, const unsigned char *w2_, unsigned int _w2_high);
-extern "C" void mcError_errorFormat3 (mcError_error e, const char *a_, unsigned int _a_high, const unsigned char *w1_, unsigned int _w1_high, const unsigned char *w2_, unsigned int _w2_high, const unsigned char *w3_, unsigned int _w3_high);
-extern "C" void mcError_errorString (mcError_error e, DynamicStrings_String str);
+static decl_node__opaque makeIntrinsicBinaryType (decl_nodeT k, decl_node__opaque paramList, decl_node__opaque returnType);
/*
- errorStringAt - given an error string, s, it places this
- string at token position, tok.
- The string is consumed.
+ checkIntrinsic - checks to see if the function call to, c, with
+ parameter list, n, is really an intrinic. If it
+ is an intrinic then an intrinic node is created
+ and returned. Otherwise NIL is returned.
*/
-extern "C" void mcError_errorStringAt (DynamicStrings_String s, unsigned int tok);
+static decl_node__opaque checkIntrinsic (decl_node__opaque c, decl_node__opaque n);
/*
- errorStringAt2 - given an error string, s, it places this
- string at token positions, tok1 and tok2, respectively.
- The string is consumed.
+ checkCHeaders - check to see if the function is a C system function and
+ requires a header file included.
*/
-extern "C" void mcError_errorStringAt2 (DynamicStrings_String s, unsigned int tok1, unsigned int tok2);
+static void checkCHeaders (decl_node__opaque c);
/*
- errorStringsAt2 - given error strings, s1, and, s2, it places these
- strings at token positions, tok1 and tok2, respectively.
- Both strings are consumed.
+ isFuncCall - returns TRUE if, n, is a function/procedure call.
*/
-extern "C" void mcError_errorStringsAt2 (DynamicStrings_String s1, DynamicStrings_String s2, unsigned int tok1, unsigned int tok2);
+static bool isFuncCall (decl_node__opaque n);
/*
- warnStringAt - given an error string, s, it places this
- string at token position, tok.
- The string is consumed.
+ putTypeInternal - marks type, des, as being an internally generated type.
*/
-extern "C" void mcError_warnStringAt (DynamicStrings_String s, unsigned int tok);
+static void putTypeInternal (decl_node__opaque des);
/*
- warnStringAt2 - given an warning string, s, it places this
- string at token positions, tok1 and tok2, respectively.
- The string is consumed.
+ isTypeInternal - returns TRUE if type, n, is internal.
*/
-extern "C" void mcError_warnStringAt2 (DynamicStrings_String s, unsigned int tok1, unsigned int tok2);
+static bool isTypeInternal (decl_node__opaque n);
/*
- warnStringsAt2 - given warning strings, s1, and, s2, it places these
- strings at token positions, tok1 and tok2, respectively.
- Both strings are consumed.
+ lookupBase - return node named n from the base symbol scope.
*/
-extern "C" void mcError_warnStringsAt2 (DynamicStrings_String s1, DynamicStrings_String s2, unsigned int tok1, unsigned int tok2);
-extern "C" void mcError_warnFormat0 (const char *a_, unsigned int _a_high);
+static decl_node__opaque lookupBase (nameKey_Name n);
/*
- warnFormat1 - displays the source module and line together
- with the encapsulated format string.
- Used for simple warning messages tied to the current token.
+ dumpScopes - display the names of all the scopes stacked.
*/
-extern "C" void mcError_warnFormat1 (const char *a_, unsigned int _a_high, const unsigned char *w_, unsigned int _w_high);
+static void dumpScopes (void);
/*
- flushErrors - switches the output channel to the error channel
- and then writes out all errors.
+ out0 - write string a to StdOut.
*/
-extern "C" void mcError_flushErrors (void);
+static void out0 (const char *a_, unsigned int _a_high);
/*
- flushWarnings - switches the output channel to the error channel
- and then writes out all warnings.
- If an error is present the compilation is terminated,
- if warnings only were emitted then compilation will
- continue.
+ out1 - write string a to StdOut using format specifier a.
*/
-extern "C" void mcError_flushWarnings (void);
+static void out1 (const char *a_, unsigned int _a_high, decl_node__opaque s);
/*
- errorAbort0 - aborts compiling, it flushes all warnings and errors before aborting.
+ out2 - write string a to StdOut using format specifier a.
*/
-extern "C" void mcError_errorAbort0 (const char *a_, unsigned int _a_high);
-extern "C" mcComment_commentDesc mcLexBuf_getProcedureComment (void);
-extern "C" mcComment_commentDesc mcLexBuf_getBodyComment (void);
-extern "C" mcComment_commentDesc mcLexBuf_getAfterComment (void);
-extern "C" bool mcLexBuf_openSource (DynamicStrings_String s);
-extern "C" void mcLexBuf_closeSource (void);
-extern "C" void mcLexBuf_reInitialize (void);
-extern "C" void mcLexBuf_resetForNewPass (void);
-extern "C" void mcLexBuf_getToken (void);
-extern "C" void mcLexBuf_insertToken (mcReserved_toktype token);
-extern "C" void mcLexBuf_insertTokenAndRewind (mcReserved_toktype token);
-extern "C" unsigned int mcLexBuf_getPreviousTokenLineNo (void);
-extern "C" unsigned int mcLexBuf_getLineNo (void);
-extern "C" unsigned int mcLexBuf_getTokenNo (void);
-extern "C" unsigned int mcLexBuf_tokenToLineNo (unsigned int tokenNo, unsigned int depth);
-extern "C" unsigned int mcLexBuf_getColumnNo (void);
-extern "C" unsigned int mcLexBuf_tokenToColumnNo (unsigned int tokenNo, unsigned int depth);
-extern "C" DynamicStrings_String mcLexBuf_findFileNameFromToken (unsigned int tokenNo, unsigned int depth);
-extern "C" DynamicStrings_String mcLexBuf_getFileName (void);
-extern "C" void mcLexBuf_addTok (mcReserved_toktype t);
-extern "C" void mcLexBuf_addTokCharStar (mcReserved_toktype t, void * s);
-extern "C" void mcLexBuf_addTokInteger (mcReserved_toktype t, int i);
-extern "C" void mcLexBuf_addTokComment (mcReserved_toktype t, mcComment_commentDesc com);
-extern "C" void mcLexBuf_setFile (void * filename);
-extern "C" void mcLexBuf_pushFile (void * filename);
-extern "C" void mcLexBuf_popFile (void * filename);
-extern "C" void StrLib_StrConCat (const char *a_, unsigned int _a_high, const char *b_, unsigned int _b_high, char *c, unsigned int _c_high);
-extern "C" bool StrLib_StrLess (const char *a_, unsigned int _a_high, const char *b_, unsigned int _b_high);
-extern "C" bool StrLib_StrEqual (const char *a_, unsigned int _a_high, const char *b_, unsigned int _b_high);
-extern "C" unsigned int StrLib_StrLen (const char *a_, unsigned int _a_high);
-extern "C" void StrLib_StrCopy (const char *src_, unsigned int _src_high, char *dest, unsigned int _dest_high);
-extern "C" bool StrLib_IsSubString (const char *a_, unsigned int _a_high, const char *b_, unsigned int _b_high);
-extern "C" void StrLib_StrRemoveWhitePrefix (const char *a_, unsigned int _a_high, char *b, unsigned int _b_high);
+static void out2 (const char *a_, unsigned int _a_high, unsigned int c, decl_node__opaque s);
/*
- initPretty - initialise a pretty print data structure.
+ out3 - write string a to StdOut using format specifier a.
*/
-extern "C" mcPretty_pretty mcPretty_initPretty (mcPretty_writeProc w, mcPretty_writeLnProc l);
+static void out3 (const char *a_, unsigned int _a_high, unsigned int l, nameKey_Name n, decl_node__opaque s);
/*
- dupPretty - duplicate a pretty print data structure.
+ isUnary - returns TRUE if, n, is an unary node.
*/
-extern "C" mcPretty_pretty mcPretty_dupPretty (mcPretty_pretty p);
+static bool isUnary (decl_node__opaque n);
/*
- killPretty - destroy a pretty print data structure.
- Post condition: p is assigned to NIL.
+ isBinary - returns TRUE if, n, is an binary node.
*/
-extern "C" void mcPretty_killPretty (mcPretty_pretty *p);
+static bool isBinary (decl_node__opaque n);
/*
- pushPretty - duplicate, p. Push, p, and return the duplicate.
+ makeUnary - create a unary expression node with, e, as the argument
+ and res as the return type.
*/
-extern "C" mcPretty_pretty mcPretty_pushPretty (mcPretty_pretty p);
+static decl_node__opaque makeUnary (decl_nodeT k, decl_node__opaque e, decl_node__opaque res);
/*
- popPretty - pops the pretty object from the stack.
+ isLeafString - returns TRUE if n is a leaf node which is a string constant.
*/
-extern "C" mcPretty_pretty mcPretty_popPretty (mcPretty_pretty p);
+static bool isLeafString (decl_node__opaque n);
/*
- getindent - returns the current indent value.
+ getLiteralStringContents - return the contents of a literal node as a string.
*/
-extern "C" unsigned int mcPretty_getindent (mcPretty_pretty p);
+static DynamicStrings_String getLiteralStringContents (decl_node__opaque n);
/*
- setindent - sets the current indent to, n.
+ getStringContents - return the string contents of a constant, literal,
+ string or a constexp node.
*/
-extern "C" void mcPretty_setindent (mcPretty_pretty p, unsigned int n);
+static DynamicStrings_String getStringContents (decl_node__opaque n);
/*
- getcurpos - returns the current cursor position.
+ addNames -
*/
-extern "C" unsigned int mcPretty_getcurpos (mcPretty_pretty s);
+static nameKey_Name addNames (decl_node__opaque a, decl_node__opaque b);
/*
- getseekpos - returns the seek position.
+ resolveString -
*/
-extern "C" unsigned int mcPretty_getseekpos (mcPretty_pretty s);
+static decl_node__opaque resolveString (decl_node__opaque n);
/*
- getcurline - returns the current line number.
+ foldBinary -
*/
-extern "C" unsigned int mcPretty_getcurline (mcPretty_pretty s);
-extern "C" void mcPretty_setNeedSpace (mcPretty_pretty s);
+static decl_node__opaque foldBinary (decl_nodeT k, decl_node__opaque l, decl_node__opaque r, decl_node__opaque res);
/*
- noSpace - unset needsSpace.
+ makeBinary - create a binary node with left/right/result type: l, r and resultType.
*/
-extern "C" void mcPretty_noSpace (mcPretty_pretty s);
+static decl_node__opaque makeBinary (decl_nodeT k, decl_node__opaque l, decl_node__opaque r, decl_node__opaque resultType);
/*
- print - print a string using, p.
+ doMakeBinary - returns a binary node containing left/right/result values
+ l, r, res, with a node operator, k.
*/
-extern "C" void mcPretty_print (mcPretty_pretty p, const char *a_, unsigned int _a_high);
+static decl_node__opaque doMakeBinary (decl_nodeT k, decl_node__opaque l, decl_node__opaque r, decl_node__opaque res);
/*
- prints - print a string using, p.
+ doMakeComponentRef -
*/
-extern "C" void mcPretty_prints (mcPretty_pretty p, DynamicStrings_String s);
+static decl_node__opaque doMakeComponentRef (decl_node__opaque rec, decl_node__opaque field);
/*
- raw - print out string, s, without any translation of
- escape sequences.
+ isComponentRef -
*/
-extern "C" void mcPretty_raw (mcPretty_pretty p, DynamicStrings_String s);
+static bool isComponentRef (decl_node__opaque n);
/*
- InitIndex - creates and returns an Index.
+ isArrayRef - returns TRUE if the node was an arrayref.
*/
-extern "C" Indexing_Index Indexing_InitIndex (unsigned int low);
+static bool isArrayRef (decl_node__opaque n);
/*
- KillIndex - returns Index to free storage.
+ isDeref - returns TRUE if, n, is a deref node.
*/
-extern "C" Indexing_Index Indexing_KillIndex (Indexing_Index i);
+static bool isDeref (decl_node__opaque n);
/*
- DebugIndex - turns on debugging within an index.
+ makeBase - create a base type or constant.
+ It only supports the base types and constants
+ enumerated below.
*/
-extern "C" Indexing_Index Indexing_DebugIndex (Indexing_Index i);
+static decl_node__opaque makeBase (decl_nodeT k);
/*
- InBounds - returns TRUE if indice, n, is within the bounds
- of the dynamic array.
+ isOrdinal - returns TRUE if, n, is an ordinal type.
*/
-extern "C" bool Indexing_InBounds (Indexing_Index i, unsigned int n);
+static bool isOrdinal (decl_node__opaque n);
/*
- HighIndice - returns the last legally accessible indice of this array.
+ mixTypes -
*/
-extern "C" unsigned int Indexing_HighIndice (Indexing_Index i);
+static decl_node__opaque mixTypes (decl_node__opaque a, decl_node__opaque b);
/*
- LowIndice - returns the first legally accessible indice of this array.
+ doSetExprType -
*/
-extern "C" unsigned int Indexing_LowIndice (Indexing_Index i);
+static decl_node__opaque doSetExprType (decl_node__opaque *t, decl_node__opaque n);
/*
- PutIndice - places, a, into the dynamic array at position i[n]
+ getMaxMinType -
*/
-extern "C" void Indexing_PutIndice (Indexing_Index i, unsigned int n, void * a);
+static decl_node__opaque getMaxMinType (decl_node__opaque n);
/*
- GetIndice - retrieves, element i[n] from the dynamic array.
+ doGetFuncType -
*/
-extern "C" void * Indexing_GetIndice (Indexing_Index i, unsigned int n);
+static decl_node__opaque doGetFuncType (decl_node__opaque n);
/*
- IsIndiceInIndex - returns TRUE if, a, is in the index, i.
+ doGetExprType - works out the type which is associated with node, n.
*/
-extern "C" bool Indexing_IsIndiceInIndex (Indexing_Index i, void * a);
+static decl_node__opaque doGetExprType (decl_node__opaque n);
/*
- RemoveIndiceFromIndex - removes, a, from Index, i.
+ getExprType - return the expression type.
*/
-extern "C" void Indexing_RemoveIndiceFromIndex (Indexing_Index i, void * a);
+static decl_node__opaque getExprType (decl_node__opaque n);
/*
- DeleteIndice - delete i[j] from the array.
+ openOutput -
*/
-extern "C" void Indexing_DeleteIndice (Indexing_Index i, unsigned int j);
+static void openOutput (void);
/*
- IncludeIndiceIntoIndex - if the indice is not in the index, then
- add it at the end.
+ closeOutput -
*/
-extern "C" void Indexing_IncludeIndiceIntoIndex (Indexing_Index i, void * a);
+static void closeOutput (void);
/*
- ForeachIndiceInIndexDo - for each j indice of i, call procedure p(i[j])
+ write - outputs a single char, ch.
*/
-extern "C" void Indexing_ForeachIndiceInIndexDo (Indexing_Index i, Indexing_IndexProcedure p);
+static void write_ (char ch);
/*
- initList - creates a new alist, l.
+ writeln -
*/
-extern "C" alists_alist alists_initList (void);
+static void writeln (void);
/*
- killList - deletes the complete alist, l.
+ doIncludeC - include header file for definition module, n.
*/
-extern "C" void alists_killList (alists_alist *l);
+static void doIncludeC (decl_node__opaque n);
/*
- putItemIntoList - places an ADDRESS, c, into alist, l.
+ getSymScope - returns the scope where node, n, was declared.
*/
-extern "C" void alists_putItemIntoList (alists_alist l, void * c);
+static decl_node__opaque getSymScope (decl_node__opaque n);
/*
- getItemFromList - retrieves the nth WORD from alist, l.
+ isQualifiedForced - should the node be written with a module prefix?
*/
-extern "C" void * alists_getItemFromList (alists_alist l, unsigned int n);
+static bool isQualifiedForced (decl_node__opaque n);
/*
- getIndexOfList - returns the index for WORD, c, in alist, l.
- If more than one WORD, c, exists the index
- for the first is returned.
+ getFQstring -
*/
-extern "C" unsigned int alists_getIndexOfList (alists_alist l, void * c);
+static DynamicStrings_String getFQstring (decl_node__opaque n);
/*
- noOfItemsInList - returns the number of items in alist, l.
+ getFQDstring -
*/
-extern "C" unsigned int alists_noOfItemsInList (alists_alist l);
+static DynamicStrings_String getFQDstring (decl_node__opaque n, bool scopes);
/*
- includeItemIntoList - adds an ADDRESS, c, into a alist providing
- the value does not already exist.
+ getString - returns the name as a string.
*/
-extern "C" void alists_includeItemIntoList (alists_alist l, void * c);
+static DynamicStrings_String getString (decl_node__opaque n);
/*
- removeItemFromList - removes a ADDRESS, c, from a alist.
- It assumes that this value only appears once.
+ doNone - call HALT.
*/
-extern "C" void alists_removeItemFromList (alists_alist l, void * c);
+static void doNone (decl_node__opaque n);
/*
- isItemInList - returns true if a ADDRESS, c, was found in alist, l.
+ doNothing - does nothing!
*/
-extern "C" bool alists_isItemInList (alists_alist l, void * c);
+static void doNothing (decl_node__opaque n);
/*
- foreachItemInListDo - calls procedure, P, foreach item in alist, l.
+ doConstC -
*/
-extern "C" void alists_foreachItemInListDo (alists_alist l, alists_performOperation p);
+static void doConstC (decl_node__opaque n);
/*
- duplicateList - returns a duplicate alist derived from, l.
+ needsParen - returns TRUE if expression, n, needs to be enclosed in ().
*/
-extern "C" alists_alist alists_duplicateList (alists_alist l);
+static bool needsParen (decl_node__opaque n);
/*
- equalList - returns TRUE if left contains the same information as right.
+ doUnary -
*/
-extern "C" bool alists_equalList (alists_alist left, alists_alist right);
+static void doUnary (mcPretty_pretty p, const char *op_, unsigned int _op_high, decl_node__opaque expr, decl_node__opaque type, bool l, bool r);
/*
- initList - creates a new wlist, l.
+ doSetSub - perform l & (~ r)
*/
-extern "C" wlists_wlist wlists_initList (void);
+static void doSetSub (mcPretty_pretty p, decl_node__opaque left, decl_node__opaque right);
/*
- killList - deletes the complete wlist, l.
+ doPolyBinary -
*/
-extern "C" void wlists_killList (wlists_wlist *l);
+static void doPolyBinary (mcPretty_pretty p, decl_nodeT op, decl_node__opaque left, decl_node__opaque right, bool l, bool r);
/*
- putItemIntoList - places an WORD, c, into wlist, l.
+ doBinary -
*/
-extern "C" void wlists_putItemIntoList (wlists_wlist l, unsigned int c);
+static void doBinary (mcPretty_pretty p, const char *op_, unsigned int _op_high, decl_node__opaque left, decl_node__opaque right, bool l, bool r, bool unpackProc);
/*
- getItemFromList - retrieves the nth WORD from wlist, l.
+ doPostUnary -
*/
-extern "C" unsigned int wlists_getItemFromList (wlists_wlist l, unsigned int n);
+static void doPostUnary (mcPretty_pretty p, const char *op_, unsigned int _op_high, decl_node__opaque expr);
/*
- getIndexOfList - returns the index for WORD, c, in wlist, l.
- If more than one WORD, c, exists the index
- for the first is returned.
+ doDeRefC -
*/
-extern "C" unsigned int wlists_getIndexOfList (wlists_wlist l, unsigned int c);
+static decl_node__opaque doDeRefC (mcPretty_pretty p, decl_node__opaque expr);
/*
- noOfItemsInList - returns the number of items in wlist, l.
+ doGetLastOp - returns, a, if b is a terminal otherwise walk right.
*/
-extern "C" unsigned int wlists_noOfItemsInList (wlists_wlist l);
+static decl_node__opaque doGetLastOp (decl_node__opaque a, decl_node__opaque b);
/*
- includeItemIntoList - adds an WORD, c, into a wlist providing
- the value does not already exist.
+ doComponentRefC -
*/
-extern "C" void wlists_includeItemIntoList (wlists_wlist l, unsigned int c);
+static void doComponentRefC (mcPretty_pretty p, decl_node__opaque l, decl_node__opaque r);
/*
- removeItemFromList - removes a WORD, c, from a wlist.
- It assumes that this value only appears once.
+ doPointerRefC -
*/
-extern "C" void wlists_removeItemFromList (wlists_wlist l, unsigned int c);
+static void doPointerRefC (mcPretty_pretty p, decl_node__opaque l, decl_node__opaque r);
/*
- replaceItemInList - replace the nth WORD in wlist, l.
- The first item in a wlists is at index, 1.
- If the index, n, is out of range nothing is changed.
+ doPreBinary -
*/
-extern "C" void wlists_replaceItemInList (wlists_wlist l, unsigned int n, unsigned int w);
+static void doPreBinary (mcPretty_pretty p, const char *op_, unsigned int _op_high, decl_node__opaque left, decl_node__opaque right, bool l, bool r);
/*
- isItemInList - returns true if a WORD, c, was found in wlist, l.
+ doConstExpr -
*/
-extern "C" bool wlists_isItemInList (wlists_wlist l, unsigned int c);
+static void doConstExpr (mcPretty_pretty p, decl_node__opaque n);
/*
- foreachItemInListDo - calls procedure, P, foreach item in wlist, l.
+ doEnumerationField -
*/
-extern "C" void wlists_foreachItemInListDo (wlists_wlist l, wlists_performOperation p);
+static void doEnumerationField (mcPretty_pretty p, decl_node__opaque n);
/*
- duplicateList - returns a duplicate wlist derived from, l.
+ isZero - returns TRUE if node, n, is zero.
*/
-extern "C" wlists_wlist wlists_duplicateList (wlists_wlist l);
-extern "C" void keyc_useUnistd (void);
-extern "C" void keyc_useThrow (void);
-extern "C" void keyc_useStorage (void);
-extern "C" void keyc_useFree (void);
-extern "C" void keyc_useMalloc (void);
-extern "C" void keyc_useProc (void);
-extern "C" void keyc_useTrue (void);
-extern "C" void keyc_useFalse (void);
-extern "C" void keyc_useNull (void);
-extern "C" void keyc_useMemcpy (void);
-extern "C" void keyc_useIntMin (void);
-extern "C" void keyc_useUIntMin (void);
-extern "C" void keyc_useLongMin (void);
-extern "C" void keyc_useULongMin (void);
-extern "C" void keyc_useCharMin (void);
-extern "C" void keyc_useUCharMin (void);
-extern "C" void keyc_useIntMax (void);
-extern "C" void keyc_useUIntMax (void);
-extern "C" void keyc_useLongMax (void);
-extern "C" void keyc_useULongMax (void);
-extern "C" void keyc_useCharMax (void);
-extern "C" void keyc_useUCharMax (void);
-extern "C" void keyc_useSize_t (void);
-extern "C" void keyc_useSSize_t (void);
-extern "C" void keyc_useLabs (void);
-extern "C" void keyc_useAbs (void);
-extern "C" void keyc_useFabs (void);
-extern "C" void keyc_useFabsl (void);
-extern "C" void keyc_useException (void);
-extern "C" void keyc_useComplex (void);
-extern "C" void keyc_useM2RTS (void);
-extern "C" void keyc_useStrlen (void);
-extern "C" void keyc_useCtype (void);
-extern "C" void keyc_genDefs (mcPretty_pretty p);
-extern "C" void keyc_genConfigSystem (mcPretty_pretty p);
-extern "C" void keyc_enterScope (decl_node n);
-extern "C" void keyc_leaveScope (decl_node n);
-extern "C" DynamicStrings_String keyc_cname (nameKey_Name n, bool scopes);
-extern "C" nameKey_Name keyc_cnamen (nameKey_Name n, bool scopes);
-extern "C" void keyc_cp (void);
-extern "C" FIO_File mcStream_openFrag (unsigned int id);
-extern "C" void mcStream_setDest (FIO_File f);
-extern "C" FIO_File mcStream_combine (void);
-extern "C" void mcStream_removeFiles (void);
-extern "C" void StrIO_WriteLn (void);
-extern "C" void StrIO_ReadString (char *a, unsigned int _a_high);
-extern "C" void StrIO_WriteString (const char *a_, unsigned int _a_high);
-extern "C" void NumberIO_ReadCard (unsigned int *x);
-extern "C" void NumberIO_WriteCard (unsigned int x, unsigned int n);
-extern "C" void NumberIO_ReadHex (unsigned int *x);
-extern "C" void NumberIO_WriteHex (unsigned int x, unsigned int n);
-extern "C" void NumberIO_ReadInt (int *x);
-extern "C" void NumberIO_WriteInt (int x, unsigned int n);
-extern "C" void NumberIO_CardToStr (unsigned int x, unsigned int n, char *a, unsigned int _a_high);
-extern "C" void NumberIO_StrToCard (const char *a_, unsigned int _a_high, unsigned int *x);
-extern "C" void NumberIO_HexToStr (unsigned int x, unsigned int n, char *a, unsigned int _a_high);
-extern "C" void NumberIO_StrToHex (const char *a_, unsigned int _a_high, unsigned int *x);
-extern "C" void NumberIO_IntToStr (int x, unsigned int n, char *a, unsigned int _a_high);
-extern "C" void NumberIO_StrToInt (const char *a_, unsigned int _a_high, int *x);
-extern "C" void NumberIO_ReadOct (unsigned int *x);
-extern "C" void NumberIO_WriteOct (unsigned int x, unsigned int n);
-extern "C" void NumberIO_OctToStr (unsigned int x, unsigned int n, char *a, unsigned int _a_high);
-extern "C" void NumberIO_StrToOct (const char *a_, unsigned int _a_high, unsigned int *x);
-extern "C" void NumberIO_ReadBin (unsigned int *x);
-extern "C" void NumberIO_WriteBin (unsigned int x, unsigned int n);
-extern "C" void NumberIO_BinToStr (unsigned int x, unsigned int n, char *a, unsigned int _a_high);
-extern "C" void NumberIO_StrToBin (const char *a_, unsigned int _a_high, unsigned int *x);
-extern "C" void NumberIO_StrToBinInt (const char *a_, unsigned int _a_high, int *x);
-extern "C" void NumberIO_StrToHexInt (const char *a_, unsigned int _a_high, int *x);
-extern "C" void NumberIO_StrToOctInt (const char *a_, unsigned int _a_high, int *x);
-extern "C" void Debug_Halt (const char *Message_, unsigned int _Message_high, const char *Module_, unsigned int _Module_high, const char *Function_, unsigned int _Function_high, unsigned int LineNo);
-extern "C" void Debug_DebugString (const char *a_, unsigned int _a_high);
-extern "C" void Assertion_Assert (bool Condition);
-extern "C" void StdIO_Read (char *ch);
-extern "C" void StdIO_Write (char ch);
-extern "C" void StdIO_PushOutput (StdIO_ProcWrite p);
-extern "C" void StdIO_PopOutput (void);
-extern "C" StdIO_ProcWrite StdIO_GetCurrentOutput (void);
-extern "C" void StdIO_PushInput (StdIO_ProcRead p);
-extern "C" void StdIO_PopInput (void);
-extern "C" StdIO_ProcRead StdIO_GetCurrentInput (void);
-extern "C" void mcPrintf_printf0 (const char *a_, unsigned int _a_high);
-extern "C" void mcPrintf_printf1 (const char *a_, unsigned int _a_high, const unsigned char *w_, unsigned int _w_high);
-extern "C" void mcPrintf_printf2 (const char *a_, unsigned int _a_high, const unsigned char *w1_, unsigned int _w1_high, const unsigned char *w2_, unsigned int _w2_high);
-extern "C" void mcPrintf_printf3 (const char *a_, unsigned int _a_high, const unsigned char *w1_, unsigned int _w1_high, const unsigned char *w2_, unsigned int _w2_high, const unsigned char *w3_, unsigned int _w3_high);
-extern "C" void mcPrintf_printf4 (const char *a_, unsigned int _a_high, const unsigned char *w1_, unsigned int _w1_high, const unsigned char *w2_, unsigned int _w2_high, const unsigned char *w3_, unsigned int _w3_high, const unsigned char *w4_, unsigned int _w4_high);
-extern "C" void mcPrintf_fprintf0 (FIO_File file, const char *a_, unsigned int _a_high);
-extern "C" void mcPrintf_fprintf1 (FIO_File file, const char *a_, unsigned int _a_high, const unsigned char *w_, unsigned int _w_high);
-extern "C" void mcPrintf_fprintf2 (FIO_File file, const char *a_, unsigned int _a_high, const unsigned char *w1_, unsigned int _w1_high, const unsigned char *w2_, unsigned int _w2_high);
-extern "C" void mcPrintf_fprintf3 (FIO_File file, const char *a_, unsigned int _a_high, const unsigned char *w1_, unsigned int _w1_high, const unsigned char *w2_, unsigned int _w2_high, const unsigned char *w3_, unsigned int _w3_high);
-extern "C" void mcPrintf_fprintf4 (FIO_File file, const char *a_, unsigned int _a_high, const unsigned char *w1_, unsigned int _w1_high, const unsigned char *w2_, unsigned int _w2_high, const unsigned char *w3_, unsigned int _w3_high, const unsigned char *w4_, unsigned int _w4_high);
+static bool isZero (decl_node__opaque n);
/*
- newNode - create and return a new node of kind k.
+ doArrayRef - perform an array reference. If constCast
+ then an unbounded array access will be const_cast
+ (the constCast should be TRUE if an assignment to
+ the array is required).
*/
-static decl_node newNode (decl_nodeT k);
+static void doArrayRef (mcPretty_pretty p, decl_node__opaque n, bool constCast);
/*
- disposeNode - dispose node, n.
+ doProcedure -
*/
-static void disposeNode (decl_node *n);
+static void doProcedure (mcPretty_pretty p, decl_node__opaque n);
/*
- newGroup -
+ doRecordfield -
*/
-static void newGroup (decl_group *g);
+static void doRecordfield (mcPretty_pretty p, decl_node__opaque n);
/*
- initGroup - returns a group which with all lists initialized.
+ doCastC -
*/
-static decl_group initGroup (void);
+static void doCastC (mcPretty_pretty p, decl_node__opaque t, decl_node__opaque e);
/*
- killGroup - deallocate the group and place the group record into the freeGroup list.
+ doSetValueC -
*/
-static void killGroup (decl_group *g);
+static void doSetValueC (mcPretty_pretty p, decl_node__opaque n);
/*
- dupGroup - If g is not NIL then destroy g.
- Return a duplicate of GlobalGroup (not g).
+ getSetLow - returns the low value of the set type from
+ expression, n.
*/
-static decl_group dupGroup (decl_group g);
+static decl_node__opaque getSetLow (decl_node__opaque n);
/*
- equalGroup - return TRUE if group left = right.
+ doInC - performs (((1 << (l)) & (r)) != 0)
*/
-static bool equalGroup (decl_group left, decl_group right);
+static void doInC (mcPretty_pretty p, decl_node__opaque l, decl_node__opaque r);
/*
- isLocal - returns TRUE if symbol, n, is locally declared in a procedure.
+ doThrowC -
*/
-static bool isLocal (decl_node n);
+static void doThrowC (mcPretty_pretty p, decl_node__opaque n);
/*
- importEnumFields - if, n, is an enumeration type import the all fields into module, m.
+ doUnreachableC -
*/
-static void importEnumFields (decl_node m, decl_node n);
+static void doUnreachableC (mcPretty_pretty p, decl_node__opaque n);
/*
- isComplex - returns TRUE if, n, is the complex type.
+ outNull -
*/
-static bool isComplex (decl_node n);
+static void outNull (mcPretty_pretty p);
/*
- isLongComplex - returns TRUE if, n, is the longcomplex type.
+ outTrue -
*/
-static bool isLongComplex (decl_node n);
+static void outTrue (mcPretty_pretty p);
/*
- isShortComplex - returns TRUE if, n, is the shortcomplex type.
+ outFalse -
*/
-static bool isShortComplex (decl_node n);
+static void outFalse (mcPretty_pretty p);
/*
- isAProcType - returns TRUE if, n, is a proctype or proc node.
+ doExprC -
*/
-static bool isAProcType (decl_node n);
+static void doExprC (mcPretty_pretty p, decl_node__opaque n);
/*
- initFixupInfo - initialize the fixupInfo record.
+ doExprCup -
*/
-static decl_fixupInfo initFixupInfo (void);
+static decl_node__opaque doExprCup (mcPretty_pretty p, decl_node__opaque n, bool unpackProc, bool uncastConst);
/*
- makeDef - returns a definition module node named, n.
+ doExprM2 -
*/
-static decl_node makeDef (nameKey_Name n);
+static void doExprM2 (mcPretty_pretty p, decl_node__opaque n);
/*
- makeImp - returns an implementation module node named, n.
+ doVar -
*/
-static decl_node makeImp (nameKey_Name n);
+static void doVar (mcPretty_pretty p, decl_node__opaque n);
/*
- makeModule - returns a module node named, n.
+ doLiteralC -
*/
-static decl_node makeModule (nameKey_Name n);
+static void doLiteralC (mcPretty_pretty p, decl_node__opaque n);
/*
- isDefForC - returns TRUE if the definition module was defined FOR "C".
+ doLiteral -
*/
-static bool isDefForC (decl_node n);
+static void doLiteral (mcPretty_pretty p, decl_node__opaque n);
/*
- initDecls - initialize the decls, scopeT.
+ isString - returns TRUE if node, n, is a string.
*/
-static void initDecls (decl_scopeT *decls);
+static bool isString (decl_node__opaque n);
/*
- addTo - adds node, d, to scope decls and returns, d.
- It stores, d, in the symbols tree associated with decls.
+ doString -
*/
-static decl_node addTo (decl_scopeT *decls, decl_node d);
+static void doString (mcPretty_pretty p, decl_node__opaque n);
/*
- export - export node, n, from definition module, d.
+ replaceChar - replace every occurance of, ch, by, a and return modified string, s.
*/
-static void export_ (decl_node d, decl_node n);
+static DynamicStrings_String replaceChar (DynamicStrings_String s, char ch, const char *a_, unsigned int _a_high);
/*
- addToScope - adds node, n, to the current scope and returns, n.
+ toCstring - translates string, n, into a C string
+ and returns the new String.
*/
-static decl_node addToScope (decl_node n);
+static DynamicStrings_String toCstring (nameKey_Name n);
/*
- addModuleToScope - adds module, i, to module, m, scope.
+ toCchar -
*/
-static void addModuleToScope (decl_node m, decl_node i);
+static DynamicStrings_String toCchar (nameKey_Name n);
/*
- completedEnum - assign boolean enumsComplete to TRUE if a definition,
- implementation or module symbol.
+ countChar -
*/
-static void completedEnum (decl_node n);
+static unsigned int countChar (DynamicStrings_String s, char ch);
/*
- setUnary - sets a unary node to contain, arg, a, and type, t.
+ lenCstring -
*/
-static void setUnary (decl_node u, decl_nodeT k, decl_node a, decl_node t);
+static unsigned int lenCstring (DynamicStrings_String s);
/*
- putVarBool - assigns the four booleans associated with a variable.
+ outCstring -
*/
-static void putVarBool (decl_node v, bool init, bool param, bool isvar, bool isused);
+static void outCstring (mcPretty_pretty p, decl_node__opaque s, bool aString);
/*
- checkPtr - in C++ we need to create a typedef for a pointer
- in case we need to use reinterpret_cast.
+ doStringC -
*/
-static decl_node checkPtr (decl_node n);
+static void doStringC (mcPretty_pretty p, decl_node__opaque n);
/*
- isVarDecl - returns TRUE if, n, is a vardecl node.
+ isPunct -
*/
-static bool isVarDecl (decl_node n);
+static bool isPunct (char ch);
/*
- makeVariablesFromParameters - creates variables which are really parameters.
+ isWhite -
*/
-static void makeVariablesFromParameters (decl_node proc, decl_node id, decl_node type, bool isvar, bool isused);
+static bool isWhite (char ch);
/*
- addProcedureToScope - add a procedure name n and node d to the
- current scope.
+ outText -
*/
-static decl_node addProcedureToScope (decl_node d, nameKey_Name n);
+static void outText (mcPretty_pretty p, const char *a_, unsigned int _a_high);
/*
- putProcTypeReturn - sets the return type of, proc, to, type.
+ outRawS -
*/
-static void putProcTypeReturn (decl_node proc, decl_node type);
+static void outRawS (mcPretty_pretty p, DynamicStrings_String s);
/*
- putProcTypeOptReturn - sets, proc, to have an optional return type.
+ outKm2 -
*/
-static void putProcTypeOptReturn (decl_node proc);
+static mcPretty_pretty outKm2 (mcPretty_pretty p, const char *a_, unsigned int _a_high);
/*
- makeOptParameter - creates and returns an optarg.
+ outKc -
*/
-static decl_node makeOptParameter (decl_node l, decl_node type, decl_node init);
+static mcPretty_pretty outKc (mcPretty_pretty p, const char *a_, unsigned int _a_high);
/*
- setwatch - assign the globalNode to n.
+ outTextS -
*/
-static bool setwatch (decl_node n);
+static void outTextS (mcPretty_pretty p, DynamicStrings_String s);
/*
- runwatch - set the globalNode to an identlist.
+ outCard -
*/
-static bool runwatch (void);
+static void outCard (mcPretty_pretty p, unsigned int c);
/*
- isIdentList - returns TRUE if, n, is an identlist.
+ outTextN -
*/
-static bool isIdentList (decl_node n);
+static void outTextN (mcPretty_pretty p, nameKey_Name n);
/*
- identListLen - returns the length of identlist.
+ outputEnumerationC -
*/
-static unsigned int identListLen (decl_node n);
+static void outputEnumerationC (mcPretty_pretty p, decl_node__opaque n);
/*
- checkParameters - placeholder for future parameter checking.
+ isDeclType - return TRUE if the current module should declare type.
*/
-static void checkParameters (decl_node p, decl_node i, decl_node type, bool isvar, bool isused);
+static bool isDeclType (decl_node__opaque type);
/*
- checkMakeVariables - create shadow local variables for parameters providing that
- procedure n has not already been built and we are compiling
- a module or an implementation module.
+ doEnumerationC -
*/
-static void checkMakeVariables (decl_node n, decl_node i, decl_node type, bool isvar, bool isused);
+static void doEnumerationC (mcPretty_pretty p, decl_node__opaque n);
/*
- makeVarientField - create a varient field within varient, v,
- The new varient field is returned.
+ doNamesC -
*/
-static decl_node makeVarientField (decl_node v, decl_node p);
+static void doNamesC (mcPretty_pretty p, nameKey_Name n);
/*
- putFieldVarient - places the field varient, f, as a brother to, the
- varient symbol, v, and also tells, f, that its varient
- parent is, v.
+ doNameC -
*/
-static void putFieldVarient (decl_node f, decl_node v);
+static void doNameC (mcPretty_pretty p, decl_node__opaque n);
/*
- putFieldRecord - create a new recordfield and place it into record r.
- The new field has a tagname and type and can have a
- variant field v.
+ initCname -
*/
-static decl_node putFieldRecord (decl_node r, nameKey_Name tag, decl_node type, decl_node v);
+static void initCname (decl_cnameT *c);
/*
- ensureOrder - ensures that, a, and, b, exist in, i, and also
- ensure that, a, is before, b.
+ doCname -
*/
-static void ensureOrder (Indexing_Index i, decl_node a, decl_node b);
+static nameKey_Name doCname (nameKey_Name n, decl_cnameT *c, bool scopes);
/*
- putVarientTag - places tag into variant v.
+ getDName -
*/
-static void putVarientTag (decl_node v, decl_node tag);
+static nameKey_Name getDName (decl_node__opaque n, bool scopes);
/*
- getParent - returns the parent field of recordfield or varientfield symbol, n.
+ doDNameC -
*/
-static decl_node getParent (decl_node n);
+static void doDNameC (mcPretty_pretty p, decl_node__opaque n, bool scopes);
/*
- getRecord - returns the record associated with node, n.
- (Parental record).
+ doFQDNameC -
*/
-static decl_node getRecord (decl_node n);
+static void doFQDNameC (mcPretty_pretty p, decl_node__opaque n, bool scopes);
/*
- isConstExp - return TRUE if the node kind is a constexp.
+ doFQNameC -
*/
-static bool isConstExp (decl_node c);
+static void doFQNameC (mcPretty_pretty p, decl_node__opaque n);
/*
- addEnumToModule - adds enumeration type, e, into the list of enums
- in module, m.
+ doNameM2 -
*/
-static void addEnumToModule (decl_node m, decl_node e);
+static void doNameM2 (mcPretty_pretty p, decl_node__opaque n);
/*
- getNextFixup - return the next fixup from from f.
+ doUsed -
*/
-static decl_node getNextFixup (decl_fixupInfo *f);
+static void doUsed (mcPretty_pretty p, bool used);
/*
- doMakeEnum - create an enumeration type and add it to the current module.
+ doHighC -
*/
-static decl_node doMakeEnum (void);
+static void doHighC (mcPretty_pretty p, decl_node__opaque a, nameKey_Name n, bool isused);
/*
- doMakeEnumField - create an enumeration field name and add it to enumeration e.
- Return the new field.
+ doParamConstCast -
*/
-static decl_node doMakeEnumField (decl_node e, nameKey_Name n);
+static void doParamConstCast (mcPretty_pretty p, decl_node__opaque n);
/*
- getExpList - returns the, n, th argument in an explist.
+ getParameterVariable - returns the variable which shadows the parameter
+ named, m, in parameter block, n.
*/
-static decl_node getExpList (decl_node p, unsigned int n);
+static decl_node__opaque getParameterVariable (decl_node__opaque n, nameKey_Name m);
/*
- expListLen - returns the length of explist, p.
+ doParamTypeEmit - emit parameter type for C/C++. It checks to see if the
+ parameter type is a procedure type and if it were declared
+ in a definition module for "C" and if so it uses the "C"
+ definition for a procedure type, rather than the mc
+ C++ version.
*/
-static unsigned int expListLen (decl_node p);
+static void doParamTypeEmit (mcPretty_pretty p, decl_node__opaque paramnode, decl_node__opaque paramtype);
/*
- getConstExpComplete - gets the field from the def or imp or module, n.
+ doParamTypeNameModifier - Add an _ to an unbounded parameter which is non var.
*/
-static bool getConstExpComplete (decl_node n);
+static void doParamTypeNameModifier (mcPretty_pretty p, decl_node__opaque ptype, bool varparam);
/*
- addConstToModule - adds const exp, e, into the list of constant
- expressions in module, m.
+ initOpaqueCastState - assign fields opaque and voidstar in opaquestate.
*/
-static void addConstToModule (decl_node m, decl_node e);
+static void initOpaqueCastState (decl_opaqueCastState *opaquestate, bool opaque, bool voidstar);
/*
- doMakeConstExp - create a constexp node and add it to the current module.
+ initNodeOpaqueCastState - assign opaque and currentvoidstar
*/
-static decl_node doMakeConstExp (void);
+static void initNodeOpaqueCastState (decl_node__opaque n, bool opaque, bool voidstar);
/*
- isAnyType - return TRUE if node n is any type kind.
+ setOpaqueCastState - set the voidStar field in opaquestate.
*/
-static bool isAnyType (decl_node n);
+static void setOpaqueCastState (decl_opaqueCastState *opaquestate, bool voidstar);
/*
- makeVal - creates a VAL (type, expression) node.
+ setNodeOpaqueVoidStar - sets the voidStar field in node to voidstar.
*/
-static decl_node makeVal (decl_node params);
+static void setNodeOpaqueVoidStar (decl_node__opaque n, bool voidstar);
/*
- makeCast - creates a cast node TYPENAME (expr).
+ nodeUsesOpaque - return TRUE if node n uses an opaque type.
*/
-static decl_node makeCast (decl_node c, decl_node p);
-static decl_node makeIntrinsicProc (decl_nodeT k, unsigned int noArgs, decl_node p);
+static bool nodeUsesOpaque (decl_node__opaque n);
/*
- makeIntrinsicUnaryType - create an intrisic unary type.
+ getNodeOpaqueVoidStar - return TRUE if the opaque type used by node n is a void *.
*/
-static decl_node makeIntrinsicUnaryType (decl_nodeT k, decl_node paramList, decl_node returnType);
+static bool getNodeOpaqueVoidStar (decl_node__opaque n);
/*
- makeIntrinsicBinaryType - create an intrisic binary type.
+ getOpaqueFlushNecessary - return TRUE if the value next differs from the opaque state.
*/
-static decl_node makeIntrinsicBinaryType (decl_nodeT k, decl_node paramList, decl_node returnType);
+static bool getOpaqueFlushNecessary (decl_opaqueCastState state, bool next);
/*
- checkIntrinsic - checks to see if the function call to, c, with
- parameter list, n, is really an intrinic. If it
- is an intrinic then an intrinic node is created
- and returned. Otherwise NIL is returned.
+ getNodeOpaqueFlushNecessary - return TRUE if the value of next requires a cast.
*/
-static decl_node checkIntrinsic (decl_node c, decl_node n);
+static bool getNodeOpaqueFlushNecessary (decl_node__opaque n, bool next);
/*
- checkCHeaders - check to see if the function is a C system function and
- requires a header file included.
+ makeOpaqueCast - wrap node n with an opaquecast node and assign
+ voidstar into the new opaque state.
*/
-static void checkCHeaders (decl_node c);
+static decl_node__opaque makeOpaqueCast (decl_node__opaque n, bool voidstar);
/*
- isFuncCall - returns TRUE if, n, is a function/procedure call.
+ flushOpaque - perform a cast to voidstar (if necessary) and ignore the new
+ node which could be created.
*/
-static bool isFuncCall (decl_node n);
+static void flushOpaque (mcPretty_pretty p, decl_node__opaque n, bool toVoidStar);
/*
- putTypeInternal - marks type, des, as being an internally generated type.
+ castOpaque - flushes the opaque type casts if necessary and changes the
+ voidstar boolean value. If necessary it creates a opaquecast
+ and returns the new node otherwise return n.
*/
-static void putTypeInternal (decl_node des);
+static decl_node__opaque castOpaque (mcPretty_pretty p, decl_node__opaque n, bool toVoidStar);
/*
- isTypeInternal - returns TRUE if type, n, is internal.
+ isTypeOpaqueDefImp - returns TRUE if type is an opaque type by checking
+ the def/imp pair of modules or fall back to the
+ definition module.
*/
-static bool isTypeInternal (decl_node n);
+static bool isTypeOpaqueDefImp (decl_node__opaque type);
/*
- lookupBase - return node named n from the base symbol scope.
+ isParamVoidStar - return TRUE if the procedure or proctype opaque type
+ parameter should be implemented as a (void * ).
*/
-static decl_node lookupBase (nameKey_Name n);
+static bool isParamVoidStar (decl_node__opaque n);
/*
- dumpScopes - display the names of all the scopes stacked.
+ isRefVoidStar - returns TRUE if the ref node uses an opaque type which
+ is represented as a (void * ).
*/
-static void dumpScopes (void);
+static bool isRefVoidStar (decl_node__opaque n);
/*
- out0 - write string a to StdOut.
+ isReturnVoidStar - return TRUE if the procedure or proctype opaque type
+ return type should be implemented as a (void * ).
*/
-static void out0 (const char *a_, unsigned int _a_high);
+static bool isReturnVoidStar (decl_node__opaque proc, decl_node__opaque type);
/*
- out1 - write string a to StdOut using format specifier a.
+ isVarVoidStar - return TRUE if the variable using an opaque type should
+ be implemented as a (void * ).
*/
-static void out1 (const char *a_, unsigned int _a_high, decl_node s);
+static bool isVarVoidStar (decl_node__opaque n);
/*
- out2 - write string a to StdOut using format specifier a.
+ initNodeOpaqueState - initialize the node opaque state.
*/
-static void out2 (const char *a_, unsigned int _a_high, unsigned int c, decl_node s);
+static void initNodeOpaqueState (decl_node__opaque n);
/*
- out3 - write string a to StdOut using format specifier a.
+ assignNodeOpaqueCastState - copy the opaqueCastState from src into dest.
*/
-static void out3 (const char *a_, unsigned int _a_high, unsigned int l, nameKey_Name n, decl_node s);
+static void assignNodeOpaqueCastState (decl_node__opaque dest, decl_node__opaque src);
/*
- isUnary - returns TRUE if, n, is an unary node.
+ assignNodeOpaqueCastFalse - assign the voidstar field of dest to false.
+ It assigns the opaque field of dest to the value
+ of the src opaque field.
*/
-static bool isUnary (decl_node n);
+static void assignNodeOpaqueCastFalse (decl_node__opaque dest, decl_node__opaque src);
/*
- isBinary - returns TRUE if, n, is an binary node.
+ dumpOpaqueState -
*/
-static bool isBinary (decl_node n);
+static void dumpOpaqueState (decl_node__opaque n);
/*
- makeUnary - create a unary expression node with, e, as the argument
- and res as the return type.
+ doParamC - emit parameter for C/C++.
*/
-static decl_node makeUnary (decl_nodeT k, decl_node e, decl_node res);
+static void doParamC (mcPretty_pretty p, decl_node__opaque n);
/*
- isLeafString - returns TRUE if n is a leaf node which is a string constant.
+ doVarParamC - emit a VAR parameter for C/C++.
*/
-static bool isLeafString (decl_node n);
+static void doVarParamC (mcPretty_pretty p, decl_node__opaque n);
/*
- getLiteralStringContents - return the contents of a literal node as a string.
+ doOptargC -
*/
-static DynamicStrings_String getLiteralStringContents (decl_node n);
+static void doOptargC (mcPretty_pretty p, decl_node__opaque n);
/*
- getStringContents - return the string contents of a constant, literal,
- string or a constexp node.
+ doParameterC -
*/
-static DynamicStrings_String getStringContents (decl_node n);
+static void doParameterC (mcPretty_pretty p, decl_node__opaque n);
/*
- addNames -
+ doProcTypeC -
*/
-static nameKey_Name addNames (decl_node a, decl_node b);
+static void doProcTypeC (mcPretty_pretty p, decl_node__opaque t, decl_node__opaque n);
/*
- resolveString -
+ isDeclInImp - returns TRUE if node type is declared as an opaque and
+ is declared fully in the current implementation module.
+ This should only be called if isType (type). Its purpose
+ is specific to a type checking whether it is an opaque type
+ declared in the .def/.mod pair of the current imp module.
*/
-static decl_node resolveString (decl_node n);
+static bool isDeclInImp (decl_node__opaque type);
/*
- foldBinary -
+ doTypeNameModifier - adds the __opaque modifier to the type n provided
+ it is an opaque type which is being declared in the
+ implementation module.
*/
-static decl_node foldBinary (decl_nodeT k, decl_node l, decl_node r, decl_node res);
+static void doTypeNameModifier (mcPretty_pretty p, decl_node__opaque n);
/*
- makeBinary - create a binary node with left/right/result type: l, r and resultType.
+ doTypesC -
*/
-static decl_node makeBinary (decl_nodeT k, decl_node l, decl_node r, decl_node resultType);
+static void doTypesC (decl_node__opaque n);
/*
- doMakeBinary - returns a binary node containing left/right/result values
- l, r, res, with a node operator, k.
+ doCompletePartialC -
*/
-static decl_node doMakeBinary (decl_nodeT k, decl_node l, decl_node r, decl_node res);
+static void doCompletePartialC (decl_node__opaque n);
/*
- doMakeComponentRef -
+ doCompletePartialRecord -
*/
-static decl_node doMakeComponentRef (decl_node rec, decl_node field);
+static void doCompletePartialRecord (mcPretty_pretty p, decl_node__opaque t, decl_node__opaque r);
/*
- isComponentRef -
+ doCompletePartialArray -
*/
-static bool isComponentRef (decl_node n);
+static void doCompletePartialArray (mcPretty_pretty p, decl_node__opaque t, decl_node__opaque r);
/*
- isArrayRef - returns TRUE if the node was an arrayref.
+ lookupConst -
*/
-static bool isArrayRef (decl_node n);
+static decl_node__opaque lookupConst (decl_node__opaque type, nameKey_Name n);
/*
- isDeref - returns TRUE if, n, is a deref node.
+ doMin -
*/
-static bool isDeref (decl_node n);
+static decl_node__opaque doMin (decl_node__opaque n);
/*
- makeBase - create a base type or constant.
- It only supports the base types and constants
- enumerated below.
+ doMax -
*/
-static decl_node makeBase (decl_nodeT k);
+static decl_node__opaque doMax (decl_node__opaque n);
/*
- isOrdinal - returns TRUE if, n, is an ordinal type.
+ getMax -
*/
-static bool isOrdinal (decl_node n);
+static decl_node__opaque getMax (decl_node__opaque n);
/*
- mixTypes -
+ getMin -
*/
-static decl_node mixTypes (decl_node a, decl_node b);
+static decl_node__opaque getMin (decl_node__opaque n);
/*
- doSetExprType -
+ doSubtractC -
*/
-static decl_node doSetExprType (decl_node *t, decl_node n);
+static void doSubtractC (mcPretty_pretty p, decl_node__opaque s);
/*
- getMaxMinType -
+ doSubrC -
*/
-static decl_node getMaxMinType (decl_node n);
+static void doSubrC (mcPretty_pretty p, decl_node__opaque s);
/*
- doGetFuncType -
+ doCompletePartialProcType -
*/
-static decl_node doGetFuncType (decl_node n);
+static void doCompletePartialProcType (mcPretty_pretty p, decl_node__opaque t, decl_node__opaque n);
/*
- doGetExprType - works out the type which is associated with node, n.
+ outputCompletePartialProcType -
*/
-static decl_node doGetExprType (decl_node n);
+static void outputCompletePartialProcType (mcPretty_pretty p, decl_node__opaque t, decl_node__opaque n);
/*
- getExprType - return the expression type.
+ isBase -
*/
-static decl_node getExprType (decl_node n);
+static bool isBase (decl_node__opaque n);
/*
- openOutput -
+ doBoolC -
*/
-static void openOutput (void);
+static void doBoolC (mcPretty_pretty p);
/*
- closeOutput -
+ doBaseC -
*/
-static void closeOutput (void);
+static void doBaseC (mcPretty_pretty p, decl_node__opaque n);
/*
- write - outputs a single char, ch.
+ isSystem -
*/
-static void write_ (char ch);
+static bool isSystem (decl_node__opaque n);
/*
- writeln -
+ doSystemC -
*/
-static void writeln (void);
+static void doSystemC (mcPretty_pretty p, decl_node__opaque n);
/*
- doIncludeC - include header file for definition module, n.
+ doArrayC -
*/
-static void doIncludeC (decl_node n);
+static void doArrayC (mcPretty_pretty p, decl_node__opaque n);
/*
- getSymScope - returns the scope where node, n, was declared.
+ doPointerC -
*/
-static decl_node getSymScope (decl_node n);
+static void doPointerC (mcPretty_pretty p, decl_node__opaque n, decl_node__opaque *m);
/*
- isQualifiedForced - should the node be written with a module prefix?
+ doRecordFieldC -
*/
-static bool isQualifiedForced (decl_node n);
+static void doRecordFieldC (mcPretty_pretty p, decl_node__opaque f);
/*
- getFQstring -
+ doVarientFieldC -
*/
-static DynamicStrings_String getFQstring (decl_node n);
+static void doVarientFieldC (mcPretty_pretty p, decl_node__opaque n);
/*
- getFQDstring -
+ doVarientC -
*/
-static DynamicStrings_String getFQDstring (decl_node n, bool scopes);
+static void doVarientC (mcPretty_pretty p, decl_node__opaque n);
/*
- getString - returns the name as a string.
+ doRecordC -
*/
-static DynamicStrings_String getString (decl_node n);
+static void doRecordC (mcPretty_pretty p, decl_node__opaque n, decl_node__opaque *m);
/*
- doNone - call HALT.
+ isBitset -
*/
-static void doNone (decl_node n);
+static bool isBitset (decl_node__opaque n);
/*
- doNothing - does nothing!
+ isNegative - returns TRUE if expression, n, is negative.
*/
-static void doNothing (decl_node n);
+static bool isNegative (decl_node__opaque n);
/*
- doConstC -
+ doSubrangeC -
*/
-static void doConstC (decl_node n);
+static void doSubrangeC (mcPretty_pretty p, decl_node__opaque n);
/*
- needsParen - returns TRUE if expression, n, needs to be enclosed in ().
+ doSetC - generates a C type which holds the set.
+ Currently we only support sets of size WORD.
*/
-static bool needsParen (decl_node n);
+static void doSetC (mcPretty_pretty p, decl_node__opaque n);
/*
- doUnary -
+ doTypeC -
*/
-static void doUnary (mcPretty_pretty p, const char *op_, unsigned int _op_high, decl_node expr, decl_node type, bool l, bool r);
+static void doTypeC (mcPretty_pretty p, decl_node__opaque n, decl_node__opaque *m);
/*
- doSetSub - perform l & (~ r)
+ doArrayNameC - it displays the array declaration (it might be an unbounded).
*/
-static void doSetSub (mcPretty_pretty p, decl_node left, decl_node right);
+static void doArrayNameC (mcPretty_pretty p, decl_node__opaque n);
/*
- doPolyBinary -
+ doRecordNameC - emit the C/C++ record name <name of n>"_r".
*/
-static void doPolyBinary (mcPretty_pretty p, decl_nodeT op, decl_node left, decl_node right, bool l, bool r);
+static void doRecordNameC (mcPretty_pretty p, decl_node__opaque n);
/*
- doBinary -
+ doPointerNameC - emit the C/C++ pointer type <name of n>*.
*/
-static void doBinary (mcPretty_pretty p, const char *op_, unsigned int _op_high, decl_node left, decl_node right, bool l, bool r, bool unpackProc);
+static void doPointerNameC (mcPretty_pretty p, decl_node__opaque n);
/*
- doPostUnary -
+ doTypeNameC -
*/
-static void doPostUnary (mcPretty_pretty p, const char *op_, unsigned int _op_high, decl_node expr);
+static void doTypeNameC (mcPretty_pretty p, decl_node__opaque n);
/*
- doDeRefC -
+ isExternal - returns TRUE if symbol, n, was declared in another module.
*/
-static void doDeRefC (mcPretty_pretty p, decl_node expr);
+static bool isExternal (decl_node__opaque n);
/*
- doGetLastOp - returns, a, if b is a terminal otherwise walk right.
+ doOpaqueModifier - adds postfix __opaque providing n uses an opaque type which is
+ not represented by ( void * ). n is a non type node which might
+ be using an opaque type. For example a var or param node.
*/
-static decl_node doGetLastOp (decl_node a, decl_node b);
+static void doOpaqueModifier (mcPretty_pretty p, decl_node__opaque n);
/*
- doComponentRefC -
+ doDeclareVarC -
*/
-static void doComponentRefC (mcPretty_pretty p, decl_node l, decl_node r);
+static void doDeclareVarC (decl_node__opaque n);
/*
- doPointerRefC -
+ doVarC - output a variable declaration. Note that we do not generate
+ a declaration if we are translating the implementation module
+ and a variable is exported as the variable will be in the .h
+ file to avoid all -Wodr issues.
*/
-static void doPointerRefC (mcPretty_pretty p, decl_node l, decl_node r);
+static void doVarC (decl_node__opaque n);
/*
- doPreBinary -
+ doExternCP -
*/
-static void doPreBinary (mcPretty_pretty p, const char *op_, unsigned int _op_high, decl_node left, decl_node right, bool l, bool r);
+static void doExternCP (mcPretty_pretty p);
/*
- doConstExpr -
+ doProcedureCommentText -
*/
-static void doConstExpr (mcPretty_pretty p, decl_node n);
+static void doProcedureCommentText (mcPretty_pretty p, DynamicStrings_String s);
/*
- doEnumerationField -
+ doProcedureComment -
*/
-static void doEnumerationField (mcPretty_pretty p, decl_node n);
+static void doProcedureComment (mcPretty_pretty p, DynamicStrings_String s);
/*
- isZero - returns TRUE if node, n, is zero.
+ doProcedureHeadingC -
*/
-static bool isZero (decl_node n);
+static void doProcedureHeadingC (decl_node__opaque n, bool prototype);
/*
- doArrayRef -
+ checkDeclareUnboundedParamCopyC -
*/
-static void doArrayRef (mcPretty_pretty p, decl_node n);
+static bool checkDeclareUnboundedParamCopyC (mcPretty_pretty p, decl_node__opaque n);
/*
- doProcedure -
+ checkUnboundedParamCopyC -
*/
-static void doProcedure (mcPretty_pretty p, decl_node n);
+static void checkUnboundedParamCopyC (mcPretty_pretty p, decl_node__opaque n);
/*
- doRecordfield -
+ doUnboundedParamCopyC -
*/
-static void doRecordfield (mcPretty_pretty p, decl_node n);
+static void doUnboundedParamCopyC (mcPretty_pretty p, decl_node__opaque n);
/*
- doCastC -
+ doPrototypeC -
*/
-static void doCastC (mcPretty_pretty p, decl_node t, decl_node e);
+static void doPrototypeC (decl_node__opaque n);
/*
- doSetValueC -
+ addTodo - adds, n, to the todo list.
*/
-static void doSetValueC (mcPretty_pretty p, decl_node n);
+static void addTodo (decl_node__opaque n);
/*
- getSetLow - returns the low value of the set type from
- expression, n.
+ addVariablesTodo -
*/
-static decl_node getSetLow (decl_node n);
+static void addVariablesTodo (decl_node__opaque n);
/*
- doInC - performs (((1 << (l)) & (r)) != 0)
+ addTypesTodo -
*/
-static void doInC (mcPretty_pretty p, decl_node l, decl_node r);
+static void addTypesTodo (decl_node__opaque n);
/*
- doThrowC -
+ tempName -
*/
-static void doThrowC (mcPretty_pretty p, decl_node n);
+static DynamicStrings_String tempName (void);
/*
- doUnreachableC -
+ makeIntermediateType -
*/
-static void doUnreachableC (mcPretty_pretty p, decl_node n);
+static decl_node__opaque makeIntermediateType (DynamicStrings_String s, decl_node__opaque p);
/*
- outNull -
+ simplifyType -
*/
-static void outNull (mcPretty_pretty p);
+static void simplifyType (alists_alist l, decl_node__opaque *p);
/*
- outTrue -
+ simplifyVar -
*/
-static void outTrue (mcPretty_pretty p);
+static void simplifyVar (alists_alist l, decl_node__opaque n);
/*
- outFalse -
+ simplifyRecord -
*/
-static void outFalse (mcPretty_pretty p);
+static void simplifyRecord (alists_alist l, decl_node__opaque n);
/*
- doExprC -
+ simplifyVarient -
*/
-static void doExprC (mcPretty_pretty p, decl_node n);
+static void simplifyVarient (alists_alist l, decl_node__opaque n);
/*
- doExprCup -
+ simplifyVarientField -
*/
-static void doExprCup (mcPretty_pretty p, decl_node n, bool unpackProc);
+static void simplifyVarientField (alists_alist l, decl_node__opaque n);
/*
- doExprM2 -
+ doSimplifyNode -
*/
-static void doExprM2 (mcPretty_pretty p, decl_node n);
+static void doSimplifyNode (alists_alist l, decl_node__opaque n);
/*
- doVar -
+ simplifyNode -
*/
-static void doVar (mcPretty_pretty p, decl_node n);
+static void simplifyNode (alists_alist l, decl_node__opaque n);
/*
- doLiteralC -
+ doSimplify -
*/
-static void doLiteralC (mcPretty_pretty p, decl_node n);
+static void doSimplify (decl_node__opaque n);
/*
- doLiteral -
+ simplifyTypes -
*/
-static void doLiteral (mcPretty_pretty p, decl_node n);
+static void simplifyTypes (decl_scopeT s);
/*
- isString - returns TRUE if node, n, is a string.
+ outDeclsDefC -
*/
-static bool isString (decl_node n);
+static void outDeclsDefC (mcPretty_pretty p, decl_node__opaque n);
/*
- doString -
+ includeConstType -
*/
-static void doString (mcPretty_pretty p, decl_node n);
+static void includeConstType (decl_scopeT s);
/*
- replaceChar - replace every occurance of, ch, by, a and return modified string, s.
+ includeVarProcedure -
*/
-static DynamicStrings_String replaceChar (DynamicStrings_String s, char ch, const char *a_, unsigned int _a_high);
+static void includeVarProcedure (decl_scopeT s);
/*
- toCstring - translates string, n, into a C string
- and returns the new String.
+ includeVar -
*/
-static DynamicStrings_String toCstring (nameKey_Name n);
+static void includeVar (decl_scopeT s);
/*
- toCchar -
+ includeExternals -
*/
-static DynamicStrings_String toCchar (nameKey_Name n);
+static void includeExternals (decl_node__opaque n);
/*
- countChar -
+ checkSystemInclude -
*/
-static unsigned int countChar (DynamicStrings_String s, char ch);
+static void checkSystemInclude (decl_node__opaque n);
/*
- lenCstring -
+ addExported -
*/
-static unsigned int lenCstring (DynamicStrings_String s);
+static void addExported (decl_node__opaque n);
/*
- outCstring -
+ addExternal - only adds, n, if this symbol is external to the
+ implementation module and is not a hidden type.
*/
-static void outCstring (mcPretty_pretty p, decl_node s, bool aString);
+static void addExternal (decl_node__opaque n);
/*
- doStringC -
+ includeDefConstType -
*/
-static void doStringC (mcPretty_pretty p, decl_node n);
+static void includeDefConstType (decl_node__opaque n);
/*
- isPunct -
+ runIncludeDefConstType -
*/
-static bool isPunct (char ch);
+static void runIncludeDefConstType (decl_node__opaque n);
/*
- isWhite -
+ joinProcedures - copies procedures from definition module,
+ d, into implementation module, i.
*/
-static bool isWhite (char ch);
+static void joinProcedures (decl_node__opaque i, decl_node__opaque d);
/*
- outText -
+ includeDefVarProcedure -
*/
-static void outText (mcPretty_pretty p, const char *a_, unsigned int _a_high);
+static void includeDefVarProcedure (decl_node__opaque n);
/*
- outRawS -
+ foreachModuleDo -
*/
-static void outRawS (mcPretty_pretty p, DynamicStrings_String s);
+static void foreachModuleDo (decl_node__opaque n, symbolKey_performOperation p);
/*
- outKm2 -
+ outDeclsImpC -
*/
-static mcPretty_pretty outKm2 (mcPretty_pretty p, const char *a_, unsigned int _a_high);
+static void outDeclsImpC (mcPretty_pretty p, decl_scopeT s);
/*
- outKc -
+ doStatementSequenceC -
*/
-static mcPretty_pretty outKc (mcPretty_pretty p, const char *a_, unsigned int _a_high);
+static void doStatementSequenceC (mcPretty_pretty p, decl_node__opaque s);
/*
- outTextS -
+ isStatementSequenceEmpty -
*/
-static void outTextS (mcPretty_pretty p, DynamicStrings_String s);
+static bool isStatementSequenceEmpty (decl_node__opaque s);
/*
- outCard -
+ isSingleStatement - returns TRUE if the statement sequence, s, has
+ only one statement.
*/
-static void outCard (mcPretty_pretty p, unsigned int c);
+static bool isSingleStatement (decl_node__opaque s);
/*
- outTextN -
+ doCommentC -
*/
-static void outTextN (mcPretty_pretty p, nameKey_Name n);
+static void doCommentC (mcPretty_pretty p, decl_node__opaque s);
/*
- doTypeAliasC -
+ doAfterCommentC - emit an after comment, c, or a newline if, c, is empty.
*/
-static void doTypeAliasC (mcPretty_pretty p, decl_node n, decl_node *m);
+static void doAfterCommentC (mcPretty_pretty p, decl_node__opaque c);
/*
- doEnumerationC -
+ doReturnC - issue a return statement and also place in an after comment if one exists.
*/
-static void doEnumerationC (mcPretty_pretty p, decl_node n);
+static void doReturnC (mcPretty_pretty p, decl_node__opaque s);
/*
- doNamesC -
+ isZtypeEquivalent -
*/
-static void doNamesC (mcPretty_pretty p, nameKey_Name n);
+static bool isZtypeEquivalent (decl_node__opaque type);
/*
- doNameC -
+ isEquivalentType - returns TRUE if type1 and type2 are equivalent.
*/
-static void doNameC (mcPretty_pretty p, decl_node n);
+static bool isEquivalentType (decl_node__opaque type1, decl_node__opaque type2);
/*
- initCname -
+ doExprCastC - build a cast if necessary.
*/
-static void initCname (decl_cnameT *c);
+static void doExprCastC (mcPretty_pretty p, decl_node__opaque e, decl_node__opaque type);
/*
- doCname -
+ requiresUnpackProc - returns TRUE if either the expr is a procedure or the proctypes differ.
*/
-static nameKey_Name doCname (nameKey_Name n, decl_cnameT *c, bool scopes);
+static bool requiresUnpackProc (decl_node__opaque s);
/*
- getDName -
+ forceCastOpaque -
*/
-static nameKey_Name getDName (decl_node n, bool scopes);
+static void forceCastOpaque (mcPretty_pretty p, decl_node__opaque des, decl_node__opaque expr, bool toVoidStar);
/*
- doDNameC -
+ forceReintCastOpaque -
*/
-static void doDNameC (mcPretty_pretty p, decl_node n, bool scopes);
+static void forceReintCastOpaque (mcPretty_pretty p, decl_node__opaque des, decl_node__opaque expr, bool toVoidStar);
/*
- doFQDNameC -
+ doUnConstCastUnbounded - if node n type is an unbounded array then
+ use const_cast to remove the const parameter
+ to allow the unbounded array to be modified.
*/
-static void doFQDNameC (mcPretty_pretty p, decl_node n, bool scopes);
+static void doUnConstCastUnbounded (mcPretty_pretty p, decl_node__opaque n);
/*
- doFQNameC -
+ doAssignmentC -
*/
-static void doFQNameC (mcPretty_pretty p, decl_node n);
+static void doAssignmentC (mcPretty_pretty p, decl_node__opaque s);
/*
- doNameM2 -
+ containsStatement -
*/
-static void doNameM2 (mcPretty_pretty p, decl_node n);
+static bool containsStatement (decl_node__opaque s);
/*
- doUsed -
+ doCompoundStmt -
*/
-static void doUsed (mcPretty_pretty p, bool used);
+static void doCompoundStmt (mcPretty_pretty p, decl_node__opaque s);
/*
- doHighC -
+ doElsifC -
*/
-static void doHighC (mcPretty_pretty p, decl_node a, nameKey_Name n, bool isused);
+static void doElsifC (mcPretty_pretty p, decl_node__opaque s);
/*
- doParamConstCast -
+ noIfElse -
*/
-static void doParamConstCast (mcPretty_pretty p, decl_node n);
+static bool noIfElse (decl_node__opaque n);
/*
- getParameterVariable - returns the variable which shadows the parameter
- named, m, in parameter block, n.
+ noIfElseChained - returns TRUE if, n, is an IF statement which
+ has no associated ELSE statement. An IF with an
+ ELSIF is also checked for no ELSE and will result
+ in a return value of TRUE.
*/
-static decl_node getParameterVariable (decl_node n, nameKey_Name m);
+static bool noIfElseChained (decl_node__opaque n);
/*
- doParamTypeEmit - emit parameter type for C/C++. It checks to see if the
- parameter type is a procedure type and if it were declared
- in a definition module for "C" and if so it uses the "C"
- definition for a procedure type, rather than the mc
- C++ version.
+ hasIfElse -
*/
-static void doParamTypeEmit (mcPretty_pretty p, decl_node paramnode, decl_node paramtype);
+static bool hasIfElse (decl_node__opaque n);
/*
- doParamC - emit parameter for C/C++.
+ isIfElse -
*/
-static void doParamC (mcPretty_pretty p, decl_node n);
+static bool isIfElse (decl_node__opaque n);
/*
- doVarParamC - emit a VAR parameter for C/C++.
+ hasIfAndNoElse - returns TRUE if statement, n, is a single statement
+ which is an IF and it has no else statement.
*/
-static void doVarParamC (mcPretty_pretty p, decl_node n);
+static bool hasIfAndNoElse (decl_node__opaque n);
/*
- doOptargC -
+ doIfC - issue an if statement and also place in an after comment if one exists.
+ The if statement might contain an else or elsif which are also handled.
*/
-static void doOptargC (mcPretty_pretty p, decl_node n);
+static void doIfC (mcPretty_pretty p, decl_node__opaque s);
/*
- doParameterC -
+ doForIncCP -
*/
-static void doParameterC (mcPretty_pretty p, decl_node n);
+static void doForIncCP (mcPretty_pretty p, decl_node__opaque s);
/*
- doProcTypeC -
+ doForIncC -
*/
-static void doProcTypeC (mcPretty_pretty p, decl_node t, decl_node n);
+static void doForIncC (mcPretty_pretty p, decl_node__opaque s);
/*
- doTypesC -
+ doForInc -
*/
-static void doTypesC (decl_node n);
+static void doForInc (mcPretty_pretty p, decl_node__opaque s);
/*
- doCompletePartialC -
+ doForC -
*/
-static void doCompletePartialC (decl_node n);
+static void doForC (mcPretty_pretty p, decl_node__opaque s);
/*
- doCompletePartialRecord -
+ doRepeatC -
*/
-static void doCompletePartialRecord (mcPretty_pretty p, decl_node t, decl_node r);
+static void doRepeatC (mcPretty_pretty p, decl_node__opaque s);
/*
- doCompletePartialArray -
+ doWhileC -
*/
-static void doCompletePartialArray (mcPretty_pretty p, decl_node t, decl_node r);
+static void doWhileC (mcPretty_pretty p, decl_node__opaque s);
/*
- lookupConst -
+ doFuncHighC -
*/
-static decl_node lookupConst (decl_node type, nameKey_Name n);
+static void doFuncHighC (mcPretty_pretty p, decl_node__opaque a);
/*
- doMin -
+ doMultiplyBySize -
*/
-static decl_node doMin (decl_node n);
+static void doMultiplyBySize (mcPretty_pretty p, decl_node__opaque a);
/*
- doMax -
+ doTotype -
*/
-static decl_node doMax (decl_node n);
+static void doTotype (mcPretty_pretty p, decl_node__opaque a, decl_node__opaque t);
/*
- getMax -
+ doFuncUnbounded -
*/
-static decl_node getMax (decl_node n);
+static void doFuncUnbounded (mcPretty_pretty p, decl_node__opaque actual, decl_node__opaque formalParam, decl_node__opaque formal, decl_node__opaque func);
/*
- getMin -
+ doProcedureParamC -
*/
-static decl_node getMin (decl_node n);
+static void doProcedureParamC (mcPretty_pretty p, decl_node__opaque actual, decl_node__opaque formal);
/*
- doSubtractC -
+ doAdrExprC -
*/
-static void doSubtractC (mcPretty_pretty p, decl_node s);
+static void doAdrExprC (mcPretty_pretty p, decl_node__opaque n);
/*
- doSubrC -
+ typePair -
*/
-static void doSubrC (mcPretty_pretty p, decl_node s);
+static bool typePair (decl_node__opaque a, decl_node__opaque b, decl_node__opaque x, decl_node__opaque y);
/*
- doCompletePartialProcType -
+ needsCast - return TRUE if the actual type parameter needs to be cast to
+ the formal type.
*/
-static void doCompletePartialProcType (mcPretty_pretty p, decl_node t, decl_node n);
+static bool needsCast (decl_node__opaque at, decl_node__opaque ft);
/*
- isBase -
+ checkSystemCast - checks to see if we are passing to/from
+ a system generic type (WORD, BYTE, ADDRESS)
+ and if so emit a cast. It returns the number of
+ open parenthesis.
*/
-static bool isBase (decl_node n);
+static unsigned int checkSystemCast (mcPretty_pretty p, decl_node__opaque actual, decl_node__opaque formal);
/*
- doBoolC -
+ emitN -
*/
-static void doBoolC (mcPretty_pretty p);
+static void emitN (mcPretty_pretty p, const char *a_, unsigned int _a_high, unsigned int n);
/*
- doBaseC -
+ isForC - return true if node n is a varparam, param or procedure
+ which was declared inside a definition module for "C".
*/
-static void doBaseC (mcPretty_pretty p, decl_node n);
+static bool isForC (decl_node__opaque n);
/*
- isSystem -
+ isDefForCNode - return TRUE if node n was declared inside a definition module for "C".
*/
-static bool isSystem (decl_node n);
+static bool isDefForCNode (decl_node__opaque n);
/*
- doSystemC -
+ doFuncVarParam - detect whether the formal uses an opaque and ensure that the address of
+ the actual parameter is cast to the formal type.
*/
-static void doSystemC (mcPretty_pretty p, decl_node n);
+static void doFuncVarParam (mcPretty_pretty p, decl_node__opaque actual, decl_node__opaque formal);
/*
- doArrayC -
+ doFuncParamC -
*/
-static void doArrayC (mcPretty_pretty p, decl_node n);
+static void doFuncParamC (mcPretty_pretty p, decl_node__opaque actual, decl_node__opaque formal, decl_node__opaque func);
/*
- doPointerC -
+ getNthParamType - return the type of parameter, i, in list, l.
+ If the parameter is a vararg NIL is returned.
*/
-static void doPointerC (mcPretty_pretty p, decl_node n, decl_node *m);
+static decl_node__opaque getNthParamType (Indexing_Index l, unsigned int i);
/*
- doRecordFieldC -
+ getNthParam - return the parameter, i, in list, l.
+ If the parameter is a vararg NIL is returned.
*/
-static void doRecordFieldC (mcPretty_pretty p, decl_node f);
+static decl_node__opaque getNthParam (Indexing_Index l, unsigned int i);
/*
- doVarientFieldC -
+ doFuncArgsC -
*/
-static void doVarientFieldC (mcPretty_pretty p, decl_node n);
+static void doFuncArgsC (mcPretty_pretty p, decl_node__opaque s, Indexing_Index l, bool needParen);
/*
- doVarientC -
+ doProcTypeArgsC -
*/
-static void doVarientC (mcPretty_pretty p, decl_node n);
+static void doProcTypeArgsC (mcPretty_pretty p, decl_node__opaque s, Indexing_Index args, bool needParen);
/*
- doRecordC -
+ doAdrArgC -
*/
-static void doRecordC (mcPretty_pretty p, decl_node n, decl_node *m);
+static void doAdrArgC (mcPretty_pretty p, decl_node__opaque n);
/*
- isBitset -
+ doAdrC -
*/
-static bool isBitset (decl_node n);
+static void doAdrC (mcPretty_pretty p, decl_node__opaque n);
/*
- isNegative - returns TRUE if expression, n, is negative.
+ doInc -
*/
-static bool isNegative (decl_node n);
+static void doInc (mcPretty_pretty p, decl_node__opaque n);
/*
- doSubrangeC -
+ doDec -
*/
-static void doSubrangeC (mcPretty_pretty p, decl_node n);
+static void doDec (mcPretty_pretty p, decl_node__opaque n);
/*
- doSetC - generates a C type which holds the set.
- Currently we only support sets of size WORD.
+ doIncDecC -
*/
-static void doSetC (mcPretty_pretty p, decl_node n);
+static void doIncDecC (mcPretty_pretty p, decl_node__opaque n, const char *op_, unsigned int _op_high);
/*
- doTypeC -
+ doIncDecCP -
*/
-static void doTypeC (mcPretty_pretty p, decl_node n, decl_node *m);
+static void doIncDecCP (mcPretty_pretty p, decl_node__opaque n, const char *op_, unsigned int _op_high);
/*
- doArrayNameC - it displays the array declaration (it might be an unbounded).
+ doInclC -
*/
-static void doArrayNameC (mcPretty_pretty p, decl_node n);
+static void doInclC (mcPretty_pretty p, decl_node__opaque n);
/*
- doRecordNameC - emit the C/C++ record name <name of n>"_r".
+ doExclC -
*/
-static void doRecordNameC (mcPretty_pretty p, decl_node n);
+static void doExclC (mcPretty_pretty p, decl_node__opaque n);
/*
- doPointerNameC - emit the C/C++ pointer type <name of n>*.
+ doNewC -
*/
-static void doPointerNameC (mcPretty_pretty p, decl_node n);
+static void doNewC (mcPretty_pretty p, decl_node__opaque n);
/*
- doTypeNameC -
+ doDisposeC -
*/
-static void doTypeNameC (mcPretty_pretty p, decl_node n);
+static void doDisposeC (mcPretty_pretty p, decl_node__opaque n);
/*
- isExternal - returns TRUE if symbol, n, was declared in another module.
+ doCapC -
*/
-static bool isExternal (decl_node n);
+static void doCapC (mcPretty_pretty p, decl_node__opaque n);
/*
- doVarC -
+ doLengthC -
*/
-static void doVarC (decl_node n);
+static void doLengthC (mcPretty_pretty p, decl_node__opaque n);
/*
- doExternCP -
+ doAbsC -
*/
-static void doExternCP (mcPretty_pretty p);
+static void doAbsC (mcPretty_pretty p, decl_node__opaque n);
/*
- doProcedureCommentText -
+ doValC -
*/
-static void doProcedureCommentText (mcPretty_pretty p, DynamicStrings_String s);
+static void doValC (mcPretty_pretty p, decl_node__opaque n);
/*
- doProcedureComment -
+ doMinC -
*/
-static void doProcedureComment (mcPretty_pretty p, DynamicStrings_String s);
+static void doMinC (mcPretty_pretty p, decl_node__opaque n);
/*
- doProcedureHeadingC -
+ doMaxC -
*/
-static void doProcedureHeadingC (decl_node n, bool prototype);
+static void doMaxC (mcPretty_pretty p, decl_node__opaque n);
/*
- checkDeclareUnboundedParamCopyC -
+ isIntrinsic - returns if, n, is an intrinsic procedure.
+ The intrinsic functions are represented as unary and binary nodes.
*/
-static bool checkDeclareUnboundedParamCopyC (mcPretty_pretty p, decl_node n);
+static bool isIntrinsic (decl_node__opaque n);
/*
- checkUnboundedParamCopyC -
+ doHalt -
*/
-static void checkUnboundedParamCopyC (mcPretty_pretty p, decl_node n);
+static void doHalt (mcPretty_pretty p, decl_node__opaque n);
/*
- doUnboundedParamCopyC -
+ doCreal - emit the appropriate creal function.
*/
-static void doUnboundedParamCopyC (mcPretty_pretty p, decl_node n);
+static void doCreal (mcPretty_pretty p, decl_node__opaque t);
/*
- doPrototypeC -
+ doCimag - emit the appropriate cimag function.
*/
-static void doPrototypeC (decl_node n);
+static void doCimag (mcPretty_pretty p, decl_node__opaque t);
/*
- addTodo - adds, n, to the todo list.
+ doReC -
*/
-static void addTodo (decl_node n);
+static void doReC (mcPretty_pretty p, decl_node__opaque n);
/*
- addVariablesTodo -
+ doImC -
*/
-static void addVariablesTodo (decl_node n);
+static void doImC (mcPretty_pretty p, decl_node__opaque n);
/*
- addTypesTodo -
+ doCmplx -
*/
-static void addTypesTodo (decl_node n);
+static void doCmplx (mcPretty_pretty p, decl_node__opaque n);
/*
- tempName -
+ doIntrinsicC -
*/
-static DynamicStrings_String tempName (void);
+static void doIntrinsicC (mcPretty_pretty p, decl_node__opaque n);
/*
- makeIntermediateType -
+ isIntrinsicFunction - returns true if, n, is an instrinsic function.
*/
-static decl_node makeIntermediateType (DynamicStrings_String s, decl_node p);
+static bool isIntrinsicFunction (decl_node__opaque n);
/*
- simplifyType -
+ doSizeC -
*/
-static void simplifyType (alists_alist l, decl_node *p);
+static void doSizeC (mcPretty_pretty p, decl_node__opaque n);
/*
- simplifyVar -
+ doConvertC -
*/
-static void simplifyVar (alists_alist l, decl_node n);
+static void doConvertC (mcPretty_pretty p, decl_node__opaque n, const char *conversion_, unsigned int _conversion_high);
/*
- simplifyRecord -
+ doConvertSC -
*/
-static void simplifyRecord (alists_alist l, decl_node n);
+static void doConvertSC (mcPretty_pretty p, decl_node__opaque n, DynamicStrings_String conversion);
/*
- simplifyVarient -
+ getFunction - return the function associate with funccall node n.
*/
-static void simplifyVarient (alists_alist l, decl_node n);
+static decl_node__opaque getFunction (decl_node__opaque n);
/*
- simplifyVarientField -
+ getFuncFromExpr -
*/
-static void simplifyVarientField (alists_alist l, decl_node n);
+static decl_node__opaque getFuncFromExpr (decl_node__opaque n);
/*
- doSimplifyNode -
+ doFuncExprC -
*/
-static void doSimplifyNode (alists_alist l, decl_node n);
+static void doFuncExprC (mcPretty_pretty p, decl_node__opaque n);
/*
- simplifyNode -
+ doFuncCallC -
*/
-static void simplifyNode (alists_alist l, decl_node n);
+static void doFuncCallC (mcPretty_pretty p, decl_node__opaque n);
/*
- doSimplify -
+ doCaseStatementC -
*/
-static void doSimplify (decl_node n);
+static void doCaseStatementC (mcPretty_pretty p, decl_node__opaque n, bool needBreak);
/*
- simplifyTypes -
+ doExceptionC -
*/
-static void simplifyTypes (decl_scopeT s);
+static void doExceptionC (mcPretty_pretty p, const char *a_, unsigned int _a_high, decl_node__opaque n);
/*
- outDeclsDefC -
+ doExceptionCP -
*/
-static void outDeclsDefC (mcPretty_pretty p, decl_node n);
+static void doExceptionCP (mcPretty_pretty p, const char *a_, unsigned int _a_high, decl_node__opaque n);
/*
- includeConstType -
+ doException -
*/
-static void includeConstType (decl_scopeT s);
+static void doException (mcPretty_pretty p, const char *a_, unsigned int _a_high, decl_node__opaque n);
/*
- includeVarProcedure -
+ doRangeListC -
*/
-static void includeVarProcedure (decl_scopeT s);
+static void doRangeListC (mcPretty_pretty p, decl_node__opaque c);
/*
- includeVar -
+ doRangeIfListC -
*/
-static void includeVar (decl_scopeT s);
+static void doRangeIfListC (mcPretty_pretty p, decl_node__opaque e, decl_node__opaque c);
/*
- includeExternals -
+ doCaseLabels -
*/
-static void includeExternals (decl_node n);
+static void doCaseLabels (mcPretty_pretty p, decl_node__opaque n, bool needBreak);
/*
- checkSystemInclude -
+ doCaseLabelListC -
*/
-static void checkSystemInclude (decl_node n);
+static void doCaseLabelListC (mcPretty_pretty p, decl_node__opaque n, bool haveElse);
/*
- addExported -
+ doCaseIfLabels -
*/
-static void addExported (decl_node n);
+static void doCaseIfLabels (mcPretty_pretty p, decl_node__opaque e, decl_node__opaque n, unsigned int i, unsigned int h);
/*
- addExternal - only adds, n, if this symbol is external to the
- implementation module and is not a hidden type.
+ doCaseIfLabelListC -
*/
-static void addExternal (decl_node n);
+static void doCaseIfLabelListC (mcPretty_pretty p, decl_node__opaque n);
/*
- includeDefConstType -
+ doCaseElseC -
*/
-static void includeDefConstType (decl_node n);
+static void doCaseElseC (mcPretty_pretty p, decl_node__opaque n);
/*
- runIncludeDefConstType -
+ doCaseIfElseC -
*/
-static void runIncludeDefConstType (decl_node n);
+static void doCaseIfElseC (mcPretty_pretty p, decl_node__opaque n);
/*
- joinProcedures - copies procedures from definition module,
- d, into implementation module, i.
+ canUseSwitchCaseLabels - returns TRUE if all the case labels are
+ single values and not ranges.
*/
-static void joinProcedures (decl_node i, decl_node d);
+static bool canUseSwitchCaseLabels (decl_node__opaque n);
/*
- includeDefVarProcedure -
+ canUseSwitch - returns TRUE if the case statement can be implement
+ by a switch statement. This will be TRUE if all case
+ selectors are single values rather than ranges.
*/
-static void includeDefVarProcedure (decl_node n);
+static bool canUseSwitch (decl_node__opaque n);
/*
- foreachModuleDo -
+ doCaseC -
*/
-static void foreachModuleDo (decl_node n, symbolKey_performOperation p);
+static void doCaseC (mcPretty_pretty p, decl_node__opaque n);
/*
- outDeclsImpC -
+ doLoopC -
*/
-static void outDeclsImpC (mcPretty_pretty p, decl_scopeT s);
+static void doLoopC (mcPretty_pretty p, decl_node__opaque s);
/*
- doStatementSequenceC -
+ doExitC -
*/
-static void doStatementSequenceC (mcPretty_pretty p, decl_node s);
+static void doExitC (mcPretty_pretty p, decl_node__opaque s);
/*
- isStatementSequenceEmpty -
+ doStatementsC -
*/
-static bool isStatementSequenceEmpty (decl_node s);
+static void doStatementsC (mcPretty_pretty p, decl_node__opaque s);
+static void localstop (void);
/*
- isSingleStatement - returns TRUE if the statement sequence, s, has
- only one statement.
+ doLocalVarC -
*/
-static bool isSingleStatement (decl_node s);
+static void doLocalVarC (mcPretty_pretty p, decl_scopeT s);
/*
- doCommentC -
+ doLocalConstTypesC -
*/
-static void doCommentC (mcPretty_pretty p, decl_node s);
+static void doLocalConstTypesC (mcPretty_pretty p, decl_scopeT s);
/*
- doAfterCommentC - emit an after comment, c, or a newline if, c, is empty.
+ addParamDone -
*/
-static void doAfterCommentC (mcPretty_pretty p, decl_node c);
+static void addParamDone (decl_node__opaque n);
/*
- doReturnC - issue a return statement and also place in an after comment if one exists.
+ includeParameters -
*/
-static void doReturnC (mcPretty_pretty p, decl_node s);
+static void includeParameters (decl_node__opaque n);
/*
- isZtypeEquivalent -
+ isHalt -
*/
-static bool isZtypeEquivalent (decl_node type);
+static bool isHalt (decl_node__opaque n);
/*
- isEquivalentType - returns TRUE if type1 and type2 are equivalent.
+ isReturnOrHalt -
*/
-static bool isEquivalentType (decl_node type1, decl_node type2);
+static bool isReturnOrHalt (decl_node__opaque n);
/*
- doExprCastC - build a cast if necessary.
+ isLastStatementReturn -
*/
-static void doExprCastC (mcPretty_pretty p, decl_node e, decl_node type);
+static bool isLastStatementReturn (decl_node__opaque n);
/*
- requiresUnpackProc - returns TRUE if either the expr is a procedure or the proctypes differ.
+ isLastStatementSequence -
*/
-static bool requiresUnpackProc (decl_node s);
+static bool isLastStatementSequence (decl_node__opaque n, decl_isNodeF q);
/*
- doAssignmentC -
+ isLastStatementIf -
*/
-static void doAssignmentC (mcPretty_pretty p, decl_node s);
+static bool isLastStatementIf (decl_node__opaque n, decl_isNodeF q);
/*
- containsStatement -
+ isLastStatementElsif -
*/
-static bool containsStatement (decl_node s);
+static bool isLastStatementElsif (decl_node__opaque n, decl_isNodeF q);
/*
- doCompoundStmt -
+ isLastStatementCase -
*/
-static void doCompoundStmt (mcPretty_pretty p, decl_node s);
+static bool isLastStatementCase (decl_node__opaque n, decl_isNodeF q);
/*
- doElsifC -
+ isLastStatement - returns TRUE if the last statement in, n, is, q.
*/
-static void doElsifC (mcPretty_pretty p, decl_node s);
+static bool isLastStatement (decl_node__opaque n, decl_isNodeF q);
/*
- noIfElse -
+ doProcedureC -
*/
-static bool noIfElse (decl_node n);
+static void doProcedureC (decl_node__opaque n);
/*
- noIfElseChained - returns TRUE if, n, is an IF statement which
- has no associated ELSE statement. An IF with an
- ELSIF is also checked for no ELSE and will result
- in a return value of TRUE.
+ outProceduresC -
*/
-static bool noIfElseChained (decl_node n);
+static void outProceduresC (mcPretty_pretty p, decl_scopeT s);
/*
- hasIfElse -
+ output -
*/
-static bool hasIfElse (decl_node n);
+static void output (decl_node__opaque n, decl_nodeProcedure c, decl_nodeProcedure t, decl_nodeProcedure v);
/*
- isIfElse -
+ allDependants -
*/
-static bool isIfElse (decl_node n);
+static decl_dependentState allDependants (decl_node__opaque n);
/*
- hasIfAndNoElse - returns TRUE if statement, n, is a single statement
- which is an IF and it has no else statement.
+ walkDependants -
*/
-static bool hasIfAndNoElse (decl_node n);
+static decl_dependentState walkDependants (alists_alist l, decl_node__opaque n);
/*
- doIfC - issue an if statement and also place in an after comment if one exists.
- The if statement might contain an else or elsif which are also handled.
+ walkType -
*/
-static void doIfC (mcPretty_pretty p, decl_node s);
+static decl_dependentState walkType (alists_alist l, decl_node__opaque n);
/*
- doForIncCP -
+ db -
*/
-static void doForIncCP (mcPretty_pretty p, decl_node s);
+static void db (const char *a_, unsigned int _a_high, decl_node__opaque n);
/*
- doForIncC -
+ dbt -
*/
-static void doForIncC (mcPretty_pretty p, decl_node s);
+static void dbt (const char *a_, unsigned int _a_high);
/*
- doForInc -
+ dbs -
*/
-static void doForInc (mcPretty_pretty p, decl_node s);
+static void dbs (decl_dependentState s, decl_node__opaque n);
/*
- doForC -
+ dbq -
*/
-static void doForC (mcPretty_pretty p, decl_node s);
+static void dbq (decl_node__opaque n);
/*
- doRepeatC -
+ walkRecord -
*/
-static void doRepeatC (mcPretty_pretty p, decl_node s);
+static decl_dependentState walkRecord (alists_alist l, decl_node__opaque n);
/*
- doWhileC -
+ walkVarient -
*/
-static void doWhileC (mcPretty_pretty p, decl_node s);
+static decl_dependentState walkVarient (alists_alist l, decl_node__opaque n);
/*
- doFuncHighC -
+ queueBlocked -
*/
-static void doFuncHighC (mcPretty_pretty p, decl_node a);
+static void queueBlocked (decl_node__opaque n);
/*
- doMultiplyBySize -
+ walkVar -
*/
-static void doMultiplyBySize (mcPretty_pretty p, decl_node a);
+static decl_dependentState walkVar (alists_alist l, decl_node__opaque n);
/*
- doTotype -
+ walkEnumeration -
*/
-static void doTotype (mcPretty_pretty p, decl_node a, decl_node t);
+static decl_dependentState walkEnumeration (alists_alist l, decl_node__opaque n);
/*
- doFuncUnbounded -
+ walkSubrange -
*/
-static void doFuncUnbounded (mcPretty_pretty p, decl_node actual, decl_node formalParam, decl_node formal, decl_node func);
+static decl_dependentState walkSubrange (alists_alist l, decl_node__opaque n);
/*
- doProcedureParamC -
+ walkSubscript -
*/
-static void doProcedureParamC (mcPretty_pretty p, decl_node actual, decl_node formal);
+static decl_dependentState walkSubscript (alists_alist l, decl_node__opaque n);
/*
- doAdrExprC -
+ walkPointer -
*/
-static void doAdrExprC (mcPretty_pretty p, decl_node n);
+static decl_dependentState walkPointer (alists_alist l, decl_node__opaque n);
/*
- typePair -
+ walkArray -
*/
-static bool typePair (decl_node a, decl_node b, decl_node x, decl_node y);
+static decl_dependentState walkArray (alists_alist l, decl_node__opaque n);
/*
- needsCast - return TRUE if the actual type parameter needs to be cast to
- the formal type.
+ walkConst -
*/
-static bool needsCast (decl_node at, decl_node ft);
+static decl_dependentState walkConst (alists_alist l, decl_node__opaque n);
/*
- checkSystemCast - checks to see if we are passing to/from
- a system generic type (WORD, BYTE, ADDRESS)
- and if so emit a cast. It returns the number of
- open parenthesis.
+ walkVarParam -
*/
-static unsigned int checkSystemCast (mcPretty_pretty p, decl_node actual, decl_node formal);
+static decl_dependentState walkVarParam (alists_alist l, decl_node__opaque n);
/*
- emitN -
+ walkParam -
*/
-static void emitN (mcPretty_pretty p, const char *a_, unsigned int _a_high, unsigned int n);
+static decl_dependentState walkParam (alists_alist l, decl_node__opaque n);
/*
- isForC - return true if node n is a varparam, param or procedure
- which was declared inside a definition module for "C".
+ walkOptarg -
*/
-static bool isForC (decl_node n);
+static decl_dependentState walkOptarg (alists_alist l, decl_node__opaque n);
/*
- isDefForCNode - return TRUE if node n was declared inside a definition module for "C".
+ walkRecordField -
*/
-static bool isDefForCNode (decl_node n);
+static decl_dependentState walkRecordField (alists_alist l, decl_node__opaque n);
/*
- doFuncParamC -
+ walkVarientField -
*/
-static void doFuncParamC (mcPretty_pretty p, decl_node actual, decl_node formal, decl_node func);
+static decl_dependentState walkVarientField (alists_alist l, decl_node__opaque n);
/*
- getNthParamType - return the type of parameter, i, in list, l.
- If the parameter is a vararg NIL is returned.
+ walkEnumerationField -
*/
-static decl_node getNthParamType (Indexing_Index l, unsigned int i);
+static decl_dependentState walkEnumerationField (alists_alist l, decl_node__opaque n);
/*
- getNthParam - return the parameter, i, in list, l.
- If the parameter is a vararg NIL is returned.
+ walkSet -
*/
-static decl_node getNthParam (Indexing_Index l, unsigned int i);
+static decl_dependentState walkSet (alists_alist l, decl_node__opaque n);
/*
- doFuncArgsC -
+ walkProcType -
*/
-static void doFuncArgsC (mcPretty_pretty p, decl_node s, Indexing_Index l, bool needParen);
+static decl_dependentState walkProcType (alists_alist l, decl_node__opaque n);
/*
- doProcTypeArgsC -
+ walkProcedure -
*/
-static void doProcTypeArgsC (mcPretty_pretty p, decl_node s, Indexing_Index args, bool needParen);
+static decl_dependentState walkProcedure (alists_alist l, decl_node__opaque n);
/*
- doAdrArgC -
+ walkParameters -
*/
-static void doAdrArgC (mcPretty_pretty p, decl_node n);
+static decl_dependentState walkParameters (alists_alist l, Indexing_Index p);
/*
- doAdrC -
+ walkFuncCall -
*/
-static void doAdrC (mcPretty_pretty p, decl_node n);
+static decl_dependentState walkFuncCall (alists_alist l, decl_node__opaque n);
/*
- doInc -
+ walkUnary -
*/
-static void doInc (mcPretty_pretty p, decl_node n);
+static decl_dependentState walkUnary (alists_alist l, decl_node__opaque n);
/*
- doDec -
+ walkBinary -
*/
-static void doDec (mcPretty_pretty p, decl_node n);
+static decl_dependentState walkBinary (alists_alist l, decl_node__opaque n);
/*
- doIncDecC -
+ walkComponentRef -
*/
-static void doIncDecC (mcPretty_pretty p, decl_node n, const char *op_, unsigned int _op_high);
+static decl_dependentState walkComponentRef (alists_alist l, decl_node__opaque n);
/*
- doIncDecCP -
+ walkPointerRef -
*/
-static void doIncDecCP (mcPretty_pretty p, decl_node n, const char *op_, unsigned int _op_high);
+static decl_dependentState walkPointerRef (alists_alist l, decl_node__opaque n);
/*
- doInclC -
+ walkSetValue -
*/
-static void doInclC (mcPretty_pretty p, decl_node n);
+static decl_dependentState walkSetValue (alists_alist l, decl_node__opaque n);
/*
- doExclC -
+ doDependants - return the dependentState depending upon whether
+ all dependants have been declared.
*/
-static void doExclC (mcPretty_pretty p, decl_node n);
+static decl_dependentState doDependants (alists_alist l, decl_node__opaque n);
/*
- doNewC -
+ tryComplete - returns TRUE if node, n, can be and was completed.
*/
-static void doNewC (mcPretty_pretty p, decl_node n);
+static bool tryComplete (decl_node__opaque n, decl_nodeProcedure c, decl_nodeProcedure t, decl_nodeProcedure v);
/*
- doDisposeC -
+ tryCompleteFromPartial -
*/
-static void doDisposeC (mcPretty_pretty p, decl_node n);
+static bool tryCompleteFromPartial (decl_node__opaque n, decl_nodeProcedure t);
/*
- doCapC -
+ visitIntrinsicFunction -
*/
-static void doCapC (mcPretty_pretty p, decl_node n);
+static void visitIntrinsicFunction (alists_alist v, decl_node__opaque n, decl_nodeProcedure p);
/*
- doLengthC -
+ visitUnary -
*/
-static void doLengthC (mcPretty_pretty p, decl_node n);
+static void visitUnary (alists_alist v, decl_node__opaque n, decl_nodeProcedure p);
/*
- doAbsC -
+ visitBinary -
*/
-static void doAbsC (mcPretty_pretty p, decl_node n);
+static void visitBinary (alists_alist v, decl_node__opaque n, decl_nodeProcedure p);
/*
- doValC -
+ visitBoolean -
*/
-static void doValC (mcPretty_pretty p, decl_node n);
+static void visitBoolean (alists_alist v, decl_node__opaque n, decl_nodeProcedure p);
/*
- doMinC -
+ visitScope -
*/
-static void doMinC (mcPretty_pretty p, decl_node n);
+static void visitScope (alists_alist v, decl_node__opaque n, decl_nodeProcedure p);
/*
- doMaxC -
+ visitType -
*/
-static void doMaxC (mcPretty_pretty p, decl_node n);
+static void visitType (alists_alist v, decl_node__opaque n, decl_nodeProcedure p);
/*
- isIntrinsic - returns if, n, is an intrinsic procedure.
- The intrinsic functions are represented as unary and binary nodes.
+ visitIndex -
*/
-static bool isIntrinsic (decl_node n);
+static void visitIndex (alists_alist v, Indexing_Index i, decl_nodeProcedure p);
/*
- doHalt -
+ visitRecord -
*/
-static void doHalt (mcPretty_pretty p, decl_node n);
+static void visitRecord (alists_alist v, decl_node__opaque n, decl_nodeProcedure p);
/*
- doCreal - emit the appropriate creal function.
+ visitVarient -
*/
-static void doCreal (mcPretty_pretty p, decl_node t);
+static void visitVarient (alists_alist v, decl_node__opaque n, decl_nodeProcedure p);
/*
- doCimag - emit the appropriate cimag function.
+ visitVar -
*/
-static void doCimag (mcPretty_pretty p, decl_node t);
+static void visitVar (alists_alist v, decl_node__opaque n, decl_nodeProcedure p);
/*
- doReC -
+ visitEnumeration -
*/
-static void doReC (mcPretty_pretty p, decl_node n);
+static void visitEnumeration (alists_alist v, decl_node__opaque n, decl_nodeProcedure p);
/*
- doImC -
+ visitSubrange -
*/
-static void doImC (mcPretty_pretty p, decl_node n);
+static void visitSubrange (alists_alist v, decl_node__opaque n, decl_nodeProcedure p);
/*
- doCmplx -
+ visitPointer -
*/
-static void doCmplx (mcPretty_pretty p, decl_node n);
+static void visitPointer (alists_alist v, decl_node__opaque n, decl_nodeProcedure p);
/*
- doIntrinsicC -
+ visitArray -
*/
-static void doIntrinsicC (mcPretty_pretty p, decl_node n);
+static void visitArray (alists_alist v, decl_node__opaque n, decl_nodeProcedure p);
/*
- isIntrinsicFunction - returns true if, n, is an instrinsic function.
+ visitConst -
*/
-static bool isIntrinsicFunction (decl_node n);
+static void visitConst (alists_alist v, decl_node__opaque n, decl_nodeProcedure p);
/*
- doSizeC -
+ visitVarParam -
*/
-static void doSizeC (mcPretty_pretty p, decl_node n);
+static void visitVarParam (alists_alist v, decl_node__opaque n, decl_nodeProcedure p);
/*
- doConvertC -
+ visitParam -
*/
-static void doConvertC (mcPretty_pretty p, decl_node n, const char *conversion_, unsigned int _conversion_high);
+static void visitParam (alists_alist v, decl_node__opaque n, decl_nodeProcedure p);
/*
- doConvertSC -
+ visitOptarg -
*/
-static void doConvertSC (mcPretty_pretty p, decl_node n, DynamicStrings_String conversion);
+static void visitOptarg (alists_alist v, decl_node__opaque n, decl_nodeProcedure p);
/*
- getFuncFromExpr -
+ visitRecordField -
*/
-static decl_node getFuncFromExpr (decl_node n);
+static void visitRecordField (alists_alist v, decl_node__opaque n, decl_nodeProcedure p);
/*
- doFuncExprC -
+ visitVarientField -
*/
-static void doFuncExprC (mcPretty_pretty p, decl_node n);
+static void visitVarientField (alists_alist v, decl_node__opaque n, decl_nodeProcedure p);
/*
- doFuncCallC -
+ visitEnumerationField -
*/
-static void doFuncCallC (mcPretty_pretty p, decl_node n);
+static void visitEnumerationField (alists_alist v, decl_node__opaque n, decl_nodeProcedure p);
/*
- doCaseStatementC -
+ visitSet -
*/
-static void doCaseStatementC (mcPretty_pretty p, decl_node n, bool needBreak);
+static void visitSet (alists_alist v, decl_node__opaque n, decl_nodeProcedure p);
/*
- doExceptionC -
+ visitProcType -
*/
-static void doExceptionC (mcPretty_pretty p, const char *a_, unsigned int _a_high, decl_node n);
+static void visitProcType (alists_alist v, decl_node__opaque n, decl_nodeProcedure p);
/*
- doExceptionCP -
+ visitSubscript -
*/
-static void doExceptionCP (mcPretty_pretty p, const char *a_, unsigned int _a_high, decl_node n);
+static void visitSubscript (alists_alist v, decl_node__opaque n, decl_nodeProcedure p);
/*
- doException -
+ visitDecls -
*/
-static void doException (mcPretty_pretty p, const char *a_, unsigned int _a_high, decl_node n);
+static void visitDecls (alists_alist v, decl_scopeT s, decl_nodeProcedure p);
/*
- doRangeListC -
+ visitProcedure -
*/
-static void doRangeListC (mcPretty_pretty p, decl_node c);
+static void visitProcedure (alists_alist v, decl_node__opaque n, decl_nodeProcedure p);
/*
- doRangeIfListC -
+ visitDef -
*/
-static void doRangeIfListC (mcPretty_pretty p, decl_node e, decl_node c);
+static void visitDef (alists_alist v, decl_node__opaque n, decl_nodeProcedure p);
/*
- doCaseLabels -
+ visitImp -
*/
-static void doCaseLabels (mcPretty_pretty p, decl_node n, bool needBreak);
+static void visitImp (alists_alist v, decl_node__opaque n, decl_nodeProcedure p);
/*
- doCaseLabelListC -
+ visitModule -
*/
-static void doCaseLabelListC (mcPretty_pretty p, decl_node n, bool haveElse);
+static void visitModule (alists_alist v, decl_node__opaque n, decl_nodeProcedure p);
/*
- doCaseIfLabels -
+ visitLoop -
*/
-static void doCaseIfLabels (mcPretty_pretty p, decl_node e, decl_node n, unsigned int i, unsigned int h);
+static void visitLoop (alists_alist v, decl_node__opaque n, decl_nodeProcedure p);
/*
- doCaseIfLabelListC -
+ visitWhile -
*/
-static void doCaseIfLabelListC (mcPretty_pretty p, decl_node n);
+static void visitWhile (alists_alist v, decl_node__opaque n, decl_nodeProcedure p);
/*
- doCaseElseC -
+ visitRepeat -
*/
-static void doCaseElseC (mcPretty_pretty p, decl_node n);
+static void visitRepeat (alists_alist v, decl_node__opaque n, decl_nodeProcedure p);
/*
- doCaseIfElseC -
+ visitCase -
*/
-static void doCaseIfElseC (mcPretty_pretty p, decl_node n);
+static void visitCase (alists_alist v, decl_node__opaque n, decl_nodeProcedure p);
/*
- canUseSwitchCaseLabels - returns TRUE if all the case labels are
- single values and not ranges.
+ visitCaseLabelList -
*/
-static bool canUseSwitchCaseLabels (decl_node n);
+static void visitCaseLabelList (alists_alist v, decl_node__opaque n, decl_nodeProcedure p);
/*
- canUseSwitch - returns TRUE if the case statement can be implement
- by a switch statement. This will be TRUE if all case
- selectors are single values rather than ranges.
+ visitCaseList -
*/
-static bool canUseSwitch (decl_node n);
+static void visitCaseList (alists_alist v, decl_node__opaque n, decl_nodeProcedure p);
/*
- doCaseC -
+ visitRange -
*/
-static void doCaseC (mcPretty_pretty p, decl_node n);
+static void visitRange (alists_alist v, decl_node__opaque n, decl_nodeProcedure p);
/*
- doLoopC -
+ visitIf -
*/
-static void doLoopC (mcPretty_pretty p, decl_node s);
+static void visitIf (alists_alist v, decl_node__opaque n, decl_nodeProcedure p);
/*
- doExitC -
+ visitElsif -
*/
-static void doExitC (mcPretty_pretty p, decl_node s);
+static void visitElsif (alists_alist v, decl_node__opaque n, decl_nodeProcedure p);
/*
- doStatementsC -
+ visitFor -
*/
-static void doStatementsC (mcPretty_pretty p, decl_node s);
-static void stop (void);
+static void visitFor (alists_alist v, decl_node__opaque n, decl_nodeProcedure p);
/*
- doLocalVarC -
+ visitAssignment -
*/
-static void doLocalVarC (mcPretty_pretty p, decl_scopeT s);
+static void visitAssignment (alists_alist v, decl_node__opaque n, decl_nodeProcedure p);
/*
- doLocalConstTypesC -
+ visitComponentRef -
*/
-static void doLocalConstTypesC (mcPretty_pretty p, decl_scopeT s);
+static void visitComponentRef (alists_alist v, decl_node__opaque n, decl_nodeProcedure p);
/*
- addParamDone -
+ visitPointerRef -
*/
-static void addParamDone (decl_node n);
+static void visitPointerRef (alists_alist v, decl_node__opaque n, decl_nodeProcedure p);
/*
- includeParameters -
+ visitArrayRef -
*/
-static void includeParameters (decl_node n);
+static void visitArrayRef (alists_alist v, decl_node__opaque n, decl_nodeProcedure p);
/*
- isHalt -
+ visitFunccall -
*/
-static bool isHalt (decl_node n);
+static void visitFunccall (alists_alist v, decl_node__opaque n, decl_nodeProcedure p);
/*
- isReturnOrHalt -
+ visitVarDecl -
*/
-static bool isReturnOrHalt (decl_node n);
+static void visitVarDecl (alists_alist v, decl_node__opaque n, decl_nodeProcedure p);
/*
- isLastStatementReturn -
+ visitExplist -
*/
-static bool isLastStatementReturn (decl_node n);
+static void visitExplist (alists_alist v, decl_node__opaque n, decl_nodeProcedure p);
/*
- isLastStatementSequence -
+ visitExit -
*/
-static bool isLastStatementSequence (decl_node n, decl_isNodeF q);
+static void visitExit (alists_alist v, decl_node__opaque n, decl_nodeProcedure p);
/*
- isLastStatementIf -
+ visitReturn -
*/
-static bool isLastStatementIf (decl_node n, decl_isNodeF q);
+static void visitReturn (alists_alist v, decl_node__opaque n, decl_nodeProcedure p);
/*
- isLastStatementElsif -
+ visitStmtSeq -
*/
-static bool isLastStatementElsif (decl_node n, decl_isNodeF q);
+static void visitStmtSeq (alists_alist v, decl_node__opaque n, decl_nodeProcedure p);
/*
- isLastStatementCase -
+ visitVarargs -
*/
-static bool isLastStatementCase (decl_node n, decl_isNodeF q);
+static void visitVarargs (alists_alist v, decl_node__opaque n, decl_nodeProcedure p);
/*
- isLastStatement - returns TRUE if the last statement in, n, is, q.
+ visitSetValue -
*/
-static bool isLastStatement (decl_node n, decl_isNodeF q);
+static void visitSetValue (alists_alist v, decl_node__opaque n, decl_nodeProcedure p);
/*
- doProcedureC -
+ visitIntrinsic -
*/
-static void doProcedureC (decl_node n);
+static void visitIntrinsic (alists_alist v, decl_node__opaque n, decl_nodeProcedure p);
/*
- outProceduresC -
+ visitDependants - helper procedure function called from visitNode.
+ node n has just been visited, this procedure will
+ visit node, n, dependants.
*/
-static void outProceduresC (mcPretty_pretty p, decl_scopeT s);
+static void visitDependants (alists_alist v, decl_node__opaque n, decl_nodeProcedure p);
/*
- output -
+ visitNode - visits node, n, if it is not already in the alist, v.
+ It calls p(n) if the node is unvisited.
*/
-static void output (decl_node n, decl_nodeProcedure c, decl_nodeProcedure t, decl_nodeProcedure v);
+static void visitNode (alists_alist v, decl_node__opaque n, decl_nodeProcedure p);
/*
- allDependants -
+ genKind - returns a string depending upon the kind of node, n.
*/
-static decl_dependentState allDependants (decl_node n);
+static DynamicStrings_String genKind (decl_node__opaque n);
/*
- walkDependants -
+ gen - generate a small string describing node, n.
*/
-static decl_dependentState walkDependants (alists_alist l, decl_node n);
+static DynamicStrings_String gen (decl_node__opaque n);
/*
- walkType -
+ dumpQ -
*/
-static decl_dependentState walkType (alists_alist l, decl_node n);
+static void dumpQ (const char *q_, unsigned int _q_high, alists_alist l);
/*
- db -
+ dumpLists -
*/
-static void db (const char *a_, unsigned int _a_high, decl_node n);
+static void dumpLists (void);
/*
- dbt -
+ outputHidden -
*/
-static void dbt (const char *a_, unsigned int _a_high);
+static void outputHidden (decl_node__opaque n);
/*
- dbs -
+ outputHiddenComplete -
*/
-static void dbs (decl_dependentState s, decl_node n);
+static void outputHiddenComplete (decl_node__opaque n);
/*
- dbq -
+ tryPartial -
*/
-static void dbq (decl_node n);
+static bool tryPartial (decl_node__opaque n, decl_nodeProcedure pt);
/*
- walkRecord -
+ outputPartialRecordArrayProcType -
*/
-static decl_dependentState walkRecord (alists_alist l, decl_node n);
+static void outputPartialRecordArrayProcType (decl_node__opaque n, decl_node__opaque q, unsigned int indirection);
/*
- walkVarient -
+ outputPartial -
*/
-static decl_dependentState walkVarient (alists_alist l, decl_node n);
+static void outputPartial (decl_node__opaque n);
/*
- queueBlocked -
+ tryOutputTodo -
*/
-static void queueBlocked (decl_node n);
+static void tryOutputTodo (decl_nodeProcedure c, decl_nodeProcedure t, decl_nodeProcedure v, decl_nodeProcedure pt);
/*
- walkVar -
+ tryOutputPartial -
*/
-static decl_dependentState walkVar (alists_alist l, decl_node n);
+static void tryOutputPartial (decl_nodeProcedure t);
/*
- walkEnumeration -
+ debugList -
*/
-static decl_dependentState walkEnumeration (alists_alist l, decl_node n);
+static void debugList (const char *listName_, unsigned int _listName_high, const char *symName_, unsigned int _symName_high, alists_alist l);
/*
- walkSubrange -
+ debugLists -
*/
-static decl_dependentState walkSubrange (alists_alist l, decl_node n);
+static void debugLists (void);
/*
- walkSubscript -
+ addEnumConst -
*/
-static decl_dependentState walkSubscript (alists_alist l, decl_node n);
+static void addEnumConst (decl_node__opaque n);
/*
- walkPointer -
+ populateTodo -
*/
-static decl_dependentState walkPointer (alists_alist l, decl_node n);
+static void populateTodo (decl_nodeProcedure p);
/*
- walkArray -
+ topologicallyOut - keep trying to resolve the todoQ and partialQ
+ until there is no change from the global group.
*/
-static decl_dependentState walkArray (alists_alist l, decl_node n);
+static void topologicallyOut (decl_nodeProcedure c, decl_nodeProcedure t, decl_nodeProcedure v, decl_nodeProcedure tp, decl_nodeProcedure pc, decl_nodeProcedure pt, decl_nodeProcedure pv);
/*
- walkConst -
+ scaffoldStatic -
*/
-static decl_dependentState walkConst (alists_alist l, decl_node n);
+static void scaffoldStatic (mcPretty_pretty p, decl_node__opaque n);
/*
- walkVarParam -
+ emitCtor -
*/
-static decl_dependentState walkVarParam (alists_alist l, decl_node n);
+static void emitCtor (mcPretty_pretty p, decl_node__opaque n);
/*
- walkParam -
+ scaffoldDynamic -
*/
-static decl_dependentState walkParam (alists_alist l, decl_node n);
+static void scaffoldDynamic (mcPretty_pretty p, decl_node__opaque n);
/*
- walkOptarg -
+ scaffoldMain -
*/
-static decl_dependentState walkOptarg (alists_alist l, decl_node n);
+static void scaffoldMain (mcPretty_pretty p, decl_node__opaque n);
/*
- walkRecordField -
+ outImpInitC - emit the init/fini functions and main function if required.
*/
-static decl_dependentState walkRecordField (alists_alist l, decl_node n);
+static void outImpInitC (mcPretty_pretty p, decl_node__opaque n);
/*
- walkVarientField -
+ runSimplifyTypes -
*/
-static decl_dependentState walkVarientField (alists_alist l, decl_node n);
+static void runSimplifyTypes (decl_node__opaque n);
/*
- walkEnumerationField -
+ outDefC -
*/
-static decl_dependentState walkEnumerationField (alists_alist l, decl_node n);
+static void outDefC (mcPretty_pretty p, decl_node__opaque n);
/*
- walkSet -
+ runPrototypeExported -
*/
-static decl_dependentState walkSet (alists_alist l, decl_node n);
+static void runPrototypeExported (decl_node__opaque n);
/*
- walkProcType -
+ runPrototypeDefC -
*/
-static decl_dependentState walkProcType (alists_alist l, decl_node n);
+static void runPrototypeDefC (decl_node__opaque n);
/*
- walkProcedure -
+ outImpC -
*/
-static decl_dependentState walkProcedure (alists_alist l, decl_node n);
+static void outImpC (mcPretty_pretty p, decl_node__opaque n);
/*
- walkParameters -
+ outDeclsModuleC -
*/
-static decl_dependentState walkParameters (alists_alist l, Indexing_Index p);
+static void outDeclsModuleC (mcPretty_pretty p, decl_scopeT s);
/*
- walkFuncCall -
+ outModuleInitC -
*/
-static decl_dependentState walkFuncCall (alists_alist l, decl_node n);
+static void outModuleInitC (mcPretty_pretty p, decl_node__opaque n);
/*
- walkUnary -
+ outModuleC -
*/
-static decl_dependentState walkUnary (alists_alist l, decl_node n);
+static void outModuleC (mcPretty_pretty p, decl_node__opaque n);
/*
- walkBinary -
+ outC -
*/
-static decl_dependentState walkBinary (alists_alist l, decl_node n);
+static void outC (mcPretty_pretty p, decl_node__opaque n);
/*
- walkComponentRef -
+ doIncludeM2 - include modules in module, n.
*/
-static decl_dependentState walkComponentRef (alists_alist l, decl_node n);
+static void doIncludeM2 (decl_node__opaque n);
/*
- walkPointerRef -
+ doConstM2 -
*/
-static decl_dependentState walkPointerRef (alists_alist l, decl_node n);
+static void doConstM2 (decl_node__opaque n);
/*
- walkSetValue -
+ doProcTypeM2 -
*/
-static decl_dependentState walkSetValue (alists_alist l, decl_node n);
+static void doProcTypeM2 (mcPretty_pretty p, decl_node__opaque n);
/*
- doDependants - return the dependentState depending upon whether
- all dependants have been declared.
+ doRecordFieldM2 -
*/
-static decl_dependentState doDependants (alists_alist l, decl_node n);
+static void doRecordFieldM2 (mcPretty_pretty p, decl_node__opaque f);
/*
- tryComplete - returns TRUE if node, n, can be and was completed.
+ doVarientFieldM2 -
*/
-static bool tryComplete (decl_node n, decl_nodeProcedure c, decl_nodeProcedure t, decl_nodeProcedure v);
+static void doVarientFieldM2 (mcPretty_pretty p, decl_node__opaque n);
/*
- tryCompleteFromPartial -
+ doVarientM2 -
*/
-static bool tryCompleteFromPartial (decl_node n, decl_nodeProcedure t);
+static void doVarientM2 (mcPretty_pretty p, decl_node__opaque n);
/*
- visitIntrinsicFunction -
+ doRecordM2 -
*/
-static void visitIntrinsicFunction (alists_alist v, decl_node n, decl_nodeProcedure p);
+static void doRecordM2 (mcPretty_pretty p, decl_node__opaque n);
/*
- visitUnary -
+ doPointerM2 -
*/
-static void visitUnary (alists_alist v, decl_node n, decl_nodeProcedure p);
+static void doPointerM2 (mcPretty_pretty p, decl_node__opaque n);
/*
- visitBinary -
+ doTypeAliasM2 -
*/
-static void visitBinary (alists_alist v, decl_node n, decl_nodeProcedure p);
+static void doTypeAliasM2 (mcPretty_pretty p, decl_node__opaque n);
/*
- visitBoolean -
+ doEnumerationM2 -
*/
-static void visitBoolean (alists_alist v, decl_node n, decl_nodeProcedure p);
+static void doEnumerationM2 (mcPretty_pretty p, decl_node__opaque n);
/*
- visitScope -
+ doBaseM2 -
*/
-static void visitScope (alists_alist v, decl_node n, decl_nodeProcedure p);
+static void doBaseM2 (mcPretty_pretty p, decl_node__opaque n);
/*
- visitType -
+ doSystemM2 -
*/
-static void visitType (alists_alist v, decl_node n, decl_nodeProcedure p);
+static void doSystemM2 (mcPretty_pretty p, decl_node__opaque n);
/*
- visitIndex -
+ doTypeM2 -
*/
-static void visitIndex (alists_alist v, Indexing_Index i, decl_nodeProcedure p);
+static void doTypeM2 (mcPretty_pretty p, decl_node__opaque n);
/*
- visitRecord -
+ doTypesM2 -
*/
-static void visitRecord (alists_alist v, decl_node n, decl_nodeProcedure p);
+static void doTypesM2 (decl_node__opaque n);
/*
- visitVarient -
+ doVarM2 -
*/
-static void visitVarient (alists_alist v, decl_node n, decl_nodeProcedure p);
+static void doVarM2 (decl_node__opaque n);
/*
- visitVar -
+ doVarsM2 -
*/
-static void visitVar (alists_alist v, decl_node n, decl_nodeProcedure p);
+static void doVarsM2 (decl_node__opaque n);
/*
- visitEnumeration -
+ doTypeNameM2 -
*/
-static void visitEnumeration (alists_alist v, decl_node n, decl_nodeProcedure p);
+static void doTypeNameM2 (mcPretty_pretty p, decl_node__opaque n);
/*
- visitSubrange -
+ doParamM2 -
*/
-static void visitSubrange (alists_alist v, decl_node n, decl_nodeProcedure p);
+static void doParamM2 (mcPretty_pretty p, decl_node__opaque n);
/*
- visitPointer -
+ doVarParamM2 -
*/
-static void visitPointer (alists_alist v, decl_node n, decl_nodeProcedure p);
+static void doVarParamM2 (mcPretty_pretty p, decl_node__opaque n);
/*
- visitArray -
+ doParameterM2 -
*/
-static void visitArray (alists_alist v, decl_node n, decl_nodeProcedure p);
+static void doParameterM2 (mcPretty_pretty p, decl_node__opaque n);
/*
- visitConst -
+ doPrototypeM2 -
*/
-static void visitConst (alists_alist v, decl_node n, decl_nodeProcedure p);
+static void doPrototypeM2 (decl_node__opaque n);
/*
- visitVarParam -
+ outputPartialM2 - just writes out record, array, and proctypes.
+ No need for forward declarations in Modula-2
+ but we need to keep topological sort happy.
+ So when asked to output partial we emit the
+ full type for these types and then do nothing
+ when trying to complete partial to full.
*/
-static void visitVarParam (alists_alist v, decl_node n, decl_nodeProcedure p);
+static void outputPartialM2 (decl_node__opaque n);
/*
- visitParam -
+ outDeclsDefM2 -
*/
-static void visitParam (alists_alist v, decl_node n, decl_nodeProcedure p);
+static void outDeclsDefM2 (mcPretty_pretty p, decl_scopeT s);
/*
- visitOptarg -
+ outDefM2 -
*/
-static void visitOptarg (alists_alist v, decl_node n, decl_nodeProcedure p);
+static void outDefM2 (mcPretty_pretty p, decl_node__opaque n);
/*
- visitRecordField -
+ outDeclsImpM2 -
*/
-static void visitRecordField (alists_alist v, decl_node n, decl_nodeProcedure p);
+static void outDeclsImpM2 (mcPretty_pretty p, decl_scopeT s);
/*
- visitVarientField -
+ outImpM2 -
*/
-static void visitVarientField (alists_alist v, decl_node n, decl_nodeProcedure p);
+static void outImpM2 (mcPretty_pretty p, decl_node__opaque n);
/*
- visitEnumerationField -
+ outModuleM2 -
*/
-static void visitEnumerationField (alists_alist v, decl_node n, decl_nodeProcedure p);
+static void outModuleM2 (mcPretty_pretty p, decl_node__opaque n);
/*
- visitSet -
+ outM2 -
*/
-static void visitSet (alists_alist v, decl_node n, decl_nodeProcedure p);
+static void outM2 (mcPretty_pretty p, decl_node__opaque n);
/*
- visitProcType -
+ addDone - adds node, n, to the doneQ.
*/
-static void visitProcType (alists_alist v, decl_node n, decl_nodeProcedure p);
+static void addDone (decl_node__opaque n);
/*
- visitSubscript -
+ addDoneDef - adds node, n, to the doneQ providing
+ it is not an opaque of the main module we are compiling.
*/
-static void visitSubscript (alists_alist v, decl_node n, decl_nodeProcedure p);
+static void addDoneDef (decl_node__opaque n);
/*
- visitDecls -
+ dbgAdd -
*/
-static void visitDecls (alists_alist v, decl_scopeT s, decl_nodeProcedure p);
+static decl_node__opaque dbgAdd (alists_alist l, decl_node__opaque n);
/*
- visitProcedure -
+ dbgType -
*/
-static void visitProcedure (alists_alist v, decl_node n, decl_nodeProcedure p);
+static void dbgType (alists_alist l, decl_node__opaque n);
/*
- visitDef -
+ dbgPointer -
*/
-static void visitDef (alists_alist v, decl_node n, decl_nodeProcedure p);
+static void dbgPointer (alists_alist l, decl_node__opaque n);
/*
- visitImp -
+ dbgRecord -
*/
-static void visitImp (alists_alist v, decl_node n, decl_nodeProcedure p);
+static void dbgRecord (alists_alist l, decl_node__opaque n);
/*
- visitModule -
+ dbgVarient -
*/
-static void visitModule (alists_alist v, decl_node n, decl_nodeProcedure p);
+static void dbgVarient (alists_alist l, decl_node__opaque n);
/*
- visitLoop -
+ dbgEnumeration -
*/
-static void visitLoop (alists_alist v, decl_node n, decl_nodeProcedure p);
+static void dbgEnumeration (alists_alist l, decl_node__opaque n);
/*
- visitWhile -
+ dbgVar -
*/
-static void visitWhile (alists_alist v, decl_node n, decl_nodeProcedure p);
+static void dbgVar (alists_alist l, decl_node__opaque n);
/*
- visitRepeat -
+ dbgSubrange -
*/
-static void visitRepeat (alists_alist v, decl_node n, decl_nodeProcedure p);
+static void dbgSubrange (alists_alist l, decl_node__opaque n);
/*
- visitCase -
+ dbgArray -
*/
-static void visitCase (alists_alist v, decl_node n, decl_nodeProcedure p);
+static void dbgArray (alists_alist l, decl_node__opaque n);
/*
- visitCaseLabelList -
+ doDbg -
*/
-static void visitCaseLabelList (alists_alist v, decl_node n, decl_nodeProcedure p);
+static void doDbg (alists_alist l, decl_node__opaque n);
/*
- visitCaseList -
+ dbg -
*/
-static void visitCaseList (alists_alist v, decl_node n, decl_nodeProcedure p);
+static void dbg (const char *listName_, unsigned int _listName_high, const char *symName_, unsigned int _symName_high, decl_node__opaque n);
/*
- visitRange -
+ addGenericBody - adds comment node to funccall, return, assignment
+ nodes.
*/
-static void visitRange (alists_alist v, decl_node n, decl_nodeProcedure p);
+static void addGenericBody (decl_node__opaque n, decl_node__opaque c);
/*
- visitIf -
+ addGenericAfter - adds comment node to funccall, return, assignment
+ nodes.
*/
-static void visitIf (alists_alist v, decl_node n, decl_nodeProcedure p);
+static void addGenericAfter (decl_node__opaque n, decl_node__opaque c);
/*
- visitElsif -
+ isAssignment -
*/
-static void visitElsif (alists_alist v, decl_node n, decl_nodeProcedure p);
+static bool isAssignment (decl_node__opaque n);
/*
- visitFor -
+ isComment - returns TRUE if node, n, is a comment.
*/
-static void visitFor (alists_alist v, decl_node n, decl_nodeProcedure p);
+static bool isComment (decl_node__opaque n);
/*
- visitAssignment -
+ initPair - initialise the commentPair, c.
*/
-static void visitAssignment (alists_alist v, decl_node n, decl_nodeProcedure p);
+static void initPair (decl_commentPair *c);
/*
- visitComponentRef -
+ dupExplist -
*/
-static void visitComponentRef (alists_alist v, decl_node n, decl_nodeProcedure p);
+static decl_node__opaque dupExplist (decl_node__opaque n);
/*
- visitPointerRef -
+ dupArrayref -
*/
-static void visitPointerRef (alists_alist v, decl_node n, decl_nodeProcedure p);
+static decl_node__opaque dupArrayref (decl_node__opaque n);
/*
- visitArrayRef -
+ dupPointerref -
*/
-static void visitArrayRef (alists_alist v, decl_node n, decl_nodeProcedure p);
+static decl_node__opaque dupPointerref (decl_node__opaque n);
/*
- visitFunccall -
+ dupComponentref -
*/
-static void visitFunccall (alists_alist v, decl_node n, decl_nodeProcedure p);
+static decl_node__opaque dupComponentref (decl_node__opaque n);
/*
- visitVarDecl -
+ dupBinary -
*/
-static void visitVarDecl (alists_alist v, decl_node n, decl_nodeProcedure p);
+static decl_node__opaque dupBinary (decl_node__opaque n);
/*
- visitExplist -
+ dupUnary -
*/
-static void visitExplist (alists_alist v, decl_node n, decl_nodeProcedure p);
+static decl_node__opaque dupUnary (decl_node__opaque n);
/*
- visitExit -
+ dupFunccall -
*/
-static void visitExit (alists_alist v, decl_node n, decl_nodeProcedure p);
+static decl_node__opaque dupFunccall (decl_node__opaque n);
/*
- visitReturn -
+ dupSetValue -
*/
-static void visitReturn (alists_alist v, decl_node n, decl_nodeProcedure p);
+static decl_node__opaque dupSetValue (decl_node__opaque n);
/*
- visitStmtSeq -
+ doDupExpr -
*/
-static void visitStmtSeq (alists_alist v, decl_node n, decl_nodeProcedure p);
+static decl_node__opaque doDupExpr (decl_node__opaque n);
/*
- visitVarargs -
+ makeSystem -
*/
-static void visitVarargs (alists_alist v, decl_node n, decl_nodeProcedure p);
+static void makeSystem (void);
/*
- visitSetValue -
+ makeM2rts -
*/
-static void visitSetValue (alists_alist v, decl_node n, decl_nodeProcedure p);
+static void makeM2rts (void);
/*
- visitIntrinsic -
+ makeBitnum -
*/
-static void visitIntrinsic (alists_alist v, decl_node n, decl_nodeProcedure p);
+static decl_node__opaque makeBitnum (void);
/*
- visitDependants - helper procedure function called from visitNode.
- node n has just been visited, this procedure will
- visit node, n, dependants.
+ makeBaseSymbols -
*/
-static void visitDependants (alists_alist v, decl_node n, decl_nodeProcedure p);
+static void makeBaseSymbols (void);
/*
- visitNode - visits node, n, if it is not already in the alist, v.
- It calls p(n) if the node is unvisited.
+ makeBuiltins -
*/
-static void visitNode (alists_alist v, decl_node n, decl_nodeProcedure p);
+static void makeBuiltins (void);
/*
- genKind - returns a string depending upon the kind of node, n.
+ init -
*/
-static DynamicStrings_String genKind (decl_node n);
-
-/*
- gen - generate a small string describing node, n.
-*/
+static void init (void);
-static DynamicStrings_String gen (decl_node n);
/*
- dumpQ -
+ newNode - create and return a new node of kind k.
*/
-static void dumpQ (const char *q_, unsigned int _q_high, alists_alist l);
+static decl_node__opaque newNode (decl_nodeT k)
+{
+ decl_node__opaque d;
-/*
- dumpLists -
-*/
+ Storage_ALLOCATE ((void **) &d, sizeof (decl_nodeRec));
+ if (enableMemsetOnAllocation)
+ {
+ d = static_cast<decl_node__opaque> (libc_memset (reinterpret_cast<void *> (d), 0, static_cast<size_t> (sizeof ((*d)))));
+ }
+ if (d == NULL)
+ {
+ M2RTS_HALT (-1);
+ __builtin_unreachable ();
+ }
+ else
+ {
+ d->kind = k;
+ d->at.defDeclared = 0;
+ d->at.modDeclared = 0;
+ d->at.firstUsed = 0;
+ return d;
+ }
+ ReturnException ("../../gcc/m2/mc/decl.def", 20, 1);
+ __builtin_unreachable ();
+}
-static void dumpLists (void);
/*
- outputHidden -
+ disposeNode - dispose node, n.
*/
-static void outputHidden (decl_node n);
-
-/*
- outputHiddenComplete -
-*/
+static void disposeNode (decl_node__opaque *n)
+{
+ Storage_DEALLOCATE ((void **) &(*n), sizeof (decl_nodeRec));
+ (*n) = static_cast<decl_node__opaque> (NULL);
+}
-static void outputHiddenComplete (decl_node n);
/*
- tryPartial -
+ newGroup -
*/
-static bool tryPartial (decl_node n, decl_nodeProcedure pt);
+static void newGroup (decl_group *g)
+{
+ if (freeGroup == NULL)
+ {
+ Storage_ALLOCATE ((void **) &(*g), sizeof (decl__T1));
+ }
+ else
+ {
+ (*g) = freeGroup;
+ freeGroup = freeGroup->next;
+ }
+}
+
/*
- outputPartialRecordArrayProcType -
+ initGroup - returns a group which with all lists initialized.
*/
-static void outputPartialRecordArrayProcType (decl_node n, decl_node q, unsigned int indirection);
+static decl_group initGroup (void)
+{
+ decl_group g;
-/*
- outputPartial -
-*/
+ newGroup (&g);
+ g->todoQ = alists_initList ();
+ g->partialQ = alists_initList ();
+ g->doneQ = alists_initList ();
+ g->next = NULL;
+ return g;
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
+}
-static void outputPartial (decl_node n);
/*
- tryOutputTodo -
+ killGroup - deallocate the group and place the group record into the freeGroup list.
*/
-static void tryOutputTodo (decl_nodeProcedure c, decl_nodeProcedure t, decl_nodeProcedure v, decl_nodeProcedure pt);
+static void killGroup (decl_group *g)
+{
+ alists_killList (&(*g)->todoQ);
+ alists_killList (&(*g)->partialQ);
+ alists_killList (&(*g)->doneQ);
+ (*g)->next = freeGroup;
+ freeGroup = (*g);
+}
+
/*
- tryOutputPartial -
+ dupGroup - If g is not NIL then destroy g.
+ Return a duplicate of GlobalGroup (not g).
*/
-static void tryOutputPartial (decl_nodeProcedure t);
+static decl_group dupGroup (decl_group g)
+{
+ if (g != NULL)
+ {
+ /* Kill old group. */
+ killGroup (&g);
+ }
+ newGroup (&g);
+ /* Copy all lists. */
+ g->todoQ = alists_duplicateList (globalGroup->todoQ);
+ g->partialQ = alists_duplicateList (globalGroup->partialQ);
+ g->doneQ = alists_duplicateList (globalGroup->doneQ);
+ g->next = NULL;
+ return g;
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
+}
+
/*
- debugList -
+ equalGroup - return TRUE if group left = right.
*/
-static void debugList (const char *a_, unsigned int _a_high, alists_alist l);
+static bool equalGroup (decl_group left, decl_group right)
+{
+ return (left == right) || (((alists_equalList (left->todoQ, right->todoQ)) && (alists_equalList (left->partialQ, right->partialQ))) && (alists_equalList (left->doneQ, right->doneQ)));
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
+}
+
/*
- debugLists -
+ isLocal - returns TRUE if symbol, n, is locally declared in a procedure.
*/
-static void debugLists (void);
+static bool isLocal (decl_node__opaque n)
+{
+ decl_node__opaque s;
-/*
- addEnumConst -
-*/
+ s = static_cast<decl_node__opaque> (decl_getScope (static_cast<decl_node> (n)));
+ if (s != NULL)
+ {
+ return decl_isProcedure (static_cast<decl_node> (s));
+ }
+ return false;
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
+}
-static void addEnumConst (decl_node n);
/*
- populateTodo -
+ importEnumFields - if, n, is an enumeration type import the all fields into module, m.
*/
-static void populateTodo (decl_nodeProcedure p);
+static void importEnumFields (decl_node__opaque m, decl_node__opaque n)
+{
+ decl_node__opaque r;
+ decl_node__opaque e;
+ unsigned int i;
+ unsigned int h;
-/*
- topologicallyOut - keep trying to resolve the todoQ and partialQ
- until there is no change from the global group.
-*/
+ mcDebug_assert (((decl_isDef (static_cast<decl_node> (m))) || (decl_isModule (static_cast<decl_node> (m)))) || (decl_isImp (static_cast<decl_node> (m))));
+ n = static_cast<decl_node__opaque> (decl_skipType (static_cast<decl_node> (n)));
+ if ((n != NULL) && (decl_isEnumeration (static_cast<decl_node> (n))))
+ {
+ i = Indexing_LowIndice (n->enumerationF.listOfSons);
+ h = Indexing_HighIndice (n->enumerationF.listOfSons);
+ while (i <= h)
+ {
+ e = static_cast<decl_node__opaque> (Indexing_GetIndice (n->enumerationF.listOfSons, i));
+ r = static_cast<decl_node__opaque> (decl_import (static_cast<decl_node> (m), static_cast<decl_node> (e)));
+ if (e != r)
+ {
+ mcMetaError_metaError2 ((const char *) "enumeration field {%1ad} cannot be imported implicitly into {%2d} due to a name clash", 85, (const unsigned char *) &e, (sizeof (e)-1), (const unsigned char *) &m, (sizeof (m)-1));
+ }
+ i += 1;
+ }
+ }
+}
-static void topologicallyOut (decl_nodeProcedure c, decl_nodeProcedure t, decl_nodeProcedure v, decl_nodeProcedure tp, decl_nodeProcedure pc, decl_nodeProcedure pt, decl_nodeProcedure pv);
/*
- scaffoldStatic -
+ isComplex - returns TRUE if, n, is the complex type.
*/
-static void scaffoldStatic (mcPretty_pretty p, decl_node n);
+static bool isComplex (decl_node__opaque n)
+{
+ return n == complexN;
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
+}
+
/*
- emitCtor -
+ isLongComplex - returns TRUE if, n, is the longcomplex type.
*/
-static void emitCtor (mcPretty_pretty p, decl_node n);
+static bool isLongComplex (decl_node__opaque n)
+{
+ return n == longcomplexN;
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
+}
+
/*
- scaffoldDynamic -
+ isShortComplex - returns TRUE if, n, is the shortcomplex type.
*/
-static void scaffoldDynamic (mcPretty_pretty p, decl_node n);
-
-/*
- scaffoldMain -
-*/
+static bool isShortComplex (decl_node__opaque n)
+{
+ return n == shortcomplexN;
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
+}
-static void scaffoldMain (mcPretty_pretty p, decl_node n);
/*
- outImpInitC - emit the init/fini functions and main function if required.
+ isAProcType - returns TRUE if, n, is a proctype or proc node.
*/
-static void outImpInitC (mcPretty_pretty p, decl_node n);
-
-/*
- runSimplifyTypes -
-*/
+static bool isAProcType (decl_node__opaque n)
+{
+ mcDebug_assert (n != NULL);
+ return (decl_isProcType (static_cast<decl_node> (n))) || (n == procN);
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
+}
-static void runSimplifyTypes (decl_node n);
/*
- outDefC -
+ initFixupInfo - initialize the fixupInfo record.
*/
-static void outDefC (mcPretty_pretty p, decl_node n);
+static decl_fixupInfo initFixupInfo (void)
+{
+ decl_fixupInfo f;
-/*
- runPrototypeExported -
-*/
+ f.count = 0;
+ f.info = Indexing_InitIndex (1);
+ return f;
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
+}
-static void runPrototypeExported (decl_node n);
/*
- runPrototypeDefC -
+ makeDef - returns a definition module node named, n.
*/
-static void runPrototypeDefC (decl_node n);
+static decl_node__opaque makeDef (nameKey_Name n)
+{
+ decl_node__opaque d;
-/*
- outImpC -
-*/
+ d = newNode (decl_def);
+ d->defF.name = n;
+ d->defF.source = nameKey_NulName;
+ d->defF.hasHidden = false;
+ d->defF.forC = false;
+ d->defF.exported = Indexing_InitIndex (1);
+ d->defF.importedModules = Indexing_InitIndex (1);
+ d->defF.constFixup = initFixupInfo ();
+ d->defF.enumFixup = initFixupInfo ();
+ initDecls (&d->defF.decls);
+ d->defF.enumsComplete = false;
+ d->defF.constsComplete = false;
+ d->defF.visited = false;
+ initPair (&d->defF.com);
+ return d;
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
+}
-static void outImpC (mcPretty_pretty p, decl_node n);
/*
- outDeclsModuleC -
+ makeImp - returns an implementation module node named, n.
*/
-static void outDeclsModuleC (mcPretty_pretty p, decl_scopeT s);
+static decl_node__opaque makeImp (nameKey_Name n)
+{
+ decl_node__opaque d;
-/*
- outModuleInitC -
-*/
+ d = newNode (decl_imp);
+ d->impF.name = n;
+ d->impF.source = nameKey_NulName;
+ d->impF.importedModules = Indexing_InitIndex (1);
+ d->impF.constFixup = initFixupInfo ();
+ d->impF.enumFixup = initFixupInfo ();
+ initDecls (&d->impF.decls);
+ d->impF.beginStatements = static_cast<decl_node__opaque> (NULL);
+ d->impF.finallyStatements = static_cast<decl_node__opaque> (NULL);
+ d->impF.definitionModule = static_cast<decl_node__opaque> (NULL);
+ d->impF.enumsComplete = false;
+ d->impF.constsComplete = false;
+ d->impF.visited = false;
+ initPair (&d->impF.com);
+ return d;
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
+}
-static void outModuleInitC (mcPretty_pretty p, decl_node n);
/*
- outModuleC -
+ makeModule - returns a module node named, n.
*/
-static void outModuleC (mcPretty_pretty p, decl_node n);
+static decl_node__opaque makeModule (nameKey_Name n)
+{
+ decl_node__opaque d;
-/*
- outC -
-*/
+ d = newNode (decl_module);
+ d->moduleF.name = n;
+ d->moduleF.source = nameKey_NulName;
+ d->moduleF.importedModules = Indexing_InitIndex (1);
+ d->moduleF.constFixup = initFixupInfo ();
+ d->moduleF.enumFixup = initFixupInfo ();
+ initDecls (&d->moduleF.decls);
+ d->moduleF.beginStatements = static_cast<decl_node__opaque> (NULL);
+ d->moduleF.finallyStatements = static_cast<decl_node__opaque> (NULL);
+ d->moduleF.enumsComplete = false;
+ d->moduleF.constsComplete = false;
+ d->moduleF.visited = false;
+ initPair (&d->moduleF.com);
+ return d;
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
+}
-static void outC (mcPretty_pretty p, decl_node n);
/*
- doIncludeM2 - include modules in module, n.
+ isDefForC - returns TRUE if the definition module was defined FOR "C".
*/
-static void doIncludeM2 (decl_node n);
-
-/*
- doConstM2 -
-*/
+static bool isDefForC (decl_node__opaque n)
+{
+ return (decl_isDef (static_cast<decl_node> (n))) && n->defF.forC;
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
+}
-static void doConstM2 (decl_node n);
/*
- doProcTypeM2 -
+ initDecls - initialize the decls, scopeT.
*/
-static void doProcTypeM2 (mcPretty_pretty p, decl_node n);
-
-/*
- doRecordFieldM2 -
-*/
+static void initDecls (decl_scopeT *decls)
+{
+ (*decls).symbols = symbolKey_initTree ();
+ (*decls).constants = Indexing_InitIndex (1);
+ (*decls).types = Indexing_InitIndex (1);
+ (*decls).procedures = Indexing_InitIndex (1);
+ (*decls).variables = Indexing_InitIndex (1);
+}
-static void doRecordFieldM2 (mcPretty_pretty p, decl_node f);
/*
- doVarientFieldM2 -
+ addTo - adds node, d, to scope decls and returns, d.
+ It stores, d, in the symbols tree associated with decls.
*/
-static void doVarientFieldM2 (mcPretty_pretty p, decl_node n);
+static decl_node__opaque addTo (decl_scopeT *decls, decl_node__opaque d)
+{
+ nameKey_Name n;
-/*
- doVarientM2 -
-*/
+ n = decl_getSymName (static_cast<decl_node> (d));
+ if (n != nameKey_NulName)
+ {
+ /* avoid gcc warning by using compound statement even if not strictly necessary. */
+ if ((symbolKey_getSymKey ((*decls).symbols, n)) == NULL)
+ {
+ symbolKey_putSymKey ((*decls).symbols, n, reinterpret_cast<void *> (d));
+ }
+ else
+ {
+ mcMetaError_metaError1 ((const char *) "{%1DMad} was declared", 21, (const unsigned char *) &d, (sizeof (d)-1));
+ mcMetaError_metaError1 ((const char *) "{%1k} and is being declared again", 33, (const unsigned char *) &n, (sizeof (n)-1));
+ }
+ }
+ if (decl_isConst (static_cast<decl_node> (d)))
+ {
+ Indexing_IncludeIndiceIntoIndex ((*decls).constants, reinterpret_cast<void *> (d));
+ }
+ else if (decl_isVar (static_cast<decl_node> (d)))
+ {
+ /* avoid dangling else. */
+ Indexing_IncludeIndiceIntoIndex ((*decls).variables, reinterpret_cast<void *> (d));
+ }
+ else if (decl_isType (static_cast<decl_node> (d)))
+ {
+ /* avoid dangling else. */
+ Indexing_IncludeIndiceIntoIndex ((*decls).types, reinterpret_cast<void *> (d));
+ }
+ else if (decl_isProcedure (static_cast<decl_node> (d)))
+ {
+ /* avoid dangling else. */
+ Indexing_IncludeIndiceIntoIndex ((*decls).procedures, reinterpret_cast<void *> (d));
+ if (debugDecl)
+ {
+ libc_printf ((const char *) "%d procedures on the dynamic array\\n", 36, Indexing_HighIndice ((*decls).procedures));
+ }
+ }
+ return d;
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
+}
-static void doVarientM2 (mcPretty_pretty p, decl_node n);
/*
- doRecordM2 -
+ export - export node, n, from definition module, d.
*/
-static void doRecordM2 (mcPretty_pretty p, decl_node n);
+static void export_ (decl_node__opaque d, decl_node__opaque n)
+{
+ mcDebug_assert (decl_isDef (static_cast<decl_node> (d)));
+ Indexing_IncludeIndiceIntoIndex (d->defF.exported, reinterpret_cast<void *> (n));
+}
+
/*
- doPointerM2 -
+ addToScope - adds node, n, to the current scope and returns, n.
*/
-static void doPointerM2 (mcPretty_pretty p, decl_node n);
+static decl_node__opaque addToScope (decl_node__opaque n)
+{
+ decl_node__opaque s;
+ unsigned int i;
-/*
- doTypeAliasM2 -
-*/
+ i = Indexing_HighIndice (scopeStack);
+ s = static_cast<decl_node__opaque> (Indexing_GetIndice (scopeStack, i));
+ if (decl_isProcedure (static_cast<decl_node> (s)))
+ {
+ if (debugDecl)
+ {
+ outText (doP, (const char *) "adding ", 7);
+ doNameC (doP, n);
+ outText (doP, (const char *) " to procedure\\n", 15);
+ }
+ return addTo (&s->procedureF.decls, n);
+ }
+ else if (decl_isModule (static_cast<decl_node> (s)))
+ {
+ /* avoid dangling else. */
+ if (debugDecl)
+ {
+ outText (doP, (const char *) "adding ", 7);
+ doNameC (doP, n);
+ outText (doP, (const char *) " to module\\n", 12);
+ }
+ return addTo (&s->moduleF.decls, n);
+ }
+ else if (decl_isDef (static_cast<decl_node> (s)))
+ {
+ /* avoid dangling else. */
+ if (debugDecl)
+ {
+ outText (doP, (const char *) "adding ", 7);
+ doNameC (doP, n);
+ outText (doP, (const char *) " to definition module\\n", 23);
+ }
+ export_ (s, n);
+ return addTo (&s->defF.decls, n);
+ }
+ else if (decl_isImp (static_cast<decl_node> (s)))
+ {
+ /* avoid dangling else. */
+ if (debugDecl)
+ {
+ outText (doP, (const char *) "adding ", 7);
+ doNameC (doP, n);
+ outText (doP, (const char *) " to implementation module\\n", 27);
+ }
+ return addTo (&s->impF.decls, n);
+ }
+ M2RTS_HALT (-1);
+ __builtin_unreachable ();
+ ReturnException ("../../gcc/m2/mc/decl.def", 20, 1);
+ __builtin_unreachable ();
+}
-static void doTypeAliasM2 (mcPretty_pretty p, decl_node n);
/*
- doEnumerationM2 -
+ addModuleToScope - adds module, i, to module, m, scope.
*/
-static void doEnumerationM2 (mcPretty_pretty p, decl_node n);
+static void addModuleToScope (decl_node__opaque m, decl_node__opaque i)
+{
+ mcDebug_assert ((decl_getDeclScope ()) == m);
+ if ((decl_lookupSym (decl_getSymName (static_cast<decl_node> (i)))) == NULL)
+ {
+ i = addToScope (i);
+ }
+}
+
/*
- doBaseM2 -
+ completedEnum - assign boolean enumsComplete to TRUE if a definition,
+ implementation or module symbol.
*/
-static void doBaseM2 (mcPretty_pretty p, decl_node n);
+static void completedEnum (decl_node__opaque n)
+{
+ mcDebug_assert (((decl_isDef (static_cast<decl_node> (n))) || (decl_isImp (static_cast<decl_node> (n)))) || (decl_isModule (static_cast<decl_node> (n))));
+ if (decl_isDef (static_cast<decl_node> (n)))
+ {
+ n->defF.enumsComplete = true;
+ }
+ else if (decl_isImp (static_cast<decl_node> (n)))
+ {
+ /* avoid dangling else. */
+ n->impF.enumsComplete = true;
+ }
+ else if (decl_isModule (static_cast<decl_node> (n)))
+ {
+ /* avoid dangling else. */
+ n->moduleF.enumsComplete = true;
+ }
+}
+
/*
- doSystemM2 -
+ setUnary - sets a unary node to contain, arg, a, and type, t.
*/
-static void doSystemM2 (mcPretty_pretty p, decl_node n);
-
-/*
- doTypeM2 -
-*/
+static void setUnary (decl_node__opaque u, decl_nodeT k, decl_node__opaque a, decl_node__opaque t)
+{
+ switch (k)
+ {
+ case decl_constexp:
+ case decl_deref:
+ case decl_chr:
+ case decl_cap:
+ case decl_abs:
+ case decl_float:
+ case decl_trunc:
+ case decl_ord:
+ case decl_high:
+ case decl_throw:
+ case decl_re:
+ case decl_im:
+ case decl_not:
+ case decl_neg:
+ case decl_adr:
+ case decl_size:
+ case decl_tsize:
+ case decl_min:
+ case decl_max:
+ u->kind = k;
+ u->unaryF.arg = a;
+ u->unaryF.resultType = t;
+ break;
-static void doTypeM2 (mcPretty_pretty p, decl_node n);
-/*
- doTypesM2 -
-*/
+ default:
+ CaseException ("../../gcc/m2/mc/decl.def", 20, 1);
+ __builtin_unreachable ();
+ }
+}
-static void doTypesM2 (decl_node n);
/*
- doVarM2 -
+ putVarBool - assigns the four booleans associated with a variable.
*/
-static void doVarM2 (decl_node n);
-
-/*
- doVarsM2 -
-*/
+static void putVarBool (decl_node__opaque v, bool init, bool param, bool isvar, bool isused)
+{
+ mcDebug_assert (decl_isVar (static_cast<decl_node> (v)));
+ v->varF.isInitialised = init;
+ v->varF.isParameter = param;
+ v->varF.isVarParameter = isvar;
+ v->varF.isUsed = isused;
+}
-static void doVarsM2 (decl_node n);
/*
- doTypeNameM2 -
+ checkPtr - in C++ we need to create a typedef for a pointer
+ in case we need to use reinterpret_cast.
*/
-static void doTypeNameM2 (mcPretty_pretty p, decl_node n);
+static decl_node__opaque checkPtr (decl_node__opaque n)
+{
+ DynamicStrings_String s;
+ decl_node__opaque p;
-/*
- doParamM2 -
-*/
+ if (lang == decl_ansiCP)
+ {
+ if (decl_isPointer (static_cast<decl_node> (n)))
+ {
+ s = tempName ();
+ p = static_cast<decl_node__opaque> (decl_makeType (nameKey_makekey (DynamicStrings_string (s))));
+ decl_putType (static_cast<decl_node> (p), static_cast<decl_node> (n));
+ s = DynamicStrings_KillString (s);
+ return p;
+ }
+ }
+ return n;
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
+}
-static void doParamM2 (mcPretty_pretty p, decl_node n);
/*
- doVarParamM2 -
+ isVarDecl - returns TRUE if, n, is a vardecl node.
*/
-static void doVarParamM2 (mcPretty_pretty p, decl_node n);
-
-/*
- doParameterM2 -
-*/
+static bool isVarDecl (decl_node__opaque n)
+{
+ return n->kind == decl_vardecl;
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
+}
-static void doParameterM2 (mcPretty_pretty p, decl_node n);
/*
- doPrototypeM2 -
+ makeVariablesFromParameters - creates variables which are really parameters.
*/
-static void doPrototypeM2 (decl_node n);
+static void makeVariablesFromParameters (decl_node__opaque proc, decl_node__opaque id, decl_node__opaque type, bool isvar, bool isused)
+{
+ decl_node__opaque v;
+ unsigned int i;
+ unsigned int n;
+ nameKey_Name m;
+ DynamicStrings_String s;
-/*
- outputPartialM2 - just writes out record, array, and proctypes.
- No need for forward declarations in Modula-2
- but we need to keep topological sort happy.
- So when asked to output partial we emit the
- full type for these types and then do nothing
- when trying to complete partial to full.
-*/
+ mcDebug_assert (decl_isProcedure (static_cast<decl_node> (proc)));
+ mcDebug_assert (isIdentList (id));
+ i = 1;
+ n = wlists_noOfItemsInList (id->identlistF.names);
+ while (i <= n)
+ {
+ m = static_cast<nameKey_Name> (wlists_getItemFromList (id->identlistF.names, i));
+ v = static_cast<decl_node__opaque> (decl_makeVar (m));
+ decl_putVar (static_cast<decl_node> (v), static_cast<decl_node> (type), static_cast<decl_node> (NULL));
+ putVarBool (v, true, true, isvar, isused);
+ if (debugScopes)
+ {
+ libc_printf ((const char *) "adding parameter variable into top scope\\n", 42);
+ dumpScopes ();
+ libc_printf ((const char *) " variable name is: ", 19);
+ s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (m));
+ if ((DynamicStrings_KillString (SFIO_WriteS (FIO_StdOut, s))) == NULL)
+ {} /* empty. */
+ libc_printf ((const char *) "\\n", 2);
+ }
+ i += 1;
+ }
+}
-static void outputPartialM2 (decl_node n);
/*
- outDeclsDefM2 -
+ addProcedureToScope - add a procedure name n and node d to the
+ current scope.
*/
-static void outDeclsDefM2 (mcPretty_pretty p, decl_scopeT s);
+static decl_node__opaque addProcedureToScope (decl_node__opaque d, nameKey_Name n)
+{
+ decl_node__opaque m;
+ unsigned int i;
-/*
- outDefM2 -
-*/
+ i = Indexing_HighIndice (scopeStack);
+ m = static_cast<decl_node__opaque> (Indexing_GetIndice (scopeStack, i));
+ if (((decl_isDef (static_cast<decl_node> (m))) && ((decl_getSymName (static_cast<decl_node> (m))) == (nameKey_makeKey ((const char *) "M2RTS", 5)))) && ((decl_getSymName (static_cast<decl_node> (d))) == (nameKey_makeKey ((const char *) "HALT", 4))))
+ {
+ haltN = d;
+ symbolKey_putSymKey (baseSymbols, n, reinterpret_cast<void *> (haltN));
+ }
+ return addToScope (d);
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
+}
-static void outDefM2 (mcPretty_pretty p, decl_node n);
/*
- outDeclsImpM2 -
+ putProcTypeReturn - sets the return type of, proc, to, type.
*/
-static void outDeclsImpM2 (mcPretty_pretty p, decl_scopeT s);
-
-/*
- outImpM2 -
-*/
+static void putProcTypeReturn (decl_node__opaque proc, decl_node__opaque type)
+{
+ mcDebug_assert (decl_isProcType (static_cast<decl_node> (proc)));
+ proc->proctypeF.returnType = type;
+ initNodeOpaqueState (proc);
+}
-static void outImpM2 (mcPretty_pretty p, decl_node n);
/*
- outModuleM2 -
+ putProcTypeOptReturn - sets, proc, to have an optional return type.
*/
-static void outModuleM2 (mcPretty_pretty p, decl_node n);
-
-/*
- outM2 -
-*/
+static void putProcTypeOptReturn (decl_node__opaque proc)
+{
+ mcDebug_assert (decl_isProcType (static_cast<decl_node> (proc)));
+ proc->proctypeF.returnopt = true;
+}
-static void outM2 (mcPretty_pretty p, decl_node n);
/*
- addDone - adds node, n, to the doneQ.
+ makeOptParameter - creates and returns an optarg.
*/
-static void addDone (decl_node n);
+static decl_node__opaque makeOptParameter (decl_node__opaque l, decl_node__opaque type, decl_node__opaque init)
+{
+ decl_node__opaque n;
-/*
- addDoneDef - adds node, n, to the doneQ providing
- it is not an opaque of the main module we are compiling.
-*/
+ n = newNode (decl_optarg);
+ n->optargF.namelist = l;
+ n->optargF.type = type;
+ n->optargF.init = init;
+ n->optargF.scope = static_cast<decl_node__opaque> (NULL);
+ return n;
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
+}
-static void addDoneDef (decl_node n);
/*
- dbgAdd -
+ setwatch - assign the globalNode to n.
*/
-static decl_node dbgAdd (alists_alist l, decl_node n);
-
-/*
- dbgType -
-*/
+static bool setwatch (decl_node__opaque n)
+{
+ globalNode = n;
+ return true;
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
+}
-static void dbgType (alists_alist l, decl_node n);
/*
- dbgPointer -
+ runwatch - set the globalNode to an identlist.
*/
-static void dbgPointer (alists_alist l, decl_node n);
-
-/*
- dbgRecord -
-*/
+static bool runwatch (void)
+{
+ return globalNode->kind == decl_identlist;
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
+}
-static void dbgRecord (alists_alist l, decl_node n);
/*
- dbgVarient -
+ isIdentList - returns TRUE if, n, is an identlist.
*/
-static void dbgVarient (alists_alist l, decl_node n);
+static bool isIdentList (decl_node__opaque n)
+{
+ return n->kind == decl_identlist;
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
+}
+
/*
- dbgEnumeration -
+ identListLen - returns the length of identlist.
*/
-static void dbgEnumeration (alists_alist l, decl_node n);
+static unsigned int identListLen (decl_node__opaque n)
+{
+ if (n == NULL)
+ {
+ return 0;
+ }
+ else
+ {
+ mcDebug_assert (isIdentList (n));
+ return wlists_noOfItemsInList (n->identlistF.names);
+ }
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
+}
+
/*
- dbgVar -
+ checkParameters - placeholder for future parameter checking.
*/
-static void dbgVar (alists_alist l, decl_node n);
+static void checkParameters (decl_node__opaque p, decl_node__opaque i, decl_node__opaque type, bool isvar, bool isused)
+{
+ /* do check. */
+ disposeNode (&i);
+}
+
/*
- dbgSubrange -
+ checkMakeVariables - create shadow local variables for parameters providing that
+ procedure n has not already been built and we are compiling
+ a module or an implementation module.
*/
-static void dbgSubrange (alists_alist l, decl_node n);
+static void checkMakeVariables (decl_node__opaque n, decl_node__opaque i, decl_node__opaque type, bool isvar, bool isused)
+{
+ if (((decl_isImp (static_cast<decl_node> (currentModule))) || (decl_isModule (static_cast<decl_node> (currentModule)))) && ! n->procedureF.built)
+ {
+ makeVariablesFromParameters (n, i, type, isvar, isused);
+ }
+}
+
/*
- dbgArray -
+ makeVarientField - create a varient field within varient, v,
+ The new varient field is returned.
*/
-static void dbgArray (alists_alist l, decl_node n);
+static decl_node__opaque makeVarientField (decl_node__opaque v, decl_node__opaque p)
+{
+ decl_node__opaque n;
-/*
- doDbg -
-*/
+ n = newNode (decl_varientfield);
+ n->varientfieldF.name = nameKey_NulName;
+ n->varientfieldF.parent = p;
+ n->varientfieldF.varient = v;
+ n->varientfieldF.simple = false;
+ n->varientfieldF.listOfSons = Indexing_InitIndex (1);
+ n->varientfieldF.scope = static_cast<decl_node__opaque> (decl_getDeclScope ());
+ return n;
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
+}
-static void doDbg (alists_alist l, decl_node n);
/*
- dbg -
+ putFieldVarient - places the field varient, f, as a brother to, the
+ varient symbol, v, and also tells, f, that its varient
+ parent is, v.
*/
-static void dbg (decl_node n);
-
-/*
- addGenericBody - adds comment node to funccall, return, assignment
- nodes.
-*/
-
-static void addGenericBody (decl_node n, decl_node c);
-
-/*
- addGenericAfter - adds comment node to funccall, return, assignment
- nodes.
-*/
+static void putFieldVarient (decl_node__opaque f, decl_node__opaque v)
+{
+ mcDebug_assert (decl_isVarient (static_cast<decl_node> (v)));
+ mcDebug_assert (decl_isVarientField (static_cast<decl_node> (f)));
+ switch (v->kind)
+ {
+ case decl_varient:
+ Indexing_IncludeIndiceIntoIndex (v->varientF.listOfSons, reinterpret_cast<void *> (f));
+ break;
-static void addGenericAfter (decl_node n, decl_node c);
-/*
- isAssignment -
-*/
+ default:
+ CaseException ("../../gcc/m2/mc/decl.def", 20, 1);
+ __builtin_unreachable ();
+ }
+ switch (f->kind)
+ {
+ case decl_varientfield:
+ f->varientfieldF.varient = v;
+ break;
-static bool isAssignment (decl_node n);
-/*
- isComment - returns TRUE if node, n, is a comment.
-*/
+ default:
+ CaseException ("../../gcc/m2/mc/decl.def", 20, 1);
+ __builtin_unreachable ();
+ }
+}
-static bool isComment (decl_node n);
/*
- initPair - initialise the commentPair, c.
+ putFieldRecord - create a new recordfield and place it into record r.
+ The new field has a tagname and type and can have a
+ variant field v.
*/
-static void initPair (decl_commentPair *c);
-
-/*
- dupExplist -
-*/
+static decl_node__opaque putFieldRecord (decl_node__opaque r, nameKey_Name tag, decl_node__opaque type, decl_node__opaque v)
+{
+ decl_node__opaque f;
+ decl_node__opaque n;
+ decl_node__opaque p;
-static decl_node dupExplist (decl_node n);
+ n = newNode (decl_recordfield);
+ switch (r->kind)
+ {
+ case decl_record:
+ Indexing_IncludeIndiceIntoIndex (r->recordF.listOfSons, reinterpret_cast<void *> (n));
+ /* ensure that field, n, is in the parents Local Symbols. */
+ if (tag != nameKey_NulName)
+ {
+ /* avoid gcc warning by using compound statement even if not strictly necessary. */
+ if ((symbolKey_getSymKey (r->recordF.localSymbols, tag)) == symbolKey_NulKey)
+ {
+ symbolKey_putSymKey (r->recordF.localSymbols, tag, reinterpret_cast<void *> (n));
+ }
+ else
+ {
+ f = static_cast<decl_node__opaque> (symbolKey_getSymKey (r->recordF.localSymbols, tag));
+ mcMetaError_metaErrors1 ((const char *) "field record {%1Dad} has already been declared", 46, (const char *) "field record duplicate", 22, (const unsigned char *) &f, (sizeof (f)-1));
+ }
+ }
+ break;
-/*
- dupArrayref -
-*/
+ case decl_varientfield:
+ Indexing_IncludeIndiceIntoIndex (r->varientfieldF.listOfSons, reinterpret_cast<void *> (n));
+ p = getParent (r);
+ mcDebug_assert (p->kind == decl_record);
+ if (tag != nameKey_NulName)
+ {
+ symbolKey_putSymKey (p->recordF.localSymbols, tag, reinterpret_cast<void *> (n));
+ }
+ break;
-static decl_node dupArrayref (decl_node n);
-/*
- dupPointerref -
-*/
+ default:
+ CaseException ("../../gcc/m2/mc/decl.def", 20, 1);
+ __builtin_unreachable ();
+ }
+ /* fill in, n. */
+ n->recordfieldF.type = type;
+ n->recordfieldF.name = tag;
+ n->recordfieldF.parent = r;
+ n->recordfieldF.varient = v;
+ n->recordfieldF.tag = false;
+ n->recordfieldF.scope = static_cast<decl_node__opaque> (NULL);
+ initCname (&n->recordfieldF.cname);
+ /*
+ IF r^.kind=record
+ THEN
+ doRecordM2 (doP, r)
+ END ;
+ */
+ return n;
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
+}
-static decl_node dupPointerref (decl_node n);
/*
- dupComponentref -
+ ensureOrder - ensures that, a, and, b, exist in, i, and also
+ ensure that, a, is before, b.
*/
-static decl_node dupComponentref (decl_node n);
-
-/*
- dupBinary -
-*/
+static void ensureOrder (Indexing_Index i, decl_node__opaque a, decl_node__opaque b)
+{
+ mcDebug_assert (Indexing_IsIndiceInIndex (i, reinterpret_cast<void *> (a)));
+ mcDebug_assert (Indexing_IsIndiceInIndex (i, reinterpret_cast<void *> (b)));
+ Indexing_RemoveIndiceFromIndex (i, reinterpret_cast<void *> (a));
+ Indexing_RemoveIndiceFromIndex (i, reinterpret_cast<void *> (b));
+ Indexing_IncludeIndiceIntoIndex (i, reinterpret_cast<void *> (a));
+ Indexing_IncludeIndiceIntoIndex (i, reinterpret_cast<void *> (b));
+ mcDebug_assert (Indexing_IsIndiceInIndex (i, reinterpret_cast<void *> (a)));
+ mcDebug_assert (Indexing_IsIndiceInIndex (i, reinterpret_cast<void *> (b)));
+}
-static decl_node dupBinary (decl_node n);
/*
- dupUnary -
+ putVarientTag - places tag into variant v.
*/
-static decl_node dupUnary (decl_node n);
+static void putVarientTag (decl_node__opaque v, decl_node__opaque tag)
+{
+ decl_node__opaque p;
-/*
- dupFunccall -
-*/
+ mcDebug_assert (decl_isVarient (static_cast<decl_node> (v)));
+ switch (v->kind)
+ {
+ case decl_varient:
+ v->varientF.tag = tag;
+ break;
-static decl_node dupFunccall (decl_node n);
-/*
- dupSetValue -
-*/
+ default:
+ CaseException ("../../gcc/m2/mc/decl.def", 20, 1);
+ __builtin_unreachable ();
+ }
+}
-static decl_node dupSetValue (decl_node n);
/*
- doDupExpr -
+ getParent - returns the parent field of recordfield or varientfield symbol, n.
*/
-static decl_node doDupExpr (decl_node n);
+static decl_node__opaque getParent (decl_node__opaque n)
+{
+ switch (n->kind)
+ {
+ case decl_recordfield:
+ return n->recordfieldF.parent;
+ break;
-/*
- makeSystem -
-*/
+ case decl_varientfield:
+ return n->varientfieldF.parent;
+ break;
-static void makeSystem (void);
-/*
- makeM2rts -
-*/
+ default:
+ CaseException ("../../gcc/m2/mc/decl.def", 20, 1);
+ __builtin_unreachable ();
+ }
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
+}
-static void makeM2rts (void);
/*
- makeBitnum -
+ getRecord - returns the record associated with node, n.
+ (Parental record).
*/
-static decl_node makeBitnum (void);
+static decl_node__opaque getRecord (decl_node__opaque n)
+{
+ mcDebug_assert (n->kind != decl_varient); /* if this fails then we need to add parent field to varient. */
+ switch (n->kind)
+ {
+ case decl_record:
+ return n; /* if this fails then we need to add parent field to varient. */
+ break;
-/*
- makeBaseSymbols -
-*/
+ case decl_varientfield:
+ return getRecord (getParent (n));
+ break;
-static void makeBaseSymbols (void);
-/*
- makeBuiltins -
-*/
+ default:
+ CaseException ("../../gcc/m2/mc/decl.def", 20, 1);
+ __builtin_unreachable ();
+ }
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
+}
-static void makeBuiltins (void);
/*
- init -
+ isConstExp - return TRUE if the node kind is a constexp.
*/
-static void init (void);
+static bool isConstExp (decl_node__opaque c)
+{
+ mcDebug_assert (c != NULL);
+ return c->kind == decl_constexp;
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
+}
/*
- newNode - create and return a new node of kind k.
+ addEnumToModule - adds enumeration type, e, into the list of enums
+ in module, m.
*/
-static decl_node newNode (decl_nodeT k)
+static void addEnumToModule (decl_node__opaque m, decl_node__opaque e)
{
- decl_node d;
-
- Storage_ALLOCATE ((void **) &d, sizeof (decl_nodeRec));
- if (enableMemsetOnAllocation)
+ mcDebug_assert ((decl_isEnumeration (static_cast<decl_node> (e))) || (decl_isEnumerationField (static_cast<decl_node> (e))));
+ mcDebug_assert (((decl_isModule (static_cast<decl_node> (m))) || (decl_isDef (static_cast<decl_node> (m)))) || (decl_isImp (static_cast<decl_node> (m))));
+ if (decl_isModule (static_cast<decl_node> (m)))
{
- d = static_cast<decl_node> (libc_memset (reinterpret_cast<void *> (d), 0, static_cast<size_t> (sizeof ((*d)))));
+ Indexing_IncludeIndiceIntoIndex (m->moduleF.enumFixup.info, reinterpret_cast<void *> (e));
}
- if (d == NULL)
+ else if (decl_isDef (static_cast<decl_node> (m)))
{
- M2RTS_HALT (-1);
- __builtin_unreachable ();
+ /* avoid dangling else. */
+ Indexing_IncludeIndiceIntoIndex (m->defF.enumFixup.info, reinterpret_cast<void *> (e));
}
- else
+ else if (decl_isImp (static_cast<decl_node> (m)))
{
- d->kind = k;
- d->at.defDeclared = 0;
- d->at.modDeclared = 0;
- d->at.firstUsed = 0;
- return d;
+ /* avoid dangling else. */
+ Indexing_IncludeIndiceIntoIndex (m->impF.enumFixup.info, reinterpret_cast<void *> (e));
}
- ReturnException ("../../gcc/m2/mc/decl.def", 20, 1);
- __builtin_unreachable ();
}
/*
- disposeNode - dispose node, n.
+ getNextFixup - return the next fixup from from f.
*/
-static void disposeNode (decl_node *n)
+static decl_node__opaque getNextFixup (decl_fixupInfo *f)
{
- Storage_DEALLOCATE ((void **) &(*n), sizeof (decl_nodeRec));
- (*n) = NULL;
+ (*f).count += 1;
+ return static_cast<decl_node__opaque> (Indexing_GetIndice ((*f).info, (*f).count));
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
}
/*
- newGroup -
+ doMakeEnum - create an enumeration type and add it to the current module.
*/
-static void newGroup (decl_group *g)
+static decl_node__opaque doMakeEnum (void)
{
- if (freeGroup == NULL)
- {
- Storage_ALLOCATE ((void **) &(*g), sizeof (decl__T15));
- }
- else
- {
- (*g) = freeGroup;
- freeGroup = freeGroup->next;
- }
+ decl_node__opaque e;
+
+ e = newNode (decl_enumeration);
+ e->enumerationF.noOfElements = 0;
+ e->enumerationF.localSymbols = symbolKey_initTree ();
+ e->enumerationF.scope = static_cast<decl_node__opaque> (decl_getDeclScope ());
+ e->enumerationF.listOfSons = Indexing_InitIndex (1);
+ e->enumerationF.low = static_cast<decl_node__opaque> (NULL);
+ e->enumerationF.high = static_cast<decl_node__opaque> (NULL);
+ addEnumToModule (currentModule, e);
+ return e;
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
}
/*
- initGroup - returns a group which with all lists initialized.
+ doMakeEnumField - create an enumeration field name and add it to enumeration e.
+ Return the new field.
*/
-static decl_group initGroup (void)
+static decl_node__opaque doMakeEnumField (decl_node__opaque e, nameKey_Name n)
{
- decl_group g;
+ decl_node__opaque f;
- newGroup (&g);
- g->todoQ = alists_initList ();
- g->partialQ = alists_initList ();
- g->doneQ = alists_initList ();
- g->next = NULL;
- return g;
+ mcDebug_assert (decl_isEnumeration (static_cast<decl_node> (e)));
+ f = static_cast<decl_node__opaque> (decl_lookupSym (n));
+ if (f == NULL)
+ {
+ f = newNode (decl_enumerationfield);
+ symbolKey_putSymKey (e->enumerationF.localSymbols, n, reinterpret_cast<void *> (f));
+ Indexing_IncludeIndiceIntoIndex (e->enumerationF.listOfSons, reinterpret_cast<void *> (f));
+ f->enumerationfieldF.name = n;
+ f->enumerationfieldF.type = e;
+ f->enumerationfieldF.scope = static_cast<decl_node__opaque> (decl_getDeclScope ());
+ f->enumerationfieldF.value = e->enumerationF.noOfElements;
+ initCname (&f->enumerationfieldF.cname);
+ e->enumerationF.noOfElements += 1;
+ mcDebug_assert ((Indexing_GetIndice (e->enumerationF.listOfSons, e->enumerationF.noOfElements)) == f);
+ addEnumToModule (currentModule, f);
+ if (e->enumerationF.low == NULL)
+ {
+ e->enumerationF.low = f;
+ }
+ e->enumerationF.high = f;
+ return addToScope (f);
+ }
+ else
+ {
+ mcMetaError_metaErrors2 ((const char *) "cannot create enumeration field {%1k} as the name is already in use", 67, (const char *) "{%2DMad} was declared elsewhere", 31, (const unsigned char *) &n, (sizeof (n)-1), (const unsigned char *) &f, (sizeof (f)-1));
+ }
+ return f;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
/*
- killGroup - deallocate the group and place the group record into the freeGroup list.
+ getExpList - returns the, n, th argument in an explist.
*/
-static void killGroup (decl_group *g)
+static decl_node__opaque getExpList (decl_node__opaque p, unsigned int n)
{
- alists_killList (&(*g)->todoQ);
- alists_killList (&(*g)->partialQ);
- alists_killList (&(*g)->doneQ);
- (*g)->next = freeGroup;
- freeGroup = (*g);
+ mcDebug_assert (p != NULL);
+ mcDebug_assert (decl_isExpList (static_cast<decl_node> (p)));
+ mcDebug_assert (n <= (Indexing_HighIndice (p->explistF.exp)));
+ return static_cast<decl_node__opaque> (Indexing_GetIndice (p->explistF.exp, n));
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
}
/*
- dupGroup - If g is not NIL then destroy g.
- Return a duplicate of GlobalGroup (not g).
+ expListLen - returns the length of explist, p.
*/
-static decl_group dupGroup (decl_group g)
+static unsigned int expListLen (decl_node__opaque p)
{
- if (g != NULL)
+ if (p == NULL)
{
- /* Kill old group. */
- killGroup (&g);
+ return 0;
+ }
+ else
+ {
+ mcDebug_assert (decl_isExpList (static_cast<decl_node> (p)));
+ return Indexing_HighIndice (p->explistF.exp);
}
- newGroup (&g);
- /* Copy all lists. */
- g->todoQ = alists_duplicateList (globalGroup->todoQ);
- g->partialQ = alists_duplicateList (globalGroup->partialQ);
- g->doneQ = alists_duplicateList (globalGroup->doneQ);
- g->next = NULL;
- return g;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
/*
- equalGroup - return TRUE if group left = right.
+ getConstExpComplete - gets the field from the def or imp or module, n.
*/
-static bool equalGroup (decl_group left, decl_group right)
+static bool getConstExpComplete (decl_node__opaque n)
{
- return (left == right) || (((alists_equalList (left->todoQ, right->todoQ)) && (alists_equalList (left->partialQ, right->partialQ))) && (alists_equalList (left->doneQ, right->doneQ)));
- /* static analysis guarentees a RETURN statement will be used before here. */
- __builtin_unreachable ();
-}
+ switch (n->kind)
+ {
+ case decl_def:
+ return n->defF.constsComplete;
+ break;
+ case decl_imp:
+ return n->impF.constsComplete;
+ break;
-/*
- isLocal - returns TRUE if symbol, n, is locally declared in a procedure.
-*/
+ case decl_module:
+ return n->moduleF.constsComplete;
+ break;
-static bool isLocal (decl_node n)
-{
- decl_node s;
- s = decl_getScope (n);
- if (s != NULL)
- {
- return decl_isProcedure (s);
+ default:
+ CaseException ("../../gcc/m2/mc/decl.def", 20, 1);
+ __builtin_unreachable ();
}
- return false;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
/*
- importEnumFields - if, n, is an enumeration type import the all fields into module, m.
+ addConstToModule - adds const exp, e, into the list of constant
+ expressions in module, m.
*/
-static void importEnumFields (decl_node m, decl_node n)
+static void addConstToModule (decl_node__opaque m, decl_node__opaque e)
{
- decl_node r;
- decl_node e;
- unsigned int i;
- unsigned int h;
-
- mcDebug_assert (((decl_isDef (m)) || (decl_isModule (m))) || (decl_isImp (m)));
- n = decl_skipType (n);
- if ((n != NULL) && (decl_isEnumeration (n)))
+ mcDebug_assert (((decl_isModule (static_cast<decl_node> (m))) || (decl_isDef (static_cast<decl_node> (m)))) || (decl_isImp (static_cast<decl_node> (m))));
+ if (decl_isModule (static_cast<decl_node> (m)))
{
- i = Indexing_LowIndice (n->enumerationF.listOfSons);
- h = Indexing_HighIndice (n->enumerationF.listOfSons);
- while (i <= h)
- {
- e = static_cast<decl_node> (Indexing_GetIndice (n->enumerationF.listOfSons, i));
- r = decl_import (m, e);
- if (e != r)
- {
- mcMetaError_metaError2 ((const char *) "enumeration field {%1ad} cannot be imported implicitly into {%2d} due to a name clash", 85, (const unsigned char *) &e, (sizeof (e)-1), (const unsigned char *) &m, (sizeof (m)-1));
- }
- i += 1;
- }
+ Indexing_IncludeIndiceIntoIndex (m->moduleF.constFixup.info, reinterpret_cast<void *> (e));
+ }
+ else if (decl_isDef (static_cast<decl_node> (m)))
+ {
+ /* avoid dangling else. */
+ Indexing_IncludeIndiceIntoIndex (m->defF.constFixup.info, reinterpret_cast<void *> (e));
+ }
+ else if (decl_isImp (static_cast<decl_node> (m)))
+ {
+ /* avoid dangling else. */
+ Indexing_IncludeIndiceIntoIndex (m->impF.constFixup.info, reinterpret_cast<void *> (e));
}
}
/*
- isComplex - returns TRUE if, n, is the complex type.
+ doMakeConstExp - create a constexp node and add it to the current module.
*/
-static bool isComplex (decl_node n)
+static decl_node__opaque doMakeConstExp (void)
{
- return n == complexN;
+ decl_node__opaque c;
+
+ c = makeUnary (decl_constexp, static_cast<decl_node__opaque> (NULL), static_cast<decl_node__opaque> (NULL));
+ addConstToModule (currentModule, c);
+ return c;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
/*
- isLongComplex - returns TRUE if, n, is the longcomplex type.
+ isAnyType - return TRUE if node n is any type kind.
*/
-static bool isLongComplex (decl_node n)
+static bool isAnyType (decl_node__opaque n)
{
- return n == longcomplexN;
- /* static analysis guarentees a RETURN statement will be used before here. */
- __builtin_unreachable ();
-}
-
+ mcDebug_assert (n != NULL);
+ switch (n->kind)
+ {
+ case decl_address:
+ case decl_loc:
+ case decl_byte:
+ case decl_word:
+ case decl_char:
+ case decl_cardinal:
+ case decl_longcard:
+ case decl_shortcard:
+ case decl_integer:
+ case decl_longint:
+ case decl_shortint:
+ case decl_complex:
+ case decl_longcomplex:
+ case decl_shortcomplex:
+ case decl_bitset:
+ case decl_boolean:
+ case decl_proc:
+ case decl_type:
+ return true;
+ break;
-/*
- isShortComplex - returns TRUE if, n, is the shortcomplex type.
-*/
-static bool isShortComplex (decl_node n)
-{
- return n == shortcomplexN;
+ default:
+ return false;
+ break;
+ }
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
/*
- isAProcType - returns TRUE if, n, is a proctype or proc node.
+ makeVal - creates a VAL (type, expression) node.
*/
-static bool isAProcType (decl_node n)
+static decl_node__opaque makeVal (decl_node__opaque params)
{
- mcDebug_assert (n != NULL);
- return (decl_isProcType (n)) || (n == procN);
- /* static analysis guarentees a RETURN statement will be used before here. */
+ mcDebug_assert (decl_isExpList (static_cast<decl_node> (params)));
+ if ((expListLen (params)) == 2)
+ {
+ return makeBinary (decl_val, getExpList (params, 1), getExpList (params, 2), getExpList (params, 1));
+ }
+ else
+ {
+ M2RTS_HALT (-1);
+ __builtin_unreachable ();
+ }
+ ReturnException ("../../gcc/m2/mc/decl.def", 20, 1);
__builtin_unreachable ();
}
/*
- initFixupInfo - initialize the fixupInfo record.
+ makeCast - creates a cast node TYPENAME (expr).
*/
-static decl_fixupInfo initFixupInfo (void)
+static decl_node__opaque makeCast (decl_node__opaque c, decl_node__opaque p)
{
- decl_fixupInfo f;
-
- f.count = 0;
- f.info = Indexing_InitIndex (1);
- return f;
- /* static analysis guarentees a RETURN statement will be used before here. */
+ mcDebug_assert (decl_isExpList (static_cast<decl_node> (p)));
+ if ((expListLen (p)) == 1)
+ {
+ return makeBinary (decl_cast, c, getExpList (p, 1), c);
+ }
+ else
+ {
+ M2RTS_HALT (-1);
+ __builtin_unreachable ();
+ }
+ ReturnException ("../../gcc/m2/mc/decl.def", 20, 1);
__builtin_unreachable ();
}
-
-/*
- makeDef - returns a definition module node named, n.
-*/
-
-static decl_node makeDef (nameKey_Name n)
+static decl_node__opaque makeIntrinsicProc (decl_nodeT k, unsigned int noArgs, decl_node__opaque p)
{
- decl_node d;
+ decl_node__opaque f;
- d = newNode (decl_def);
- d->defF.name = n;
- d->defF.source = nameKey_NulName;
- d->defF.hasHidden = false;
- d->defF.forC = false;
- d->defF.exported = Indexing_InitIndex (1);
- d->defF.importedModules = Indexing_InitIndex (1);
- d->defF.constFixup = initFixupInfo ();
- d->defF.enumFixup = initFixupInfo ();
- initDecls (&d->defF.decls);
- d->defF.enumsComplete = false;
- d->defF.constsComplete = false;
- d->defF.visited = false;
- initPair (&d->defF.com);
- return d;
+ /*
+ makeIntrisicProc - create an intrinsic node.
+ */
+ f = newNode (k);
+ f->intrinsicF.args = p;
+ f->intrinsicF.noArgs = noArgs;
+ f->intrinsicF.type = static_cast<decl_node__opaque> (NULL);
+ f->intrinsicF.postUnreachable = k == decl_halt;
+ initPair (&f->intrinsicF.intrinsicComment);
+ return f;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
/*
- makeImp - returns an implementation module node named, n.
+ makeIntrinsicUnaryType - create an intrisic unary type.
*/
-static decl_node makeImp (nameKey_Name n)
+static decl_node__opaque makeIntrinsicUnaryType (decl_nodeT k, decl_node__opaque paramList, decl_node__opaque returnType)
{
- decl_node d;
-
- d = newNode (decl_imp);
- d->impF.name = n;
- d->impF.source = nameKey_NulName;
- d->impF.importedModules = Indexing_InitIndex (1);
- d->impF.constFixup = initFixupInfo ();
- d->impF.enumFixup = initFixupInfo ();
- initDecls (&d->impF.decls);
- d->impF.beginStatements = NULL;
- d->impF.finallyStatements = NULL;
- d->impF.definitionModule = NULL;
- d->impF.enumsComplete = false;
- d->impF.constsComplete = false;
- d->impF.visited = false;
- initPair (&d->impF.com);
- return d;
+ return makeUnary (k, getExpList (paramList, 1), returnType);
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
/*
- makeModule - returns a module node named, n.
+ makeIntrinsicBinaryType - create an intrisic binary type.
*/
-static decl_node makeModule (nameKey_Name n)
+static decl_node__opaque makeIntrinsicBinaryType (decl_nodeT k, decl_node__opaque paramList, decl_node__opaque returnType)
{
- decl_node d;
-
- d = newNode (decl_module);
- d->moduleF.name = n;
- d->moduleF.source = nameKey_NulName;
- d->moduleF.importedModules = Indexing_InitIndex (1);
- d->moduleF.constFixup = initFixupInfo ();
- d->moduleF.enumFixup = initFixupInfo ();
- initDecls (&d->moduleF.decls);
- d->moduleF.beginStatements = NULL;
- d->moduleF.finallyStatements = NULL;
- d->moduleF.enumsComplete = false;
- d->moduleF.constsComplete = false;
- d->moduleF.visited = false;
- initPair (&d->moduleF.com);
- return d;
+ return makeBinary (k, getExpList (paramList, 1), getExpList (paramList, 2), returnType);
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
/*
- isDefForC - returns TRUE if the definition module was defined FOR "C".
+ checkIntrinsic - checks to see if the function call to, c, with
+ parameter list, n, is really an intrinic. If it
+ is an intrinic then an intrinic node is created
+ and returned. Otherwise NIL is returned.
*/
-static bool isDefForC (decl_node n)
+static decl_node__opaque checkIntrinsic (decl_node__opaque c, decl_node__opaque n)
{
- return (decl_isDef (n)) && n->defF.forC;
- /* static analysis guarentees a RETURN statement will be used before here. */
- __builtin_unreachable ();
-}
-
-
-/*
- initDecls - initialize the decls, scopeT.
-*/
-
-static void initDecls (decl_scopeT *decls)
-{
- (*decls).symbols = symbolKey_initTree ();
- (*decls).constants = Indexing_InitIndex (1);
- (*decls).types = Indexing_InitIndex (1);
- (*decls).procedures = Indexing_InitIndex (1);
- (*decls).variables = Indexing_InitIndex (1);
-}
-
-
-/*
- addTo - adds node, d, to scope decls and returns, d.
- It stores, d, in the symbols tree associated with decls.
-*/
-
-static decl_node addTo (decl_scopeT *decls, decl_node d)
-{
- nameKey_Name n;
-
- n = decl_getSymName (d);
- if (n != nameKey_NulName)
+ if (isAnyType (c))
{
- /* avoid gcc warning by using compound statement even if not strictly necessary. */
- if ((symbolKey_getSymKey ((*decls).symbols, n)) == NULL)
- {
- symbolKey_putSymKey ((*decls).symbols, n, reinterpret_cast<void *> (d));
- }
- else
- {
- mcMetaError_metaError1 ((const char *) "{%1DMad} was declared", 21, (const unsigned char *) &d, (sizeof (d)-1));
- mcMetaError_metaError1 ((const char *) "{%1k} and is being declared again", 33, (const unsigned char *) &n, (sizeof (n)-1));
- }
+ return makeCast (c, n);
}
- if (decl_isConst (d))
+ else if (c == maxN)
{
- Indexing_IncludeIndiceIntoIndex ((*decls).constants, reinterpret_cast<void *> (d));
+ /* avoid dangling else. */
+ return makeIntrinsicUnaryType (decl_max, n, static_cast<decl_node__opaque> (NULL));
}
- else if (decl_isVar (d))
+ else if (c == minN)
{
/* avoid dangling else. */
- Indexing_IncludeIndiceIntoIndex ((*decls).variables, reinterpret_cast<void *> (d));
+ return makeIntrinsicUnaryType (decl_min, n, static_cast<decl_node__opaque> (NULL));
}
- else if (decl_isType (d))
+ else if (c == haltN)
{
/* avoid dangling else. */
- Indexing_IncludeIndiceIntoIndex ((*decls).types, reinterpret_cast<void *> (d));
+ return makeIntrinsicProc (decl_halt, expListLen (n), n);
}
- else if (decl_isProcedure (d))
+ else if (c == valN)
{
/* avoid dangling else. */
- Indexing_IncludeIndiceIntoIndex ((*decls).procedures, reinterpret_cast<void *> (d));
- if (debugDecl)
- {
- libc_printf ((const char *) "%d procedures on the dynamic array\\n", 36, Indexing_HighIndice ((*decls).procedures));
- }
+ return makeVal (n);
}
- return d;
+ else if (c == adrN)
+ {
+ /* avoid dangling else. */
+ return makeIntrinsicUnaryType (decl_adr, n, addressN);
+ }
+ else if (c == sizeN)
+ {
+ /* avoid dangling else. */
+ return makeIntrinsicUnaryType (decl_size, n, cardinalN);
+ }
+ else if (c == tsizeN)
+ {
+ /* avoid dangling else. */
+ return makeIntrinsicUnaryType (decl_tsize, n, cardinalN);
+ }
+ else if (c == floatN)
+ {
+ /* avoid dangling else. */
+ return makeIntrinsicUnaryType (decl_float, n, realN);
+ }
+ else if (c == truncN)
+ {
+ /* avoid dangling else. */
+ return makeIntrinsicUnaryType (decl_trunc, n, integerN);
+ }
+ else if (c == ordN)
+ {
+ /* avoid dangling else. */
+ return makeIntrinsicUnaryType (decl_ord, n, cardinalN);
+ }
+ else if (c == chrN)
+ {
+ /* avoid dangling else. */
+ return makeIntrinsicUnaryType (decl_chr, n, charN);
+ }
+ else if (c == capN)
+ {
+ /* avoid dangling else. */
+ return makeIntrinsicUnaryType (decl_cap, n, charN);
+ }
+ else if (c == absN)
+ {
+ /* avoid dangling else. */
+ return makeIntrinsicUnaryType (decl_abs, n, static_cast<decl_node__opaque> (NULL));
+ }
+ else if (c == imN)
+ {
+ /* avoid dangling else. */
+ return makeIntrinsicUnaryType (decl_im, n, static_cast<decl_node__opaque> (NULL));
+ }
+ else if (c == reN)
+ {
+ /* avoid dangling else. */
+ return makeIntrinsicUnaryType (decl_re, n, static_cast<decl_node__opaque> (NULL));
+ }
+ else if (c == cmplxN)
+ {
+ /* avoid dangling else. */
+ return makeIntrinsicBinaryType (decl_cmplx, n, static_cast<decl_node__opaque> (NULL));
+ }
+ else if (c == highN)
+ {
+ /* avoid dangling else. */
+ return makeIntrinsicUnaryType (decl_high, n, cardinalN);
+ }
+ else if (c == incN)
+ {
+ /* avoid dangling else. */
+ return makeIntrinsicProc (decl_inc, expListLen (n), n);
+ }
+ else if (c == decN)
+ {
+ /* avoid dangling else. */
+ return makeIntrinsicProc (decl_dec, expListLen (n), n);
+ }
+ else if (c == inclN)
+ {
+ /* avoid dangling else. */
+ return makeIntrinsicProc (decl_incl, expListLen (n), n);
+ }
+ else if (c == exclN)
+ {
+ /* avoid dangling else. */
+ return makeIntrinsicProc (decl_excl, expListLen (n), n);
+ }
+ else if (c == newN)
+ {
+ /* avoid dangling else. */
+ return makeIntrinsicProc (decl_new, 1, n);
+ }
+ else if (c == disposeN)
+ {
+ /* avoid dangling else. */
+ return makeIntrinsicProc (decl_dispose, 1, n);
+ }
+ else if (c == lengthN)
+ {
+ /* avoid dangling else. */
+ return makeIntrinsicUnaryType (decl_length, n, cardinalN);
+ }
+ else if (c == throwN)
+ {
+ /* avoid dangling else. */
+ keyc_useThrow ();
+ return makeIntrinsicProc (decl_throw, 1, n);
+ }
+ return static_cast<decl_node__opaque> (NULL);
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
/*
- export - export node, n, from definition module, d.
+ checkCHeaders - check to see if the function is a C system function and
+ requires a header file included.
*/
-static void export_ (decl_node d, decl_node n)
+static void checkCHeaders (decl_node__opaque c)
{
- mcDebug_assert (decl_isDef (d));
- Indexing_IncludeIndiceIntoIndex (d->defF.exported, reinterpret_cast<void *> (n));
+ nameKey_Name name;
+ decl_node__opaque s;
+
+ if (decl_isProcedure (static_cast<decl_node> (c)))
+ {
+ s = static_cast<decl_node__opaque> (decl_getScope (static_cast<decl_node> (c)));
+ if ((decl_getSymName (static_cast<decl_node> (s))) == (nameKey_makeKey ((const char *) "libc", 4)))
+ {
+ name = decl_getSymName (static_cast<decl_node> (c));
+ if ((((name == (nameKey_makeKey ((const char *) "read", 4))) || (name == (nameKey_makeKey ((const char *) "write", 5)))) || (name == (nameKey_makeKey ((const char *) "open", 4)))) || (name == (nameKey_makeKey ((const char *) "close", 5))))
+ {
+ keyc_useUnistd ();
+ }
+ }
+ }
}
/*
- addToScope - adds node, n, to the current scope and returns, n.
+ isFuncCall - returns TRUE if, n, is a function/procedure call.
*/
-static decl_node addToScope (decl_node n)
+static bool isFuncCall (decl_node__opaque n)
{
- decl_node s;
- unsigned int i;
-
- i = Indexing_HighIndice (scopeStack);
- s = static_cast<decl_node> (Indexing_GetIndice (scopeStack, i));
- if (decl_isProcedure (s))
- {
- if (debugDecl)
- {
- outText (doP, (const char *) "adding ", 7);
- doNameC (doP, n);
- outText (doP, (const char *) " to procedure\\n", 15);
- }
- return addTo (&s->procedureF.decls, n);
- }
- else if (decl_isModule (s))
- {
- /* avoid dangling else. */
- if (debugDecl)
- {
- outText (doP, (const char *) "adding ", 7);
- doNameC (doP, n);
- outText (doP, (const char *) " to module\\n", 12);
- }
- return addTo (&s->moduleF.decls, n);
- }
- else if (decl_isDef (s))
- {
- /* avoid dangling else. */
- if (debugDecl)
- {
- outText (doP, (const char *) "adding ", 7);
- doNameC (doP, n);
- outText (doP, (const char *) " to definition module\\n", 23);
- }
- export_ (s, n);
- return addTo (&s->defF.decls, n);
- }
- else if (decl_isImp (s))
- {
- /* avoid dangling else. */
- if (debugDecl)
- {
- outText (doP, (const char *) "adding ", 7);
- doNameC (doP, n);
- outText (doP, (const char *) " to implementation module\\n", 27);
- }
- return addTo (&s->impF.decls, n);
- }
- M2RTS_HALT (-1);
- __builtin_unreachable ();
- ReturnException ("../../gcc/m2/mc/decl.def", 20, 1);
+ mcDebug_assert (n != NULL);
+ return n->kind == decl_funccall;
+ /* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
/*
- addModuleToScope - adds module, i, to module, m, scope.
+ putTypeInternal - marks type, des, as being an internally generated type.
*/
-static void addModuleToScope (decl_node m, decl_node i)
+static void putTypeInternal (decl_node__opaque des)
{
- mcDebug_assert ((decl_getDeclScope ()) == m);
- if ((decl_lookupSym (decl_getSymName (i))) == NULL)
- {
- i = addToScope (i);
- }
+ mcDebug_assert (des != NULL);
+ mcDebug_assert (decl_isType (static_cast<decl_node> (des)));
+ des->typeF.isInternal = true;
}
/*
- completedEnum - assign boolean enumsComplete to TRUE if a definition,
- implementation or module symbol.
+ isTypeInternal - returns TRUE if type, n, is internal.
*/
-static void completedEnum (decl_node n)
+static bool isTypeInternal (decl_node__opaque n)
{
- mcDebug_assert (((decl_isDef (n)) || (decl_isImp (n))) || (decl_isModule (n)));
- if (decl_isDef (n))
- {
- n->defF.enumsComplete = true;
- }
- else if (decl_isImp (n))
- {
- /* avoid dangling else. */
- n->impF.enumsComplete = true;
- }
- else if (decl_isModule (n))
- {
- /* avoid dangling else. */
- n->moduleF.enumsComplete = true;
- }
+ mcDebug_assert (n != NULL);
+ mcDebug_assert (decl_isType (static_cast<decl_node> (n)));
+ return n->typeF.isInternal;
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
}
/*
- setUnary - sets a unary node to contain, arg, a, and type, t.
+ lookupBase - return node named n from the base symbol scope.
*/
-static void setUnary (decl_node u, decl_nodeT k, decl_node a, decl_node t)
+static decl_node__opaque lookupBase (nameKey_Name n)
{
- switch (k)
- {
- case decl_constexp:
- case decl_deref:
- case decl_chr:
- case decl_cap:
- case decl_abs:
- case decl_float:
- case decl_trunc:
- case decl_ord:
- case decl_high:
- case decl_throw:
- case decl_re:
- case decl_im:
- case decl_not:
- case decl_neg:
- case decl_adr:
- case decl_size:
- case decl_tsize:
- case decl_min:
- case decl_max:
- u->kind = k;
- u->unaryF.arg = a;
- u->unaryF.resultType = t;
- break;
+ decl_node__opaque m;
-
- default:
- CaseException ("../../gcc/m2/mc/decl.def", 20, 1);
- __builtin_unreachable ();
+ m = static_cast<decl_node__opaque> (symbolKey_getSymKey (baseSymbols, n));
+ if (m == procN)
+ {
+ keyc_useProc ();
}
-}
-
-
-/*
- putVarBool - assigns the four booleans associated with a variable.
-*/
-
-static void putVarBool (decl_node v, bool init, bool param, bool isvar, bool isused)
-{
- mcDebug_assert (decl_isVar (v));
- v->varF.isInitialised = init;
- v->varF.isParameter = param;
- v->varF.isVarParameter = isvar;
- v->varF.isUsed = isused;
-}
-
-
-/*
- checkPtr - in C++ we need to create a typedef for a pointer
- in case we need to use reinterpret_cast.
-*/
-
-static decl_node checkPtr (decl_node n)
-{
- DynamicStrings_String s;
- decl_node p;
-
- if (lang == decl_ansiCP)
+ else if (((m == complexN) || (m == longcomplexN)) || (m == shortcomplexN))
{
- if (decl_isPointer (n))
- {
- s = tempName ();
- p = decl_makeType (nameKey_makekey (DynamicStrings_string (s)));
- decl_putType (p, n);
- s = DynamicStrings_KillString (s);
- return p;
- }
+ /* avoid dangling else. */
+ keyc_useComplex ();
}
- return n;
+ return m;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
/*
- isVarDecl - returns TRUE if, n, is a vardecl node.
+ dumpScopes - display the names of all the scopes stacked.
*/
-static bool isVarDecl (decl_node n)
+static void dumpScopes (void)
{
- return n->kind == decl_vardecl;
- /* static analysis guarentees a RETURN statement will be used before here. */
- __builtin_unreachable ();
+ unsigned int h;
+ decl_node__opaque s;
+
+ h = Indexing_HighIndice (scopeStack);
+ libc_printf ((const char *) "total scopes stacked %d\\n", 25, h);
+ while (h >= 1)
+ {
+ s = static_cast<decl_node__opaque> (Indexing_GetIndice (scopeStack, h));
+ out2 ((const char *) " scope [%d] is %s\\n", 19, h, s);
+ h -= 1;
+ }
}
/*
- makeVariablesFromParameters - creates variables which are really parameters.
+ out0 - write string a to StdOut.
*/
-static void makeVariablesFromParameters (decl_node proc, decl_node id, decl_node type, bool isvar, bool isused)
+static void out0 (const char *a_, unsigned int _a_high)
{
- decl_node v;
- unsigned int i;
- unsigned int n;
- nameKey_Name m;
- DynamicStrings_String s;
+ DynamicStrings_String m;
+ char a[_a_high+1];
- mcDebug_assert (decl_isProcedure (proc));
- mcDebug_assert (isIdentList (id));
- i = 1;
- n = wlists_noOfItemsInList (id->identlistF.names);
- while (i <= n)
- {
- m = static_cast<nameKey_Name> (wlists_getItemFromList (id->identlistF.names, i));
- v = decl_makeVar (m);
- decl_putVar (v, type, NULL);
- putVarBool (v, true, true, isvar, isused);
- if (debugScopes)
- {
- libc_printf ((const char *) "adding parameter variable into top scope\\n", 42);
- dumpScopes ();
- libc_printf ((const char *) " variable name is: ", 19);
- s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (m));
- if ((DynamicStrings_KillString (SFIO_WriteS (FIO_StdOut, s))) == NULL)
- {} /* empty. */
- libc_printf ((const char *) "\\n", 2);
- }
- i += 1;
- }
+ /* make a local copy of each unbounded array. */
+ memcpy (a, a_, _a_high+1);
+
+ m = FormatStrings_Sprintf0 (DynamicStrings_InitString ((const char *) a, _a_high));
+ m = DynamicStrings_KillString (SFIO_WriteS (FIO_StdOut, m));
}
/*
- addProcedureToScope - add a procedure name n and node d to the
- current scope.
+ out1 - write string a to StdOut using format specifier a.
*/
-static decl_node addProcedureToScope (decl_node d, nameKey_Name n)
+static void out1 (const char *a_, unsigned int _a_high, decl_node__opaque s)
{
- decl_node m;
- unsigned int i;
+ DynamicStrings_String m;
+ unsigned int d;
+ char a[_a_high+1];
- i = Indexing_HighIndice (scopeStack);
- m = static_cast<decl_node> (Indexing_GetIndice (scopeStack, i));
- if (((decl_isDef (m)) && ((decl_getSymName (m)) == (nameKey_makeKey ((const char *) "M2RTS", 5)))) && ((decl_getSymName (d)) == (nameKey_makeKey ((const char *) "HALT", 4))))
+ /* make a local copy of each unbounded array. */
+ memcpy (a, a_, _a_high+1);
+
+ m = getFQstring (s);
+ if (DynamicStrings_EqualArray (m, (const char *) "", 0))
{
- haltN = d;
- symbolKey_putSymKey (baseSymbols, n, reinterpret_cast<void *> (haltN));
+ d = (unsigned int ) ((long unsigned int ) (s));
+ m = DynamicStrings_KillString (m);
+ m = FormatStrings_Sprintf1 (DynamicStrings_InitString ((const char *) "[%d]", 4), (const unsigned char *) &d, (sizeof (d)-1));
}
- return addToScope (d);
- /* static analysis guarentees a RETURN statement will be used before here. */
- __builtin_unreachable ();
+ m = FormatStrings_Sprintf1 (DynamicStrings_InitString ((const char *) a, _a_high), (const unsigned char *) &m, (sizeof (m)-1));
+ m = DynamicStrings_KillString (SFIO_WriteS (FIO_StdOut, m));
}
/*
- putProcTypeReturn - sets the return type of, proc, to, type.
+ out2 - write string a to StdOut using format specifier a.
*/
-static void putProcTypeReturn (decl_node proc, decl_node type)
+static void out2 (const char *a_, unsigned int _a_high, unsigned int c, decl_node__opaque s)
{
- mcDebug_assert (decl_isProcType (proc));
- proc->proctypeF.returnType = type;
-}
-
+ DynamicStrings_String m;
+ DynamicStrings_String m1;
+ char a[_a_high+1];
-/*
- putProcTypeOptReturn - sets, proc, to have an optional return type.
-*/
+ /* make a local copy of each unbounded array. */
+ memcpy (a, a_, _a_high+1);
-static void putProcTypeOptReturn (decl_node proc)
-{
- mcDebug_assert (decl_isProcType (proc));
- proc->proctypeF.returnopt = true;
+ m1 = getString (s);
+ m = FormatStrings_Sprintf2 (DynamicStrings_InitString ((const char *) a, _a_high), (const unsigned char *) &c, (sizeof (c)-1), (const unsigned char *) &m1, (sizeof (m1)-1));
+ m = DynamicStrings_KillString (SFIO_WriteS (FIO_StdOut, m));
+ m1 = DynamicStrings_KillString (m1);
}
/*
- makeOptParameter - creates and returns an optarg.
+ out3 - write string a to StdOut using format specifier a.
*/
-static decl_node makeOptParameter (decl_node l, decl_node type, decl_node init)
+static void out3 (const char *a_, unsigned int _a_high, unsigned int l, nameKey_Name n, decl_node__opaque s)
{
- decl_node n;
+ DynamicStrings_String m;
+ DynamicStrings_String m1;
+ DynamicStrings_String m2;
+ char a[_a_high+1];
- n = newNode (decl_optarg);
- n->optargF.namelist = l;
- n->optargF.type = type;
- n->optargF.init = init;
- n->optargF.scope = NULL;
- return n;
- /* static analysis guarentees a RETURN statement will be used before here. */
- __builtin_unreachable ();
+ /* make a local copy of each unbounded array. */
+ memcpy (a, a_, _a_high+1);
+
+ m1 = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (n));
+ m2 = getString (s);
+ m = FormatStrings_Sprintf3 (DynamicStrings_InitString ((const char *) a, _a_high), (const unsigned char *) &l, (sizeof (l)-1), (const unsigned char *) &m1, (sizeof (m1)-1), (const unsigned char *) &m2, (sizeof (m2)-1));
+ m = DynamicStrings_KillString (SFIO_WriteS (FIO_StdOut, m));
+ m1 = DynamicStrings_KillString (m1);
+ m2 = DynamicStrings_KillString (m2);
}
/*
- setwatch - assign the globalNode to n.
+ isUnary - returns TRUE if, n, is an unary node.
*/
-static bool setwatch (decl_node n)
+static bool isUnary (decl_node__opaque n)
{
- globalNode = n;
- return true;
- /* static analysis guarentees a RETURN statement will be used before here. */
- __builtin_unreachable ();
-}
-
+ mcDebug_assert (n != NULL);
+ switch (n->kind)
+ {
+ case decl_length:
+ case decl_re:
+ case decl_im:
+ case decl_deref:
+ case decl_high:
+ case decl_chr:
+ case decl_cap:
+ case decl_abs:
+ case decl_ord:
+ case decl_float:
+ case decl_trunc:
+ case decl_constexp:
+ case decl_not:
+ case decl_neg:
+ case decl_adr:
+ case decl_size:
+ case decl_tsize:
+ case decl_min:
+ case decl_max:
+ return true;
+ break;
-/*
- runwatch - set the globalNode to an identlist.
-*/
-static bool runwatch (void)
-{
- return globalNode->kind == decl_identlist;
+ default:
+ return false;
+ break;
+ }
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
/*
- isIdentList - returns TRUE if, n, is an identlist.
+ isBinary - returns TRUE if, n, is an binary node.
*/
-static bool isIdentList (decl_node n)
+static bool isBinary (decl_node__opaque n)
{
- return n->kind == decl_identlist;
+ mcDebug_assert (n != NULL);
+ switch (n->kind)
+ {
+ case decl_cmplx:
+ case decl_and:
+ case decl_or:
+ case decl_equal:
+ case decl_notequal:
+ case decl_less:
+ case decl_greater:
+ case decl_greequal:
+ case decl_lessequal:
+ case decl_val:
+ case decl_cast:
+ case decl_plus:
+ case decl_sub:
+ case decl_div:
+ case decl_mod:
+ case decl_mult:
+ case decl_divide:
+ case decl_in:
+ return true;
+ break;
+
+
+ default:
+ return false;
+ break;
+ }
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
/*
- identListLen - returns the length of identlist.
+ makeUnary - create a unary expression node with, e, as the argument
+ and res as the return type.
*/
-static unsigned int identListLen (decl_node n)
+static decl_node__opaque makeUnary (decl_nodeT k, decl_node__opaque e, decl_node__opaque res)
{
- if (n == NULL)
+ decl_node__opaque n;
+
+ if (k == decl_plus)
{
- return 0;
+ return e;
}
else
{
- mcDebug_assert (isIdentList (n));
- return wlists_noOfItemsInList (n->identlistF.names);
+ n = newNode (k);
+ switch (n->kind)
+ {
+ case decl_min:
+ case decl_max:
+ case decl_throw:
+ case decl_re:
+ case decl_im:
+ case decl_deref:
+ case decl_high:
+ case decl_chr:
+ case decl_cap:
+ case decl_abs:
+ case decl_ord:
+ case decl_float:
+ case decl_trunc:
+ case decl_length:
+ case decl_constexp:
+ case decl_not:
+ case decl_neg:
+ case decl_adr:
+ case decl_size:
+ case decl_tsize:
+ n->unaryF.arg = e;
+ n->unaryF.resultType = res;
+ break;
+
+
+ default:
+ CaseException ("../../gcc/m2/mc/decl.def", 20, 1);
+ __builtin_unreachable ();
+ }
}
+ return n;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
/*
- checkParameters - placeholder for future parameter checking.
+ isLeafString - returns TRUE if n is a leaf node which is a string constant.
*/
-static void checkParameters (decl_node p, decl_node i, decl_node type, bool isvar, bool isused)
+static bool isLeafString (decl_node__opaque n)
{
- /* do check. */
- disposeNode (&i);
+ return ((isString (n)) || ((decl_isLiteral (static_cast<decl_node> (n))) && ((decl_getType (static_cast<decl_node> (n))) == charN))) || ((decl_isConst (static_cast<decl_node> (n))) && ((getExprType (n)) == charN));
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
}
/*
- checkMakeVariables - create shadow local variables for parameters providing that
- procedure n has not already been built and we are compiling
- a module or an implementation module.
+ getLiteralStringContents - return the contents of a literal node as a string.
*/
-static void checkMakeVariables (decl_node n, decl_node i, decl_node type, bool isvar, bool isused)
+static DynamicStrings_String getLiteralStringContents (decl_node__opaque n)
{
- if (((decl_isImp (currentModule)) || (decl_isModule (currentModule))) && ! n->procedureF.built)
+ DynamicStrings_String number;
+ DynamicStrings_String content;
+ DynamicStrings_String s;
+
+ mcDebug_assert (n->kind == decl_literal);
+ s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (n->literalF.name));
+ content = static_cast<DynamicStrings_String> (NULL);
+ if (n->literalF.type == charN)
{
- makeVariablesFromParameters (n, i, type, isvar, isused);
+ if ((DynamicStrings_char (s, -1)) == 'C')
+ {
+ if ((DynamicStrings_Length (s)) > 1)
+ {
+ number = DynamicStrings_Slice (s, 0, -1);
+ content = DynamicStrings_InitStringChar ((char ) (StringConvert_ostoc (number)));
+ number = DynamicStrings_KillString (number);
+ }
+ else
+ {
+ content = DynamicStrings_InitStringChar ('C');
+ }
+ }
+ else
+ {
+ content = DynamicStrings_Dup (s);
+ }
+ }
+ else
+ {
+ mcMetaError_metaError1 ((const char *) "cannot obtain string contents from {%1k}", 40, (const unsigned char *) &n->literalF.name, (sizeof (n->literalF.name)-1));
}
+ s = DynamicStrings_KillString (s);
+ return content;
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
}
/*
- makeVarientField - create a varient field within varient, v,
- The new varient field is returned.
+ getStringContents - return the string contents of a constant, literal,
+ string or a constexp node.
+*/
+
+static DynamicStrings_String getStringContents (decl_node__opaque n)
+{
+ if (decl_isConst (static_cast<decl_node> (n)))
+ {
+ return getStringContents (n->constF.value);
+ }
+ else if (decl_isLiteral (static_cast<decl_node> (n)))
+ {
+ /* avoid dangling else. */
+ return getLiteralStringContents (n);
+ }
+ else if (isString (n))
+ {
+ /* avoid dangling else. */
+ return getString (n);
+ }
+ else if (isConstExp (n))
+ {
+ /* avoid dangling else. */
+ return getStringContents (n->unaryF.arg);
+ }
+ M2RTS_HALT (-1);
+ __builtin_unreachable ();
+ ReturnException ("../../gcc/m2/mc/decl.def", 20, 1);
+ __builtin_unreachable ();
+}
+
+
+/*
+ addNames -
*/
-static decl_node makeVarientField (decl_node v, decl_node p)
+static nameKey_Name addNames (decl_node__opaque a, decl_node__opaque b)
{
- decl_node n;
+ DynamicStrings_String sa;
+ DynamicStrings_String sb;
+ nameKey_Name n;
- n = newNode (decl_varientfield);
- n->varientfieldF.name = nameKey_NulName;
- n->varientfieldF.parent = p;
- n->varientfieldF.varient = v;
- n->varientfieldF.simple = false;
- n->varientfieldF.listOfSons = Indexing_InitIndex (1);
- n->varientfieldF.scope = decl_getDeclScope ();
+ sa = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (static_cast<decl_node> (a))));
+ sb = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (static_cast<decl_node> (b))));
+ sa = DynamicStrings_ConCat (sa, sb);
+ n = nameKey_makekey (DynamicStrings_string (sa));
+ sa = DynamicStrings_KillString (sa);
+ sb = DynamicStrings_KillString (sb);
return n;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
/*
- putFieldVarient - places the field varient, f, as a brother to, the
- varient symbol, v, and also tells, f, that its varient
- parent is, v.
+ resolveString -
*/
-static void putFieldVarient (decl_node f, decl_node v)
+static decl_node__opaque resolveString (decl_node__opaque n)
{
- mcDebug_assert (decl_isVarient (v));
- mcDebug_assert (decl_isVarientField (f));
- switch (v->kind)
+ while ((decl_isConst (static_cast<decl_node> (n))) || (isConstExp (n)))
{
- case decl_varient:
- Indexing_IncludeIndiceIntoIndex (v->varientF.listOfSons, reinterpret_cast<void *> (f));
- break;
-
-
- default:
- CaseException ("../../gcc/m2/mc/decl.def", 20, 1);
- __builtin_unreachable ();
+ if (decl_isConst (static_cast<decl_node> (n)))
+ {
+ n = n->constF.value;
+ }
+ else
+ {
+ n = n->unaryF.arg;
+ }
}
- switch (f->kind)
+ if (n->kind == decl_plus)
{
- case decl_varientfield:
- f->varientfieldF.varient = v;
- break;
-
-
- default:
- CaseException ("../../gcc/m2/mc/decl.def", 20, 1);
- __builtin_unreachable ();
+ n = static_cast<decl_node__opaque> (decl_makeString (addNames (resolveString (n->binaryF.left), resolveString (n->binaryF.right))));
}
+ return n;
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
}
/*
- putFieldRecord - create a new recordfield and place it into record r.
- The new field has a tagname and type and can have a
- variant field v.
+ foldBinary -
*/
-static decl_node putFieldRecord (decl_node r, nameKey_Name tag, decl_node type, decl_node v)
+static decl_node__opaque foldBinary (decl_nodeT k, decl_node__opaque l, decl_node__opaque r, decl_node__opaque res)
{
- decl_node f;
- decl_node n;
- decl_node p;
+ decl_node__opaque n;
+ DynamicStrings_String ls;
+ DynamicStrings_String rs;
- n = newNode (decl_recordfield);
- switch (r->kind)
+ n = static_cast<decl_node__opaque> (NULL);
+ if (((k == decl_plus) && (isLeafString (l))) && (isLeafString (r)))
{
- case decl_record:
- Indexing_IncludeIndiceIntoIndex (r->recordF.listOfSons, reinterpret_cast<void *> (n));
- /* ensure that field, n, is in the parents Local Symbols. */
- if (tag != nameKey_NulName)
- {
- /* avoid gcc warning by using compound statement even if not strictly necessary. */
- if ((symbolKey_getSymKey (r->recordF.localSymbols, tag)) == symbolKey_NulKey)
- {
- symbolKey_putSymKey (r->recordF.localSymbols, tag, reinterpret_cast<void *> (n));
- }
- else
- {
- f = static_cast<decl_node> (symbolKey_getSymKey (r->recordF.localSymbols, tag));
- mcMetaError_metaErrors1 ((const char *) "field record {%1Dad} has already been declared", 46, (const char *) "field record duplicate", 22, (const unsigned char *) &f, (sizeof (f)-1));
- }
- }
- break;
-
- case decl_varientfield:
- Indexing_IncludeIndiceIntoIndex (r->varientfieldF.listOfSons, reinterpret_cast<void *> (n));
- p = getParent (r);
- mcDebug_assert (p->kind == decl_record);
- if (tag != nameKey_NulName)
- {
- symbolKey_putSymKey (p->recordF.localSymbols, tag, reinterpret_cast<void *> (n));
- }
- break;
-
-
- default:
- CaseException ("../../gcc/m2/mc/decl.def", 20, 1);
- __builtin_unreachable ();
+ ls = getStringContents (l);
+ rs = getStringContents (r);
+ ls = DynamicStrings_Add (ls, rs);
+ n = static_cast<decl_node__opaque> (decl_makeString (nameKey_makekey (DynamicStrings_string (ls))));
+ ls = DynamicStrings_KillString (ls);
+ rs = DynamicStrings_KillString (rs);
}
- /* fill in, n. */
- n->recordfieldF.type = type;
- n->recordfieldF.name = tag;
- n->recordfieldF.parent = r;
- n->recordfieldF.varient = v;
- n->recordfieldF.tag = false;
- n->recordfieldF.scope = NULL;
- initCname (&n->recordfieldF.cname);
- /*
- IF r^.kind=record
- THEN
- doRecordM2 (doP, r)
- END ;
- */
return n;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
/*
- ensureOrder - ensures that, a, and, b, exist in, i, and also
- ensure that, a, is before, b.
+ makeBinary - create a binary node with left/right/result type: l, r and resultType.
*/
-static void ensureOrder (Indexing_Index i, decl_node a, decl_node b)
+static decl_node__opaque makeBinary (decl_nodeT k, decl_node__opaque l, decl_node__opaque r, decl_node__opaque resultType)
{
- mcDebug_assert (Indexing_IsIndiceInIndex (i, reinterpret_cast<void *> (a)));
- mcDebug_assert (Indexing_IsIndiceInIndex (i, reinterpret_cast<void *> (b)));
- Indexing_RemoveIndiceFromIndex (i, reinterpret_cast<void *> (a));
- Indexing_RemoveIndiceFromIndex (i, reinterpret_cast<void *> (b));
- Indexing_IncludeIndiceIntoIndex (i, reinterpret_cast<void *> (a));
- Indexing_IncludeIndiceIntoIndex (i, reinterpret_cast<void *> (b));
- mcDebug_assert (Indexing_IsIndiceInIndex (i, reinterpret_cast<void *> (a)));
- mcDebug_assert (Indexing_IsIndiceInIndex (i, reinterpret_cast<void *> (b)));
+ decl_node__opaque n;
+
+ n = foldBinary (k, l, r, resultType);
+ if (n == NULL)
+ {
+ n = doMakeBinary (k, l, r, resultType);
+ }
+ return n;
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
}
/*
- putVarientTag - places tag into variant v.
+ doMakeBinary - returns a binary node containing left/right/result values
+ l, r, res, with a node operator, k.
*/
-static void putVarientTag (decl_node v, decl_node tag)
+static decl_node__opaque doMakeBinary (decl_nodeT k, decl_node__opaque l, decl_node__opaque r, decl_node__opaque res)
{
- decl_node p;
+ decl_node__opaque n;
- mcDebug_assert (decl_isVarient (v));
- switch (v->kind)
+ n = newNode (k);
+ switch (n->kind)
{
- case decl_varient:
- v->varientF.tag = tag;
- break;
-
-
- default:
- CaseException ("../../gcc/m2/mc/decl.def", 20, 1);
- __builtin_unreachable ();
- }
-}
-
-
-/*
- getParent - returns the parent field of recordfield or varientfield symbol, n.
-*/
-
-static decl_node getParent (decl_node n)
-{
- switch (n->kind)
- {
- case decl_recordfield:
- return n->recordfieldF.parent;
- break;
-
- case decl_varientfield:
- return n->varientfieldF.parent;
+ case decl_cmplx:
+ case decl_equal:
+ case decl_notequal:
+ case decl_less:
+ case decl_greater:
+ case decl_greequal:
+ case decl_lessequal:
+ case decl_and:
+ case decl_or:
+ case decl_cast:
+ case decl_val:
+ case decl_plus:
+ case decl_sub:
+ case decl_div:
+ case decl_mod:
+ case decl_mult:
+ case decl_divide:
+ case decl_in:
+ n->binaryF.left = l;
+ n->binaryF.right = r;
+ n->binaryF.resultType = res;
break;
CaseException ("../../gcc/m2/mc/decl.def", 20, 1);
__builtin_unreachable ();
}
+ return n;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
/*
- getRecord - returns the record associated with node, n.
- (Parental record).
+ doMakeComponentRef -
*/
-static decl_node getRecord (decl_node n)
+static decl_node__opaque doMakeComponentRef (decl_node__opaque rec, decl_node__opaque field)
{
- mcDebug_assert (n->kind != decl_varient); /* if this fails then we need to add parent field to varient. */
- switch (n->kind)
- {
- case decl_record:
- return n; /* if this fails then we need to add parent field to varient. */
- break;
-
- case decl_varientfield:
- return getRecord (getParent (n));
- break;
-
+ decl_node__opaque n;
- default:
- CaseException ("../../gcc/m2/mc/decl.def", 20, 1);
- __builtin_unreachable ();
- }
+ n = newNode (decl_componentref);
+ n->componentrefF.rec = rec;
+ n->componentrefF.field = field;
+ n->componentrefF.resultType = static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (field)));
+ initNodeOpaqueState (n);
+ return n;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
/*
- isConstExp - return TRUE if the node kind is a constexp.
+ isComponentRef -
*/
-static bool isConstExp (decl_node c)
+static bool isComponentRef (decl_node__opaque n)
{
- mcDebug_assert (c != NULL);
- return c->kind == decl_constexp;
+ mcDebug_assert (n != NULL);
+ return n->kind == decl_componentref;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
/*
- addEnumToModule - adds enumeration type, e, into the list of enums
- in module, m.
-*/
-
-static void addEnumToModule (decl_node m, decl_node e)
-{
- mcDebug_assert ((decl_isEnumeration (e)) || (decl_isEnumerationField (e)));
- mcDebug_assert (((decl_isModule (m)) || (decl_isDef (m))) || (decl_isImp (m)));
- if (decl_isModule (m))
- {
- Indexing_IncludeIndiceIntoIndex (m->moduleF.enumFixup.info, reinterpret_cast<void *> (e));
- }
- else if (decl_isDef (m))
- {
- /* avoid dangling else. */
- Indexing_IncludeIndiceIntoIndex (m->defF.enumFixup.info, reinterpret_cast<void *> (e));
- }
- else if (decl_isImp (m))
- {
- /* avoid dangling else. */
- Indexing_IncludeIndiceIntoIndex (m->impF.enumFixup.info, reinterpret_cast<void *> (e));
- }
-}
-
-
-/*
- getNextFixup - return the next fixup from from f.
+ isArrayRef - returns TRUE if the node was an arrayref.
*/
-static decl_node getNextFixup (decl_fixupInfo *f)
+static bool isArrayRef (decl_node__opaque n)
{
- (*f).count += 1;
- return static_cast<decl_node> (Indexing_GetIndice ((*f).info, (*f).count));
+ mcDebug_assert (n != NULL);
+ return n->kind == decl_arrayref;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
/*
- doMakeEnum - create an enumeration type and add it to the current module.
+ isDeref - returns TRUE if, n, is a deref node.
*/
-static decl_node doMakeEnum (void)
+static bool isDeref (decl_node__opaque n)
{
- decl_node e;
-
- e = newNode (decl_enumeration);
- e->enumerationF.noOfElements = 0;
- e->enumerationF.localSymbols = symbolKey_initTree ();
- e->enumerationF.scope = decl_getDeclScope ();
- e->enumerationF.listOfSons = Indexing_InitIndex (1);
- e->enumerationF.low = NULL;
- e->enumerationF.high = NULL;
- addEnumToModule (currentModule, e);
- return e;
+ mcDebug_assert (n != NULL);
+ return n->kind == decl_deref;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
/*
- doMakeEnumField - create an enumeration field name and add it to enumeration e.
- Return the new field.
+ makeBase - create a base type or constant.
+ It only supports the base types and constants
+ enumerated below.
*/
-static decl_node doMakeEnumField (decl_node e, nameKey_Name n)
+static decl_node__opaque makeBase (decl_nodeT k)
{
- decl_node f;
+ decl_node__opaque n;
- mcDebug_assert (decl_isEnumeration (e));
- f = decl_lookupSym (n);
- if (f == NULL)
- {
- f = newNode (decl_enumerationfield);
- symbolKey_putSymKey (e->enumerationF.localSymbols, n, reinterpret_cast<void *> (f));
- Indexing_IncludeIndiceIntoIndex (e->enumerationF.listOfSons, reinterpret_cast<void *> (f));
- f->enumerationfieldF.name = n;
- f->enumerationfieldF.type = e;
- f->enumerationfieldF.scope = decl_getDeclScope ();
- f->enumerationfieldF.value = e->enumerationF.noOfElements;
- initCname (&f->enumerationfieldF.cname);
- e->enumerationF.noOfElements += 1;
- mcDebug_assert ((Indexing_GetIndice (e->enumerationF.listOfSons, e->enumerationF.noOfElements)) == f);
- addEnumToModule (currentModule, f);
- if (e->enumerationF.low == NULL)
- {
- e->enumerationF.low = f;
- }
- e->enumerationF.high = f;
- return addToScope (f);
- }
- else
+ n = newNode (k);
+ switch (k)
{
- mcMetaError_metaErrors2 ((const char *) "cannot create enumeration field {%1k} as the name is already in use", 67, (const char *) "{%2DMad} was declared elsewhere", 31, (const unsigned char *) &n, (sizeof (n)-1), (const unsigned char *) &f, (sizeof (f)-1));
+ case decl_new:
+ case decl_dispose:
+ case decl_length:
+ case decl_inc:
+ case decl_dec:
+ case decl_incl:
+ case decl_excl:
+ case decl_nil:
+ case decl_true:
+ case decl_false:
+ case decl_address:
+ case decl_loc:
+ case decl_byte:
+ case decl_word:
+ case decl_csizet:
+ case decl_cssizet:
+ case decl_char:
+ case decl_cardinal:
+ case decl_longcard:
+ case decl_shortcard:
+ case decl_integer:
+ case decl_longint:
+ case decl_shortint:
+ case decl_real:
+ case decl_longreal:
+ case decl_shortreal:
+ case decl_bitset:
+ case decl_boolean:
+ case decl_proc:
+ case decl_ztype:
+ case decl_rtype:
+ case decl_complex:
+ case decl_longcomplex:
+ case decl_shortcomplex:
+ case decl_adr:
+ case decl_chr:
+ case decl_cap:
+ case decl_abs:
+ case decl_float:
+ case decl_trunc:
+ case decl_ord:
+ case decl_high:
+ case decl_throw:
+ case decl_re:
+ case decl_im:
+ case decl_cmplx:
+ case decl_size:
+ case decl_tsize:
+ case decl_val:
+ case decl_min:
+ case decl_max:
+ break;
+
+
+ default:
+ M2RTS_HALT (-1); /* legal kind. */
+ __builtin_unreachable ();
+ break;
}
- return f;
+ return n;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
/*
- getExpList - returns the, n, th argument in an explist.
+ isOrdinal - returns TRUE if, n, is an ordinal type.
*/
-static decl_node getExpList (decl_node p, unsigned int n)
+static bool isOrdinal (decl_node__opaque n)
{
- mcDebug_assert (p != NULL);
- mcDebug_assert (decl_isExpList (p));
- mcDebug_assert (n <= (Indexing_HighIndice (p->explistF.exp)));
- return static_cast<decl_node> (Indexing_GetIndice (p->explistF.exp, n));
+ switch (n->kind)
+ {
+ case decl_address:
+ case decl_loc:
+ case decl_byte:
+ case decl_word:
+ case decl_csizet:
+ case decl_cssizet:
+ case decl_char:
+ case decl_integer:
+ case decl_longint:
+ case decl_shortint:
+ case decl_cardinal:
+ case decl_longcard:
+ case decl_shortcard:
+ case decl_bitset:
+ return true;
+ break;
+
+
+ default:
+ return false;
+ break;
+ }
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
/*
- expListLen - returns the length of explist, p.
+ mixTypes -
*/
-static unsigned int expListLen (decl_node p)
+static decl_node__opaque mixTypes (decl_node__opaque a, decl_node__opaque b)
{
- if (p == NULL)
- {
- return 0;
- }
- else
+ if ((a == addressN) || (b == addressN))
{
- mcDebug_assert (decl_isExpList (p));
- return Indexing_HighIndice (p->explistF.exp);
+ return addressN;
}
+ return a;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
/*
- getConstExpComplete - gets the field from the def or imp or module, n.
+ doSetExprType -
*/
-static bool getConstExpComplete (decl_node n)
+static decl_node__opaque doSetExprType (decl_node__opaque *t, decl_node__opaque n)
{
- switch (n->kind)
+ if ((*t) == NULL)
{
- case decl_def:
- return n->defF.constsComplete;
- break;
-
- case decl_imp:
- return n->impF.constsComplete;
- break;
-
- case decl_module:
- return n->moduleF.constsComplete;
- break;
-
-
- default:
- CaseException ("../../gcc/m2/mc/decl.def", 20, 1);
- __builtin_unreachable ();
+ (*t) = n;
}
+ return (*t);
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
/*
- addConstToModule - adds const exp, e, into the list of constant
- expressions in module, m.
+ getMaxMinType -
*/
-static void addConstToModule (decl_node m, decl_node e)
+static decl_node__opaque getMaxMinType (decl_node__opaque n)
{
- mcDebug_assert (((decl_isModule (m)) || (decl_isDef (m))) || (decl_isImp (m)));
- if (decl_isModule (m))
+ if ((decl_isVar (static_cast<decl_node> (n))) || (decl_isConst (static_cast<decl_node> (n))))
{
- Indexing_IncludeIndiceIntoIndex (m->moduleF.constFixup.info, reinterpret_cast<void *> (e));
+ return static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (n)));
}
- else if (decl_isDef (m))
+ else if (isConstExp (n))
{
/* avoid dangling else. */
- Indexing_IncludeIndiceIntoIndex (m->defF.constFixup.info, reinterpret_cast<void *> (e));
+ n = getExprType (n->unaryF.arg);
+ if (n == bitsetN)
+ {
+ return ztypeN;
+ }
+ else
+ {
+ return n;
+ }
}
- else if (decl_isImp (m))
+ else
{
/* avoid dangling else. */
- Indexing_IncludeIndiceIntoIndex (m->impF.constFixup.info, reinterpret_cast<void *> (e));
+ return n;
}
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
}
/*
- doMakeConstExp - create a constexp node and add it to the current module.
+ doGetFuncType -
*/
-static decl_node doMakeConstExp (void)
+static decl_node__opaque doGetFuncType (decl_node__opaque n)
{
- decl_node c;
+ decl_node__opaque result;
- c = makeUnary (decl_constexp, NULL, NULL);
- addConstToModule (currentModule, c);
- return c;
+ mcDebug_assert (isFuncCall (n));
+ result = doSetExprType (&n->funccallF.type, static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (n->funccallF.function))));
+ initNodeOpaqueState (n); /* Update now that the return type is known. */
+ return result; /* Update now that the return type is known. */
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
/*
- isAnyType - return TRUE if node n is any type kind.
+ doGetExprType - works out the type which is associated with node, n.
*/
-static bool isAnyType (decl_node n)
+static decl_node__opaque doGetExprType (decl_node__opaque n)
{
- mcDebug_assert (n != NULL);
switch (n->kind)
{
+ case decl_max:
+ case decl_min:
+ return getMaxMinType (n->unaryF.arg);
+ break;
+
+ case decl_cast:
+ case decl_val:
+ return doSetExprType (&n->binaryF.resultType, n->binaryF.left);
+ break;
+
+ case decl_halt:
+ case decl_new:
+ case decl_dispose:
+ return static_cast<decl_node__opaque> (NULL);
+ break;
+
+ case decl_inc:
+ case decl_dec:
+ case decl_incl:
+ case decl_excl:
+ return static_cast<decl_node__opaque> (NULL);
+ break;
+
+ case decl_nil:
+ return addressN;
+ break;
+
+ case decl_true:
+ case decl_false:
+ return booleanN;
+ break;
+
case decl_address:
+ return n;
+ break;
+
case decl_loc:
+ return n;
+ break;
+
case decl_byte:
+ return n;
+ break;
+
case decl_word:
+ return n;
+ break;
+
+ case decl_csizet:
+ return n;
+ break;
+
+ case decl_cssizet:
+ return n;
+ break;
+
+ case decl_boolean:
+ /* base types. */
+ return n;
+ break;
+
+ case decl_proc:
+ return n;
+ break;
+
case decl_char:
+ return n;
+ break;
+
case decl_cardinal:
+ return n;
+ break;
+
case decl_longcard:
+ return n;
+ break;
+
case decl_shortcard:
+ return n;
+ break;
+
case decl_integer:
+ return n;
+ break;
+
case decl_longint:
+ return n;
+ break;
+
case decl_shortint:
- case decl_complex:
- case decl_longcomplex:
- case decl_shortcomplex:
+ return n;
+ break;
+
+ case decl_real:
+ return n;
+ break;
+
+ case decl_longreal:
+ return n;
+ break;
+
+ case decl_shortreal:
+ return n;
+ break;
+
case decl_bitset:
- case decl_boolean:
- case decl_proc:
- case decl_type:
- return true;
+ return n;
break;
+ case decl_ztype:
+ return n;
+ break;
- default:
- return false;
+ case decl_rtype:
+ return n;
break;
- }
- /* static analysis guarentees a RETURN statement will be used before here. */
- __builtin_unreachable ();
-}
+ case decl_complex:
+ return n;
+ break;
-/*
- makeVal - creates a VAL (type, expression) node.
-*/
+ case decl_longcomplex:
+ return n;
+ break;
-static decl_node makeVal (decl_node params)
-{
- mcDebug_assert (decl_isExpList (params));
- if ((expListLen (params)) == 2)
- {
- return makeBinary (decl_val, getExpList (params, 1), getExpList (params, 2), getExpList (params, 1));
- }
- else
- {
- M2RTS_HALT (-1);
- __builtin_unreachable ();
- }
- ReturnException ("../../gcc/m2/mc/decl.def", 20, 1);
- __builtin_unreachable ();
-}
+ case decl_shortcomplex:
+ return n;
+ break;
+ case decl_type:
+ /* language features and compound type attributes. */
+ return n->typeF.type;
+ break;
-/*
- makeCast - creates a cast node TYPENAME (expr).
-*/
+ case decl_record:
+ return n;
+ break;
-static decl_node makeCast (decl_node c, decl_node p)
-{
- mcDebug_assert (decl_isExpList (p));
- if ((expListLen (p)) == 1)
- {
- return makeBinary (decl_cast, c, getExpList (p, 1), c);
- }
- else
- {
- M2RTS_HALT (-1);
- __builtin_unreachable ();
- }
- ReturnException ("../../gcc/m2/mc/decl.def", 20, 1);
- __builtin_unreachable ();
-}
+ case decl_varient:
+ return n;
+ break;
-static decl_node makeIntrinsicProc (decl_nodeT k, unsigned int noArgs, decl_node p)
-{
- decl_node f;
+ case decl_var:
+ return n->varF.type;
+ break;
- /*
- makeIntrisicProc - create an intrinsic node.
- */
- f = newNode (k);
- f->intrinsicF.args = p;
- f->intrinsicF.noArgs = noArgs;
- f->intrinsicF.type = NULL;
- f->intrinsicF.postUnreachable = k == decl_halt;
- initPair (&f->intrinsicF.intrinsicComment);
- return f;
- /* static analysis guarentees a RETURN statement will be used before here. */
- __builtin_unreachable ();
-}
+ case decl_enumeration:
+ return n;
+ break;
+ case decl_subrange:
+ return n->subrangeF.type;
+ break;
-/*
- makeIntrinsicUnaryType - create an intrisic unary type.
-*/
+ case decl_array:
+ return n->arrayF.type;
+ break;
-static decl_node makeIntrinsicUnaryType (decl_nodeT k, decl_node paramList, decl_node returnType)
-{
- return makeUnary (k, getExpList (paramList, 1), returnType);
- /* static analysis guarentees a RETURN statement will be used before here. */
- __builtin_unreachable ();
-}
+ case decl_string:
+ return charN;
+ break;
+ case decl_const:
+ return doSetExprType (&n->constF.type, getExprType (n->constF.value));
+ break;
-/*
- makeIntrinsicBinaryType - create an intrisic binary type.
-*/
+ case decl_literal:
+ return n->literalF.type;
+ break;
-static decl_node makeIntrinsicBinaryType (decl_nodeT k, decl_node paramList, decl_node returnType)
-{
- return makeBinary (k, getExpList (paramList, 1), getExpList (paramList, 2), returnType);
- /* static analysis guarentees a RETURN statement will be used before here. */
- __builtin_unreachable ();
-}
+ case decl_varparam:
+ return n->varparamF.type;
+ break;
+ case decl_param:
+ return n->paramF.type;
+ break;
-/*
- checkIntrinsic - checks to see if the function call to, c, with
- parameter list, n, is really an intrinic. If it
- is an intrinic then an intrinic node is created
- and returned. Otherwise NIL is returned.
-*/
+ case decl_optarg:
+ return n->optargF.type;
+ break;
-static decl_node checkIntrinsic (decl_node c, decl_node n)
-{
- if (isAnyType (c))
- {
- return makeCast (c, n);
- }
- else if (c == maxN)
- {
- /* avoid dangling else. */
- return makeIntrinsicUnaryType (decl_max, n, NULL);
- }
- else if (c == minN)
- {
- /* avoid dangling else. */
- return makeIntrinsicUnaryType (decl_min, n, NULL);
- }
- else if (c == haltN)
- {
- /* avoid dangling else. */
- return makeIntrinsicProc (decl_halt, expListLen (n), n);
- }
- else if (c == valN)
- {
- /* avoid dangling else. */
- return makeVal (n);
- }
- else if (c == adrN)
- {
- /* avoid dangling else. */
- return makeIntrinsicUnaryType (decl_adr, n, addressN);
- }
- else if (c == sizeN)
- {
- /* avoid dangling else. */
- return makeIntrinsicUnaryType (decl_size, n, cardinalN);
- }
- else if (c == tsizeN)
- {
- /* avoid dangling else. */
- return makeIntrinsicUnaryType (decl_tsize, n, cardinalN);
- }
- else if (c == floatN)
- {
- /* avoid dangling else. */
- return makeIntrinsicUnaryType (decl_float, n, realN);
- }
- else if (c == truncN)
- {
- /* avoid dangling else. */
- return makeIntrinsicUnaryType (decl_trunc, n, integerN);
- }
- else if (c == ordN)
- {
- /* avoid dangling else. */
- return makeIntrinsicUnaryType (decl_ord, n, cardinalN);
- }
- else if (c == chrN)
- {
- /* avoid dangling else. */
- return makeIntrinsicUnaryType (decl_chr, n, charN);
- }
- else if (c == capN)
- {
- /* avoid dangling else. */
- return makeIntrinsicUnaryType (decl_cap, n, charN);
- }
- else if (c == absN)
- {
- /* avoid dangling else. */
- return makeIntrinsicUnaryType (decl_abs, n, NULL);
- }
- else if (c == imN)
- {
- /* avoid dangling else. */
- return makeIntrinsicUnaryType (decl_im, n, NULL);
- }
- else if (c == reN)
- {
- /* avoid dangling else. */
- return makeIntrinsicUnaryType (decl_re, n, NULL);
- }
- else if (c == cmplxN)
- {
- /* avoid dangling else. */
- return makeIntrinsicBinaryType (decl_cmplx, n, NULL);
- }
- else if (c == highN)
- {
- /* avoid dangling else. */
- return makeIntrinsicUnaryType (decl_high, n, cardinalN);
- }
- else if (c == incN)
- {
- /* avoid dangling else. */
- return makeIntrinsicProc (decl_inc, expListLen (n), n);
- }
- else if (c == decN)
- {
- /* avoid dangling else. */
- return makeIntrinsicProc (decl_dec, expListLen (n), n);
- }
- else if (c == inclN)
- {
- /* avoid dangling else. */
- return makeIntrinsicProc (decl_incl, expListLen (n), n);
- }
- else if (c == exclN)
- {
- /* avoid dangling else. */
- return makeIntrinsicProc (decl_excl, expListLen (n), n);
- }
- else if (c == newN)
- {
- /* avoid dangling else. */
- return makeIntrinsicProc (decl_new, 1, n);
- }
- else if (c == disposeN)
- {
- /* avoid dangling else. */
- return makeIntrinsicProc (decl_dispose, 1, n);
- }
- else if (c == lengthN)
- {
- /* avoid dangling else. */
- return makeIntrinsicUnaryType (decl_length, n, cardinalN);
- }
- else if (c == throwN)
- {
- /* avoid dangling else. */
- keyc_useThrow ();
- return makeIntrinsicProc (decl_throw, 1, n);
- }
- return NULL;
- /* static analysis guarentees a RETURN statement will be used before here. */
- __builtin_unreachable ();
-}
-
-
-/*
- checkCHeaders - check to see if the function is a C system function and
- requires a header file included.
-*/
-
-static void checkCHeaders (decl_node c)
-{
- nameKey_Name name;
- decl_node s;
-
- if (decl_isProcedure (c))
- {
- s = decl_getScope (c);
- if ((decl_getSymName (s)) == (nameKey_makeKey ((const char *) "libc", 4)))
- {
- name = decl_getSymName (c);
- if ((((name == (nameKey_makeKey ((const char *) "read", 4))) || (name == (nameKey_makeKey ((const char *) "write", 5)))) || (name == (nameKey_makeKey ((const char *) "open", 4)))) || (name == (nameKey_makeKey ((const char *) "close", 5))))
- {
- keyc_useUnistd ();
- }
- }
- }
-}
-
-
-/*
- isFuncCall - returns TRUE if, n, is a function/procedure call.
-*/
-
-static bool isFuncCall (decl_node n)
-{
- mcDebug_assert (n != NULL);
- return n->kind == decl_funccall;
- /* static analysis guarentees a RETURN statement will be used before here. */
- __builtin_unreachable ();
-}
-
-
-/*
- putTypeInternal - marks type, des, as being an internally generated type.
-*/
-
-static void putTypeInternal (decl_node des)
-{
- mcDebug_assert (des != NULL);
- mcDebug_assert (decl_isType (des));
- des->typeF.isInternal = true;
-}
-
-
-/*
- isTypeInternal - returns TRUE if type, n, is internal.
-*/
-
-static bool isTypeInternal (decl_node n)
-{
- mcDebug_assert (n != NULL);
- mcDebug_assert (decl_isType (n));
- return n->typeF.isInternal;
- /* static analysis guarentees a RETURN statement will be used before here. */
- __builtin_unreachable ();
-}
-
-
-/*
- lookupBase - return node named n from the base symbol scope.
-*/
-
-static decl_node lookupBase (nameKey_Name n)
-{
- decl_node m;
-
- m = static_cast<decl_node> (symbolKey_getSymKey (baseSymbols, n));
- if (m == procN)
- {
- keyc_useProc ();
- }
- else if (((m == complexN) || (m == longcomplexN)) || (m == shortcomplexN))
- {
- /* avoid dangling else. */
- keyc_useComplex ();
- }
- return m;
- /* static analysis guarentees a RETURN statement will be used before here. */
- __builtin_unreachable ();
-}
-
-
-/*
- dumpScopes - display the names of all the scopes stacked.
-*/
-
-static void dumpScopes (void)
-{
- unsigned int h;
- decl_node s;
-
- h = Indexing_HighIndice (scopeStack);
- libc_printf ((const char *) "total scopes stacked %d\\n", 25, h);
- while (h >= 1)
- {
- s = static_cast<decl_node> (Indexing_GetIndice (scopeStack, h));
- out2 ((const char *) " scope [%d] is %s\\n", 19, h, s);
- h -= 1;
- }
-}
-
-
-/*
- out0 - write string a to StdOut.
-*/
-
-static void out0 (const char *a_, unsigned int _a_high)
-{
- DynamicStrings_String m;
- char a[_a_high+1];
+ case decl_pointer:
+ return n->pointerF.type;
+ break;
- /* make a local copy of each unbounded array. */
- memcpy (a, a_, _a_high+1);
+ case decl_recordfield:
+ return n->recordfieldF.type;
+ break;
- m = FormatStrings_Sprintf0 (DynamicStrings_InitString ((const char *) a, _a_high));
- m = DynamicStrings_KillString (SFIO_WriteS (FIO_StdOut, m));
-}
+ case decl_varientfield:
+ return n;
+ break;
+ case decl_enumerationfield:
+ return n->enumerationfieldF.type;
+ break;
-/*
- out1 - write string a to StdOut using format specifier a.
-*/
+ case decl_set:
+ return n->setF.type;
+ break;
-static void out1 (const char *a_, unsigned int _a_high, decl_node s)
-{
- DynamicStrings_String m;
- unsigned int d;
- char a[_a_high+1];
+ case decl_proctype:
+ return n->proctypeF.returnType;
+ break;
- /* make a local copy of each unbounded array. */
- memcpy (a, a_, _a_high+1);
+ case decl_subscript:
+ return n->subscriptF.type;
+ break;
- m = getFQstring (s);
- if (DynamicStrings_EqualArray (m, (const char *) "", 0))
- {
- d = (unsigned int ) ((long unsigned int ) (s));
- m = DynamicStrings_KillString (m);
- m = FormatStrings_Sprintf1 (DynamicStrings_InitString ((const char *) "[%d]", 4), (const unsigned char *) &d, (sizeof (d)-1));
- }
- m = FormatStrings_Sprintf1 (DynamicStrings_InitString ((const char *) a, _a_high), (const unsigned char *) &m, (sizeof (m)-1));
- m = DynamicStrings_KillString (SFIO_WriteS (FIO_StdOut, m));
-}
+ case decl_procedure:
+ /* blocks. */
+ return n->procedureF.returnType;
+ break;
+ case decl_throw:
+ return static_cast<decl_node__opaque> (NULL);
+ break;
-/*
- out2 - write string a to StdOut using format specifier a.
-*/
+ case decl_unreachable:
+ return static_cast<decl_node__opaque> (NULL);
+ break;
-static void out2 (const char *a_, unsigned int _a_high, unsigned int c, decl_node s)
-{
- DynamicStrings_String m;
- DynamicStrings_String m1;
- char a[_a_high+1];
+ case decl_def:
+ case decl_imp:
+ case decl_module:
+ case decl_loop:
+ case decl_while:
+ case decl_for:
+ case decl_repeat:
+ case decl_if:
+ case decl_elsif:
+ case decl_assignment:
+ /* statements. */
+ M2RTS_HALT (-1);
+ __builtin_unreachable ();
+ break;
- /* make a local copy of each unbounded array. */
- memcpy (a, a_, _a_high+1);
+ case decl_plus:
+ case decl_sub:
+ case decl_div:
+ case decl_mod:
+ case decl_mult:
+ case decl_divide:
+ /* expressions. */
+ return doSetExprType (&n->binaryF.resultType, mixTypes (getExprType (n->binaryF.left), getExprType (n->binaryF.right)));
+ break;
- m1 = getString (s);
- m = FormatStrings_Sprintf2 (DynamicStrings_InitString ((const char *) a, _a_high), (const unsigned char *) &c, (sizeof (c)-1), (const unsigned char *) &m1, (sizeof (m1)-1));
- m = DynamicStrings_KillString (SFIO_WriteS (FIO_StdOut, m));
- m1 = DynamicStrings_KillString (m1);
-}
+ case decl_in:
+ case decl_and:
+ case decl_or:
+ case decl_equal:
+ case decl_notequal:
+ case decl_less:
+ case decl_greater:
+ case decl_greequal:
+ case decl_lessequal:
+ return doSetExprType (&n->binaryF.resultType, booleanN);
+ break;
+ case decl_cmplx:
+ return doSetExprType (&n->binaryF.resultType, complexN);
+ break;
-/*
- out3 - write string a to StdOut using format specifier a.
-*/
+ case decl_abs:
+ case decl_constexp:
+ case decl_deref:
+ case decl_neg:
+ return doSetExprType (&n->unaryF.resultType, getExprType (n->unaryF.arg));
+ break;
-static void out3 (const char *a_, unsigned int _a_high, unsigned int l, nameKey_Name n, decl_node s)
-{
- DynamicStrings_String m;
- DynamicStrings_String m1;
- DynamicStrings_String m2;
- char a[_a_high+1];
+ case decl_adr:
+ return doSetExprType (&n->unaryF.resultType, addressN);
+ break;
- /* make a local copy of each unbounded array. */
- memcpy (a, a_, _a_high+1);
+ case decl_size:
+ case decl_tsize:
+ return doSetExprType (&n->unaryF.resultType, cardinalN);
+ break;
- m1 = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (n));
- m2 = getString (s);
- m = FormatStrings_Sprintf3 (DynamicStrings_InitString ((const char *) a, _a_high), (const unsigned char *) &l, (sizeof (l)-1), (const unsigned char *) &m1, (sizeof (m1)-1), (const unsigned char *) &m2, (sizeof (m2)-1));
- m = DynamicStrings_KillString (SFIO_WriteS (FIO_StdOut, m));
- m1 = DynamicStrings_KillString (m1);
- m2 = DynamicStrings_KillString (m2);
-}
+ case decl_high:
+ case decl_ord:
+ return doSetExprType (&n->unaryF.resultType, cardinalN);
+ break;
+ case decl_float:
+ return doSetExprType (&n->unaryF.resultType, realN);
+ break;
-/*
- isUnary - returns TRUE if, n, is an unary node.
-*/
+ case decl_trunc:
+ return doSetExprType (&n->unaryF.resultType, integerN);
+ break;
-static bool isUnary (decl_node n)
-{
- mcDebug_assert (n != NULL);
- switch (n->kind)
- {
- case decl_length:
- case decl_re:
- case decl_im:
- case decl_deref:
- case decl_high:
case decl_chr:
+ return doSetExprType (&n->unaryF.resultType, charN);
+ break;
+
case decl_cap:
- case decl_abs:
- case decl_ord:
- case decl_float:
- case decl_trunc:
- case decl_constexp:
+ return doSetExprType (&n->unaryF.resultType, charN);
+ break;
+
case decl_not:
- case decl_neg:
- case decl_adr:
- case decl_size:
- case decl_tsize:
- case decl_min:
- case decl_max:
- return true;
+ return doSetExprType (&n->unaryF.resultType, booleanN);
break;
+ case decl_re:
+ return doSetExprType (&n->unaryF.resultType, realN);
+ break;
- default:
- return false;
+ case decl_im:
+ return doSetExprType (&n->unaryF.resultType, realN);
break;
- }
- /* static analysis guarentees a RETURN statement will be used before here. */
- __builtin_unreachable ();
-}
+ case decl_arrayref:
+ return n->arrayrefF.resultType;
+ break;
-/*
- isBinary - returns TRUE if, n, is an binary node.
-*/
+ case decl_componentref:
+ return n->componentrefF.resultType;
+ break;
-static bool isBinary (decl_node n)
-{
- mcDebug_assert (n != NULL);
- switch (n->kind)
- {
- case decl_cmplx:
- case decl_and:
- case decl_or:
- case decl_equal:
- case decl_notequal:
- case decl_less:
- case decl_greater:
- case decl_greequal:
- case decl_lessequal:
- case decl_val:
- case decl_cast:
- case decl_plus:
- case decl_sub:
- case decl_div:
- case decl_mod:
- case decl_mult:
- case decl_divide:
- case decl_in:
- return true;
+ case decl_pointerref:
+ return n->pointerrefF.resultType;
break;
+ case decl_funccall:
+ return doSetExprType (&n->funccallF.type, doGetFuncType (n));
+ break;
- default:
- return false;
+ case decl_setvalue:
+ return n->setvalueF.type;
break;
+
+
+ default:
+ CaseException ("../../gcc/m2/mc/decl.def", 20, 1);
+ __builtin_unreachable ();
}
- /* static analysis guarentees a RETURN statement will be used before here. */
+ M2RTS_HALT (-1);
+ __builtin_unreachable ();
+ ReturnException ("../../gcc/m2/mc/decl.def", 20, 1);
__builtin_unreachable ();
}
/*
- makeUnary - create a unary expression node with, e, as the argument
- and res as the return type.
+ getExprType - return the expression type.
*/
-static decl_node makeUnary (decl_nodeT k, decl_node e, decl_node res)
+static decl_node__opaque getExprType (decl_node__opaque n)
{
- decl_node n;
+ decl_node__opaque t;
- if (k == decl_plus)
+ if (((isFuncCall (n)) && ((decl_getType (static_cast<decl_node> (n))) != NULL)) && (decl_isProcType (decl_skipType (decl_getType (static_cast<decl_node> (n))))))
{
- return e;
+ return static_cast<decl_node__opaque> (decl_getType (decl_skipType (decl_getType (static_cast<decl_node> (n)))));
}
- else
+ t = static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (n)));
+ if (t == NULL)
{
- n = newNode (k);
- switch (n->kind)
- {
- case decl_min:
- case decl_max:
- case decl_throw:
- case decl_re:
- case decl_im:
- case decl_deref:
- case decl_high:
- case decl_chr:
- case decl_cap:
- case decl_abs:
- case decl_ord:
- case decl_float:
- case decl_trunc:
- case decl_length:
- case decl_constexp:
- case decl_not:
- case decl_neg:
- case decl_adr:
- case decl_size:
- case decl_tsize:
- n->unaryF.arg = e;
- n->unaryF.resultType = res;
- break;
-
-
- default:
- CaseException ("../../gcc/m2/mc/decl.def", 20, 1);
- __builtin_unreachable ();
- }
+ t = doGetExprType (n);
}
- return n;
- /* static analysis guarentees a RETURN statement will be used before here. */
- __builtin_unreachable ();
-}
-
-
-/*
- isLeafString - returns TRUE if n is a leaf node which is a string constant.
-*/
-
-static bool isLeafString (decl_node n)
-{
- return ((isString (n)) || ((decl_isLiteral (n)) && ((decl_getType (n)) == charN))) || ((decl_isConst (n)) && ((getExprType (n)) == charN));
+ return t;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
/*
- getLiteralStringContents - return the contents of a literal node as a string.
+ openOutput -
*/
-static DynamicStrings_String getLiteralStringContents (decl_node n)
+static void openOutput (void)
{
- DynamicStrings_String number;
- DynamicStrings_String content;
DynamicStrings_String s;
- mcDebug_assert (n->kind == decl_literal);
- s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (n->literalF.name));
- content = NULL;
- if (n->literalF.type == charN)
+ s = mcOptions_getOutputFile ();
+ if (DynamicStrings_EqualArray (s, (const char *) "-", 1))
{
- if ((DynamicStrings_char (s, -1)) == 'C')
- {
- if ((DynamicStrings_Length (s)) > 1)
- {
- number = DynamicStrings_Slice (s, 0, -1);
- content = DynamicStrings_InitStringChar ((char ) (StringConvert_ostoc (number)));
- number = DynamicStrings_KillString (number);
- }
- else
- {
- content = DynamicStrings_InitStringChar ('C');
- }
- }
- else
- {
- content = DynamicStrings_Dup (s);
- }
+ outputFile = FIO_StdOut;
}
else
{
- mcMetaError_metaError1 ((const char *) "cannot obtain string contents from {%1k}", 40, (const unsigned char *) &n->literalF.name, (sizeof (n->literalF.name)-1));
+ outputFile = SFIO_OpenToWrite (s);
}
- s = DynamicStrings_KillString (s);
- return content;
- /* static analysis guarentees a RETURN statement will be used before here. */
- __builtin_unreachable ();
+ mcStream_setDest (outputFile);
}
/*
- getStringContents - return the string contents of a constant, literal,
- string or a constexp node.
+ closeOutput -
*/
-static DynamicStrings_String getStringContents (decl_node n)
+static void closeOutput (void)
{
- if (decl_isConst (n))
- {
- return getStringContents (n->constF.value);
- }
- else if (decl_isLiteral (n))
- {
- /* avoid dangling else. */
- return getLiteralStringContents (n);
- }
- else if (isString (n))
- {
- /* avoid dangling else. */
- return getString (n);
- }
- else if (isConstExp (n))
+ DynamicStrings_String s;
+
+ s = mcOptions_getOutputFile ();
+ outputFile = mcStream_combine ();
+ if (! (DynamicStrings_EqualArray (s, (const char *) "-", 1)))
{
- /* avoid dangling else. */
- return getStringContents (n->unaryF.arg);
+ FIO_Close (outputFile);
}
- M2RTS_HALT (-1);
- __builtin_unreachable ();
- ReturnException ("../../gcc/m2/mc/decl.def", 20, 1);
- __builtin_unreachable ();
}
/*
- addNames -
+ write - outputs a single char, ch.
*/
-static nameKey_Name addNames (decl_node a, decl_node b)
+static void write_ (char ch)
{
- DynamicStrings_String sa;
- DynamicStrings_String sb;
- nameKey_Name n;
-
- sa = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (a)));
- sb = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (b)));
- sa = DynamicStrings_ConCat (sa, sb);
- n = nameKey_makekey (DynamicStrings_string (sa));
- sa = DynamicStrings_KillString (sa);
- sb = DynamicStrings_KillString (sb);
- return n;
- /* static analysis guarentees a RETURN statement will be used before here. */
- __builtin_unreachable ();
+ FIO_WriteChar (outputFile, ch);
+ FIO_FlushBuffer (outputFile);
}
/*
- resolveString -
+ writeln -
*/
-static decl_node resolveString (decl_node n)
+static void writeln (void)
{
- while ((decl_isConst (n)) || (isConstExp (n)))
- {
- if (decl_isConst (n))
- {
- n = n->constF.value;
- }
- else
- {
- n = n->unaryF.arg;
- }
- }
- if (n->kind == decl_plus)
- {
- n = decl_makeString (addNames (resolveString (n->binaryF.left), resolveString (n->binaryF.right)));
- }
- return n;
- /* static analysis guarentees a RETURN statement will be used before here. */
- __builtin_unreachable ();
+ FIO_WriteLine (outputFile);
+ FIO_FlushBuffer (outputFile);
}
/*
- foldBinary -
+ doIncludeC - include header file for definition module, n.
*/
-static decl_node foldBinary (decl_nodeT k, decl_node l, decl_node r, decl_node res)
+static void doIncludeC (decl_node__opaque n)
{
- decl_node n;
- DynamicStrings_String ls;
- DynamicStrings_String rs;
+ DynamicStrings_String s;
- n = NULL;
- if (((k == decl_plus) && (isLeafString (l))) && (isLeafString (r)))
+ s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (static_cast<decl_node> (n))));
+ if (mcOptions_getExtendedOpaque ())
+ {} /* empty. */
+ /* no include in this case. */
+ else if (decl_isDef (static_cast<decl_node> (n)))
{
- ls = getStringContents (l);
- rs = getStringContents (r);
- ls = DynamicStrings_Add (ls, rs);
- n = decl_makeString (nameKey_makekey (DynamicStrings_string (ls)));
- ls = DynamicStrings_KillString (ls);
- rs = DynamicStrings_KillString (rs);
+ /* avoid dangling else. */
+ mcPretty_print (doP, (const char *) "# include \"", 13);
+ mcPretty_prints (doP, mcOptions_getHPrefix ());
+ mcPretty_prints (doP, s);
+ mcPretty_print (doP, (const char *) ".h\"\\n", 5);
+ symbolKey_foreachNodeDo (n->defF.decls.symbols, (symbolKey_performOperation) {(symbolKey_performOperation_t) addDoneDef});
}
- return n;
- /* static analysis guarentees a RETURN statement will be used before here. */
- __builtin_unreachable ();
+ s = DynamicStrings_KillString (s);
}
/*
- makeBinary - create a binary node with left/right/result type: l, r and resultType.
+ getSymScope - returns the scope where node, n, was declared.
*/
-static decl_node makeBinary (decl_nodeT k, decl_node l, decl_node r, decl_node resultType)
+static decl_node__opaque getSymScope (decl_node__opaque n)
{
- decl_node n;
-
- n = foldBinary (k, l, r, resultType);
- if (n == NULL)
+ switch (n->kind)
{
- n = doMakeBinary (k, l, r, resultType);
+ case decl_const:
+ return n->constF.scope;
+ break;
+
+ case decl_type:
+ return n->typeF.scope;
+ break;
+
+ case decl_var:
+ return n->varF.scope;
+ break;
+
+ case decl_procedure:
+ return n->procedureF.scope;
+ break;
+
+
+ default:
+ CaseException ("../../gcc/m2/mc/decl.def", 20, 1);
+ __builtin_unreachable ();
}
- return n;
- /* static analysis guarentees a RETURN statement will be used before here. */
+ M2RTS_HALT (-1);
+ __builtin_unreachable ();
+ ReturnException ("../../gcc/m2/mc/decl.def", 20, 1);
__builtin_unreachable ();
}
/*
- doMakeBinary - returns a binary node containing left/right/result values
- l, r, res, with a node operator, k.
+ isQualifiedForced - should the node be written with a module prefix?
*/
-static decl_node doMakeBinary (decl_nodeT k, decl_node l, decl_node r, decl_node res)
+static bool isQualifiedForced (decl_node__opaque n)
{
- decl_node n;
-
- n = newNode (k);
- switch (n->kind)
- {
- case decl_cmplx:
- case decl_equal:
- case decl_notequal:
- case decl_less:
- case decl_greater:
- case decl_greequal:
- case decl_lessequal:
- case decl_and:
- case decl_or:
- case decl_cast:
- case decl_val:
- case decl_plus:
- case decl_sub:
- case decl_div:
- case decl_mod:
- case decl_mult:
- case decl_divide:
- case decl_in:
- n->binaryF.left = l;
- n->binaryF.right = r;
- n->binaryF.resultType = res;
- break;
+ return forceQualified && (((((decl_isType (static_cast<decl_node> (n))) || (decl_isRecord (static_cast<decl_node> (n)))) || (decl_isArray (static_cast<decl_node> (n)))) || (decl_isEnumeration (static_cast<decl_node> (n)))) || (decl_isEnumerationField (static_cast<decl_node> (n))));
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
+}
- default:
- CaseException ("../../gcc/m2/mc/decl.def", 20, 1);
- __builtin_unreachable ();
+/*
+ getFQstring -
+*/
+
+static DynamicStrings_String getFQstring (decl_node__opaque n)
+{
+ DynamicStrings_String i;
+ DynamicStrings_String s;
+
+ if ((decl_getScope (static_cast<decl_node> (n))) == NULL)
+ {
+ return DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (static_cast<decl_node> (n))));
+ }
+ else if (isQualifiedForced (n))
+ {
+ /* avoid dangling else. */
+ i = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (static_cast<decl_node> (n))));
+ s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (decl_getScope (static_cast<decl_node> (n)))));
+ return FormatStrings_Sprintf2 (DynamicStrings_InitString ((const char *) "%s_%s", 5), (const unsigned char *) &s, (sizeof (s)-1), (const unsigned char *) &i, (sizeof (i)-1));
+ }
+ else if ((! (decl_isExported (static_cast<decl_node> (n)))) || (mcOptions_getIgnoreFQ ()))
+ {
+ /* avoid dangling else. */
+ return DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (static_cast<decl_node> (n))));
+ }
+ else
+ {
+ /* avoid dangling else. */
+ i = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (static_cast<decl_node> (n))));
+ s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (decl_getScope (static_cast<decl_node> (n)))));
+ return FormatStrings_Sprintf2 (DynamicStrings_InitString ((const char *) "%s_%s", 5), (const unsigned char *) &s, (sizeof (s)-1), (const unsigned char *) &i, (sizeof (i)-1));
}
- return n;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
/*
- doMakeComponentRef -
+ getFQDstring -
*/
-static decl_node doMakeComponentRef (decl_node rec, decl_node field)
+static DynamicStrings_String getFQDstring (decl_node__opaque n, bool scopes)
{
- decl_node n;
+ DynamicStrings_String i;
+ DynamicStrings_String s;
- n = newNode (decl_componentref);
- n->componentrefF.rec = rec;
- n->componentrefF.field = field;
- n->componentrefF.resultType = decl_getType (field);
- return n;
+ if ((decl_getScope (static_cast<decl_node> (n))) == NULL)
+ {
+ return DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (getDName (n, scopes)));
+ }
+ else if (isQualifiedForced (n))
+ {
+ /* avoid dangling else. */
+ /* we assume a qualified name will never conflict. */
+ i = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (static_cast<decl_node> (n))));
+ s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (decl_getScope (static_cast<decl_node> (n)))));
+ return FormatStrings_Sprintf2 (DynamicStrings_InitString ((const char *) "%s_%s", 5), (const unsigned char *) &s, (sizeof (s)-1), (const unsigned char *) &i, (sizeof (i)-1));
+ }
+ else if ((! (decl_isExported (static_cast<decl_node> (n)))) || (mcOptions_getIgnoreFQ ()))
+ {
+ /* avoid dangling else. */
+ return DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (getDName (n, scopes)));
+ }
+ else
+ {
+ /* avoid dangling else. */
+ /* we assume a qualified name will never conflict. */
+ i = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (static_cast<decl_node> (n))));
+ s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (decl_getScope (static_cast<decl_node> (n)))));
+ return FormatStrings_Sprintf2 (DynamicStrings_InitString ((const char *) "%s_%s", 5), (const unsigned char *) &s, (sizeof (s)-1), (const unsigned char *) &i, (sizeof (i)-1));
+ }
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
/*
- isComponentRef -
+ getString - returns the name as a string.
*/
-static bool isComponentRef (decl_node n)
+static DynamicStrings_String getString (decl_node__opaque n)
{
- mcDebug_assert (n != NULL);
- return n->kind == decl_componentref;
+ if ((decl_getSymName (static_cast<decl_node> (n))) == nameKey_NulName)
+ {
+ return DynamicStrings_InitString ((const char *) "", 0);
+ }
+ else
+ {
+ return DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (static_cast<decl_node> (n))));
+ }
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
/*
- isArrayRef - returns TRUE if the node was an arrayref.
+ doNone - call HALT.
*/
-static bool isArrayRef (decl_node n)
+static void doNone (decl_node__opaque n)
{
- mcDebug_assert (n != NULL);
- return n->kind == decl_arrayref;
- /* static analysis guarentees a RETURN statement will be used before here. */
+ M2RTS_HALT (-1);
__builtin_unreachable ();
}
/*
- isDeref - returns TRUE if, n, is a deref node.
+ doNothing - does nothing!
*/
-static bool isDeref (decl_node n)
+static void doNothing (decl_node__opaque n)
{
- mcDebug_assert (n != NULL);
- return n->kind == decl_deref;
- /* static analysis guarentees a RETURN statement will be used before here. */
- __builtin_unreachable ();
}
/*
- makeBase - create a base type or constant.
- It only supports the base types and constants
- enumerated below.
+ doConstC -
*/
-static decl_node makeBase (decl_nodeT k)
+static void doConstC (decl_node__opaque n)
{
- decl_node n;
+ if (! (alists_isItemInList (globalGroup->doneQ, reinterpret_cast<void *> (n))))
+ {
+ mcPretty_print (doP, (const char *) "# define ", 11);
+ doFQNameC (doP, n);
+ mcPretty_setNeedSpace (doP);
+ doExprC (doP, n->constF.value);
+ mcPretty_print (doP, (const char *) "\\n", 2);
+ alists_includeItemIntoList (globalGroup->doneQ, reinterpret_cast<void *> (n));
+ }
+}
- n = newNode (k);
- switch (k)
+
+/*
+ needsParen - returns TRUE if expression, n, needs to be enclosed in ().
+*/
+
+static bool needsParen (decl_node__opaque n)
+{
+ mcDebug_assert (n != NULL);
+ switch (n->kind)
{
- case decl_new:
- case decl_dispose:
- case decl_length:
- case decl_inc:
- case decl_dec:
- case decl_incl:
- case decl_excl:
case decl_nil:
case decl_true:
case decl_false:
- case decl_address:
- case decl_loc:
- case decl_byte:
- case decl_word:
- case decl_csizet:
- case decl_cssizet:
- case decl_char:
- case decl_cardinal:
- case decl_longcard:
- case decl_shortcard:
- case decl_integer:
- case decl_longint:
- case decl_shortint:
- case decl_real:
- case decl_longreal:
- case decl_shortreal:
- case decl_bitset:
- case decl_boolean:
- case decl_proc:
- case decl_ztype:
- case decl_rtype:
- case decl_complex:
- case decl_longcomplex:
- case decl_shortcomplex:
+ return false;
+ break;
+
+ case decl_constexp:
+ return needsParen (n->unaryF.arg);
+ break;
+
+ case decl_neg:
+ return needsParen (n->unaryF.arg);
+ break;
+
+ case decl_not:
+ return needsParen (n->unaryF.arg);
+ break;
+
case decl_adr:
- case decl_chr:
- case decl_cap:
- case decl_abs:
+ case decl_size:
+ case decl_tsize:
+ case decl_ord:
case decl_float:
case decl_trunc:
- case decl_ord:
+ case decl_chr:
+ case decl_cap:
case decl_high:
- case decl_throw:
- case decl_re:
- case decl_im:
- case decl_cmplx:
- case decl_size:
- case decl_tsize:
+ return false;
+ break;
+
+ case decl_deref:
+ return false;
+ break;
+
+ case decl_equal:
+ case decl_notequal:
+ case decl_less:
+ case decl_greater:
+ case decl_greequal:
+ case decl_lessequal:
+ return true;
+ break;
+
+ case decl_componentref:
+ return false;
+ break;
+
+ case decl_pointerref:
+ return false;
+ break;
+
+ case decl_cast:
+ return true;
+ break;
+
case decl_val:
- case decl_min:
+ return true;
+ break;
+
+ case decl_abs:
+ return false;
+ break;
+
+ case decl_plus:
+ case decl_sub:
+ case decl_div:
+ case decl_mod:
+ case decl_mult:
+ case decl_divide:
+ case decl_in:
+ return true;
+ break;
+
+ case decl_literal:
+ case decl_const:
+ case decl_enumerationfield:
+ case decl_string:
+ return false;
+ break;
+
case decl_max:
+ return true;
break;
+ case decl_min:
+ return true;
+ break;
- default:
- M2RTS_HALT (-1); /* legal kind. */
- __builtin_unreachable ();
+ case decl_var:
+ return false;
break;
- }
- return n;
- /* static analysis guarentees a RETURN statement will be used before here. */
- __builtin_unreachable ();
-}
+ case decl_arrayref:
+ return false;
+ break;
-/*
- isOrdinal - returns TRUE if, n, is an ordinal type.
-*/
+ case decl_and:
+ case decl_or:
+ return true;
+ break;
+
+ case decl_funccall:
+ return true;
+ break;
+
+ case decl_recordfield:
+ return false;
+ break;
-static bool isOrdinal (decl_node n)
-{
- switch (n->kind)
- {
- case decl_address:
case decl_loc:
case decl_byte:
case decl_word:
- case decl_csizet:
- case decl_cssizet:
- case decl_char:
- case decl_integer:
- case decl_longint:
- case decl_shortint:
+ case decl_type:
+ case decl_char:
case decl_cardinal:
case decl_longcard:
case decl_shortcard:
+ case decl_integer:
+ case decl_longint:
+ case decl_shortint:
+ case decl_real:
+ case decl_longreal:
+ case decl_shortreal:
+ case decl_complex:
+ case decl_longcomplex:
+ case decl_shortcomplex:
case decl_bitset:
- return true;
+ case decl_boolean:
+ case decl_proc:
+ return false;
+ break;
+
+ case decl_setvalue:
+ return false;
break;
+ case decl_address:
+ return true;
+ break;
- default:
+ case decl_procedure:
return false;
break;
- }
- /* static analysis guarentees a RETURN statement will be used before here. */
- __builtin_unreachable ();
-}
+ case decl_length:
+ case decl_cmplx:
+ case decl_re:
+ case decl_im:
+ return true;
+ break;
-/*
- mixTypes -
-*/
-static decl_node mixTypes (decl_node a, decl_node b)
-{
- if ((a == addressN) || (b == addressN))
- {
- return addressN;
+ default:
+ CaseException ("../../gcc/m2/mc/decl.def", 20, 1);
+ __builtin_unreachable ();
}
- return a;
+ return true;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
/*
- doSetExprType -
+ doUnary -
*/
-static decl_node doSetExprType (decl_node *t, decl_node n)
+static void doUnary (mcPretty_pretty p, const char *op_, unsigned int _op_high, decl_node__opaque expr, decl_node__opaque type, bool l, bool r)
{
- if ((*t) == NULL)
+ char op[_op_high+1];
+
+ /* make a local copy of each unbounded array. */
+ memcpy (op, op_, _op_high+1);
+
+ if (l)
{
- (*t) = n;
+ mcPretty_setNeedSpace (p);
+ }
+ mcPretty_print (p, (const char *) op, _op_high);
+ if (r)
+ {
+ mcPretty_setNeedSpace (p);
+ }
+ if (needsParen (expr))
+ {
+ outText (p, (const char *) "(", 1);
+ doExprC (p, expr);
+ outText (p, (const char *) ")", 1);
+ }
+ else
+ {
+ doExprC (p, expr);
}
- return (*t);
- /* static analysis guarentees a RETURN statement will be used before here. */
- __builtin_unreachable ();
}
/*
- getMaxMinType -
+ doSetSub - perform l & (~ r)
*/
-static decl_node getMaxMinType (decl_node n)
+static void doSetSub (mcPretty_pretty p, decl_node__opaque left, decl_node__opaque right)
{
- if ((decl_isVar (n)) || (decl_isConst (n)))
+ if (needsParen (left))
{
- return decl_getType (n);
+ outText (p, (const char *) "(", 1);
+ doExprC (p, left);
+ outText (p, (const char *) ")", 1);
}
- else if (isConstExp (n))
+ else
{
- /* avoid dangling else. */
- n = getExprType (n->unaryF.arg);
- if (n == bitsetN)
- {
- return ztypeN;
- }
- else
- {
- return n;
- }
+ doExprC (p, left);
+ }
+ mcPretty_setNeedSpace (p);
+ outText (p, (const char *) "&", 1);
+ mcPretty_setNeedSpace (p);
+ if (needsParen (right))
+ {
+ outText (p, (const char *) "(~(", 3);
+ doExprC (p, right);
+ outText (p, (const char *) "))", 2);
}
else
{
- /* avoid dangling else. */
- return n;
+ outText (p, (const char *) "(~", 2);
+ doExprC (p, right);
+ outText (p, (const char *) ")", 1);
}
- /* static analysis guarentees a RETURN statement will be used before here. */
- __builtin_unreachable ();
}
/*
- doGetFuncType -
+ doPolyBinary -
*/
-static decl_node doGetFuncType (decl_node n)
+static void doPolyBinary (mcPretty_pretty p, decl_nodeT op, decl_node__opaque left, decl_node__opaque right, bool l, bool r)
{
- mcDebug_assert (isFuncCall (n));
- return doSetExprType (&n->funccallF.type, decl_getType (n->funccallF.function));
- /* static analysis guarentees a RETURN statement will be used before here. */
- __builtin_unreachable ();
-}
-
-
-/*
- doGetExprType - works out the type which is associated with node, n.
-*/
+ decl_node__opaque lt;
+ decl_node__opaque rt;
-static decl_node doGetExprType (decl_node n)
-{
- switch (n->kind)
+ lt = static_cast<decl_node__opaque> (decl_skipType (static_cast<decl_node> (getExprType (left))));
+ rt = static_cast<decl_node__opaque> (decl_skipType (static_cast<decl_node> (getExprType (right))));
+ if (((lt != NULL) && ((decl_isSet (static_cast<decl_node> (lt))) || (isBitset (lt)))) || ((rt != NULL) && ((decl_isSet (static_cast<decl_node> (rt))) || (isBitset (rt)))))
{
- case decl_max:
- case decl_min:
- return getMaxMinType (n->unaryF.arg);
- break;
-
- case decl_cast:
- case decl_val:
- return doSetExprType (&n->binaryF.resultType, n->binaryF.left);
- break;
+ switch (op)
+ {
+ case decl_plus:
+ doBinary (p, (const char *) "|", 1, left, right, l, r, false);
+ break;
- case decl_halt:
- case decl_new:
- case decl_dispose:
- return NULL;
- break;
+ case decl_sub:
+ doSetSub (p, left, right);
+ break;
- case decl_inc:
- case decl_dec:
- case decl_incl:
- case decl_excl:
- return NULL;
- break;
+ case decl_mult:
+ doBinary (p, (const char *) "&", 1, left, right, l, r, false);
+ break;
- case decl_nil:
- return addressN;
- break;
+ case decl_divide:
+ doBinary (p, (const char *) "^", 1, left, right, l, r, false);
+ break;
- case decl_true:
- case decl_false:
- return booleanN;
- break;
- case decl_address:
- return n;
- break;
+ default:
+ CaseException ("../../gcc/m2/mc/decl.def", 20, 1);
+ __builtin_unreachable ();
+ }
+ }
+ else
+ {
+ switch (op)
+ {
+ case decl_plus:
+ doBinary (p, (const char *) "+", 1, left, right, l, r, false);
+ break;
- case decl_loc:
- return n;
- break;
+ case decl_sub:
+ doBinary (p, (const char *) "-", 1, left, right, l, r, false);
+ break;
- case decl_byte:
- return n;
- break;
+ case decl_mult:
+ doBinary (p, (const char *) "*", 1, left, right, l, r, false);
+ break;
- case decl_word:
- return n;
- break;
+ case decl_divide:
+ doBinary (p, (const char *) "/", 1, left, right, l, r, false);
+ break;
- case decl_csizet:
- return n;
- break;
- case decl_cssizet:
- return n;
- break;
+ default:
+ CaseException ("../../gcc/m2/mc/decl.def", 20, 1);
+ __builtin_unreachable ();
+ }
+ }
+}
- case decl_boolean:
- /* base types. */
- return n;
- break;
- case decl_proc:
- return n;
- break;
+/*
+ doBinary -
+*/
- case decl_char:
- return n;
- break;
+static void doBinary (mcPretty_pretty p, const char *op_, unsigned int _op_high, decl_node__opaque left, decl_node__opaque right, bool l, bool r, bool unpackProc)
+{
+ char op[_op_high+1];
- case decl_cardinal:
- return n;
- break;
+ /* make a local copy of each unbounded array. */
+ memcpy (op, op_, _op_high+1);
- case decl_longcard:
- return n;
- break;
+ if (needsParen (left))
+ {
+ outText (p, (const char *) "(", 1);
+ left = doExprCup (p, left, unpackProc, false);
+ outText (p, (const char *) ")", 1);
+ }
+ else
+ {
+ left = doExprCup (p, left, unpackProc, false);
+ }
+ if (l)
+ {
+ mcPretty_setNeedSpace (p);
+ }
+ outText (p, (const char *) op, _op_high);
+ if (r)
+ {
+ mcPretty_setNeedSpace (p);
+ }
+ if (needsParen (right))
+ {
+ outText (p, (const char *) "(", 1);
+ right = doExprCup (p, right, unpackProc, false);
+ outText (p, (const char *) ")", 1);
+ }
+ else
+ {
+ right = doExprCup (p, right, unpackProc, false);
+ }
+}
- case decl_shortcard:
- return n;
- break;
- case decl_integer:
- return n;
- break;
+/*
+ doPostUnary -
+*/
- case decl_longint:
- return n;
- break;
+static void doPostUnary (mcPretty_pretty p, const char *op_, unsigned int _op_high, decl_node__opaque expr)
+{
+ char op[_op_high+1];
- case decl_shortint:
- return n;
- break;
+ /* make a local copy of each unbounded array. */
+ memcpy (op, op_, _op_high+1);
- case decl_real:
- return n;
- break;
+ doExprC (p, expr);
+ outText (p, (const char *) op, _op_high);
+}
- case decl_longreal:
- return n;
- break;
- case decl_shortreal:
- return n;
- break;
+/*
+ doDeRefC -
+*/
- case decl_bitset:
- return n;
- break;
+static decl_node__opaque doDeRefC (mcPretty_pretty p, decl_node__opaque expr)
+{
+ outText (p, (const char *) "(*", 2);
+ expr = castOpaque (p, expr, false);
+ outText (p, (const char *) ")", 1);
+ return expr;
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
+}
- case decl_ztype:
- return n;
- break;
- case decl_rtype:
- return n;
- break;
+/*
+ doGetLastOp - returns, a, if b is a terminal otherwise walk right.
+*/
- case decl_complex:
- return n;
+static decl_node__opaque doGetLastOp (decl_node__opaque a, decl_node__opaque b)
+{
+ switch (b->kind)
+ {
+ case decl_nil:
+ return a;
break;
- case decl_longcomplex:
- return n;
+ case decl_true:
+ return a;
break;
- case decl_shortcomplex:
- return n;
+ case decl_false:
+ return a;
break;
- case decl_type:
- /* language features and compound type attributes. */
- return n->typeF.type;
+ case decl_constexp:
+ return doGetLastOp (b, b->unaryF.arg);
break;
- case decl_record:
- return n;
+ case decl_neg:
+ return doGetLastOp (b, b->unaryF.arg);
break;
- case decl_varient:
- return n;
+ case decl_not:
+ return doGetLastOp (b, b->unaryF.arg);
break;
- case decl_var:
- return n->varF.type;
+ case decl_adr:
+ return doGetLastOp (b, b->unaryF.arg);
break;
- case decl_enumeration:
- return n;
+ case decl_size:
+ return doGetLastOp (b, b->unaryF.arg);
break;
- case decl_subrange:
- return n->subrangeF.type;
+ case decl_tsize:
+ return doGetLastOp (b, b->unaryF.arg);
break;
- case decl_array:
- return n->arrayF.type;
+ case decl_ord:
+ return doGetLastOp (b, b->unaryF.arg);
break;
- case decl_string:
- return charN;
+ case decl_float:
+ case decl_trunc:
+ return doGetLastOp (b, b->unaryF.arg);
break;
- case decl_const:
- return doSetExprType (&n->constF.type, getExprType (n->constF.value));
+ case decl_chr:
+ return doGetLastOp (b, b->unaryF.arg);
break;
- case decl_literal:
- return n->literalF.type;
+ case decl_cap:
+ return doGetLastOp (b, b->unaryF.arg);
break;
- case decl_varparam:
- return n->varparamF.type;
+ case decl_high:
+ return doGetLastOp (b, b->unaryF.arg);
break;
- case decl_param:
- return n->paramF.type;
+ case decl_deref:
+ return doGetLastOp (b, b->unaryF.arg);
break;
- case decl_optarg:
- return n->optargF.type;
+ case decl_re:
+ case decl_im:
+ return doGetLastOp (b, b->unaryF.arg);
break;
- case decl_pointer:
- return n->pointerF.type;
+ case decl_equal:
+ return doGetLastOp (b, b->binaryF.right);
break;
- case decl_recordfield:
- return n->recordfieldF.type;
+ case decl_notequal:
+ return doGetLastOp (b, b->binaryF.right);
break;
- case decl_varientfield:
- return n;
+ case decl_less:
+ return doGetLastOp (b, b->binaryF.right);
break;
- case decl_enumerationfield:
- return n->enumerationfieldF.type;
+ case decl_greater:
+ return doGetLastOp (b, b->binaryF.right);
break;
- case decl_set:
- return n->setF.type;
+ case decl_greequal:
+ return doGetLastOp (b, b->binaryF.right);
break;
- case decl_proctype:
- return n->proctypeF.returnType;
+ case decl_lessequal:
+ return doGetLastOp (b, b->binaryF.right);
break;
- case decl_subscript:
- return n->subscriptF.type;
+ case decl_componentref:
+ return doGetLastOp (b, b->componentrefF.field);
break;
- case decl_procedure:
- /* blocks. */
- return n->procedureF.returnType;
+ case decl_pointerref:
+ return doGetLastOp (b, b->pointerrefF.field);
break;
- case decl_throw:
- return NULL;
+ case decl_cast:
+ return doGetLastOp (b, b->binaryF.right);
break;
- case decl_unreachable:
- return NULL;
+ case decl_val:
+ return doGetLastOp (b, b->binaryF.right);
break;
- case decl_def:
- case decl_imp:
- case decl_module:
- case decl_loop:
- case decl_while:
- case decl_for:
- case decl_repeat:
- case decl_if:
- case decl_elsif:
- case decl_assignment:
- /* statements. */
- M2RTS_HALT (-1);
- __builtin_unreachable ();
+ case decl_plus:
+ return doGetLastOp (b, b->binaryF.right);
break;
- case decl_plus:
case decl_sub:
- case decl_div:
- case decl_mod:
- case decl_mult:
- case decl_divide:
- /* expressions. */
- return doSetExprType (&n->binaryF.resultType, mixTypes (getExprType (n->binaryF.left), getExprType (n->binaryF.right)));
+ return doGetLastOp (b, b->binaryF.right);
break;
- case decl_in:
- case decl_and:
- case decl_or:
- case decl_equal:
- case decl_notequal:
- case decl_less:
- case decl_greater:
- case decl_greequal:
- case decl_lessequal:
- return doSetExprType (&n->binaryF.resultType, booleanN);
+ case decl_div:
+ return doGetLastOp (b, b->binaryF.right);
break;
- case decl_cmplx:
- return doSetExprType (&n->binaryF.resultType, complexN);
+ case decl_mod:
+ return doGetLastOp (b, b->binaryF.right);
break;
- case decl_abs:
- case decl_constexp:
- case decl_deref:
- case decl_neg:
- return doSetExprType (&n->unaryF.resultType, getExprType (n->unaryF.arg));
+ case decl_mult:
+ return doGetLastOp (b, b->binaryF.right);
break;
- case decl_adr:
- return doSetExprType (&n->unaryF.resultType, addressN);
+ case decl_divide:
+ return doGetLastOp (b, b->binaryF.right);
break;
- case decl_size:
- case decl_tsize:
- return doSetExprType (&n->unaryF.resultType, cardinalN);
+ case decl_in:
+ return doGetLastOp (b, b->binaryF.right);
break;
- case decl_high:
- case decl_ord:
- return doSetExprType (&n->unaryF.resultType, cardinalN);
+ case decl_and:
+ return doGetLastOp (b, b->binaryF.right);
break;
- case decl_float:
- return doSetExprType (&n->unaryF.resultType, realN);
+ case decl_or:
+ return doGetLastOp (b, b->binaryF.right);
break;
- case decl_trunc:
- return doSetExprType (&n->unaryF.resultType, integerN);
+ case decl_cmplx:
+ return doGetLastOp (b, b->binaryF.right);
break;
- case decl_chr:
- return doSetExprType (&n->unaryF.resultType, charN);
+ case decl_literal:
+ return a;
break;
- case decl_cap:
- return doSetExprType (&n->unaryF.resultType, charN);
+ case decl_const:
+ return a;
break;
- case decl_not:
- return doSetExprType (&n->unaryF.resultType, booleanN);
+ case decl_enumerationfield:
+ return a;
break;
- case decl_re:
- return doSetExprType (&n->unaryF.resultType, realN);
+ case decl_string:
+ return a;
break;
- case decl_im:
- return doSetExprType (&n->unaryF.resultType, realN);
+ case decl_max:
+ return doGetLastOp (b, b->unaryF.arg);
break;
- case decl_arrayref:
- return n->arrayrefF.resultType;
+ case decl_min:
+ return doGetLastOp (b, b->unaryF.arg);
break;
- case decl_componentref:
- return n->componentrefF.resultType;
+ case decl_var:
+ return a;
break;
- case decl_pointerref:
- return n->pointerrefF.resultType;
+ case decl_arrayref:
+ return a;
break;
case decl_funccall:
- return doSetExprType (&n->funccallF.type, doGetFuncType (n));
+ return a;
break;
- case decl_setvalue:
- return n->setvalueF.type;
+ case decl_procedure:
+ return a;
+ break;
+
+ case decl_recordfield:
+ return a;
break;
CaseException ("../../gcc/m2/mc/decl.def", 20, 1);
__builtin_unreachable ();
}
- M2RTS_HALT (-1);
- __builtin_unreachable ();
- ReturnException ("../../gcc/m2/mc/decl.def", 20, 1);
+ /* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
/*
- getExprType - return the expression type.
+ doComponentRefC -
+*/
+
+static void doComponentRefC (mcPretty_pretty p, decl_node__opaque l, decl_node__opaque r)
+{
+ flushOpaque (p, l, false);
+ outText (p, (const char *) ".", 1);
+ doExprC (p, r);
+}
+
+
+/*
+ doPointerRefC -
+*/
+
+static void doPointerRefC (mcPretty_pretty p, decl_node__opaque l, decl_node__opaque r)
+{
+ flushOpaque (p, l, false);
+ outText (p, (const char *) "->", 2);
+ doExprC (p, r);
+}
+
+
+/*
+ doPreBinary -
*/
-static decl_node getExprType (decl_node n)
+static void doPreBinary (mcPretty_pretty p, const char *op_, unsigned int _op_high, decl_node__opaque left, decl_node__opaque right, bool l, bool r)
{
- decl_node t;
+ char op[_op_high+1];
+
+ /* make a local copy of each unbounded array. */
+ memcpy (op, op_, _op_high+1);
- if (((isFuncCall (n)) && ((decl_getType (n)) != NULL)) && (decl_isProcType (decl_skipType (decl_getType (n)))))
+ if (l)
{
- return decl_getType (decl_skipType (decl_getType (n)));
+ mcPretty_setNeedSpace (p);
}
- t = decl_getType (n);
- if (t == NULL)
+ outText (p, (const char *) op, _op_high);
+ if (r)
{
- t = doGetExprType (n);
+ mcPretty_setNeedSpace (p);
}
- return t;
- /* static analysis guarentees a RETURN statement will be used before here. */
- __builtin_unreachable ();
+ outText (p, (const char *) "(", 1);
+ doExprC (p, left);
+ outText (p, (const char *) ",", 1);
+ mcPretty_setNeedSpace (p);
+ doExprC (p, right);
+ outText (p, (const char *) ")", 1);
}
/*
- openOutput -
+ doConstExpr -
*/
-static void openOutput (void)
+static void doConstExpr (mcPretty_pretty p, decl_node__opaque n)
{
- DynamicStrings_String s;
+ doFQNameC (p, n);
+}
- s = mcOptions_getOutputFile ();
- if (DynamicStrings_EqualArray (s, (const char *) "-", 1))
- {
- outputFile = FIO_StdOut;
- }
- else
+
+/*
+ doEnumerationField -
+*/
+
+static void doEnumerationField (mcPretty_pretty p, decl_node__opaque n)
+{
+ doFQDNameC (p, n, false);
+}
+
+
+/*
+ isZero - returns TRUE if node, n, is zero.
+*/
+
+static bool isZero (decl_node__opaque n)
+{
+ if (isConstExp (n))
{
- outputFile = SFIO_OpenToWrite (s);
+ return isZero (n->unaryF.arg);
}
- mcStream_setDest (outputFile);
+ return (decl_getSymName (static_cast<decl_node> (n))) == (nameKey_makeKey ((const char *) "0", 1));
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
}
/*
- closeOutput -
+ doArrayRef - perform an array reference. If constCast
+ then an unbounded array access will be const_cast
+ (the constCast should be TRUE if an assignment to
+ the array is required).
*/
-static void closeOutput (void)
+static void doArrayRef (mcPretty_pretty p, decl_node__opaque n, bool constCast)
{
- DynamicStrings_String s;
+ decl_node__opaque type;
+ decl_node__opaque v;
+ unsigned int i;
+ unsigned int c;
- s = mcOptions_getOutputFile ();
- outputFile = mcStream_combine ();
- if (! (DynamicStrings_EqualArray (s, (const char *) "-", 1)))
+ mcDebug_assert (n != NULL);
+ mcDebug_assert (isArrayRef (n));
+ type = static_cast<decl_node__opaque> (decl_skipType (decl_getType (static_cast<decl_node> (n->arrayrefF.array))));
+ if (decl_isUnbounded (static_cast<decl_node> (type)))
{
- FIO_Close (outputFile);
+ v = n->arrayrefF.array;
+ if ((constCast && (decl_isVar (static_cast<decl_node> (n->arrayrefF.array)))) && (v->varF.isParameter || v->varF.isVarParameter))
+ {
+ outText (p, (const char *) "const_cast<", 11);
+ doTypeNameC (p, static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (v))));
+ outText (p, (const char *) ">(", 2);
+ outTextN (p, decl_getSymName (static_cast<decl_node> (n->arrayrefF.array)));
+ outText (p, (const char *) ")", 1);
+ }
+ else
+ {
+ outTextN (p, decl_getSymName (static_cast<decl_node> (n->arrayrefF.array)));
+ }
+ }
+ else
+ {
+ doExprC (p, n->arrayrefF.array);
+ mcDebug_assert (decl_isArray (static_cast<decl_node> (type)));
+ outText (p, (const char *) ".array", 6);
+ }
+ outText (p, (const char *) "[", 1);
+ i = 1;
+ c = expListLen (n->arrayrefF.index);
+ while (i <= c)
+ {
+ doExprC (p, getExpList (n->arrayrefF.index, i));
+ if (decl_isUnbounded (static_cast<decl_node> (type)))
+ {
+ mcDebug_assert (c == 1);
+ }
+ else
+ {
+ doSubtractC (p, getMin (type->arrayF.subr));
+ if (i < c)
+ {
+ mcDebug_assert (decl_isArray (static_cast<decl_node> (type)));
+ outText (p, (const char *) "].array[", 8);
+ type = static_cast<decl_node__opaque> (decl_skipType (decl_getType (static_cast<decl_node> (type))));
+ }
+ }
+ i += 1;
}
+ outText (p, (const char *) "]", 1);
}
/*
- write - outputs a single char, ch.
+ doProcedure -
*/
-static void write_ (char ch)
+static void doProcedure (mcPretty_pretty p, decl_node__opaque n)
{
- FIO_WriteChar (outputFile, ch);
- FIO_FlushBuffer (outputFile);
+ mcDebug_assert (decl_isProcedure (static_cast<decl_node> (n)));
+ doFQDNameC (p, n, true);
}
/*
- writeln -
+ doRecordfield -
*/
-static void writeln (void)
+static void doRecordfield (mcPretty_pretty p, decl_node__opaque n)
{
- FIO_WriteLine (outputFile);
- FIO_FlushBuffer (outputFile);
+ doDNameC (p, n, false);
}
/*
- doIncludeC - include header file for definition module, n.
+ doCastC -
*/
-static void doIncludeC (decl_node n)
+static void doCastC (mcPretty_pretty p, decl_node__opaque t, decl_node__opaque e)
{
- DynamicStrings_String s;
+ decl_node__opaque et;
- s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (n)));
- if (mcOptions_getExtendedOpaque ())
- {} /* empty. */
- /* no include in this case. */
- else if (decl_isDef (n))
+ outText (p, (const char *) "(", 1);
+ doTypeNameC (p, t);
+ outText (p, (const char *) ")", 1);
+ mcPretty_setNeedSpace (p);
+ et = static_cast<decl_node__opaque> (decl_skipType (decl_getType (static_cast<decl_node> (e))));
+ if (((et != NULL) && (isAProcType (et))) && (isAProcType (static_cast<decl_node__opaque> (decl_skipType (static_cast<decl_node> (t))))))
{
- /* avoid dangling else. */
- mcPretty_print (doP, (const char *) "# include \"", 13);
- mcPretty_prints (doP, mcOptions_getHPrefix ());
- mcPretty_prints (doP, s);
- mcPretty_print (doP, (const char *) ".h\"\\n", 5);
- symbolKey_foreachNodeDo (n->defF.decls.symbols, (symbolKey_performOperation) {(symbolKey_performOperation_t) addDoneDef});
+ outText (p, (const char *) "{(", 2);
+ doFQNameC (p, t);
+ outText (p, (const char *) "_t)", 3);
+ mcPretty_setNeedSpace (p);
+ doExprC (p, e);
+ outText (p, (const char *) ".proc}", 6);
+ }
+ else
+ {
+ outText (p, (const char *) "(", 1);
+ doExprC (p, e);
+ outText (p, (const char *) ")", 1);
}
- s = DynamicStrings_KillString (s);
}
/*
- getSymScope - returns the scope where node, n, was declared.
+ doSetValueC -
*/
-static decl_node getSymScope (decl_node n)
+static void doSetValueC (mcPretty_pretty p, decl_node__opaque n)
{
- switch (n->kind)
- {
- case decl_const:
- return n->constF.scope;
- break;
-
- case decl_type:
- return n->typeF.scope;
- break;
-
- case decl_var:
- return n->varF.scope;
- break;
-
- case decl_procedure:
- return n->procedureF.scope;
- break;
-
+ decl_node__opaque lo;
+ unsigned int i;
+ unsigned int h;
- default:
- CaseException ("../../gcc/m2/mc/decl.def", 20, 1);
- __builtin_unreachable ();
+ mcDebug_assert (decl_isSetValue (static_cast<decl_node> (n)));
+ lo = getSetLow (n);
+ if (n->setvalueF.type != NULL)
+ {
+ outText (p, (const char *) "(", 1);
+ doTypeNameC (p, n->setvalueF.type);
+ mcPretty_noSpace (p);
+ outText (p, (const char *) ")", 1);
+ mcPretty_setNeedSpace (p);
+ }
+ if ((Indexing_HighIndice (n->setvalueF.values)) == 0)
+ {
+ outText (p, (const char *) "0", 1);
+ }
+ else
+ {
+ i = Indexing_LowIndice (n->setvalueF.values);
+ h = Indexing_HighIndice (n->setvalueF.values);
+ outText (p, (const char *) "(", 1);
+ while (i <= h)
+ {
+ outText (p, (const char *) "(1", 2);
+ mcPretty_setNeedSpace (p);
+ outText (p, (const char *) "<<", 2);
+ mcPretty_setNeedSpace (p);
+ outText (p, (const char *) "(", 1);
+ doExprC (p, static_cast<decl_node__opaque> (Indexing_GetIndice (n->setvalueF.values, i)));
+ doSubtractC (p, lo);
+ outText (p, (const char *) ")", 1);
+ outText (p, (const char *) ")", 1);
+ if (i < h)
+ {
+ mcPretty_setNeedSpace (p);
+ outText (p, (const char *) "|", 1);
+ mcPretty_setNeedSpace (p);
+ }
+ i += 1;
+ }
+ outText (p, (const char *) ")", 1);
}
- M2RTS_HALT (-1);
- __builtin_unreachable ();
- ReturnException ("../../gcc/m2/mc/decl.def", 20, 1);
- __builtin_unreachable ();
}
/*
- isQualifiedForced - should the node be written with a module prefix?
+ getSetLow - returns the low value of the set type from
+ expression, n.
*/
-static bool isQualifiedForced (decl_node n)
+static decl_node__opaque getSetLow (decl_node__opaque n)
{
- return forceQualified && (((((decl_isType (n)) || (decl_isRecord (n))) || (decl_isArray (n))) || (decl_isEnumeration (n))) || (decl_isEnumerationField (n)));
+ decl_node__opaque type;
+
+ if ((decl_getType (static_cast<decl_node> (n))) == NULL)
+ {
+ return static_cast<decl_node__opaque> (decl_makeLiteralInt (nameKey_makeKey ((const char *) "0", 1)));
+ }
+ else
+ {
+ type = static_cast<decl_node__opaque> (decl_skipType (decl_getType (static_cast<decl_node> (n))));
+ if (decl_isSet (static_cast<decl_node> (type)))
+ {
+ return getMin (static_cast<decl_node__opaque> (decl_skipType (decl_getType (static_cast<decl_node> (type)))));
+ }
+ else
+ {
+ return static_cast<decl_node__opaque> (decl_makeLiteralInt (nameKey_makeKey ((const char *) "0", 1)));
+ }
+ }
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
/*
- getFQstring -
+ doInC - performs (((1 << (l)) & (r)) != 0)
*/
-static DynamicStrings_String getFQstring (decl_node n)
+static void doInC (mcPretty_pretty p, decl_node__opaque l, decl_node__opaque r)
{
- DynamicStrings_String i;
- DynamicStrings_String s;
+ decl_node__opaque lo;
- if ((decl_getScope (n)) == NULL)
- {
- return DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (n)));
- }
- else if (isQualifiedForced (n))
- {
- /* avoid dangling else. */
- i = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (n)));
- s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (decl_getScope (n))));
- return FormatStrings_Sprintf2 (DynamicStrings_InitString ((const char *) "%s_%s", 5), (const unsigned char *) &s, (sizeof (s)-1), (const unsigned char *) &i, (sizeof (i)-1));
- }
- else if ((! (decl_isExported (n))) || (mcOptions_getIgnoreFQ ()))
- {
- /* avoid dangling else. */
- return DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (n)));
- }
- else
- {
- /* avoid dangling else. */
- i = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (n)));
- s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (decl_getScope (n))));
- return FormatStrings_Sprintf2 (DynamicStrings_InitString ((const char *) "%s_%s", 5), (const unsigned char *) &s, (sizeof (s)-1), (const unsigned char *) &i, (sizeof (i)-1));
- }
- /* static analysis guarentees a RETURN statement will be used before here. */
- __builtin_unreachable ();
+ lo = getSetLow (r);
+ outText (p, (const char *) "(((1", 4);
+ mcPretty_setNeedSpace (p);
+ outText (p, (const char *) "<<", 2);
+ mcPretty_setNeedSpace (p);
+ outText (p, (const char *) "(", 1);
+ doExprC (p, l);
+ doSubtractC (p, lo);
+ outText (p, (const char *) "))", 2);
+ mcPretty_setNeedSpace (p);
+ outText (p, (const char *) "&", 1);
+ mcPretty_setNeedSpace (p);
+ outText (p, (const char *) "(", 1);
+ doExprC (p, r);
+ outText (p, (const char *) "))", 2);
+ mcPretty_setNeedSpace (p);
+ outText (p, (const char *) "!=", 2);
+ mcPretty_setNeedSpace (p);
+ outText (p, (const char *) "0)", 2);
}
/*
- getFQDstring -
+ doThrowC -
*/
-static DynamicStrings_String getFQDstring (decl_node n, bool scopes)
+static void doThrowC (mcPretty_pretty p, decl_node__opaque n)
{
- DynamicStrings_String i;
- DynamicStrings_String s;
-
- if ((decl_getScope (n)) == NULL)
- {
- return DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (getDName (n, scopes)));
- }
- else if (isQualifiedForced (n))
- {
- /* avoid dangling else. */
- /* we assume a qualified name will never conflict. */
- i = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (n)));
- s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (decl_getScope (n))));
- return FormatStrings_Sprintf2 (DynamicStrings_InitString ((const char *) "%s_%s", 5), (const unsigned char *) &s, (sizeof (s)-1), (const unsigned char *) &i, (sizeof (i)-1));
- }
- else if ((! (decl_isExported (n))) || (mcOptions_getIgnoreFQ ()))
- {
- /* avoid dangling else. */
- return DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (getDName (n, scopes)));
- }
- else
+ mcDebug_assert (isIntrinsic (n));
+ outText (p, (const char *) "throw", 5);
+ mcPretty_setNeedSpace (p);
+ outText (p, (const char *) "(", 1);
+ if ((expListLen (n->intrinsicF.args)) == 1)
{
- /* avoid dangling else. */
- /* we assume a qualified name will never conflict. */
- i = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (n)));
- s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (decl_getScope (n))));
- return FormatStrings_Sprintf2 (DynamicStrings_InitString ((const char *) "%s_%s", 5), (const unsigned char *) &s, (sizeof (s)-1), (const unsigned char *) &i, (sizeof (i)-1));
+ doExprC (p, getExpList (n->intrinsicF.args, 1));
}
- /* static analysis guarentees a RETURN statement will be used before here. */
- __builtin_unreachable ();
+ outText (p, (const char *) ")", 1);
}
/*
- getString - returns the name as a string.
+ doUnreachableC -
*/
-static DynamicStrings_String getString (decl_node n)
+static void doUnreachableC (mcPretty_pretty p, decl_node__opaque n)
{
- if ((decl_getSymName (n)) == nameKey_NulName)
- {
- return DynamicStrings_InitString ((const char *) "", 0);
- }
- else
- {
- return DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (n)));
- }
- /* static analysis guarentees a RETURN statement will be used before here. */
- __builtin_unreachable ();
+ mcDebug_assert (isIntrinsic (n));
+ outText (p, (const char *) "__builtin_unreachable", 21);
+ mcPretty_setNeedSpace (p);
+ outText (p, (const char *) "(", 1);
+ mcDebug_assert ((expListLen (n->intrinsicF.args)) == 0);
+ outText (p, (const char *) ")", 1);
}
/*
- doNone - call HALT.
+ outNull -
*/
-static void doNone (decl_node n)
+static void outNull (mcPretty_pretty p)
{
- M2RTS_HALT (-1);
- __builtin_unreachable ();
+ keyc_useNull ();
+ outText (p, (const char *) "NULL", 4);
}
/*
- doNothing - does nothing!
+ outTrue -
*/
-static void doNothing (decl_node n)
+static void outTrue (mcPretty_pretty p)
{
+ keyc_useTrue ();
+ if ((mcOptions_useBool ()) && (lang == decl_ansiCP))
+ {
+ outText (p, (const char *) "true", 4);
+ }
+ else
+ {
+ outText (p, (const char *) "TRUE", 4);
+ }
}
/*
- doConstC -
+ outFalse -
*/
-static void doConstC (decl_node n)
+static void outFalse (mcPretty_pretty p)
{
- if (! (alists_isItemInList (globalGroup->doneQ, reinterpret_cast<void *> (n))))
+ keyc_useFalse ();
+ if ((mcOptions_useBool ()) && (lang == decl_ansiCP))
{
- mcPretty_print (doP, (const char *) "# define ", 11);
- doFQNameC (doP, n);
- mcPretty_setNeedSpace (doP);
- doExprC (doP, n->constF.value);
- mcPretty_print (doP, (const char *) "\\n", 2);
- alists_includeItemIntoList (globalGroup->doneQ, reinterpret_cast<void *> (n));
+ outText (p, (const char *) "false", 5);
+ }
+ else
+ {
+ outText (p, (const char *) "FALSE", 5);
}
}
/*
- needsParen - returns TRUE if expression, n, needs to be enclosed in ().
+ doExprC -
*/
-static bool needsParen (decl_node n)
+static void doExprC (mcPretty_pretty p, decl_node__opaque n)
{
+ decl_node__opaque t;
+
mcDebug_assert (n != NULL);
+ t = getExprType (n);
switch (n->kind)
{
case decl_nil:
+ outNull (p);
+ break;
+
case decl_true:
+ outTrue (p);
+ break;
+
case decl_false:
- return false;
+ outFalse (p);
break;
case decl_constexp:
- return needsParen (n->unaryF.arg);
+ doUnary (p, (const char *) "", 0, n->unaryF.arg, n->unaryF.resultType, false, false);
break;
case decl_neg:
- return needsParen (n->unaryF.arg);
+ doUnary (p, (const char *) "-", 1, n->unaryF.arg, n->unaryF.resultType, false, false);
break;
case decl_not:
- return needsParen (n->unaryF.arg);
+ doUnary (p, (const char *) "!", 1, n->unaryF.arg, n->unaryF.resultType, false, true);
+ break;
+
+ case decl_val:
+ doValC (p, n);
break;
case decl_adr:
+ doAdrC (p, n);
+ break;
+
case decl_size:
case decl_tsize:
- case decl_ord:
+ doSizeC (p, n);
+ break;
+
case decl_float:
+ doConvertSC (p, n, mcOptions_getCRealType ());
+ break;
+
case decl_trunc:
+ doConvertC (p, n, (const char *) "int", 3);
+ break;
+
+ case decl_ord:
+ doConvertC (p, n, (const char *) "unsigned int", 12);
+ break;
+
case decl_chr:
+ doConvertC (p, n, (const char *) "char", 4);
+ break;
+
case decl_cap:
+ doCapC (p, n);
+ break;
+
+ case decl_abs:
+ doAbsC (p, n);
+ break;
+
case decl_high:
- return false;
+ doFuncHighC (p, n->unaryF.arg);
+ break;
+
+ case decl_length:
+ doLengthC (p, n);
+ break;
+
+ case decl_min:
+ doMinC (p, n);
+ break;
+
+ case decl_max:
+ doMaxC (p, n);
+ break;
+
+ case decl_throw:
+ doThrowC (p, n);
+ break;
+
+ case decl_unreachable:
+ doUnreachableC (p, n);
+ break;
+
+ case decl_re:
+ doReC (p, n);
+ break;
+
+ case decl_im:
+ doImC (p, n);
+ break;
+
+ case decl_cmplx:
+ doCmplx (p, n);
break;
case decl_deref:
- return false;
+ n->unaryF.arg = doDeRefC (p, n->unaryF.arg);
break;
case decl_equal:
+ doBinary (p, (const char *) "==", 2, n->binaryF.left, n->binaryF.right, true, true, true);
+ break;
+
case decl_notequal:
+ doBinary (p, (const char *) "!=", 2, n->binaryF.left, n->binaryF.right, true, true, true);
+ break;
+
case decl_less:
+ doBinary (p, (const char *) "<", 1, n->binaryF.left, n->binaryF.right, true, true, false);
+ break;
+
case decl_greater:
+ doBinary (p, (const char *) ">", 1, n->binaryF.left, n->binaryF.right, true, true, false);
+ break;
+
case decl_greequal:
+ doBinary (p, (const char *) ">=", 2, n->binaryF.left, n->binaryF.right, true, true, false);
+ break;
+
case decl_lessequal:
- return true;
+ doBinary (p, (const char *) "<=", 2, n->binaryF.left, n->binaryF.right, true, true, false);
break;
case decl_componentref:
- return false;
+ doComponentRefC (p, n->componentrefF.rec, n->componentrefF.field);
break;
case decl_pointerref:
- return false;
+ doPointerRefC (p, n->pointerrefF.ptr, n->pointerrefF.field);
+ break;
+
+ case decl_cast:
+ doCastC (p, n->binaryF.left, n->binaryF.right);
+ break;
+
+ case decl_plus:
+ doPolyBinary (p, decl_plus, n->binaryF.left, n->binaryF.right, false, false);
+ break;
+
+ case decl_sub:
+ doPolyBinary (p, decl_sub, n->binaryF.left, n->binaryF.right, false, false);
+ break;
+
+ case decl_div:
+ doBinary (p, (const char *) "/", 1, n->binaryF.left, n->binaryF.right, true, true, false);
+ break;
+
+ case decl_mod:
+ doBinary (p, (const char *) "%", 1, n->binaryF.left, n->binaryF.right, true, true, false);
+ break;
+
+ case decl_mult:
+ doPolyBinary (p, decl_mult, n->binaryF.left, n->binaryF.right, false, false);
+ break;
+
+ case decl_divide:
+ doPolyBinary (p, decl_divide, n->binaryF.left, n->binaryF.right, false, false);
break;
- case decl_cast:
- return true;
+ case decl_in:
+ doInC (p, n->binaryF.left, n->binaryF.right);
break;
- case decl_val:
- return true;
+ case decl_and:
+ doBinary (p, (const char *) "&&", 2, n->binaryF.left, n->binaryF.right, true, true, false);
break;
- case decl_abs:
- return false;
+ case decl_or:
+ doBinary (p, (const char *) "||", 2, n->binaryF.left, n->binaryF.right, true, true, false);
break;
- case decl_plus:
- case decl_sub:
- case decl_div:
- case decl_mod:
- case decl_mult:
- case decl_divide:
- case decl_in:
- return true;
+ case decl_literal:
+ doLiteralC (p, n);
break;
- case decl_literal:
case decl_const:
- case decl_enumerationfield:
- case decl_string:
- return false;
+ doConstExpr (p, n);
break;
- case decl_max:
- return true;
+ case decl_enumerationfield:
+ doEnumerationField (p, n);
break;
- case decl_min:
- return true;
+ case decl_string:
+ doStringC (p, n);
break;
case decl_var:
- return false;
+ doVar (p, n);
break;
case decl_arrayref:
- return false;
+ doArrayRef (p, n, false);
break;
- case decl_and:
- case decl_or:
- return true;
+ case decl_funccall:
+ doFuncExprC (p, n);
break;
- case decl_funccall:
- return true;
+ case decl_procedure:
+ doProcedure (p, n);
break;
case decl_recordfield:
- return false;
+ doRecordfield (p, n);
+ break;
+
+ case decl_setvalue:
+ doSetValueC (p, n);
break;
- case decl_loc:
- case decl_byte:
- case decl_word:
- case decl_type:
case decl_char:
case decl_cardinal:
case decl_longcard:
case decl_integer:
case decl_longint:
case decl_shortint:
- case decl_real:
- case decl_longreal:
- case decl_shortreal:
case decl_complex:
case decl_longcomplex:
case decl_shortcomplex:
+ case decl_real:
+ case decl_longreal:
+ case decl_shortreal:
case decl_bitset:
case decl_boolean:
case decl_proc:
- return false;
- break;
-
- case decl_setvalue:
- return false;
+ doBaseC (p, n);
break;
case decl_address:
- return true;
- break;
-
- case decl_procedure:
- return false;
- break;
-
- case decl_length:
- case decl_cmplx:
- case decl_re:
- case decl_im:
- return true;
- break;
-
-
- default:
- CaseException ("../../gcc/m2/mc/decl.def", 20, 1);
- __builtin_unreachable ();
- }
- return true;
- /* static analysis guarentees a RETURN statement will be used before here. */
- __builtin_unreachable ();
-}
-
-
-/*
- doUnary -
-*/
-
-static void doUnary (mcPretty_pretty p, const char *op_, unsigned int _op_high, decl_node expr, decl_node type, bool l, bool r)
-{
- char op[_op_high+1];
-
- /* make a local copy of each unbounded array. */
- memcpy (op, op_, _op_high+1);
-
- if (l)
- {
- mcPretty_setNeedSpace (p);
- }
- mcPretty_print (p, (const char *) op, _op_high);
- if (r)
- {
- mcPretty_setNeedSpace (p);
- }
- if (needsParen (expr))
- {
- outText (p, (const char *) "(", 1);
- doExprC (p, expr);
- outText (p, (const char *) ")", 1);
- }
- else
- {
- doExprC (p, expr);
- }
-}
-
-
-/*
- doSetSub - perform l & (~ r)
-*/
-
-static void doSetSub (mcPretty_pretty p, decl_node left, decl_node right)
-{
- if (needsParen (left))
- {
- outText (p, (const char *) "(", 1);
- doExprC (p, left);
- outText (p, (const char *) ")", 1);
- }
- else
- {
- doExprC (p, left);
- }
- mcPretty_setNeedSpace (p);
- outText (p, (const char *) "&", 1);
- mcPretty_setNeedSpace (p);
- if (needsParen (right))
- {
- outText (p, (const char *) "(~(", 3);
- doExprC (p, right);
- outText (p, (const char *) "))", 2);
- }
- else
- {
- outText (p, (const char *) "(~", 2);
- doExprC (p, right);
- outText (p, (const char *) ")", 1);
- }
-}
-
-
-/*
- doPolyBinary -
-*/
-
-static void doPolyBinary (mcPretty_pretty p, decl_nodeT op, decl_node left, decl_node right, bool l, bool r)
-{
- decl_node lt;
- decl_node rt;
-
- lt = decl_skipType (getExprType (left));
- rt = decl_skipType (getExprType (right));
- if (((lt != NULL) && ((decl_isSet (lt)) || (isBitset (lt)))) || ((rt != NULL) && ((decl_isSet (rt)) || (isBitset (rt)))))
- {
- switch (op)
- {
- case decl_plus:
- doBinary (p, (const char *) "|", 1, left, right, l, r, false);
- break;
-
- case decl_sub:
- doSetSub (p, left, right);
- break;
-
- case decl_mult:
- doBinary (p, (const char *) "&", 1, left, right, l, r, false);
- break;
-
- case decl_divide:
- doBinary (p, (const char *) "^", 1, left, right, l, r, false);
- break;
-
-
- default:
- CaseException ("../../gcc/m2/mc/decl.def", 20, 1);
- __builtin_unreachable ();
- }
- }
- else
- {
- switch (op)
- {
- case decl_plus:
- doBinary (p, (const char *) "+", 1, left, right, l, r, false);
- break;
-
- case decl_sub:
- doBinary (p, (const char *) "-", 1, left, right, l, r, false);
- break;
-
- case decl_mult:
- doBinary (p, (const char *) "*", 1, left, right, l, r, false);
- break;
-
- case decl_divide:
- doBinary (p, (const char *) "/", 1, left, right, l, r, false);
- break;
-
-
- default:
- CaseException ("../../gcc/m2/mc/decl.def", 20, 1);
- __builtin_unreachable ();
- }
- }
-}
-
-
-/*
- doBinary -
-*/
-
-static void doBinary (mcPretty_pretty p, const char *op_, unsigned int _op_high, decl_node left, decl_node right, bool l, bool r, bool unpackProc)
-{
- char op[_op_high+1];
-
- /* make a local copy of each unbounded array. */
- memcpy (op, op_, _op_high+1);
-
- if (needsParen (left))
- {
- outText (p, (const char *) "(", 1);
- doExprCup (p, left, unpackProc);
- outText (p, (const char *) ")", 1);
- }
- else
- {
- doExprCup (p, left, unpackProc);
- }
- if (l)
- {
- mcPretty_setNeedSpace (p);
- }
- outText (p, (const char *) op, _op_high);
- if (r)
- {
- mcPretty_setNeedSpace (p);
- }
- if (needsParen (right))
- {
- outText (p, (const char *) "(", 1);
- doExprCup (p, right, unpackProc);
- outText (p, (const char *) ")", 1);
- }
- else
- {
- doExprCup (p, right, unpackProc);
- }
-}
-
+ case decl_loc:
+ case decl_byte:
+ case decl_word:
+ case decl_csizet:
+ case decl_cssizet:
+ doSystemC (p, n);
+ break;
-/*
- doPostUnary -
-*/
+ case decl_type:
+ doTypeNameC (p, n);
+ break;
-static void doPostUnary (mcPretty_pretty p, const char *op_, unsigned int _op_high, decl_node expr)
-{
- char op[_op_high+1];
+ case decl_pointer:
+ doTypeNameC (p, n);
+ break;
- /* make a local copy of each unbounded array. */
- memcpy (op, op_, _op_high+1);
- doExprC (p, expr);
- outText (p, (const char *) op, _op_high);
+ default:
+ CaseException ("../../gcc/m2/mc/decl.def", 20, 1);
+ __builtin_unreachable ();
+ }
}
/*
- doDeRefC -
+ doExprCup -
*/
-static void doDeRefC (mcPretty_pretty p, decl_node expr)
+static decl_node__opaque doExprCup (mcPretty_pretty p, decl_node__opaque n, bool unpackProc, bool uncastConst)
{
- outText (p, (const char *) "(*", 2);
- doExprC (p, expr);
- outText (p, (const char *) ")", 1);
+ decl_node__opaque type;
+
+ if (uncastConst && (isArrayRef (n)))
+ {
+ doArrayRef (p, n, true);
+ }
+ else
+ {
+ doExprC (p, n);
+ if (unpackProc)
+ {
+ type = static_cast<decl_node__opaque> (decl_skipType (static_cast<decl_node> (getExprType (n))));
+ if ((type != NULL) && (isAProcType (type)))
+ {
+ outText (p, (const char *) ".proc", 5);
+ }
+ }
+ }
+ return n;
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
}
/*
- doGetLastOp - returns, a, if b is a terminal otherwise walk right.
+ doExprM2 -
*/
-static decl_node doGetLastOp (decl_node a, decl_node b)
+static void doExprM2 (mcPretty_pretty p, decl_node__opaque n)
{
- switch (b->kind)
+ mcDebug_assert (n != NULL);
+ switch (n->kind)
{
case decl_nil:
- return a;
+ outText (p, (const char *) "NIL", 3);
break;
case decl_true:
- return a;
+ outText (p, (const char *) "TRUE", 4);
break;
case decl_false:
- return a;
+ outText (p, (const char *) "FALSE", 5);
break;
case decl_constexp:
- return doGetLastOp (b, b->unaryF.arg);
+ doUnary (p, (const char *) "", 0, n->unaryF.arg, n->unaryF.resultType, false, false);
break;
case decl_neg:
- return doGetLastOp (b, b->unaryF.arg);
+ doUnary (p, (const char *) "-", 1, n->unaryF.arg, n->unaryF.resultType, false, false);
break;
case decl_not:
- return doGetLastOp (b, b->unaryF.arg);
+ doUnary (p, (const char *) "NOT", 3, n->unaryF.arg, n->unaryF.resultType, true, true);
break;
case decl_adr:
- return doGetLastOp (b, b->unaryF.arg);
+ doUnary (p, (const char *) "ADR", 3, n->unaryF.arg, n->unaryF.resultType, true, true);
break;
case decl_size:
- return doGetLastOp (b, b->unaryF.arg);
+ doUnary (p, (const char *) "SIZE", 4, n->unaryF.arg, n->unaryF.resultType, true, true);
break;
case decl_tsize:
- return doGetLastOp (b, b->unaryF.arg);
+ doUnary (p, (const char *) "TSIZE", 5, n->unaryF.arg, n->unaryF.resultType, true, true);
break;
- case decl_ord:
- return doGetLastOp (b, b->unaryF.arg);
+ case decl_float:
+ doUnary (p, (const char *) "FLOAT", 5, n->unaryF.arg, n->unaryF.resultType, true, true);
break;
- case decl_float:
case decl_trunc:
- return doGetLastOp (b, b->unaryF.arg);
+ doUnary (p, (const char *) "TRUNC", 5, n->unaryF.arg, n->unaryF.resultType, true, true);
+ break;
+
+ case decl_ord:
+ doUnary (p, (const char *) "ORD", 3, n->unaryF.arg, n->unaryF.resultType, true, true);
break;
case decl_chr:
- return doGetLastOp (b, b->unaryF.arg);
+ doUnary (p, (const char *) "CHR", 3, n->unaryF.arg, n->unaryF.resultType, true, true);
break;
case decl_cap:
- return doGetLastOp (b, b->unaryF.arg);
+ doUnary (p, (const char *) "CAP", 3, n->unaryF.arg, n->unaryF.resultType, true, true);
break;
case decl_high:
- return doGetLastOp (b, b->unaryF.arg);
+ doUnary (p, (const char *) "HIGH", 4, n->unaryF.arg, n->unaryF.resultType, true, true);
break;
- case decl_deref:
- return doGetLastOp (b, b->unaryF.arg);
+ case decl_re:
+ doUnary (p, (const char *) "RE", 2, n->unaryF.arg, n->unaryF.resultType, true, true);
break;
- case decl_re:
case decl_im:
- return doGetLastOp (b, b->unaryF.arg);
+ doUnary (p, (const char *) "IM", 2, n->unaryF.arg, n->unaryF.resultType, true, true);
+ break;
+
+ case decl_deref:
+ doPostUnary (p, (const char *) "^", 1, n->unaryF.arg);
break;
case decl_equal:
- return doGetLastOp (b, b->binaryF.right);
+ doBinary (p, (const char *) "=", 1, n->binaryF.left, n->binaryF.right, true, true, false);
break;
case decl_notequal:
- return doGetLastOp (b, b->binaryF.right);
+ doBinary (p, (const char *) "#", 1, n->binaryF.left, n->binaryF.right, true, true, false);
break;
case decl_less:
- return doGetLastOp (b, b->binaryF.right);
+ doBinary (p, (const char *) "<", 1, n->binaryF.left, n->binaryF.right, true, true, false);
break;
case decl_greater:
- return doGetLastOp (b, b->binaryF.right);
+ doBinary (p, (const char *) ">", 1, n->binaryF.left, n->binaryF.right, true, true, false);
break;
case decl_greequal:
- return doGetLastOp (b, b->binaryF.right);
+ doBinary (p, (const char *) ">=", 2, n->binaryF.left, n->binaryF.right, true, true, false);
break;
case decl_lessequal:
- return doGetLastOp (b, b->binaryF.right);
+ doBinary (p, (const char *) "<=", 2, n->binaryF.left, n->binaryF.right, true, true, false);
break;
case decl_componentref:
- return doGetLastOp (b, b->componentrefF.field);
+ doBinary (p, (const char *) ".", 1, n->componentrefF.rec, n->componentrefF.field, false, false, false);
break;
case decl_pointerref:
- return doGetLastOp (b, b->pointerrefF.field);
+ doBinary (p, (const char *) "^.", 2, n->pointerrefF.ptr, n->pointerrefF.field, false, false, false);
break;
case decl_cast:
- return doGetLastOp (b, b->binaryF.right);
+ doPreBinary (p, (const char *) "CAST", 4, n->binaryF.left, n->binaryF.right, true, true);
break;
case decl_val:
- return doGetLastOp (b, b->binaryF.right);
+ doPreBinary (p, (const char *) "VAL", 3, n->binaryF.left, n->binaryF.right, true, true);
+ break;
+
+ case decl_cmplx:
+ doPreBinary (p, (const char *) "CMPLX", 5, n->binaryF.left, n->binaryF.right, true, true);
break;
case decl_plus:
- return doGetLastOp (b, b->binaryF.right);
+ doBinary (p, (const char *) "+", 1, n->binaryF.left, n->binaryF.right, false, false, false);
break;
case decl_sub:
- return doGetLastOp (b, b->binaryF.right);
+ doBinary (p, (const char *) "-", 1, n->binaryF.left, n->binaryF.right, false, false, false);
break;
case decl_div:
- return doGetLastOp (b, b->binaryF.right);
+ doBinary (p, (const char *) "DIV", 3, n->binaryF.left, n->binaryF.right, true, true, false);
break;
case decl_mod:
- return doGetLastOp (b, b->binaryF.right);
+ doBinary (p, (const char *) "MOD", 3, n->binaryF.left, n->binaryF.right, true, true, false);
break;
case decl_mult:
- return doGetLastOp (b, b->binaryF.right);
+ doBinary (p, (const char *) "*", 1, n->binaryF.left, n->binaryF.right, false, false, false);
break;
case decl_divide:
- return doGetLastOp (b, b->binaryF.right);
- break;
-
- case decl_in:
- return doGetLastOp (b, b->binaryF.right);
- break;
-
- case decl_and:
- return doGetLastOp (b, b->binaryF.right);
- break;
-
- case decl_or:
- return doGetLastOp (b, b->binaryF.right);
- break;
-
- case decl_cmplx:
- return doGetLastOp (b, b->binaryF.right);
+ doBinary (p, (const char *) "/", 1, n->binaryF.left, n->binaryF.right, false, false, false);
break;
case decl_literal:
- return a;
+ doLiteral (p, n);
break;
case decl_const:
- return a;
+ doConstExpr (p, n);
break;
case decl_enumerationfield:
- return a;
+ doEnumerationField (p, n);
break;
case decl_string:
- return a;
+ doString (p, n);
break;
case decl_max:
- return doGetLastOp (b, b->unaryF.arg);
+ doUnary (p, (const char *) "MAX", 3, n->unaryF.arg, n->unaryF.resultType, true, true);
break;
case decl_min:
- return doGetLastOp (b, b->unaryF.arg);
+ doUnary (p, (const char *) "MIN", 3, n->unaryF.arg, n->unaryF.resultType, true, true);
break;
case decl_var:
- return a;
- break;
-
- case decl_arrayref:
- return a;
- break;
-
- case decl_funccall:
- return a;
- break;
-
- case decl_procedure:
- return a;
- break;
-
- case decl_recordfield:
- return a;
+ doVar (p, n);
break;
CaseException ("../../gcc/m2/mc/decl.def", 20, 1);
__builtin_unreachable ();
}
- /* static analysis guarentees a RETURN statement will be used before here. */
- __builtin_unreachable ();
-}
-
-
-/*
- doComponentRefC -
-*/
-
-static void doComponentRefC (mcPretty_pretty p, decl_node l, decl_node r)
-{
- doExprC (p, l);
- outText (p, (const char *) ".", 1);
- doExprC (p, r);
-}
-
-
-/*
- doPointerRefC -
-*/
-
-static void doPointerRefC (mcPretty_pretty p, decl_node l, decl_node r)
-{
- doExprC (p, l);
- outText (p, (const char *) "->", 2);
- doExprC (p, r);
}
/*
- doPreBinary -
+ doVar -
*/
-static void doPreBinary (mcPretty_pretty p, const char *op_, unsigned int _op_high, decl_node left, decl_node right, bool l, bool r)
+static void doVar (mcPretty_pretty p, decl_node__opaque n)
{
- char op[_op_high+1];
-
- /* make a local copy of each unbounded array. */
- memcpy (op, op_, _op_high+1);
-
- if (l)
- {
- mcPretty_setNeedSpace (p);
- }
- outText (p, (const char *) op, _op_high);
- if (r)
+ mcDebug_assert (decl_isVar (static_cast<decl_node> (n)));
+ if (n->varF.isVarParameter)
{
- mcPretty_setNeedSpace (p);
+ outText (p, (const char *) "(*", 2);
+ doFQDNameC (p, n, true);
+ outText (p, (const char *) ")", 1);
}
- outText (p, (const char *) "(", 1);
- doExprC (p, left);
- outText (p, (const char *) ",", 1);
- mcPretty_setNeedSpace (p);
- doExprC (p, right);
- outText (p, (const char *) ")", 1);
-}
-
-
-/*
- doConstExpr -
-*/
-
-static void doConstExpr (mcPretty_pretty p, decl_node n)
-{
- doFQNameC (p, n);
-}
-
-
-/*
- doEnumerationField -
-*/
-
-static void doEnumerationField (mcPretty_pretty p, decl_node n)
-{
- doFQDNameC (p, n, false);
-}
-
-
-/*
- isZero - returns TRUE if node, n, is zero.
-*/
-
-static bool isZero (decl_node n)
-{
- if (isConstExp (n))
+ else
{
- return isZero (n->unaryF.arg);
+ doFQDNameC (p, n, true);
}
- return (decl_getSymName (n)) == (nameKey_makeKey ((const char *) "0", 1));
- /* static analysis guarentees a RETURN statement will be used before here. */
- __builtin_unreachable ();
}
/*
- doArrayRef -
+ doLiteralC -
*/
-static void doArrayRef (mcPretty_pretty p, decl_node n)
+static void doLiteralC (mcPretty_pretty p, decl_node__opaque n)
{
- decl_node t;
- unsigned int i;
- unsigned int c;
+ DynamicStrings_String s;
- mcDebug_assert (n != NULL);
- mcDebug_assert (isArrayRef (n));
- t = decl_skipType (decl_getType (n->arrayrefF.array));
- if (decl_isUnbounded (t))
+ mcDebug_assert (decl_isLiteral (static_cast<decl_node> (n)));
+ s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (static_cast<decl_node> (n))));
+ if (n->literalF.type == charN)
{
- outTextN (p, decl_getSymName (n->arrayrefF.array));
+ if ((DynamicStrings_char (s, -1)) == 'C')
+ {
+ s = DynamicStrings_Slice (DynamicStrings_Mark (s), 0, -1);
+ if ((DynamicStrings_char (s, 0)) != '0')
+ {
+ s = DynamicStrings_ConCat (DynamicStrings_InitString ((const char *) "0", 1), DynamicStrings_Mark (s));
+ }
+ }
+ outText (p, (const char *) "(char)", 6);
+ mcPretty_setNeedSpace (p);
}
- else
+ else if ((DynamicStrings_char (s, -1)) == 'H')
{
- doExprC (p, n->arrayrefF.array);
- mcDebug_assert (decl_isArray (t));
- outText (p, (const char *) ".array", 6);
+ /* avoid dangling else. */
+ outText (p, (const char *) "0x", 2);
+ s = DynamicStrings_Slice (DynamicStrings_Mark (s), 0, -1);
}
- outText (p, (const char *) "[", 1);
- i = 1;
- c = expListLen (n->arrayrefF.index);
- while (i <= c)
+ else if ((DynamicStrings_char (s, -1)) == 'B')
{
- doExprC (p, getExpList (n->arrayrefF.index, i));
- if (decl_isUnbounded (t))
- {
- mcDebug_assert (c == 1);
- }
- else
+ /* avoid dangling else. */
+ outText (p, (const char *) "0", 1);
+ s = DynamicStrings_Slice (DynamicStrings_Mark (s), 0, -1);
+ }
+ outTextS (p, s);
+ s = DynamicStrings_KillString (s);
+}
+
+
+/*
+ doLiteral -
+*/
+
+static void doLiteral (mcPretty_pretty p, decl_node__opaque n)
+{
+ DynamicStrings_String s;
+
+ mcDebug_assert (decl_isLiteral (static_cast<decl_node> (n)));
+ s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (static_cast<decl_node> (n))));
+ if (n->literalF.type == charN)
+ {
+ if ((DynamicStrings_char (s, -1)) == 'C')
{
- doSubtractC (p, getMin (t->arrayF.subr));
- if (i < c)
+ s = DynamicStrings_Slice (DynamicStrings_Mark (s), 0, -1);
+ if ((DynamicStrings_char (s, 0)) != '0')
{
- mcDebug_assert (decl_isArray (t));
- outText (p, (const char *) "].array[", 8);
- t = decl_skipType (decl_getType (t));
+ s = DynamicStrings_ConCat (DynamicStrings_InitString ((const char *) "0", 1), DynamicStrings_Mark (s));
}
}
- i += 1;
+ outText (p, (const char *) "(char)", 6);
+ mcPretty_setNeedSpace (p);
}
- outText (p, (const char *) "]", 1);
+ outTextS (p, s);
+ s = DynamicStrings_KillString (s);
}
/*
- doProcedure -
+ isString - returns TRUE if node, n, is a string.
*/
-static void doProcedure (mcPretty_pretty p, decl_node n)
+static bool isString (decl_node__opaque n)
{
- mcDebug_assert (decl_isProcedure (n));
- doFQDNameC (p, n, true);
+ mcDebug_assert (n != NULL);
+ return n->kind == decl_string;
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
}
/*
- doRecordfield -
+ doString -
*/
-static void doRecordfield (mcPretty_pretty p, decl_node n)
+static void doString (mcPretty_pretty p, decl_node__opaque n)
{
- doDNameC (p, n, false);
+ DynamicStrings_String s;
+
+ mcDebug_assert (isString (n));
+ s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (static_cast<decl_node> (n))));
+ outTextS (p, s);
+ s = DynamicStrings_KillString (s);
+ /*
+ IF DynamicStrings.Index (s, '"', 0)=-1
+ THEN
+ outText (p, '"') ;
+ outTextS (p, s) ;
+ outText (p, '"')
+ ELSIF DynamicStrings.Index (s, "'", 0)=-1
+ THEN
+ outText (p, '"') ;
+ outTextS (p, s) ;
+ outText (p, '"')
+ ELSE
+ metaError1 ('illegal string {%1k}', n)
+ END
+ */
+ M2RTS_HALT (-1);
+ __builtin_unreachable ();
}
/*
- doCastC -
+ replaceChar - replace every occurance of, ch, by, a and return modified string, s.
*/
-static void doCastC (mcPretty_pretty p, decl_node t, decl_node e)
+static DynamicStrings_String replaceChar (DynamicStrings_String s, char ch, const char *a_, unsigned int _a_high)
{
- decl_node et;
+ int i;
+ char a[_a_high+1];
- outText (p, (const char *) "(", 1);
- doTypeNameC (p, t);
- outText (p, (const char *) ")", 1);
- mcPretty_setNeedSpace (p);
- et = decl_skipType (decl_getType (e));
- if (((et != NULL) && (isAProcType (et))) && (isAProcType (decl_skipType (t))))
- {
- outText (p, (const char *) "{(", 2);
- doFQNameC (p, t);
- outText (p, (const char *) "_t)", 3);
- mcPretty_setNeedSpace (p);
- doExprC (p, e);
- outText (p, (const char *) ".proc}", 6);
- }
- else
- {
- outText (p, (const char *) "(", 1);
- doExprC (p, e);
- outText (p, (const char *) ")", 1);
- }
+ /* make a local copy of each unbounded array. */
+ memcpy (a, a_, _a_high+1);
+
+ i = 0;
+ for (;;)
+ {
+ i = DynamicStrings_Index (s, ch, static_cast<unsigned int> (i));
+ if (i == 0)
+ {
+ s = DynamicStrings_ConCat (DynamicStrings_InitString ((const char *) a, _a_high), DynamicStrings_Slice (s, 1, 0));
+ i = StrLib_StrLen ((const char *) a, _a_high);
+ }
+ else if (i > 0)
+ {
+ /* avoid dangling else. */
+ s = DynamicStrings_ConCat (DynamicStrings_ConCat (DynamicStrings_Slice (s, 0, i), DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high))), DynamicStrings_Slice (s, i+1, 0));
+ i += StrLib_StrLen ((const char *) a, _a_high);
+ }
+ else
+ {
+ /* avoid dangling else. */
+ return s;
+ }
+ }
+ ReturnException ("../../gcc/m2/mc/decl.def", 20, 1);
+ __builtin_unreachable ();
}
/*
- doSetValueC -
+ toCstring - translates string, n, into a C string
+ and returns the new String.
*/
-static void doSetValueC (mcPretty_pretty p, decl_node n)
+static DynamicStrings_String toCstring (nameKey_Name n)
{
- decl_node lo;
- unsigned int i;
- unsigned int h;
+ DynamicStrings_String s;
- mcDebug_assert (decl_isSetValue (n));
- lo = getSetLow (n);
- if (n->setvalueF.type != NULL)
- {
- outText (p, (const char *) "(", 1);
- doTypeNameC (p, n->setvalueF.type);
- mcPretty_noSpace (p);
- outText (p, (const char *) ")", 1);
- mcPretty_setNeedSpace (p);
- }
- if ((Indexing_HighIndice (n->setvalueF.values)) == 0)
- {
- outText (p, (const char *) "0", 1);
- }
- else
- {
- i = Indexing_LowIndice (n->setvalueF.values);
- h = Indexing_HighIndice (n->setvalueF.values);
- outText (p, (const char *) "(", 1);
- while (i <= h)
- {
- outText (p, (const char *) "(1", 2);
- mcPretty_setNeedSpace (p);
- outText (p, (const char *) "<<", 2);
- mcPretty_setNeedSpace (p);
- outText (p, (const char *) "(", 1);
- doExprC (p, reinterpret_cast<decl_node> (Indexing_GetIndice (n->setvalueF.values, i)));
- doSubtractC (p, lo);
- outText (p, (const char *) ")", 1);
- outText (p, (const char *) ")", 1);
- if (i < h)
- {
- mcPretty_setNeedSpace (p);
- outText (p, (const char *) "|", 1);
- mcPretty_setNeedSpace (p);
- }
- i += 1;
- }
- outText (p, (const char *) ")", 1);
- }
+ s = DynamicStrings_Slice (DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (n)), 1, -1);
+ return replaceChar (replaceChar (s, '\\', (const char *) "\\\\", 2), '"', (const char *) "\\\"", 2);
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
}
/*
- getSetLow - returns the low value of the set type from
- expression, n.
+ toCchar -
*/
-static decl_node getSetLow (decl_node n)
+static DynamicStrings_String toCchar (nameKey_Name n)
{
- decl_node type;
+ DynamicStrings_String s;
- if ((decl_getType (n)) == NULL)
- {
- return decl_makeLiteralInt (nameKey_makeKey ((const char *) "0", 1));
- }
- else
- {
- type = decl_skipType (decl_getType (n));
- if (decl_isSet (type))
- {
- return getMin (decl_skipType (decl_getType (type)));
- }
- else
- {
- return decl_makeLiteralInt (nameKey_makeKey ((const char *) "0", 1));
- }
- }
+ s = DynamicStrings_Slice (DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (n)), 1, -1);
+ return replaceChar (replaceChar (s, '\\', (const char *) "\\\\", 2), '\'', (const char *) "\\'", 2);
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
/*
- doInC - performs (((1 << (l)) & (r)) != 0)
+ countChar -
*/
-static void doInC (mcPretty_pretty p, decl_node l, decl_node r)
+static unsigned int countChar (DynamicStrings_String s, char ch)
{
- decl_node lo;
+ int i;
+ unsigned int c;
- lo = getSetLow (r);
- outText (p, (const char *) "(((1", 4);
- mcPretty_setNeedSpace (p);
- outText (p, (const char *) "<<", 2);
- mcPretty_setNeedSpace (p);
- outText (p, (const char *) "(", 1);
- doExprC (p, l);
- doSubtractC (p, lo);
- outText (p, (const char *) "))", 2);
- mcPretty_setNeedSpace (p);
- outText (p, (const char *) "&", 1);
- mcPretty_setNeedSpace (p);
- outText (p, (const char *) "(", 1);
- doExprC (p, r);
- outText (p, (const char *) "))", 2);
- mcPretty_setNeedSpace (p);
- outText (p, (const char *) "!=", 2);
- mcPretty_setNeedSpace (p);
- outText (p, (const char *) "0)", 2);
+ c = 0;
+ i = 0;
+ for (;;)
+ {
+ i = DynamicStrings_Index (s, ch, static_cast<unsigned int> (i));
+ if (i >= 0)
+ {
+ i += 1;
+ c += 1;
+ }
+ else
+ {
+ return c;
+ }
+ }
+ ReturnException ("../../gcc/m2/mc/decl.def", 20, 1);
+ __builtin_unreachable ();
}
/*
- doThrowC -
+ lenCstring -
*/
-static void doThrowC (mcPretty_pretty p, decl_node n)
+static unsigned int lenCstring (DynamicStrings_String s)
{
- mcDebug_assert (isIntrinsic (n));
- outText (p, (const char *) "throw", 5);
- mcPretty_setNeedSpace (p);
- outText (p, (const char *) "(", 1);
- if ((expListLen (n->intrinsicF.args)) == 1)
- {
- doExprC (p, getExpList (n->intrinsicF.args, 1));
- }
- outText (p, (const char *) ")", 1);
+ return (DynamicStrings_Length (s))-(countChar (s, '\\'));
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
}
/*
- doUnreachableC -
+ outCstring -
*/
-static void doUnreachableC (mcPretty_pretty p, decl_node n)
+static void outCstring (mcPretty_pretty p, decl_node__opaque s, bool aString)
{
- mcDebug_assert (isIntrinsic (n));
- outText (p, (const char *) "__builtin_unreachable", 21);
- mcPretty_setNeedSpace (p);
- outText (p, (const char *) "(", 1);
- mcDebug_assert ((expListLen (n->intrinsicF.args)) == 0);
- outText (p, (const char *) ")", 1);
+ if (aString)
+ {
+ outText (p, (const char *) "\"", 1);
+ outRawS (p, s->stringF.cstring);
+ outText (p, (const char *) "\"", 1);
+ }
+ else
+ {
+ outText (p, (const char *) "'", 1);
+ outRawS (p, s->stringF.cchar);
+ outText (p, (const char *) "'", 1);
+ }
}
/*
- outNull -
+ doStringC -
*/
-static void outNull (mcPretty_pretty p)
+static void doStringC (mcPretty_pretty p, decl_node__opaque n)
{
- keyc_useNull ();
- outText (p, (const char *) "NULL", 4);
+ DynamicStrings_String s;
+
+ mcDebug_assert (isString (n));
+ /*
+ s := InitStringCharStar (keyToCharStar (getSymName (n))) ;
+ IF DynamicStrings.Length (s)>3
+ THEN
+ IF DynamicStrings.Index (s, '"', 0)=-1
+ THEN
+ s := DynamicStrings.Slice (s, 1, -1) ;
+ outText (p, '"') ;
+ outCstring (p, s) ;
+ outText (p, '"')
+ ELSIF DynamicStrings.Index (s, "'", 0)=-1
+ THEN
+ s := DynamicStrings.Slice (s, 1, -1) ;
+ outText (p, '"') ;
+ outCstring (p, s) ;
+ outText (p, '"')
+ ELSE
+ metaError1 ('illegal string {%1k}', n)
+ END
+ ELSIF DynamicStrings.Length (s) = 3
+ THEN
+ s := DynamicStrings.Slice (s, 1, -1) ;
+ outText (p, "'") ;
+ IF DynamicStrings.char (s, 0) = "'"
+ THEN
+ outText (p, "\'")
+ ELSIF DynamicStrings.char (s, 0) = "\"
+ THEN
+ outText (p, "\\")
+ ELSE
+ outTextS (p, s)
+ END ;
+ outText (p, "'")
+ ELSE
+ outText (p, "'\0'")
+ END ;
+ s := KillString (s)
+ */
+ outCstring (p, n, ! n->stringF.isCharCompatible);
}
/*
- outTrue -
+ isPunct -
*/
-static void outTrue (mcPretty_pretty p)
+static bool isPunct (char ch)
{
- keyc_useTrue ();
- if ((mcOptions_useBool ()) && (lang == decl_ansiCP))
- {
- outText (p, (const char *) "true", 4);
- }
- else
- {
- outText (p, (const char *) "TRUE", 4);
- }
+ return (((((((((ch == '.') || (ch == '(')) || (ch == ')')) || (ch == '^')) || (ch == ':')) || (ch == ';')) || (ch == '{')) || (ch == '}')) || (ch == ',')) || (ch == '*');
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
}
/*
- outFalse -
+ isWhite -
*/
-static void outFalse (mcPretty_pretty p)
+static bool isWhite (char ch)
{
- keyc_useFalse ();
- if ((mcOptions_useBool ()) && (lang == decl_ansiCP))
- {
- outText (p, (const char *) "false", 5);
- }
- else
- {
- outText (p, (const char *) "FALSE", 5);
- }
+ return ((ch == ' ') || (ch == ASCII_tab)) || (ch == ASCII_lf);
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
}
/*
- doExprC -
+ outText -
*/
-static void doExprC (mcPretty_pretty p, decl_node n)
+static void outText (mcPretty_pretty p, const char *a_, unsigned int _a_high)
{
- decl_node t;
-
- mcDebug_assert (n != NULL);
- t = getExprType (n);
- switch (n->kind)
- {
- case decl_nil:
- outNull (p);
- break;
-
- case decl_true:
- outTrue (p);
- break;
+ DynamicStrings_String s;
+ char a[_a_high+1];
- case decl_false:
- outFalse (p);
- break;
+ /* make a local copy of each unbounded array. */
+ memcpy (a, a_, _a_high+1);
- case decl_constexp:
- doUnary (p, (const char *) "", 0, n->unaryF.arg, n->unaryF.resultType, false, false);
- break;
+ s = DynamicStrings_InitString ((const char *) a, _a_high);
+ outTextS (p, s);
+ s = DynamicStrings_KillString (s);
+}
- case decl_neg:
- doUnary (p, (const char *) "-", 1, n->unaryF.arg, n->unaryF.resultType, false, false);
- break;
- case decl_not:
- doUnary (p, (const char *) "!", 1, n->unaryF.arg, n->unaryF.resultType, false, true);
- break;
+/*
+ outRawS -
+*/
- case decl_val:
- doValC (p, n);
- break;
+static void outRawS (mcPretty_pretty p, DynamicStrings_String s)
+{
+ mcPretty_raw (p, s);
+}
- case decl_adr:
- doAdrC (p, n);
- break;
- case decl_size:
- case decl_tsize:
- doSizeC (p, n);
- break;
+/*
+ outKm2 -
+*/
- case decl_float:
- doConvertSC (p, n, mcOptions_getCRealType ());
- break;
+static mcPretty_pretty outKm2 (mcPretty_pretty p, const char *a_, unsigned int _a_high)
+{
+ unsigned int i;
+ DynamicStrings_String s;
+ char a[_a_high+1];
- case decl_trunc:
- doConvertC (p, n, (const char *) "int", 3);
- break;
+ /* make a local copy of each unbounded array. */
+ memcpy (a, a_, _a_high+1);
- case decl_ord:
- doConvertC (p, n, (const char *) "unsigned int", 12);
- break;
+ if (StrLib_StrEqual ((const char *) a, _a_high, (const char *) "RECORD", 6))
+ {
+ p = mcPretty_pushPretty (p);
+ i = mcPretty_getcurpos (p);
+ mcPretty_setindent (p, i);
+ outText (p, (const char *) a, _a_high);
+ p = mcPretty_pushPretty (p);
+ mcPretty_setindent (p, i+indentation);
+ }
+ else if (StrLib_StrEqual ((const char *) a, _a_high, (const char *) "END", 3))
+ {
+ /* avoid dangling else. */
+ p = mcPretty_popPretty (p);
+ outText (p, (const char *) a, _a_high);
+ p = mcPretty_popPretty (p);
+ }
+ return p;
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
+}
- case decl_chr:
- doConvertC (p, n, (const char *) "char", 4);
- break;
- case decl_cap:
- doCapC (p, n);
- break;
+/*
+ outKc -
+*/
- case decl_abs:
- doAbsC (p, n);
- break;
+static mcPretty_pretty outKc (mcPretty_pretty p, const char *a_, unsigned int _a_high)
+{
+ int i;
+ unsigned int c;
+ DynamicStrings_String s;
+ DynamicStrings_String t;
+ char a[_a_high+1];
- case decl_high:
- doFuncHighC (p, n->unaryF.arg);
- break;
+ /* make a local copy of each unbounded array. */
+ memcpy (a, a_, _a_high+1);
- case decl_length:
- doLengthC (p, n);
- break;
+ s = DynamicStrings_InitString ((const char *) a, _a_high);
+ i = DynamicStrings_Index (s, '\\', 0);
+ if (i == -1)
+ {
+ t = static_cast<DynamicStrings_String> (NULL);
+ }
+ else
+ {
+ t = DynamicStrings_Slice (s, i, 0);
+ s = DynamicStrings_Slice (DynamicStrings_Mark (s), 0, i);
+ }
+ if ((DynamicStrings_char (s, 0)) == '{')
+ {
+ p = mcPretty_pushPretty (p);
+ c = mcPretty_getcurpos (p);
+ mcPretty_setindent (p, c);
+ outTextS (p, s);
+ p = mcPretty_pushPretty (p);
+ mcPretty_setindent (p, c+indentationC);
+ }
+ else if ((DynamicStrings_char (s, 0)) == '}')
+ {
+ /* avoid dangling else. */
+ p = mcPretty_popPretty (p);
+ outTextS (p, s);
+ p = mcPretty_popPretty (p);
+ }
+ outTextS (p, t);
+ t = DynamicStrings_KillString (t);
+ s = DynamicStrings_KillString (s);
+ return p;
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
+}
- case decl_min:
- doMinC (p, n);
- break;
- case decl_max:
- doMaxC (p, n);
- break;
+/*
+ outTextS -
+*/
- case decl_throw:
- doThrowC (p, n);
- break;
+static void outTextS (mcPretty_pretty p, DynamicStrings_String s)
+{
+ if (s != NULL)
+ {
+ mcPretty_prints (p, s);
+ }
+}
- case decl_unreachable:
- doUnreachableC (p, n);
- break;
- case decl_re:
- doReC (p, n);
- break;
+/*
+ outCard -
+*/
- case decl_im:
- doImC (p, n);
- break;
+static void outCard (mcPretty_pretty p, unsigned int c)
+{
+ DynamicStrings_String s;
- case decl_cmplx:
- doCmplx (p, n);
- break;
+ s = StringConvert_CardinalToString (c, 0, ' ', 10, false);
+ outTextS (p, s);
+ s = DynamicStrings_KillString (s);
+}
- case decl_deref:
- doDeRefC (p, n->unaryF.arg);
- break;
- case decl_equal:
- doBinary (p, (const char *) "==", 2, n->binaryF.left, n->binaryF.right, true, true, true);
- break;
+/*
+ outTextN -
+*/
- case decl_notequal:
- doBinary (p, (const char *) "!=", 2, n->binaryF.left, n->binaryF.right, true, true, true);
- break;
+static void outTextN (mcPretty_pretty p, nameKey_Name n)
+{
+ DynamicStrings_String s;
- case decl_less:
- doBinary (p, (const char *) "<", 1, n->binaryF.left, n->binaryF.right, true, true, false);
- break;
+ s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (n));
+ mcPretty_prints (p, s);
+ s = DynamicStrings_KillString (s);
+}
- case decl_greater:
- doBinary (p, (const char *) ">", 1, n->binaryF.left, n->binaryF.right, true, true, false);
- break;
- case decl_greequal:
- doBinary (p, (const char *) ">=", 2, n->binaryF.left, n->binaryF.right, true, true, false);
- break;
+/*
+ outputEnumerationC -
+*/
- case decl_lessequal:
- doBinary (p, (const char *) "<=", 2, n->binaryF.left, n->binaryF.right, true, true, false);
- break;
+static void outputEnumerationC (mcPretty_pretty p, decl_node__opaque n)
+{
+ unsigned int i;
+ unsigned int h;
+ decl_node__opaque s;
+ DynamicStrings_String t;
- case decl_componentref:
- doComponentRefC (p, n->componentrefF.rec, n->componentrefF.field);
- break;
+ outText (p, (const char *) "enum {", 6);
+ i = Indexing_LowIndice (n->enumerationF.listOfSons);
+ h = Indexing_HighIndice (n->enumerationF.listOfSons);
+ while (i <= h)
+ {
+ s = static_cast<decl_node__opaque> (Indexing_GetIndice (n->enumerationF.listOfSons, i));
+ doFQDNameC (p, s, false);
+ if (i < h)
+ {
+ outText (p, (const char *) ",", 1);
+ mcPretty_setNeedSpace (p);
+ }
+ i += 1;
+ }
+ outText (p, (const char *) "}", 1);
+}
- case decl_pointerref:
- doPointerRefC (p, n->pointerrefF.ptr, n->pointerrefF.field);
- break;
- case decl_cast:
- doCastC (p, n->binaryF.left, n->binaryF.right);
- break;
+/*
+ isDeclType - return TRUE if the current module should declare type.
+*/
- case decl_plus:
- doPolyBinary (p, decl_plus, n->binaryF.left, n->binaryF.right, false, false);
- break;
+static bool isDeclType (decl_node__opaque type)
+{
+ decl_node__opaque n;
+ decl_node__opaque def;
+ nameKey_Name name;
- case decl_sub:
- doPolyBinary (p, decl_sub, n->binaryF.left, n->binaryF.right, false, false);
- break;
+ if (decl_isImp (static_cast<decl_node> (currentModule)))
+ {
+ name = decl_getSymName (static_cast<decl_node> (type));
+ if (name != nameKey_NulName)
+ {
+ /* Lookup the matching .def module. */
+ def = static_cast<decl_node__opaque> (decl_lookupDef (decl_getSymName (static_cast<decl_node> (currentModule))));
+ if (def != NULL)
+ {
+ /* Return TRUE if the symbol has not already been declared in the .def. */
+ return (decl_lookupExported (static_cast<decl_node> (def), name)) == NULL;
+ }
+ }
+ }
+ return true;
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
+}
- case decl_div:
- doBinary (p, (const char *) "/", 1, n->binaryF.left, n->binaryF.right, true, true, false);
- break;
- case decl_mod:
- doBinary (p, (const char *) "%", 1, n->binaryF.left, n->binaryF.right, true, true, false);
- break;
+/*
+ doEnumerationC -
+*/
- case decl_mult:
- doPolyBinary (p, decl_mult, n->binaryF.left, n->binaryF.right, false, false);
- break;
+static void doEnumerationC (mcPretty_pretty p, decl_node__opaque n)
+{
+ if (isDeclType (n))
+ {
+ outputEnumerationC (p, n);
+ }
+}
- case decl_divide:
- doPolyBinary (p, decl_divide, n->binaryF.left, n->binaryF.right, false, false);
- break;
- case decl_in:
- doInC (p, n->binaryF.left, n->binaryF.right);
- break;
+/*
+ doNamesC -
+*/
- case decl_and:
- doBinary (p, (const char *) "&&", 2, n->binaryF.left, n->binaryF.right, true, true, false);
- break;
+static void doNamesC (mcPretty_pretty p, nameKey_Name n)
+{
+ DynamicStrings_String s;
- case decl_or:
- doBinary (p, (const char *) "||", 2, n->binaryF.left, n->binaryF.right, true, true, false);
- break;
+ s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (n));
+ outTextS (p, s);
+ s = DynamicStrings_KillString (s);
+}
- case decl_literal:
- doLiteralC (p, n);
- break;
- case decl_const:
- doConstExpr (p, n);
- break;
+/*
+ doNameC -
+*/
- case decl_enumerationfield:
- doEnumerationField (p, n);
- break;
+static void doNameC (mcPretty_pretty p, decl_node__opaque n)
+{
+ if ((n != NULL) && ((decl_getSymName (static_cast<decl_node> (n))) != nameKey_NulName))
+ {
+ doNamesC (p, decl_getSymName (static_cast<decl_node> (n)));
+ }
+}
- case decl_string:
- doStringC (p, n);
- break;
- case decl_var:
- doVar (p, n);
- break;
+/*
+ initCname -
+*/
- case decl_arrayref:
- doArrayRef (p, n);
- break;
+static void initCname (decl_cnameT *c)
+{
+ (*c).init = false;
+}
- case decl_funccall:
- doFuncExprC (p, n);
- break;
- case decl_procedure:
- doProcedure (p, n);
- break;
+/*
+ doCname -
+*/
- case decl_recordfield:
- doRecordfield (p, n);
- break;
+static nameKey_Name doCname (nameKey_Name n, decl_cnameT *c, bool scopes)
+{
+ DynamicStrings_String s;
- case decl_setvalue:
- doSetValueC (p, n);
- break;
+ if ((*c).init)
+ {
+ return (*c).name;
+ }
+ else
+ {
+ (*c).init = true;
+ s = keyc_cname (n, scopes);
+ if (s == NULL)
+ {
+ (*c).name = n;
+ }
+ else
+ {
+ (*c).name = nameKey_makekey (DynamicStrings_string (s));
+ s = DynamicStrings_KillString (s);
+ }
+ return (*c).name;
+ }
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
+}
- case decl_char:
- case decl_cardinal:
- case decl_longcard:
- case decl_shortcard:
- case decl_integer:
- case decl_longint:
- case decl_shortint:
- case decl_complex:
- case decl_longcomplex:
- case decl_shortcomplex:
- case decl_real:
- case decl_longreal:
- case decl_shortreal:
- case decl_bitset:
- case decl_boolean:
- case decl_proc:
- doBaseC (p, n);
+
+/*
+ getDName -
+*/
+
+static nameKey_Name getDName (decl_node__opaque n, bool scopes)
+{
+ nameKey_Name m;
+
+ m = decl_getSymName (static_cast<decl_node> (n));
+ switch (n->kind)
+ {
+ case decl_procedure:
+ return doCname (m, &n->procedureF.cname, scopes);
break;
- case decl_address:
- case decl_loc:
- case decl_byte:
- case decl_word:
- case decl_csizet:
- case decl_cssizet:
- doSystemC (p, n);
+ case decl_var:
+ return doCname (m, &n->varF.cname, scopes);
break;
- case decl_type:
- doTypeNameC (p, n);
+ case decl_recordfield:
+ return doCname (m, &n->recordfieldF.cname, scopes);
break;
- case decl_pointer:
- doTypeNameC (p, n);
+ case decl_enumerationfield:
+ return doCname (m, &n->enumerationfieldF.cname, scopes);
break;
default:
- CaseException ("../../gcc/m2/mc/decl.def", 20, 1);
- __builtin_unreachable ();
+ break;
}
+ return m;
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
}
/*
- doExprCup -
+ doDNameC -
*/
-static void doExprCup (mcPretty_pretty p, decl_node n, bool unpackProc)
+static void doDNameC (mcPretty_pretty p, decl_node__opaque n, bool scopes)
{
- decl_node t;
-
- doExprC (p, n);
- if (unpackProc)
+ if ((n != NULL) && ((decl_getSymName (static_cast<decl_node> (n))) != nameKey_NulName))
{
- t = decl_skipType (getExprType (n));
- if ((t != NULL) && (isAProcType (t)))
- {
- outText (p, (const char *) ".proc", 5);
- }
+ doNamesC (p, getDName (n, scopes));
}
}
/*
- doExprM2 -
+ doFQDNameC -
*/
-static void doExprM2 (mcPretty_pretty p, decl_node n)
+static void doFQDNameC (mcPretty_pretty p, decl_node__opaque n, bool scopes)
{
- mcDebug_assert (n != NULL);
- switch (n->kind)
- {
- case decl_nil:
- outText (p, (const char *) "NIL", 3);
- break;
+ DynamicStrings_String s;
- case decl_true:
- outText (p, (const char *) "TRUE", 4);
- break;
+ s = getFQDstring (n, scopes);
+ outTextS (p, s);
+ s = DynamicStrings_KillString (s);
+}
- case decl_false:
- outText (p, (const char *) "FALSE", 5);
- break;
- case decl_constexp:
- doUnary (p, (const char *) "", 0, n->unaryF.arg, n->unaryF.resultType, false, false);
- break;
+/*
+ doFQNameC -
+*/
- case decl_neg:
- doUnary (p, (const char *) "-", 1, n->unaryF.arg, n->unaryF.resultType, false, false);
- break;
+static void doFQNameC (mcPretty_pretty p, decl_node__opaque n)
+{
+ DynamicStrings_String s;
- case decl_not:
- doUnary (p, (const char *) "NOT", 3, n->unaryF.arg, n->unaryF.resultType, true, true);
- break;
+ s = getFQstring (n);
+ outTextS (p, s);
+ s = DynamicStrings_KillString (s);
+}
- case decl_adr:
- doUnary (p, (const char *) "ADR", 3, n->unaryF.arg, n->unaryF.resultType, true, true);
- break;
- case decl_size:
- doUnary (p, (const char *) "SIZE", 4, n->unaryF.arg, n->unaryF.resultType, true, true);
- break;
+/*
+ doNameM2 -
+*/
- case decl_tsize:
- doUnary (p, (const char *) "TSIZE", 5, n->unaryF.arg, n->unaryF.resultType, true, true);
- break;
+static void doNameM2 (mcPretty_pretty p, decl_node__opaque n)
+{
+ doNameC (p, n);
+}
- case decl_float:
- doUnary (p, (const char *) "FLOAT", 5, n->unaryF.arg, n->unaryF.resultType, true, true);
- break;
- case decl_trunc:
- doUnary (p, (const char *) "TRUNC", 5, n->unaryF.arg, n->unaryF.resultType, true, true);
- break;
+/*
+ doUsed -
+*/
- case decl_ord:
- doUnary (p, (const char *) "ORD", 3, n->unaryF.arg, n->unaryF.resultType, true, true);
- break;
+static void doUsed (mcPretty_pretty p, bool used)
+{
+ if (! used)
+ {
+ mcPretty_setNeedSpace (p);
+ outText (p, (const char *) "__attribute__((unused))", 23);
+ }
+}
- case decl_chr:
- doUnary (p, (const char *) "CHR", 3, n->unaryF.arg, n->unaryF.resultType, true, true);
- break;
- case decl_cap:
- doUnary (p, (const char *) "CAP", 3, n->unaryF.arg, n->unaryF.resultType, true, true);
- break;
+/*
+ doHighC -
+*/
- case decl_high:
- doUnary (p, (const char *) "HIGH", 4, n->unaryF.arg, n->unaryF.resultType, true, true);
- break;
+static void doHighC (mcPretty_pretty p, decl_node__opaque a, nameKey_Name n, bool isused)
+{
+ if ((decl_isArray (static_cast<decl_node> (a))) && (decl_isUnbounded (static_cast<decl_node> (a))))
+ {
+ /* need to display high. */
+ mcPretty_print (p, (const char *) ",", 1);
+ mcPretty_setNeedSpace (p);
+ doTypeNameC (p, cardinalN);
+ mcPretty_setNeedSpace (p);
+ mcPretty_print (p, (const char *) "_", 1);
+ outTextN (p, n);
+ mcPretty_print (p, (const char *) "_high", 5);
+ doUsed (p, isused);
+ }
+}
- case decl_re:
- doUnary (p, (const char *) "RE", 2, n->unaryF.arg, n->unaryF.resultType, true, true);
- break;
- case decl_im:
- doUnary (p, (const char *) "IM", 2, n->unaryF.arg, n->unaryF.resultType, true, true);
- break;
+/*
+ doParamConstCast -
+*/
- case decl_deref:
- doPostUnary (p, (const char *) "^", 1, n->unaryF.arg);
- break;
+static void doParamConstCast (mcPretty_pretty p, decl_node__opaque n)
+{
+ decl_node__opaque ptype;
- case decl_equal:
- doBinary (p, (const char *) "=", 1, n->binaryF.left, n->binaryF.right, true, true, false);
- break;
+ ptype = static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (n)));
+ if (((decl_isArray (static_cast<decl_node> (ptype))) && (decl_isUnbounded (static_cast<decl_node> (ptype)))) && (lang == decl_ansiCP))
+ {
+ outText (p, (const char *) "const", 5);
+ mcPretty_setNeedSpace (p);
+ }
+}
- case decl_notequal:
- doBinary (p, (const char *) "#", 1, n->binaryF.left, n->binaryF.right, true, true, false);
- break;
- case decl_less:
- doBinary (p, (const char *) "<", 1, n->binaryF.left, n->binaryF.right, true, true, false);
- break;
+/*
+ getParameterVariable - returns the variable which shadows the parameter
+ named, m, in parameter block, n.
+*/
- case decl_greater:
- doBinary (p, (const char *) ">", 1, n->binaryF.left, n->binaryF.right, true, true, false);
- break;
+static decl_node__opaque getParameterVariable (decl_node__opaque n, nameKey_Name m)
+{
+ decl_node__opaque p;
- case decl_greequal:
- doBinary (p, (const char *) ">=", 2, n->binaryF.left, n->binaryF.right, true, true, false);
- break;
+ mcDebug_assert ((decl_isParam (static_cast<decl_node> (n))) || (decl_isVarParam (static_cast<decl_node> (n))));
+ if (decl_isParam (static_cast<decl_node> (n)))
+ {
+ p = n->paramF.scope;
+ }
+ else
+ {
+ p = n->varparamF.scope;
+ }
+ mcDebug_assert (decl_isProcedure (static_cast<decl_node> (p)));
+ return static_cast<decl_node__opaque> (decl_lookupInScope (static_cast<decl_node> (p), m));
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
+}
- case decl_lessequal:
- doBinary (p, (const char *) "<=", 2, n->binaryF.left, n->binaryF.right, true, true, false);
- break;
- case decl_componentref:
- doBinary (p, (const char *) ".", 1, n->componentrefF.rec, n->componentrefF.field, false, false, false);
- break;
+/*
+ doParamTypeEmit - emit parameter type for C/C++. It checks to see if the
+ parameter type is a procedure type and if it were declared
+ in a definition module for "C" and if so it uses the "C"
+ definition for a procedure type, rather than the mc
+ C++ version.
+*/
- case decl_pointerref:
- doBinary (p, (const char *) "^.", 2, n->pointerrefF.ptr, n->pointerrefF.field, false, false, false);
- break;
+static void doParamTypeEmit (mcPretty_pretty p, decl_node__opaque paramnode, decl_node__opaque paramtype)
+{
+ mcDebug_assert ((decl_isParam (static_cast<decl_node> (paramnode))) || (decl_isVarParam (static_cast<decl_node> (paramnode))));
+ if ((isForC (paramnode)) && (decl_isProcType (decl_skipType (static_cast<decl_node> (paramtype)))))
+ {
+ doFQNameC (p, paramtype);
+ outText (p, (const char *) "_C", 2);
+ }
+ else
+ {
+ doTypeNameC (p, paramtype);
+ doOpaqueModifier (p, paramnode);
+ }
+ /*
+ IF nodeUsesOpaque (paramnode) AND (NOT getNodeOpaqueVoidStar (paramnode))
+ THEN
+ outText (p, '__opaque')
+ END
+ */
+}
- case decl_cast:
- doPreBinary (p, (const char *) "CAST", 4, n->binaryF.left, n->binaryF.right, true, true);
- break;
- case decl_val:
- doPreBinary (p, (const char *) "VAL", 3, n->binaryF.left, n->binaryF.right, true, true);
- break;
+/*
+ doParamTypeNameModifier - Add an _ to an unbounded parameter which is non var.
+*/
- case decl_cmplx:
- doPreBinary (p, (const char *) "CMPLX", 5, n->binaryF.left, n->binaryF.right, true, true);
- break;
+static void doParamTypeNameModifier (mcPretty_pretty p, decl_node__opaque ptype, bool varparam)
+{
+ if ((! varparam && (decl_isArray (static_cast<decl_node> (ptype)))) && (decl_isUnbounded (static_cast<decl_node> (ptype))))
+ {
+ outText (p, (const char *) "_", 1);
+ }
+}
- case decl_plus:
- doBinary (p, (const char *) "+", 1, n->binaryF.left, n->binaryF.right, false, false, false);
+
+/*
+ initOpaqueCastState - assign fields opaque and voidstar in opaquestate.
+*/
+
+static void initOpaqueCastState (decl_opaqueCastState *opaquestate, bool opaque, bool voidstar)
+{
+ (*opaquestate).opaque = opaque;
+ (*opaquestate).voidStar = voidstar;
+}
+
+
+/*
+ initNodeOpaqueCastState - assign opaque and currentvoidstar
+*/
+
+static void initNodeOpaqueCastState (decl_node__opaque n, bool opaque, bool voidstar)
+{
+ switch (n->kind)
+ {
+ case decl_opaquecast:
+ initOpaqueCastState (&n->opaquecastF.opaqueState, opaque, voidstar);
break;
- case decl_sub:
- doBinary (p, (const char *) "-", 1, n->binaryF.left, n->binaryF.right, false, false, false);
+ case decl_funccall:
+ initOpaqueCastState (&n->funccallF.opaqueState, opaque, voidstar);
break;
- case decl_div:
- doBinary (p, (const char *) "DIV", 3, n->binaryF.left, n->binaryF.right, true, true, false);
+ case decl_var:
+ initOpaqueCastState (&n->varF.opaqueState, opaque, voidstar);
break;
- case decl_mod:
- doBinary (p, (const char *) "MOD", 3, n->binaryF.left, n->binaryF.right, true, true, false);
+ case decl_array:
+ initOpaqueCastState (&n->arrayF.opaqueState, opaque, voidstar);
break;
- case decl_mult:
- doBinary (p, (const char *) "*", 1, n->binaryF.left, n->binaryF.right, false, false, false);
+ case decl_varparam:
+ initOpaqueCastState (&n->varparamF.opaqueState, opaque, voidstar);
break;
- case decl_divide:
- doBinary (p, (const char *) "/", 1, n->binaryF.left, n->binaryF.right, false, false, false);
+ case decl_param:
+ initOpaqueCastState (&n->paramF.opaqueState, opaque, voidstar);
break;
- case decl_literal:
- doLiteral (p, n);
+ case decl_pointer:
+ initOpaqueCastState (&n->pointerF.opaqueState, opaque, voidstar);
break;
- case decl_const:
- doConstExpr (p, n);
+ case decl_recordfield:
+ initOpaqueCastState (&n->recordfieldF.opaqueState, opaque, voidstar);
break;
- case decl_enumerationfield:
- doEnumerationField (p, n);
+ case decl_componentref:
+ initOpaqueCastState (&n->componentrefF.opaqueState, opaque, voidstar);
break;
- case decl_string:
- doString (p, n);
+ case decl_pointerref:
+ initOpaqueCastState (&n->pointerrefF.opaqueState, opaque, voidstar);
break;
- case decl_max:
- doUnary (p, (const char *) "MAX", 3, n->unaryF.arg, n->unaryF.resultType, true, true);
+ case decl_arrayref:
+ initOpaqueCastState (&n->arrayrefF.opaqueState, opaque, voidstar);
break;
- case decl_min:
- doUnary (p, (const char *) "MIN", 3, n->unaryF.arg, n->unaryF.resultType, true, true);
+ case decl_procedure:
+ initOpaqueCastState (&n->procedureF.opaqueState, opaque, voidstar);
break;
- case decl_var:
- doVar (p, n);
+ case decl_proctype:
+ initOpaqueCastState (&n->proctypeF.opaqueState, opaque, voidstar);
break;
default:
- CaseException ("../../gcc/m2/mc/decl.def", 20, 1);
+ M2RTS_HALT (-1);
__builtin_unreachable ();
+ break;
}
}
/*
- doVar -
+ setOpaqueCastState - set the voidStar field in opaquestate.
*/
-static void doVar (mcPretty_pretty p, decl_node n)
+static void setOpaqueCastState (decl_opaqueCastState *opaquestate, bool voidstar)
{
- mcDebug_assert (decl_isVar (n));
- if (n->varF.isVarParameter)
- {
- outText (p, (const char *) "(*", 2);
- doFQDNameC (p, n, true);
- outText (p, (const char *) ")", 1);
- }
- else
- {
- doFQDNameC (p, n, true);
- }
+ (*opaquestate).voidStar = voidstar;
}
/*
- doLiteralC -
+ setNodeOpaqueVoidStar - sets the voidStar field in node to voidstar.
*/
-static void doLiteralC (mcPretty_pretty p, decl_node n)
+static void setNodeOpaqueVoidStar (decl_node__opaque n, bool voidstar)
{
- DynamicStrings_String s;
-
- mcDebug_assert (decl_isLiteral (n));
- s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (n)));
- if (n->literalF.type == charN)
- {
- if ((DynamicStrings_char (s, -1)) == 'C')
- {
- s = DynamicStrings_Slice (DynamicStrings_Mark (s), 0, -1);
- if ((DynamicStrings_char (s, 0)) != '0')
- {
- s = DynamicStrings_ConCat (DynamicStrings_InitString ((const char *) "0", 1), DynamicStrings_Mark (s));
- }
- }
- outText (p, (const char *) "(char)", 6);
- mcPretty_setNeedSpace (p);
- }
- else if ((DynamicStrings_char (s, -1)) == 'H')
- {
- /* avoid dangling else. */
- outText (p, (const char *) "0x", 2);
- s = DynamicStrings_Slice (DynamicStrings_Mark (s), 0, -1);
- }
- else if ((DynamicStrings_char (s, -1)) == 'B')
+ mcDebug_assert (nodeUsesOpaque (n));
+ switch (n->kind)
{
- /* avoid dangling else. */
- outText (p, (const char *) "0", 1);
- s = DynamicStrings_Slice (DynamicStrings_Mark (s), 0, -1);
- }
- outTextS (p, s);
- s = DynamicStrings_KillString (s);
-}
-
-
-/*
- doLiteral -
-*/
+ case decl_opaquecast:
+ setOpaqueCastState (&n->opaquecastF.opaqueState, voidstar);
+ break;
-static void doLiteral (mcPretty_pretty p, decl_node n)
-{
- DynamicStrings_String s;
+ case decl_funccall:
+ setOpaqueCastState (&n->funccallF.opaqueState, voidstar);
+ break;
- mcDebug_assert (decl_isLiteral (n));
- s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (n)));
- if (n->literalF.type == charN)
- {
- if ((DynamicStrings_char (s, -1)) == 'C')
- {
- s = DynamicStrings_Slice (DynamicStrings_Mark (s), 0, -1);
- if ((DynamicStrings_char (s, 0)) != '0')
- {
- s = DynamicStrings_ConCat (DynamicStrings_InitString ((const char *) "0", 1), DynamicStrings_Mark (s));
- }
- }
- outText (p, (const char *) "(char)", 6);
- mcPretty_setNeedSpace (p);
- }
- outTextS (p, s);
- s = DynamicStrings_KillString (s);
-}
+ case decl_var:
+ setOpaqueCastState (&n->varF.opaqueState, voidstar);
+ break;
+ case decl_array:
+ setOpaqueCastState (&n->arrayF.opaqueState, voidstar);
+ break;
-/*
- isString - returns TRUE if node, n, is a string.
-*/
+ case decl_varparam:
+ setOpaqueCastState (&n->varparamF.opaqueState, voidstar);
+ break;
-static bool isString (decl_node n)
-{
- mcDebug_assert (n != NULL);
- return n->kind == decl_string;
- /* static analysis guarentees a RETURN statement will be used before here. */
- __builtin_unreachable ();
-}
+ case decl_param:
+ setOpaqueCastState (&n->paramF.opaqueState, voidstar);
+ break;
+ case decl_pointer:
+ setOpaqueCastState (&n->pointerF.opaqueState, voidstar);
+ break;
-/*
- doString -
-*/
+ case decl_recordfield:
+ setOpaqueCastState (&n->recordfieldF.opaqueState, voidstar);
+ break;
-static void doString (mcPretty_pretty p, decl_node n)
-{
- DynamicStrings_String s;
+ case decl_componentref:
+ mcDebug_assert (! voidstar);
+ setOpaqueCastState (&n->componentrefF.opaqueState, voidstar);
+ break;
- mcDebug_assert (isString (n));
- s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (n)));
- outTextS (p, s);
- s = DynamicStrings_KillString (s);
- /*
- IF DynamicStrings.Index (s, '"', 0)=-1
- THEN
- outText (p, '"') ;
- outTextS (p, s) ;
- outText (p, '"')
- ELSIF DynamicStrings.Index (s, "'", 0)=-1
- THEN
- outText (p, '"') ;
- outTextS (p, s) ;
- outText (p, '"')
- ELSE
- metaError1 ('illegal string {%1k}', n)
- END
- */
- M2RTS_HALT (-1);
- __builtin_unreachable ();
-}
+ case decl_pointerref:
+ mcDebug_assert (! voidstar);
+ setOpaqueCastState (&n->pointerrefF.opaqueState, voidstar);
+ break;
+ case decl_arrayref:
+ setOpaqueCastState (&n->arrayrefF.opaqueState, voidstar);
+ break;
-/*
- replaceChar - replace every occurance of, ch, by, a and return modified string, s.
-*/
+ case decl_procedure:
+ setOpaqueCastState (&n->procedureF.opaqueState, voidstar);
+ break;
-static DynamicStrings_String replaceChar (DynamicStrings_String s, char ch, const char *a_, unsigned int _a_high)
-{
- int i;
- char a[_a_high+1];
+ case decl_proctype:
+ setOpaqueCastState (&n->proctypeF.opaqueState, voidstar);
+ break;
- /* make a local copy of each unbounded array. */
- memcpy (a, a_, _a_high+1);
- i = 0;
- for (;;)
- {
- i = DynamicStrings_Index (s, ch, static_cast<unsigned int> (i));
- if (i == 0)
- {
- s = DynamicStrings_ConCat (DynamicStrings_InitString ((const char *) a, _a_high), DynamicStrings_Slice (s, 1, 0));
- i = StrLib_StrLen ((const char *) a, _a_high);
- }
- else if (i > 0)
- {
- /* avoid dangling else. */
- s = DynamicStrings_ConCat (DynamicStrings_ConCat (DynamicStrings_Slice (s, 0, i), DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high))), DynamicStrings_Slice (s, i+1, 0));
- i += StrLib_StrLen ((const char *) a, _a_high);
- }
- else
- {
- /* avoid dangling else. */
- return s;
- }
- }
- ReturnException ("../../gcc/m2/mc/decl.def", 20, 1);
- __builtin_unreachable ();
+ default:
+ M2RTS_HALT (-1);
+ __builtin_unreachable ();
+ break;
+ }
}
/*
- toCstring - translates string, n, into a C string
- and returns the new String.
+ nodeUsesOpaque - return TRUE if node n uses an opaque type.
*/
-static DynamicStrings_String toCstring (nameKey_Name n)
+static bool nodeUsesOpaque (decl_node__opaque n)
{
- DynamicStrings_String s;
-
- s = DynamicStrings_Slice (DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (n)), 1, -1);
- return replaceChar (replaceChar (s, '\\', (const char *) "\\\\", 2), '"', (const char *) "\\\"", 2);
- /* static analysis guarentees a RETURN statement will be used before here. */
- __builtin_unreachable ();
-}
-
+ switch (n->kind)
+ {
+ case decl_opaquecast:
+ return n->opaquecastF.opaqueState.opaque;
+ break;
-/*
- toCchar -
-*/
+ case decl_funccall:
+ return n->funccallF.opaqueState.opaque;
+ break;
-static DynamicStrings_String toCchar (nameKey_Name n)
-{
- DynamicStrings_String s;
+ case decl_var:
+ return n->varF.opaqueState.opaque;
+ break;
- s = DynamicStrings_Slice (DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (n)), 1, -1);
- return replaceChar (replaceChar (s, '\\', (const char *) "\\\\", 2), '\'', (const char *) "\\'", 2);
- /* static analysis guarentees a RETURN statement will be used before here. */
- __builtin_unreachable ();
-}
+ case decl_array:
+ return n->arrayF.opaqueState.opaque;
+ break;
+ case decl_varparam:
+ return n->varparamF.opaqueState.opaque;
+ break;
-/*
- countChar -
-*/
+ case decl_param:
+ return n->paramF.opaqueState.opaque;
+ break;
-static unsigned int countChar (DynamicStrings_String s, char ch)
-{
- int i;
- unsigned int c;
+ case decl_pointer:
+ return n->pointerF.opaqueState.opaque;
+ break;
- c = 0;
- i = 0;
- for (;;)
- {
- i = DynamicStrings_Index (s, ch, static_cast<unsigned int> (i));
- if (i >= 0)
- {
- i += 1;
- c += 1;
- }
- else
- {
- return c;
- }
- }
- ReturnException ("../../gcc/m2/mc/decl.def", 20, 1);
- __builtin_unreachable ();
-}
+ case decl_recordfield:
+ return n->recordfieldF.opaqueState.opaque;
+ break;
+ case decl_componentref:
+ return n->componentrefF.opaqueState.opaque;
+ break;
-/*
- lenCstring -
-*/
+ case decl_pointerref:
+ return n->pointerrefF.opaqueState.opaque;
+ break;
-static unsigned int lenCstring (DynamicStrings_String s)
-{
- return (DynamicStrings_Length (s))-(countChar (s, '\\'));
+ case decl_arrayref:
+ return n->arrayrefF.opaqueState.opaque;
+ break;
+
+ case decl_procedure:
+ return n->procedureF.opaqueState.opaque;
+ break;
+
+ case decl_proctype:
+ return n->proctypeF.opaqueState.opaque;
+ break;
+
+ case decl_deref:
+ return nodeUsesOpaque (n->unaryF.arg);
+ break;
+
+
+ default:
+ return false;
+ break;
+ }
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
/*
- outCstring -
+ getNodeOpaqueVoidStar - return TRUE if the opaque type used by node n is a void *.
*/
-static void outCstring (mcPretty_pretty p, decl_node s, bool aString)
+static bool getNodeOpaqueVoidStar (decl_node__opaque n)
{
- if (aString)
- {
- outText (p, (const char *) "\"", 1);
- outRawS (p, s->stringF.cstring);
- outText (p, (const char *) "\"", 1);
- }
- else
+ mcDebug_assert (nodeUsesOpaque (n));
+ switch (n->kind)
{
- outText (p, (const char *) "'", 1);
- outRawS (p, s->stringF.cchar);
- outText (p, (const char *) "'", 1);
- }
-}
+ case decl_opaquecast:
+ return n->opaquecastF.opaqueState.voidStar;
+ break;
+ case decl_funccall:
+ return n->funccallF.opaqueState.voidStar;
+ break;
-/*
- doStringC -
-*/
+ case decl_var:
+ return n->varF.opaqueState.voidStar;
+ break;
-static void doStringC (mcPretty_pretty p, decl_node n)
-{
- DynamicStrings_String s;
+ case decl_array:
+ return n->arrayF.opaqueState.voidStar;
+ break;
- mcDebug_assert (isString (n));
- /*
- s := InitStringCharStar (keyToCharStar (getSymName (n))) ;
- IF DynamicStrings.Length (s)>3
- THEN
- IF DynamicStrings.Index (s, '"', 0)=-1
- THEN
- s := DynamicStrings.Slice (s, 1, -1) ;
- outText (p, '"') ;
- outCstring (p, s) ;
- outText (p, '"')
- ELSIF DynamicStrings.Index (s, "'", 0)=-1
- THEN
- s := DynamicStrings.Slice (s, 1, -1) ;
- outText (p, '"') ;
- outCstring (p, s) ;
- outText (p, '"')
- ELSE
- metaError1 ('illegal string {%1k}', n)
- END
- ELSIF DynamicStrings.Length (s) = 3
- THEN
- s := DynamicStrings.Slice (s, 1, -1) ;
- outText (p, "'") ;
- IF DynamicStrings.char (s, 0) = "'"
- THEN
- outText (p, "\'")
- ELSIF DynamicStrings.char (s, 0) = "\"
- THEN
- outText (p, "\\")
- ELSE
- outTextS (p, s)
- END ;
- outText (p, "'")
- ELSE
- outText (p, "'\0'")
- END ;
- s := KillString (s)
- */
- outCstring (p, n, ! n->stringF.isCharCompatible);
-}
+ case decl_varparam:
+ return n->varparamF.opaqueState.voidStar;
+ break;
+ case decl_param:
+ return n->paramF.opaqueState.voidStar;
+ break;
-/*
- isPunct -
-*/
+ case decl_pointer:
+ return n->pointerF.opaqueState.voidStar;
+ break;
-static bool isPunct (char ch)
-{
- return (((((((((ch == '.') || (ch == '(')) || (ch == ')')) || (ch == '^')) || (ch == ':')) || (ch == ';')) || (ch == '{')) || (ch == '}')) || (ch == ',')) || (ch == '*');
- /* static analysis guarentees a RETURN statement will be used before here. */
- __builtin_unreachable ();
-}
+ case decl_recordfield:
+ return n->recordfieldF.opaqueState.voidStar;
+ break;
+ case decl_componentref:
+ return n->componentrefF.opaqueState.voidStar;
+ break;
-/*
- isWhite -
-*/
+ case decl_pointerref:
+ return n->pointerrefF.opaqueState.voidStar;
+ break;
-static bool isWhite (char ch)
-{
- return ((ch == ' ') || (ch == ASCII_tab)) || (ch == ASCII_lf);
- /* static analysis guarentees a RETURN statement will be used before here. */
- __builtin_unreachable ();
-}
+ case decl_arrayref:
+ return n->arrayrefF.opaqueState.voidStar;
+ break;
+ case decl_procedure:
+ return n->procedureF.opaqueState.voidStar;
+ break;
-/*
- outText -
-*/
+ case decl_proctype:
+ return n->proctypeF.opaqueState.voidStar;
+ break;
-static void outText (mcPretty_pretty p, const char *a_, unsigned int _a_high)
-{
- DynamicStrings_String s;
- char a[_a_high+1];
+ case decl_deref:
+ return false;
+ break;
- /* make a local copy of each unbounded array. */
- memcpy (a, a_, _a_high+1);
- s = DynamicStrings_InitString ((const char *) a, _a_high);
- outTextS (p, s);
- s = DynamicStrings_KillString (s);
+ default:
+ M2RTS_HALT (-1);
+ __builtin_unreachable ();
+ break;
+ }
+ ReturnException ("../../gcc/m2/mc/decl.def", 20, 1);
+ __builtin_unreachable ();
}
/*
- outRawS -
+ getOpaqueFlushNecessary - return TRUE if the value next differs from the opaque state.
*/
-static void outRawS (mcPretty_pretty p, DynamicStrings_String s)
+static bool getOpaqueFlushNecessary (decl_opaqueCastState state, bool next)
{
- mcPretty_raw (p, s);
+ return state.opaque && (state.voidStar != next);
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
}
/*
- outKm2 -
+ getNodeOpaqueFlushNecessary - return TRUE if the value of next requires a cast.
*/
-static mcPretty_pretty outKm2 (mcPretty_pretty p, const char *a_, unsigned int _a_high)
+static bool getNodeOpaqueFlushNecessary (decl_node__opaque n, bool next)
{
- unsigned int i;
- DynamicStrings_String s;
- char a[_a_high+1];
+ switch (n->kind)
+ {
+ case decl_opaquecast:
+ return getOpaqueFlushNecessary (n->opaquecastF.opaqueState, next);
+ break;
- /* make a local copy of each unbounded array. */
- memcpy (a, a_, _a_high+1);
+ case decl_funccall:
+ return getOpaqueFlushNecessary (n->funccallF.opaqueState, next);
+ break;
- if (StrLib_StrEqual ((const char *) a, _a_high, (const char *) "RECORD", 6))
- {
- p = mcPretty_pushPretty (p);
- i = mcPretty_getcurpos (p);
- mcPretty_setindent (p, i);
- outText (p, (const char *) a, _a_high);
- p = mcPretty_pushPretty (p);
- mcPretty_setindent (p, i+indentation);
- }
- else if (StrLib_StrEqual ((const char *) a, _a_high, (const char *) "END", 3))
- {
- /* avoid dangling else. */
- p = mcPretty_popPretty (p);
- outText (p, (const char *) a, _a_high);
- p = mcPretty_popPretty (p);
- }
- return p;
- /* static analysis guarentees a RETURN statement will be used before here. */
- __builtin_unreachable ();
-}
+ case decl_var:
+ return getOpaqueFlushNecessary (n->varF.opaqueState, next);
+ break;
+ case decl_array:
+ return getOpaqueFlushNecessary (n->arrayF.opaqueState, next);
+ break;
-/*
- outKc -
-*/
+ case decl_varparam:
+ return getOpaqueFlushNecessary (n->varparamF.opaqueState, next);
+ break;
-static mcPretty_pretty outKc (mcPretty_pretty p, const char *a_, unsigned int _a_high)
-{
- int i;
- unsigned int c;
- DynamicStrings_String s;
- DynamicStrings_String t;
- char a[_a_high+1];
+ case decl_param:
+ return getOpaqueFlushNecessary (n->paramF.opaqueState, next);
+ break;
- /* make a local copy of each unbounded array. */
- memcpy (a, a_, _a_high+1);
+ case decl_pointer:
+ return getOpaqueFlushNecessary (n->pointerF.opaqueState, next);
+ break;
- s = DynamicStrings_InitString ((const char *) a, _a_high);
- i = DynamicStrings_Index (s, '\\', 0);
- if (i == -1)
- {
- t = NULL;
- }
- else
- {
- t = DynamicStrings_Slice (s, i, 0);
- s = DynamicStrings_Slice (DynamicStrings_Mark (s), 0, i);
- }
- if ((DynamicStrings_char (s, 0)) == '{')
- {
- p = mcPretty_pushPretty (p);
- c = mcPretty_getcurpos (p);
- mcPretty_setindent (p, c);
- outTextS (p, s);
- p = mcPretty_pushPretty (p);
- mcPretty_setindent (p, c+indentationC);
- }
- else if ((DynamicStrings_char (s, 0)) == '}')
- {
- /* avoid dangling else. */
- p = mcPretty_popPretty (p);
- outTextS (p, s);
- p = mcPretty_popPretty (p);
- }
- outTextS (p, t);
- t = DynamicStrings_KillString (t);
- s = DynamicStrings_KillString (s);
- return p;
- /* static analysis guarentees a RETURN statement will be used before here. */
- __builtin_unreachable ();
-}
+ case decl_recordfield:
+ return getOpaqueFlushNecessary (n->recordfieldF.opaqueState, next);
+ break;
+
+ case decl_componentref:
+ return getOpaqueFlushNecessary (n->componentrefF.opaqueState, next);
+ break;
+
+ case decl_pointerref:
+ return getOpaqueFlushNecessary (n->pointerrefF.opaqueState, next);
+ break;
+
+ case decl_arrayref:
+ return getOpaqueFlushNecessary (n->arrayrefF.opaqueState, next);
+ break;
+ case decl_procedure:
+ return getOpaqueFlushNecessary (n->procedureF.opaqueState, next);
+ break;
-/*
- outTextS -
-*/
+ case decl_proctype:
+ return getOpaqueFlushNecessary (n->proctypeF.opaqueState, next);
+ break;
-static void outTextS (mcPretty_pretty p, DynamicStrings_String s)
-{
- if (s != NULL)
- {
- mcPretty_prints (p, s);
+
+ default:
+ return false;
+ break;
}
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
}
/*
- outCard -
+ makeOpaqueCast - wrap node n with an opaquecast node and assign
+ voidstar into the new opaque state.
*/
-static void outCard (mcPretty_pretty p, unsigned int c)
+static decl_node__opaque makeOpaqueCast (decl_node__opaque n, bool voidstar)
{
- DynamicStrings_String s;
+ decl_node__opaque o;
- s = StringConvert_CardinalToString (c, 0, ' ', 10, false);
- outTextS (p, s);
- s = DynamicStrings_KillString (s);
+ o = newNode (decl_opaquecast);
+ o->opaquecastF.exp = n;
+ initOpaqueCastState (&o->opaquecastF.opaqueState, true, voidstar);
+ return o;
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
}
/*
- outTextN -
+ flushOpaque - perform a cast to voidstar (if necessary) and ignore the new
+ node which could be created.
*/
-static void outTextN (mcPretty_pretty p, nameKey_Name n)
+static void flushOpaque (mcPretty_pretty p, decl_node__opaque n, bool toVoidStar)
{
- DynamicStrings_String s;
+ decl_node__opaque o;
- s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (n));
- mcPretty_prints (p, s);
- s = DynamicStrings_KillString (s);
+ o = castOpaque (p, n, toVoidStar);
}
/*
- doTypeAliasC -
+ castOpaque - flushes the opaque type casts if necessary and changes the
+ voidstar boolean value. If necessary it creates a opaquecast
+ and returns the new node otherwise return n.
*/
-static void doTypeAliasC (mcPretty_pretty p, decl_node n, decl_node *m)
+static decl_node__opaque castOpaque (mcPretty_pretty p, decl_node__opaque n, bool toVoidStar)
{
- mcPretty_print (p, (const char *) "typedef", 7);
- mcPretty_setNeedSpace (p);
- if ((decl_isTypeHidden (n)) && ((decl_isDef (decl_getMainModule ())) || ((decl_getScope (n)) != (decl_getMainModule ()))))
+ decl_node__opaque type;
+
+ if (getNodeOpaqueFlushNecessary (n, toVoidStar))
{
- outText (p, (const char *) "void *", 6);
+ type = static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (n)));
+ if (toVoidStar)
+ {
+ /* next is true cast to void * opaque type. */
+ outText (p, (const char *) "static_cast<", 12);
+ doTypeNameC (p, type);
+ mcPretty_noSpace (p);
+ outText (p, (const char *) "> (", 3);
+ doExprC (p, n);
+ outText (p, (const char *) ")", 1);
+ return makeOpaqueCast (n, true);
+ }
+ else
+ {
+ /* next is false cast to __opaque opaque type. */
+ outText (p, (const char *) "static_cast<", 12);
+ doTypeNameC (p, type);
+ outText (p, (const char *) "__opaque", 8);
+ mcPretty_noSpace (p);
+ outText (p, (const char *) "> (", 3);
+ doExprC (p, n);
+ outText (p, (const char *) ")", 1);
+ return makeOpaqueCast (n, false);
+ }
}
else
{
- doTypeC (p, decl_getType (n), m);
- }
- if ((*m) != NULL)
- {
- doFQNameC (p, (*m));
+ if (debugOpaque)
+ {
+ doP = p;
+ dumpOpaqueState (n);
+ if (nodeUsesOpaque (n))
+ {
+ outText (p, (const char *) " /* no difference seen */ ", 26);
+ }
+ else
+ {
+ outText (p, (const char *) " /* no opaque used */ ", 22);
+ }
+ }
+ doExprC (p, n);
}
- mcPretty_print (p, (const char *) ";\\n\\n", 5);
+ return n;
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
}
/*
- doEnumerationC -
+ isTypeOpaqueDefImp - returns TRUE if type is an opaque type by checking
+ the def/imp pair of modules or fall back to the
+ definition module.
*/
-static void doEnumerationC (mcPretty_pretty p, decl_node n)
+static bool isTypeOpaqueDefImp (decl_node__opaque type)
{
- unsigned int i;
- unsigned int h;
- decl_node s;
- DynamicStrings_String t;
+ decl_node__opaque scope;
+ decl_node__opaque def;
+ decl_node__opaque opaque;
- outText (p, (const char *) "enum {", 6);
- i = Indexing_LowIndice (n->enumerationF.listOfSons);
- h = Indexing_HighIndice (n->enumerationF.listOfSons);
- while (i <= h)
+ if (type == NULL)
{
- s = static_cast<decl_node> (Indexing_GetIndice (n->enumerationF.listOfSons, i));
- doFQDNameC (p, s, false);
- if (i < h)
+ return false;
+ }
+ else if (decl_isType (static_cast<decl_node> (type)))
+ {
+ /* avoid dangling else. */
+ scope = static_cast<decl_node__opaque> (decl_getScope (static_cast<decl_node> (type)));
+ if (decl_isImp (static_cast<decl_node> (scope)))
{
- outText (p, (const char *) ",", 1);
- mcPretty_setNeedSpace (p);
+ /* avoid dangling else. */
+ def = static_cast<decl_node__opaque> (decl_lookupDef (decl_getSymName (static_cast<decl_node> (scope))));
+ if (def != NULL)
+ {
+ /* Lookup the type name in the matching definition module. */
+ opaque = static_cast<decl_node__opaque> (decl_lookupExported (static_cast<decl_node> (def), decl_getSymName (static_cast<decl_node> (type))));
+ return ((opaque != NULL) && (decl_isType (static_cast<decl_node> (opaque)))) && (decl_isTypeOpaque (static_cast<decl_node> (opaque)));
+ }
+ }
+ else
+ {
+ /* Otherwise just check the definition module. */
+ return decl_isTypeOpaque (static_cast<decl_node> (type));
}
- i += 1;
}
- outText (p, (const char *) "}", 1);
+ return false;
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
}
/*
- doNamesC -
+ isParamVoidStar - return TRUE if the procedure or proctype opaque type
+ parameter should be implemented as a (void * ).
*/
-static void doNamesC (mcPretty_pretty p, nameKey_Name n)
+static bool isParamVoidStar (decl_node__opaque n)
{
- DynamicStrings_String s;
+ decl_node__opaque proc;
+ decl_node__opaque type;
- s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (n));
- outTextS (p, s);
- s = DynamicStrings_KillString (s);
+ proc = static_cast<decl_node__opaque> (decl_getScope (static_cast<decl_node> (n)));
+ mcDebug_assert ((decl_isProcedure (static_cast<decl_node> (proc))) || (decl_isProcType (static_cast<decl_node> (proc))));
+ type = static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (n)));
+ return isReturnVoidStar (proc, type);
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
}
/*
- doNameC -
+ isRefVoidStar - returns TRUE if the ref node uses an opaque type which
+ is represented as a (void * ).
*/
-static void doNameC (mcPretty_pretty p, decl_node n)
+static bool isRefVoidStar (decl_node__opaque n)
{
- if ((n != NULL) && ((decl_getSymName (n)) != nameKey_NulName))
+ decl_node__opaque type;
+
+ type = static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (n)));
+ if ((! (decl_isType (static_cast<decl_node> (type)))) || (! (decl_isTypeOpaque (static_cast<decl_node> (type)))))
{
- doNamesC (p, decl_getSymName (n));
+ /* We should finish the procedure as the ref does not use an opaque. */
+ return true;
}
+ else
+ {
+ /* We check whether the opaque type was declared in the implementation
+ module. If it is declared in the implementation module then we
+ return FALSE. */
+ return ! (isDeclInImp (type));
+ }
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
}
/*
- initCname -
-*/
-
-static void initCname (decl_cnameT *c)
-{
- (*c).init = false;
-}
-
-
-/*
- doCname -
+ isReturnVoidStar - return TRUE if the procedure or proctype opaque type
+ return type should be implemented as a (void * ).
*/
-static nameKey_Name doCname (nameKey_Name n, decl_cnameT *c, bool scopes)
+static bool isReturnVoidStar (decl_node__opaque proc, decl_node__opaque type)
{
- DynamicStrings_String s;
+ decl_node__opaque def;
- if ((*c).init)
+ mcDebug_assert ((decl_isProcedure (static_cast<decl_node> (proc))) || (decl_isProcType (static_cast<decl_node> (proc))));
+ if (decl_isExported (static_cast<decl_node> (proc)))
{
- return (*c).name;
+ return true;
}
else
{
- (*c).init = true;
- s = keyc_cname (n, scopes);
- if (s == NULL)
+ /* Not exported therefore local, we check whether the opaque type
+ was declared in the implementation module. */
+ if (decl_isImp (static_cast<decl_node> (currentModule)))
{
- (*c).name = n;
+ if (decl_isType (static_cast<decl_node> (type)))
+ {
+ return ! (isDeclInImp (type));
+ }
+ else
+ {
+ return false;
+ }
}
else
{
- (*c).name = nameKey_makekey (DynamicStrings_string (s));
- s = DynamicStrings_KillString (s);
+ /* Always use void * in .def modules. */
+ return true;
}
- return (*c).name;
}
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
/*
- getDName -
+ isVarVoidStar - return TRUE if the variable using an opaque type should
+ be implemented as a (void * ).
*/
-static nameKey_Name getDName (decl_node n, bool scopes)
+static bool isVarVoidStar (decl_node__opaque n)
{
- nameKey_Name m;
+ decl_node__opaque type;
- m = decl_getSymName (n);
- switch (n->kind)
+ mcDebug_assert (decl_isVar (static_cast<decl_node> (n)));
+ type = static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (n)));
+ if ((! (decl_isType (static_cast<decl_node> (type)))) || (! (decl_isTypeOpaque (static_cast<decl_node> (type)))))
{
- case decl_procedure:
- return doCname (m, &n->procedureF.cname, scopes);
- break;
-
- case decl_var:
- return doCname (m, &n->varF.cname, scopes);
- break;
-
- case decl_recordfield:
- return doCname (m, &n->recordfieldF.cname, scopes);
- break;
-
- case decl_enumerationfield:
- return doCname (m, &n->enumerationfieldF.cname, scopes);
- break;
-
-
- default:
- break;
+ /* We should finish the procedure as the variable does not use an opaque. */
+ return true;
}
- return m;
- /* static analysis guarentees a RETURN statement will be used before here. */
- __builtin_unreachable ();
-}
-
-
-/*
- doDNameC -
-*/
-
-static void doDNameC (mcPretty_pretty p, decl_node n, bool scopes)
-{
- if ((n != NULL) && ((decl_getSymName (n)) != nameKey_NulName))
+ else if (decl_isExported (static_cast<decl_node> (n)))
{
- doNamesC (p, getDName (n, scopes));
+ /* avoid dangling else. */
+ /* Exported variables using an opaque type will always be implemented
+ with a (void * ). */
+ return true;
+ }
+ else
+ {
+ /* avoid dangling else. */
+ /* Not exported therefore static to the module (local or global non exported
+ variable), we check whether the opaque type was declared in the
+ implementation module. If it is declared in the implementation module
+ then we return FALSE. */
+ return ! (isDeclInImp (type));
}
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
}
/*
- doFQDNameC -
+ initNodeOpaqueState - initialize the node opaque state.
*/
-static void doFQDNameC (mcPretty_pretty p, decl_node n, bool scopes)
+static void initNodeOpaqueState (decl_node__opaque n)
{
- DynamicStrings_String s;
-
- s = getFQDstring (n, scopes);
- outTextS (p, s);
- s = DynamicStrings_KillString (s);
-}
+ decl_node__opaque type;
+ switch (n->kind)
+ {
+ case decl_opaquecast:
+ break;
-/*
- doFQNameC -
-*/
-
-static void doFQNameC (mcPretty_pretty p, decl_node n)
-{
- DynamicStrings_String s;
+ case decl_funccall:
+ assignNodeOpaqueCastState (n, getFunction (n)); /* This must be done when the cast direction is known. */
+ break;
- s = getFQstring (n);
- outTextS (p, s);
- s = DynamicStrings_KillString (s);
-}
+ case decl_var:
+ type = static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (n)));
+ if (n->varF.isParameter || n->varF.isVarParameter)
+ {
+ /* If the variable is really a parameter then it uses
+ the state of the parameter. */
+ initNodeOpaqueCastState (n, isTypeOpaqueDefImp (type), isParamVoidStar (n));
+ }
+ else
+ {
+ initNodeOpaqueCastState (n, isTypeOpaqueDefImp (type), isVarVoidStar (n));
+ }
+ break;
+ case decl_array:
+ type = static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (n)));
+ initNodeOpaqueCastState (n, isTypeOpaqueDefImp (type), decl_isExported (static_cast<decl_node> (n)));
+ break;
-/*
- doNameM2 -
-*/
+ case decl_varparam:
+ case decl_param:
+ mcDebug_assert ((decl_isProcedure (decl_getScope (static_cast<decl_node> (n)))) || (decl_isProcType (decl_getScope (static_cast<decl_node> (n)))));
+ type = static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (n)));
+ initNodeOpaqueCastState (n, isTypeOpaqueDefImp (type), isParamVoidStar (n));
+ break;
-static void doNameM2 (mcPretty_pretty p, decl_node n)
-{
- doNameC (p, n);
-}
+ case decl_componentref:
+ case decl_pointerref:
+ case decl_pointer:
+ case decl_recordfield:
+ case decl_arrayref:
+ type = static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (n)));
+ /* In the future this should be revisited. */
+ initNodeOpaqueCastState (n, isTypeOpaqueDefImp (type), isRefVoidStar (n));
+ break;
+ case decl_proctype:
+ case decl_procedure:
+ type = static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (n))); /* We only consider the return type for a procedure or proctype.
+ The parameters and local vars are handled separately (see
+ above). */
+ if (type == NULL)
+ {
+ /* No return type, therefore no opaque type used. */
+ initNodeOpaqueCastState (n, false, false);
+ }
+ else
+ {
+ /* Init state from the return type. Is type an opaque type?
+ Is the opaque type declared in this module? */
+ initNodeOpaqueCastState (n, isTypeOpaqueDefImp (type), isReturnVoidStar (n, type));
+ }
+ break;
-/*
- doUsed -
-*/
-static void doUsed (mcPretty_pretty p, bool used)
-{
- if (! used)
- {
- mcPretty_setNeedSpace (p);
- outText (p, (const char *) "__attribute__((unused))", 23);
+ default:
+ break;
}
-}
-
-
-/*
- doHighC -
-*/
-
-static void doHighC (mcPretty_pretty p, decl_node a, nameKey_Name n, bool isused)
-{
- if ((decl_isArray (a)) && (decl_isUnbounded (a)))
- {
- /* need to display high. */
- mcPretty_print (p, (const char *) ",", 1);
- mcPretty_setNeedSpace (p);
- doTypeNameC (p, cardinalN);
- mcPretty_setNeedSpace (p);
- mcPretty_print (p, (const char *) "_", 1);
- outTextN (p, n);
- mcPretty_print (p, (const char *) "_high", 5);
- doUsed (p, isused);
+ if (debugOpaque)
+ {
+ dumpOpaqueState (n);
}
}
/*
- doParamConstCast -
+ assignNodeOpaqueCastState - copy the opaqueCastState from src into dest.
*/
-static void doParamConstCast (mcPretty_pretty p, decl_node n)
+static void assignNodeOpaqueCastState (decl_node__opaque dest, decl_node__opaque src)
{
- decl_node ptype;
-
- ptype = decl_getType (n);
- if (((decl_isArray (ptype)) && (decl_isUnbounded (ptype))) && (lang == decl_ansiCP))
+ if (nodeUsesOpaque (src))
{
- outText (p, (const char *) "const", 5);
- mcPretty_setNeedSpace (p);
+ initNodeOpaqueCastState (dest, true, getNodeOpaqueVoidStar (src));
+ }
+ else
+ {
+ initNodeOpaqueCastState (dest, false, false);
}
}
/*
- getParameterVariable - returns the variable which shadows the parameter
- named, m, in parameter block, n.
+ assignNodeOpaqueCastFalse - assign the voidstar field of dest to false.
+ It assigns the opaque field of dest to the value
+ of the src opaque field.
*/
-static decl_node getParameterVariable (decl_node n, nameKey_Name m)
+static void assignNodeOpaqueCastFalse (decl_node__opaque dest, decl_node__opaque src)
{
- decl_node p;
-
- mcDebug_assert ((decl_isParam (n)) || (decl_isVarParam (n)));
- if (decl_isParam (n))
+ if (nodeUsesOpaque (src))
{
- p = n->paramF.scope;
+ initNodeOpaqueCastState (dest, true, false);
}
else
{
- p = n->varparamF.scope;
+ initNodeOpaqueCastState (dest, false, false);
}
- mcDebug_assert (decl_isProcedure (p));
- return decl_lookupInScope (p, m);
- /* static analysis guarentees a RETURN statement will be used before here. */
- __builtin_unreachable ();
}
/*
- doParamTypeEmit - emit parameter type for C/C++. It checks to see if the
- parameter type is a procedure type and if it were declared
- in a definition module for "C" and if so it uses the "C"
- definition for a procedure type, rather than the mc
- C++ version.
+ dumpOpaqueState -
*/
-static void doParamTypeEmit (mcPretty_pretty p, decl_node paramnode, decl_node paramtype)
+static void dumpOpaqueState (decl_node__opaque n)
{
- mcDebug_assert ((decl_isParam (paramnode)) || (decl_isVarParam (paramnode)));
- if ((isForC (paramnode)) && (decl_isProcType (decl_skipType (paramtype))))
+ decl_node__opaque o;
+
+ switch (n->kind)
{
- doFQNameC (p, paramtype);
- outText (p, (const char *) "_C", 2);
+ case decl_opaquecast:
+ case decl_funccall:
+ case decl_var:
+ case decl_array:
+ case decl_varparam:
+ case decl_param:
+ case decl_pointer:
+ case decl_recordfield:
+ case decl_componentref:
+ case decl_arrayref:
+ case decl_procedure:
+ case decl_proctype:
+ o = n;
+ break;
+
+
+ default:
+ o = static_cast<decl_node__opaque> (NULL);
+ break;
}
- else
+ if (o != NULL)
{
- doTypeNameC (p, paramtype);
+ outText (doP, (const char *) "/* ", 3);
+ doNameC (doP, o);
+ outText (doP, (const char *) " ", 2);
+ switch (o->kind)
+ {
+ case decl_opaquecast:
+ outText (doP, (const char *) "opaquecast", 10);
+ break;
+
+ case decl_funccall:
+ outText (doP, (const char *) "funccall", 8);
+ break;
+
+ case decl_var:
+ outText (doP, (const char *) "var", 3);
+ break;
+
+ case decl_array:
+ outText (doP, (const char *) "array", 5);
+ break;
+
+ case decl_varparam:
+ outText (doP, (const char *) "varparam", 8);
+ break;
+
+ case decl_param:
+ outText (doP, (const char *) "param", 5);
+ break;
+
+ case decl_pointer:
+ outText (doP, (const char *) "pointer", 7);
+ break;
+
+ case decl_recordfield:
+ outText (doP, (const char *) "recordfield", 11);
+ break;
+
+ case decl_componentref:
+ outText (doP, (const char *) "componentref", 12);
+ break;
+
+ case decl_pointerref:
+ outText (doP, (const char *) "pointerref", 10);
+ break;
+
+ case decl_arrayref:
+ outText (doP, (const char *) "arrayref", 8);
+ break;
+
+ case decl_procedure:
+ outText (doP, (const char *) "procedure", 9);
+ break;
+
+ case decl_proctype:
+ outText (doP, (const char *) "proctype", 8);
+ break;
+
+
+ default:
+ break;
+ }
+ if (nodeUsesOpaque (o))
+ {
+ /* avoid gcc warning by using compound statement even if not strictly necessary. */
+ if (getNodeOpaqueVoidStar (o))
+ {
+ outText (doP, (const char *) " uses (void *) opaque", 21);
+ }
+ else
+ {
+ outText (doP, (const char *) " uses opaque__full", 18);
+ }
+ }
+ outText (doP, (const char *) " */ \\n", 6);
}
}
doParamC - emit parameter for C/C++.
*/
-static void doParamC (mcPretty_pretty p, decl_node n)
+static void doParamC (mcPretty_pretty p, decl_node__opaque n)
{
- decl_node v;
- decl_node ptype;
+ decl_node__opaque v;
+ decl_node__opaque ptype;
nameKey_Name i;
unsigned int c;
unsigned int t;
wlists_wlist l;
- mcDebug_assert (decl_isParam (n));
- ptype = decl_getType (n);
+ mcDebug_assert (decl_isParam (static_cast<decl_node> (n)));
+ ptype = static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (n)));
if (n->paramF.namelist == NULL)
{
/* avoid dangling else. */
doParamConstCast (p, n);
doTypeNameC (p, ptype);
doUsed (p, n->paramF.isUsed);
- if ((decl_isArray (ptype)) && (decl_isUnbounded (ptype)))
+ if ((decl_isArray (static_cast<decl_node> (ptype))) && (decl_isUnbounded (static_cast<decl_node> (ptype))))
{
outText (p, (const char *) ",", 1);
mcPretty_setNeedSpace (p);
/* avoid dangling else. */
doParamConstCast (p, n);
doParamTypeEmit (p, n, ptype);
- if ((decl_isArray (ptype)) && (decl_isUnbounded (ptype)))
+ if ((decl_isArray (static_cast<decl_node> (ptype))) && (decl_isUnbounded (static_cast<decl_node> (ptype))))
{
doUsed (p, n->paramF.isUsed);
outText (p, (const char *) ",", 1);
doParamConstCast (p, n);
doParamTypeEmit (p, n, ptype);
i = static_cast<nameKey_Name> (wlists_getItemFromList (l, c));
- if ((decl_isArray (ptype)) && (decl_isUnbounded (ptype)))
+ if ((decl_isArray (static_cast<decl_node> (ptype))) && (decl_isUnbounded (static_cast<decl_node> (ptype))))
{
mcPretty_noSpace (p);
}
{
doFQDNameC (p, v, true);
}
- if ((decl_isArray (ptype)) && (decl_isUnbounded (ptype)))
- {
- outText (p, (const char *) "_", 1);
- }
+ doParamTypeNameModifier (p, ptype, false);
doUsed (p, n->paramF.isUsed);
doHighC (p, ptype, i, n->paramF.isUsed);
if (c < t)
doVarParamC - emit a VAR parameter for C/C++.
*/
-static void doVarParamC (mcPretty_pretty p, decl_node n)
+static void doVarParamC (mcPretty_pretty p, decl_node__opaque n)
{
- decl_node v;
- decl_node ptype;
+ decl_node__opaque v;
+ decl_node__opaque ptype;
nameKey_Name i;
unsigned int c;
unsigned int t;
wlists_wlist l;
- mcDebug_assert (decl_isVarParam (n));
- ptype = decl_getType (n);
+ mcDebug_assert (decl_isVarParam (static_cast<decl_node> (n)));
+ ptype = static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (n)));
if (n->varparamF.namelist == NULL)
{
/* avoid dangling else. */
doTypeNameC (p, ptype);
/* doTypeC (p, ptype, n) ; */
- if (! (decl_isArray (ptype)))
+ if (! (decl_isArray (static_cast<decl_node> (ptype))))
{
mcPretty_setNeedSpace (p);
outText (p, (const char *) "*", 1);
}
doUsed (p, n->varparamF.isUsed);
- if ((decl_isArray (ptype)) && (decl_isUnbounded (ptype)))
+ if ((decl_isArray (static_cast<decl_node> (ptype))) && (decl_isUnbounded (static_cast<decl_node> (ptype))))
{
outText (p, (const char *) ",", 1);
mcPretty_setNeedSpace (p);
while (c <= t)
{
doParamTypeEmit (p, n, ptype);
- if (! (decl_isArray (ptype)))
+ if (! (decl_isArray (static_cast<decl_node> (ptype))))
{
mcPretty_setNeedSpace (p);
outText (p, (const char *) "*", 1);
{
doFQDNameC (p, v, true);
}
+ doParamTypeNameModifier (p, ptype, true);
doUsed (p, n->varparamF.isUsed);
doHighC (p, ptype, i, n->varparamF.isUsed);
if (c < t)
doOptargC -
*/
-static void doOptargC (mcPretty_pretty p, decl_node n)
+static void doOptargC (mcPretty_pretty p, decl_node__opaque n)
{
- decl_node ptype;
+ decl_node__opaque ptype;
nameKey_Name i;
unsigned int t;
wlists_wlist l;
- mcDebug_assert (decl_isOptarg (n));
- ptype = decl_getType (n);
+ mcDebug_assert (decl_isOptarg (static_cast<decl_node> (n)));
+ ptype = static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (n)));
mcDebug_assert (n->optargF.namelist != NULL);
mcDebug_assert (isIdentList (n->paramF.namelist));
l = n->paramF.namelist->identlistF.names;
doParameterC -
*/
-static void doParameterC (mcPretty_pretty p, decl_node n)
+static void doParameterC (mcPretty_pretty p, decl_node__opaque n)
{
- if (decl_isParam (n))
+ if (decl_isParam (static_cast<decl_node> (n)))
{
doParamC (p, n);
}
- else if (decl_isVarParam (n))
+ else if (decl_isVarParam (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
doVarParamC (p, n);
}
- else if (decl_isVarargs (n))
+ else if (decl_isVarargs (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
mcPretty_print (p, (const char *) "...", 3);
}
- else if (decl_isOptarg (n))
+ else if (decl_isOptarg (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
doOptargC (p, n);
doProcTypeC -
*/
-static void doProcTypeC (mcPretty_pretty p, decl_node t, decl_node n)
+static void doProcTypeC (mcPretty_pretty p, decl_node__opaque t, decl_node__opaque n)
+{
+ mcDebug_assert (decl_isType (static_cast<decl_node> (t)));
+ if ((isDeclType (t)) && (isDeclType (n)))
+ {
+ outputPartial (t);
+ doCompletePartialProcType (p, t, n);
+ }
+}
+
+
+/*
+ isDeclInImp - returns TRUE if node type is declared as an opaque and
+ is declared fully in the current implementation module.
+ This should only be called if isType (type). Its purpose
+ is specific to a type checking whether it is an opaque type
+ declared in the .def/.mod pair of the current imp module.
+*/
+
+static bool isDeclInImp (decl_node__opaque type)
+{
+ decl_node__opaque scope;
+ decl_node__opaque def;
+ nameKey_Name name;
+
+ mcDebug_assert (decl_isType (static_cast<decl_node> (type)));
+ scope = static_cast<decl_node__opaque> (decl_getScope (static_cast<decl_node> (type)));
+ if ((isTypeOpaqueDefImp (type)) && (decl_isImp (static_cast<decl_node> (currentModule))))
+ {
+ name = decl_getSymName (static_cast<decl_node> (type));
+ if (name != nameKey_NulName)
+ {
+ /* Lookup the matching .def module. */
+ def = static_cast<decl_node__opaque> (decl_lookupDef (decl_getSymName (static_cast<decl_node> (currentModule))));
+ if ((def != NULL) && ((def == scope) || (currentModule == scope)))
+ {
+ /* Return TRUE if the symbol has already been declared in the .def. */
+ return (decl_lookupExported (static_cast<decl_node> (def), name)) != NULL;
+ }
+ }
+ }
+ return false;
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
+}
+
+
+/*
+ doTypeNameModifier - adds the __opaque modifier to the type n provided
+ it is an opaque type which is being declared in the
+ implementation module.
+*/
+
+static void doTypeNameModifier (mcPretty_pretty p, decl_node__opaque n)
{
- mcDebug_assert (decl_isType (t));
- outputPartial (t);
- doCompletePartialProcType (p, t, n);
+ if ((isTypeOpaqueDefImp (n)) && (decl_isImp (static_cast<decl_node> (currentModule))))
+ {
+ outText (p, (const char *) "__opaque", 8);
+ }
}
doTypesC -
*/
-static void doTypesC (decl_node n)
+static void doTypesC (decl_node__opaque n)
{
- decl_node m;
+ decl_node__opaque m;
- if (decl_isType (n))
+ if (decl_isType (static_cast<decl_node> (n)))
{
- m = decl_getType (n);
- if (decl_isProcType (m))
+ m = static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (n)));
+ if (decl_isProcType (static_cast<decl_node> (m)))
{
doProcTypeC (doP, n, m);
}
- else if ((decl_isType (m)) || (decl_isPointer (m)))
+ else if ((decl_isType (static_cast<decl_node> (m))) || (decl_isPointer (static_cast<decl_node> (m))))
{
/* avoid dangling else. */
outText (doP, (const char *) "typedef", 7);
mcPretty_setNeedSpace (doP);
doTypeC (doP, m, &m);
- if (decl_isType (m))
+ if (decl_isType (static_cast<decl_node> (m)))
{
mcPretty_setNeedSpace (doP);
}
doTypeNameC (doP, n);
+ doTypeNameModifier (doP, n);
outText (doP, (const char *) ";\\n\\n", 5);
}
- else if (decl_isEnumeration (m))
+ else if (decl_isEnumeration (static_cast<decl_node> (m)))
{
/* avoid dangling else. */
- outText (doP, (const char *) "typedef", 7);
- mcPretty_setNeedSpace (doP);
- doTypeC (doP, m, &m);
- mcPretty_setNeedSpace (doP);
- doTypeNameC (doP, n);
- outText (doP, (const char *) ";\\n\\n", 5);
+ if (isDeclType (n))
+ {
+ outText (doP, (const char *) "typedef", 7);
+ mcPretty_setNeedSpace (doP);
+ doTypeC (doP, m, &m);
+ mcPretty_setNeedSpace (doP);
+ doTypeNameC (doP, n);
+ outText (doP, (const char *) ";\\n\\n", 5);
+ }
}
else
{
outText (doP, (const char *) "typedef", 7);
mcPretty_setNeedSpace (doP);
doTypeC (doP, m, &m);
- if (decl_isType (m))
+ if (decl_isType (static_cast<decl_node> (m)))
{
mcPretty_setNeedSpace (doP);
}
doTypeNameC (doP, n);
+ doTypeNameModifier (doP, n);
outText (doP, (const char *) ";\\n\\n", 5);
}
}
doCompletePartialC -
*/
-static void doCompletePartialC (decl_node n)
+static void doCompletePartialC (decl_node__opaque n)
{
- decl_node m;
+ decl_node__opaque m;
- if (decl_isType (n))
+ if (decl_isType (static_cast<decl_node> (n)))
{
- m = decl_getType (n);
- if (decl_isRecord (m))
+ m = static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (n)));
+ if (decl_isRecord (static_cast<decl_node> (m)))
{
doCompletePartialRecord (doP, n, m);
}
- else if (decl_isArray (m))
+ else if (decl_isArray (static_cast<decl_node> (m)))
{
/* avoid dangling else. */
doCompletePartialArray (doP, n, m);
}
- else if (decl_isProcType (m))
+ else if (decl_isProcType (static_cast<decl_node> (m)))
{
/* avoid dangling else. */
doCompletePartialProcType (doP, n, m);
doCompletePartialRecord -
*/
-static void doCompletePartialRecord (mcPretty_pretty p, decl_node t, decl_node r)
+static void doCompletePartialRecord (mcPretty_pretty p, decl_node__opaque t, decl_node__opaque r)
{
unsigned int i;
unsigned int h;
- decl_node f;
+ decl_node__opaque f;
- mcDebug_assert (decl_isRecord (r));
- mcDebug_assert (decl_isType (t));
+ mcDebug_assert (decl_isRecord (static_cast<decl_node> (r)));
+ mcDebug_assert (decl_isType (static_cast<decl_node> (t)));
outText (p, (const char *) "struct", 6);
mcPretty_setNeedSpace (p);
doFQNameC (p, t);
h = Indexing_HighIndice (r->recordF.listOfSons);
while (i <= h)
{
- f = static_cast<decl_node> (Indexing_GetIndice (r->recordF.listOfSons, i));
- if (decl_isRecordField (f))
+ f = static_cast<decl_node__opaque> (Indexing_GetIndice (r->recordF.listOfSons, i));
+ if (decl_isRecordField (static_cast<decl_node> (f)))
{
/* avoid dangling else. */
if (! f->recordfieldF.tag)
{
- mcPretty_setNeedSpace (p);
doRecordFieldC (p, f);
outText (p, (const char *) ";\\n", 3);
}
}
- else if (decl_isVarient (f))
+ else if (decl_isVarient (static_cast<decl_node> (f)))
{
/* avoid dangling else. */
doVarientC (p, f);
outText (p, (const char *) ";\\n", 3);
}
- else if (decl_isVarientField (f))
+ else if (decl_isVarientField (static_cast<decl_node> (f)))
{
/* avoid dangling else. */
doVarientFieldC (p, f);
doCompletePartialArray -
*/
-static void doCompletePartialArray (mcPretty_pretty p, decl_node t, decl_node r)
+static void doCompletePartialArray (mcPretty_pretty p, decl_node__opaque t, decl_node__opaque r)
{
- decl_node type;
- decl_node s;
+ decl_node__opaque type;
+ decl_node__opaque s;
- mcDebug_assert (decl_isArray (r));
+ mcDebug_assert (decl_isArray (static_cast<decl_node> (r)));
type = r->arrayF.type;
- s = NULL;
+ s = static_cast<decl_node__opaque> (NULL);
outText (p, (const char *) "struct", 6);
mcPretty_setNeedSpace (p);
doFQNameC (p, t);
lookupConst -
*/
-static decl_node lookupConst (decl_node type, nameKey_Name n)
+static decl_node__opaque lookupConst (decl_node__opaque type, nameKey_Name n)
{
- return decl_makeLiteralInt (n);
+ return static_cast<decl_node__opaque> (decl_makeLiteralInt (n));
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
doMin -
*/
-static decl_node doMin (decl_node n)
+static decl_node__opaque doMin (decl_node__opaque n)
{
if (n == booleanN)
{
else if (n == bitsetN)
{
/* avoid dangling else. */
- mcDebug_assert (decl_isSubrange (bitnumN));
+ mcDebug_assert (decl_isSubrange (static_cast<decl_node> (bitnumN)));
return bitnumN->subrangeF.low;
}
else if (n == locN)
doMax -
*/
-static decl_node doMax (decl_node n)
+static decl_node__opaque doMax (decl_node__opaque n)
{
if (n == booleanN)
{
else if (n == bitsetN)
{
/* avoid dangling else. */
- mcDebug_assert (decl_isSubrange (bitnumN));
+ mcDebug_assert (decl_isSubrange (static_cast<decl_node> (bitnumN)));
return bitnumN->subrangeF.high;
}
else if (n == locN)
{
/* avoid dangling else. */
mcMetaError_metaError1 ((const char *) "trying to obtain MAX ({%1ad}) is illegal", 40, (const unsigned char *) &n, (sizeof (n)-1));
- return NULL;
+ return static_cast<decl_node__opaque> (NULL);
}
else
{
getMax -
*/
-static decl_node getMax (decl_node n)
+static decl_node__opaque getMax (decl_node__opaque n)
{
- n = decl_skipType (n);
- if (decl_isSubrange (n))
+ n = static_cast<decl_node__opaque> (decl_skipType (static_cast<decl_node> (n)));
+ if (decl_isSubrange (static_cast<decl_node> (n)))
{
return n->subrangeF.high;
}
- else if (decl_isEnumeration (n))
+ else if (decl_isEnumeration (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
return n->enumerationF.high;
getMin -
*/
-static decl_node getMin (decl_node n)
+static decl_node__opaque getMin (decl_node__opaque n)
{
- n = decl_skipType (n);
- if (decl_isSubrange (n))
+ n = static_cast<decl_node__opaque> (decl_skipType (static_cast<decl_node> (n)));
+ if (decl_isSubrange (static_cast<decl_node> (n)))
{
return n->subrangeF.low;
}
- else if (decl_isEnumeration (n))
+ else if (decl_isEnumeration (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
return n->enumerationF.low;
doSubtractC -
*/
-static void doSubtractC (mcPretty_pretty p, decl_node s)
+static void doSubtractC (mcPretty_pretty p, decl_node__opaque s)
{
if (! (isZero (s)))
{
doSubrC -
*/
-static void doSubrC (mcPretty_pretty p, decl_node s)
+static void doSubrC (mcPretty_pretty p, decl_node__opaque s)
{
- decl_node low;
- decl_node high;
+ decl_node__opaque low;
+ decl_node__opaque high;
- s = decl_skipType (s);
+ s = static_cast<decl_node__opaque> (decl_skipType (static_cast<decl_node> (s)));
if (isOrdinal (s))
{
low = getMin (s);
doSubtractC (p, low);
outText (p, (const char *) "+1", 2);
}
- else if (decl_isEnumeration (s))
+ else if (decl_isEnumeration (static_cast<decl_node> (s)))
{
/* avoid dangling else. */
low = getMin (s);
else
{
/* avoid dangling else. */
- mcDebug_assert (decl_isSubrange (s));
+ mcDebug_assert (decl_isSubrange (static_cast<decl_node> (s)));
if ((s->subrangeF.high == NULL) || (s->subrangeF.low == NULL))
{
- doSubrC (p, decl_getType (s));
+ doSubrC (p, static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (s))));
}
else
{
doCompletePartialProcType -
*/
-static void doCompletePartialProcType (mcPretty_pretty p, decl_node t, decl_node n)
+static void doCompletePartialProcType (mcPretty_pretty p, decl_node__opaque t, decl_node__opaque n)
+{
+ if ((isDeclType (t)) && (isDeclType (n)))
+ {
+ outputCompletePartialProcType (p, t, n);
+ }
+}
+
+
+/*
+ outputCompletePartialProcType -
+*/
+
+static void outputCompletePartialProcType (mcPretty_pretty p, decl_node__opaque t, decl_node__opaque n)
{
unsigned int i;
unsigned int h;
- decl_node v;
- decl_node u;
+ decl_node__opaque v;
+ decl_node__opaque u;
- mcDebug_assert (decl_isProcType (n));
- u = NULL;
+ mcDebug_assert (decl_isProcType (static_cast<decl_node> (n)));
+ u = static_cast<decl_node__opaque> (NULL);
outText (p, (const char *) "typedef", 7);
mcPretty_setNeedSpace (p);
doTypeC (p, n->proctypeF.returnType, &u);
+ doOpaqueModifier (p, n);
mcPretty_setNeedSpace (p);
outText (p, (const char *) "(*", 2);
doFQNameC (p, t);
h = Indexing_HighIndice (n->proctypeF.parameters);
while (i <= h)
{
- v = static_cast<decl_node> (Indexing_GetIndice (n->proctypeF.parameters, i));
+ v = static_cast<decl_node__opaque> (Indexing_GetIndice (n->proctypeF.parameters, i));
doParameterC (p, v);
mcPretty_noSpace (p);
if (i < h)
isBase -
*/
-static bool isBase (decl_node n)
+static bool isBase (decl_node__opaque n)
{
switch (n->kind)
{
doBaseC -
*/
-static void doBaseC (mcPretty_pretty p, decl_node n)
+static void doBaseC (mcPretty_pretty p, decl_node__opaque n)
{
switch (n->kind)
{
isSystem -
*/
-static bool isSystem (decl_node n)
+static bool isSystem (decl_node__opaque n)
{
switch (n->kind)
{
doSystemC -
*/
-static void doSystemC (mcPretty_pretty p, decl_node n)
+static void doSystemC (mcPretty_pretty p, decl_node__opaque n)
{
switch (n->kind)
{
doArrayC -
*/
-static void doArrayC (mcPretty_pretty p, decl_node n)
+static void doArrayC (mcPretty_pretty p, decl_node__opaque n)
{
- decl_node t;
- decl_node s;
- decl_node u;
+ decl_node__opaque t;
+ decl_node__opaque s;
+ decl_node__opaque u;
- mcDebug_assert (decl_isArray (n));
+ mcDebug_assert (decl_isArray (static_cast<decl_node> (n)));
t = n->arrayF.type;
s = n->arrayF.subr;
- u = NULL;
+ u = static_cast<decl_node__opaque> (NULL);
if (s == NULL)
{
doTypeC (p, t, &u);
doPointerC -
*/
-static void doPointerC (mcPretty_pretty p, decl_node n, decl_node *m)
+static void doPointerC (mcPretty_pretty p, decl_node__opaque n, decl_node__opaque *m)
{
- decl_node t;
- decl_node s;
+ decl_node__opaque t;
+ decl_node__opaque s;
t = n->pointerF.type;
- s = NULL;
+ s = static_cast<decl_node__opaque> (NULL);
doTypeC (p, t, &s);
mcPretty_setNeedSpace (p);
outText (p, (const char *) "*", 1);
doRecordFieldC -
*/
-static void doRecordFieldC (mcPretty_pretty p, decl_node f)
+static void doRecordFieldC (mcPretty_pretty p, decl_node__opaque f)
{
- decl_node m;
+ decl_node__opaque m;
- m = NULL;
+ m = static_cast<decl_node__opaque> (NULL);
mcPretty_setNeedSpace (p);
doTypeC (p, f->recordfieldF.type, &m);
+ if ((decl_isType (static_cast<decl_node> (f->recordfieldF.type))) && (isDeclInImp (f->recordfieldF.type)))
+ {
+ outText (p, (const char *) "__opaque", 8);
+ }
+ mcPretty_setNeedSpace (p);
doDNameC (p, f, false);
}
doVarientFieldC -
*/
-static void doVarientFieldC (mcPretty_pretty p, decl_node n)
+static void doVarientFieldC (mcPretty_pretty p, decl_node__opaque n)
{
unsigned int i;
unsigned int t;
- decl_node q;
+ decl_node__opaque q;
- mcDebug_assert (decl_isVarientField (n));
+ mcDebug_assert (decl_isVarientField (static_cast<decl_node> (n)));
if (! n->varientfieldF.simple)
{
outText (p, (const char *) "struct", 6);
t = Indexing_HighIndice (n->varientfieldF.listOfSons);
while (i <= t)
{
- q = static_cast<decl_node> (Indexing_GetIndice (n->varientfieldF.listOfSons, i));
- if (decl_isRecordField (q))
+ q = static_cast<decl_node__opaque> (Indexing_GetIndice (n->varientfieldF.listOfSons, i));
+ if (decl_isRecordField (static_cast<decl_node> (q)))
{
/* avoid dangling else. */
if (! q->recordfieldF.tag)
outText (p, (const char *) ";\\n", 3);
}
}
- else if (decl_isVarient (q))
+ else if (decl_isVarient (static_cast<decl_node> (q)))
{
/* avoid dangling else. */
doVarientC (p, q);
doVarientC -
*/
-static void doVarientC (mcPretty_pretty p, decl_node n)
+static void doVarientC (mcPretty_pretty p, decl_node__opaque n)
{
unsigned int i;
unsigned int t;
- decl_node q;
+ decl_node__opaque q;
- mcDebug_assert (decl_isVarient (n));
+ mcDebug_assert (decl_isVarient (static_cast<decl_node> (n)));
if (n->varientF.tag != NULL)
{
/* avoid gcc warning by using compound statement even if not strictly necessary. */
- if (decl_isRecordField (n->varientF.tag))
+ if (decl_isRecordField (static_cast<decl_node> (n->varientF.tag)))
{
doRecordFieldC (p, n->varientF.tag);
outText (p, (const char *) "; /* case tag */\\n", 19);
}
- else if (decl_isVarientField (n->varientF.tag))
+ else if (decl_isVarientField (static_cast<decl_node> (n->varientF.tag)))
{
/* avoid dangling else. */
/* doVarientFieldC (p, n^.varientF.tag) */
t = Indexing_HighIndice (n->varientF.listOfSons);
while (i <= t)
{
- q = static_cast<decl_node> (Indexing_GetIndice (n->varientF.listOfSons, i));
- if (decl_isRecordField (q))
+ q = static_cast<decl_node__opaque> (Indexing_GetIndice (n->varientF.listOfSons, i));
+ if (decl_isRecordField (static_cast<decl_node> (q)))
{
/* avoid dangling else. */
if (! q->recordfieldF.tag)
outText (p, (const char *) ";\\n", 3);
}
}
- else if (decl_isVarientField (q))
+ else if (decl_isVarientField (static_cast<decl_node> (q)))
{
/* avoid dangling else. */
doVarientFieldC (p, q);
doRecordC -
*/
-static void doRecordC (mcPretty_pretty p, decl_node n, decl_node *m)
+static void doRecordC (mcPretty_pretty p, decl_node__opaque n, decl_node__opaque *m)
{
unsigned int i;
unsigned int h;
- decl_node f;
+ decl_node__opaque f;
- mcDebug_assert (decl_isRecord (n));
+ mcDebug_assert (decl_isRecord (static_cast<decl_node> (n)));
outText (p, (const char *) "struct", 6);
mcPretty_setNeedSpace (p);
p = outKc (p, (const char *) "{", 1);
outText (p, (const char *) "\\n", 2);
while (i <= h)
{
- f = static_cast<decl_node> (Indexing_GetIndice (n->recordF.listOfSons, i));
- if (decl_isRecordField (f))
+ f = static_cast<decl_node__opaque> (Indexing_GetIndice (n->recordF.listOfSons, i));
+ if (decl_isRecordField (static_cast<decl_node> (f)))
{
/* avoid dangling else. */
if (! f->recordfieldF.tag)
outText (p, (const char *) ";\\n", 3);
}
}
- else if (decl_isVarient (f))
+ else if (decl_isVarient (static_cast<decl_node> (f)))
{
/* avoid dangling else. */
doVarientC (p, f);
outText (p, (const char *) ";\\n", 3);
}
- else if (decl_isVarientField (f))
+ else if (decl_isVarientField (static_cast<decl_node> (f)))
{
/* avoid dangling else. */
doVarientFieldC (p, f);
isBitset -
*/
-static bool isBitset (decl_node n)
+static bool isBitset (decl_node__opaque n)
{
return n == bitsetN;
/* static analysis guarentees a RETURN statement will be used before here. */
isNegative - returns TRUE if expression, n, is negative.
*/
-static bool isNegative (decl_node n)
+static bool isNegative (decl_node__opaque n)
{
/* --fixme-- needs to be completed. */
return false;
doSubrangeC -
*/
-static void doSubrangeC (mcPretty_pretty p, decl_node n)
+static void doSubrangeC (mcPretty_pretty p, decl_node__opaque n)
{
- mcDebug_assert (decl_isSubrange (n));
+ mcDebug_assert (decl_isSubrange (static_cast<decl_node> (n)));
if (isNegative (n->subrangeF.low))
{
outText (p, (const char *) "int", 3);
Currently we only support sets of size WORD.
*/
-static void doSetC (mcPretty_pretty p, decl_node n)
+static void doSetC (mcPretty_pretty p, decl_node__opaque n)
{
- mcDebug_assert (decl_isSet (n));
+ mcDebug_assert (decl_isSet (static_cast<decl_node> (n)));
outText (p, (const char *) "unsigned int", 12);
mcPretty_setNeedSpace (p);
}
doTypeC -
*/
-static void doTypeC (mcPretty_pretty p, decl_node n, decl_node *m)
+static void doTypeC (mcPretty_pretty p, decl_node__opaque n, decl_node__opaque *m)
{
if (n == NULL)
{
/* avoid dangling else. */
doSystemC (p, n);
}
- else if (decl_isEnumeration (n))
+ else if (decl_isEnumeration (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
doEnumerationC (p, n);
}
- else if (decl_isType (n))
+ else if (decl_isType (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
doFQNameC (p, n);
- /*
- ELSIF isProcType (n) OR isArray (n) OR isRecord (n)
- THEN
- HALT n should have been simplified.
- */
- mcPretty_setNeedSpace (p);
}
- else if (decl_isProcType (n))
+ else if (decl_isProcType (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
doProcTypeC (p, n, (*m));
}
- else if (decl_isArray (n))
+ else if (decl_isArray (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
doArrayC (p, n);
}
- else if (decl_isRecord (n))
+ else if (decl_isRecord (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
doRecordC (p, n, m);
}
- else if (decl_isPointer (n))
+ else if (decl_isPointer (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
doPointerC (p, n, m);
}
- else if (decl_isSubrange (n))
+ else if (decl_isSubrange (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
doSubrangeC (p, n);
}
- else if (decl_isSet (n))
+ else if (decl_isSet (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
doSetC (p, n);
doArrayNameC - it displays the array declaration (it might be an unbounded).
*/
-static void doArrayNameC (mcPretty_pretty p, decl_node n)
+static void doArrayNameC (mcPretty_pretty p, decl_node__opaque n)
{
- doTypeNameC (p, decl_getType (n));
+ doTypeNameC (p, static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (n))));
mcPretty_setNeedSpace (p);
outText (p, (const char *) "*", 1);
}
doRecordNameC - emit the C/C++ record name <name of n>"_r".
*/
-static void doRecordNameC (mcPretty_pretty p, decl_node n)
+static void doRecordNameC (mcPretty_pretty p, decl_node__opaque n)
{
DynamicStrings_String s;
doPointerNameC - emit the C/C++ pointer type <name of n>*.
*/
-static void doPointerNameC (mcPretty_pretty p, decl_node n)
+static void doPointerNameC (mcPretty_pretty p, decl_node__opaque n)
{
- doTypeNameC (p, decl_getType (n));
+ doTypeNameC (p, static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (n))));
mcPretty_setNeedSpace (p);
outText (p, (const char *) "*", 1);
}
doTypeNameC -
*/
-static void doTypeNameC (mcPretty_pretty p, decl_node n)
+static void doTypeNameC (mcPretty_pretty p, decl_node__opaque n)
{
DynamicStrings_String t;
/* avoid dangling else. */
doSystemC (p, n);
}
- else if (decl_isEnumeration (n))
+ else if (decl_isEnumeration (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
mcPretty_print (p, (const char *) "is enumeration type name required\\n", 35);
}
- else if (decl_isType (n))
+ else if (decl_isType (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
doFQNameC (p, n);
}
- else if (decl_isProcType (n))
+ else if (decl_isProcType (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
doFQNameC (p, n);
outText (p, (const char *) "_t", 2);
}
- else if (decl_isArray (n))
+ else if (decl_isArray (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
doArrayNameC (p, n);
}
- else if (decl_isRecord (n))
+ else if (decl_isRecord (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
doRecordNameC (p, n);
}
- else if (decl_isPointer (n))
+ else if (decl_isPointer (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
doPointerNameC (p, n);
}
- else if (decl_isSubrange (n))
+ else if (decl_isSubrange (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
doSubrangeC (p, n);
{
/* avoid dangling else. */
mcPretty_print (p, (const char *) "is type unknown required\\n", 26);
- stop ();
}
}
isExternal - returns TRUE if symbol, n, was declared in another module.
*/
-static bool isExternal (decl_node n)
+static bool isExternal (decl_node__opaque n)
{
- decl_node s;
+ decl_node__opaque s;
- s = decl_getScope (n);
- return ((s != NULL) && (decl_isDef (s))) && (((decl_isImp (decl_getMainModule ())) && (s != (decl_lookupDef (decl_getSymName (decl_getMainModule ()))))) || (decl_isModule (decl_getMainModule ())));
+ s = static_cast<decl_node__opaque> (decl_getScope (static_cast<decl_node> (n)));
+ return ((s != NULL) && (decl_isDef (static_cast<decl_node> (s)))) && (((decl_isImp (decl_getMainModule ())) && (s != (decl_lookupDef (decl_getSymName (decl_getMainModule ()))))) || (decl_isModule (decl_getMainModule ())));
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
/*
- doVarC -
+ doOpaqueModifier - adds postfix __opaque providing n uses an opaque type which is
+ not represented by ( void * ). n is a non type node which might
+ be using an opaque type. For example a var or param node.
+*/
+
+static void doOpaqueModifier (mcPretty_pretty p, decl_node__opaque n)
+{
+ mcDebug_assert (! (decl_isType (static_cast<decl_node> (n))));
+ if (((decl_isImp (decl_getCurrentModule ())) && (nodeUsesOpaque (n))) && (! (getNodeOpaqueVoidStar (n))))
+ {
+ outText (doP, (const char *) "__opaque", 8);
+ }
+}
+
+
+/*
+ doDeclareVarC -
*/
-static void doVarC (decl_node n)
+static void doDeclareVarC (decl_node__opaque n)
{
- decl_node s;
+ decl_node__opaque type;
+ decl_node__opaque s;
+
+ s = static_cast<decl_node__opaque> (NULL);
+ type = static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (n)));
+ doTypeC (doP, type, &s);
+ doOpaqueModifier (doP, n);
+ mcPretty_setNeedSpace (doP);
+ doFQDNameC (doP, n, false);
+ mcPretty_print (doP, (const char *) ";\\n", 3);
+}
+
+/*
+ doVarC - output a variable declaration. Note that we do not generate
+ a declaration if we are translating the implementation module
+ and a variable is exported as the variable will be in the .h
+ file to avoid all -Wodr issues.
+*/
+
+static void doVarC (decl_node__opaque n)
+{
if (decl_isDef (decl_getMainModule ()))
{
mcPretty_print (doP, (const char *) "EXTERN", 6);
mcPretty_setNeedSpace (doP);
+ doDeclareVarC (n);
}
- else if ((! (decl_isExported (n))) && (! (isLocal (n))))
+ else if ((! (decl_isExported (static_cast<decl_node> (n)))) && (! (isLocal (n))))
{
/* avoid dangling else. */
mcPretty_print (doP, (const char *) "static", 6);
mcPretty_setNeedSpace (doP);
+ doDeclareVarC (n);
}
else if (mcOptions_getExtendedOpaque ())
{
/* avoid dangling else. */
+ /* --fixme-- need to revisit extended opaque. */
if (isExternal (n))
{
/* different module declared this variable, therefore it is extern. */
mcPretty_print (doP, (const char *) "extern", 6);
mcPretty_setNeedSpace (doP);
}
+ doDeclareVarC (n);
+ }
+ else if (isLocal (n))
+ {
+ /* avoid dangling else. */
+ doDeclareVarC (n);
}
- s = NULL;
- doTypeC (doP, decl_getType (n), &s);
- mcPretty_setNeedSpace (doP);
- doFQDNameC (doP, n, false);
- mcPretty_print (doP, (const char *) ";\\n", 3);
}
doProcedureHeadingC -
*/
-static void doProcedureHeadingC (decl_node n, bool prototype)
+static void doProcedureHeadingC (decl_node__opaque n, bool prototype)
{
+ DynamicStrings_String s;
unsigned int i;
unsigned int h;
- decl_node p;
- decl_node q;
+ decl_node__opaque p;
+ decl_node__opaque q;
- mcDebug_assert (decl_isProcedure (n));
+ mcDebug_assert (decl_isProcedure (static_cast<decl_node> (n)));
+ s = getFQstring (n);
+ if (DynamicStrings_EqualArray (s, (const char *) "M2Quads_BuildAssignment", 23))
+ {
+ localstop ();
+ }
+ s = DynamicStrings_KillString (s);
mcPretty_noSpace (doP);
if (decl_isDef (decl_getMainModule ()))
{
outText (doP, (const char *) "EXTERN", 6);
mcPretty_setNeedSpace (doP);
}
- else if (decl_isExported (n))
+ else if (decl_isExported (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
doProcedureComment (doP, mcComment_getContent (n->procedureF.modComment));
outText (doP, (const char *) "static", 6);
mcPretty_setNeedSpace (doP);
}
- q = NULL;
+ q = static_cast<decl_node__opaque> (NULL);
doTypeC (doP, n->procedureF.returnType, &q);
+ /*
+ IF NOT isExported (n)
+ THEN
+ doTypeNameModifier (doP, n^.procedureF.returnType)
+ END ;
+ */
+ doOpaqueModifier (doP, n);
mcPretty_setNeedSpace (doP);
doFQDNameC (doP, n, false);
mcPretty_setNeedSpace (doP);
h = Indexing_HighIndice (n->procedureF.parameters);
while (i <= h)
{
- p = static_cast<decl_node> (Indexing_GetIndice (n->procedureF.parameters, i));
+ p = static_cast<decl_node__opaque> (Indexing_GetIndice (n->procedureF.parameters, i));
doParameterC (doP, p);
mcPretty_noSpace (doP);
if (i < h)
checkDeclareUnboundedParamCopyC -
*/
-static bool checkDeclareUnboundedParamCopyC (mcPretty_pretty p, decl_node n)
+static bool checkDeclareUnboundedParamCopyC (mcPretty_pretty p, decl_node__opaque n)
{
- decl_node t;
+ decl_node__opaque t;
unsigned int i;
unsigned int c;
wlists_wlist l;
bool seen;
seen = false;
- t = decl_getType (n);
+ t = static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (n)));
l = n->paramF.namelist->identlistF.names;
- if (((decl_isArray (t)) && (decl_isUnbounded (t))) && (l != NULL))
+ if (((decl_isArray (static_cast<decl_node> (t))) && (decl_isUnbounded (static_cast<decl_node> (t)))) && (l != NULL))
{
- t = decl_getType (t);
+ t = static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (t)));
c = wlists_noOfItemsInList (l);
i = 1;
while (i <= c)
checkUnboundedParamCopyC -
*/
-static void checkUnboundedParamCopyC (mcPretty_pretty p, decl_node n)
+static void checkUnboundedParamCopyC (mcPretty_pretty p, decl_node__opaque n)
{
- decl_node t;
- decl_node s;
+ decl_node__opaque t;
+ decl_node__opaque s;
unsigned int i;
unsigned int c;
wlists_wlist l;
- t = decl_getType (n);
+ t = static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (n)));
l = n->paramF.namelist->identlistF.names;
- if (((decl_isArray (t)) && (decl_isUnbounded (t))) && (l != NULL))
+ if (((decl_isArray (static_cast<decl_node> (t))) && (decl_isUnbounded (static_cast<decl_node> (t)))) && (l != NULL))
{
c = wlists_noOfItemsInList (l);
i = 1;
- t = decl_getType (t);
- s = decl_skipType (t);
+ t = static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (t)));
+ s = static_cast<decl_node__opaque> (decl_skipType (static_cast<decl_node> (t)));
while (i <= c)
{
keyc_useMemcpy ();
doUnboundedParamCopyC -
*/
-static void doUnboundedParamCopyC (mcPretty_pretty p, decl_node n)
+static void doUnboundedParamCopyC (mcPretty_pretty p, decl_node__opaque n)
{
unsigned int i;
unsigned int h;
- decl_node q;
+ decl_node__opaque q;
bool seen;
- mcDebug_assert (decl_isProcedure (n));
+ mcDebug_assert (decl_isProcedure (static_cast<decl_node> (n)));
i = Indexing_LowIndice (n->procedureF.parameters);
h = Indexing_HighIndice (n->procedureF.parameters);
seen = false;
while (i <= h)
{
- q = static_cast<decl_node> (Indexing_GetIndice (n->procedureF.parameters, i));
- if (decl_isParam (q))
+ q = static_cast<decl_node__opaque> (Indexing_GetIndice (n->procedureF.parameters, i));
+ if (decl_isParam (static_cast<decl_node> (q)))
{
seen = (checkDeclareUnboundedParamCopyC (p, q)) || seen;
}
i = Indexing_LowIndice (n->procedureF.parameters);
while (i <= h)
{
- q = static_cast<decl_node> (Indexing_GetIndice (n->procedureF.parameters, i));
- if (decl_isParam (q))
+ q = static_cast<decl_node__opaque> (Indexing_GetIndice (n->procedureF.parameters, i));
+ if (decl_isParam (static_cast<decl_node> (q)))
{
checkUnboundedParamCopyC (p, q);
}
doPrototypeC -
*/
-static void doPrototypeC (decl_node n)
+static void doPrototypeC (decl_node__opaque n)
{
- if (! (decl_isExported (n)))
+ if (! (decl_isExported (static_cast<decl_node> (n))))
{
- keyc_enterScope (n);
+ keyc_enterScope (static_cast<decl_node> (n));
doProcedureHeadingC (n, true);
mcPretty_print (doP, (const char *) ";\\n", 3);
- keyc_leaveScope (n);
+ keyc_leaveScope (static_cast<decl_node> (n));
}
}
addTodo - adds, n, to the todo list.
*/
-static void addTodo (decl_node n)
+static void addTodo (decl_node__opaque n)
{
if (((n != NULL) && (! (alists_isItemInList (globalGroup->partialQ, reinterpret_cast<void *> (n))))) && (! (alists_isItemInList (globalGroup->doneQ, reinterpret_cast<void *> (n)))))
{
- mcDebug_assert (! (decl_isVarient (n)));
- mcDebug_assert (! (decl_isVarientField (n)));
- mcDebug_assert (! (decl_isDef (n)));
+ mcDebug_assert (! (decl_isVarient (static_cast<decl_node> (n))));
+ mcDebug_assert (! (decl_isVarientField (static_cast<decl_node> (n))));
+ mcDebug_assert (! (decl_isDef (static_cast<decl_node> (n))));
alists_includeItemIntoList (globalGroup->todoQ, reinterpret_cast<void *> (n));
}
}
addVariablesTodo -
*/
-static void addVariablesTodo (decl_node n)
+static void addVariablesTodo (decl_node__opaque n)
{
- if (decl_isVar (n))
+ if (decl_isVar (static_cast<decl_node> (n)))
{
/* avoid gcc warning by using compound statement even if not strictly necessary. */
if (n->varF.isParameter || n->varF.isVarParameter)
{
addDone (n);
- addTodo (decl_getType (n));
+ addTodo (static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (n))));
}
else
{
addTypesTodo -
*/
-static void addTypesTodo (decl_node n)
+static void addTypesTodo (decl_node__opaque n)
{
- if (decl_isUnbounded (n))
+ if (decl_isUnbounded (static_cast<decl_node> (n)))
{
addDone (n);
}
makeIntermediateType -
*/
-static decl_node makeIntermediateType (DynamicStrings_String s, decl_node p)
+static decl_node__opaque makeIntermediateType (DynamicStrings_String s, decl_node__opaque p)
{
nameKey_Name n;
- decl_node o;
+ decl_node__opaque o;
n = nameKey_makekey (DynamicStrings_string (s));
- decl_enterScope (decl_getScope (p));
+ decl_enterScope (decl_getScope (static_cast<decl_node> (p)));
o = p;
- p = decl_makeType (nameKey_makekey (DynamicStrings_string (s)));
- decl_putType (p, o);
+ p = static_cast<decl_node__opaque> (decl_makeType (nameKey_makekey (DynamicStrings_string (s))));
+ decl_putType (static_cast<decl_node> (p), static_cast<decl_node> (o));
putTypeInternal (p);
decl_leaveScope ();
return p;
simplifyType -
*/
-static void simplifyType (alists_alist l, decl_node *p)
+static void simplifyType (alists_alist l, decl_node__opaque *p)
{
DynamicStrings_String s;
- if ((((*p) != NULL) && (((decl_isRecord ((*p))) || (decl_isArray ((*p)))) || (decl_isProcType ((*p))))) && (! (decl_isUnbounded ((*p)))))
+ if ((((*p) != NULL) && (((decl_isRecord (static_cast<decl_node> ((*p)))) || (decl_isArray (static_cast<decl_node> ((*p))))) || (decl_isProcType (static_cast<decl_node> ((*p)))))) && (! (decl_isUnbounded (static_cast<decl_node> ((*p))))))
{
s = tempName ();
(*p) = makeIntermediateType (s, (*p));
simplifyVar -
*/
-static void simplifyVar (alists_alist l, decl_node n)
+static void simplifyVar (alists_alist l, decl_node__opaque n)
{
unsigned int i;
unsigned int t;
- decl_node v;
- decl_node d;
- decl_node o;
+ decl_node__opaque v;
+ decl_node__opaque d;
+ decl_node__opaque o;
- mcDebug_assert (decl_isVar (n));
+ mcDebug_assert (decl_isVar (static_cast<decl_node> (n)));
o = n->varF.type;
simplifyType (l, &n->varF.type);
if (o != n->varF.type)
i = 1;
while (i <= t)
{
- v = decl_lookupInScope (n->varF.scope, wlists_getItemFromList (d->vardeclF.names, i));
- mcDebug_assert (decl_isVar (v));
+ v = static_cast<decl_node__opaque> (decl_lookupInScope (static_cast<decl_node> (n->varF.scope), wlists_getItemFromList (d->vardeclF.names, i)));
+ mcDebug_assert (decl_isVar (static_cast<decl_node> (v)));
v->varF.type = n->varF.type;
i += 1;
}
simplifyRecord -
*/
-static void simplifyRecord (alists_alist l, decl_node n)
+static void simplifyRecord (alists_alist l, decl_node__opaque n)
{
unsigned int i;
unsigned int t;
- decl_node q;
+ decl_node__opaque q;
i = Indexing_LowIndice (n->recordF.listOfSons);
t = Indexing_HighIndice (n->recordF.listOfSons);
while (i <= t)
{
- q = static_cast<decl_node> (Indexing_GetIndice (n->recordF.listOfSons, i));
+ q = static_cast<decl_node__opaque> (Indexing_GetIndice (n->recordF.listOfSons, i));
simplifyNode (l, q);
i += 1;
}
simplifyVarient -
*/
-static void simplifyVarient (alists_alist l, decl_node n)
+static void simplifyVarient (alists_alist l, decl_node__opaque n)
{
unsigned int i;
unsigned int t;
- decl_node q;
+ decl_node__opaque q;
simplifyNode (l, n->varientF.tag);
i = Indexing_LowIndice (n->varientF.listOfSons);
t = Indexing_HighIndice (n->varientF.listOfSons);
while (i <= t)
{
- q = static_cast<decl_node> (Indexing_GetIndice (n->varientF.listOfSons, i));
+ q = static_cast<decl_node__opaque> (Indexing_GetIndice (n->varientF.listOfSons, i));
simplifyNode (l, q);
i += 1;
}
simplifyVarientField -
*/
-static void simplifyVarientField (alists_alist l, decl_node n)
+static void simplifyVarientField (alists_alist l, decl_node__opaque n)
{
unsigned int i;
unsigned int t;
- decl_node q;
+ decl_node__opaque q;
i = Indexing_LowIndice (n->varientfieldF.listOfSons);
t = Indexing_HighIndice (n->varientfieldF.listOfSons);
while (i <= t)
{
- q = static_cast<decl_node> (Indexing_GetIndice (n->varientfieldF.listOfSons, i));
+ q = static_cast<decl_node__opaque> (Indexing_GetIndice (n->varientfieldF.listOfSons, i));
simplifyNode (l, q);
i += 1;
}
doSimplifyNode -
*/
-static void doSimplifyNode (alists_alist l, decl_node n)
+static void doSimplifyNode (alists_alist l, decl_node__opaque n)
{
if (n == NULL)
{} /* empty. */
- else if (decl_isType (n))
+ else if (decl_isType (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
/* no need to simplify a type. */
- simplifyNode (l, decl_getType (n));
+ simplifyNode (l, static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (n))));
}
- else if (decl_isVar (n))
+ else if (decl_isVar (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
simplifyVar (l, n);
}
- else if (decl_isRecord (n))
+ else if (decl_isRecord (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
simplifyRecord (l, n);
}
- else if (decl_isRecordField (n))
+ else if (decl_isRecordField (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
simplifyType (l, &n->recordfieldF.type);
}
- else if (decl_isArray (n))
+ else if (decl_isArray (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
simplifyType (l, &n->arrayF.type);
}
- else if (decl_isVarient (n))
+ else if (decl_isVarient (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
simplifyVarient (l, n);
}
- else if (decl_isVarientField (n))
+ else if (decl_isVarientField (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
simplifyVarientField (l, n);
}
- else if (decl_isPointer (n))
+ else if (decl_isPointer (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
simplifyType (l, &n->pointerF.type);
simplifyNode -
*/
-static void simplifyNode (alists_alist l, decl_node n)
+static void simplifyNode (alists_alist l, decl_node__opaque n)
{
if (! (alists_isItemInList (l, reinterpret_cast<void *> (n))))
{
doSimplify -
*/
-static void doSimplify (decl_node n)
+static void doSimplify (decl_node__opaque n)
{
alists_alist l;
outDeclsDefC -
*/
-static void outDeclsDefC (mcPretty_pretty p, decl_node n)
+static void outDeclsDefC (mcPretty_pretty p, decl_node__opaque n)
{
decl_scopeT s;
includeExternals -
*/
-static void includeExternals (decl_node n)
+static void includeExternals (decl_node__opaque n)
{
alists_alist l;
checkSystemInclude -
*/
-static void checkSystemInclude (decl_node n)
+static void checkSystemInclude (decl_node__opaque n)
{
}
addExported -
*/
-static void addExported (decl_node n)
+static void addExported (decl_node__opaque n)
{
- decl_node s;
+ decl_node__opaque s;
- s = decl_getScope (n);
- if (((s != NULL) && (decl_isDef (s))) && (s != defModule))
+ s = static_cast<decl_node__opaque> (decl_getScope (static_cast<decl_node> (n)));
+ if (((s != NULL) && (decl_isDef (static_cast<decl_node> (s)))) && (s != defModule))
{
- if (((decl_isType (n)) || (decl_isVar (n))) || (decl_isConst (n)))
+ if (((decl_isType (static_cast<decl_node> (n))) || (decl_isVar (static_cast<decl_node> (n)))) || (decl_isConst (static_cast<decl_node> (n))))
{
addTodo (n);
}
implementation module and is not a hidden type.
*/
-static void addExternal (decl_node n)
+static void addExternal (decl_node__opaque n)
{
- if (((((decl_getScope (n)) == defModule) && (decl_isType (n))) && (decl_isTypeHidden (n))) && (! (mcOptions_getExtendedOpaque ())))
+ if (((((decl_getScope (static_cast<decl_node> (n))) == defModule) && (decl_isType (static_cast<decl_node> (n)))) && (decl_isTypeHidden (static_cast<decl_node> (n)))) && (! (mcOptions_getExtendedOpaque ())))
{} /* empty. */
/* do nothing. */
- else if (! (decl_isDef (n)))
+ else if (! (decl_isDef (static_cast<decl_node> (n))))
{
/* avoid dangling else. */
addTodo (n);
includeDefConstType -
*/
-static void includeDefConstType (decl_node n)
+static void includeDefConstType (decl_node__opaque n)
{
- decl_node d;
+ decl_node__opaque d;
- if (decl_isImp (n))
+ if (decl_isImp (static_cast<decl_node> (n)))
{
- defModule = decl_lookupDef (decl_getSymName (n));
+ defModule = static_cast<decl_node__opaque> (decl_lookupDef (decl_getSymName (static_cast<decl_node> (n))));
if (defModule != NULL)
{
simplifyTypes (defModule->defF.decls);
runIncludeDefConstType -
*/
-static void runIncludeDefConstType (decl_node n)
+static void runIncludeDefConstType (decl_node__opaque n)
{
- decl_node d;
+ decl_node__opaque d;
- if (decl_isDef (n))
+ if (decl_isDef (static_cast<decl_node> (n)))
{
simplifyTypes (n->defF.decls);
includeConstType (n->defF.decls);
d, into implementation module, i.
*/
-static void joinProcedures (decl_node i, decl_node d)
+static void joinProcedures (decl_node__opaque i, decl_node__opaque d)
{
unsigned int h;
unsigned int j;
- mcDebug_assert (decl_isDef (d));
- mcDebug_assert (decl_isImp (i));
+ mcDebug_assert (decl_isDef (static_cast<decl_node> (d)));
+ mcDebug_assert (decl_isImp (static_cast<decl_node> (i)));
j = 1;
h = Indexing_HighIndice (d->defF.decls.procedures);
while (j <= h)
includeDefVarProcedure -
*/
-static void includeDefVarProcedure (decl_node n)
+static void includeDefVarProcedure (decl_node__opaque n)
{
- decl_node d;
+ decl_node__opaque d;
- if (decl_isImp (n))
+ if (decl_isImp (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
- defModule = decl_lookupDef (decl_getSymName (n));
+ defModule = static_cast<decl_node__opaque> (decl_lookupDef (decl_getSymName (static_cast<decl_node> (n))));
if (defModule != NULL)
{
/*
joinProcedures (n, defModule);
}
}
- else if (decl_isDef (n))
+ else if (decl_isDef (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
includeVar (n->defF.decls);
foreachModuleDo -
*/
-static void foreachModuleDo (decl_node n, symbolKey_performOperation p)
+static void foreachModuleDo (decl_node__opaque n, symbolKey_performOperation p)
{
decl_foreachDefModuleDo (p);
decl_foreachModModuleDo (p);
doStatementSequenceC -
*/
-static void doStatementSequenceC (mcPretty_pretty p, decl_node s)
+static void doStatementSequenceC (mcPretty_pretty p, decl_node__opaque s)
{
unsigned int i;
unsigned int h;
- mcDebug_assert (decl_isStatementSequence (s));
+ mcDebug_assert (decl_isStatementSequence (static_cast<decl_node> (s)));
h = Indexing_HighIndice (s->stmtF.statements);
i = 1;
while (i <= h)
{
- doStatementsC (p, reinterpret_cast<decl_node> (Indexing_GetIndice (s->stmtF.statements, i)));
+ doStatementsC (p, static_cast<decl_node__opaque> (Indexing_GetIndice (s->stmtF.statements, i)));
i += 1;
}
}
isStatementSequenceEmpty -
*/
-static bool isStatementSequenceEmpty (decl_node s)
+static bool isStatementSequenceEmpty (decl_node__opaque s)
{
- mcDebug_assert (decl_isStatementSequence (s));
+ mcDebug_assert (decl_isStatementSequence (static_cast<decl_node> (s)));
return (Indexing_HighIndice (s->stmtF.statements)) == 0;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
only one statement.
*/
-static bool isSingleStatement (decl_node s)
+static bool isSingleStatement (decl_node__opaque s)
{
unsigned int h;
- mcDebug_assert (decl_isStatementSequence (s));
+ mcDebug_assert (decl_isStatementSequence (static_cast<decl_node> (s)));
h = Indexing_HighIndice (s->stmtF.statements);
if ((h == 0) || (h > 1))
{
return false;
}
- s = static_cast<decl_node> (Indexing_GetIndice (s->stmtF.statements, 1));
- return (! (decl_isStatementSequence (s))) || (isSingleStatement (s));
+ s = static_cast<decl_node__opaque> (Indexing_GetIndice (s->stmtF.statements, 1));
+ return (! (decl_isStatementSequence (static_cast<decl_node> (s)))) || (isSingleStatement (s));
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
doCommentC -
*/
-static void doCommentC (mcPretty_pretty p, decl_node s)
+static void doCommentC (mcPretty_pretty p, decl_node__opaque s)
{
DynamicStrings_String c;
doAfterCommentC - emit an after comment, c, or a newline if, c, is empty.
*/
-static void doAfterCommentC (mcPretty_pretty p, decl_node c)
+static void doAfterCommentC (mcPretty_pretty p, decl_node__opaque c)
{
if (c == NULL)
{
doReturnC - issue a return statement and also place in an after comment if one exists.
*/
-static void doReturnC (mcPretty_pretty p, decl_node s)
+static void doReturnC (mcPretty_pretty p, decl_node__opaque s)
{
- mcDebug_assert (decl_isReturn (s));
+ decl_node__opaque type;
+
+ mcDebug_assert (decl_isReturn (static_cast<decl_node> (s)));
doCommentC (p, s->returnF.returnComment.body);
outText (p, (const char *) "return", 6);
- if (s->returnF.scope != NULL)
+ if ((s->returnF.scope != NULL) && (s->returnF.exp != NULL))
{
mcPretty_setNeedSpace (p);
- if ((! (decl_isProcedure (s->returnF.scope))) || ((decl_getType (s->returnF.scope)) == NULL))
+ if ((! (decl_isProcedure (static_cast<decl_node> (s->returnF.scope)))) || ((decl_getType (static_cast<decl_node> (s->returnF.scope))) == NULL))
{
mcMetaError_metaError1 ((const char *) "{%1DMad} has no return type", 27, (const unsigned char *) &s->returnF.scope, (sizeof (s->returnF.scope)-1));
}
else
{
- doExprCastC (p, s->returnF.exp, decl_getType (s->returnF.scope));
+ if ((decl_isProcedure (static_cast<decl_node> (s->returnF.scope))) && (nodeUsesOpaque (s->returnF.scope)))
+ {
+ forceCastOpaque (p, s->returnF.scope, s->returnF.exp, getNodeOpaqueVoidStar (s->returnF.scope));
+ }
+ else
+ {
+ doExprCastC (p, s->returnF.exp, static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (s->returnF.scope))));
+ }
}
}
outText (p, (const char *) ";", 1);
isZtypeEquivalent -
*/
-static bool isZtypeEquivalent (decl_node type)
+static bool isZtypeEquivalent (decl_node__opaque type)
{
switch (type->kind)
{
isEquivalentType - returns TRUE if type1 and type2 are equivalent.
*/
-static bool isEquivalentType (decl_node type1, decl_node type2)
+static bool isEquivalentType (decl_node__opaque type1, decl_node__opaque type2)
{
- type1 = decl_skipType (type1);
- type2 = decl_skipType (type2);
+ type1 = static_cast<decl_node__opaque> (decl_skipType (static_cast<decl_node> (type1)));
+ type2 = static_cast<decl_node__opaque> (decl_skipType (static_cast<decl_node> (type2)));
return (type1 == type2) || ((isZtypeEquivalent (type1)) && (isZtypeEquivalent (type2)));
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
doExprCastC - build a cast if necessary.
*/
-static void doExprCastC (mcPretty_pretty p, decl_node e, decl_node type)
+static void doExprCastC (mcPretty_pretty p, decl_node__opaque e, decl_node__opaque type)
{
- decl_node stype;
+ decl_node__opaque stype;
- stype = decl_skipType (type);
- if ((! (isEquivalentType (type, getExprType (e)))) && (! ((e->kind == decl_nil) && ((decl_isPointer (stype)) || (stype->kind == decl_address)))))
+ stype = static_cast<decl_node__opaque> (decl_skipType (static_cast<decl_node> (type)));
+ if ((! (isEquivalentType (type, getExprType (e)))) && (! ((e->kind == decl_nil) && ((decl_isPointer (static_cast<decl_node> (stype))) || (stype->kind == decl_address)))))
{
if (lang == decl_ansiCP)
{
/* avoid gcc warning by using compound statement even if not strictly necessary. */
/* potentially a cast is required. */
- if ((decl_isPointer (type)) || (type == addressN))
+ if ((decl_isPointer (static_cast<decl_node> (type))) || (type == addressN))
{
- outText (p, (const char *) "reinterpret_cast<", 17);
+ outText (p, (const char *) "static_cast<", 12);
doTypeNameC (p, type);
mcPretty_noSpace (p);
outText (p, (const char *) "> (", 3);
doExprC (p, e);
outText (p, (const char *) ")", 1);
- return ;
+ return;
}
else
{
outText (p, (const char *) "static_cast<", 12);
- if (decl_isProcType (decl_skipType (type)))
+ if (decl_isProcType (decl_skipType (static_cast<decl_node> (type))))
{
doTypeNameC (p, type);
outText (p, (const char *) "_t", 2);
outText (p, (const char *) "> (", 3);
doExprC (p, e);
outText (p, (const char *) ")", 1);
- return ;
+ return;
}
}
}
requiresUnpackProc - returns TRUE if either the expr is a procedure or the proctypes differ.
*/
-static bool requiresUnpackProc (decl_node s)
+static bool requiresUnpackProc (decl_node__opaque s)
{
mcDebug_assert (isAssignment (s));
- return (decl_isProcedure (s->assignmentF.expr)) || ((decl_skipType (decl_getType (s->assignmentF.des))) != (decl_skipType (decl_getType (s->assignmentF.expr))));
+ return (decl_isProcedure (static_cast<decl_node> (s->assignmentF.expr))) || ((decl_skipType (decl_getType (static_cast<decl_node> (s->assignmentF.des)))) != (decl_skipType (decl_getType (static_cast<decl_node> (s->assignmentF.expr)))));
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
+/*
+ forceCastOpaque -
+*/
+
+static void forceCastOpaque (mcPretty_pretty p, decl_node__opaque des, decl_node__opaque expr, bool toVoidStar)
+{
+ if (nodeUsesOpaque (expr))
+ {
+ flushOpaque (p, expr, getNodeOpaqueVoidStar (des));
+ }
+ else
+ {
+ forceReintCastOpaque (p, des, expr, toVoidStar);
+ }
+}
+
+
+/*
+ forceReintCastOpaque -
+*/
+
+static void forceReintCastOpaque (mcPretty_pretty p, decl_node__opaque des, decl_node__opaque expr, bool toVoidStar)
+{
+ decl_node__opaque type;
+
+ type = static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (des)));
+ if (toVoidStar)
+ {
+ /* next is true cast to void * opaque type. */
+ outText (p, (const char *) "static_cast<", 12);
+ doTypeNameC (p, type);
+ mcPretty_noSpace (p);
+ outText (p, (const char *) "> (", 3);
+ doExprC (p, expr);
+ outText (p, (const char *) ")", 1);
+ }
+ else
+ {
+ /* next is false cast to __opaque opaque type. */
+ outText (p, (const char *) "static_cast<", 12);
+ doTypeNameC (p, type);
+ outText (p, (const char *) "__opaque", 8);
+ mcPretty_noSpace (p);
+ outText (p, (const char *) "> (", 3);
+ doExprC (p, expr);
+ outText (p, (const char *) ")", 1);
+ }
+}
+
+
+/*
+ doUnConstCastUnbounded - if node n type is an unbounded array then
+ use const_cast to remove the const parameter
+ to allow the unbounded array to be modified.
+*/
+
+static void doUnConstCastUnbounded (mcPretty_pretty p, decl_node__opaque n)
+{
+ decl_node__opaque type;
+ decl_node__opaque v;
+
+ if (isArrayRef (n))
+ {
+ if (decl_isVar (static_cast<decl_node> (n->arrayrefF.array)))
+ {
+ v = n->arrayrefF.array;
+ if ((v->varF.isParameter || v->varF.isVarParameter) && (decl_isUnbounded (decl_getType (static_cast<decl_node> (v)))))
+ {
+ type = static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (v)));
+ outText (p, (const char *) " /* const_cast<", 15);
+ doTypeNameC (p, type);
+ outText (p, (const char *) "> is needed */ ", 15);
+ }
+ }
+ }
+}
+
+
/*
doAssignmentC -
*/
-static void doAssignmentC (mcPretty_pretty p, decl_node s)
+static void doAssignmentC (mcPretty_pretty p, decl_node__opaque s)
{
mcDebug_assert (isAssignment (s));
doCommentC (p, s->assignmentF.assignComment.body);
- doExprCup (p, s->assignmentF.des, requiresUnpackProc (s));
+ if (debugOpaque)
+ {
+ outText (p, (const char *) " /* des: */ ", 12);
+ dumpOpaqueState (s->assignmentF.des);
+ outText (p, (const char *) " /* expr: */ ", 13);
+ dumpOpaqueState (s->assignmentF.expr);
+ }
+ s->assignmentF.des = doExprCup (p, s->assignmentF.des, requiresUnpackProc (s), true);
+ if (debugOpaque)
+ {
+ outText (p, (const char *) "\\n /* after doExprCup des: */ ", 30);
+ dumpOpaqueState (s->assignmentF.des);
+ outText (p, (const char *) "\\n", 2);
+ }
mcPretty_setNeedSpace (p);
outText (p, (const char *) "=", 1);
mcPretty_setNeedSpace (p);
- doExprCastC (p, s->assignmentF.expr, decl_getType (s->assignmentF.des));
+ if (nodeUsesOpaque (s->assignmentF.des))
+ {
+ forceCastOpaque (p, s->assignmentF.des, s->assignmentF.expr, getNodeOpaqueVoidStar (s->assignmentF.des));
+ }
+ else
+ {
+ if (debugOpaque)
+ {
+ outText (p, (const char *) " /* no opaque des seen */ ", 26);
+ }
+ doExprCastC (p, s->assignmentF.expr, static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (s->assignmentF.des))));
+ }
outText (p, (const char *) ";", 1);
doAfterCommentC (p, s->assignmentF.assignComment.after);
}
containsStatement -
*/
-static bool containsStatement (decl_node s)
+static bool containsStatement (decl_node__opaque s)
{
- return ((s != NULL) && (decl_isStatementSequence (s))) && (! (isStatementSequenceEmpty (s)));
+ return ((s != NULL) && (decl_isStatementSequence (static_cast<decl_node> (s)))) && (! (isStatementSequenceEmpty (s)));
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
doCompoundStmt -
*/
-static void doCompoundStmt (mcPretty_pretty p, decl_node s)
+static void doCompoundStmt (mcPretty_pretty p, decl_node__opaque s)
{
- if ((s == NULL) || ((decl_isStatementSequence (s)) && (isStatementSequenceEmpty (s))))
+ if ((s == NULL) || ((decl_isStatementSequence (static_cast<decl_node> (s))) && (isStatementSequenceEmpty (s))))
{
p = mcPretty_pushPretty (p);
mcPretty_setindent (p, (mcPretty_getindent (p))+indentationC);
outText (p, (const char *) "{} /* empty. */\\n", 19);
p = mcPretty_popPretty (p);
}
- else if (((decl_isStatementSequence (s)) && (isSingleStatement (s))) && ! forceCompoundStatement)
+ else if (((decl_isStatementSequence (static_cast<decl_node> (s))) && (isSingleStatement (s))) && ! forceCompoundStatement)
{
/* avoid dangling else. */
p = mcPretty_pushPretty (p);
doElsifC -
*/
-static void doElsifC (mcPretty_pretty p, decl_node s)
+static void doElsifC (mcPretty_pretty p, decl_node__opaque s)
{
- mcDebug_assert (decl_isElsif (s));
+ mcDebug_assert (decl_isElsif (static_cast<decl_node> (s)));
outText (p, (const char *) "else if", 7);
mcPretty_setNeedSpace (p);
outText (p, (const char *) "(", 1);
doCompoundStmt (p, s->elsifF.else_);
}
}
- else if ((s->elsifF.elsif != NULL) && (decl_isElsif (s->elsifF.elsif)))
+ else if ((s->elsifF.elsif != NULL) && (decl_isElsif (static_cast<decl_node> (s->elsifF.elsif))))
{
/* avoid dangling else. */
doElsifC (p, s->elsifF.elsif);
noIfElse -
*/
-static bool noIfElse (decl_node n)
+static bool noIfElse (decl_node__opaque n)
{
- return (((n != NULL) && (decl_isIf (n))) && (n->ifF.else_ == NULL)) && (n->ifF.elsif == NULL);
+ return (((n != NULL) && (decl_isIf (static_cast<decl_node> (n)))) && (n->ifF.else_ == NULL)) && (n->ifF.elsif == NULL);
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
in a return value of TRUE.
*/
-static bool noIfElseChained (decl_node n)
+static bool noIfElseChained (decl_node__opaque n)
{
- decl_node e;
+ decl_node__opaque e;
if (n != NULL)
{
/* avoid gcc warning by using compound statement even if not strictly necessary. */
- if (decl_isIf (n))
+ if (decl_isIf (static_cast<decl_node> (n)))
{
if (n->ifF.else_ != NULL)
{
/* avoid dangling else. */
/* test elsif for lack of else. */
e = n->ifF.elsif;
- mcDebug_assert (decl_isElsif (e));
+ mcDebug_assert (decl_isElsif (static_cast<decl_node> (e)));
return noIfElseChained (e);
}
}
- else if (decl_isElsif (n))
+ else if (decl_isElsif (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
if (n->elsifF.else_ != NULL)
/* avoid dangling else. */
/* test elsif for lack of else. */
e = n->elsifF.elsif;
- mcDebug_assert (decl_isElsif (e));
+ mcDebug_assert (decl_isElsif (static_cast<decl_node> (e)));
return noIfElseChained (e);
}
}
hasIfElse -
*/
-static bool hasIfElse (decl_node n)
+static bool hasIfElse (decl_node__opaque n)
{
if (n != NULL)
{
- if (decl_isStatementSequence (n))
+ if (decl_isStatementSequence (static_cast<decl_node> (n)))
{
/* avoid gcc warning by using compound statement even if not strictly necessary. */
if (isStatementSequenceEmpty (n))
else if (isSingleStatement (n))
{
/* avoid dangling else. */
- n = static_cast<decl_node> (Indexing_GetIndice (n->stmtF.statements, 1));
+ n = static_cast<decl_node__opaque> (Indexing_GetIndice (n->stmtF.statements, 1));
return isIfElse (n);
}
}
isIfElse -
*/
-static bool isIfElse (decl_node n)
+static bool isIfElse (decl_node__opaque n)
{
- return ((n != NULL) && (decl_isIf (n))) && ((n->ifF.else_ != NULL) || (n->ifF.elsif != NULL));
+ return ((n != NULL) && (decl_isIf (static_cast<decl_node> (n)))) && ((n->ifF.else_ != NULL) || (n->ifF.elsif != NULL));
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
which is an IF and it has no else statement.
*/
-static bool hasIfAndNoElse (decl_node n)
+static bool hasIfAndNoElse (decl_node__opaque n)
{
if (n != NULL)
{
/* avoid gcc warning by using compound statement even if not strictly necessary. */
- if (decl_isStatementSequence (n))
+ if (decl_isStatementSequence (static_cast<decl_node> (n)))
{
if (isStatementSequenceEmpty (n))
{
else if (isSingleStatement (n))
{
/* avoid dangling else. */
- n = static_cast<decl_node> (Indexing_GetIndice (n->stmtF.statements, 1));
+ n = static_cast<decl_node__opaque> (Indexing_GetIndice (n->stmtF.statements, 1));
return hasIfAndNoElse (n);
}
else
{
/* avoid dangling else. */
- n = static_cast<decl_node> (Indexing_GetIndice (n->stmtF.statements, Indexing_HighIndice (n->stmtF.statements)));
+ n = static_cast<decl_node__opaque> (Indexing_GetIndice (n->stmtF.statements, Indexing_HighIndice (n->stmtF.statements)));
return hasIfAndNoElse (n);
}
}
- else if ((decl_isElsif (n)) || (decl_isIf (n)))
+ else if ((decl_isElsif (static_cast<decl_node> (n))) || (decl_isIf (static_cast<decl_node> (n))))
{
/* avoid dangling else. */
return noIfElseChained (n);
The if statement might contain an else or elsif which are also handled.
*/
-static void doIfC (mcPretty_pretty p, decl_node s)
+static void doIfC (mcPretty_pretty p, decl_node__opaque s)
{
- mcDebug_assert (decl_isIf (s));
+ mcDebug_assert (decl_isIf (static_cast<decl_node> (s)));
doCommentC (p, s->ifF.ifComment.body);
outText (p, (const char *) "if", 2);
mcPretty_setNeedSpace (p);
doAfterCommentC (p, s->ifF.elseComment.after);
doCompoundStmt (p, s->ifF.else_);
}
- else if ((s->ifF.elsif != NULL) && (decl_isElsif (s->ifF.elsif)))
+ else if ((s->ifF.elsif != NULL) && (decl_isElsif (static_cast<decl_node> (s->ifF.elsif))))
{
/* avoid dangling else. */
doCommentC (p, s->ifF.elseComment.body);
doForIncCP -
*/
-static void doForIncCP (mcPretty_pretty p, decl_node s)
+static void doForIncCP (mcPretty_pretty p, decl_node__opaque s)
{
- decl_node t;
+ decl_node__opaque t;
- mcDebug_assert (decl_isFor (s));
- t = decl_skipType (decl_getType (s->forF.des));
- if (decl_isEnumeration (t))
+ mcDebug_assert (decl_isFor (static_cast<decl_node> (s)));
+ t = static_cast<decl_node__opaque> (decl_skipType (decl_getType (static_cast<decl_node> (s->forF.des))));
+ if (decl_isEnumeration (static_cast<decl_node> (t)))
{
if (s->forF.increment == NULL)
{
doExprC (p, s->forF.des);
outText (p, (const char *) "= static_cast<", 14);
- doTypeNameC (p, decl_getType (s->forF.des));
+ doTypeNameC (p, static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (s->forF.des))));
mcPretty_noSpace (p);
outText (p, (const char *) ">(static_cast<int>(", 19);
doExprC (p, s->forF.des);
{
doExprC (p, s->forF.des);
outText (p, (const char *) "= static_cast<", 14);
- doTypeNameC (p, decl_getType (s->forF.des));
+ doTypeNameC (p, static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (s->forF.des))));
mcPretty_noSpace (p);
outText (p, (const char *) ">(static_cast<int>(", 19);
doExprC (p, s->forF.des);
doForIncC -
*/
-static void doForIncC (mcPretty_pretty p, decl_node s)
+static void doForIncC (mcPretty_pretty p, decl_node__opaque s)
{
if (s->forF.increment == NULL)
{
doForInc -
*/
-static void doForInc (mcPretty_pretty p, decl_node s)
+static void doForInc (mcPretty_pretty p, decl_node__opaque s)
{
if (lang == decl_ansiCP)
{
doForC -
*/
-static void doForC (mcPretty_pretty p, decl_node s)
+static void doForC (mcPretty_pretty p, decl_node__opaque s)
{
- mcDebug_assert (decl_isFor (s));
+ mcDebug_assert (decl_isFor (static_cast<decl_node> (s)));
outText (p, (const char *) "for (", 5);
doExprC (p, s->forF.des);
outText (p, (const char *) "=", 1);
doRepeatC -
*/
-static void doRepeatC (mcPretty_pretty p, decl_node s)
+static void doRepeatC (mcPretty_pretty p, decl_node__opaque s)
{
- mcDebug_assert (decl_isRepeat (s));
+ mcDebug_assert (decl_isRepeat (static_cast<decl_node> (s)));
doCommentC (p, s->repeatF.repeatComment.body);
outText (p, (const char *) "do {", 4);
doAfterCommentC (p, s->repeatF.repeatComment.after);
doWhileC -
*/
-static void doWhileC (mcPretty_pretty p, decl_node s)
+static void doWhileC (mcPretty_pretty p, decl_node__opaque s)
{
- mcDebug_assert (decl_isWhile (s));
+ mcDebug_assert (decl_isWhile (static_cast<decl_node> (s)));
doCommentC (p, s->whileF.doComment.body);
outText (p, (const char *) "while (", 7);
doExprC (p, s->whileF.expr);
doFuncHighC -
*/
-static void doFuncHighC (mcPretty_pretty p, decl_node a)
+static void doFuncHighC (mcPretty_pretty p, decl_node__opaque a)
{
- decl_node s;
- decl_node n;
+ decl_node__opaque s;
+ decl_node__opaque n;
- if ((decl_isLiteral (a)) && ((decl_getType (a)) == charN))
+ if ((decl_isLiteral (static_cast<decl_node> (a))) && ((decl_getType (static_cast<decl_node> (a))) == charN))
{
outCard (p, 0);
}
/* avoid dangling else. */
outCard (p, a->stringF.length-2);
}
- else if ((decl_isConst (a)) && (isString (a->constF.value)))
+ else if ((decl_isConst (static_cast<decl_node> (a))) && (isString (a->constF.value)))
{
/* avoid dangling else. */
doFuncHighC (p, a->constF.value);
}
- else if (decl_isUnbounded (decl_getType (a)))
+ else if (decl_isUnbounded (decl_getType (static_cast<decl_node> (a))))
{
/* avoid dangling else. */
outText (p, (const char *) "_", 1);
- outTextN (p, decl_getSymName (a));
+ outTextN (p, decl_getSymName (static_cast<decl_node> (a)));
outText (p, (const char *) "_high", 5);
}
- else if (decl_isArray (decl_skipType (decl_getType (a))))
+ else if (decl_isArray (decl_skipType (decl_getType (static_cast<decl_node> (a)))))
{
/* avoid dangling else. */
- n = decl_skipType (decl_getType (a));
+ n = static_cast<decl_node__opaque> (decl_skipType (decl_getType (static_cast<decl_node> (a))));
s = n->arrayF.subr;
if (isZero (getMin (s)))
{
doMultiplyBySize -
*/
-static void doMultiplyBySize (mcPretty_pretty p, decl_node a)
+static void doMultiplyBySize (mcPretty_pretty p, decl_node__opaque a)
{
if (((a != charN) && (a != byteN)) && (a != locN))
{
doTotype -
*/
-static void doTotype (mcPretty_pretty p, decl_node a, decl_node t)
+static void doTotype (mcPretty_pretty p, decl_node__opaque a, decl_node__opaque t)
{
- if ((! (isString (a))) && (! (decl_isLiteral (a))))
+ if ((! (isString (a))) && (! (decl_isLiteral (static_cast<decl_node> (a)))))
{
- if (decl_isVar (a))
+ if (decl_isVar (static_cast<decl_node> (a)))
{
- if (((a->varF.isParameter || a->varF.isVarParameter) && (decl_isUnbounded (decl_getType (a)))) && ((decl_skipType (decl_getType (decl_getType (a)))) == (decl_skipType (decl_getType (t)))))
+ if (((a->varF.isParameter || a->varF.isVarParameter) && (decl_isUnbounded (decl_getType (static_cast<decl_node> (a))))) && ((decl_skipType (decl_getType (decl_getType (static_cast<decl_node> (a))))) == (decl_skipType (decl_getType (static_cast<decl_node> (t))))))
{
/* do not multiply by size as the existing high value is correct. */
- return ;
+ return;
}
- a = decl_getType (a);
- if (decl_isArray (a))
+ a = static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (a)));
+ if (decl_isArray (static_cast<decl_node> (a)))
{
- doMultiplyBySize (p, decl_skipType (decl_getType (a)));
+ doMultiplyBySize (p, static_cast<decl_node__opaque> (decl_skipType (decl_getType (static_cast<decl_node> (a)))));
}
}
}
doFuncUnbounded -
*/
-static void doFuncUnbounded (mcPretty_pretty p, decl_node actual, decl_node formalParam, decl_node formal, decl_node func)
+static void doFuncUnbounded (mcPretty_pretty p, decl_node__opaque actual, decl_node__opaque formalParam, decl_node__opaque formal, decl_node__opaque func)
{
- decl_node h;
+ decl_node__opaque h;
DynamicStrings_String s;
- mcDebug_assert (decl_isUnbounded (formal));
+ mcDebug_assert (decl_isUnbounded (static_cast<decl_node> (formal)));
outText (p, (const char *) "(", 1);
- if ((lang == decl_ansiCP) && (decl_isParam (formalParam)))
+ if ((lang == decl_ansiCP) && (decl_isParam (static_cast<decl_node> (formalParam))))
{
outText (p, (const char *) "const", 5);
mcPretty_setNeedSpace (p);
}
- doTypeC (p, decl_getType (formal), &formal);
+ doTypeC (p, static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (formal))), &formal);
mcPretty_setNeedSpace (p);
outText (p, (const char *) "*)", 2);
mcPretty_setNeedSpace (p);
- if ((decl_isLiteral (actual)) && ((decl_getType (actual)) == charN))
+ if ((decl_isLiteral (static_cast<decl_node> (actual))) && ((decl_getType (static_cast<decl_node> (actual))) == charN))
{
outText (p, (const char *) "\"\\0", 3);
s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (actual->literalF.name));
/* avoid dangling else. */
outCstring (p, actual, true);
}
- else if (decl_isConst (actual))
+ else if (decl_isConst (static_cast<decl_node> (actual)))
{
/* avoid dangling else. */
actual = resolveString (actual);
doExprC (p, actual);
}
}
- else if (decl_isUnbounded (decl_getType (actual)))
+ else if (decl_isUnbounded (decl_getType (static_cast<decl_node> (actual))))
{
/* avoid dangling else. */
/* doExprC (p, actual). */
/* avoid dangling else. */
outText (p, (const char *) "&", 1);
doExprC (p, actual);
- if (decl_isArray (decl_skipType (decl_getType (actual))))
+ if (decl_isArray (decl_skipType (decl_getType (static_cast<decl_node> (actual)))))
{
outText (p, (const char *) ".array[0]", 9);
}
}
- if (! (enableDefForCStrings && (isDefForC (decl_getScope (func)))))
+ if (! (enableDefForCStrings && (isDefForC (static_cast<decl_node__opaque> (decl_getScope (static_cast<decl_node> (func)))))))
{
outText (p, (const char *) ",", 1);
mcPretty_setNeedSpace (p);
doProcedureParamC -
*/
-static void doProcedureParamC (mcPretty_pretty p, decl_node actual, decl_node formal)
+static void doProcedureParamC (mcPretty_pretty p, decl_node__opaque actual, decl_node__opaque formal)
{
if (isForC (formal))
{
outText (p, (const char *) "(", 1);
- doFQNameC (p, decl_getType (formal));
+ doFQNameC (p, static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (formal))));
outText (p, (const char *) "_C", 2);
outText (p, (const char *) ")", 1);
mcPretty_setNeedSpace (p);
else
{
outText (p, (const char *) "(", 1);
- doTypeNameC (p, decl_getType (formal));
+ doTypeNameC (p, static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (formal))));
outText (p, (const char *) ")", 1);
mcPretty_setNeedSpace (p);
outText (p, (const char *) "{", 1);
outText (p, (const char *) "(", 1);
- doFQNameC (p, decl_getType (formal));
+ doFQNameC (p, static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (formal))));
outText (p, (const char *) "_t)", 3);
mcPretty_setNeedSpace (p);
doExprC (p, actual);
doAdrExprC -
*/
-static void doAdrExprC (mcPretty_pretty p, decl_node n)
+static void doAdrExprC (mcPretty_pretty p, decl_node__opaque n)
{
if (isDeref (n))
{
- /* no point in issuing & ( * n ) */
+ /* No point in issuing & ( * n ). */
doExprC (p, n->unaryF.arg);
}
- else if ((decl_isVar (n)) && n->varF.isVarParameter)
+ else if ((decl_isVar (static_cast<decl_node> (n))) && n->varF.isVarParameter)
{
/* avoid dangling else. */
- /* no point in issuing & ( * n ) */
+ /* No point in issuing & ( * n ). */
doFQNameC (p, n);
}
else
typePair -
*/
-static bool typePair (decl_node a, decl_node b, decl_node x, decl_node y)
+static bool typePair (decl_node__opaque a, decl_node__opaque b, decl_node__opaque x, decl_node__opaque y)
{
return ((a == x) && (b == y)) || ((a == y) && (b == x));
/* static analysis guarentees a RETURN statement will be used before here. */
the formal type.
*/
-static bool needsCast (decl_node at, decl_node ft)
+static bool needsCast (decl_node__opaque at, decl_node__opaque ft)
{
- at = decl_skipType (at);
- ft = decl_skipType (ft);
+ at = static_cast<decl_node__opaque> (decl_skipType (static_cast<decl_node> (at)));
+ ft = static_cast<decl_node__opaque> (decl_skipType (static_cast<decl_node> (ft)));
if (((((((((((((at == nilN) || (at->kind == decl_nil)) || (at == ft)) || (typePair (at, ft, cardinalN, wordN))) || (typePair (at, ft, cardinalN, ztypeN))) || (typePair (at, ft, integerN, ztypeN))) || (typePair (at, ft, longcardN, ztypeN))) || (typePair (at, ft, shortcardN, ztypeN))) || (typePair (at, ft, longintN, ztypeN))) || (typePair (at, ft, shortintN, ztypeN))) || (typePair (at, ft, realN, rtypeN))) || (typePair (at, ft, longrealN, rtypeN))) || (typePair (at, ft, shortrealN, rtypeN)))
{
return false;
open parenthesis.
*/
-static unsigned int checkSystemCast (mcPretty_pretty p, decl_node actual, decl_node formal)
+static unsigned int checkSystemCast (mcPretty_pretty p, decl_node__opaque actual, decl_node__opaque formal)
{
- decl_node at;
- decl_node ft;
+ decl_node__opaque at;
+ decl_node__opaque ft;
at = getExprType (actual);
- ft = decl_getType (formal);
+ ft = static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (formal)));
if (needsCast (at, ft))
{
/* avoid gcc warning by using compound statement even if not strictly necessary. */
if (lang == decl_ansiCP)
{
- if ((isString (actual)) && ((decl_skipType (ft)) == addressN))
+ if ((isString (actual)) && ((decl_skipType (static_cast<decl_node> (ft))) == addressN))
{
- outText (p, (const char *) "const_cast<void*> (reinterpret_cast<const void*> (", 50);
+ outText (p, (const char *) "const_cast<void*> (static_cast<const void*> (", 45);
return 2;
}
- else if ((decl_isPointer (decl_skipType (ft))) || ((decl_skipType (ft)) == addressN))
+ else if ((decl_isPointer (decl_skipType (static_cast<decl_node> (ft)))) || ((decl_skipType (static_cast<decl_node> (ft))) == addressN))
{
/* avoid dangling else. */
if (actual == nilN)
{
- if (decl_isVarParam (formal))
+ if (decl_isVarParam (static_cast<decl_node> (formal)))
{
mcMetaError_metaError1 ((const char *) "NIL is being passed to a VAR parameter {%1DMad}", 47, (const unsigned char *) &formal, (sizeof (formal)-1));
}
{
outText (p, (const char *) "reinterpret_cast<", 17);
doTypeNameC (p, ft);
- if (decl_isVarParam (formal))
+ if (decl_isVarParam (static_cast<decl_node> (formal)))
{
outText (p, (const char *) "*", 1);
}
/* avoid dangling else. */
outText (p, (const char *) "static_cast<", 12);
doTypeNameC (p, ft);
- if (decl_isVarParam (formal))
+ if (decl_isVarParam (static_cast<decl_node> (formal)))
{
outText (p, (const char *) "*", 1);
}
{
outText (p, (const char *) "(", 1);
doTypeNameC (p, ft);
- if (decl_isVarParam (formal))
+ if (decl_isVarParam (static_cast<decl_node> (formal)))
{
outText (p, (const char *) "*", 1);
}
which was declared inside a definition module for "C".
*/
-static bool isForC (decl_node n)
+static bool isForC (decl_node__opaque n)
{
- if (decl_isVarParam (n))
+ if (decl_isVarParam (static_cast<decl_node> (n)))
{
return n->varparamF.isForC;
}
- else if (decl_isParam (n))
+ else if (decl_isParam (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
return n->paramF.isForC;
}
- else if (decl_isProcedure (n))
+ else if (decl_isProcedure (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
return n->procedureF.isForC;
}
- return false;
+ return false;
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
+}
+
+
+/*
+ isDefForCNode - return TRUE if node n was declared inside a definition module for "C".
+*/
+
+static bool isDefForCNode (decl_node__opaque n)
+{
+ nameKey_Name name;
+
+ while ((n != NULL) && (! (((decl_isImp (static_cast<decl_node> (n))) || (decl_isDef (static_cast<decl_node> (n)))) || (decl_isModule (static_cast<decl_node> (n))))))
+ {
+ n = static_cast<decl_node__opaque> (decl_getScope (static_cast<decl_node> (n)));
+ }
+ if ((n != NULL) && (decl_isImp (static_cast<decl_node> (n))))
+ {
+ name = decl_getSymName (static_cast<decl_node> (n));
+ n = static_cast<decl_node__opaque> (decl_lookupDef (name));
+ }
+ return ((n != NULL) && (decl_isDef (static_cast<decl_node> (n)))) && (isDefForC (n));
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
/*
- isDefForCNode - return TRUE if node n was declared inside a definition module for "C".
+ doFuncVarParam - detect whether the formal uses an opaque and ensure that the address of
+ the actual parameter is cast to the formal type.
*/
-static bool isDefForCNode (decl_node n)
+static void doFuncVarParam (mcPretty_pretty p, decl_node__opaque actual, decl_node__opaque formal)
{
- nameKey_Name name;
+ decl_node__opaque type;
- while ((n != NULL) && (! (((decl_isImp (n)) || (decl_isDef (n))) || (decl_isModule (n)))))
+ if ((nodeUsesOpaque (formal)) && (getNodeOpaqueFlushNecessary (actual, getNodeOpaqueVoidStar (formal))))
{
- n = decl_getScope (n);
+ type = static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (formal)));
+ outText (p, (const char *) "reinterpret_cast<", 17);
+ if (getNodeOpaqueVoidStar (formal))
+ {
+ doTypeNameC (p, type);
+ mcPretty_setNeedSpace (p);
+ outText (p, (const char *) "*> (&", 5);
+ doExprC (p, actual);
+ outText (p, (const char *) ")", 1);
+ actual = makeOpaqueCast (actual, true);
+ }
+ else
+ {
+ doTypeNameC (p, type);
+ mcPretty_noSpace (p);
+ outText (p, (const char *) "__opaque *> (&", 14);
+ doExprC (p, actual);
+ outText (p, (const char *) ")", 1);
+ actual = makeOpaqueCast (actual, false);
+ }
}
- if ((n != NULL) && (decl_isImp (n)))
+ else
{
- name = decl_getSymName (n);
- n = decl_lookupDef (name);
+ doAdrExprC (p, actual);
}
- return ((n != NULL) && (decl_isDef (n))) && (isDefForC (n));
- /* static analysis guarentees a RETURN statement will be used before here. */
- __builtin_unreachable ();
}
doFuncParamC -
*/
-static void doFuncParamC (mcPretty_pretty p, decl_node actual, decl_node formal, decl_node func)
+static void doFuncParamC (mcPretty_pretty p, decl_node__opaque actual, decl_node__opaque formal, decl_node__opaque func)
{
- decl_node ft;
- decl_node at;
+ decl_node__opaque ft;
+ decl_node__opaque at;
unsigned int lbr;
if (formal == NULL)
}
else
{
- ft = decl_skipType (decl_getType (formal));
- if (decl_isUnbounded (ft))
+ ft = static_cast<decl_node__opaque> (decl_skipType (decl_getType (static_cast<decl_node> (formal))));
+ if (decl_isUnbounded (static_cast<decl_node> (ft)))
{
doFuncUnbounded (p, actual, formal, ft, func);
}
else
{
- if ((isAProcType (ft)) && (decl_isProcedure (actual)))
+ if ((isAProcType (ft)) && (decl_isProcedure (static_cast<decl_node> (actual))))
{
- if (decl_isVarParam (formal))
+ if (decl_isVarParam (static_cast<decl_node> (formal)))
{
mcMetaError_metaError1 ((const char *) "{%1MDad} cannot be passed as a VAR parameter", 44, (const unsigned char *) &actual, (sizeof (actual)-1));
}
doProcedureParamC (p, actual, formal);
}
}
- else if (((((decl_getType (actual)) != NULL) && (decl_isProcType (decl_skipType (decl_getType (actual))))) && (isAProcType (ft))) && (isForC (formal)))
+ else if (((((decl_getType (static_cast<decl_node> (actual))) != NULL) && (decl_isProcType (decl_skipType (decl_getType (static_cast<decl_node> (actual)))))) && (isAProcType (ft))) && (isForC (formal)))
{
/* avoid dangling else. */
- if (decl_isVarParam (formal))
+ if (decl_isVarParam (static_cast<decl_node> (formal)))
{
mcMetaError_metaError2 ((const char *) "{%1MDad} cannot be passed as a VAR parameter to the definition for C module as the parameter requires a cast to the formal type {%2MDtad}", 137, (const unsigned char *) &actual, (sizeof (actual)-1), (const unsigned char *) &formal, (sizeof (formal)-1));
}
else
{
outText (p, (const char *) "(", 1);
- doFQNameC (p, decl_getType (formal));
+ doFQNameC (p, static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (formal))));
outText (p, (const char *) "_C", 2);
outText (p, (const char *) ")", 1);
mcPretty_setNeedSpace (p);
outText (p, (const char *) ".proc", 5);
}
}
- else if ((((decl_getType (actual)) != NULL) && (decl_isProcType (decl_skipType (decl_getType (actual))))) && ((decl_getType (actual)) != (decl_getType (formal))))
+ else if ((((decl_getType (static_cast<decl_node> (actual))) != NULL) && (decl_isProcType (decl_skipType (decl_getType (static_cast<decl_node> (actual)))))) && ((decl_getType (static_cast<decl_node> (actual))) != (decl_getType (static_cast<decl_node> (formal)))))
{
/* avoid dangling else. */
- if (decl_isVarParam (formal))
+ if (decl_isVarParam (static_cast<decl_node> (formal)))
{
mcMetaError_metaError2 ((const char *) "{%1MDad} cannot be passed as a VAR parameter as the parameter requires a cast to the formal type {%2MDtad}", 106, (const unsigned char *) &actual, (sizeof (actual)-1), (const unsigned char *) &formal, (sizeof (formal)-1));
}
else
{
- doCastC (p, decl_getType (formal), actual);
+ doCastC (p, static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (formal))), actual);
}
}
else
{
/* avoid dangling else. */
- lbr = checkSystemCast (p, actual, formal);
- if (decl_isVarParam (formal))
+ if (decl_isVarParam (static_cast<decl_node> (formal)))
{
- doAdrExprC (p, actual);
+ lbr = checkSystemCast (p, actual, formal);
+ doFuncVarParam (p, actual, formal);
+ emitN (p, (const char *) ")", 1, lbr);
}
else
{
- doExprC (p, actual);
+ if (nodeUsesOpaque (formal))
+ {
+ forceCastOpaque (p, formal, actual, getNodeOpaqueVoidStar (formal));
+ }
+ else
+ {
+ lbr = checkSystemCast (p, actual, formal);
+ doExprC (p, actual);
+ emitN (p, (const char *) ")", 1, lbr);
+ }
}
- emitN (p, (const char *) ")", 1, lbr);
}
}
}
If the parameter is a vararg NIL is returned.
*/
-static decl_node getNthParamType (Indexing_Index l, unsigned int i)
+static decl_node__opaque getNthParamType (Indexing_Index l, unsigned int i)
{
- decl_node p;
+ decl_node__opaque p;
p = getNthParam (l, i);
if (p != NULL)
{
- return decl_getType (p);
+ return static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (p)));
}
- return NULL;
+ return static_cast<decl_node__opaque> (NULL);
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
If the parameter is a vararg NIL is returned.
*/
-static decl_node getNthParam (Indexing_Index l, unsigned int i)
+static decl_node__opaque getNthParam (Indexing_Index l, unsigned int i)
{
- decl_node p;
+ decl_node__opaque p;
unsigned int j;
unsigned int k;
unsigned int h;
h = Indexing_HighIndice (l);
while (j <= h)
{
- p = static_cast<decl_node> (Indexing_GetIndice (l, j));
- if (decl_isParam (p))
+ p = static_cast<decl_node__opaque> (Indexing_GetIndice (l, j));
+ if (decl_isParam (static_cast<decl_node> (p)))
{
k = identListLen (p->paramF.namelist);
}
- else if (decl_isVarParam (p))
+ else if (decl_isVarParam (static_cast<decl_node> (p)))
{
/* avoid dangling else. */
k = identListLen (p->varparamF.namelist);
else
{
/* avoid dangling else. */
- mcDebug_assert (decl_isVarargs (p));
- return NULL;
+ mcDebug_assert (decl_isVarargs (static_cast<decl_node> (p)));
+ return static_cast<decl_node__opaque> (NULL);
}
if (i <= k)
{
}
}
}
- return NULL;
+ return static_cast<decl_node__opaque> (NULL);
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
doFuncArgsC -
*/
-static void doFuncArgsC (mcPretty_pretty p, decl_node s, Indexing_Index l, bool needParen)
+static void doFuncArgsC (mcPretty_pretty p, decl_node__opaque s, Indexing_Index l, bool needParen)
{
- decl_node actual;
- decl_node formal;
+ decl_node__opaque actual;
+ decl_node__opaque formal;
unsigned int i;
unsigned int n;
doProcTypeArgsC -
*/
-static void doProcTypeArgsC (mcPretty_pretty p, decl_node s, Indexing_Index args, bool needParen)
+static void doProcTypeArgsC (mcPretty_pretty p, decl_node__opaque s, Indexing_Index args, bool needParen)
{
- decl_node a;
- decl_node b;
+ decl_node__opaque a;
+ decl_node__opaque b;
unsigned int i;
unsigned int n;
while (i <= n)
{
a = getExpList (s->funccallF.args, i);
- b = static_cast<decl_node> (Indexing_GetIndice (args, i));
+ b = static_cast<decl_node__opaque> (Indexing_GetIndice (args, i));
doFuncParamC (p, a, b, s->funccallF.function);
if (i < n)
{
doAdrArgC -
*/
-static void doAdrArgC (mcPretty_pretty p, decl_node n)
+static void doAdrArgC (mcPretty_pretty p, decl_node__opaque n)
{
if (isDeref (n))
{
/* & and * cancel each other out. */
doExprC (p, n->unaryF.arg);
}
- else if ((decl_isVar (n)) && n->varF.isVarParameter)
+ else if ((decl_isVar (static_cast<decl_node> (n))) && n->varF.isVarParameter)
{
/* avoid dangling else. */
- outTextN (p, decl_getSymName (n)); /* --fixme-- does the caller need to cast it? */
+ outTextN (p, decl_getSymName (static_cast<decl_node> (n))); /* --fixme-- does the caller need to cast it? */
}
- else
+ else if ((isString (n)) || ((decl_isArray (decl_getType (static_cast<decl_node> (n)))) && (decl_isUnbounded (decl_getType (static_cast<decl_node> (n))))))
{
/* avoid dangling else. */
- if (isString (n))
+ if (lang == decl_ansiCP)
{
- if (lang == decl_ansiCP)
- {
- outText (p, (const char *) "const_cast<void*> (reinterpret_cast<const void*>", 48);
- outText (p, (const char *) "(", 1);
- doExprC (p, n);
- outText (p, (const char *) "))", 2);
- }
- else
- {
- doExprC (p, n);
- }
+ outText (p, (const char *) "const_cast<void*> (static_cast<const void*>", 43);
+ outText (p, (const char *) "(", 1);
+ doExprC (p, n);
+ outText (p, (const char *) "))", 2);
}
else
{
- outText (p, (const char *) "&", 1);
doExprC (p, n);
}
}
+ else
+ {
+ /* avoid dangling else. */
+ outText (p, (const char *) "&", 1);
+ doExprC (p, n);
+ }
}
doAdrC -
*/
-static void doAdrC (mcPretty_pretty p, decl_node n)
+static void doAdrC (mcPretty_pretty p, decl_node__opaque n)
{
mcDebug_assert (isUnary (n));
doAdrArgC (p, n->unaryF.arg);
doInc -
*/
-static void doInc (mcPretty_pretty p, decl_node n)
+static void doInc (mcPretty_pretty p, decl_node__opaque n)
{
mcDebug_assert (isIntrinsic (n));
if (lang == decl_ansiCP)
doDec -
*/
-static void doDec (mcPretty_pretty p, decl_node n)
+static void doDec (mcPretty_pretty p, decl_node__opaque n)
{
mcDebug_assert (isIntrinsic (n));
if (lang == decl_ansiCP)
doIncDecC -
*/
-static void doIncDecC (mcPretty_pretty p, decl_node n, const char *op_, unsigned int _op_high)
+static void doIncDecC (mcPretty_pretty p, decl_node__opaque n, const char *op_, unsigned int _op_high)
{
char op[_op_high+1];
doIncDecCP -
*/
-static void doIncDecCP (mcPretty_pretty p, decl_node n, const char *op_, unsigned int _op_high)
+static void doIncDecCP (mcPretty_pretty p, decl_node__opaque n, const char *op_, unsigned int _op_high)
{
- decl_node lhs;
- decl_node type;
+ decl_node__opaque lhs;
+ decl_node__opaque type;
char op[_op_high+1];
/* make a local copy of each unbounded array. */
lhs = getExpList (n->intrinsicF.args, 1);
doExprC (p, lhs);
mcPretty_setNeedSpace (p);
- type = decl_getType (lhs);
- if ((decl_isPointer (type)) || (type == addressN))
+ type = static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (lhs)));
+ if ((decl_isPointer (static_cast<decl_node> (type))) || (type == addressN))
{
/* cast to (char * ) and then back again after the arithmetic is complete. */
outText (p, (const char *) "=", 1);
}
outText (p, (const char *) ")", 1);
}
- else if (decl_isEnumeration (decl_skipType (type)))
+ else if (decl_isEnumeration (decl_skipType (static_cast<decl_node> (type))))
{
/* avoid dangling else. */
outText (p, (const char *) "= static_cast<", 14);
doInclC -
*/
-static void doInclC (mcPretty_pretty p, decl_node n)
+static void doInclC (mcPretty_pretty p, decl_node__opaque n)
{
- decl_node lo;
+ decl_node__opaque lo;
mcDebug_assert (isIntrinsic (n));
if (n->intrinsicF.args != NULL)
doExclC -
*/
-static void doExclC (mcPretty_pretty p, decl_node n)
+static void doExclC (mcPretty_pretty p, decl_node__opaque n)
{
- decl_node lo;
+ decl_node__opaque lo;
mcDebug_assert (isIntrinsic (n));
if (n->intrinsicF.args != NULL)
doNewC -
*/
-static void doNewC (mcPretty_pretty p, decl_node n)
+static void doNewC (mcPretty_pretty p, decl_node__opaque n)
{
- decl_node t;
+ decl_node__opaque t;
mcDebug_assert (isIntrinsic (n));
if (n->intrinsicF.args == NULL)
doExprC (p, getExpList (n->intrinsicF.args, 1));
outText (p, (const char *) ",", 1);
mcPretty_setNeedSpace (p);
- t = decl_skipType (decl_getType (getExpList (n->intrinsicF.args, 1)));
- if (decl_isPointer (t))
+ t = static_cast<decl_node__opaque> (decl_skipType (decl_getType (static_cast<decl_node> (getExpList (n->intrinsicF.args, 1)))));
+ if (decl_isPointer (static_cast<decl_node> (t)))
{
- t = decl_getType (t);
+ t = static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (t)));
outText (p, (const char *) "sizeof", 6);
mcPretty_setNeedSpace (p);
outText (p, (const char *) "(", 1);
doDisposeC -
*/
-static void doDisposeC (mcPretty_pretty p, decl_node n)
+static void doDisposeC (mcPretty_pretty p, decl_node__opaque n)
{
- decl_node t;
+ decl_node__opaque t;
mcDebug_assert (isIntrinsic (n));
if (n->intrinsicF.args == NULL)
doExprC (p, getExpList (n->intrinsicF.args, 1));
outText (p, (const char *) ",", 1);
mcPretty_setNeedSpace (p);
- t = decl_skipType (decl_getType (getExpList (n->intrinsicF.args, 1)));
- if (decl_isPointer (t))
+ t = static_cast<decl_node__opaque> (decl_skipType (decl_getType (static_cast<decl_node> (getExpList (n->intrinsicF.args, 1)))));
+ if (decl_isPointer (static_cast<decl_node> (t)))
{
- t = decl_getType (t);
+ t = static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (t)));
outText (p, (const char *) "sizeof", 6);
mcPretty_setNeedSpace (p);
outText (p, (const char *) "(", 1);
doCapC -
*/
-static void doCapC (mcPretty_pretty p, decl_node n)
+static void doCapC (mcPretty_pretty p, decl_node__opaque n)
{
mcDebug_assert (isUnary (n));
if (n->unaryF.arg == NULL)
doLengthC -
*/
-static void doLengthC (mcPretty_pretty p, decl_node n)
+static void doLengthC (mcPretty_pretty p, decl_node__opaque n)
{
mcDebug_assert (isUnary (n));
if (n->unaryF.arg == NULL)
doAbsC -
*/
-static void doAbsC (mcPretty_pretty p, decl_node n)
+static void doAbsC (mcPretty_pretty p, decl_node__opaque n)
{
- decl_node t;
+ decl_node__opaque t;
mcDebug_assert (isUnary (n));
if (n->unaryF.arg == NULL)
doValC -
*/
-static void doValC (mcPretty_pretty p, decl_node n)
+static void doValC (mcPretty_pretty p, decl_node__opaque n)
{
mcDebug_assert (isBinary (n));
outText (p, (const char *) "(", 1);
doMinC -
*/
-static void doMinC (mcPretty_pretty p, decl_node n)
+static void doMinC (mcPretty_pretty p, decl_node__opaque n)
{
- decl_node t;
+ decl_node__opaque t;
mcDebug_assert (isUnary (n));
t = getExprType (n->unaryF.arg);
doMaxC -
*/
-static void doMaxC (mcPretty_pretty p, decl_node n)
+static void doMaxC (mcPretty_pretty p, decl_node__opaque n)
{
- decl_node t;
+ decl_node__opaque t;
mcDebug_assert (isUnary (n));
t = getExprType (n->unaryF.arg);
The intrinsic functions are represented as unary and binary nodes.
*/
-static bool isIntrinsic (decl_node n)
+static bool isIntrinsic (decl_node__opaque n)
{
switch (n->kind)
{
doHalt -
*/
-static void doHalt (mcPretty_pretty p, decl_node n)
+static void doHalt (mcPretty_pretty p, decl_node__opaque n)
{
mcDebug_assert (n->kind == decl_halt);
if ((n->intrinsicF.args == NULL) || ((expListLen (n->intrinsicF.args)) == 0))
doCreal - emit the appropriate creal function.
*/
-static void doCreal (mcPretty_pretty p, decl_node t)
+static void doCreal (mcPretty_pretty p, decl_node__opaque t)
{
switch (t->kind)
{
doCimag - emit the appropriate cimag function.
*/
-static void doCimag (mcPretty_pretty p, decl_node t)
+static void doCimag (mcPretty_pretty p, decl_node__opaque t)
{
switch (t->kind)
{
doReC -
*/
-static void doReC (mcPretty_pretty p, decl_node n)
+static void doReC (mcPretty_pretty p, decl_node__opaque n)
{
- decl_node t;
+ decl_node__opaque t;
mcDebug_assert (n->kind == decl_re);
if (n->unaryF.arg != NULL)
doImC -
*/
-static void doImC (mcPretty_pretty p, decl_node n)
+static void doImC (mcPretty_pretty p, decl_node__opaque n)
{
- decl_node t;
+ decl_node__opaque t;
mcDebug_assert (n->kind == decl_im);
if (n->unaryF.arg != NULL)
doCmplx -
*/
-static void doCmplx (mcPretty_pretty p, decl_node n)
+static void doCmplx (mcPretty_pretty p, decl_node__opaque n)
{
mcDebug_assert (isBinary (n));
keyc_useComplex ();
doIntrinsicC -
*/
-static void doIntrinsicC (mcPretty_pretty p, decl_node n)
+static void doIntrinsicC (mcPretty_pretty p, decl_node__opaque n)
{
mcDebug_assert (isIntrinsic (n));
doCommentC (p, n->intrinsicF.intrinsicComment.body);
isIntrinsicFunction - returns true if, n, is an instrinsic function.
*/
-static bool isIntrinsicFunction (decl_node n)
+static bool isIntrinsicFunction (decl_node__opaque n)
{
switch (n->kind)
{
doSizeC -
*/
-static void doSizeC (mcPretty_pretty p, decl_node n)
+static void doSizeC (mcPretty_pretty p, decl_node__opaque n)
{
mcDebug_assert (isUnary (n));
outText (p, (const char *) "sizeof (", 8);
doConvertC -
*/
-static void doConvertC (mcPretty_pretty p, decl_node n, const char *conversion_, unsigned int _conversion_high)
+static void doConvertC (mcPretty_pretty p, decl_node__opaque n, const char *conversion_, unsigned int _conversion_high)
{
DynamicStrings_String s;
char conversion[_conversion_high+1];
doConvertSC -
*/
-static void doConvertSC (mcPretty_pretty p, decl_node n, DynamicStrings_String conversion)
+static void doConvertSC (mcPretty_pretty p, decl_node__opaque n, DynamicStrings_String conversion)
{
mcDebug_assert (isUnary (n));
mcPretty_setNeedSpace (p);
}
+/*
+ getFunction - return the function associate with funccall node n.
+*/
+
+static decl_node__opaque getFunction (decl_node__opaque n)
+{
+ mcDebug_assert (isFuncCall (n));
+ switch (n->kind)
+ {
+ case decl_funccall:
+ return n->funccallF.function;
+ break;
+
+
+ default:
+ M2RTS_HALT (-1);
+ __builtin_unreachable ();
+ break;
+ }
+ ReturnException ("../../gcc/m2/mc/decl.def", 20, 1);
+ __builtin_unreachable ();
+}
+
+
/*
getFuncFromExpr -
*/
-static decl_node getFuncFromExpr (decl_node n)
+static decl_node__opaque getFuncFromExpr (decl_node__opaque n)
{
- n = decl_skipType (decl_getType (n));
- while ((n != procN) && (! (decl_isProcType (n))))
+ n = static_cast<decl_node__opaque> (decl_skipType (decl_getType (static_cast<decl_node> (n))));
+ while ((n != procN) && (! (decl_isProcType (static_cast<decl_node> (n)))))
{
- n = decl_skipType (decl_getType (n));
+ n = static_cast<decl_node__opaque> (decl_skipType (decl_getType (static_cast<decl_node> (n))));
}
return n;
/* static analysis guarentees a RETURN statement will be used before here. */
doFuncExprC -
*/
-static void doFuncExprC (mcPretty_pretty p, decl_node n)
+static void doFuncExprC (mcPretty_pretty p, decl_node__opaque n)
{
- decl_node t;
+ decl_node__opaque t;
mcDebug_assert (isFuncCall (n));
- if (decl_isProcedure (n->funccallF.function))
+ if (decl_isProcedure (static_cast<decl_node> (n->funccallF.function)))
{
doFQDNameC (p, n->funccallF.function, true);
mcPretty_setNeedSpace (p);
mcPretty_setNeedSpace (p);
if (t == procN)
{
- doProcTypeArgsC (p, n, NULL, true);
+ doProcTypeArgsC (p, n, static_cast<Indexing_Index> (NULL), true);
}
else
{
- mcDebug_assert (decl_isProcType (t));
+ mcDebug_assert (decl_isProcType (static_cast<decl_node> (t)));
doProcTypeArgsC (p, n, t->proctypeF.parameters, true);
}
}
doFuncCallC -
*/
-static void doFuncCallC (mcPretty_pretty p, decl_node n)
+static void doFuncCallC (mcPretty_pretty p, decl_node__opaque n)
{
doCommentC (p, n->funccallF.funccallComment.body);
doFuncExprC (p, n);
doCaseStatementC -
*/
-static void doCaseStatementC (mcPretty_pretty p, decl_node n, bool needBreak)
+static void doCaseStatementC (mcPretty_pretty p, decl_node__opaque n, bool needBreak)
{
p = mcPretty_pushPretty (p);
mcPretty_setindent (p, (mcPretty_getindent (p))+indentationC);
doExceptionC -
*/
-static void doExceptionC (mcPretty_pretty p, const char *a_, unsigned int _a_high, decl_node n)
+static void doExceptionC (mcPretty_pretty p, const char *a_, unsigned int _a_high, decl_node__opaque n)
{
unsigned int w;
char a[_a_high+1];
/* make a local copy of each unbounded array. */
memcpy (a, a_, _a_high+1);
- w = decl_getDeclaredMod (n);
+ w = decl_getDeclaredMod (static_cast<decl_node> (n));
outText (p, (const char *) a, _a_high);
mcPretty_setNeedSpace (p);
outText (p, (const char *) "(\"", 2);
doExceptionCP -
*/
-static void doExceptionCP (mcPretty_pretty p, const char *a_, unsigned int _a_high, decl_node n)
+static void doExceptionCP (mcPretty_pretty p, const char *a_, unsigned int _a_high, decl_node__opaque n)
{
unsigned int w;
char a[_a_high+1];
/* make a local copy of each unbounded array. */
memcpy (a, a_, _a_high+1);
- w = decl_getDeclaredMod (n);
+ w = decl_getDeclaredMod (static_cast<decl_node> (n));
outText (p, (const char *) a, _a_high);
mcPretty_setNeedSpace (p);
outText (p, (const char *) "(\"", 2);
doException -
*/
-static void doException (mcPretty_pretty p, const char *a_, unsigned int _a_high, decl_node n)
+static void doException (mcPretty_pretty p, const char *a_, unsigned int _a_high, decl_node__opaque n)
{
char a[_a_high+1];
doRangeListC -
*/
-static void doRangeListC (mcPretty_pretty p, decl_node c)
+static void doRangeListC (mcPretty_pretty p, decl_node__opaque c)
{
- decl_node r;
+ decl_node__opaque r;
unsigned int i;
unsigned int h;
- mcDebug_assert (decl_isCaseList (c));
+ mcDebug_assert (decl_isCaseList (static_cast<decl_node> (c)));
i = 1;
h = Indexing_HighIndice (c->caselistF.rangePairs);
while (i <= h)
{
- r = static_cast<decl_node> (Indexing_GetIndice (c->caselistF.rangePairs, i));
+ r = static_cast<decl_node__opaque> (Indexing_GetIndice (c->caselistF.rangePairs, i));
mcDebug_assert ((r->rangeF.hi == NULL) || (r->rangeF.lo == r->rangeF.hi));
outText (p, (const char *) "case", 4);
mcPretty_setNeedSpace (p);
doRangeIfListC -
*/
-static void doRangeIfListC (mcPretty_pretty p, decl_node e, decl_node c)
+static void doRangeIfListC (mcPretty_pretty p, decl_node__opaque e, decl_node__opaque c)
{
- decl_node r;
+ decl_node__opaque r;
unsigned int i;
unsigned int h;
- mcDebug_assert (decl_isCaseList (c));
+ mcDebug_assert (decl_isCaseList (static_cast<decl_node> (c)));
i = 1;
h = Indexing_HighIndice (c->caselistF.rangePairs);
while (i <= h)
{
- r = static_cast<decl_node> (Indexing_GetIndice (c->caselistF.rangePairs, i));
+ r = static_cast<decl_node__opaque> (Indexing_GetIndice (c->caselistF.rangePairs, i));
if ((r->rangeF.lo != r->rangeF.hi) && (r->rangeF.hi != NULL))
{
outText (p, (const char *) "((", 2);
doCaseLabels -
*/
-static void doCaseLabels (mcPretty_pretty p, decl_node n, bool needBreak)
+static void doCaseLabels (mcPretty_pretty p, decl_node__opaque n, bool needBreak)
{
- mcDebug_assert (decl_isCaseLabelList (n));
+ mcDebug_assert (decl_isCaseLabelList (static_cast<decl_node> (n)));
doRangeListC (p, n->caselabellistF.caseList);
p = mcPretty_pushPretty (p);
mcPretty_setindent (p, (mcPretty_getindent (p))+indentationC);
doCaseLabelListC -
*/
-static void doCaseLabelListC (mcPretty_pretty p, decl_node n, bool haveElse)
+static void doCaseLabelListC (mcPretty_pretty p, decl_node__opaque n, bool haveElse)
{
unsigned int i;
unsigned int h;
- decl_node c;
+ decl_node__opaque c;
- mcDebug_assert (decl_isCase (n));
+ mcDebug_assert (decl_isCase (static_cast<decl_node> (n)));
i = 1;
h = Indexing_HighIndice (n->caseF.caseLabelList);
while (i <= h)
{
- c = static_cast<decl_node> (Indexing_GetIndice (n->caseF.caseLabelList, i));
+ c = static_cast<decl_node__opaque> (Indexing_GetIndice (n->caseF.caseLabelList, i));
doCaseLabels (p, c, ((i < h) || haveElse) || caseException);
i += 1;
}
doCaseIfLabels -
*/
-static void doCaseIfLabels (mcPretty_pretty p, decl_node e, decl_node n, unsigned int i, unsigned int h)
+static void doCaseIfLabels (mcPretty_pretty p, decl_node__opaque e, decl_node__opaque n, unsigned int i, unsigned int h)
{
- mcDebug_assert (decl_isCaseLabelList (n));
+ mcDebug_assert (decl_isCaseLabelList (static_cast<decl_node> (n)));
if (i > 1)
{
outText (p, (const char *) "else", 4);
doCaseIfLabelListC -
*/
-static void doCaseIfLabelListC (mcPretty_pretty p, decl_node n)
+static void doCaseIfLabelListC (mcPretty_pretty p, decl_node__opaque n)
{
unsigned int i;
unsigned int h;
- decl_node c;
+ decl_node__opaque c;
- mcDebug_assert (decl_isCase (n));
+ mcDebug_assert (decl_isCase (static_cast<decl_node> (n)));
i = 1;
h = Indexing_HighIndice (n->caseF.caseLabelList);
while (i <= h)
{
- c = static_cast<decl_node> (Indexing_GetIndice (n->caseF.caseLabelList, i));
+ c = static_cast<decl_node__opaque> (Indexing_GetIndice (n->caseF.caseLabelList, i));
doCaseIfLabels (p, n->caseF.expression, c, i, h);
i += 1;
}
doCaseElseC -
*/
-static void doCaseElseC (mcPretty_pretty p, decl_node n)
+static void doCaseElseC (mcPretty_pretty p, decl_node__opaque n)
{
- mcDebug_assert (decl_isCase (n));
+ mcDebug_assert (decl_isCase (static_cast<decl_node> (n)));
if (n->caseF.else_ == NULL)
{
/* avoid dangling else. */
doCaseIfElseC -
*/
-static void doCaseIfElseC (mcPretty_pretty p, decl_node n)
+static void doCaseIfElseC (mcPretty_pretty p, decl_node__opaque n)
{
- mcDebug_assert (decl_isCase (n));
+ mcDebug_assert (decl_isCase (static_cast<decl_node> (n)));
if (n->caseF.else_ == NULL)
{
/* avoid dangling else. */
single values and not ranges.
*/
-static bool canUseSwitchCaseLabels (decl_node n)
+static bool canUseSwitchCaseLabels (decl_node__opaque n)
{
unsigned int i;
unsigned int h;
- decl_node r;
- decl_node l;
+ decl_node__opaque r;
+ decl_node__opaque l;
- mcDebug_assert (decl_isCaseLabelList (n));
+ mcDebug_assert (decl_isCaseLabelList (static_cast<decl_node> (n)));
l = n->caselabellistF.caseList;
i = 1;
h = Indexing_HighIndice (l->caselistF.rangePairs);
while (i <= h)
{
- r = static_cast<decl_node> (Indexing_GetIndice (l->caselistF.rangePairs, i));
+ r = static_cast<decl_node__opaque> (Indexing_GetIndice (l->caselistF.rangePairs, i));
if ((r->rangeF.hi != NULL) && (r->rangeF.lo != r->rangeF.hi))
{
return false;
selectors are single values rather than ranges.
*/
-static bool canUseSwitch (decl_node n)
+static bool canUseSwitch (decl_node__opaque n)
{
unsigned int i;
unsigned int h;
- decl_node c;
+ decl_node__opaque c;
- mcDebug_assert (decl_isCase (n));
+ mcDebug_assert (decl_isCase (static_cast<decl_node> (n)));
i = 1;
h = Indexing_HighIndice (n->caseF.caseLabelList);
while (i <= h)
{
- c = static_cast<decl_node> (Indexing_GetIndice (n->caseF.caseLabelList, i));
+ c = static_cast<decl_node__opaque> (Indexing_GetIndice (n->caseF.caseLabelList, i));
if (! (canUseSwitchCaseLabels (c)))
{
return false;
doCaseC -
*/
-static void doCaseC (mcPretty_pretty p, decl_node n)
+static void doCaseC (mcPretty_pretty p, decl_node__opaque n)
{
unsigned int i;
- mcDebug_assert (decl_isCase (n));
+ mcDebug_assert (decl_isCase (static_cast<decl_node> (n)));
if (canUseSwitch (n))
{
i = mcPretty_getindent (p);
doLoopC -
*/
-static void doLoopC (mcPretty_pretty p, decl_node s)
+static void doLoopC (mcPretty_pretty p, decl_node__opaque s)
{
- mcDebug_assert (decl_isLoop (s));
+ mcDebug_assert (decl_isLoop (static_cast<decl_node> (s)));
outText (p, (const char *) "for (;;)\\n", 10);
outText (p, (const char *) "{\\n", 3);
p = mcPretty_pushPretty (p);
doExitC -
*/
-static void doExitC (mcPretty_pretty p, decl_node s)
+static void doExitC (mcPretty_pretty p, decl_node__opaque s)
{
- mcDebug_assert (decl_isExit (s));
+ mcDebug_assert (decl_isExit (static_cast<decl_node> (s)));
outText (p, (const char *) "/* exit. */\\n", 14);
}
doStatementsC -
*/
-static void doStatementsC (mcPretty_pretty p, decl_node s)
+static void doStatementsC (mcPretty_pretty p, decl_node__opaque s)
{
if (s == NULL)
{} /* empty. */
- else if (decl_isStatementSequence (s))
+ else if (decl_isStatementSequence (static_cast<decl_node> (s)))
{
/* avoid dangling else. */
doStatementSequenceC (p, s);
/* avoid dangling else. */
doCommentC (p, s);
}
- else if (decl_isExit (s))
+ else if (decl_isExit (static_cast<decl_node> (s)))
{
/* avoid dangling else. */
doExitC (p, s);
}
- else if (decl_isReturn (s))
+ else if (decl_isReturn (static_cast<decl_node> (s)))
{
/* avoid dangling else. */
doReturnC (p, s);
/* avoid dangling else. */
doAssignmentC (p, s);
}
- else if (decl_isIf (s))
+ else if (decl_isIf (static_cast<decl_node> (s)))
{
/* avoid dangling else. */
doIfC (p, s);
}
- else if (decl_isFor (s))
+ else if (decl_isFor (static_cast<decl_node> (s)))
{
/* avoid dangling else. */
doForC (p, s);
}
- else if (decl_isRepeat (s))
+ else if (decl_isRepeat (static_cast<decl_node> (s)))
{
/* avoid dangling else. */
doRepeatC (p, s);
}
- else if (decl_isWhile (s))
+ else if (decl_isWhile (static_cast<decl_node> (s)))
{
/* avoid dangling else. */
doWhileC (p, s);
/* avoid dangling else. */
doFuncCallC (p, s);
}
- else if (decl_isCase (s))
+ else if (decl_isCase (static_cast<decl_node> (s)))
{
/* avoid dangling else. */
doCaseC (p, s);
}
- else if (decl_isLoop (s))
+ else if (decl_isLoop (static_cast<decl_node> (s)))
{
/* avoid dangling else. */
doLoopC (p, s);
}
- else if (decl_isExit (s))
+ else if (decl_isExit (static_cast<decl_node> (s)))
{
/* avoid dangling else. */
doExitC (p, s);
}
}
-static void stop (void)
+static void localstop (void)
{
}
addParamDone -
*/
-static void addParamDone (decl_node n)
+static void addParamDone (decl_node__opaque n)
{
- if ((decl_isVar (n)) && n->varF.isParameter)
+ if ((decl_isVar (static_cast<decl_node> (n))) && n->varF.isParameter)
{
addDone (n);
- addDone (decl_getType (n));
+ addDone (static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (n))));
}
}
includeParameters -
*/
-static void includeParameters (decl_node n)
+static void includeParameters (decl_node__opaque n)
{
- mcDebug_assert (decl_isProcedure (n));
+ mcDebug_assert (decl_isProcedure (static_cast<decl_node> (n)));
Indexing_ForeachIndiceInIndexDo (n->procedureF.decls.variables, (Indexing_IndexProcedure) {(Indexing_IndexProcedure_t) addParamDone});
}
isHalt -
*/
-static bool isHalt (decl_node n)
+static bool isHalt (decl_node__opaque n)
{
return n->kind == decl_halt;
/* static analysis guarentees a RETURN statement will be used before here. */
isReturnOrHalt -
*/
-static bool isReturnOrHalt (decl_node n)
+static bool isReturnOrHalt (decl_node__opaque n)
{
- return (isHalt (n)) || (decl_isReturn (n));
+ return (isHalt (n)) || (decl_isReturn (static_cast<decl_node> (n)));
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
isLastStatementReturn -
*/
-static bool isLastStatementReturn (decl_node n)
+static bool isLastStatementReturn (decl_node__opaque n)
{
return isLastStatement (n, (decl_isNodeF) {(decl_isNodeF_t) isReturnOrHalt});
/* static analysis guarentees a RETURN statement will be used before here. */
isLastStatementSequence -
*/
-static bool isLastStatementSequence (decl_node n, decl_isNodeF q)
+static bool isLastStatementSequence (decl_node__opaque n, decl_isNodeF q)
{
unsigned int h;
- mcDebug_assert (decl_isStatementSequence (n));
+ mcDebug_assert (decl_isStatementSequence (static_cast<decl_node> (n)));
h = Indexing_HighIndice (n->stmtF.statements);
if (h > 0)
{
- return isLastStatement (reinterpret_cast<decl_node> (Indexing_GetIndice (n->stmtF.statements, h)), q);
+ return isLastStatement (static_cast<decl_node__opaque> (Indexing_GetIndice (n->stmtF.statements, h)), q);
}
return false;
/* static analysis guarentees a RETURN statement will be used before here. */
isLastStatementIf -
*/
-static bool isLastStatementIf (decl_node n, decl_isNodeF q)
+static bool isLastStatementIf (decl_node__opaque n, decl_isNodeF q)
{
bool ret;
- mcDebug_assert (decl_isIf (n));
+ mcDebug_assert (decl_isIf (static_cast<decl_node> (n)));
ret = true;
if ((n->ifF.elsif != NULL) && ret)
{
isLastStatementElsif -
*/
-static bool isLastStatementElsif (decl_node n, decl_isNodeF q)
+static bool isLastStatementElsif (decl_node__opaque n, decl_isNodeF q)
{
bool ret;
- mcDebug_assert (decl_isElsif (n));
+ mcDebug_assert (decl_isElsif (static_cast<decl_node> (n)));
ret = true;
if ((n->elsifF.elsif != NULL) && ret)
{
isLastStatementCase -
*/
-static bool isLastStatementCase (decl_node n, decl_isNodeF q)
+static bool isLastStatementCase (decl_node__opaque n, decl_isNodeF q)
{
bool ret;
unsigned int i;
unsigned int h;
- decl_node c;
+ decl_node__opaque c;
ret = true;
- mcDebug_assert (decl_isCase (n));
+ mcDebug_assert (decl_isCase (static_cast<decl_node> (n)));
i = 1;
h = Indexing_HighIndice (n->caseF.caseLabelList);
while (i <= h)
{
- c = static_cast<decl_node> (Indexing_GetIndice (n->caseF.caseLabelList, i));
- mcDebug_assert (decl_isCaseLabelList (c));
+ c = static_cast<decl_node__opaque> (Indexing_GetIndice (n->caseF.caseLabelList, i));
+ mcDebug_assert (decl_isCaseLabelList (static_cast<decl_node> (c)));
ret = ret && (isLastStatement (c->caselabellistF.statements, q));
i += 1;
}
isLastStatement - returns TRUE if the last statement in, n, is, q.
*/
-static bool isLastStatement (decl_node n, decl_isNodeF q)
+static bool isLastStatement (decl_node__opaque n, decl_isNodeF q)
{
bool ret;
{
return false;
}
- else if (decl_isStatementSequence (n))
+ else if (decl_isStatementSequence (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
return isLastStatementSequence (n, q);
}
- else if (decl_isProcedure (n))
+ else if (decl_isProcedure (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
- mcDebug_assert (decl_isProcedure (n));
+ mcDebug_assert (decl_isProcedure (static_cast<decl_node> (n)));
return isLastStatement (n->procedureF.beginStatements, q);
}
- else if (decl_isIf (n))
+ else if (decl_isIf (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
return isLastStatementIf (n, q);
}
- else if (decl_isElsif (n))
+ else if (decl_isElsif (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
return isLastStatementElsif (n, q);
}
- else if (decl_isCase (n))
+ else if (decl_isCase (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
return isLastStatementCase (n, q);
}
- else if ((*q.proc) (n))
+ else if ((*q.proc) (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
return true;
doProcedureC -
*/
-static void doProcedureC (decl_node n)
+static void doProcedureC (decl_node__opaque n)
{
unsigned int s;
outText (doP, (const char *) "\\n", 2);
includeParameters (n);
- keyc_enterScope (n);
+ keyc_enterScope (static_cast<decl_node> (n));
doProcedureHeadingC (n, false);
outText (doP, (const char *) "\\n", 2);
doP = outKc (doP, (const char *) "{\\n", 3);
}
}
doP = outKc (doP, (const char *) "}\\n", 3);
- keyc_leaveScope (n);
+ keyc_leaveScope (static_cast<decl_node> (n));
}
output -
*/
-static void output (decl_node n, decl_nodeProcedure c, decl_nodeProcedure t, decl_nodeProcedure v)
+static void output (decl_node__opaque n, decl_nodeProcedure c, decl_nodeProcedure t, decl_nodeProcedure v)
{
- if (decl_isConst (n))
+ if (decl_isConst (static_cast<decl_node> (n)))
{
(*c.proc) (n);
}
- else if (decl_isVar (n))
+ else if (decl_isVar (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
(*v.proc) (n);
allDependants -
*/
-static decl_dependentState allDependants (decl_node n)
+static decl_dependentState allDependants (decl_node__opaque n)
{
alists_alist l;
decl_dependentState s;
walkDependants -
*/
-static decl_dependentState walkDependants (alists_alist l, decl_node n)
+static decl_dependentState walkDependants (alists_alist l, decl_node__opaque n)
{
if ((n == NULL) || (alists_isItemInList (globalGroup->doneQ, reinterpret_cast<void *> (n))))
{
walkType -
*/
-static decl_dependentState walkType (alists_alist l, decl_node n)
+static decl_dependentState walkType (alists_alist l, decl_node__opaque n)
{
- decl_node t;
+ decl_node__opaque t;
- t = decl_getType (n);
+ t = static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (n)));
if (alists_isItemInList (globalGroup->doneQ, reinterpret_cast<void *> (t)))
{
return decl_completed;
db -
*/
-static void db (const char *a_, unsigned int _a_high, decl_node n)
+static void db (const char *a_, unsigned int _a_high, decl_node__opaque n)
{
char a[_a_high+1];
dbs -
*/
-static void dbs (decl_dependentState s, decl_node n)
+static void dbs (decl_dependentState s, decl_node__opaque n)
{
if (mcOptions_getDebugTopological ())
{
dbq -
*/
-static void dbq (decl_node n)
+static void dbq (decl_node__opaque n)
{
if (mcOptions_getDebugTopological ())
{
walkRecord -
*/
-static decl_dependentState walkRecord (alists_alist l, decl_node n)
+static decl_dependentState walkRecord (alists_alist l, decl_node__opaque n)
{
decl_dependentState s;
unsigned int o;
unsigned int i;
unsigned int t;
- decl_node q;
+ decl_node__opaque q;
i = Indexing_LowIndice (n->recordF.listOfSons);
t = Indexing_HighIndice (n->recordF.listOfSons);
dbq (n);
while (i <= t)
{
- q = static_cast<decl_node> (Indexing_GetIndice (n->recordF.listOfSons, i));
+ q = static_cast<decl_node__opaque> (Indexing_GetIndice (n->recordF.listOfSons, i));
db ((const char *) "", 0, q);
- if ((decl_isRecordField (q)) && q->recordfieldF.tag)
+ if ((decl_isRecordField (static_cast<decl_node> (q))) && q->recordfieldF.tag)
{} /* empty. */
else
{
dbs (s, q);
addTodo (n);
dbq (n);
- db ((const char *) "\\n", 2, NULL);
+ db ((const char *) "\\n", 2, static_cast<decl_node__opaque> (NULL));
mcPretty_setindent (doP, o);
return s;
}
walkVarient -
*/
-static decl_dependentState walkVarient (alists_alist l, decl_node n)
+static decl_dependentState walkVarient (alists_alist l, decl_node__opaque n)
{
decl_dependentState s;
unsigned int i;
unsigned int t;
- decl_node q;
+ decl_node__opaque q;
db ((const char *) "\\nwalking", 9, n);
s = walkDependants (l, n->varientF.tag);
{
dbs (s, n->varientF.tag);
dbq (n->varientF.tag);
- db ((const char *) "\\n", 2, NULL);
+ db ((const char *) "\\n", 2, static_cast<decl_node__opaque> (NULL));
return s;
}
i = Indexing_LowIndice (n->varientF.listOfSons);
t = Indexing_HighIndice (n->varientF.listOfSons);
while (i <= t)
{
- q = static_cast<decl_node> (Indexing_GetIndice (n->varientF.listOfSons, i));
+ q = static_cast<decl_node__opaque> (Indexing_GetIndice (n->varientF.listOfSons, i));
db ((const char *) "", 0, q);
s = walkDependants (l, q);
if (s != decl_completed)
{
dbs (s, q);
- db ((const char *) "\\n", 2, NULL);
+ db ((const char *) "\\n", 2, static_cast<decl_node__opaque> (NULL));
return s;
}
i += 1;
queueBlocked -
*/
-static void queueBlocked (decl_node n)
+static void queueBlocked (decl_node__opaque n)
{
if (! ((alists_isItemInList (globalGroup->doneQ, reinterpret_cast<void *> (n))) || (alists_isItemInList (globalGroup->partialQ, reinterpret_cast<void *> (n)))))
{
walkVar -
*/
-static decl_dependentState walkVar (alists_alist l, decl_node n)
+static decl_dependentState walkVar (alists_alist l, decl_node__opaque n)
{
- decl_node t;
+ decl_node__opaque t;
- t = decl_getType (n);
+ t = static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (n)));
if (alists_isItemInList (globalGroup->doneQ, reinterpret_cast<void *> (t)))
{
return decl_completed;
walkEnumeration -
*/
-static decl_dependentState walkEnumeration (alists_alist l, decl_node n)
+static decl_dependentState walkEnumeration (alists_alist l, decl_node__opaque n)
{
decl_dependentState s;
unsigned int i;
unsigned int t;
- decl_node q;
+ decl_node__opaque q;
i = Indexing_LowIndice (n->enumerationF.listOfSons);
t = Indexing_HighIndice (n->enumerationF.listOfSons);
s = decl_completed;
while (i <= t)
{
- q = static_cast<decl_node> (Indexing_GetIndice (n->enumerationF.listOfSons, i));
+ q = static_cast<decl_node__opaque> (Indexing_GetIndice (n->enumerationF.listOfSons, i));
s = walkDependants (l, q);
if (s != decl_completed)
{
walkSubrange -
*/
-static decl_dependentState walkSubrange (alists_alist l, decl_node n)
+static decl_dependentState walkSubrange (alists_alist l, decl_node__opaque n)
{
decl_dependentState s;
walkSubscript -
*/
-static decl_dependentState walkSubscript (alists_alist l, decl_node n)
+static decl_dependentState walkSubscript (alists_alist l, decl_node__opaque n)
{
decl_dependentState s;
walkPointer -
*/
-static decl_dependentState walkPointer (alists_alist l, decl_node n)
+static decl_dependentState walkPointer (alists_alist l, decl_node__opaque n)
{
- decl_node t;
+ decl_node__opaque t;
/* if the type of, n, is done or partial then we can output pointer. */
- t = decl_getType (n);
+ t = static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (n)));
if ((alists_isItemInList (globalGroup->partialQ, reinterpret_cast<void *> (t))) || (alists_isItemInList (globalGroup->doneQ, reinterpret_cast<void *> (t))))
{
/* pointer to partial can always generate a complete type. */
walkArray -
*/
-static decl_dependentState walkArray (alists_alist l, decl_node n)
+static decl_dependentState walkArray (alists_alist l, decl_node__opaque n)
{
decl_dependentState s;
walkConst -
*/
-static decl_dependentState walkConst (alists_alist l, decl_node n)
+static decl_dependentState walkConst (alists_alist l, decl_node__opaque n)
{
decl_dependentState s;
walkVarParam -
*/
-static decl_dependentState walkVarParam (alists_alist l, decl_node n)
+static decl_dependentState walkVarParam (alists_alist l, decl_node__opaque n)
{
- decl_node t;
+ decl_node__opaque t;
- t = decl_getType (n);
+ t = static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (n)));
if (alists_isItemInList (globalGroup->partialQ, reinterpret_cast<void *> (t)))
{
/* parameter can be issued from a partial. */
walkParam -
*/
-static decl_dependentState walkParam (alists_alist l, decl_node n)
+static decl_dependentState walkParam (alists_alist l, decl_node__opaque n)
{
- decl_node t;
+ decl_node__opaque t;
- t = decl_getType (n);
+ t = static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (n)));
if (alists_isItemInList (globalGroup->partialQ, reinterpret_cast<void *> (t)))
{
/* parameter can be issued from a partial. */
walkOptarg -
*/
-static decl_dependentState walkOptarg (alists_alist l, decl_node n)
+static decl_dependentState walkOptarg (alists_alist l, decl_node__opaque n)
{
- decl_node t;
+ decl_node__opaque t;
- t = decl_getType (n);
+ t = static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (n)));
if (alists_isItemInList (globalGroup->partialQ, reinterpret_cast<void *> (t)))
{
/* parameter can be issued from a partial. */
walkRecordField -
*/
-static decl_dependentState walkRecordField (alists_alist l, decl_node n)
+static decl_dependentState walkRecordField (alists_alist l, decl_node__opaque n)
{
- decl_node t;
+ decl_node__opaque t;
decl_dependentState s;
- mcDebug_assert (decl_isRecordField (n));
- t = decl_getType (n);
+ mcDebug_assert (decl_isRecordField (static_cast<decl_node> (n)));
+ t = static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (n)));
if (alists_isItemInList (globalGroup->partialQ, reinterpret_cast<void *> (t)))
{
dbs (decl_partial, n);
walkVarientField -
*/
-static decl_dependentState walkVarientField (alists_alist l, decl_node n)
+static decl_dependentState walkVarientField (alists_alist l, decl_node__opaque n)
{
decl_dependentState s;
unsigned int i;
unsigned int t;
- decl_node q;
+ decl_node__opaque q;
i = Indexing_LowIndice (n->varientfieldF.listOfSons);
t = Indexing_HighIndice (n->varientfieldF.listOfSons);
s = decl_completed;
while (i <= t)
{
- q = static_cast<decl_node> (Indexing_GetIndice (n->varientfieldF.listOfSons, i));
+ q = static_cast<decl_node__opaque> (Indexing_GetIndice (n->varientfieldF.listOfSons, i));
s = walkDependants (l, q);
if (s != decl_completed)
{
walkEnumerationField -
*/
-static decl_dependentState walkEnumerationField (alists_alist l, decl_node n)
+static decl_dependentState walkEnumerationField (alists_alist l, decl_node__opaque n)
{
return decl_completed;
/* static analysis guarentees a RETURN statement will be used before here. */
walkSet -
*/
-static decl_dependentState walkSet (alists_alist l, decl_node n)
+static decl_dependentState walkSet (alists_alist l, decl_node__opaque n)
{
- return walkDependants (l, decl_getType (n));
+ return walkDependants (l, static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (n))));
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
walkProcType -
*/
-static decl_dependentState walkProcType (alists_alist l, decl_node n)
+static decl_dependentState walkProcType (alists_alist l, decl_node__opaque n)
{
decl_dependentState s;
- decl_node t;
+ decl_node__opaque t;
- t = decl_getType (n);
+ t = static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (n)));
if (alists_isItemInList (globalGroup->partialQ, reinterpret_cast<void *> (t)))
{} /* empty. */
else
walkProcedure -
*/
-static decl_dependentState walkProcedure (alists_alist l, decl_node n)
+static decl_dependentState walkProcedure (alists_alist l, decl_node__opaque n)
{
decl_dependentState s;
- s = walkDependants (l, decl_getType (n));
+ s = walkDependants (l, static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (n))));
if (s != decl_completed)
{
return s;
decl_dependentState s;
unsigned int i;
unsigned int h;
- decl_node q;
+ decl_node__opaque q;
i = Indexing_LowIndice (p);
h = Indexing_HighIndice (p);
while (i <= h)
{
- q = static_cast<decl_node> (Indexing_GetIndice (p, i));
+ q = static_cast<decl_node__opaque> (Indexing_GetIndice (p, i));
s = walkDependants (l, q);
if (s != decl_completed)
{
walkFuncCall -
*/
-static decl_dependentState walkFuncCall (alists_alist l, decl_node n)
+static decl_dependentState walkFuncCall (alists_alist l, decl_node__opaque n)
{
return decl_completed;
/* static analysis guarentees a RETURN statement will be used before here. */
walkUnary -
*/
-static decl_dependentState walkUnary (alists_alist l, decl_node n)
+static decl_dependentState walkUnary (alists_alist l, decl_node__opaque n)
{
decl_dependentState s;
walkBinary -
*/
-static decl_dependentState walkBinary (alists_alist l, decl_node n)
+static decl_dependentState walkBinary (alists_alist l, decl_node__opaque n)
{
decl_dependentState s;
walkComponentRef -
*/
-static decl_dependentState walkComponentRef (alists_alist l, decl_node n)
+static decl_dependentState walkComponentRef (alists_alist l, decl_node__opaque n)
{
decl_dependentState s;
walkPointerRef -
*/
-static decl_dependentState walkPointerRef (alists_alist l, decl_node n)
+static decl_dependentState walkPointerRef (alists_alist l, decl_node__opaque n)
{
decl_dependentState s;
walkSetValue -
*/
-static decl_dependentState walkSetValue (alists_alist l, decl_node n)
+static decl_dependentState walkSetValue (alists_alist l, decl_node__opaque n)
{
decl_dependentState s;
unsigned int i;
unsigned int j;
- mcDebug_assert (decl_isSetValue (n));
+ mcDebug_assert (decl_isSetValue (static_cast<decl_node> (n)));
s = walkDependants (l, n->setvalueF.type);
if (s != decl_completed)
{
j = Indexing_HighIndice (n->setvalueF.values);
while (i <= j)
{
- s = walkDependants (l, reinterpret_cast<decl_node> (Indexing_GetIndice (n->setvalueF.values, i)));
+ s = walkDependants (l, static_cast<decl_node__opaque> (Indexing_GetIndice (n->setvalueF.values, i)));
if (s != decl_completed)
{
return s;
all dependants have been declared.
*/
-static decl_dependentState doDependants (alists_alist l, decl_node n)
+static decl_dependentState doDependants (alists_alist l, decl_node__opaque n)
{
switch (n->kind)
{
tryComplete - returns TRUE if node, n, can be and was completed.
*/
-static bool tryComplete (decl_node n, decl_nodeProcedure c, decl_nodeProcedure t, decl_nodeProcedure v)
+static bool tryComplete (decl_node__opaque n, decl_nodeProcedure c, decl_nodeProcedure t, decl_nodeProcedure v)
{
- if (decl_isEnumeration (n))
+ if (decl_isEnumeration (static_cast<decl_node> (n)))
{
/* can always emit enumerated types. */
output (n, c, t, v);
return true;
}
- else if (((decl_isType (n)) && (decl_isTypeHidden (n))) && ((decl_getType (n)) == NULL))
+ else if (((decl_isType (static_cast<decl_node> (n))) && (decl_isTypeHidden (static_cast<decl_node> (n)))) && ((decl_getType (static_cast<decl_node> (n))) == NULL))
{
/* avoid dangling else. */
/* can always emit hidden types. */
tryCompleteFromPartial -
*/
-static bool tryCompleteFromPartial (decl_node n, decl_nodeProcedure t)
+static bool tryCompleteFromPartial (decl_node__opaque n, decl_nodeProcedure t)
{
- if ((((decl_isType (n)) && ((decl_getType (n)) != NULL)) && (decl_isPointer (decl_getType (n)))) && ((allDependants (decl_getType (n))) == decl_completed))
+ if ((((decl_isType (static_cast<decl_node> (n))) && ((decl_getType (static_cast<decl_node> (n))) != NULL)) && (decl_isPointer (decl_getType (static_cast<decl_node> (n))))) && ((allDependants (static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (n))))) == decl_completed))
{
/* alists.includeItemIntoList (globalGroup^.partialQ, getType (n)) ; */
outputHiddenComplete (n);
visitIntrinsicFunction -
*/
-static void visitIntrinsicFunction (alists_alist v, decl_node n, decl_nodeProcedure p)
+static void visitIntrinsicFunction (alists_alist v, decl_node__opaque n, decl_nodeProcedure p)
{
mcDebug_assert (isIntrinsicFunction (n));
switch (n->kind)
visitUnary -
*/
-static void visitUnary (alists_alist v, decl_node n, decl_nodeProcedure p)
+static void visitUnary (alists_alist v, decl_node__opaque n, decl_nodeProcedure p)
{
mcDebug_assert (isUnary (n));
visitNode (v, n->unaryF.arg, p);
visitBinary -
*/
-static void visitBinary (alists_alist v, decl_node n, decl_nodeProcedure p)
+static void visitBinary (alists_alist v, decl_node__opaque n, decl_nodeProcedure p)
{
visitNode (v, n->binaryF.left, p);
visitNode (v, n->binaryF.right, p);
visitBoolean -
*/
-static void visitBoolean (alists_alist v, decl_node n, decl_nodeProcedure p)
+static void visitBoolean (alists_alist v, decl_node__opaque n, decl_nodeProcedure p)
{
visitNode (v, falseN, p);
visitNode (v, trueN, p);
visitScope -
*/
-static void visitScope (alists_alist v, decl_node n, decl_nodeProcedure p)
+static void visitScope (alists_alist v, decl_node__opaque n, decl_nodeProcedure p)
{
if (mustVisitScope)
{
visitType -
*/
-static void visitType (alists_alist v, decl_node n, decl_nodeProcedure p)
+static void visitType (alists_alist v, decl_node__opaque n, decl_nodeProcedure p)
{
- mcDebug_assert (decl_isType (n));
+ mcDebug_assert (decl_isType (static_cast<decl_node> (n)));
visitNode (v, n->typeF.type, p);
visitScope (v, n->typeF.scope, p);
}
h = Indexing_HighIndice (i);
while (j <= h)
{
- visitNode (v, reinterpret_cast<decl_node> (Indexing_GetIndice (i, j)), p);
+ visitNode (v, static_cast<decl_node__opaque> (Indexing_GetIndice (i, j)), p);
j += 1;
}
}
visitRecord -
*/
-static void visitRecord (alists_alist v, decl_node n, decl_nodeProcedure p)
+static void visitRecord (alists_alist v, decl_node__opaque n, decl_nodeProcedure p)
{
- mcDebug_assert (decl_isRecord (n));
+ mcDebug_assert (decl_isRecord (static_cast<decl_node> (n)));
visitScope (v, n->recordF.scope, p);
visitIndex (v, n->recordF.listOfSons, p);
}
visitVarient -
*/
-static void visitVarient (alists_alist v, decl_node n, decl_nodeProcedure p)
+static void visitVarient (alists_alist v, decl_node__opaque n, decl_nodeProcedure p)
{
- mcDebug_assert (decl_isVarient (n));
+ mcDebug_assert (decl_isVarient (static_cast<decl_node> (n)));
visitIndex (v, n->varientF.listOfSons, p);
visitNode (v, n->varientF.varient, p);
visitNode (v, n->varientF.tag, p);
visitVar -
*/
-static void visitVar (alists_alist v, decl_node n, decl_nodeProcedure p)
+static void visitVar (alists_alist v, decl_node__opaque n, decl_nodeProcedure p)
{
- mcDebug_assert (decl_isVar (n));
+ mcDebug_assert (decl_isVar (static_cast<decl_node> (n)));
visitNode (v, n->varF.type, p);
visitNode (v, n->varF.decl, p);
visitScope (v, n->varF.scope, p);
visitEnumeration -
*/
-static void visitEnumeration (alists_alist v, decl_node n, decl_nodeProcedure p)
+static void visitEnumeration (alists_alist v, decl_node__opaque n, decl_nodeProcedure p)
{
- mcDebug_assert (decl_isEnumeration (n));
+ mcDebug_assert (decl_isEnumeration (static_cast<decl_node> (n)));
visitIndex (v, n->enumerationF.listOfSons, p);
visitScope (v, n->enumerationF.scope, p);
}
visitSubrange -
*/
-static void visitSubrange (alists_alist v, decl_node n, decl_nodeProcedure p)
+static void visitSubrange (alists_alist v, decl_node__opaque n, decl_nodeProcedure p)
{
- mcDebug_assert (decl_isSubrange (n));
+ mcDebug_assert (decl_isSubrange (static_cast<decl_node> (n)));
visitNode (v, n->subrangeF.low, p);
visitNode (v, n->subrangeF.high, p);
visitNode (v, n->subrangeF.type, p);
visitPointer -
*/
-static void visitPointer (alists_alist v, decl_node n, decl_nodeProcedure p)
+static void visitPointer (alists_alist v, decl_node__opaque n, decl_nodeProcedure p)
{
- mcDebug_assert (decl_isPointer (n));
+ mcDebug_assert (decl_isPointer (static_cast<decl_node> (n)));
visitNode (v, n->pointerF.type, p);
visitScope (v, n->pointerF.scope, p);
}
visitArray -
*/
-static void visitArray (alists_alist v, decl_node n, decl_nodeProcedure p)
+static void visitArray (alists_alist v, decl_node__opaque n, decl_nodeProcedure p)
{
- mcDebug_assert (decl_isArray (n));
+ mcDebug_assert (decl_isArray (static_cast<decl_node> (n)));
visitNode (v, n->arrayF.subr, p);
visitNode (v, n->arrayF.type, p);
visitScope (v, n->arrayF.scope, p);
visitConst -
*/
-static void visitConst (alists_alist v, decl_node n, decl_nodeProcedure p)
+static void visitConst (alists_alist v, decl_node__opaque n, decl_nodeProcedure p)
{
- mcDebug_assert (decl_isConst (n));
+ mcDebug_assert (decl_isConst (static_cast<decl_node> (n)));
visitNode (v, n->constF.type, p);
visitNode (v, n->constF.value, p);
visitScope (v, n->constF.scope, p);
visitVarParam -
*/
-static void visitVarParam (alists_alist v, decl_node n, decl_nodeProcedure p)
+static void visitVarParam (alists_alist v, decl_node__opaque n, decl_nodeProcedure p)
{
- mcDebug_assert (decl_isVarParam (n));
+ mcDebug_assert (decl_isVarParam (static_cast<decl_node> (n)));
visitNode (v, n->varparamF.namelist, p);
visitNode (v, n->varparamF.type, p);
visitScope (v, n->varparamF.scope, p);
visitParam -
*/
-static void visitParam (alists_alist v, decl_node n, decl_nodeProcedure p)
+static void visitParam (alists_alist v, decl_node__opaque n, decl_nodeProcedure p)
{
- mcDebug_assert (decl_isParam (n));
+ mcDebug_assert (decl_isParam (static_cast<decl_node> (n)));
visitNode (v, n->paramF.namelist, p);
visitNode (v, n->paramF.type, p);
visitScope (v, n->paramF.scope, p);
visitOptarg -
*/
-static void visitOptarg (alists_alist v, decl_node n, decl_nodeProcedure p)
+static void visitOptarg (alists_alist v, decl_node__opaque n, decl_nodeProcedure p)
{
- mcDebug_assert (decl_isOptarg (n));
+ mcDebug_assert (decl_isOptarg (static_cast<decl_node> (n)));
visitNode (v, n->optargF.namelist, p);
visitNode (v, n->optargF.type, p);
visitNode (v, n->optargF.init, p);
visitRecordField -
*/
-static void visitRecordField (alists_alist v, decl_node n, decl_nodeProcedure p)
+static void visitRecordField (alists_alist v, decl_node__opaque n, decl_nodeProcedure p)
{
- mcDebug_assert (decl_isRecordField (n));
+ mcDebug_assert (decl_isRecordField (static_cast<decl_node> (n)));
visitNode (v, n->recordfieldF.type, p);
visitNode (v, n->recordfieldF.parent, p);
visitNode (v, n->recordfieldF.varient, p);
visitVarientField -
*/
-static void visitVarientField (alists_alist v, decl_node n, decl_nodeProcedure p)
+static void visitVarientField (alists_alist v, decl_node__opaque n, decl_nodeProcedure p)
{
- mcDebug_assert (decl_isVarientField (n));
+ mcDebug_assert (decl_isVarientField (static_cast<decl_node> (n)));
visitNode (v, n->varientfieldF.parent, p);
visitNode (v, n->varientfieldF.varient, p);
visitIndex (v, n->varientfieldF.listOfSons, p);
visitEnumerationField -
*/
-static void visitEnumerationField (alists_alist v, decl_node n, decl_nodeProcedure p)
+static void visitEnumerationField (alists_alist v, decl_node__opaque n, decl_nodeProcedure p)
{
- mcDebug_assert (decl_isEnumerationField (n));
+ mcDebug_assert (decl_isEnumerationField (static_cast<decl_node> (n)));
visitNode (v, n->enumerationfieldF.type, p);
visitScope (v, n->enumerationfieldF.scope, p);
}
visitSet -
*/
-static void visitSet (alists_alist v, decl_node n, decl_nodeProcedure p)
+static void visitSet (alists_alist v, decl_node__opaque n, decl_nodeProcedure p)
{
- mcDebug_assert (decl_isSet (n));
+ mcDebug_assert (decl_isSet (static_cast<decl_node> (n)));
visitNode (v, n->setF.type, p);
visitScope (v, n->setF.scope, p);
}
visitProcType -
*/
-static void visitProcType (alists_alist v, decl_node n, decl_nodeProcedure p)
+static void visitProcType (alists_alist v, decl_node__opaque n, decl_nodeProcedure p)
{
- mcDebug_assert (decl_isProcType (n));
+ mcDebug_assert (decl_isProcType (static_cast<decl_node> (n)));
visitIndex (v, n->proctypeF.parameters, p);
visitNode (v, n->proctypeF.optarg_, p);
visitNode (v, n->proctypeF.returnType, p);
visitSubscript -
*/
-static void visitSubscript (alists_alist v, decl_node n, decl_nodeProcedure p)
+static void visitSubscript (alists_alist v, decl_node__opaque n, decl_nodeProcedure p)
{
}
visitProcedure -
*/
-static void visitProcedure (alists_alist v, decl_node n, decl_nodeProcedure p)
+static void visitProcedure (alists_alist v, decl_node__opaque n, decl_nodeProcedure p)
{
- mcDebug_assert (decl_isProcedure (n));
+ mcDebug_assert (decl_isProcedure (static_cast<decl_node> (n)));
visitDecls (v, n->procedureF.decls, p);
visitScope (v, n->procedureF.scope, p);
visitIndex (v, n->procedureF.parameters, p);
visitDef -
*/
-static void visitDef (alists_alist v, decl_node n, decl_nodeProcedure p)
+static void visitDef (alists_alist v, decl_node__opaque n, decl_nodeProcedure p)
{
- mcDebug_assert (decl_isDef (n));
+ mcDebug_assert (decl_isDef (static_cast<decl_node> (n)));
visitDecls (v, n->defF.decls, p);
}
visitImp -
*/
-static void visitImp (alists_alist v, decl_node n, decl_nodeProcedure p)
+static void visitImp (alists_alist v, decl_node__opaque n, decl_nodeProcedure p)
{
- mcDebug_assert (decl_isImp (n));
+ mcDebug_assert (decl_isImp (static_cast<decl_node> (n)));
visitDecls (v, n->impF.decls, p);
visitNode (v, n->impF.beginStatements, p);
/* --fixme-- do we need to visit definitionModule? */
visitModule -
*/
-static void visitModule (alists_alist v, decl_node n, decl_nodeProcedure p)
+static void visitModule (alists_alist v, decl_node__opaque n, decl_nodeProcedure p)
{
- mcDebug_assert (decl_isModule (n));
+ mcDebug_assert (decl_isModule (static_cast<decl_node> (n)));
visitDecls (v, n->moduleF.decls, p);
visitNode (v, n->moduleF.beginStatements, p);
visitNode (v, n->moduleF.finallyStatements, p);
visitLoop -
*/
-static void visitLoop (alists_alist v, decl_node n, decl_nodeProcedure p)
+static void visitLoop (alists_alist v, decl_node__opaque n, decl_nodeProcedure p)
{
- mcDebug_assert (decl_isLoop (n));
+ mcDebug_assert (decl_isLoop (static_cast<decl_node> (n)));
visitNode (v, n->loopF.statements, p);
}
visitWhile -
*/
-static void visitWhile (alists_alist v, decl_node n, decl_nodeProcedure p)
+static void visitWhile (alists_alist v, decl_node__opaque n, decl_nodeProcedure p)
{
- mcDebug_assert (decl_isWhile (n));
+ mcDebug_assert (decl_isWhile (static_cast<decl_node> (n)));
visitNode (v, n->whileF.expr, p);
visitNode (v, n->whileF.statements, p);
}
visitRepeat -
*/
-static void visitRepeat (alists_alist v, decl_node n, decl_nodeProcedure p)
+static void visitRepeat (alists_alist v, decl_node__opaque n, decl_nodeProcedure p)
{
- mcDebug_assert (decl_isRepeat (n));
+ mcDebug_assert (decl_isRepeat (static_cast<decl_node> (n)));
visitNode (v, n->repeatF.expr, p);
visitNode (v, n->repeatF.statements, p);
}
visitCase -
*/
-static void visitCase (alists_alist v, decl_node n, decl_nodeProcedure p)
+static void visitCase (alists_alist v, decl_node__opaque n, decl_nodeProcedure p)
{
- mcDebug_assert (decl_isCase (n));
+ mcDebug_assert (decl_isCase (static_cast<decl_node> (n)));
visitNode (v, n->caseF.expression, p);
visitIndex (v, n->caseF.caseLabelList, p);
visitNode (v, n->caseF.else_, p);
visitCaseLabelList -
*/
-static void visitCaseLabelList (alists_alist v, decl_node n, decl_nodeProcedure p)
+static void visitCaseLabelList (alists_alist v, decl_node__opaque n, decl_nodeProcedure p)
{
- mcDebug_assert (decl_isCaseLabelList (n));
+ mcDebug_assert (decl_isCaseLabelList (static_cast<decl_node> (n)));
visitNode (v, n->caselabellistF.caseList, p);
visitNode (v, n->caselabellistF.statements, p);
}
visitCaseList -
*/
-static void visitCaseList (alists_alist v, decl_node n, decl_nodeProcedure p)
+static void visitCaseList (alists_alist v, decl_node__opaque n, decl_nodeProcedure p)
{
- mcDebug_assert (decl_isCaseList (n));
+ mcDebug_assert (decl_isCaseList (static_cast<decl_node> (n)));
visitIndex (v, n->caselistF.rangePairs, p);
}
visitRange -
*/
-static void visitRange (alists_alist v, decl_node n, decl_nodeProcedure p)
+static void visitRange (alists_alist v, decl_node__opaque n, decl_nodeProcedure p)
{
- mcDebug_assert (decl_isRange (n));
+ mcDebug_assert (decl_isRange (static_cast<decl_node> (n)));
visitNode (v, n->rangeF.lo, p);
visitNode (v, n->rangeF.hi, p);
}
visitIf -
*/
-static void visitIf (alists_alist v, decl_node n, decl_nodeProcedure p)
+static void visitIf (alists_alist v, decl_node__opaque n, decl_nodeProcedure p)
{
- mcDebug_assert (decl_isIf (n));
+ mcDebug_assert (decl_isIf (static_cast<decl_node> (n)));
visitNode (v, n->ifF.expr, p);
visitNode (v, n->ifF.elsif, p);
visitNode (v, n->ifF.then, p);
visitElsif -
*/
-static void visitElsif (alists_alist v, decl_node n, decl_nodeProcedure p)
+static void visitElsif (alists_alist v, decl_node__opaque n, decl_nodeProcedure p)
{
- mcDebug_assert (decl_isElsif (n));
+ mcDebug_assert (decl_isElsif (static_cast<decl_node> (n)));
visitNode (v, n->elsifF.expr, p);
visitNode (v, n->elsifF.elsif, p);
visitNode (v, n->elsifF.then, p);
visitFor -
*/
-static void visitFor (alists_alist v, decl_node n, decl_nodeProcedure p)
+static void visitFor (alists_alist v, decl_node__opaque n, decl_nodeProcedure p)
{
- mcDebug_assert (decl_isFor (n));
+ mcDebug_assert (decl_isFor (static_cast<decl_node> (n)));
visitNode (v, n->forF.des, p);
visitNode (v, n->forF.start, p);
visitNode (v, n->forF.end, p);
visitAssignment -
*/
-static void visitAssignment (alists_alist v, decl_node n, decl_nodeProcedure p)
+static void visitAssignment (alists_alist v, decl_node__opaque n, decl_nodeProcedure p)
{
mcDebug_assert (isAssignment (n));
visitNode (v, n->assignmentF.des, p);
visitComponentRef -
*/
-static void visitComponentRef (alists_alist v, decl_node n, decl_nodeProcedure p)
+static void visitComponentRef (alists_alist v, decl_node__opaque n, decl_nodeProcedure p)
{
mcDebug_assert (isComponentRef (n));
visitNode (v, n->componentrefF.rec, p);
visitPointerRef -
*/
-static void visitPointerRef (alists_alist v, decl_node n, decl_nodeProcedure p)
+static void visitPointerRef (alists_alist v, decl_node__opaque n, decl_nodeProcedure p)
{
- mcDebug_assert (decl_isPointerRef (n));
+ mcDebug_assert (decl_isPointerRef (static_cast<decl_node> (n)));
visitNode (v, n->pointerrefF.ptr, p);
visitNode (v, n->pointerrefF.field, p);
visitNode (v, n->pointerrefF.resultType, p);
visitArrayRef -
*/
-static void visitArrayRef (alists_alist v, decl_node n, decl_nodeProcedure p)
+static void visitArrayRef (alists_alist v, decl_node__opaque n, decl_nodeProcedure p)
{
mcDebug_assert (isArrayRef (n));
visitNode (v, n->arrayrefF.array, p);
visitFunccall -
*/
-static void visitFunccall (alists_alist v, decl_node n, decl_nodeProcedure p)
+static void visitFunccall (alists_alist v, decl_node__opaque n, decl_nodeProcedure p)
{
mcDebug_assert (isFuncCall (n));
visitNode (v, n->funccallF.function, p);
visitVarDecl -
*/
-static void visitVarDecl (alists_alist v, decl_node n, decl_nodeProcedure p)
+static void visitVarDecl (alists_alist v, decl_node__opaque n, decl_nodeProcedure p)
{
mcDebug_assert (isVarDecl (n));
visitNode (v, n->vardeclF.type, p);
visitExplist -
*/
-static void visitExplist (alists_alist v, decl_node n, decl_nodeProcedure p)
+static void visitExplist (alists_alist v, decl_node__opaque n, decl_nodeProcedure p)
{
- mcDebug_assert (decl_isExpList (n));
+ mcDebug_assert (decl_isExpList (static_cast<decl_node> (n)));
visitIndex (v, n->explistF.exp, p);
}
visitExit -
*/
-static void visitExit (alists_alist v, decl_node n, decl_nodeProcedure p)
+static void visitExit (alists_alist v, decl_node__opaque n, decl_nodeProcedure p)
{
- mcDebug_assert (decl_isExit (n));
+ mcDebug_assert (decl_isExit (static_cast<decl_node> (n)));
visitNode (v, n->exitF.loop, p);
}
visitReturn -
*/
-static void visitReturn (alists_alist v, decl_node n, decl_nodeProcedure p)
+static void visitReturn (alists_alist v, decl_node__opaque n, decl_nodeProcedure p)
{
- mcDebug_assert (decl_isReturn (n));
+ mcDebug_assert (decl_isReturn (static_cast<decl_node> (n)));
visitNode (v, n->returnF.exp, p);
}
visitStmtSeq -
*/
-static void visitStmtSeq (alists_alist v, decl_node n, decl_nodeProcedure p)
+static void visitStmtSeq (alists_alist v, decl_node__opaque n, decl_nodeProcedure p)
{
- mcDebug_assert (decl_isStatementSequence (n));
+ mcDebug_assert (decl_isStatementSequence (static_cast<decl_node> (n)));
visitIndex (v, n->stmtF.statements, p);
}
visitVarargs -
*/
-static void visitVarargs (alists_alist v, decl_node n, decl_nodeProcedure p)
+static void visitVarargs (alists_alist v, decl_node__opaque n, decl_nodeProcedure p)
{
- mcDebug_assert (decl_isVarargs (n));
+ mcDebug_assert (decl_isVarargs (static_cast<decl_node> (n)));
visitScope (v, n->varargsF.scope, p);
}
visitSetValue -
*/
-static void visitSetValue (alists_alist v, decl_node n, decl_nodeProcedure p)
+static void visitSetValue (alists_alist v, decl_node__opaque n, decl_nodeProcedure p)
{
- mcDebug_assert (decl_isSetValue (n));
+ mcDebug_assert (decl_isSetValue (static_cast<decl_node> (n)));
visitNode (v, n->setvalueF.type, p);
visitIndex (v, n->setvalueF.values, p);
}
visitIntrinsic -
*/
-static void visitIntrinsic (alists_alist v, decl_node n, decl_nodeProcedure p)
+static void visitIntrinsic (alists_alist v, decl_node__opaque n, decl_nodeProcedure p)
{
mcDebug_assert (isIntrinsic (n));
visitNode (v, n->intrinsicF.args, p);
visit node, n, dependants.
*/
-static void visitDependants (alists_alist v, decl_node n, decl_nodeProcedure p)
+static void visitDependants (alists_alist v, decl_node__opaque n, decl_nodeProcedure p)
{
mcDebug_assert (n != NULL);
mcDebug_assert (alists_isItemInList (v, reinterpret_cast<void *> (n)));
It calls p(n) if the node is unvisited.
*/
-static void visitNode (alists_alist v, decl_node n, decl_nodeProcedure p)
+static void visitNode (alists_alist v, decl_node__opaque n, decl_nodeProcedure p)
{
if ((n != NULL) && (! (alists_isItemInList (v, reinterpret_cast<void *> (n)))))
{
genKind - returns a string depending upon the kind of node, n.
*/
-static DynamicStrings_String genKind (decl_node n)
+static DynamicStrings_String genKind (decl_node__opaque n)
{
switch (n->kind)
{
case decl_longcomplex:
case decl_shortcomplex:
/* types, no need to generate a kind string as it it contained in the name. */
- return NULL;
+ return static_cast<DynamicStrings_String> (NULL);
break;
case decl_type:
gen - generate a small string describing node, n.
*/
-static DynamicStrings_String gen (decl_node n)
+static DynamicStrings_String gen (decl_node__opaque n)
{
DynamicStrings_String s;
unsigned int d;
static void dumpQ (const char *q_, unsigned int _q_high, alists_alist l)
{
DynamicStrings_String m;
- decl_node n;
+ decl_node__opaque n;
unsigned int d;
unsigned int h;
unsigned int i;
h = alists_noOfItemsInList (l);
while (i <= h)
{
- n = static_cast<decl_node> (alists_getItemFromList (l, i));
+ n = static_cast<decl_node__opaque> (alists_getItemFromList (l, i));
m = DynamicStrings_KillString (SFIO_WriteS (FIO_StdOut, gen (n)));
i += 1;
}
static void dumpLists (void)
{
- DynamicStrings_String m;
-
- if (mcOptions_getDebugTopological ())
+ if ((mcOptions_getDebugTopological ()) && false)
{
- m = FormatStrings_Sprintf0 (DynamicStrings_InitString ((const char *) "\\n", 2));
- m = DynamicStrings_KillString (SFIO_WriteS (FIO_StdOut, m));
dumpQ ((const char *) "todo", 4, globalGroup->todoQ);
dumpQ ((const char *) "partial", 7, globalGroup->partialQ);
dumpQ ((const char *) "done", 4, globalGroup->doneQ);
outputHidden -
*/
-static void outputHidden (decl_node n)
+static void outputHidden (decl_node__opaque n)
{
outText (doP, (const char *) "#if !defined (", 14);
doFQNameC (doP, n);
outputHiddenComplete -
*/
-static void outputHiddenComplete (decl_node n)
+static void outputHiddenComplete (decl_node__opaque n)
{
- decl_node t;
+ decl_node__opaque t;
- mcDebug_assert (decl_isType (n));
- t = decl_getType (n);
- mcDebug_assert (decl_isPointer (t));
+ mcDebug_assert (decl_isType (static_cast<decl_node> (n)));
+ t = static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (n)));
+ mcDebug_assert (decl_isPointer (static_cast<decl_node> (t)));
outText (doP, (const char *) "#define ", 8);
doFQNameC (doP, n);
outText (doP, (const char *) "_D\\n", 4);
outText (doP, (const char *) "typedef ", 8);
- doTypeNameC (doP, decl_getType (t));
+ doTypeNameC (doP, static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (t))));
mcPretty_setNeedSpace (doP);
outText (doP, (const char *) "*", 1);
doFQNameC (doP, n);
tryPartial -
*/
-static bool tryPartial (decl_node n, decl_nodeProcedure pt)
+static bool tryPartial (decl_node__opaque n, decl_nodeProcedure pt)
{
- decl_node q;
+ decl_node__opaque q;
- if ((n != NULL) && (decl_isType (n)))
+ if ((n != NULL) && (decl_isType (static_cast<decl_node> (n))))
{
- q = decl_getType (n);
- while (decl_isPointer (q))
+ q = static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (n)));
+ while (decl_isPointer (static_cast<decl_node> (q)))
{
- q = decl_getType (q);
+ q = static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (q)));
}
if (q != NULL)
{
/* avoid gcc warning by using compound statement even if not strictly necessary. */
- if ((decl_isRecord (q)) || (decl_isProcType (q)))
+ if ((decl_isRecord (static_cast<decl_node> (q))) || (decl_isProcType (static_cast<decl_node> (q))))
{
(*pt.proc) (n);
addTodo (q);
return true;
}
- else if (decl_isArray (q))
+ else if (decl_isArray (static_cast<decl_node> (q)))
{
/* avoid dangling else. */
(*pt.proc) (n);
outputPartialRecordArrayProcType -
*/
-static void outputPartialRecordArrayProcType (decl_node n, decl_node q, unsigned int indirection)
+static void outputPartialRecordArrayProcType (decl_node__opaque n, decl_node__opaque q, unsigned int indirection)
{
DynamicStrings_String s;
outText (doP, (const char *) "typedef struct", 14);
mcPretty_setNeedSpace (doP);
s = getFQstring (n);
- if (decl_isRecord (q))
+ if (decl_isRecord (static_cast<decl_node> (q)))
{
s = DynamicStrings_ConCat (s, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "_r", 2)));
}
- else if (decl_isArray (q))
+ else if (decl_isArray (static_cast<decl_node> (q)))
{
/* avoid dangling else. */
s = DynamicStrings_ConCat (s, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "_a", 2)));
}
- else if (decl_isProcType (q))
+ else if (decl_isProcType (static_cast<decl_node> (q)))
{
/* avoid dangling else. */
s = DynamicStrings_ConCat (s, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "_p", 2)));
outputPartial -
*/
-static void outputPartial (decl_node n)
+static void outputPartial (decl_node__opaque n)
{
- decl_node q;
+ decl_node__opaque q;
unsigned int indirection;
- q = decl_getType (n);
+ q = static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (n)));
indirection = 0;
- while (decl_isPointer (q))
+ while (decl_isPointer (static_cast<decl_node> (q)))
{
- q = decl_getType (q);
+ q = static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (q)));
indirection += 1;
}
outputPartialRecordArrayProcType (n, q, indirection);
{
unsigned int i;
unsigned int n;
- decl_node d;
+ decl_node__opaque d;
i = 1;
n = alists_noOfItemsInList (globalGroup->todoQ);
while (i <= n)
{
- d = static_cast<decl_node> (alists_getItemFromList (globalGroup->todoQ, i));
+ d = static_cast<decl_node__opaque> (alists_getItemFromList (globalGroup->todoQ, i));
if (tryComplete (d, c, t, v))
{
alists_removeItemFromList (globalGroup->todoQ, reinterpret_cast<void *> (d));
- alists_includeItemIntoList (globalGroup->doneQ, reinterpret_cast<void *> (d));
+ addDone (d);
i = 1;
}
else if (tryPartial (d, pt))
{
unsigned int i;
unsigned int n;
- decl_node d;
+ decl_node__opaque d;
i = 1;
n = alists_noOfItemsInList (globalGroup->partialQ);
while (i <= n)
{
- d = static_cast<decl_node> (alists_getItemFromList (globalGroup->partialQ, i));
+ d = static_cast<decl_node__opaque> (alists_getItemFromList (globalGroup->partialQ, i));
if (tryCompleteFromPartial (d, t))
{
alists_removeItemFromList (globalGroup->partialQ, reinterpret_cast<void *> (d));
- alists_includeItemIntoList (globalGroup->doneQ, reinterpret_cast<void *> (d));
+ addDone (d);
i = 1;
n -= 1;
}
debugList -
*/
-static void debugList (const char *a_, unsigned int _a_high, alists_alist l)
+static void debugList (const char *listName_, unsigned int _listName_high, const char *symName_, unsigned int _symName_high, alists_alist l)
{
unsigned int i;
unsigned int h;
- decl_node n;
- char a[_a_high+1];
+ decl_node__opaque n;
+ char listName[_listName_high+1];
+ char symName[_symName_high+1];
/* make a local copy of each unbounded array. */
- memcpy (a, a_, _a_high+1);
+ memcpy (listName, listName_, _listName_high+1);
+ memcpy (symName, symName_, _symName_high+1);
h = alists_noOfItemsInList (l);
if (h > 0)
{
- outText (doP, (const char *) a, _a_high);
- outText (doP, (const char *) " still contains node(s)\\n", 25);
i = 1;
do {
- n = static_cast<decl_node> (alists_getItemFromList (l, i));
- dbg (n);
+ n = static_cast<decl_node__opaque> (alists_getItemFromList (l, i));
+ dbg ((const char *) listName, _listName_high, (const char *) symName, _symName_high, n);
i += 1;
} while (! (i > h));
}
{
if (mcOptions_getDebugTopological ())
{
- debugList ((const char *) "todo", 4, globalGroup->todoQ);
- debugList ((const char *) "partial", 7, globalGroup->partialQ);
+ debugList ((const char *) "todo", 4, (const char *) "decl_node", 9, globalGroup->todoQ);
+ debugList ((const char *) "partial", 7, (const char *) "decl_node", 9, globalGroup->partialQ);
+ debugList ((const char *) "done", 4, (const char *) "decl_node", 9, globalGroup->doneQ);
}
}
addEnumConst -
*/
-static void addEnumConst (decl_node n)
+static void addEnumConst (decl_node__opaque n)
{
DynamicStrings_String s;
- if ((decl_isConst (n)) || (decl_isEnumeration (n)))
+ if ((decl_isConst (static_cast<decl_node> (n))) || (decl_isEnumeration (static_cast<decl_node> (n))))
{
addTodo (n);
}
static void populateTodo (decl_nodeProcedure p)
{
- decl_node n;
+ decl_node__opaque n;
unsigned int i;
unsigned int h;
alists_alist l;
i = 1;
while (i <= h)
{
- n = static_cast<decl_node> (alists_getItemFromList (globalGroup->todoQ, i));
+ n = static_cast<decl_node__opaque> (alists_getItemFromList (globalGroup->todoQ, i));
l = alists_initList ();
visitNode (l, n, p);
alists_killList (&l);
scaffoldStatic -
*/
-static void scaffoldStatic (mcPretty_pretty p, decl_node n)
+static void scaffoldStatic (mcPretty_pretty p, decl_node__opaque n)
{
outText (p, (const char *) "\\n", 2);
doExternCP (p);
doFQNameC (p, n);
outText (p, (const char *) "_init", 5);
mcPretty_setNeedSpace (p);
- outText (p, (const char *) "(__attribute__((unused)) int argc", 33);
- outText (p, (const char *) ",__attribute__((unused)) char *argv[]", 37);
- outText (p, (const char *) ",__attribute__((unused)) char *envp[])\\n", 40);
+ outText (p, (const char *) "(__attribute__((unused)) int argc,", 34);
+ mcPretty_setNeedSpace (p);
+ outText (p, (const char *) "__attribute__((unused)) char *argv[],", 37);
+ mcPretty_setNeedSpace (p);
+ outText (p, (const char *) "__attribute__((unused)) char *envp[])\\n", 39);
p = outKc (p, (const char *) "{\\n", 3);
doStatementsC (p, n->impF.beginStatements);
p = outKc (p, (const char *) "}\\n", 3);
doFQNameC (p, n);
outText (p, (const char *) "_fini", 5);
mcPretty_setNeedSpace (p);
- outText (p, (const char *) "(__attribute__((unused)) int argc", 33);
- outText (p, (const char *) ",__attribute__((unused)) char *argv[]", 37);
- outText (p, (const char *) ",__attribute__((unused)) char *envp[])\\n", 40);
+ outText (p, (const char *) "(__attribute__((unused)) int argc,", 34);
+ mcPretty_setNeedSpace (p);
+ outText (p, (const char *) "__attribute__((unused)) char *argv[],", 37);
+ mcPretty_setNeedSpace (p);
+ outText (p, (const char *) "__attribute__((unused)) char *envp[])\\n", 39);
p = outKc (p, (const char *) "{\\n", 3);
doStatementsC (p, n->impF.finallyStatements);
p = outKc (p, (const char *) "}\\n", 3);
emitCtor -
*/
-static void emitCtor (mcPretty_pretty p, decl_node n)
+static void emitCtor (mcPretty_pretty p, decl_node__opaque n)
{
DynamicStrings_String s;
doFQNameC (p, n);
p = outKc (p, (const char *) "{\\n", 3);
outText (p, (const char *) "M2RTS_RegisterModule (\"", 23);
- s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (n)));
+ s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (static_cast<decl_node> (n))));
mcPretty_prints (p, s);
outText (p, (const char *) "\",\\n", 4);
outText (p, (const char *) "init, fini, dependencies);\\n", 28);
scaffoldDynamic -
*/
-static void scaffoldDynamic (mcPretty_pretty p, decl_node n)
+static void scaffoldDynamic (mcPretty_pretty p, decl_node__opaque n)
{
outText (p, (const char *) "\\n", 2);
doExternCP (p);
outText (p, (const char *) "_init", 5);
mcPretty_setNeedSpace (p);
outText (p, (const char *) "(__attribute__((unused)) int argc,", 34);
- outText (p, (const char *) " __attribute__((unused)) char *argv[]", 37);
- outText (p, (const char *) " __attribute__((unused)) char *envp[])\\n", 40);
+ mcPretty_setNeedSpace (p);
+ outText (p, (const char *) "__attribute__((unused)) char *argv[],", 37);
+ mcPretty_setNeedSpace (p);
+ outText (p, (const char *) "__attribute__((unused)) char *envp[])\\n", 39);
p = outKc (p, (const char *) "{\\n", 3);
doStatementsC (p, n->impF.beginStatements);
p = outKc (p, (const char *) "}\\n", 3);
outText (p, (const char *) "_fini", 5);
mcPretty_setNeedSpace (p);
outText (p, (const char *) "(__attribute__((unused)) int argc,", 34);
- outText (p, (const char *) " __attribute__((unused)) char *argv[]", 37);
- outText (p, (const char *) " __attribute__((unused)) char *envp[])\\n", 40);
+ mcPretty_setNeedSpace (p);
+ outText (p, (const char *) "__attribute__((unused)) char *argv[],", 37);
+ mcPretty_setNeedSpace (p);
+ outText (p, (const char *) "__attribute__((unused)) char *envp[])\\n", 39);
p = outKc (p, (const char *) "{\\n", 3);
doStatementsC (p, n->impF.finallyStatements);
p = outKc (p, (const char *) "}\\n", 3);
scaffoldMain -
*/
-static void scaffoldMain (mcPretty_pretty p, decl_node n)
+static void scaffoldMain (mcPretty_pretty p, decl_node__opaque n)
{
DynamicStrings_String s;
outText (p, (const char *) "(int argc, char *argv[], char *envp[])\\n", 40);
p = outKc (p, (const char *) "{\\n", 3);
outText (p, (const char *) "M2RTS_ConstructModules (", 24);
- s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (n)));
+ s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (static_cast<decl_node> (n))));
mcPretty_prints (p, s);
outText (p, (const char *) ", argc, argv, envp);\\n", 22);
outText (p, (const char *) "M2RTS_DeconstructModules (", 26);
outImpInitC - emit the init/fini functions and main function if required.
*/
-static void outImpInitC (mcPretty_pretty p, decl_node n)
+static void outImpInitC (mcPretty_pretty p, decl_node__opaque n)
{
if (mcOptions_getScaffoldDynamic ())
{
runSimplifyTypes -
*/
-static void runSimplifyTypes (decl_node n)
+static void runSimplifyTypes (decl_node__opaque n)
{
- if (decl_isImp (n))
+ if (decl_isImp (static_cast<decl_node> (n)))
{
simplifyTypes (n->impF.decls);
}
- else if (decl_isModule (n))
+ else if (decl_isModule (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
simplifyTypes (n->moduleF.decls);
}
- else if (decl_isDef (n))
+ else if (decl_isDef (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
simplifyTypes (n->defF.decls);
outDefC -
*/
-static void outDefC (mcPretty_pretty p, decl_node n)
+static void outDefC (mcPretty_pretty p, decl_node__opaque n)
{
DynamicStrings_String s;
- mcDebug_assert (decl_isDef (n));
+ mcDebug_assert (decl_isDef (static_cast<decl_node> (n)));
outputFile = mcStream_openFrag (1); /* first fragment. */
- s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (n))); /* first fragment. */
+ s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (static_cast<decl_node> (n)))); /* first fragment. */
mcPretty_print (p, (const char *) "/* do not edit automatically generated by mc from ", 50);
mcPretty_prints (p, s);
mcPretty_print (p, (const char *) ". */\\n", 7);
runPrototypeExported -
*/
-static void runPrototypeExported (decl_node n)
+static void runPrototypeExported (decl_node__opaque n)
{
- if (decl_isExported (n))
+ if (decl_isExported (static_cast<decl_node> (n)))
{
- keyc_enterScope (n);
+ keyc_enterScope (static_cast<decl_node> (n));
doProcedureHeadingC (n, true);
mcPretty_print (doP, (const char *) ";\\n", 3);
- keyc_leaveScope (n);
+ keyc_leaveScope (static_cast<decl_node> (n));
}
}
runPrototypeDefC -
*/
-static void runPrototypeDefC (decl_node n)
+static void runPrototypeDefC (decl_node__opaque n)
{
- if (decl_isDef (n))
+ if (decl_isDef (static_cast<decl_node> (n)))
{
Indexing_ForeachIndiceInIndexDo (n->defF.decls.procedures, (Indexing_IndexProcedure) {(Indexing_IndexProcedure_t) runPrototypeExported});
}
outImpC -
*/
-static void outImpC (mcPretty_pretty p, decl_node n)
+static void outImpC (mcPretty_pretty p, decl_node__opaque n)
{
DynamicStrings_String s;
- decl_node defModule;
+ decl_node__opaque defModule;
- mcDebug_assert (decl_isImp (n));
+ mcDebug_assert (decl_isImp (static_cast<decl_node> (n)));
outputFile = mcStream_openFrag (1); /* first fragment. */
- s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (n))); /* first fragment. */
+ s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (static_cast<decl_node> (n)))); /* first fragment. */
mcPretty_print (p, (const char *) "/* do not edit automatically generated by mc from ", 50);
mcPretty_prints (p, s);
mcPretty_print (p, (const char *) ". */\\n", 7);
}
else
{
- s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (n)));
- /* we don't want to include the .h file for this implementation module. */
- mcPretty_print (p, (const char *) "#define _", 9);
- mcPretty_prints (p, s);
- mcPretty_print (p, (const char *) "_H\\n", 4);
+ s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (static_cast<decl_node> (n))));
+ /* Inform the source that this code belongs to the implementation module. */
mcPretty_print (p, (const char *) "#define _", 9);
mcPretty_prints (p, s);
mcPretty_print (p, (const char *) "_C\\n\\n", 6);
+ /* Include the definition module for any opaque types. */
+ mcPretty_print (doP, (const char *) "#include \"", 10);
+ mcPretty_prints (p, mcOptions_getHPrefix ());
+ mcPretty_prints (p, s);
+ mcPretty_print (p, (const char *) ".h\"\\n", 5);
s = DynamicStrings_KillString (s);
doP = p;
Indexing_ForeachIndiceInIndexDo (n->impF.importedModules, (Indexing_IndexProcedure) {(Indexing_IndexProcedure_t) doIncludeC});
includeDefConstType (n);
includeDefVarProcedure (n);
outDeclsImpC (p, n->impF.decls);
- defModule = decl_lookupDef (decl_getSymName (n));
+ defModule = static_cast<decl_node__opaque> (decl_lookupDef (decl_getSymName (static_cast<decl_node> (n))));
if (defModule != NULL)
{
runPrototypeDefC (defModule);
outModuleInitC -
*/
-static void outModuleInitC (mcPretty_pretty p, decl_node n)
+static void outModuleInitC (mcPretty_pretty p, decl_node__opaque n)
{
outText (p, (const char *) "\\n", 2);
doExternCP (p);
outModuleC -
*/
-static void outModuleC (mcPretty_pretty p, decl_node n)
+static void outModuleC (mcPretty_pretty p, decl_node__opaque n)
{
DynamicStrings_String s;
- mcDebug_assert (decl_isModule (n));
+ mcDebug_assert (decl_isModule (static_cast<decl_node> (n)));
outputFile = mcStream_openFrag (1); /* first fragment. */
- s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (n))); /* first fragment. */
+ s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (static_cast<decl_node> (n)))); /* first fragment. */
mcPretty_print (p, (const char *) "/* do not edit automatically generated by mc from ", 50);
mcPretty_prints (p, s);
mcPretty_print (p, (const char *) ". */\\n", 7);
outC -
*/
-static void outC (mcPretty_pretty p, decl_node n)
+static void outC (mcPretty_pretty p, decl_node__opaque n)
{
- keyc_enterScope (n);
- if (decl_isDef (n))
+ keyc_enterScope (static_cast<decl_node> (n));
+ if (decl_isDef (static_cast<decl_node> (n)))
{
outDefC (p, n);
}
- else if (decl_isImp (n))
+ else if (decl_isImp (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
outImpC (p, n);
}
- else if (decl_isModule (n))
+ else if (decl_isModule (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
outModuleC (p, n);
M2RTS_HALT (-1);
__builtin_unreachable ();
}
- keyc_leaveScope (n);
+ keyc_leaveScope (static_cast<decl_node> (n));
}
doIncludeM2 - include modules in module, n.
*/
-static void doIncludeM2 (decl_node n)
+static void doIncludeM2 (decl_node__opaque n)
{
DynamicStrings_String s;
- s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (n)));
+ s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (static_cast<decl_node> (n))));
mcPretty_print (doP, (const char *) "IMPORT ", 7);
mcPretty_prints (doP, s);
mcPretty_print (doP, (const char *) " ;\\n", 4);
s = DynamicStrings_KillString (s);
- if (decl_isDef (n))
+ if (decl_isDef (static_cast<decl_node> (n)))
{
symbolKey_foreachNodeDo (n->defF.decls.symbols, (symbolKey_performOperation) {(symbolKey_performOperation_t) addDone});
}
- else if (decl_isImp (n))
+ else if (decl_isImp (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
symbolKey_foreachNodeDo (n->impF.decls.symbols, (symbolKey_performOperation) {(symbolKey_performOperation_t) addDone});
}
- else if (decl_isModule (n))
+ else if (decl_isModule (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
symbolKey_foreachNodeDo (n->moduleF.decls.symbols, (symbolKey_performOperation) {(symbolKey_performOperation_t) addDone});
doConstM2 -
*/
-static void doConstM2 (decl_node n)
+static void doConstM2 (decl_node__opaque n)
{
mcPretty_print (doP, (const char *) "CONST\\n", 7);
doFQNameC (doP, n);
doProcTypeM2 -
*/
-static void doProcTypeM2 (mcPretty_pretty p, decl_node n)
+static void doProcTypeM2 (mcPretty_pretty p, decl_node__opaque n)
{
outText (p, (const char *) "proc type to do..", 17);
}
doRecordFieldM2 -
*/
-static void doRecordFieldM2 (mcPretty_pretty p, decl_node f)
+static void doRecordFieldM2 (mcPretty_pretty p, decl_node__opaque f)
{
doNameM2 (p, f);
outText (p, (const char *) ":", 1);
mcPretty_setNeedSpace (p);
- doTypeM2 (p, decl_getType (f));
+ doTypeM2 (p, static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (f))));
mcPretty_setNeedSpace (p);
}
doVarientFieldM2 -
*/
-static void doVarientFieldM2 (mcPretty_pretty p, decl_node n)
+static void doVarientFieldM2 (mcPretty_pretty p, decl_node__opaque n)
{
unsigned int i;
unsigned int t;
- decl_node q;
+ decl_node__opaque q;
- mcDebug_assert (decl_isVarientField (n));
+ mcDebug_assert (decl_isVarientField (static_cast<decl_node> (n)));
doNameM2 (p, n);
outText (p, (const char *) ":", 1);
mcPretty_setNeedSpace (p);
t = Indexing_HighIndice (n->varientfieldF.listOfSons);
while (i <= t)
{
- q = static_cast<decl_node> (Indexing_GetIndice (n->varientfieldF.listOfSons, i));
- if (decl_isRecordField (q))
+ q = static_cast<decl_node__opaque> (Indexing_GetIndice (n->varientfieldF.listOfSons, i));
+ if (decl_isRecordField (static_cast<decl_node> (q)))
{
doRecordFieldM2 (p, q);
outText (p, (const char *) ";\\n", 3);
}
- else if (decl_isVarient (q))
+ else if (decl_isVarient (static_cast<decl_node> (q)))
{
/* avoid dangling else. */
doVarientM2 (p, q);
doVarientM2 -
*/
-static void doVarientM2 (mcPretty_pretty p, decl_node n)
+static void doVarientM2 (mcPretty_pretty p, decl_node__opaque n)
{
unsigned int i;
unsigned int t;
- decl_node q;
+ decl_node__opaque q;
- mcDebug_assert (decl_isVarient (n));
+ mcDebug_assert (decl_isVarient (static_cast<decl_node> (n)));
outText (p, (const char *) "CASE", 4);
mcPretty_setNeedSpace (p);
if (n->varientF.tag != NULL)
{
/* avoid gcc warning by using compound statement even if not strictly necessary. */
- if (decl_isRecordField (n->varientF.tag))
+ if (decl_isRecordField (static_cast<decl_node> (n->varientF.tag)))
{
doRecordFieldM2 (p, n->varientF.tag);
}
- else if (decl_isVarientField (n->varientF.tag))
+ else if (decl_isVarientField (static_cast<decl_node> (n->varientF.tag)))
{
/* avoid dangling else. */
doVarientFieldM2 (p, n->varientF.tag);
t = Indexing_HighIndice (n->varientF.listOfSons);
while (i <= t)
{
- q = static_cast<decl_node> (Indexing_GetIndice (n->varientF.listOfSons, i));
- if (decl_isRecordField (q))
+ q = static_cast<decl_node__opaque> (Indexing_GetIndice (n->varientF.listOfSons, i));
+ if (decl_isRecordField (static_cast<decl_node> (q)))
{
/* avoid dangling else. */
if (! q->recordfieldF.tag)
outText (p, (const char *) ";\\n", 3);
}
}
- else if (decl_isVarientField (q))
+ else if (decl_isVarientField (static_cast<decl_node> (q)))
{
/* avoid dangling else. */
doVarientFieldM2 (p, q);
doRecordM2 -
*/
-static void doRecordM2 (mcPretty_pretty p, decl_node n)
+static void doRecordM2 (mcPretty_pretty p, decl_node__opaque n)
{
unsigned int i;
unsigned int h;
- decl_node f;
+ decl_node__opaque f;
- mcDebug_assert (decl_isRecord (n));
+ mcDebug_assert (decl_isRecord (static_cast<decl_node> (n)));
p = outKm2 (p, (const char *) "RECORD", 6);
i = Indexing_LowIndice (n->recordF.listOfSons);
h = Indexing_HighIndice (n->recordF.listOfSons);
outText (p, (const char *) "\\n", 2);
while (i <= h)
{
- f = static_cast<decl_node> (Indexing_GetIndice (n->recordF.listOfSons, i));
- if (decl_isRecordField (f))
+ f = static_cast<decl_node__opaque> (Indexing_GetIndice (n->recordF.listOfSons, i));
+ if (decl_isRecordField (static_cast<decl_node> (f)))
{
/* avoid dangling else. */
if (! f->recordfieldF.tag)
outText (p, (const char *) ";\\n", 3);
}
}
- else if (decl_isVarient (f))
+ else if (decl_isVarient (static_cast<decl_node> (f)))
{
/* avoid dangling else. */
doVarientM2 (p, f);
outText (p, (const char *) ";\\n", 3);
}
- else if (decl_isVarientField (f))
+ else if (decl_isVarientField (static_cast<decl_node> (f)))
{
/* avoid dangling else. */
doVarientFieldM2 (p, f);
doPointerM2 -
*/
-static void doPointerM2 (mcPretty_pretty p, decl_node n)
+static void doPointerM2 (mcPretty_pretty p, decl_node__opaque n)
{
outText (p, (const char *) "POINTER TO", 10);
mcPretty_setNeedSpace (doP);
- doTypeM2 (p, decl_getType (n));
+ doTypeM2 (p, static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (n))));
mcPretty_setNeedSpace (p);
outText (p, (const char *) ";\\n", 3);
}
doTypeAliasM2 -
*/
-static void doTypeAliasM2 (mcPretty_pretty p, decl_node n)
+static void doTypeAliasM2 (mcPretty_pretty p, decl_node__opaque n)
{
doTypeNameC (p, n);
mcPretty_setNeedSpace (p);
outText (doP, (const char *) "=", 1);
mcPretty_setNeedSpace (p);
- doTypeM2 (p, decl_getType (n));
+ doTypeM2 (p, static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (n))));
mcPretty_setNeedSpace (p);
outText (p, (const char *) "\\n", 2);
}
doEnumerationM2 -
*/
-static void doEnumerationM2 (mcPretty_pretty p, decl_node n)
+static void doEnumerationM2 (mcPretty_pretty p, decl_node__opaque n)
{
unsigned int i;
unsigned int h;
- decl_node s;
+ decl_node__opaque s;
DynamicStrings_String t;
outText (p, (const char *) "(", 1);
h = Indexing_HighIndice (n->enumerationF.listOfSons);
while (i <= h)
{
- s = static_cast<decl_node> (Indexing_GetIndice (n->enumerationF.listOfSons, i));
+ s = static_cast<decl_node__opaque> (Indexing_GetIndice (n->enumerationF.listOfSons, i));
doFQNameC (p, s);
if (i < h)
{
doBaseM2 -
*/
-static void doBaseM2 (mcPretty_pretty p, decl_node n)
+static void doBaseM2 (mcPretty_pretty p, decl_node__opaque n)
{
switch (n->kind)
{
doSystemM2 -
*/
-static void doSystemM2 (mcPretty_pretty p, decl_node n)
+static void doSystemM2 (mcPretty_pretty p, decl_node__opaque n)
{
switch (n->kind)
{
doTypeM2 -
*/
-static void doTypeM2 (mcPretty_pretty p, decl_node n)
+static void doTypeM2 (mcPretty_pretty p, decl_node__opaque n)
{
if (isBase (n))
{
/* avoid dangling else. */
doSystemM2 (p, n);
}
- else if (decl_isType (n))
+ else if (decl_isType (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
doTypeAliasM2 (p, n);
}
- else if (decl_isProcType (n))
+ else if (decl_isProcType (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
doProcTypeM2 (p, n);
}
- else if (decl_isPointer (n))
+ else if (decl_isPointer (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
doPointerM2 (p, n);
}
- else if (decl_isEnumeration (n))
+ else if (decl_isEnumeration (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
doEnumerationM2 (p, n);
}
- else if (decl_isRecord (n))
+ else if (decl_isRecord (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
doRecordM2 (p, n);
doTypesM2 -
*/
-static void doTypesM2 (decl_node n)
+static void doTypesM2 (decl_node__opaque n)
{
- decl_node m;
+ decl_node__opaque m;
outText (doP, (const char *) "TYPE\\n", 6);
doTypeM2 (doP, n);
doVarM2 -
*/
-static void doVarM2 (decl_node n)
+static void doVarM2 (decl_node__opaque n)
{
- mcDebug_assert (decl_isVar (n));
+ mcDebug_assert (decl_isVar (static_cast<decl_node> (n)));
doNameC (doP, n);
outText (doP, (const char *) ":", 1);
mcPretty_setNeedSpace (doP);
- doTypeM2 (doP, decl_getType (n));
+ doTypeM2 (doP, static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (n))));
mcPretty_setNeedSpace (doP);
outText (doP, (const char *) ";\\n", 3);
}
doVarsM2 -
*/
-static void doVarsM2 (decl_node n)
+static void doVarsM2 (decl_node__opaque n)
{
- decl_node m;
+ decl_node__opaque m;
outText (doP, (const char *) "VAR\\n", 5);
doVarM2 (n);
doTypeNameM2 -
*/
-static void doTypeNameM2 (mcPretty_pretty p, decl_node n)
+static void doTypeNameM2 (mcPretty_pretty p, decl_node__opaque n)
{
doNameM2 (p, n);
}
doParamM2 -
*/
-static void doParamM2 (mcPretty_pretty p, decl_node n)
+static void doParamM2 (mcPretty_pretty p, decl_node__opaque n)
{
- decl_node ptype;
+ decl_node__opaque ptype;
nameKey_Name i;
unsigned int c;
unsigned int t;
wlists_wlist l;
- mcDebug_assert (decl_isParam (n));
- ptype = decl_getType (n);
+ mcDebug_assert (decl_isParam (static_cast<decl_node> (n)));
+ ptype = static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (n)));
if (n->paramF.namelist == NULL)
{
doTypeNameM2 (p, ptype);
doVarParamM2 -
*/
-static void doVarParamM2 (mcPretty_pretty p, decl_node n)
+static void doVarParamM2 (mcPretty_pretty p, decl_node__opaque n)
{
- decl_node ptype;
+ decl_node__opaque ptype;
nameKey_Name i;
unsigned int c;
unsigned int t;
wlists_wlist l;
- mcDebug_assert (decl_isVarParam (n));
+ mcDebug_assert (decl_isVarParam (static_cast<decl_node> (n)));
outText (p, (const char *) "VAR", 3);
mcPretty_setNeedSpace (p);
- ptype = decl_getType (n);
+ ptype = static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (n)));
if (n->varparamF.namelist == NULL)
{
doTypeNameM2 (p, ptype);
doParameterM2 -
*/
-static void doParameterM2 (mcPretty_pretty p, decl_node n)
+static void doParameterM2 (mcPretty_pretty p, decl_node__opaque n)
{
- if (decl_isParam (n))
+ if (decl_isParam (static_cast<decl_node> (n)))
{
doParamM2 (p, n);
}
- else if (decl_isVarParam (n))
+ else if (decl_isVarParam (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
doVarParamM2 (p, n);
}
- else if (decl_isVarargs (n))
+ else if (decl_isVarargs (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
mcPretty_print (p, (const char *) "...", 3);
doPrototypeM2 -
*/
-static void doPrototypeM2 (decl_node n)
+static void doPrototypeM2 (decl_node__opaque n)
{
unsigned int i;
unsigned int h;
- decl_node p;
+ decl_node__opaque p;
- mcDebug_assert (decl_isProcedure (n));
+ mcDebug_assert (decl_isProcedure (static_cast<decl_node> (n)));
mcPretty_noSpace (doP);
doNameM2 (doP, n);
mcPretty_setNeedSpace (doP);
h = Indexing_HighIndice (n->procedureF.parameters);
while (i <= h)
{
- p = static_cast<decl_node> (Indexing_GetIndice (n->procedureF.parameters, i));
+ p = static_cast<decl_node__opaque> (Indexing_GetIndice (n->procedureF.parameters, i));
doParameterM2 (doP, p);
mcPretty_noSpace (doP);
if (i < h)
when trying to complete partial to full.
*/
-static void outputPartialM2 (decl_node n)
+static void outputPartialM2 (decl_node__opaque n)
{
- decl_node q;
+ decl_node__opaque q;
- q = decl_getType (n);
- if (decl_isRecord (q))
+ q = static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (n)));
+ if (decl_isRecord (static_cast<decl_node> (q)))
{
doTypeM2 (doP, n);
}
- else if (decl_isArray (q))
+ else if (decl_isArray (static_cast<decl_node> (q)))
{
/* avoid dangling else. */
doTypeM2 (doP, n);
}
- else if (decl_isProcType (q))
+ else if (decl_isProcType (static_cast<decl_node> (q)))
{
/* avoid dangling else. */
doTypeM2 (doP, n);
outDefM2 -
*/
-static void outDefM2 (mcPretty_pretty p, decl_node n)
+static void outDefM2 (mcPretty_pretty p, decl_node__opaque n)
{
DynamicStrings_String s;
- s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSource (n)));
+ s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSource (static_cast<decl_node> (n))));
mcPretty_print (p, (const char *) "(* automatically created by mc from ", 36);
mcPretty_prints (p, s);
mcPretty_print (p, (const char *) ". *)\\n\\n", 9);
s = DynamicStrings_KillString (s);
- s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (n)));
+ s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (static_cast<decl_node> (n))));
mcPretty_print (p, (const char *) "DEFINITION MODULE ", 18);
mcPretty_prints (p, s);
mcPretty_print (p, (const char *) " ;\\n\\n", 6);
outImpM2 -
*/
-static void outImpM2 (mcPretty_pretty p, decl_node n)
+static void outImpM2 (mcPretty_pretty p, decl_node__opaque n)
{
DynamicStrings_String s;
- s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSource (n)));
+ s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSource (static_cast<decl_node> (n))));
mcPretty_print (p, (const char *) "(* automatically created by mc from ", 36);
mcPretty_prints (p, s);
mcPretty_print (p, (const char *) ". *)\\n\\n", 9);
outModuleM2 -
*/
-static void outModuleM2 (mcPretty_pretty p, decl_node n)
+static void outModuleM2 (mcPretty_pretty p, decl_node__opaque n)
{
}
outM2 -
*/
-static void outM2 (mcPretty_pretty p, decl_node n)
+static void outM2 (mcPretty_pretty p, decl_node__opaque n)
{
- if (decl_isDef (n))
+ if (decl_isDef (static_cast<decl_node> (n)))
{
outDefM2 (p, n);
}
- else if (decl_isImp (n))
+ else if (decl_isImp (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
outImpM2 (p, n);
}
- else if (decl_isModule (n))
+ else if (decl_isModule (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
outModuleM2 (p, n);
addDone - adds node, n, to the doneQ.
*/
-static void addDone (decl_node n)
+static void addDone (decl_node__opaque n)
{
+ DynamicStrings_String s;
+
alists_includeItemIntoList (globalGroup->doneQ, reinterpret_cast<void *> (n));
+ if ((decl_isVar (static_cast<decl_node> (n))) || (decl_isParameter (static_cast<decl_node> (n))))
+ {
+ initNodeOpaqueState (n);
+ }
+ debugLists ();
}
it is not an opaque of the main module we are compiling.
*/
-static void addDoneDef (decl_node n)
+static void addDoneDef (decl_node__opaque n)
{
- if (decl_isDef (n))
+ if (decl_isDef (static_cast<decl_node> (n)))
{
addDone (n);
- return ;
+ return;
}
- if (false && ((decl_lookupImp (decl_getSymName (decl_getScope (n)))) == (decl_getMainModule ())))
+ if (false && ((decl_lookupImp (decl_getSymName (decl_getScope (static_cast<decl_node> (n))))) == (decl_getMainModule ())))
{
mcMetaError_metaError1 ((const char *) "cyclic dependancy found between another module using {%1ad} from the definition module of the implementation main being compiled, use the --extended-opaque option to compile", 173, (const unsigned char *) &n, (sizeof (n)-1));
mcError_flushErrors ();
mcError_errorAbort0 ((const char *) "terminating compilation", 23);
}
+ else if ((decl_isType (static_cast<decl_node> (n))) && (isDeclInImp (n)))
+ {
+ /* avoid dangling else. */
+ }
else
{
+ /* avoid dangling else. */
+ /* Ignore an opaque type which is declared in this implementation module as it
+ will be fully declared in C/C++ with the __opaque postfix. Whereas the
+ void * non prefixed typedef will be declared in the .h file. */
addDone (n);
}
}
dbgAdd -
*/
-static decl_node dbgAdd (alists_alist l, decl_node n)
+static decl_node__opaque dbgAdd (alists_alist l, decl_node__opaque n)
{
if (n != NULL)
{
dbgType -
*/
-static void dbgType (alists_alist l, decl_node n)
+static void dbgType (alists_alist l, decl_node__opaque n)
{
- decl_node t;
+ decl_node__opaque t;
- t = dbgAdd (l, decl_getType (n));
+ t = dbgAdd (l, static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (n))));
out1 ((const char *) "<%s type", 8, n);
if (t == NULL)
{
dbgPointer -
*/
-static void dbgPointer (alists_alist l, decl_node n)
+static void dbgPointer (alists_alist l, decl_node__opaque n)
{
- decl_node t;
+ decl_node__opaque t;
- t = dbgAdd (l, decl_getType (n));
+ t = dbgAdd (l, static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (n))));
out1 ((const char *) "<%s pointer", 11, n);
out1 ((const char *) " to %s>\\n", 9, t);
}
dbgRecord -
*/
-static void dbgRecord (alists_alist l, decl_node n)
+static void dbgRecord (alists_alist l, decl_node__opaque n)
{
unsigned int i;
unsigned int t;
- decl_node q;
+ decl_node__opaque q;
out1 ((const char *) "<%s record:\\n", 13, n);
i = Indexing_LowIndice (n->recordF.listOfSons);
t = Indexing_HighIndice (n->recordF.listOfSons);
while (i <= t)
{
- q = static_cast<decl_node> (Indexing_GetIndice (n->recordF.listOfSons, i));
- if (decl_isRecordField (q))
+ q = static_cast<decl_node__opaque> (Indexing_GetIndice (n->recordF.listOfSons, i));
+ if (decl_isRecordField (static_cast<decl_node> (q)))
{
out1 ((const char *) " <recordfield %s", 16, q);
}
- else if (decl_isVarientField (q))
+ else if (decl_isVarientField (static_cast<decl_node> (q)))
{
/* avoid dangling else. */
out1 ((const char *) " <varientfield %s", 17, q);
}
- else if (decl_isVarient (q))
+ else if (decl_isVarient (static_cast<decl_node> (q)))
{
/* avoid dangling else. */
out1 ((const char *) " <varient %s", 12, q);
M2RTS_HALT (-1);
__builtin_unreachable ();
}
- q = dbgAdd (l, decl_getType (q));
+ q = dbgAdd (l, static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (q))));
out1 ((const char *) ": %s>\\n", 7, q);
i += 1;
}
dbgVarient -
*/
-static void dbgVarient (alists_alist l, decl_node n)
+static void dbgVarient (alists_alist l, decl_node__opaque n)
{
unsigned int i;
unsigned int t;
- decl_node q;
+ decl_node__opaque q;
out1 ((const char *) "<%s varient: ", 13, n);
out1 ((const char *) "tag %s", 6, n->varientF.tag);
- q = decl_getType (n->varientF.tag);
+ q = static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (n->varientF.tag)));
if (q == NULL)
{
outText (doP, (const char *) "\\n", 2);
t = Indexing_HighIndice (n->varientF.listOfSons);
while (i <= t)
{
- q = static_cast<decl_node> (Indexing_GetIndice (n->varientF.listOfSons, i));
- if (decl_isRecordField (q))
+ q = static_cast<decl_node__opaque> (Indexing_GetIndice (n->varientF.listOfSons, i));
+ if (decl_isRecordField (static_cast<decl_node> (q)))
{
out1 ((const char *) " <recordfield %s", 16, q);
}
- else if (decl_isVarientField (q))
+ else if (decl_isVarientField (static_cast<decl_node> (q)))
{
/* avoid dangling else. */
out1 ((const char *) " <varientfield %s", 17, q);
}
- else if (decl_isVarient (q))
+ else if (decl_isVarient (static_cast<decl_node> (q)))
{
/* avoid dangling else. */
out1 ((const char *) " <varient %s", 12, q);
M2RTS_HALT (-1);
__builtin_unreachable ();
}
- q = dbgAdd (l, decl_getType (q));
+ q = dbgAdd (l, static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (q))));
out1 ((const char *) ": %s>\\n", 7, q);
i += 1;
}
dbgEnumeration -
*/
-static void dbgEnumeration (alists_alist l, decl_node n)
+static void dbgEnumeration (alists_alist l, decl_node__opaque n)
{
- decl_node e;
+ decl_node__opaque e;
unsigned int i;
unsigned int h;
h = Indexing_HighIndice (n->enumerationF.listOfSons);
while (i <= h)
{
- e = static_cast<decl_node> (Indexing_GetIndice (n->enumerationF.listOfSons, i));
+ e = static_cast<decl_node__opaque> (Indexing_GetIndice (n->enumerationF.listOfSons, i));
out1 ((const char *) "%s, ", 4, e);
i += 1;
}
dbgVar -
*/
-static void dbgVar (alists_alist l, decl_node n)
+static void dbgVar (alists_alist l, decl_node__opaque n)
{
- decl_node t;
+ decl_node__opaque t;
- t = dbgAdd (l, decl_getType (n));
+ t = dbgAdd (l, static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (n))));
out1 ((const char *) "<%s var", 7, n);
out1 ((const char *) ", type = %s>\\n", 14, t);
}
dbgSubrange -
*/
-static void dbgSubrange (alists_alist l, decl_node n)
+static void dbgSubrange (alists_alist l, decl_node__opaque n)
{
if (n->subrangeF.low == NULL)
{
dbgArray -
*/
-static void dbgArray (alists_alist l, decl_node n)
+static void dbgArray (alists_alist l, decl_node__opaque n)
{
- decl_node t;
+ decl_node__opaque t;
- t = dbgAdd (l, decl_getType (n));
+ t = dbgAdd (l, static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (n))));
out1 ((const char *) "<%s array ", 10, n);
if (n->arrayF.subr != NULL)
{
doDbg -
*/
-static void doDbg (alists_alist l, decl_node n)
+static void doDbg (alists_alist l, decl_node__opaque n)
{
if (n == NULL)
{} /* empty. */
- else if (decl_isSubrange (n))
+ else if (decl_isSubrange (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
dbgSubrange (l, n);
}
- else if (decl_isType (n))
+ else if (decl_isType (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
dbgType (l, n);
}
- else if (decl_isRecord (n))
+ else if (decl_isRecord (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
dbgRecord (l, n);
}
- else if (decl_isVarient (n))
+ else if (decl_isVarient (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
dbgVarient (l, n);
}
- else if (decl_isEnumeration (n))
+ else if (decl_isEnumeration (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
dbgEnumeration (l, n);
}
- else if (decl_isPointer (n))
+ else if (decl_isPointer (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
dbgPointer (l, n);
}
- else if (decl_isArray (n))
+ else if (decl_isArray (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
dbgArray (l, n);
}
- else if (decl_isVar (n))
+ else if (decl_isVar (static_cast<decl_node> (n)))
{
/* avoid dangling else. */
dbgVar (l, n);
dbg -
*/
-static void dbg (decl_node n)
+static void dbg (const char *listName_, unsigned int _listName_high, const char *symName_, unsigned int _symName_high, decl_node__opaque n)
{
alists_alist l;
mcPretty_pretty o;
FIO_File f;
DynamicStrings_String s;
unsigned int i;
+ char listName[_listName_high+1];
+ char symName[_symName_high+1];
+
+ /* make a local copy of each unbounded array. */
+ memcpy (listName, listName_, _listName_high+1);
+ memcpy (symName, symName_, _symName_high+1);
o = doP;
f = outputFile;
l = alists_initList ();
alists_includeItemIntoList (l, reinterpret_cast<void *> (n));
i = 1;
- out1 ((const char *) "dbg (%s)\\n", 10, n);
do {
- n = static_cast<decl_node> (alists_getItemFromList (l, i));
- doDbg (l, n);
+ n = static_cast<decl_node__opaque> (alists_getItemFromList (l, i));
+ if (decl_isType (static_cast<decl_node> (n)))
+ {
+ s = getFQstring (n);
+ if (DynamicStrings_EqualArray (s, (const char *) symName, _symName_high))
+ {
+ out0 ((const char *) "list ", 5);
+ out0 ((const char *) listName, _listName_high);
+ out0 ((const char *) ": ", 2);
+ doDbg (l, n);
+ }
+ s = DynamicStrings_KillString (s);
+ }
i += 1;
} while (! (i > (alists_noOfItemsInList (l))));
doP = o;
nodes.
*/
-static void addGenericBody (decl_node n, decl_node c)
+static void addGenericBody (decl_node__opaque n, decl_node__opaque c)
{
switch (n->kind)
{
nodes.
*/
-static void addGenericAfter (decl_node n, decl_node c)
+static void addGenericAfter (decl_node__opaque n, decl_node__opaque c)
{
switch (n->kind)
{
isAssignment -
*/
-static bool isAssignment (decl_node n)
+static bool isAssignment (decl_node__opaque n)
{
return n->kind == decl_assignment;
/* static analysis guarentees a RETURN statement will be used before here. */
isComment - returns TRUE if node, n, is a comment.
*/
-static bool isComment (decl_node n)
+static bool isComment (decl_node__opaque n)
{
mcDebug_assert (n != NULL);
return n->kind == decl_comment;
static void initPair (decl_commentPair *c)
{
- (*c).after = NULL;
- (*c).body = NULL;
+ (*c).after = static_cast<decl_node__opaque> (NULL);
+ (*c).body = static_cast<decl_node__opaque> (NULL);
}
dupExplist -
*/
-static decl_node dupExplist (decl_node n)
+static decl_node__opaque dupExplist (decl_node__opaque n)
{
- decl_node m;
+ decl_node__opaque m;
unsigned int i;
- mcDebug_assert (decl_isExpList (n));
- m = decl_makeExpList ();
+ mcDebug_assert (decl_isExpList (static_cast<decl_node> (n)));
+ m = static_cast<decl_node__opaque> (decl_makeExpList ());
i = Indexing_LowIndice (n->explistF.exp);
while (i <= (Indexing_HighIndice (n->explistF.exp)))
{
- decl_putExpList (m, decl_dupExpr (reinterpret_cast<decl_node> (Indexing_GetIndice (n->explistF.exp, i))));
+ decl_putExpList (static_cast<decl_node> (m), decl_dupExpr (static_cast<decl_node> (Indexing_GetIndice (n->explistF.exp, i))));
i += 1;
}
return m;
dupArrayref -
*/
-static decl_node dupArrayref (decl_node n)
+static decl_node__opaque dupArrayref (decl_node__opaque n)
{
mcDebug_assert (isArrayRef (n));
- return decl_makeArrayRef (decl_dupExpr (n->arrayrefF.array), decl_dupExpr (n->arrayrefF.index));
+ return static_cast<decl_node__opaque> (decl_makeArrayRef (decl_dupExpr (static_cast<decl_node> (n->arrayrefF.array)), decl_dupExpr (static_cast<decl_node> (n->arrayrefF.index))));
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
dupPointerref -
*/
-static decl_node dupPointerref (decl_node n)
+static decl_node__opaque dupPointerref (decl_node__opaque n)
{
- mcDebug_assert (decl_isPointerRef (n));
- return decl_makePointerRef (decl_dupExpr (n->pointerrefF.ptr), decl_dupExpr (n->pointerrefF.field));
+ mcDebug_assert (decl_isPointerRef (static_cast<decl_node> (n)));
+ return static_cast<decl_node__opaque> (decl_makePointerRef (decl_dupExpr (static_cast<decl_node> (n->pointerrefF.ptr)), decl_dupExpr (static_cast<decl_node> (n->pointerrefF.field))));
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
dupComponentref -
*/
-static decl_node dupComponentref (decl_node n)
+static decl_node__opaque dupComponentref (decl_node__opaque n)
{
mcDebug_assert (isComponentRef (n));
- return doMakeComponentRef (decl_dupExpr (n->componentrefF.rec), decl_dupExpr (n->componentrefF.field));
+ return doMakeComponentRef (static_cast<decl_node__opaque> (decl_dupExpr (static_cast<decl_node> (n->componentrefF.rec))), static_cast<decl_node__opaque> (decl_dupExpr (static_cast<decl_node> (n->componentrefF.field))));
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
dupBinary -
*/
-static decl_node dupBinary (decl_node n)
+static decl_node__opaque dupBinary (decl_node__opaque n)
{
/* assert (isBinary (n)) ; */
- return makeBinary (n->kind, decl_dupExpr (n->binaryF.left), decl_dupExpr (n->binaryF.right), n->binaryF.resultType);
+ return makeBinary (n->kind, static_cast<decl_node__opaque> (decl_dupExpr (static_cast<decl_node> (n->binaryF.left))), static_cast<decl_node__opaque> (decl_dupExpr (static_cast<decl_node> (n->binaryF.right))), n->binaryF.resultType);
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
dupUnary -
*/
-static decl_node dupUnary (decl_node n)
+static decl_node__opaque dupUnary (decl_node__opaque n)
{
/* assert (isUnary (n)) ; */
- return makeUnary (n->kind, decl_dupExpr (n->unaryF.arg), n->unaryF.resultType);
+ return makeUnary (n->kind, static_cast<decl_node__opaque> (decl_dupExpr (static_cast<decl_node> (n->unaryF.arg))), n->unaryF.resultType);
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
dupFunccall -
*/
-static decl_node dupFunccall (decl_node n)
+static decl_node__opaque dupFunccall (decl_node__opaque n)
{
- decl_node m;
+ decl_node__opaque m;
mcDebug_assert (isFuncCall (n));
- m = decl_makeFuncCall (decl_dupExpr (n->funccallF.function), decl_dupExpr (n->funccallF.args));
+ m = static_cast<decl_node__opaque> (decl_makeFuncCall (decl_dupExpr (static_cast<decl_node> (n->funccallF.function)), decl_dupExpr (static_cast<decl_node> (n->funccallF.args))));
m->funccallF.type = n->funccallF.type;
+ assignNodeOpaqueCastState (m, n);
return m;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
dupSetValue -
*/
-static decl_node dupSetValue (decl_node n)
+static decl_node__opaque dupSetValue (decl_node__opaque n)
{
- decl_node m;
+ decl_node__opaque m;
unsigned int i;
m = newNode (decl_setvalue);
i = Indexing_LowIndice (n->setvalueF.values);
while (i <= (Indexing_HighIndice (n->setvalueF.values)))
{
- m = decl_putSetValue (m, decl_dupExpr (reinterpret_cast<decl_node> (Indexing_GetIndice (n->setvalueF.values, i))));
+ m = static_cast<decl_node__opaque> (decl_putSetValue (static_cast<decl_node> (m), decl_dupExpr (static_cast<decl_node> (Indexing_GetIndice (n->setvalueF.values, i)))));
i += 1;
}
return m;
doDupExpr -
*/
-static decl_node doDupExpr (decl_node n)
+static decl_node__opaque doDupExpr (decl_node__opaque n)
{
mcDebug_assert (n != NULL);
switch (n->kind)
static void makeSystem (void)
{
- systemN = decl_lookupDef (nameKey_makeKey ((const char *) "SYSTEM", 6));
+ systemN = static_cast<decl_node__opaque> (decl_lookupDef (nameKey_makeKey ((const char *) "SYSTEM", 6)));
addressN = makeBase (decl_address);
locN = makeBase (decl_loc);
byteN = makeBase (decl_byte);
adrN = makeBase (decl_adr);
tsizeN = makeBase (decl_tsize);
throwN = makeBase (decl_throw);
- decl_enterScope (systemN);
+ decl_enterScope (static_cast<decl_node> (systemN));
addressN = addToScope (addressN);
locN = addToScope (locN);
byteN = addToScope (byteN);
static void makeM2rts (void)
{
- m2rtsN = decl_lookupDef (nameKey_makeKey ((const char *) "M2RTS", 5));
+ m2rtsN = static_cast<decl_node__opaque> (decl_lookupDef (nameKey_makeKey ((const char *) "M2RTS", 5)));
}
makeBitnum -
*/
-static decl_node makeBitnum (void)
+static decl_node__opaque makeBitnum (void)
{
- decl_node b;
+ decl_node__opaque b;
b = newNode (decl_subrange);
- b->subrangeF.type = NULL;
- b->subrangeF.scope = NULL;
+ b->subrangeF.type = static_cast<decl_node__opaque> (NULL);
+ b->subrangeF.scope = static_cast<decl_node__opaque> (NULL);
b->subrangeF.low = lookupConst (b, nameKey_makeKey ((const char *) "0", 1));
b->subrangeF.high = lookupConst (b, nameKey_makeKey ((const char *) "31", 2));
return b;
static void makeBuiltins (void)
{
- bitsperunitN = decl_makeLiteralInt (nameKey_makeKey ((const char *) "8", 1));
- bitsperwordN = decl_makeLiteralInt (nameKey_makeKey ((const char *) "32", 2));
- bitspercharN = decl_makeLiteralInt (nameKey_makeKey ((const char *) "8", 1));
- unitsperwordN = decl_makeLiteralInt (nameKey_makeKey ((const char *) "4", 1));
+ bitsperunitN = static_cast<decl_node__opaque> (decl_makeLiteralInt (nameKey_makeKey ((const char *) "8", 1)));
+ bitsperwordN = static_cast<decl_node__opaque> (decl_makeLiteralInt (nameKey_makeKey ((const char *) "32", 2)));
+ bitspercharN = static_cast<decl_node__opaque> (decl_makeLiteralInt (nameKey_makeKey ((const char *) "8", 1)));
+ unitsperwordN = static_cast<decl_node__opaque> (decl_makeLiteralInt (nameKey_makeKey ((const char *) "4", 1)));
addDone (bitsperunitN);
addDone (bitsperwordN);
addDone (bitspercharN);
extern "C" unsigned int decl_getDeclaredMod (decl_node n)
{
- return n->at.modDeclared;
+ return static_cast<decl_node__opaque> (n)->at.modDeclared;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" unsigned int decl_getDeclaredDef (decl_node n)
{
- return n->at.defDeclared;
+ return static_cast<decl_node__opaque> (n)->at.defDeclared;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" unsigned int decl_getFirstUsed (decl_node n)
{
- return n->at.firstUsed;
+ return static_cast<decl_node__opaque> (n)->at.firstUsed;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" bool decl_isDef (decl_node n)
{
mcDebug_assert (n != NULL);
- return n->kind == decl_def;
+ return static_cast<decl_node__opaque> (n)->kind == decl_def;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" bool decl_isImp (decl_node n)
{
mcDebug_assert (n != NULL);
- return n->kind == decl_imp;
+ return static_cast<decl_node__opaque> (n)->kind == decl_imp;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" bool decl_isVisited (decl_node n)
{
- switch (n->kind)
+ switch (static_cast<decl_node__opaque> (n)->kind)
{
case decl_def:
- return n->defF.visited;
+ return static_cast<decl_node__opaque> (n)->defF.visited;
break;
case decl_imp:
- return n->impF.visited;
+ return static_cast<decl_node__opaque> (n)->impF.visited;
break;
case decl_module:
- return n->moduleF.visited;
+ return static_cast<decl_node__opaque> (n)->moduleF.visited;
break;
extern "C" void decl_unsetVisited (decl_node n)
{
- switch (n->kind)
+ switch (static_cast<decl_node__opaque> (n)->kind)
{
case decl_def:
- n->defF.visited = false;
+ static_cast<decl_node__opaque> (n)->defF.visited = false;
break;
case decl_imp:
- n->impF.visited = false;
+ static_cast<decl_node__opaque> (n)->impF.visited = false;
break;
case decl_module:
- n->moduleF.visited = false;
+ static_cast<decl_node__opaque> (n)->moduleF.visited = false;
break;
extern "C" void decl_setVisited (decl_node n)
{
- switch (n->kind)
+ switch (static_cast<decl_node__opaque> (n)->kind)
{
case decl_def:
- n->defF.visited = true;
+ static_cast<decl_node__opaque> (n)->defF.visited = true;
break;
case decl_imp:
- n->impF.visited = true;
+ static_cast<decl_node__opaque> (n)->impF.visited = true;
break;
case decl_module:
- n->moduleF.visited = true;
+ static_cast<decl_node__opaque> (n)->moduleF.visited = true;
break;
extern "C" void decl_setEnumsComplete (decl_node n)
{
- switch (n->kind)
+ switch (static_cast<decl_node__opaque> (n)->kind)
{
case decl_def:
- n->defF.enumsComplete = true;
+ static_cast<decl_node__opaque> (n)->defF.enumsComplete = true;
break;
case decl_imp:
- n->impF.enumsComplete = true;
+ static_cast<decl_node__opaque> (n)->impF.enumsComplete = true;
break;
case decl_module:
- n->moduleF.enumsComplete = true;
+ static_cast<decl_node__opaque> (n)->moduleF.enumsComplete = true;
break;
extern "C" bool decl_getEnumsComplete (decl_node n)
{
- switch (n->kind)
+ switch (static_cast<decl_node__opaque> (n)->kind)
{
case decl_def:
- return n->defF.enumsComplete;
+ return static_cast<decl_node__opaque> (n)->defF.enumsComplete;
break;
case decl_imp:
- return n->impF.enumsComplete;
+ return static_cast<decl_node__opaque> (n)->impF.enumsComplete;
break;
case decl_module:
- return n->moduleF.enumsComplete;
+ return static_cast<decl_node__opaque> (n)->moduleF.enumsComplete;
break;
mcDebug_assert (((decl_isDef (n)) || (decl_isImp (n))) || (decl_isModule (n)));
if (decl_isDef (n))
{
- n->defF.enumFixup.count = 0;
+ static_cast<decl_node__opaque> (n)->defF.enumFixup.count = 0;
}
else if (decl_isImp (n))
{
/* avoid dangling else. */
- n->impF.enumFixup.count = 0;
+ static_cast<decl_node__opaque> (n)->impF.enumFixup.count = 0;
}
else if (decl_isModule (n))
{
/* avoid dangling else. */
- n->moduleF.enumFixup.count = 0;
+ static_cast<decl_node__opaque> (n)->moduleF.enumFixup.count = 0;
}
}
extern "C" decl_node decl_getNextEnum (void)
{
- decl_node n;
+ decl_node__opaque n;
- n = NULL;
- mcDebug_assert (((decl_isDef (currentModule)) || (decl_isImp (currentModule))) || (decl_isModule (currentModule)));
- if (decl_isDef (currentModule))
+ n = static_cast<decl_node__opaque> (NULL);
+ mcDebug_assert (((decl_isDef (static_cast<decl_node> (currentModule))) || (decl_isImp (static_cast<decl_node> (currentModule)))) || (decl_isModule (static_cast<decl_node> (currentModule))));
+ if (decl_isDef (static_cast<decl_node> (currentModule)))
{
n = getNextFixup (¤tModule->defF.enumFixup);
}
- else if (decl_isImp (currentModule))
+ else if (decl_isImp (static_cast<decl_node> (currentModule)))
{
/* avoid dangling else. */
n = getNextFixup (¤tModule->impF.enumFixup);
}
- else if (decl_isModule (currentModule))
+ else if (decl_isModule (static_cast<decl_node> (currentModule)))
{
/* avoid dangling else. */
n = getNextFixup (¤tModule->moduleF.enumFixup);
}
mcDebug_assert (n != NULL);
- mcDebug_assert ((decl_isEnumeration (n)) || (decl_isEnumerationField (n)));
- return n;
+ mcDebug_assert ((decl_isEnumeration (static_cast<decl_node> (n))) || (decl_isEnumerationField (static_cast<decl_node> (n))));
+ return static_cast<decl_node> (n);
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" bool decl_isModule (decl_node n)
{
mcDebug_assert (n != NULL);
- return n->kind == decl_module;
+ return static_cast<decl_node__opaque> (n)->kind == decl_module;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" void decl_setMainModule (decl_node n)
{
mcDebug_assert (n != NULL);
- mainModule = n;
+ mainModule = static_cast<decl_node__opaque> (n);
}
extern "C" void decl_setCurrentModule (decl_node n)
{
mcDebug_assert (n != NULL);
- currentModule = n;
+ currentModule = static_cast<decl_node__opaque> (n);
}
extern "C" decl_node decl_lookupDef (nameKey_Name n)
{
- decl_node d;
+ decl_node__opaque d;
- d = static_cast<decl_node> (symbolKey_getSymKey (defUniverse, n));
+ d = static_cast<decl_node__opaque> (symbolKey_getSymKey (defUniverse, n));
if (d == NULL)
{
d = makeDef (n);
symbolKey_putSymKey (defUniverse, n, reinterpret_cast<void *> (d));
Indexing_IncludeIndiceIntoIndex (defUniverseI, reinterpret_cast<void *> (d));
}
- return d;
+ return static_cast<decl_node> (d);
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" decl_node decl_lookupImp (nameKey_Name n)
{
- decl_node m;
+ decl_node__opaque m;
- m = static_cast<decl_node> (symbolKey_getSymKey (modUniverse, n));
+ m = static_cast<decl_node__opaque> (symbolKey_getSymKey (modUniverse, n));
if (m == NULL)
{
m = makeImp (n);
symbolKey_putSymKey (modUniverse, n, reinterpret_cast<void *> (m));
Indexing_IncludeIndiceIntoIndex (modUniverseI, reinterpret_cast<void *> (m));
}
- mcDebug_assert (! (decl_isModule (m)));
- return m;
+ mcDebug_assert (! (decl_isModule (static_cast<decl_node> (m))));
+ return static_cast<decl_node> (m);
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" decl_node decl_lookupModule (nameKey_Name n)
{
- decl_node m;
+ decl_node__opaque m;
- m = static_cast<decl_node> (symbolKey_getSymKey (modUniverse, n));
+ m = static_cast<decl_node__opaque> (symbolKey_getSymKey (modUniverse, n));
if (m == NULL)
{
m = makeModule (n);
symbolKey_putSymKey (modUniverse, n, reinterpret_cast<void *> (m));
Indexing_IncludeIndiceIntoIndex (modUniverseI, reinterpret_cast<void *> (m));
}
- mcDebug_assert (! (decl_isImp (m)));
- return m;
+ mcDebug_assert (! (decl_isImp (static_cast<decl_node> (m))));
+ return static_cast<decl_node> (m);
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" void decl_putDefForC (decl_node n)
{
mcDebug_assert (decl_isDef (n));
- n->defF.forC = true;
+ static_cast<decl_node__opaque> (n)->defF.forC = true;
}
extern "C" decl_node decl_lookupInScope (decl_node scope, nameKey_Name n)
{
- switch (scope->kind)
+ switch (static_cast<decl_node__opaque> (scope)->kind)
{
case decl_def:
- return static_cast<decl_node> (symbolKey_getSymKey (scope->defF.decls.symbols, n));
+ return static_cast<decl_node> (symbolKey_getSymKey (static_cast<decl_node__opaque> (scope)->defF.decls.symbols, n));
break;
case decl_module:
- return static_cast<decl_node> (symbolKey_getSymKey (scope->moduleF.decls.symbols, n));
+ return static_cast<decl_node> (symbolKey_getSymKey (static_cast<decl_node__opaque> (scope)->moduleF.decls.symbols, n));
break;
case decl_imp:
- return static_cast<decl_node> (symbolKey_getSymKey (scope->impF.decls.symbols, n));
+ return static_cast<decl_node> (symbolKey_getSymKey (static_cast<decl_node__opaque> (scope)->impF.decls.symbols, n));
break;
case decl_procedure:
- return static_cast<decl_node> (symbolKey_getSymKey (scope->procedureF.decls.symbols, n));
+ return static_cast<decl_node> (symbolKey_getSymKey (static_cast<decl_node__opaque> (scope)->procedureF.decls.symbols, n));
break;
case decl_record:
- return static_cast<decl_node> (symbolKey_getSymKey (scope->recordF.localSymbols, n));
+ return static_cast<decl_node> (symbolKey_getSymKey (static_cast<decl_node__opaque> (scope)->recordF.localSymbols, n));
break;
extern "C" bool decl_isConst (decl_node n)
{
mcDebug_assert (n != NULL);
- return n->kind == decl_const;
+ return static_cast<decl_node__opaque> (n)->kind == decl_const;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" bool decl_isType (decl_node n)
{
mcDebug_assert (n != NULL);
- return n->kind == decl_type;
+ return static_cast<decl_node__opaque> (n)->kind == decl_type;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
{
mcDebug_assert (des != NULL);
mcDebug_assert (decl_isType (des));
- des->typeF.type = exp;
+ static_cast<decl_node__opaque> (des)->typeF.type = static_cast<decl_node__opaque> (exp);
}
extern "C" decl_node decl_getType (decl_node n)
{
- switch (n->kind)
+ switch (static_cast<decl_node__opaque> (n)->kind)
{
case decl_new:
case decl_dispose:
- return NULL;
+ return static_cast<decl_node> (NULL);
break;
case decl_length:
- return cardinalN;
+ return static_cast<decl_node> (cardinalN);
break;
case decl_inc:
case decl_dec:
case decl_incl:
case decl_excl:
- return NULL;
+ return static_cast<decl_node> (NULL);
break;
case decl_nil:
- return addressN;
+ return static_cast<decl_node> (addressN);
break;
case decl_true:
case decl_false:
- return booleanN;
+ return static_cast<decl_node> (booleanN);
break;
case decl_address:
case decl_type:
/* language features and compound type attributes. */
- return n->typeF.type;
+ return static_cast<decl_node> (static_cast<decl_node__opaque> (n)->typeF.type);
break;
case decl_record:
break;
case decl_var:
- return n->varF.type;
+ return static_cast<decl_node> (static_cast<decl_node__opaque> (n)->varF.type);
break;
case decl_enumeration:
break;
case decl_subrange:
- return n->subrangeF.type;
+ return static_cast<decl_node> (static_cast<decl_node__opaque> (n)->subrangeF.type);
break;
case decl_array:
- return n->arrayF.type;
+ return static_cast<decl_node> (static_cast<decl_node__opaque> (n)->arrayF.type);
break;
case decl_string:
- return charN;
+ return static_cast<decl_node> (charN);
break;
case decl_const:
- return n->constF.type;
+ return static_cast<decl_node> (static_cast<decl_node__opaque> (n)->constF.type);
break;
case decl_literal:
- return n->literalF.type;
+ return static_cast<decl_node> (static_cast<decl_node__opaque> (n)->literalF.type);
break;
case decl_varparam:
- return n->varparamF.type;
+ return static_cast<decl_node> (static_cast<decl_node__opaque> (n)->varparamF.type);
break;
case decl_param:
- return n->paramF.type;
+ return static_cast<decl_node> (static_cast<decl_node__opaque> (n)->paramF.type);
break;
case decl_optarg:
- return n->optargF.type;
+ return static_cast<decl_node> (static_cast<decl_node__opaque> (n)->optargF.type);
break;
case decl_pointer:
- return n->pointerF.type;
+ return static_cast<decl_node> (static_cast<decl_node__opaque> (n)->pointerF.type);
break;
case decl_recordfield:
- return n->recordfieldF.type;
+ return static_cast<decl_node> (static_cast<decl_node__opaque> (n)->recordfieldF.type);
break;
case decl_varientfield:
break;
case decl_enumerationfield:
- return n->enumerationfieldF.type;
+ return static_cast<decl_node> (static_cast<decl_node__opaque> (n)->enumerationfieldF.type);
break;
case decl_set:
- return n->setF.type;
+ return static_cast<decl_node> (static_cast<decl_node__opaque> (n)->setF.type);
break;
case decl_proctype:
- return n->proctypeF.returnType;
+ return static_cast<decl_node> (static_cast<decl_node__opaque> (n)->proctypeF.returnType);
break;
case decl_subscript:
- return n->subscriptF.type;
+ return static_cast<decl_node> (static_cast<decl_node__opaque> (n)->subscriptF.type);
break;
case decl_procedure:
/* blocks. */
- return n->procedureF.returnType;
+ return static_cast<decl_node> (static_cast<decl_node__opaque> (n)->procedureF.returnType);
break;
case decl_throw:
- return NULL;
+ return static_cast<decl_node> (NULL);
break;
case decl_unreachable:
- return NULL;
+ return static_cast<decl_node> (NULL);
break;
case decl_def:
case decl_mult:
case decl_divide:
/* expressions. */
- return n->binaryF.resultType;
+ return static_cast<decl_node> (static_cast<decl_node__opaque> (n)->binaryF.resultType);
break;
case decl_in:
- return booleanN;
+ return static_cast<decl_node> (booleanN);
break;
case decl_max:
case decl_adr:
case decl_size:
case decl_tsize:
- return n->unaryF.resultType;
+ return static_cast<decl_node> (static_cast<decl_node__opaque> (n)->unaryF.resultType);
break;
case decl_and:
case decl_greater:
case decl_greequal:
case decl_lessequal:
- return booleanN;
+ return static_cast<decl_node> (booleanN);
break;
case decl_trunc:
- return integerN;
+ return static_cast<decl_node> (integerN);
break;
case decl_float:
- return realN;
+ return static_cast<decl_node> (realN);
break;
case decl_high:
- return cardinalN;
+ return static_cast<decl_node> (cardinalN);
break;
case decl_ord:
- return cardinalN;
+ return static_cast<decl_node> (cardinalN);
break;
case decl_chr:
- return charN;
+ return static_cast<decl_node> (charN);
break;
case decl_cap:
- return charN;
+ return static_cast<decl_node> (charN);
break;
case decl_arrayref:
- return n->arrayrefF.resultType;
+ return static_cast<decl_node> (static_cast<decl_node__opaque> (n)->arrayrefF.resultType);
break;
case decl_componentref:
- return n->componentrefF.resultType;
+ return static_cast<decl_node> (static_cast<decl_node__opaque> (n)->componentrefF.resultType);
break;
case decl_pointerref:
- return n->pointerrefF.resultType;
+ return static_cast<decl_node> (static_cast<decl_node__opaque> (n)->pointerrefF.resultType);
break;
case decl_funccall:
- return n->funccallF.type;
+ return static_cast<decl_node> (static_cast<decl_node__opaque> (n)->funccallF.type);
break;
case decl_setvalue:
- return n->setvalueF.type;
+ return static_cast<decl_node> (static_cast<decl_node__opaque> (n)->setvalueF.type);
break;
extern "C" void decl_putTypeHidden (decl_node des)
{
- decl_node s;
+ decl_node__opaque s;
mcDebug_assert (des != NULL);
mcDebug_assert (decl_isType (des));
- des->typeF.isHidden = true;
- s = decl_getScope (des);
- mcDebug_assert (decl_isDef (s));
+ static_cast<decl_node__opaque> (des)->typeF.isHidden = true;
+ s = static_cast<decl_node__opaque> (decl_getScope (des));
+ mcDebug_assert (decl_isDef (static_cast<decl_node> (s)));
s->defF.hasHidden = true;
}
{
mcDebug_assert (n != NULL);
mcDebug_assert (decl_isType (n));
- return n->typeF.isHidden;
+ return static_cast<decl_node__opaque> (n)->typeF.isHidden;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" bool decl_hasHidden (decl_node n)
{
mcDebug_assert (decl_isDef (n));
- return n->defF.hasHidden;
+ return static_cast<decl_node__opaque> (n)->defF.hasHidden;
+ /* static analysis guarentees a RETURN statement will be used before here. */
+ __builtin_unreachable ();
+}
+
+
+/*
+ putTypeOpaque - marks type, des, as being an opaque type.
+ TYPE des ;
+*/
+
+extern "C" void decl_putTypeOpaque (decl_node des)
+{
+ decl_node__opaque s;
+
+ mcDebug_assert (des != NULL);
+ mcDebug_assert (decl_isType (des));
+ static_cast<decl_node__opaque> (des)->typeF.isOpaque = true;
+}
+
+
+/*
+ isTypeOpaque - returns TRUE if type, n, is an opaque type.
+*/
+
+extern "C" bool decl_isTypeOpaque (decl_node n)
+{
+ mcDebug_assert (n != NULL);
+ mcDebug_assert (decl_isType (n));
+ return static_cast<decl_node__opaque> (n)->typeF.isOpaque;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" bool decl_isVar (decl_node n)
{
mcDebug_assert (n != NULL);
- return n->kind == decl_var;
+ return static_cast<decl_node__opaque> (n)->kind == decl_var;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" bool decl_isExported (decl_node n)
{
- decl_node s;
+ decl_node__opaque s;
- s = decl_getScope (n);
+ s = static_cast<decl_node__opaque> (decl_getScope (n));
if (s != NULL)
{
switch (s->kind)
extern "C" decl_node decl_getScope (decl_node n)
{
- switch (n->kind)
+ switch (static_cast<decl_node__opaque> (n)->kind)
{
case decl_stmtseq:
case decl_exit:
case decl_nil:
case decl_true:
case decl_false:
- return NULL;
+ return static_cast<decl_node> (NULL);
break;
case decl_address:
case decl_word:
case decl_csizet:
case decl_cssizet:
- return systemN;
+ return static_cast<decl_node> (systemN);
break;
case decl_boolean:
case decl_longcomplex:
case decl_shortcomplex:
/* base types. */
- return NULL;
+ return static_cast<decl_node> (NULL);
break;
case decl_type:
/* language features and compound type attributes. */
- return n->typeF.scope;
+ return static_cast<decl_node> (static_cast<decl_node__opaque> (n)->typeF.scope);
break;
case decl_record:
- return n->recordF.scope;
+ return static_cast<decl_node> (static_cast<decl_node__opaque> (n)->recordF.scope);
break;
case decl_varient:
- return n->varientF.scope;
+ return static_cast<decl_node> (static_cast<decl_node__opaque> (n)->varientF.scope);
break;
case decl_var:
- return n->varF.scope;
+ return static_cast<decl_node> (static_cast<decl_node__opaque> (n)->varF.scope);
break;
case decl_enumeration:
- return n->enumerationF.scope;
+ return static_cast<decl_node> (static_cast<decl_node__opaque> (n)->enumerationF.scope);
break;
case decl_subrange:
- return n->subrangeF.scope;
+ return static_cast<decl_node> (static_cast<decl_node__opaque> (n)->subrangeF.scope);
break;
case decl_array:
- return n->arrayF.scope;
+ return static_cast<decl_node> (static_cast<decl_node__opaque> (n)->arrayF.scope);
break;
case decl_string:
- return NULL;
+ return static_cast<decl_node> (NULL);
break;
case decl_const:
- return n->constF.scope;
+ return static_cast<decl_node> (static_cast<decl_node__opaque> (n)->constF.scope);
break;
case decl_literal:
- return NULL;
+ return static_cast<decl_node> (NULL);
break;
case decl_varparam:
- return n->varparamF.scope;
+ return static_cast<decl_node> (static_cast<decl_node__opaque> (n)->varparamF.scope);
break;
case decl_param:
- return n->paramF.scope;
+ return static_cast<decl_node> (static_cast<decl_node__opaque> (n)->paramF.scope);
break;
case decl_optarg:
- return n->optargF.scope;
+ return static_cast<decl_node> (static_cast<decl_node__opaque> (n)->optargF.scope);
break;
case decl_pointer:
- return n->pointerF.scope;
+ return static_cast<decl_node> (static_cast<decl_node__opaque> (n)->pointerF.scope);
break;
case decl_recordfield:
- return n->recordfieldF.scope;
+ return static_cast<decl_node> (static_cast<decl_node__opaque> (n)->recordfieldF.scope);
break;
case decl_varientfield:
- return n->varientfieldF.scope;
+ return static_cast<decl_node> (static_cast<decl_node__opaque> (n)->varientfieldF.scope);
break;
case decl_enumerationfield:
- return n->enumerationfieldF.scope;
+ return static_cast<decl_node> (static_cast<decl_node__opaque> (n)->enumerationfieldF.scope);
break;
case decl_set:
- return n->setF.scope;
+ return static_cast<decl_node> (static_cast<decl_node__opaque> (n)->setF.scope);
break;
case decl_proctype:
- return n->proctypeF.scope;
+ return static_cast<decl_node> (static_cast<decl_node__opaque> (n)->proctypeF.scope);
break;
case decl_subscript:
- return NULL;
+ return static_cast<decl_node> (NULL);
break;
case decl_procedure:
/* blocks. */
- return n->procedureF.scope;
+ return static_cast<decl_node> (static_cast<decl_node__opaque> (n)->procedureF.scope);
break;
case decl_def:
case decl_elsif:
case decl_assignment:
/* statements. */
- return NULL;
+ return static_cast<decl_node> (NULL);
break;
case decl_componentref:
case decl_divide:
case decl_in:
/* expressions. */
- return NULL;
+ return static_cast<decl_node> (NULL);
break;
case decl_neg:
- return NULL;
+ return static_cast<decl_node> (NULL);
break;
case decl_lsl:
case decl_greater:
case decl_greequal:
case decl_lessequal:
- return NULL;
+ return static_cast<decl_node> (NULL);
break;
case decl_adr:
case decl_size:
case decl_tsize:
case decl_throw:
- return systemN;
+ return static_cast<decl_node> (systemN);
break;
case decl_unreachable:
case decl_im:
case decl_min:
case decl_max:
- return NULL;
+ return static_cast<decl_node> (NULL);
break;
case decl_vardecl:
- return n->vardeclF.scope;
+ return static_cast<decl_node> (static_cast<decl_node__opaque> (n)->vardeclF.scope);
break;
case decl_funccall:
- return NULL;
+ return static_cast<decl_node> (NULL);
break;
case decl_explist:
- return NULL;
+ return static_cast<decl_node> (NULL);
break;
case decl_caselabellist:
- return NULL;
+ return static_cast<decl_node> (NULL);
break;
case decl_caselist:
- return NULL;
+ return static_cast<decl_node> (NULL);
break;
case decl_range:
- return NULL;
+ return static_cast<decl_node> (NULL);
break;
case decl_varargs:
- return n->varargsF.scope;
+ return static_cast<decl_node> (static_cast<decl_node__opaque> (n)->varargsF.scope);
break;
extern "C" bool decl_isLiteral (decl_node n)
{
mcDebug_assert (n != NULL);
- return n->kind == decl_literal;
+ return static_cast<decl_node__opaque> (n)->kind == decl_literal;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" bool decl_isEnumerationField (decl_node n)
{
mcDebug_assert (n != NULL);
- return n->kind == decl_enumerationfield;
+ return static_cast<decl_node__opaque> (n)->kind == decl_enumerationfield;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" bool decl_isEnumeration (decl_node n)
{
mcDebug_assert (n != NULL);
- return n->kind == decl_enumeration;
+ return static_cast<decl_node__opaque> (n)->kind == decl_enumeration;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" bool decl_isUnbounded (decl_node n)
{
mcDebug_assert (n != NULL);
- return (n->kind == decl_array) && n->arrayF.isUnbounded;
+ return (static_cast<decl_node__opaque> (n)->kind == decl_array) && static_cast<decl_node__opaque> (n)->arrayF.isUnbounded;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" bool decl_isParameter (decl_node n)
{
mcDebug_assert (n != NULL);
- return (n->kind == decl_param) || (n->kind == decl_varparam);
+ return (static_cast<decl_node__opaque> (n)->kind == decl_param) || (static_cast<decl_node__opaque> (n)->kind == decl_varparam);
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" bool decl_isVarParam (decl_node n)
{
mcDebug_assert (n != NULL);
- return n->kind == decl_varparam;
+ return static_cast<decl_node__opaque> (n)->kind == decl_varparam;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" bool decl_isParam (decl_node n)
{
mcDebug_assert (n != NULL);
- return n->kind == decl_param;
+ return static_cast<decl_node__opaque> (n)->kind == decl_param;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" decl_node decl_addOptParameter (decl_node proc, nameKey_Name id, decl_node type, decl_node init)
{
- decl_node p;
- decl_node l;
+ decl_node__opaque p;
+ decl_node__opaque l;
mcDebug_assert (decl_isProcedure (proc));
- l = decl_makeIdentList ();
- mcDebug_assert (decl_putIdent (l, id));
- checkMakeVariables (proc, l, type, false, true);
- if (! proc->procedureF.checking)
+ l = static_cast<decl_node__opaque> (decl_makeIdentList ());
+ mcDebug_assert (decl_putIdent (static_cast<decl_node> (l), id));
+ checkMakeVariables (static_cast<decl_node__opaque> (proc), l, static_cast<decl_node__opaque> (type), false, true);
+ if (! static_cast<decl_node__opaque> (proc)->procedureF.checking)
{
- p = makeOptParameter (l, type, init);
- decl_addParameter (proc, p);
+ p = makeOptParameter (l, static_cast<decl_node__opaque> (type), static_cast<decl_node__opaque> (init));
+ decl_addParameter (proc, static_cast<decl_node> (p));
}
- return p;
+ return static_cast<decl_node> (p);
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" bool decl_isOptarg (decl_node n)
{
- return n->kind == decl_optarg;
+ return static_cast<decl_node__opaque> (n)->kind == decl_optarg;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" bool decl_isRecord (decl_node n)
{
mcDebug_assert (n != NULL);
- return n->kind == decl_record;
+ return static_cast<decl_node__opaque> (n)->kind == decl_record;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" bool decl_isRecordField (decl_node n)
{
mcDebug_assert (n != NULL);
- return n->kind == decl_recordfield;
+ return static_cast<decl_node__opaque> (n)->kind == decl_recordfield;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" bool decl_isVarientField (decl_node n)
{
mcDebug_assert (n != NULL);
- return n->kind == decl_varientfield;
+ return static_cast<decl_node__opaque> (n)->kind == decl_varientfield;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" bool decl_isArray (decl_node n)
{
mcDebug_assert (n != NULL);
- return n->kind == decl_array;
+ return static_cast<decl_node__opaque> (n)->kind == decl_array;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" bool decl_isProcType (decl_node n)
{
mcDebug_assert (n != NULL);
- return n->kind == decl_proctype;
+ return static_cast<decl_node__opaque> (n)->kind == decl_proctype;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" bool decl_isPointer (decl_node n)
{
mcDebug_assert (n != NULL);
- return n->kind == decl_pointer;
+ return static_cast<decl_node__opaque> (n)->kind == decl_pointer;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" bool decl_isProcedure (decl_node n)
{
mcDebug_assert (n != NULL);
- return n->kind == decl_procedure;
+ return static_cast<decl_node__opaque> (n)->kind == decl_procedure;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" bool decl_isVarient (decl_node n)
{
mcDebug_assert (n != NULL);
- return n->kind == decl_varient;
+ return static_cast<decl_node__opaque> (n)->kind == decl_varient;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" bool decl_isSet (decl_node n)
{
mcDebug_assert (n != NULL);
- return n->kind == decl_set;
+ return static_cast<decl_node__opaque> (n)->kind == decl_set;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" bool decl_isSubrange (decl_node n)
{
mcDebug_assert (n != NULL);
- return n->kind == decl_subrange;
+ return static_cast<decl_node__opaque> (n)->kind == decl_subrange;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" decl_node decl_makeConst (nameKey_Name n)
{
- decl_node d;
+ decl_node__opaque d;
d = newNode (decl_const);
d->constF.name = n;
- d->constF.type = NULL;
- d->constF.scope = decl_getDeclScope ();
- d->constF.value = NULL;
- return addToScope (d);
+ d->constF.type = static_cast<decl_node__opaque> (NULL);
+ d->constF.scope = static_cast<decl_node__opaque> (decl_getDeclScope ());
+ d->constF.value = static_cast<decl_node__opaque> (NULL);
+ return static_cast<decl_node> (addToScope (d));
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" void decl_putConst (decl_node n, decl_node v)
{
mcDebug_assert (decl_isConst (n));
- n->constF.value = v;
+ static_cast<decl_node__opaque> (n)->constF.value = static_cast<decl_node__opaque> (v);
}
extern "C" decl_node decl_makeType (nameKey_Name n)
{
- decl_node d;
+ decl_node__opaque d;
d = newNode (decl_type);
d->typeF.name = n;
- d->typeF.type = NULL;
- d->typeF.scope = decl_getDeclScope ();
+ d->typeF.type = static_cast<decl_node__opaque> (NULL);
+ d->typeF.scope = static_cast<decl_node__opaque> (decl_getDeclScope ());
+ d->typeF.isOpaque = false;
d->typeF.isHidden = false;
d->typeF.isInternal = false;
- return addToScope (d);
+ return static_cast<decl_node> (addToScope (d));
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" decl_node decl_makeTypeImp (nameKey_Name n)
{
- decl_node d;
+ decl_node__opaque d;
- d = decl_lookupSym (n);
+ d = static_cast<decl_node__opaque> (decl_lookupSym (n));
if (d != NULL)
{
d->typeF.isHidden = false;
- return addToScope (d);
+ return static_cast<decl_node> (addToScope (d));
}
else
{
d = newNode (decl_type);
d->typeF.name = n;
- d->typeF.type = NULL;
- d->typeF.scope = decl_getDeclScope ();
+ d->typeF.type = static_cast<decl_node__opaque> (NULL);
+ d->typeF.scope = static_cast<decl_node__opaque> (decl_getDeclScope ());
+ d->typeF.isOpaque = false;
d->typeF.isHidden = false;
- return addToScope (d);
+ return static_cast<decl_node> (addToScope (d));
}
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
extern "C" decl_node decl_makeVar (nameKey_Name n)
{
- decl_node d;
+ decl_node__opaque d;
d = newNode (decl_var);
d->varF.name = n;
- d->varF.type = NULL;
- d->varF.decl = NULL;
- d->varF.scope = decl_getDeclScope ();
+ d->varF.type = static_cast<decl_node__opaque> (NULL);
+ d->varF.decl = static_cast<decl_node__opaque> (NULL);
+ d->varF.scope = static_cast<decl_node__opaque> (decl_getDeclScope ());
d->varF.isInitialised = false;
d->varF.isParameter = false;
d->varF.isVarParameter = false;
initCname (&d->varF.cname);
- return addToScope (d);
+ return static_cast<decl_node> (addToScope (d));
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
{
mcDebug_assert (var != NULL);
mcDebug_assert (decl_isVar (var));
- var->varF.type = type;
- var->varF.decl = decl;
+ static_cast<decl_node__opaque> (var)->varF.type = static_cast<decl_node__opaque> (type);
+ static_cast<decl_node__opaque> (var)->varF.decl = static_cast<decl_node__opaque> (decl);
+ initNodeOpaqueState (static_cast<decl_node__opaque> (var));
}
extern "C" decl_node decl_makeVarDecl (decl_node i, decl_node type)
{
- decl_node d;
- decl_node v;
+ decl_node__opaque d;
+ decl_node__opaque v;
unsigned int j;
unsigned int n;
- type = checkPtr (type);
+ type = static_cast<decl_node> (checkPtr (static_cast<decl_node__opaque> (type)));
d = newNode (decl_vardecl);
- d->vardeclF.names = i->identlistF.names;
- d->vardeclF.type = type;
- d->vardeclF.scope = decl_getDeclScope ();
+ d->vardeclF.names = static_cast<decl_node__opaque> (i)->identlistF.names;
+ d->vardeclF.type = static_cast<decl_node__opaque> (type);
+ d->vardeclF.scope = static_cast<decl_node__opaque> (decl_getDeclScope ());
n = wlists_noOfItemsInList (d->vardeclF.names);
j = 1;
while (j <= n)
{
- v = decl_lookupSym (wlists_getItemFromList (d->vardeclF.names, j));
- mcDebug_assert (decl_isVar (v));
- decl_putVar (v, type, d);
+ v = static_cast<decl_node__opaque> (decl_lookupSym (wlists_getItemFromList (d->vardeclF.names, j)));
+ mcDebug_assert (decl_isVar (static_cast<decl_node> (v)));
+ decl_putVar (static_cast<decl_node> (v), type, static_cast<decl_node> (d));
j += 1;
}
- return d;
+ return static_cast<decl_node> (d);
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" decl_node decl_makeEnum (void)
{
- if ((currentModule != NULL) && (decl_getEnumsComplete (currentModule)))
+ if ((currentModule != NULL) && (decl_getEnumsComplete (static_cast<decl_node> (currentModule))))
{
return decl_getNextEnum ();
}
else
{
- return doMakeEnum ();
+ return static_cast<decl_node> (doMakeEnum ());
}
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
extern "C" decl_node decl_makeEnumField (decl_node e, nameKey_Name n)
{
- if ((currentModule != NULL) && (decl_getEnumsComplete (currentModule)))
+ if ((currentModule != NULL) && (decl_getEnumsComplete (static_cast<decl_node> (currentModule))))
{
return decl_getNextEnum ();
}
else
{
- return doMakeEnumField (e, n);
+ return static_cast<decl_node> (doMakeEnumField (static_cast<decl_node__opaque> (e), n));
}
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
extern "C" decl_node decl_makeSubrange (decl_node low, decl_node high)
{
- decl_node n;
+ decl_node__opaque n;
n = newNode (decl_subrange);
- n->subrangeF.low = low;
- n->subrangeF.high = high;
- n->subrangeF.type = NULL;
- n->subrangeF.scope = decl_getDeclScope ();
- return n;
+ n->subrangeF.low = static_cast<decl_node__opaque> (low);
+ n->subrangeF.high = static_cast<decl_node__opaque> (high);
+ n->subrangeF.type = static_cast<decl_node__opaque> (NULL);
+ n->subrangeF.scope = static_cast<decl_node__opaque> (decl_getDeclScope ());
+ return static_cast<decl_node> (n);
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" void decl_putSubrangeType (decl_node sub, decl_node type)
{
mcDebug_assert (decl_isSubrange (sub));
- sub->subrangeF.type = type;
+ static_cast<decl_node__opaque> (sub)->subrangeF.type = static_cast<decl_node__opaque> (type);
}
extern "C" decl_node decl_makePointer (decl_node type)
{
- decl_node n;
+ decl_node__opaque n;
n = newNode (decl_pointer);
- n->pointerF.type = type;
- n->pointerF.scope = decl_getDeclScope ();
- return n;
+ n->pointerF.type = static_cast<decl_node__opaque> (type);
+ n->pointerF.scope = static_cast<decl_node__opaque> (decl_getDeclScope ());
+ return static_cast<decl_node> (n);
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" decl_node decl_makeSet (decl_node type)
{
- decl_node n;
+ decl_node__opaque n;
n = newNode (decl_set);
- n->setF.type = type;
- n->setF.scope = decl_getDeclScope ();
- return n;
+ n->setF.type = static_cast<decl_node__opaque> (type);
+ n->setF.scope = static_cast<decl_node__opaque> (decl_getDeclScope ());
+ return static_cast<decl_node> (n);
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" decl_node decl_makeArray (decl_node subr, decl_node type)
{
- decl_node n;
- decl_node s;
+ decl_node__opaque n;
+ decl_node__opaque s;
- s = decl_skipType (subr);
- mcDebug_assert (((decl_isSubrange (s)) || (isOrdinal (s))) || (decl_isEnumeration (s)));
+ s = static_cast<decl_node__opaque> (decl_skipType (subr));
+ mcDebug_assert (((decl_isSubrange (static_cast<decl_node> (s))) || (isOrdinal (s))) || (decl_isEnumeration (static_cast<decl_node> (s))));
n = newNode (decl_array);
- n->arrayF.subr = subr;
- n->arrayF.type = type;
- n->arrayF.scope = decl_getDeclScope ();
+ n->arrayF.subr = static_cast<decl_node__opaque> (subr);
+ n->arrayF.type = static_cast<decl_node__opaque> (type);
+ n->arrayF.scope = static_cast<decl_node__opaque> (decl_getDeclScope ());
n->arrayF.isUnbounded = false;
- return n;
+ return static_cast<decl_node> (n);
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" void decl_putUnbounded (decl_node n)
{
- mcDebug_assert (n->kind == decl_array);
- n->arrayF.isUnbounded = true;
+ mcDebug_assert (static_cast<decl_node__opaque> (n)->kind == decl_array);
+ static_cast<decl_node__opaque> (n)->arrayF.isUnbounded = true;
}
extern "C" decl_node decl_makeRecord (void)
{
- decl_node n;
+ decl_node__opaque n;
n = newNode (decl_record);
n->recordF.localSymbols = symbolKey_initTree ();
n->recordF.listOfSons = Indexing_InitIndex (1);
- n->recordF.scope = decl_getDeclScope ();
- return n;
+ n->recordF.scope = static_cast<decl_node__opaque> (decl_getDeclScope ());
+ return static_cast<decl_node> (n);
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" decl_node decl_makeVarient (decl_node r)
{
- decl_node n;
+ decl_node__opaque n;
n = newNode (decl_varient);
n->varientF.listOfSons = Indexing_InitIndex (1);
/* if so use this n^.varientF.parent := r */
if (decl_isRecord (r))
{
- n->varientF.varient = NULL;
+ n->varientF.varient = static_cast<decl_node__opaque> (NULL);
}
else
{
- n->varientF.varient = r;
+ n->varientF.varient = static_cast<decl_node__opaque> (r);
}
- n->varientF.tag = NULL;
- n->varientF.scope = decl_getDeclScope ();
- switch (r->kind)
+ n->varientF.tag = static_cast<decl_node__opaque> (NULL);
+ n->varientF.scope = static_cast<decl_node__opaque> (decl_getDeclScope ());
+ switch (static_cast<decl_node__opaque> (r)->kind)
{
case decl_record:
/* now add, n, to the record/varient, r, field list */
- Indexing_IncludeIndiceIntoIndex (r->recordF.listOfSons, reinterpret_cast<void *> (n));
+ Indexing_IncludeIndiceIntoIndex (static_cast<decl_node__opaque> (r)->recordF.listOfSons, reinterpret_cast<void *> (n));
break;
case decl_varientfield:
- Indexing_IncludeIndiceIntoIndex (r->varientfieldF.listOfSons, reinterpret_cast<void *> (n));
+ Indexing_IncludeIndiceIntoIndex (static_cast<decl_node__opaque> (r)->varientfieldF.listOfSons, reinterpret_cast<void *> (n));
break;
CaseException ("../../gcc/m2/mc/decl.def", 20, 1);
__builtin_unreachable ();
}
- return n;
+ return static_cast<decl_node> (n);
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" decl_node decl_addFieldsToRecord (decl_node r, decl_node v, decl_node i, decl_node t)
{
- decl_node p;
- decl_node fj;
+ decl_node__opaque p;
+ decl_node__opaque fj;
unsigned int j;
unsigned int n;
nameKey_Name fn;
if (decl_isRecord (r))
{
- p = r;
- v = NULL;
+ p = static_cast<decl_node__opaque> (r);
+ v = static_cast<decl_node> (NULL);
}
else
{
- p = getRecord (getParent (r));
+ p = getRecord (getParent (static_cast<decl_node__opaque> (r)));
mcDebug_assert (decl_isVarientField (r));
mcDebug_assert (decl_isVarient (v));
- putFieldVarient (r, v);
+ putFieldVarient (static_cast<decl_node__opaque> (r), static_cast<decl_node__opaque> (v));
}
- n = wlists_noOfItemsInList (i->identlistF.names);
+ n = wlists_noOfItemsInList (static_cast<decl_node__opaque> (i)->identlistF.names);
j = 1;
while (j <= n)
{
- fn = static_cast<nameKey_Name> (wlists_getItemFromList (i->identlistF.names, j));
- fj = static_cast<decl_node> (symbolKey_getSymKey (p->recordF.localSymbols, n));
+ fn = static_cast<nameKey_Name> (wlists_getItemFromList (static_cast<decl_node__opaque> (i)->identlistF.names, j));
+ fj = static_cast<decl_node__opaque> (symbolKey_getSymKey (p->recordF.localSymbols, n));
if (fj == NULL)
{
- fj = putFieldRecord (r, fn, t, v);
+ fj = putFieldRecord (static_cast<decl_node__opaque> (r), fn, static_cast<decl_node__opaque> (t), static_cast<decl_node__opaque> (v));
}
else
{
extern "C" void decl_buildVarientSelector (decl_node r, decl_node v, nameKey_Name tag, decl_node type)
{
- decl_node f;
+ decl_node__opaque f;
mcDebug_assert ((decl_isRecord (r)) || (decl_isVarientField (r)));
if ((decl_isRecord (r)) || (decl_isVarientField (r)))
else if (type == NULL)
{
/* avoid dangling else. */
- f = decl_lookupSym (tag);
- putVarientTag (v, f);
+ f = static_cast<decl_node__opaque> (decl_lookupSym (tag));
+ putVarientTag (static_cast<decl_node__opaque> (v), f);
}
else
{
/* avoid dangling else. */
- f = putFieldRecord (r, tag, type, v);
- mcDebug_assert (decl_isRecordField (f));
+ f = putFieldRecord (static_cast<decl_node__opaque> (r), tag, static_cast<decl_node__opaque> (type), static_cast<decl_node__opaque> (v));
+ mcDebug_assert (decl_isRecordField (static_cast<decl_node> (f)));
f->recordfieldF.tag = true;
- putVarientTag (v, f);
+ putVarientTag (static_cast<decl_node__opaque> (v), f);
}
}
}
extern "C" decl_node decl_buildVarientFieldRecord (decl_node v, decl_node p)
{
- decl_node f;
+ decl_node__opaque f;
mcDebug_assert (decl_isVarient (v));
- f = makeVarientField (v, p);
- mcDebug_assert (decl_isVarientField (f));
- putFieldVarient (f, v);
- return f;
+ f = makeVarientField (static_cast<decl_node__opaque> (v), static_cast<decl_node__opaque> (p));
+ mcDebug_assert (decl_isVarientField (static_cast<decl_node> (f)));
+ putFieldVarient (f, static_cast<decl_node__opaque> (v));
+ return static_cast<decl_node> (f);
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" nameKey_Name decl_getSymName (decl_node n)
{
- switch (n->kind)
+ switch (static_cast<decl_node__opaque> (n)->kind)
{
case decl_new:
return nameKey_makeKey ((const char *) "NEW", 3);
case decl_type:
/* language features and compound type attributes. */
- return n->typeF.name;
+ return static_cast<decl_node__opaque> (n)->typeF.name;
break;
case decl_record:
break;
case decl_var:
- return n->varF.name;
+ return static_cast<decl_node__opaque> (n)->varF.name;
break;
case decl_enumeration:
break;
case decl_string:
- return n->stringF.name;
+ return static_cast<decl_node__opaque> (n)->stringF.name;
break;
case decl_const:
- return n->constF.name;
+ return static_cast<decl_node__opaque> (n)->constF.name;
break;
case decl_literal:
- return n->literalF.name;
+ return static_cast<decl_node__opaque> (n)->literalF.name;
break;
case decl_varparam:
break;
case decl_recordfield:
- return n->recordfieldF.name;
+ return static_cast<decl_node__opaque> (n)->recordfieldF.name;
break;
case decl_varientfield:
- return n->varientfieldF.name;
+ return static_cast<decl_node__opaque> (n)->varientfieldF.name;
break;
case decl_enumerationfield:
- return n->enumerationfieldF.name;
+ return static_cast<decl_node__opaque> (n)->enumerationfieldF.name;
break;
case decl_set:
case decl_procedure:
/* blocks. */
- return n->procedureF.name;
+ return static_cast<decl_node__opaque> (n)->procedureF.name;
break;
case decl_def:
- return n->defF.name;
+ return static_cast<decl_node__opaque> (n)->defF.name;
break;
case decl_imp:
- return n->impF.name;
+ return static_cast<decl_node__opaque> (n)->impF.name;
break;
case decl_module:
- return n->moduleF.name;
+ return static_cast<decl_node__opaque> (n)->moduleF.name;
break;
case decl_loop:
extern "C" decl_node decl_import (decl_node m, decl_node n)
{
nameKey_Name name;
- decl_node r;
+ decl_node__opaque r;
mcDebug_assert (((decl_isDef (m)) || (decl_isModule (m))) || (decl_isImp (m)));
name = decl_getSymName (n);
- r = decl_lookupInScope (m, name);
+ r = static_cast<decl_node__opaque> (decl_lookupInScope (m, name));
if (r == NULL)
{
- switch (m->kind)
+ switch (static_cast<decl_node__opaque> (m)->kind)
{
case decl_def:
- symbolKey_putSymKey (m->defF.decls.symbols, name, reinterpret_cast<void *> (n));
+ symbolKey_putSymKey (static_cast<decl_node__opaque> (m)->defF.decls.symbols, name, reinterpret_cast<void *> (n));
break;
case decl_imp:
- symbolKey_putSymKey (m->impF.decls.symbols, name, reinterpret_cast<void *> (n));
+ symbolKey_putSymKey (static_cast<decl_node__opaque> (m)->impF.decls.symbols, name, reinterpret_cast<void *> (n));
break;
case decl_module:
- symbolKey_putSymKey (m->moduleF.decls.symbols, name, reinterpret_cast<void *> (n));
+ symbolKey_putSymKey (static_cast<decl_node__opaque> (m)->moduleF.decls.symbols, name, reinterpret_cast<void *> (n));
break;
CaseException ("../../gcc/m2/mc/decl.def", 20, 1);
__builtin_unreachable ();
}
- importEnumFields (m, n);
+ importEnumFields (static_cast<decl_node__opaque> (m), static_cast<decl_node__opaque> (n));
return n;
}
- return r;
+ return static_cast<decl_node> (r);
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" decl_node decl_lookupExported (decl_node n, nameKey_Name i)
{
- decl_node r;
+ decl_node__opaque r;
mcDebug_assert (decl_isDef (n));
- r = static_cast<decl_node> (symbolKey_getSymKey (n->defF.decls.symbols, i));
- if ((r != NULL) && (decl_isExported (r)))
+ r = static_cast<decl_node__opaque> (symbolKey_getSymKey (static_cast<decl_node__opaque> (n)->defF.decls.symbols, i));
+ if ((r != NULL) && (decl_isExported (static_cast<decl_node> (r))))
{
- return r;
+ return static_cast<decl_node> (r);
}
- return NULL;
+ return static_cast<decl_node> (NULL);
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" decl_node decl_lookupSym (nameKey_Name n)
{
- decl_node s;
- decl_node m;
+ decl_node__opaque s;
+ decl_node__opaque m;
unsigned int l;
unsigned int h;
h = Indexing_HighIndice (scopeStack);
while (h >= l)
{
- s = static_cast<decl_node> (Indexing_GetIndice (scopeStack, h));
- m = decl_lookupInScope (s, n);
+ s = static_cast<decl_node__opaque> (Indexing_GetIndice (scopeStack, h));
+ m = static_cast<decl_node__opaque> (decl_lookupInScope (static_cast<decl_node> (s), n));
if (debugScopes && (m == NULL))
{
out3 ((const char *) " [%d] search for symbol name %s in scope %s\\n", 45, h, n, s);
{
out3 ((const char *) " [%d] search for symbol name %s in scope %s (found)\\n", 53, h, n, s);
}
- return m;
+ return static_cast<decl_node> (m);
}
h -= 1;
}
- return lookupBase (n);
+ return static_cast<decl_node> (lookupBase (n));
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
mcDebug_assert ((decl_isDef (i)) || (decl_isModule (i)));
if (decl_isDef (m))
{
- Indexing_IncludeIndiceIntoIndex (m->defF.importedModules, reinterpret_cast<void *> (i));
+ Indexing_IncludeIndiceIntoIndex (static_cast<decl_node__opaque> (m)->defF.importedModules, reinterpret_cast<void *> (i));
}
else if (decl_isImp (m))
{
/* avoid dangling else. */
- Indexing_IncludeIndiceIntoIndex (m->impF.importedModules, reinterpret_cast<void *> (i));
+ Indexing_IncludeIndiceIntoIndex (static_cast<decl_node__opaque> (m)->impF.importedModules, reinterpret_cast<void *> (i));
}
else if (decl_isModule (m))
{
/* avoid dangling else. */
- Indexing_IncludeIndiceIntoIndex (m->moduleF.importedModules, reinterpret_cast<void *> (i));
+ Indexing_IncludeIndiceIntoIndex (static_cast<decl_node__opaque> (m)->moduleF.importedModules, reinterpret_cast<void *> (i));
}
else
{
}
if (scoped)
{
- addModuleToScope (m, i);
+ addModuleToScope (static_cast<decl_node__opaque> (m), static_cast<decl_node__opaque> (i));
}
}
extern "C" void decl_setSource (decl_node n, nameKey_Name s)
{
- switch (n->kind)
+ switch (static_cast<decl_node__opaque> (n)->kind)
{
case decl_def:
- n->defF.source = s;
+ static_cast<decl_node__opaque> (n)->defF.source = s;
break;
case decl_module:
- n->moduleF.source = s;
+ static_cast<decl_node__opaque> (n)->moduleF.source = s;
break;
case decl_imp:
- n->impF.source = s;
+ static_cast<decl_node__opaque> (n)->impF.source = s;
break;
extern "C" nameKey_Name decl_getSource (decl_node n)
{
- switch (n->kind)
+ switch (static_cast<decl_node__opaque> (n)->kind)
{
case decl_def:
- return n->defF.source;
+ return static_cast<decl_node__opaque> (n)->defF.source;
break;
case decl_module:
- return n->moduleF.source;
+ return static_cast<decl_node__opaque> (n)->moduleF.source;
break;
case decl_imp:
- return n->impF.source;
+ return static_cast<decl_node__opaque> (n)->impF.source;
break;
extern "C" decl_node decl_getMainModule (void)
{
- return mainModule;
+ return static_cast<decl_node> (mainModule);
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" decl_node decl_getCurrentModule (void)
{
- return currentModule;
+ return static_cast<decl_node> (currentModule);
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" void decl_leaveScope (void)
{
unsigned int i;
- decl_node n;
+ decl_node__opaque n;
i = Indexing_HighIndice (scopeStack);
- n = static_cast<decl_node> (Indexing_GetIndice (scopeStack, i));
+ n = static_cast<decl_node__opaque> (Indexing_GetIndice (scopeStack, i));
Indexing_RemoveIndiceFromIndex (scopeStack, reinterpret_cast<void *> (n));
if (debugScopes)
{
extern "C" decl_node decl_makeProcedure (nameKey_Name n)
{
- decl_node d;
+ decl_node__opaque d;
- d = decl_lookupSym (n);
+ d = static_cast<decl_node__opaque> (decl_lookupSym (n));
if (d == NULL)
{
d = newNode (decl_procedure);
d->procedureF.name = n;
initDecls (&d->procedureF.decls);
- d->procedureF.scope = decl_getDeclScope ();
+ d->procedureF.scope = static_cast<decl_node__opaque> (decl_getDeclScope ());
d->procedureF.parameters = Indexing_InitIndex (1);
- d->procedureF.isForC = isDefForCNode (decl_getDeclScope ());
+ d->procedureF.isForC = isDefForCNode (static_cast<decl_node__opaque> (decl_getDeclScope ()));
d->procedureF.built = false;
d->procedureF.returnopt = false;
- d->procedureF.optarg_ = NULL;
+ d->procedureF.optarg_ = static_cast<decl_node__opaque> (NULL);
d->procedureF.noreturnused = false;
d->procedureF.noreturn = false;
d->procedureF.vararg = false;
d->procedureF.checking = false;
d->procedureF.paramcount = 0;
- d->procedureF.returnType = NULL;
- d->procedureF.beginStatements = NULL;
+ d->procedureF.returnType = static_cast<decl_node__opaque> (NULL);
+ d->procedureF.beginStatements = static_cast<decl_node__opaque> (NULL);
initCname (&d->procedureF.cname);
- d->procedureF.defComment = NULL;
- d->procedureF.modComment = NULL;
+ d->procedureF.defComment = static_cast<mcComment_commentDesc> (NULL);
+ d->procedureF.modComment = static_cast<mcComment_commentDesc> (NULL);
}
- return addProcedureToScope (d, n);
+ return static_cast<decl_node> (addProcedureToScope (d, n));
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
mcDebug_assert (decl_isProcedure (n));
if (mcComment_isProcedureComment (mcLexBuf_lastcomment))
{
- n->procedureF.defComment = mcLexBuf_lastcomment;
+ static_cast<decl_node__opaque> (n)->procedureF.defComment = mcLexBuf_lastcomment;
}
}
mcDebug_assert (decl_isProcedure (n));
if (mcComment_isProcedureComment (mcLexBuf_lastcomment))
{
- n->procedureF.modComment = mcLexBuf_lastcomment;
+ static_cast<decl_node__opaque> (n)->procedureF.modComment = mcLexBuf_lastcomment;
}
}
extern "C" decl_node decl_makeProcType (void)
{
- decl_node d;
+ decl_node__opaque d;
d = newNode (decl_proctype);
- d->proctypeF.scope = decl_getDeclScope ();
+ d->proctypeF.scope = static_cast<decl_node__opaque> (decl_getDeclScope ());
d->proctypeF.parameters = Indexing_InitIndex (1);
d->proctypeF.returnopt = false;
- d->proctypeF.optarg_ = NULL;
+ d->proctypeF.optarg_ = static_cast<decl_node__opaque> (NULL);
d->proctypeF.vararg = false;
- d->proctypeF.returnType = NULL;
- return d;
+ d->proctypeF.returnType = static_cast<decl_node__opaque> (NULL);
+ initNodeOpaqueState (d);
+ return static_cast<decl_node> (d);
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
/*
- putReturnType - sets the return type of procedure or proctype, proc, to, type.
+ putReturnType - sets the return type of procedure or proctype proc to type.
*/
extern "C" void decl_putReturnType (decl_node proc, decl_node type)
mcDebug_assert ((decl_isProcedure (proc)) || (decl_isProcType (proc)));
if (decl_isProcedure (proc))
{
- proc->procedureF.returnType = type;
+ static_cast<decl_node__opaque> (proc)->procedureF.returnType = static_cast<decl_node__opaque> (type);
}
else
{
- proc->proctypeF.returnType = type;
+ static_cast<decl_node__opaque> (proc)->proctypeF.returnType = static_cast<decl_node__opaque> (type);
}
+ initNodeOpaqueState (static_cast<decl_node__opaque> (proc));
}
mcDebug_assert ((decl_isProcedure (proc)) || (decl_isProcType (proc)));
if (decl_isProcedure (proc))
{
- proc->procedureF.returnopt = true;
+ static_cast<decl_node__opaque> (proc)->procedureF.returnopt = true;
}
else
{
- proc->proctypeF.returnopt = true;
+ static_cast<decl_node__opaque> (proc)->proctypeF.returnopt = true;
}
}
extern "C" decl_node decl_makeVarParameter (decl_node l, decl_node type, decl_node proc, bool isused)
{
- decl_node d;
+ decl_node__opaque d;
- mcDebug_assert ((l == NULL) || (isIdentList (l)));
+ mcDebug_assert ((l == NULL) || (isIdentList (static_cast<decl_node__opaque> (l))));
d = newNode (decl_varparam);
- d->varparamF.namelist = l;
- d->varparamF.type = type;
- d->varparamF.scope = proc;
+ d->varparamF.namelist = static_cast<decl_node__opaque> (l);
+ d->varparamF.type = static_cast<decl_node__opaque> (type);
+ d->varparamF.scope = static_cast<decl_node__opaque> (proc);
d->varparamF.isUnbounded = false;
- d->varparamF.isForC = isDefForCNode (proc);
+ d->varparamF.isForC = isDefForCNode (static_cast<decl_node__opaque> (proc));
d->varparamF.isUsed = isused;
- return d;
+ initNodeOpaqueState (d);
+ return static_cast<decl_node> (d);
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" decl_node decl_makeNonVarParameter (decl_node l, decl_node type, decl_node proc, bool isused)
{
- decl_node d;
+ decl_node__opaque d;
- mcDebug_assert ((l == NULL) || (isIdentList (l)));
+ mcDebug_assert ((l == NULL) || (isIdentList (static_cast<decl_node__opaque> (l))));
d = newNode (decl_param);
- d->paramF.namelist = l;
- d->paramF.type = type;
- d->paramF.scope = proc;
+ d->paramF.namelist = static_cast<decl_node__opaque> (l);
+ d->paramF.type = static_cast<decl_node__opaque> (type);
+ d->paramF.scope = static_cast<decl_node__opaque> (proc);
d->paramF.isUnbounded = false;
- d->paramF.isForC = isDefForCNode (proc);
+ d->paramF.isForC = isDefForCNode (static_cast<decl_node__opaque> (proc));
d->paramF.isUsed = isused;
- return d;
+ initNodeOpaqueState (d);
+ return static_cast<decl_node> (d);
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" void decl_paramEnter (decl_node n)
{
mcDebug_assert (decl_isProcedure (n));
- n->procedureF.paramcount = 0;
+ static_cast<decl_node__opaque> (n)->procedureF.paramcount = 0;
}
extern "C" void decl_paramLeave (decl_node n)
{
mcDebug_assert (decl_isProcedure (n));
- n->procedureF.checking = true;
- if ((decl_isImp (currentModule)) || (decl_isModule (currentModule)))
+ static_cast<decl_node__opaque> (n)->procedureF.checking = true;
+ if ((decl_isImp (static_cast<decl_node> (currentModule))) || (decl_isModule (static_cast<decl_node> (currentModule))))
{
- n->procedureF.built = true;
+ static_cast<decl_node__opaque> (n)->procedureF.built = true;
}
}
extern "C" decl_node decl_makeIdentList (void)
{
- decl_node n;
+ decl_node__opaque n;
n = newNode (decl_identlist);
n->identlistF.names = wlists_initList ();
n->identlistF.cnamed = false;
- return n;
+ return static_cast<decl_node> (n);
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" bool decl_putIdent (decl_node n, nameKey_Name i)
{
- mcDebug_assert (isIdentList (n));
- if (wlists_isItemInList (n->identlistF.names, i))
+ mcDebug_assert (isIdentList (static_cast<decl_node__opaque> (n)));
+ if (wlists_isItemInList (static_cast<decl_node__opaque> (n)->identlistF.names, i))
{
return false;
}
else
{
- wlists_putItemIntoList (n->identlistF.names, i);
+ wlists_putItemIntoList (static_cast<decl_node__opaque> (n)->identlistF.names, i);
return true;
}
/* static analysis guarentees a RETURN statement will be used before here. */
extern "C" void decl_addVarParameters (decl_node n, decl_node i, decl_node type, bool isused)
{
- decl_node p;
+ decl_node__opaque p;
- mcDebug_assert (isIdentList (i));
+ mcDebug_assert (isIdentList (static_cast<decl_node__opaque> (i)));
mcDebug_assert (decl_isProcedure (n));
- checkMakeVariables (n, i, type, true, isused);
- if (n->procedureF.checking)
+ checkMakeVariables (static_cast<decl_node__opaque> (n), static_cast<decl_node__opaque> (i), static_cast<decl_node__opaque> (type), true, isused);
+ if (static_cast<decl_node__opaque> (n)->procedureF.checking)
{
- checkParameters (n, i, type, true, isused); /* will destroy, i. */
+ checkParameters (static_cast<decl_node__opaque> (n), static_cast<decl_node__opaque> (i), static_cast<decl_node__opaque> (type), true, isused); /* will destroy, i. */
}
else
{
- p = decl_makeVarParameter (i, type, n, isused);
- Indexing_IncludeIndiceIntoIndex (n->procedureF.parameters, reinterpret_cast<void *> (p));
+ p = static_cast<decl_node__opaque> (decl_makeVarParameter (i, type, n, isused));
+ Indexing_IncludeIndiceIntoIndex (static_cast<decl_node__opaque> (n)->procedureF.parameters, reinterpret_cast<void *> (p));
}
}
extern "C" void decl_addNonVarParameters (decl_node n, decl_node i, decl_node type, bool isused)
{
- decl_node p;
+ decl_node__opaque p;
- mcDebug_assert (isIdentList (i));
+ mcDebug_assert (isIdentList (static_cast<decl_node__opaque> (i)));
mcDebug_assert (decl_isProcedure (n));
- checkMakeVariables (n, i, type, false, isused);
- if (n->procedureF.checking)
+ checkMakeVariables (static_cast<decl_node__opaque> (n), static_cast<decl_node__opaque> (i), static_cast<decl_node__opaque> (type), false, isused);
+ if (static_cast<decl_node__opaque> (n)->procedureF.checking)
{
- checkParameters (n, i, type, false, isused); /* will destroy, i. */
+ checkParameters (static_cast<decl_node__opaque> (n), static_cast<decl_node__opaque> (i), static_cast<decl_node__opaque> (type), false, isused); /* will destroy, i. */
}
else
{
- p = decl_makeNonVarParameter (i, type, n, isused);
- Indexing_IncludeIndiceIntoIndex (n->procedureF.parameters, reinterpret_cast<void *> (p));
+ p = static_cast<decl_node__opaque> (decl_makeNonVarParameter (i, type, n, isused));
+ Indexing_IncludeIndiceIntoIndex (static_cast<decl_node__opaque> (n)->procedureF.parameters, reinterpret_cast<void *> (p));
}
}
extern "C" decl_node decl_makeVarargs (void)
{
- decl_node d;
+ decl_node__opaque d;
d = newNode (decl_varargs);
- d->varargsF.scope = NULL;
- return d;
+ d->varargsF.scope = static_cast<decl_node__opaque> (NULL);
+ return static_cast<decl_node> (d);
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" bool decl_isVarargs (decl_node n)
{
- return n->kind == decl_varargs;
+ return static_cast<decl_node__opaque> (n)->kind == decl_varargs;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" void decl_addParameter (decl_node proc, decl_node param)
{
mcDebug_assert ((((decl_isVarargs (param)) || (decl_isParam (param))) || (decl_isVarParam (param))) || (decl_isOptarg (param)));
- switch (proc->kind)
+ switch (static_cast<decl_node__opaque> (proc)->kind)
{
case decl_procedure:
- Indexing_IncludeIndiceIntoIndex (proc->procedureF.parameters, reinterpret_cast<void *> (param));
+ Indexing_IncludeIndiceIntoIndex (static_cast<decl_node__opaque> (proc)->procedureF.parameters, reinterpret_cast<void *> (param));
if (decl_isVarargs (param))
{
- proc->procedureF.vararg = true;
+ static_cast<decl_node__opaque> (proc)->procedureF.vararg = true;
}
if (decl_isOptarg (param))
{
- proc->procedureF.optarg_ = param;
+ static_cast<decl_node__opaque> (proc)->procedureF.optarg_ = static_cast<decl_node__opaque> (param);
}
break;
case decl_proctype:
- Indexing_IncludeIndiceIntoIndex (proc->proctypeF.parameters, reinterpret_cast<void *> (param));
+ Indexing_IncludeIndiceIntoIndex (static_cast<decl_node__opaque> (proc)->proctypeF.parameters, reinterpret_cast<void *> (param));
if (decl_isVarargs (param))
{
- proc->proctypeF.vararg = true;
+ static_cast<decl_node__opaque> (proc)->proctypeF.vararg = true;
}
if (decl_isOptarg (param))
{
- proc->proctypeF.optarg_ = param;
+ static_cast<decl_node__opaque> (proc)->proctypeF.optarg_ = static_cast<decl_node__opaque> (param);
}
break;
{
if (op == mcReserved_equaltok)
{
- return makeBinary (decl_equal, l, r, booleanN);
+ return static_cast<decl_node> (makeBinary (decl_equal, static_cast<decl_node__opaque> (l), static_cast<decl_node__opaque> (r), booleanN));
}
else if ((op == mcReserved_hashtok) || (op == mcReserved_lessgreatertok))
{
/* avoid dangling else. */
- return makeBinary (decl_notequal, l, r, booleanN);
+ return static_cast<decl_node> (makeBinary (decl_notequal, static_cast<decl_node__opaque> (l), static_cast<decl_node__opaque> (r), booleanN));
}
else if (op == mcReserved_lesstok)
{
/* avoid dangling else. */
- return makeBinary (decl_less, l, r, booleanN);
+ return static_cast<decl_node> (makeBinary (decl_less, static_cast<decl_node__opaque> (l), static_cast<decl_node__opaque> (r), booleanN));
}
else if (op == mcReserved_greatertok)
{
/* avoid dangling else. */
- return makeBinary (decl_greater, l, r, booleanN);
+ return static_cast<decl_node> (makeBinary (decl_greater, static_cast<decl_node__opaque> (l), static_cast<decl_node__opaque> (r), booleanN));
}
else if (op == mcReserved_greaterequaltok)
{
/* avoid dangling else. */
- return makeBinary (decl_greequal, l, r, booleanN);
+ return static_cast<decl_node> (makeBinary (decl_greequal, static_cast<decl_node__opaque> (l), static_cast<decl_node__opaque> (r), booleanN));
}
else if (op == mcReserved_lessequaltok)
{
/* avoid dangling else. */
- return makeBinary (decl_lessequal, l, r, booleanN);
+ return static_cast<decl_node> (makeBinary (decl_lessequal, static_cast<decl_node__opaque> (l), static_cast<decl_node__opaque> (r), booleanN));
}
else if (op == mcReserved_andtok)
{
/* avoid dangling else. */
- return makeBinary (decl_and, l, r, booleanN);
+ return static_cast<decl_node> (makeBinary (decl_and, static_cast<decl_node__opaque> (l), static_cast<decl_node__opaque> (r), booleanN));
}
else if (op == mcReserved_ortok)
{
/* avoid dangling else. */
- return makeBinary (decl_or, l, r, booleanN);
+ return static_cast<decl_node> (makeBinary (decl_or, static_cast<decl_node__opaque> (l), static_cast<decl_node__opaque> (r), booleanN));
}
else if (op == mcReserved_plustok)
{
/* avoid dangling else. */
- return makeBinary (decl_plus, l, r, NULL);
+ return static_cast<decl_node> (makeBinary (decl_plus, static_cast<decl_node__opaque> (l), static_cast<decl_node__opaque> (r), static_cast<decl_node__opaque> (NULL)));
}
else if (op == mcReserved_minustok)
{
/* avoid dangling else. */
- return makeBinary (decl_sub, l, r, NULL);
+ return static_cast<decl_node> (makeBinary (decl_sub, static_cast<decl_node__opaque> (l), static_cast<decl_node__opaque> (r), static_cast<decl_node__opaque> (NULL)));
}
else if (op == mcReserved_divtok)
{
/* avoid dangling else. */
- return makeBinary (decl_div, l, r, NULL);
+ return static_cast<decl_node> (makeBinary (decl_div, static_cast<decl_node__opaque> (l), static_cast<decl_node__opaque> (r), static_cast<decl_node__opaque> (NULL)));
}
else if (op == mcReserved_timestok)
{
/* avoid dangling else. */
- return makeBinary (decl_mult, l, r, NULL);
+ return static_cast<decl_node> (makeBinary (decl_mult, static_cast<decl_node__opaque> (l), static_cast<decl_node__opaque> (r), static_cast<decl_node__opaque> (NULL)));
}
else if (op == mcReserved_modtok)
{
/* avoid dangling else. */
- return makeBinary (decl_mod, l, r, NULL);
+ return static_cast<decl_node> (makeBinary (decl_mod, static_cast<decl_node__opaque> (l), static_cast<decl_node__opaque> (r), static_cast<decl_node__opaque> (NULL)));
}
else if (op == mcReserved_intok)
{
/* avoid dangling else. */
- return makeBinary (decl_in, l, r, NULL);
+ return static_cast<decl_node> (makeBinary (decl_in, static_cast<decl_node__opaque> (l), static_cast<decl_node__opaque> (r), static_cast<decl_node__opaque> (NULL)));
}
else if (op == mcReserved_dividetok)
{
/* avoid dangling else. */
- return makeBinary (decl_divide, l, r, NULL);
+ return static_cast<decl_node> (makeBinary (decl_divide, static_cast<decl_node__opaque> (l), static_cast<decl_node__opaque> (r), static_cast<decl_node__opaque> (NULL)));
}
else
{
{
if (op == mcReserved_nottok)
{
- return makeUnary (decl_not, e, booleanN);
+ return static_cast<decl_node> (makeUnary (decl_not, static_cast<decl_node__opaque> (e), booleanN));
}
else if (op == mcReserved_plustok)
{
/* avoid dangling else. */
- return makeUnary (decl_plus, e, NULL);
+ return static_cast<decl_node> (makeUnary (decl_plus, static_cast<decl_node__opaque> (e), static_cast<decl_node__opaque> (NULL)));
}
else if (op == mcReserved_minustok)
{
/* avoid dangling else. */
- return makeUnary (decl_neg, e, NULL);
+ return static_cast<decl_node> (makeUnary (decl_neg, static_cast<decl_node__opaque> (e), static_cast<decl_node__opaque> (NULL)));
}
else
{
extern "C" decl_node decl_makeComponentRef (decl_node rec, decl_node field)
{
- decl_node n;
- decl_node a;
+ decl_node__opaque n;
+ decl_node__opaque a;
/*
n := getLastOp (rec) ;
RETURN doMakeComponentRef (rec, field)
END
*/
- if (isDeref (rec))
- {
- a = rec->unaryF.arg;
- rec->kind = decl_pointerref;
- rec->pointerrefF.ptr = a;
- rec->pointerrefF.field = field;
- rec->pointerrefF.resultType = decl_getType (field);
+ if (isDeref (static_cast<decl_node__opaque> (rec)))
+ {
+ a = static_cast<decl_node__opaque> (rec)->unaryF.arg;
+ static_cast<decl_node__opaque> (rec)->kind = decl_pointerref;
+ static_cast<decl_node__opaque> (rec)->pointerrefF.ptr = a;
+ static_cast<decl_node__opaque> (rec)->pointerrefF.field = static_cast<decl_node__opaque> (field);
+ static_cast<decl_node__opaque> (rec)->pointerrefF.resultType = static_cast<decl_node__opaque> (decl_getType (field));
+ initNodeOpaqueState (static_cast<decl_node__opaque> (rec));
return rec;
}
else
{
- return doMakeComponentRef (rec, field);
+ return static_cast<decl_node> (doMakeComponentRef (static_cast<decl_node__opaque> (rec), static_cast<decl_node__opaque> (field)));
}
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
extern "C" decl_node decl_makePointerRef (decl_node ptr, decl_node field)
{
- decl_node n;
+ decl_node__opaque n;
n = newNode (decl_pointerref);
- n->pointerrefF.ptr = ptr;
- n->pointerrefF.field = field;
- n->pointerrefF.resultType = decl_getType (field);
- return n;
+ n->pointerrefF.ptr = static_cast<decl_node__opaque> (ptr);
+ n->pointerrefF.field = static_cast<decl_node__opaque> (field);
+ n->pointerrefF.resultType = static_cast<decl_node__opaque> (decl_getType (field));
+ initNodeOpaqueState (n);
+ return static_cast<decl_node> (n);
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" bool decl_isPointerRef (decl_node n)
{
mcDebug_assert (n != NULL);
- return n->kind == decl_pointerref;
+ return static_cast<decl_node__opaque> (n)->kind == decl_pointerref;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" decl_node decl_makeDeRef (decl_node n)
{
- decl_node t;
+ decl_node__opaque t;
- t = decl_skipType (decl_getType (n));
- mcDebug_assert (decl_isPointer (t));
- return makeUnary (decl_deref, n, decl_getType (t));
+ t = static_cast<decl_node__opaque> (decl_skipType (decl_getType (n)));
+ mcDebug_assert (decl_isPointer (static_cast<decl_node> (t)));
+ return static_cast<decl_node> (makeUnary (decl_deref, static_cast<decl_node__opaque> (n), static_cast<decl_node__opaque> (decl_getType (static_cast<decl_node> (t)))));
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" decl_node decl_makeArrayRef (decl_node array, decl_node index)
{
- decl_node n;
- decl_node t;
+ decl_node__opaque n;
+ decl_node__opaque t;
unsigned int i;
unsigned int j;
n = newNode (decl_arrayref);
- n->arrayrefF.array = array;
- n->arrayrefF.index = index;
- t = array;
- j = expListLen (index);
+ n->arrayrefF.array = static_cast<decl_node__opaque> (array);
+ n->arrayrefF.index = static_cast<decl_node__opaque> (index);
+ t = static_cast<decl_node__opaque> (array);
+ j = expListLen (static_cast<decl_node__opaque> (index));
i = 1;
- t = decl_skipType (decl_getType (t));
+ t = static_cast<decl_node__opaque> (decl_skipType (decl_getType (static_cast<decl_node> (t))));
do {
- if (decl_isArray (t))
+ if (decl_isArray (static_cast<decl_node> (t)))
{
- t = decl_skipType (decl_getType (t));
+ t = static_cast<decl_node__opaque> (decl_skipType (decl_getType (static_cast<decl_node> (t))));
}
else
{
i += 1;
} while (! (i > j));
n->arrayrefF.resultType = t;
- return n;
+ return static_cast<decl_node> (n);
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" decl_node decl_getLastOp (decl_node n)
{
- return doGetLastOp (n, n);
+ return static_cast<decl_node> (doGetLastOp (static_cast<decl_node__opaque> (n), static_cast<decl_node__opaque> (n)));
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" decl_node decl_getCardinal (void)
{
- return cardinalN;
+ return static_cast<decl_node> (cardinalN);
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" decl_node decl_makeLiteralInt (nameKey_Name n)
{
- decl_node m;
+ decl_node__opaque m;
DynamicStrings_String s;
m = newNode (decl_literal);
m->literalF.type = ztypeN;
}
s = DynamicStrings_KillString (s);
- return m;
+ return static_cast<decl_node> (m);
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" decl_node decl_makeLiteralReal (nameKey_Name n)
{
- decl_node m;
+ decl_node__opaque m;
m = newNode (decl_literal);
m->literalF.name = n;
m->literalF.type = rtypeN;
- return m;
+ return static_cast<decl_node> (m);
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" decl_node decl_makeString (nameKey_Name n)
{
- decl_node m;
+ decl_node__opaque m;
m = newNode (decl_string);
m->stringF.name = n;
}
else
{
- m->stringF.cchar = NULL;
+ m->stringF.cchar = static_cast<DynamicStrings_String> (NULL);
}
- return m;
+ return static_cast<decl_node> (m);
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" decl_node decl_makeSetValue (void)
{
- decl_node n;
+ decl_node__opaque n;
n = newNode (decl_setvalue);
n->setvalueF.type = bitsetN;
n->setvalueF.values = Indexing_InitIndex (1);
- return n;
+ return static_cast<decl_node> (n);
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" bool decl_isSetValue (decl_node n)
{
mcDebug_assert (n != NULL);
- return n->kind == decl_setvalue;
+ return static_cast<decl_node__opaque> (n)->kind == decl_setvalue;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" decl_node decl_putSetValue (decl_node n, decl_node t)
{
mcDebug_assert (decl_isSetValue (n));
- n->setvalueF.type = t;
+ static_cast<decl_node__opaque> (n)->setvalueF.type = static_cast<decl_node__opaque> (t);
return n;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
extern "C" decl_node decl_includeSetValue (decl_node n, decl_node l, decl_node h)
{
mcDebug_assert (decl_isSetValue (n));
- Indexing_IncludeIndiceIntoIndex (n->setvalueF.values, reinterpret_cast<void *> (l));
+ Indexing_IncludeIndiceIntoIndex (static_cast<decl_node__opaque> (n)->setvalueF.values, reinterpret_cast<void *> (l));
return n;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
{
if (n == (nameKey_makeKey ((const char *) "BITS_PER_UNIT", 13)))
{
- return bitsperunitN;
+ return static_cast<decl_node> (bitsperunitN);
}
else if (n == (nameKey_makeKey ((const char *) "BITS_PER_WORD", 13)))
{
/* avoid dangling else. */
- return bitsperwordN;
+ return static_cast<decl_node> (bitsperwordN);
}
else if (n == (nameKey_makeKey ((const char *) "BITS_PER_CHAR", 13)))
{
/* avoid dangling else. */
- return bitspercharN;
+ return static_cast<decl_node> (bitspercharN);
}
else if (n == (nameKey_makeKey ((const char *) "UNITS_PER_WORD", 14)))
{
/* avoid dangling else. */
- return unitsperwordN;
+ return static_cast<decl_node> (unitsperwordN);
}
else
{
/* avoid dangling else. */
- return NULL;
+ return static_cast<decl_node> (NULL);
}
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
extern "C" decl_node decl_makeExpList (void)
{
- decl_node n;
+ decl_node__opaque n;
n = newNode (decl_explist);
n->explistF.exp = Indexing_InitIndex (1);
- return n;
+ return static_cast<decl_node> (n);
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" bool decl_isExpList (decl_node n)
{
mcDebug_assert (n != NULL);
- return n->kind == decl_explist;
+ return static_cast<decl_node__opaque> (n)->kind == decl_explist;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
{
mcDebug_assert (n != NULL);
mcDebug_assert (decl_isExpList (n));
- Indexing_PutIndice (n->explistF.exp, (Indexing_HighIndice (n->explistF.exp))+1, reinterpret_cast<void *> (e));
+ Indexing_PutIndice (static_cast<decl_node__opaque> (n)->explistF.exp, (Indexing_HighIndice (static_cast<decl_node__opaque> (n)->explistF.exp))+1, reinterpret_cast<void *> (e));
}
}
else
{
- return doMakeConstExp ();
+ return static_cast<decl_node> (doMakeConstExp ());
}
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
extern "C" decl_node decl_getNextConstExp (void)
{
- decl_node n;
+ decl_node__opaque n;
- mcDebug_assert (((decl_isDef (currentModule)) || (decl_isImp (currentModule))) || (decl_isModule (currentModule)));
- if (decl_isDef (currentModule))
+ mcDebug_assert (((decl_isDef (static_cast<decl_node> (currentModule))) || (decl_isImp (static_cast<decl_node> (currentModule)))) || (decl_isModule (static_cast<decl_node> (currentModule))));
+ if (decl_isDef (static_cast<decl_node> (currentModule)))
{
- return getNextFixup (¤tModule->defF.constFixup);
+ return static_cast<decl_node> (getNextFixup (¤tModule->defF.constFixup));
}
- else if (decl_isImp (currentModule))
+ else if (decl_isImp (static_cast<decl_node> (currentModule)))
{
/* avoid dangling else. */
- return getNextFixup (¤tModule->impF.constFixup);
+ return static_cast<decl_node> (getNextFixup (¤tModule->impF.constFixup));
}
- else if (decl_isModule (currentModule))
+ else if (decl_isModule (static_cast<decl_node> (currentModule)))
{
/* avoid dangling else. */
- return getNextFixup (¤tModule->moduleF.constFixup);
+ return static_cast<decl_node> (getNextFixup (¤tModule->moduleF.constFixup));
}
- return n;
+ return static_cast<decl_node> (n);
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" void decl_setConstExpComplete (decl_node n)
{
- switch (n->kind)
+ switch (static_cast<decl_node__opaque> (n)->kind)
{
case decl_def:
- n->defF.constsComplete = true;
+ static_cast<decl_node__opaque> (n)->defF.constsComplete = true;
break;
case decl_imp:
- n->impF.constsComplete = true;
+ static_cast<decl_node__opaque> (n)->impF.constsComplete = true;
break;
case decl_module:
- n->moduleF.constsComplete = true;
+ static_cast<decl_node__opaque> (n)->moduleF.constsComplete = true;
break;
extern "C" decl_node decl_fixupConstExp (decl_node c, decl_node e)
{
- mcDebug_assert (isConstExp (c));
- c->unaryF.arg = e;
+ mcDebug_assert (isConstExp (static_cast<decl_node__opaque> (c)));
+ static_cast<decl_node__opaque> (c)->unaryF.arg = static_cast<decl_node__opaque> (e);
return c;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
mcDebug_assert (((decl_isDef (n)) || (decl_isImp (n))) || (decl_isModule (n)));
if (decl_isDef (n))
{
- n->defF.constFixup.count = 0;
+ static_cast<decl_node__opaque> (n)->defF.constFixup.count = 0;
}
else if (decl_isImp (n))
{
/* avoid dangling else. */
- n->impF.constFixup.count = 0;
+ static_cast<decl_node__opaque> (n)->impF.constFixup.count = 0;
}
else if (decl_isModule (n))
{
/* avoid dangling else. */
- n->moduleF.constFixup.count = 0;
+ static_cast<decl_node__opaque> (n)->moduleF.constFixup.count = 0;
}
}
extern "C" decl_node decl_makeFuncCall (decl_node c, decl_node n)
{
- decl_node f;
+ decl_node__opaque f;
mcDebug_assert ((n == NULL) || (decl_isExpList (n)));
if (((c == haltN) && ((decl_getMainModule ()) != (decl_lookupDef (nameKey_makeKey ((const char *) "M2RTS", 5))))) && ((decl_getMainModule ()) != (decl_lookupImp (nameKey_makeKey ((const char *) "M2RTS", 5)))))
{
decl_addImportedModule (decl_getMainModule (), decl_lookupDef (nameKey_makeKey ((const char *) "M2RTS", 5)), false);
}
- f = checkIntrinsic (c, n);
- checkCHeaders (c);
+ f = checkIntrinsic (static_cast<decl_node__opaque> (c), static_cast<decl_node__opaque> (n));
+ checkCHeaders (static_cast<decl_node__opaque> (c));
if (f == NULL)
{
f = newNode (decl_funccall);
- f->funccallF.function = c;
- f->funccallF.args = n;
- f->funccallF.type = NULL;
+ f->funccallF.function = static_cast<decl_node__opaque> (c);
+ f->funccallF.args = static_cast<decl_node__opaque> (n);
+ f->funccallF.type = static_cast<decl_node__opaque> (decl_getType (c));
initPair (&f->funccallF.funccallComment);
+ initNodeOpaqueState (f);
}
- return f;
+ return static_cast<decl_node> (f);
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" decl_node decl_makeStatementSequence (void)
{
- decl_node n;
+ decl_node__opaque n;
n = newNode (decl_stmtseq);
n->stmtF.statements = Indexing_InitIndex (1);
- return n;
+ return static_cast<decl_node> (n);
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" bool decl_isStatementSequence (decl_node n)
{
- return n->kind == decl_stmtseq;
+ return static_cast<decl_node__opaque> (n)->kind == decl_stmtseq;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
if (n != NULL)
{
mcDebug_assert (decl_isStatementSequence (s));
- Indexing_PutIndice (s->stmtF.statements, (Indexing_HighIndice (s->stmtF.statements))+1, reinterpret_cast<void *> (n));
- if ((isIntrinsic (n)) && n->intrinsicF.postUnreachable)
+ Indexing_PutIndice (static_cast<decl_node__opaque> (s)->stmtF.statements, (Indexing_HighIndice (static_cast<decl_node__opaque> (s)->stmtF.statements))+1, reinterpret_cast<void *> (n));
+ if ((isIntrinsic (static_cast<decl_node__opaque> (n))) && static_cast<decl_node__opaque> (n)->intrinsicF.postUnreachable)
{
- n->intrinsicF.postUnreachable = false;
- decl_addStatement (s, makeIntrinsicProc (decl_unreachable, 0, NULL));
+ static_cast<decl_node__opaque> (n)->intrinsicF.postUnreachable = false;
+ decl_addStatement (s, static_cast<decl_node> (makeIntrinsicProc (decl_unreachable, 0, static_cast<decl_node__opaque> (NULL))));
}
}
}
b = mcLexBuf_getBodyComment ();
if (b != NULL)
{
- addGenericBody (n, decl_makeCommentS (b));
+ addGenericBody (static_cast<decl_node__opaque> (n), static_cast<decl_node__opaque> (decl_makeCommentS (b)));
}
}
}
a = mcLexBuf_getAfterComment ();
if (a != NULL)
{
- addGenericAfter (n, decl_makeCommentS (a));
+ addGenericAfter (static_cast<decl_node__opaque> (n), static_cast<decl_node__opaque> (decl_makeCommentS (a)));
}
}
}
extern "C" void decl_addIfComments (decl_node n, decl_node body, decl_node after)
{
mcDebug_assert (decl_isIf (n));
- n->ifF.ifComment.after = after;
- n->ifF.ifComment.body = body;
+ static_cast<decl_node__opaque> (n)->ifF.ifComment.after = static_cast<decl_node__opaque> (after);
+ static_cast<decl_node__opaque> (n)->ifF.ifComment.body = static_cast<decl_node__opaque> (body);
}
mcDebug_assert ((decl_isIf (n)) || (decl_isElsif (n)));
if (decl_isIf (n))
{
- n->ifF.elseComment.after = after;
- n->ifF.elseComment.body = body;
+ static_cast<decl_node__opaque> (n)->ifF.elseComment.after = static_cast<decl_node__opaque> (after);
+ static_cast<decl_node__opaque> (n)->ifF.elseComment.body = static_cast<decl_node__opaque> (body);
}
else
{
- n->elsifF.elseComment.after = after;
- n->elsifF.elseComment.body = body;
+ static_cast<decl_node__opaque> (n)->elsifF.elseComment.after = static_cast<decl_node__opaque> (after);
+ static_cast<decl_node__opaque> (n)->elsifF.elseComment.body = static_cast<decl_node__opaque> (body);
}
}
extern "C" void decl_addIfEndComments (decl_node n, decl_node body, decl_node after)
{
mcDebug_assert (decl_isIf (n));
- n->ifF.endComment.after = after;
- n->ifF.endComment.body = body;
+ static_cast<decl_node__opaque> (n)->ifF.endComment.after = static_cast<decl_node__opaque> (after);
+ static_cast<decl_node__opaque> (n)->ifF.endComment.body = static_cast<decl_node__opaque> (body);
}
extern "C" decl_node decl_makeReturn (void)
{
- decl_node type;
- decl_node n;
+ decl_node__opaque type;
+ decl_node__opaque n;
n = newNode (decl_return);
- n->returnF.exp = NULL;
+ n->returnF.exp = static_cast<decl_node__opaque> (NULL);
if (decl_isProcedure (decl_getDeclScope ()))
{
- n->returnF.scope = decl_getDeclScope ();
+ n->returnF.scope = static_cast<decl_node__opaque> (decl_getDeclScope ());
}
else
{
- n->returnF.scope = NULL;
+ n->returnF.scope = static_cast<decl_node__opaque> (NULL);
}
initPair (&n->returnF.returnComment);
- return n;
+ return static_cast<decl_node> (n);
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" bool decl_isReturn (decl_node n)
{
mcDebug_assert (n != NULL);
- return n->kind == decl_return;
+ return static_cast<decl_node__opaque> (n)->kind == decl_return;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" void decl_putReturn (decl_node n, decl_node e)
{
mcDebug_assert (decl_isReturn (n));
- n->returnF.exp = e;
+ static_cast<decl_node__opaque> (n)->returnF.exp = static_cast<decl_node__opaque> (e);
}
extern "C" decl_node decl_makeWhile (void)
{
- decl_node n;
+ decl_node__opaque n;
n = newNode (decl_while);
- n->whileF.expr = NULL;
- n->whileF.statements = NULL;
+ n->whileF.expr = static_cast<decl_node__opaque> (NULL);
+ n->whileF.statements = static_cast<decl_node__opaque> (NULL);
initPair (&n->whileF.doComment);
initPair (&n->whileF.endComment);
- return n;
+ return static_cast<decl_node> (n);
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" void decl_putWhile (decl_node n, decl_node e, decl_node s)
{
mcDebug_assert (decl_isWhile (n));
- n->whileF.expr = e;
- n->whileF.statements = s;
+ static_cast<decl_node__opaque> (n)->whileF.expr = static_cast<decl_node__opaque> (e);
+ static_cast<decl_node__opaque> (n)->whileF.statements = static_cast<decl_node__opaque> (s);
}
extern "C" bool decl_isWhile (decl_node n)
{
- return n->kind == decl_while;
+ return static_cast<decl_node__opaque> (n)->kind == decl_while;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" void decl_addWhileDoComment (decl_node w, decl_node body, decl_node after)
{
mcDebug_assert (decl_isWhile (w));
- w->whileF.doComment.after = after;
- w->whileF.doComment.body = body;
+ static_cast<decl_node__opaque> (w)->whileF.doComment.after = static_cast<decl_node__opaque> (after);
+ static_cast<decl_node__opaque> (w)->whileF.doComment.body = static_cast<decl_node__opaque> (body);
}
extern "C" void decl_addWhileEndComment (decl_node w, decl_node body, decl_node after)
{
mcDebug_assert (decl_isWhile (w));
- w->whileF.endComment.after = after;
- w->whileF.endComment.body = body;
+ static_cast<decl_node__opaque> (w)->whileF.endComment.after = static_cast<decl_node__opaque> (after);
+ static_cast<decl_node__opaque> (w)->whileF.endComment.body = static_cast<decl_node__opaque> (body);
}
extern "C" decl_node decl_makeAssignment (decl_node d, decl_node e)
{
- decl_node n;
+ decl_node__opaque n;
n = newNode (decl_assignment);
- n->assignmentF.des = d;
- n->assignmentF.expr = e;
+ n->assignmentF.des = static_cast<decl_node__opaque> (d);
+ n->assignmentF.expr = static_cast<decl_node__opaque> (e);
initPair (&n->assignmentF.assignComment);
- return n;
+ return static_cast<decl_node> (n);
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" void decl_putBegin (decl_node b, decl_node s)
{
mcDebug_assert (((decl_isImp (b)) || (decl_isProcedure (b))) || (decl_isModule (b)));
- switch (b->kind)
+ switch (static_cast<decl_node__opaque> (b)->kind)
{
case decl_imp:
- b->impF.beginStatements = s;
+ static_cast<decl_node__opaque> (b)->impF.beginStatements = static_cast<decl_node__opaque> (s);
break;
case decl_module:
- b->moduleF.beginStatements = s;
+ static_cast<decl_node__opaque> (b)->moduleF.beginStatements = static_cast<decl_node__opaque> (s);
break;
case decl_procedure:
- b->procedureF.beginStatements = s;
+ static_cast<decl_node__opaque> (b)->procedureF.beginStatements = static_cast<decl_node__opaque> (s);
break;
extern "C" void decl_putFinally (decl_node b, decl_node s)
{
mcDebug_assert (((decl_isImp (b)) || (decl_isProcedure (b))) || (decl_isModule (b)));
- switch (b->kind)
+ switch (static_cast<decl_node__opaque> (b)->kind)
{
case decl_imp:
- b->impF.finallyStatements = s;
+ static_cast<decl_node__opaque> (b)->impF.finallyStatements = static_cast<decl_node__opaque> (s);
break;
case decl_module:
- b->moduleF.finallyStatements = s;
+ static_cast<decl_node__opaque> (b)->moduleF.finallyStatements = static_cast<decl_node__opaque> (s);
break;
extern "C" decl_node decl_makeExit (decl_node l, unsigned int n)
{
- decl_node e;
+ decl_node__opaque e;
mcDebug_assert (decl_isLoop (l));
e = newNode (decl_exit);
- e->exitF.loop = l;
- l->loopF.labelno = n;
- return e;
+ e->exitF.loop = static_cast<decl_node__opaque> (l);
+ static_cast<decl_node__opaque> (l)->loopF.labelno = n;
+ return static_cast<decl_node> (e);
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" bool decl_isExit (decl_node n)
{
mcDebug_assert (n != NULL);
- return n->kind == decl_exit;
+ return static_cast<decl_node__opaque> (n)->kind == decl_exit;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" decl_node decl_makeLoop (void)
{
- decl_node l;
+ decl_node__opaque l;
l = newNode (decl_loop);
- l->loopF.statements = NULL;
+ l->loopF.statements = static_cast<decl_node__opaque> (NULL);
l->loopF.labelno = 0;
- return l;
+ return static_cast<decl_node> (l);
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" bool decl_isLoop (decl_node n)
{
mcDebug_assert (n != NULL);
- return n->kind == decl_loop;
+ return static_cast<decl_node__opaque> (n)->kind == decl_loop;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" void decl_putLoop (decl_node l, decl_node s)
{
mcDebug_assert (decl_isLoop (l));
- l->loopF.statements = s;
+ static_cast<decl_node__opaque> (l)->loopF.statements = static_cast<decl_node__opaque> (s);
}
extern "C" decl_node decl_makeCommentS (mcComment_commentDesc c)
{
- decl_node n;
+ decl_node__opaque n;
if (c == NULL)
{
- return NULL;
+ return static_cast<decl_node> (NULL);
}
else
{
n = newNode (decl_comment);
n->commentF.content = c;
- return n;
+ return static_cast<decl_node> (n);
}
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
extern "C" decl_node decl_makeIf (decl_node e, decl_node s)
{
- decl_node n;
+ decl_node__opaque n;
n = newNode (decl_if);
- n->ifF.expr = e;
- n->ifF.then = s;
- n->ifF.else_ = NULL;
- n->ifF.elsif = NULL;
+ n->ifF.expr = static_cast<decl_node__opaque> (e);
+ n->ifF.then = static_cast<decl_node__opaque> (s);
+ n->ifF.else_ = static_cast<decl_node__opaque> (NULL);
+ n->ifF.elsif = static_cast<decl_node__opaque> (NULL);
initPair (&n->ifF.ifComment);
initPair (&n->ifF.elseComment);
initPair (&n->ifF.endComment);
- return n;
+ return static_cast<decl_node> (n);
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" bool decl_isIf (decl_node n)
{
- return n->kind == decl_if;
+ return static_cast<decl_node__opaque> (n)->kind == decl_if;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" decl_node decl_makeElsif (decl_node i, decl_node e, decl_node s)
{
- decl_node n;
+ decl_node__opaque n;
n = newNode (decl_elsif);
- n->elsifF.expr = e;
- n->elsifF.then = s;
- n->elsifF.elsif = NULL;
- n->elsifF.else_ = NULL;
+ n->elsifF.expr = static_cast<decl_node__opaque> (e);
+ n->elsifF.then = static_cast<decl_node__opaque> (s);
+ n->elsifF.elsif = static_cast<decl_node__opaque> (NULL);
+ n->elsifF.else_ = static_cast<decl_node__opaque> (NULL);
initPair (&n->elsifF.elseComment);
mcDebug_assert ((decl_isIf (i)) || (decl_isElsif (i)));
if (decl_isIf (i))
{
- i->ifF.elsif = n;
- mcDebug_assert (i->ifF.else_ == NULL);
+ static_cast<decl_node__opaque> (i)->ifF.elsif = n;
+ mcDebug_assert (static_cast<decl_node__opaque> (i)->ifF.else_ == NULL);
}
else
{
- i->elsifF.elsif = n;
- mcDebug_assert (i->elsifF.else_ == NULL);
+ static_cast<decl_node__opaque> (i)->elsifF.elsif = n;
+ mcDebug_assert (static_cast<decl_node__opaque> (i)->elsifF.else_ == NULL);
}
- return n;
+ return static_cast<decl_node> (n);
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" bool decl_isElsif (decl_node n)
{
- return n->kind == decl_elsif;
+ return static_cast<decl_node__opaque> (n)->kind == decl_elsif;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
mcDebug_assert ((decl_isIf (i)) || (decl_isElsif (i)));
if (decl_isIf (i))
{
- mcDebug_assert (i->ifF.elsif == NULL);
- mcDebug_assert (i->ifF.else_ == NULL);
- i->ifF.else_ = s;
+ mcDebug_assert (static_cast<decl_node__opaque> (i)->ifF.elsif == NULL);
+ mcDebug_assert (static_cast<decl_node__opaque> (i)->ifF.else_ == NULL);
+ static_cast<decl_node__opaque> (i)->ifF.else_ = static_cast<decl_node__opaque> (s);
}
else
{
- mcDebug_assert (i->elsifF.elsif == NULL);
- mcDebug_assert (i->elsifF.else_ == NULL);
- i->elsifF.else_ = s;
+ mcDebug_assert (static_cast<decl_node__opaque> (i)->elsifF.elsif == NULL);
+ mcDebug_assert (static_cast<decl_node__opaque> (i)->elsifF.else_ == NULL);
+ static_cast<decl_node__opaque> (i)->elsifF.else_ = static_cast<decl_node__opaque> (s);
}
}
extern "C" decl_node decl_makeFor (void)
{
- decl_node n;
+ decl_node__opaque n;
n = newNode (decl_for);
- n->forF.des = NULL;
- n->forF.start = NULL;
- n->forF.end = NULL;
- n->forF.increment = NULL;
- n->forF.statements = NULL;
- return n;
+ n->forF.des = static_cast<decl_node__opaque> (NULL);
+ n->forF.start = static_cast<decl_node__opaque> (NULL);
+ n->forF.end = static_cast<decl_node__opaque> (NULL);
+ n->forF.increment = static_cast<decl_node__opaque> (NULL);
+ n->forF.statements = static_cast<decl_node__opaque> (NULL);
+ return static_cast<decl_node> (n);
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" bool decl_isFor (decl_node n)
{
mcDebug_assert (n != NULL);
- return n->kind == decl_for;
+ return static_cast<decl_node__opaque> (n)->kind == decl_for;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" void decl_putFor (decl_node f, decl_node i, decl_node s, decl_node e, decl_node b, decl_node sq)
{
mcDebug_assert (decl_isFor (f));
- f->forF.des = i;
- f->forF.start = s;
- f->forF.end = e;
- f->forF.increment = b;
- f->forF.statements = sq;
+ static_cast<decl_node__opaque> (f)->forF.des = static_cast<decl_node__opaque> (i);
+ static_cast<decl_node__opaque> (f)->forF.start = static_cast<decl_node__opaque> (s);
+ static_cast<decl_node__opaque> (f)->forF.end = static_cast<decl_node__opaque> (e);
+ static_cast<decl_node__opaque> (f)->forF.increment = static_cast<decl_node__opaque> (b);
+ static_cast<decl_node__opaque> (f)->forF.statements = static_cast<decl_node__opaque> (sq);
}
extern "C" decl_node decl_makeRepeat (void)
{
- decl_node n;
+ decl_node__opaque n;
n = newNode (decl_repeat);
- n->repeatF.expr = NULL;
- n->repeatF.statements = NULL;
+ n->repeatF.expr = static_cast<decl_node__opaque> (NULL);
+ n->repeatF.statements = static_cast<decl_node__opaque> (NULL);
initPair (&n->repeatF.repeatComment);
initPair (&n->repeatF.untilComment);
- return n;
+ return static_cast<decl_node> (n);
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" bool decl_isRepeat (decl_node n)
{
mcDebug_assert (n != NULL);
- return n->kind == decl_repeat;
+ return static_cast<decl_node__opaque> (n)->kind == decl_repeat;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" void decl_putRepeat (decl_node n, decl_node s, decl_node e)
{
- n->repeatF.expr = e;
- n->repeatF.statements = s;
+ static_cast<decl_node__opaque> (n)->repeatF.expr = static_cast<decl_node__opaque> (e);
+ static_cast<decl_node__opaque> (n)->repeatF.statements = static_cast<decl_node__opaque> (s);
}
extern "C" void decl_addRepeatComment (decl_node r, decl_node body, decl_node after)
{
mcDebug_assert (decl_isRepeat (r));
- r->repeatF.repeatComment.after = after;
- r->repeatF.repeatComment.body = body;
+ static_cast<decl_node__opaque> (r)->repeatF.repeatComment.after = static_cast<decl_node__opaque> (after);
+ static_cast<decl_node__opaque> (r)->repeatF.repeatComment.body = static_cast<decl_node__opaque> (body);
}
extern "C" void decl_addUntilComment (decl_node r, decl_node body, decl_node after)
{
mcDebug_assert (decl_isRepeat (r));
- r->repeatF.untilComment.after = after;
- r->repeatF.untilComment.body = body;
+ static_cast<decl_node__opaque> (r)->repeatF.untilComment.after = static_cast<decl_node__opaque> (after);
+ static_cast<decl_node__opaque> (r)->repeatF.untilComment.body = static_cast<decl_node__opaque> (body);
}
extern "C" decl_node decl_makeCase (void)
{
- decl_node n;
+ decl_node__opaque n;
n = newNode (decl_case);
- n->caseF.expression = NULL;
+ n->caseF.expression = static_cast<decl_node__opaque> (NULL);
n->caseF.caseLabelList = Indexing_InitIndex (1);
- n->caseF.else_ = NULL;
- return n;
+ n->caseF.else_ = static_cast<decl_node__opaque> (NULL);
+ return static_cast<decl_node> (n);
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" bool decl_isCase (decl_node n)
{
mcDebug_assert (n != NULL);
- return n->kind == decl_case;
+ return static_cast<decl_node__opaque> (n)->kind == decl_case;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" decl_node decl_putCaseExpression (decl_node n, decl_node e)
{
mcDebug_assert (decl_isCase (n));
- n->caseF.expression = e;
+ static_cast<decl_node__opaque> (n)->caseF.expression = static_cast<decl_node__opaque> (e);
return n;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
extern "C" decl_node decl_putCaseElse (decl_node n, decl_node e)
{
mcDebug_assert (decl_isCase (n));
- n->caseF.else_ = e;
+ static_cast<decl_node__opaque> (n)->caseF.else_ = static_cast<decl_node__opaque> (e);
return n;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
{
mcDebug_assert (decl_isCase (n));
mcDebug_assert (decl_isCaseList (l));
- Indexing_IncludeIndiceIntoIndex (n->caseF.caseLabelList, reinterpret_cast<void *> (decl_makeCaseLabelList (l, s)));
+ Indexing_IncludeIndiceIntoIndex (static_cast<decl_node__opaque> (n)->caseF.caseLabelList, reinterpret_cast<void *> (decl_makeCaseLabelList (l, s)));
return n;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
extern "C" decl_node decl_makeCaseLabelList (decl_node l, decl_node s)
{
- decl_node n;
+ decl_node__opaque n;
n = newNode (decl_caselabellist);
- n->caselabellistF.caseList = l;
- n->caselabellistF.statements = s;
- return n;
+ n->caselabellistF.caseList = static_cast<decl_node__opaque> (l);
+ n->caselabellistF.statements = static_cast<decl_node__opaque> (s);
+ return static_cast<decl_node> (n);
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" bool decl_isCaseLabelList (decl_node n)
{
mcDebug_assert (n != NULL);
- return n->kind == decl_caselabellist;
+ return static_cast<decl_node__opaque> (n)->kind == decl_caselabellist;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" decl_node decl_makeCaseList (void)
{
- decl_node n;
+ decl_node__opaque n;
n = newNode (decl_caselist);
n->caselistF.rangePairs = Indexing_InitIndex (1);
- return n;
+ return static_cast<decl_node> (n);
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" bool decl_isCaseList (decl_node n)
{
mcDebug_assert (n != NULL);
- return n->kind == decl_caselist;
+ return static_cast<decl_node__opaque> (n)->kind == decl_caselist;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" decl_node decl_putCaseRange (decl_node n, decl_node lo, decl_node hi)
{
mcDebug_assert (decl_isCaseList (n));
- Indexing_IncludeIndiceIntoIndex (n->caselistF.rangePairs, reinterpret_cast<void *> (decl_makeRange (lo, hi)));
+ Indexing_IncludeIndiceIntoIndex (static_cast<decl_node__opaque> (n)->caselistF.rangePairs, reinterpret_cast<void *> (decl_makeRange (lo, hi)));
return n;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
extern "C" decl_node decl_makeRange (decl_node lo, decl_node hi)
{
- decl_node n;
+ decl_node__opaque n;
n = newNode (decl_range);
- n->rangeF.lo = lo;
- n->rangeF.hi = hi;
- return n;
+ n->rangeF.lo = static_cast<decl_node__opaque> (lo);
+ n->rangeF.hi = static_cast<decl_node__opaque> (hi);
+ return static_cast<decl_node> (n);
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
extern "C" bool decl_isRange (decl_node n)
{
mcDebug_assert (n != NULL);
- return n->kind == decl_range;
+ return static_cast<decl_node__opaque> (n)->kind == decl_range;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
}
{
mcDebug_assert (n != NULL);
mcDebug_assert (decl_isProcedure (n));
- if (n->procedureF.noreturnused && (n->procedureF.noreturn != value))
+ if (static_cast<decl_node__opaque> (n)->procedureF.noreturnused && (static_cast<decl_node__opaque> (n)->procedureF.noreturn != value))
{
mcMetaError_metaError1 ((const char *) "{%1DMad} definition module and implementation module have different <* noreturn *> attributes", 93, (const unsigned char *) &n, (sizeof (n)-1));
}
- n->procedureF.noreturn = value;
- n->procedureF.noreturnused = true;
+ static_cast<decl_node__opaque> (n)->procedureF.noreturn = value;
+ static_cast<decl_node__opaque> (n)->procedureF.noreturnused = true;
}
{
if (n == NULL)
{
- return NULL;
+ return static_cast<decl_node> (NULL);
}
else
{
- return doDupExpr (n);
+ return static_cast<decl_node> (doDupExpr (static_cast<decl_node__opaque> (n)));
}
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
switch (lang)
{
case decl_ansiC:
- outC (p, decl_getMainModule ());
+ outC (p, static_cast<decl_node__opaque> (decl_getMainModule ()));
break;
case decl_ansiCP:
- outC (p, decl_getMainModule ());
+ outC (p, static_cast<decl_node__opaque> (decl_getMainModule ()));
break;
case decl_pim4:
- outM2 (p, decl_getMainModule ());
+ outM2 (p, static_cast<decl_node__opaque> (decl_getMainModule ()));
break;
closeOutput ();
}
-extern "C" void _M2_decl_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
+extern "C" void _M2_decl_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[])
{
init ();
}
-extern "C" void _M2_decl_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
+extern "C" void _M2_decl_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[])
{
}