| 1 |
/* m2type.h header file for m2type.cc. |
| 2 |
|
| 3 |
Copyright (C) 2012-2025 Free Software Foundation, Inc. |
| 4 |
Contributed by Gaius Mulley <[email protected]>. |
| 5 |
|
| 6 |
This file is part of GNU Modula-2. |
| 7 |
|
| 8 |
GNU Modula-2 is free software; you can redistribute it and/or modify |
| 9 |
it under the terms of the GNU General Public License as published by |
| 10 |
the Free Software Foundation; either version 3, or (at your option) |
| 11 |
any later version. |
| 12 |
|
| 13 |
GNU Modula-2 is distributed in the hope that it will be useful, but |
| 14 |
WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 |
General Public License for more details. |
| 17 |
|
| 18 |
You should have received a copy of the GNU General Public License |
| 19 |
along with GNU Modula-2; see the file COPYING3. If not see |
| 20 |
<http://www.gnu.org/licenses/>. */ |
| 21 |
|
| 22 |
#if !defined(m2type_h) |
| 23 |
#define m2type_h |
| 24 |
#if defined(m2type_c) |
| 25 |
#if defined(__GNUG__) |
| 26 |
#define EXTERN extern "C" |
| 27 |
#else /* !__GNUG__. */ |
| 28 |
#define EXTERN |
| 29 |
#endif /* !__GNUG__. */ |
| 30 |
#else /* !m2type_c. */ |
| 31 |
#if defined(__GNUG__) |
| 32 |
#define EXTERN extern "C" |
| 33 |
#else /* !__GNUG__. */ |
| 34 |
#define EXTERN extern |
| 35 |
#endif /* !__GNUG__. */ |
| 36 |
#endif /* !m2type_c. */ |
| 37 |
|
| 38 |
#include <stdbool.h> |
| 39 |
|
| 40 |
typedef void *m2type_Constructor; |
| 41 |
|
| 42 |
EXTERN bool m2type_ValueInTypeRange (tree type, tree value); |
| 43 |
EXTERN bool m2type_ExceedsTypeRange (tree type, tree low, tree high); |
| 44 |
EXTERN bool m2type_ValueOutOfTypeRange (tree type, tree value); |
| 45 |
EXTERN bool m2type_WithinTypeRange (tree type, tree low, tree high); |
| 46 |
EXTERN tree m2type_BuildStartArrayType (tree index_type, tree elt_type, |
| 47 |
int type); |
| 48 |
EXTERN void m2type_PutArrayType (tree array, tree type); |
| 49 |
EXTERN tree m2type_BuildEndArrayType (tree arraytype, tree elementtype, |
| 50 |
tree indextype, int type); |
| 51 |
EXTERN tree m2type_GetArrayNoOfElements (location_t location, tree arraytype); |
| 52 |
EXTERN tree m2type_BuildArrayIndexType (tree low, tree high); |
| 53 |
EXTERN void m2type_GarbageCollect (void); |
| 54 |
EXTERN void m2type_MarkFunctionReferenced (tree f); |
| 55 |
EXTERN void m2type_AddStatement (location_t location, tree t); |
| 56 |
EXTERN tree m2type_BuildNumberOfArrayElements (location_t location, |
| 57 |
tree arrayType); |
| 58 |
EXTERN tree m2type_BuildPackedFieldRecord (location_t location, char *name, |
| 59 |
tree fieldtype); |
| 60 |
EXTERN tree m2type_SetRecordFieldOffset (tree field, tree byteOffset, |
| 61 |
tree bitOffset, tree fieldtype, |
| 62 |
tree nbits); |
| 63 |
EXTERN tree m2type_SetTypePacked (tree node); |
| 64 |
EXTERN tree m2type_SetDeclPacked (tree node); |
| 65 |
EXTERN tree m2type_SetAlignment (tree node, tree align); |
| 66 |
EXTERN tree m2type_BuildEndRecord (location_t location, tree record, |
| 67 |
tree fieldlist, bool isPacked); |
| 68 |
EXTERN tree m2type_AddStringToTreeList (tree list, tree string); |
| 69 |
EXTERN tree m2type_ChainOnParamValue (tree list, tree name, tree str, |
| 70 |
tree value); |
| 71 |
EXTERN tree m2type_ChainOn (tree t1, tree t2); |
| 72 |
EXTERN tree m2type_BuildFieldRecord (location_t location, char *name, |
| 73 |
tree type); |
| 74 |
EXTERN tree m2type_BuildStartFieldRecord (location_t location, char *name, |
| 75 |
tree type); |
| 76 |
EXTERN tree m2type_BuildEndFieldVarient (location_t location, |
| 77 |
tree varientField, tree varientList, |
| 78 |
bool isPacked); |
| 79 |
EXTERN tree m2type_BuildStartFieldVarient (location_t location, char *name); |
| 80 |
EXTERN tree m2type_BuildEndVarient (location_t location, tree varientField, |
| 81 |
tree varientList, bool isPacked); |
| 82 |
EXTERN tree m2type_BuildStartVarient (location_t location, char *name); |
| 83 |
EXTERN tree m2type_BuildStartUnion (location_t location, char *name); |
| 84 |
EXTERN tree m2type_BuildStartRecord (location_t location, char *name); |
| 85 |
EXTERN tree m2type_RealToTree (char *name); |
| 86 |
EXTERN tree m2type_BuildArrayStringConstructor (location_t location, |
| 87 |
tree arrayType, tree str, |
| 88 |
tree length); |
| 89 |
|
| 90 |
EXTERN tree m2type_GetM2CharType (void); |
| 91 |
EXTERN tree m2type_GetM2IntegerType (void); |
| 92 |
EXTERN tree m2type_GetM2ShortRealType (void); |
| 93 |
EXTERN tree m2type_GetM2RealType (void); |
| 94 |
EXTERN tree m2type_GetM2LongRealType (void); |
| 95 |
EXTERN tree m2type_GetM2LongIntType (void); |
| 96 |
EXTERN tree m2type_GetM2LongCardType (void); |
| 97 |
EXTERN tree m2type_GetM2ShortIntType (void); |
| 98 |
EXTERN tree m2type_GetShortIntType (void); |
| 99 |
EXTERN tree m2type_GetM2ShortCardType (void); |
| 100 |
EXTERN tree m2type_GetShortCardType (void); |
| 101 |
EXTERN tree m2type_GetISOWordType (void); |
| 102 |
EXTERN tree m2type_GetISOByteType (void); |
| 103 |
EXTERN tree m2type_GetISOLocType (void); |
| 104 |
EXTERN tree m2type_GetM2Integer8 (void); |
| 105 |
EXTERN tree m2type_GetM2Integer16 (void); |
| 106 |
EXTERN tree m2type_GetM2Integer32 (void); |
| 107 |
EXTERN tree m2type_GetM2Integer64 (void); |
| 108 |
EXTERN tree m2type_GetM2Cardinal8 (void); |
| 109 |
EXTERN tree m2type_GetM2Cardinal16 (void); |
| 110 |
EXTERN tree m2type_GetM2Cardinal32 (void); |
| 111 |
EXTERN tree m2type_GetM2Cardinal64 (void); |
| 112 |
EXTERN tree m2type_GetM2Word16 (void); |
| 113 |
EXTERN tree m2type_GetM2Word32 (void); |
| 114 |
EXTERN tree m2type_GetM2Word64 (void); |
| 115 |
EXTERN tree m2type_GetM2Bitset8 (void); |
| 116 |
EXTERN tree m2type_GetM2Bitset16 (void); |
| 117 |
EXTERN tree m2type_GetM2Bitset32 (void); |
| 118 |
EXTERN tree m2type_GetM2Real32 (void); |
| 119 |
EXTERN tree m2type_GetM2Real64 (void); |
| 120 |
EXTERN tree m2type_GetM2Real96 (void); |
| 121 |
EXTERN tree m2type_GetM2Real128 (void); |
| 122 |
EXTERN tree m2type_GetM2Complex32 (void); |
| 123 |
EXTERN tree m2type_GetM2Complex64 (void); |
| 124 |
EXTERN tree m2type_GetM2Complex96 (void); |
| 125 |
EXTERN tree m2type_GetM2Complex128 (void); |
| 126 |
EXTERN tree m2type_GetM2ShortComplexType (void); |
| 127 |
EXTERN tree m2type_GetM2LongComplexType (void); |
| 128 |
EXTERN tree m2type_GetM2ComplexType (void); |
| 129 |
EXTERN tree m2type_GetShortCardType (void); |
| 130 |
EXTERN tree m2type_GetProcType (void); |
| 131 |
EXTERN tree m2type_GetCSizeTType (void); |
| 132 |
EXTERN tree m2type_GetCSSizeTType (void); |
| 133 |
EXTERN tree m2type_GetCOffTType (void); |
| 134 |
EXTERN tree m2type_GetM2CType (void); |
| 135 |
|
| 136 |
EXTERN tree m2type_GetBitsetType (void); |
| 137 |
EXTERN tree m2type_GetM2CardinalType (void); |
| 138 |
EXTERN tree m2type_GetWordType (void); |
| 139 |
EXTERN tree m2type_GetIntegerType (void); |
| 140 |
EXTERN tree m2type_GetCardinalType (void); |
| 141 |
EXTERN tree m2type_GetPointerType (void); |
| 142 |
EXTERN tree m2type_GetLongIntType (void); |
| 143 |
EXTERN tree m2type_GetShortRealType (void); |
| 144 |
EXTERN tree m2type_GetLongRealType (void); |
| 145 |
EXTERN tree m2type_GetRealType (void); |
| 146 |
EXTERN tree m2type_GetBitnumType (void); |
| 147 |
EXTERN tree m2type_GetVoidType (void); |
| 148 |
EXTERN tree m2type_GetByteType (void); |
| 149 |
EXTERN tree m2type_GetCharType (void); |
| 150 |
EXTERN tree m2type_GetPackedBooleanType (void); |
| 151 |
EXTERN tree m2type_GetBooleanTrue (void); |
| 152 |
EXTERN tree m2type_GetBooleanFalse (void); |
| 153 |
EXTERN tree m2type_GetBooleanType (void); |
| 154 |
EXTERN tree m2type_BuildSmallestTypeRange (location_t location, tree low, |
| 155 |
tree high); |
| 156 |
EXTERN tree m2type_BuildSetTypeFromSubrange (location_t location, char *name, |
| 157 |
tree subrangeType, tree lowval, |
| 158 |
tree highval, bool ispacked); |
| 159 |
EXTERN int m2type_GetBitsPerBitset (void); |
| 160 |
EXTERN tree m2type_GetM2RType (void); |
| 161 |
EXTERN tree m2type_GetM2ZType (void); |
| 162 |
|
| 163 |
EXTERN tree m2type_DeclareKnownType (location_t location, char *name, |
| 164 |
tree type); |
| 165 |
EXTERN tree m2type_GetTreeType (tree type); |
| 166 |
EXTERN tree m2type_BuildEndFunctionType (tree func, tree type, |
| 167 |
bool uses_varargs); |
| 168 |
EXTERN tree m2type_BuildStartFunctionType ( |
| 169 |
location_t location ATTRIBUTE_UNUSED, char *name ATTRIBUTE_UNUSED); |
| 170 |
EXTERN void m2type_InitFunctionTypeParameters (void); |
| 171 |
EXTERN tree m2type_BuildVariableArrayAndDeclare (location_t location, |
| 172 |
tree elementtype, tree high, |
| 173 |
char *name, tree scope); |
| 174 |
EXTERN void m2type_InitSystemTypes (location_t location, int loc); |
| 175 |
EXTERN void m2type_InitBaseTypes (location_t location); |
| 176 |
EXTERN tree m2type_BuildStartType (location_t location, char *name, tree type); |
| 177 |
EXTERN tree m2type_BuildEndType (location_t location, tree type); |
| 178 |
EXTERN tree m2type_GetDefaultType (location_t location, char *name, tree type); |
| 179 |
EXTERN tree m2type_GetMinFrom (location_t location, tree type); |
| 180 |
EXTERN tree m2type_GetMaxFrom (location_t location, tree type); |
| 181 |
EXTERN void m2type_BuildTypeDeclaration (location_t location, tree type); |
| 182 |
EXTERN tree m2type_BuildStartEnumeration (location_t location, char *name, |
| 183 |
bool ispacked); |
| 184 |
EXTERN tree m2type_BuildEndEnumeration (location_t location, tree enumtype, |
| 185 |
tree enumvalues); |
| 186 |
EXTERN tree m2type_BuildEnumerator (location_t location, char *name, |
| 187 |
tree value, tree *enumvalues); |
| 188 |
EXTERN tree m2type_BuildPointerType (tree totype); |
| 189 |
EXTERN tree m2type_BuildConstPointerType (tree totype); |
| 190 |
EXTERN tree m2type_BuildSetType (location_t location, char *name, tree type, |
| 191 |
tree lowval, tree highval, bool ispacked); |
| 192 |
EXTERN void *m2type_BuildStartSetConstructor (tree type); |
| 193 |
EXTERN void m2type_BuildSetConstructorElement (void *p, tree value); |
| 194 |
EXTERN tree m2type_BuildEndSetConstructor (void *p); |
| 195 |
EXTERN void *m2type_BuildStartRecordConstructor (tree type); |
| 196 |
EXTERN tree m2type_BuildEndRecordConstructor (void *p); |
| 197 |
EXTERN void m2type_BuildRecordConstructorElement (void *p, tree value); |
| 198 |
EXTERN void *m2type_BuildStartArrayConstructor (tree type); |
| 199 |
EXTERN tree m2type_BuildEndArrayConstructor (void *p); |
| 200 |
EXTERN void m2type_BuildArrayConstructorElement (void *p, tree value, |
| 201 |
tree indice); |
| 202 |
EXTERN tree m2type_BuildCharConstant (location_t location, const char *string); |
| 203 |
EXTERN tree m2type_BuildCharConstantChar (location_t location, char ch); |
| 204 |
EXTERN tree m2type_BuildSubrangeType (location_t location, char *name, |
| 205 |
tree type, tree lowval, tree highval); |
| 206 |
EXTERN tree m2type_gm2_unsigned_type (tree type); |
| 207 |
EXTERN tree m2type_gm2_signed_type (tree type); |
| 208 |
EXTERN tree m2type_gm2_signed_or_unsigned_type (int unsignedp, tree type); |
| 209 |
EXTERN tree m2type_gm2_type_for_size (unsigned int bits, int unsignedp); |
| 210 |
EXTERN tree m2type_BuildProcTypeParameterDeclaration (location_t location, |
| 211 |
tree type, |
| 212 |
bool isreference); |
| 213 |
EXTERN bool m2type_IsAddress (tree type); |
| 214 |
EXTERN tree m2type_GetCardinalAddressType (void); |
| 215 |
EXTERN bool m2type_SameRealType (tree a, tree b); |
| 216 |
EXTERN bool m2type_IsGccStrictTypeEquivalent (tree left, tree right); |
| 217 |
|
| 218 |
#undef EXTERN |
| 219 |
#endif /* m2type_h */ |