1 /** 2 * Global variables for PARSER 3 * 4 * Compiler implementation of the 5 * $(LINK2 https://www.dlang.org, D programming language). 6 * 7 * Copyright: Copyright (C) 1985-1998 by Symantec 8 * Copyright (C) 2000-2023 by The D Language Foundation, All Rights Reserved 9 * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) 10 * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 11 * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/backend/var.d, backend/var.d) 12 */ 13 14 module dmd.backend.var; 15 16 import core.stdc.stdio; 17 18 import dmd.backend.cc; 19 import dmd.backend.cdef; 20 import dmd.backend.code; 21 import dmd.backend.dlist; 22 import dmd.backend.goh; 23 import dmd.backend.obj; 24 import dmd.backend.oper; 25 import dmd.backend.symtab; 26 import dmd.backend.ty; 27 import dmd.backend.type; 28 29 version (SCPP) 30 { 31 import parser; 32 import phstring; 33 } 34 version (HTOD) 35 { 36 import parser; 37 import phstring; 38 } 39 40 extern (C++): 41 42 nothrow: 43 @safe: 44 45 __gshared: 46 47 /* Global flags: 48 */ 49 50 char PARSER = 0; // indicate we're in the parser 51 char OPTIMIZER = 0; // indicate we're in the optimizer 52 int structalign; /* alignment for members of structures */ 53 char dbcs = 0; // current double byte character set 54 55 int TYptrdiff = TYint; 56 int TYsize = TYuint; 57 int TYsize_t = TYuint; 58 int TYaarray = TYnptr; 59 int TYdelegate = TYllong; 60 int TYdarray = TYullong; 61 62 char debuga=0,debugb=0,debugc=0,debugd=0,debuge=0,debugf=0,debugr=0,debugs=0,debugt=0,debugu=0,debugw=0,debugx=0,debugy=0; 63 64 version (MARS) { } else 65 { 66 linkage_t linkage; 67 int linkage_spec = 0; /* using the default */ 68 69 /* Function types */ 70 /* LINK_MAXDIM = C,C++,Pascal,FORTRAN,syscall,stdcall,Mars */ 71 static if (MEMMODELS == 1) 72 { 73 tym_t[LINK_MAXDIM] functypetab = 74 [ 75 TYnfunc, 76 TYnpfunc, 77 TYnpfunc, 78 TYnfunc, 79 ]; 80 } 81 else 82 { 83 tym_t[MEMMODELS][LINK_MAXDIM] functypetab = 84 [ 85 [ TYnfunc, TYffunc, TYnfunc, TYffunc, TYffunc ], 86 [ TYnfunc, TYffunc, TYnfunc, TYffunc, TYffunc ], 87 [ TYnpfunc, TYfpfunc, TYnpfunc, TYfpfunc, TYfpfunc ], 88 [ TYnpfunc, TYfpfunc, TYnpfunc, TYfpfunc, TYfpfunc ], 89 [ TYnfunc, TYffunc, TYnfunc, TYffunc, TYffunc ], 90 [ TYnsfunc, TYfsfunc, TYnsfunc, TYfsfunc, TYfsfunc ], 91 [ TYjfunc, TYfpfunc, TYnpfunc, TYfpfunc, TYfpfunc ], 92 ]; 93 } 94 95 /* Function mangling */ 96 /* LINK_MAXDIM = C,C++,Pascal,FORTRAN,syscall,stdcall */ 97 mangle_t[LINK_MAXDIM] funcmangletab = 98 [ 99 mTYman_c, 100 mTYman_cpp, 101 mTYman_pas, 102 mTYman_for, 103 mTYman_sys, 104 mTYman_std, 105 mTYman_d, 106 ]; 107 108 /* Name mangling for global variables */ 109 mangle_t[LINK_MAXDIM] varmangletab = 110 [ 111 mTYman_c, 112 mTYman_cpp, 113 mTYman_pas,mTYman_for,mTYman_sys,mTYman_std,mTYman_d 114 ]; 115 } 116 117 /* File variables: */ 118 119 char *argv0; // argv[0] (program name) 120 extern (C) 121 { 122 FILE *fdep = null; // dependency file stream pointer 123 FILE *flst = null; // list file stream pointer 124 FILE *fin = null; // input file 125 } 126 127 // htod 128 char *fdmodulename = null; 129 extern (C) FILE *fdmodule = null; 130 131 char* foutdir = null, // directory to place output files in 132 finname = null, 133 foutname = null, 134 fsymname = null, 135 fphreadname = null, 136 ftdbname = null, 137 fdepname = null, 138 flstname = null; /* the filename strings */ 139 140 version (SCPP) 141 { 142 phstring_t fdeplist; 143 phstring_t pathlist; // include paths 144 } 145 version (HTOD) 146 { 147 phstring_t fdeplist; 148 phstring_t pathlist; // include paths 149 } 150 151 int pathsysi; // -isystem= index 152 list_t headers; /* pre-include files */ 153 154 /* Data from lexical analyzer: */ 155 156 uint idhash = 0; // hash value of identifier 157 int xc = ' '; // character last read 158 159 /* Data for pragma processor: 160 */ 161 162 int colnumber = 0; /* current column number */ 163 164 /* Other variables: */ 165 166 int level = 0; /* declaration level */ 167 /* 0: top level */ 168 /* 1: function parameter declarations */ 169 /* 2: function local declarations */ 170 /* 3+: compound statement decls */ 171 172 param_t *paramlst = null; /* function parameter list */ 173 tym_t pointertype = TYnptr; /* default data pointer type */ 174 175 /* From util.c */ 176 177 /***************************** 178 * SCxxxx types. 179 */ 180 181 char[SCMAX] sytab = 182 [ 183 /* unde */ SCEXP|SCKEP|SCSCT, /* undefined */ 184 /* auto */ SCEXP|SCSS|SCRD , /* automatic (stack) */ 185 /* static */ SCEXP|SCKEP|SCSCT, /* statically allocated */ 186 /* thread */ SCEXP|SCKEP , /* thread local */ 187 /* extern */ SCEXP|SCKEP|SCSCT, /* external */ 188 /* register */ SCEXP|SCSS|SCRD , /* registered variable */ 189 /* pseudo */ SCEXP , /* pseudo register variable */ 190 /* global */ SCEXP|SCKEP|SCSCT, /* top level global definition */ 191 /* comdat */ SCEXP|SCKEP|SCSCT, /* initialized common block */ 192 /* parameter */SCEXP|SCSS , /* function parameter */ 193 /* regpar */ SCEXP|SCSS , /* function register parameter */ 194 /* fastpar */ SCEXP|SCSS , /* function parameter passed in register */ 195 /* shadowreg */SCEXP|SCSS , /* function parameter passed in register, shadowed on stack */ 196 /* typedef */ 0 , /* type definition */ 197 /* explicit */ 0 , /* explicit */ 198 /* mutable */ 0 , /* mutable */ 199 /* label */ 0 , /* goto label */ 200 /* struct */ SCKEP , /* struct/class/union tag name */ 201 /* enum */ 0 , /* enum tag name */ 202 /* field */ SCEXP|SCKEP , /* bit field of struct or union */ 203 /* const */ SCEXP|SCSCT , /* constant integer */ 204 /* member */ SCEXP|SCKEP|SCSCT, /* member of struct or union */ 205 /* anon */ 0 , /* member of anonymous union */ 206 /* inline */ SCEXP|SCKEP , /* for inline functions */ 207 /* sinline */ SCEXP|SCKEP , /* for static inline functions */ 208 /* einline */ SCEXP|SCKEP , /* for extern inline functions */ 209 /* overload */ SCEXP , /* for overloaded function names */ 210 /* friend */ 0 , /* friend of a class */ 211 /* virtual */ 0 , /* virtual function */ 212 /* locstat */ SCEXP|SCSCT , /* static, but local to a function */ 213 /* template */ 0 , /* class template */ 214 /* functempl */0 , /* function template */ 215 /* ftexpspec */0 , /* function template explicit specialization */ 216 /* linkage */ 0 , /* function linkage symbol */ 217 /* public */ SCEXP|SCKEP|SCSCT, /* generate a pubdef for this */ 218 /* comdef */ SCEXP|SCKEP|SCSCT, /* uninitialized common block */ 219 /* bprel */ SCEXP|SCSS , /* variable at fixed offset from frame pointer */ 220 /* namespace */0 , /* namespace */ 221 /* alias */ 0 , /* alias to another symbol */ 222 /* funcalias */0 , /* alias to another function symbol */ 223 /* memalias */ 0 , /* alias to base class member */ 224 /* stack */ SCEXP|SCSS , /* offset from stack pointer (not frame pointer) */ 225 /* adl */ 0 , /* list of ADL symbols for overloading */ 226 ]; 227 228 extern (C) int controlc_saw = 0; /* a control C was seen */ 229 symtab_t globsym; /* global symbol table */ 230 Pstate pstate; // parser state 231 Cstate cstate; // compiler state 232 233 uint numcse; // number of common subexpressions 234 235 GlobalOptimizer go; 236 237 /* From debug.c */ 238 const(char)*[32] regstring = ["AX","CX","DX","BX","SP","BP","SI","DI", 239 "R8","R9","R10","R11","R12","R13","R14","R15", 240 "XMM0","XMM1","XMM2","XMM3","XMM4","XMM5","XMM6","XMM7", 241 "ES","PSW","STACK","ST0","ST01","NOREG","RMload","RMstore"]; 242 243 /* From nwc.c */ 244 245 type *chartype; /* default 'char' type */ 246 247 Obj objmod = null; 248 249 __gshared uint[256] tytab = tytab_init; 250 extern (D) private enum tytab_init = 251 () { 252 uint[256] tab; 253 foreach (i; TXptr) { tab[i] |= TYFLptr; } 254 foreach (i; TXptr_nflat) { tab[i] |= TYFLptr; } 255 foreach (i; TXreal) { tab[i] |= TYFLreal; } 256 foreach (i; TXintegral) { tab[i] |= TYFLintegral; } 257 foreach (i; TXimaginary) { tab[i] |= TYFLimaginary; } 258 foreach (i; TXcomplex) { tab[i] |= TYFLcomplex; } 259 foreach (i; TXuns) { tab[i] |= TYFLuns; } 260 foreach (i; TXmptr) { tab[i] |= TYFLmptr; } 261 foreach (i; TXfv) { tab[i] |= TYFLfv; } 262 foreach (i; TXfarfunc) { tab[i] |= TYFLfarfunc; } 263 foreach (i; TXpasfunc) { tab[i] |= TYFLpascal; } 264 foreach (i; TXrevfunc) { tab[i] |= TYFLrevparam; } 265 foreach (i; TXshort) { tab[i] |= TYFLshort; } 266 foreach (i; TXaggregate) { tab[i] |= TYFLaggregate; } 267 foreach (i; TXref) { tab[i] |= TYFLref; } 268 foreach (i; TXfunc) { tab[i] |= TYFLfunc; } 269 foreach (i; TXnullptr) { tab[i] |= TYFLnullptr; } 270 foreach (i; TXpasfunc_nf) { tab[i] |= TYFLpascal; } 271 foreach (i; TXrevfunc_nf) { tab[i] |= TYFLrevparam; } 272 foreach (i; TXref_nflat) { tab[i] |= TYFLref; } 273 foreach (i; TXfunc_nflat) { tab[i] |= TYFLfunc; } 274 foreach (i; TXxmmreg) { tab[i] |= TYFLxmmreg; } 275 foreach (i; TXsimd) { tab[i] |= TYFLsimd; } 276 return tab; 277 } (); 278 279 280 extern (C) __gshared const(char)*[TYMAX] tystring = 281 () { 282 const(char)*[TYMAX] ret = [ 283 TYbool : "bool", 284 TYchar : "char", 285 TYchar8 : "char8_t", 286 TYchar16 : "char16_t", 287 TYshort : "short", 288 289 TYenum : "enum", 290 TYint : "int", 291 292 TYlong : "long", 293 TYdchar : "dchar", 294 TYcent : "cent", 295 TYucent : "ucent", 296 TYfloat : "float", 297 TYdouble : "double", 298 TYdouble_alias : "double alias", 299 300 TYfloat4 : "float4", 301 TYdouble2 : "double2", 302 TYshort8 : "short8", 303 TYlong4 : "int4", 304 305 TYfloat8 : "float8", 306 TYdouble4 : "double4", 307 TYshort16 : "short16", 308 TYlong8 : "int8", 309 310 TYfloat16 : "float16", 311 TYdouble8 : "double8", 312 TYshort32 : "short32", 313 TYlong16 : "int16", 314 315 TYnptr : "*", 316 TYref : "&", 317 TYvoid : "void", 318 TYnoreturn : "noreturn", 319 TYstruct : "struct", 320 TYarray : "array", 321 TYnfunc : "C func", 322 TYnpfunc : "Pascal func", 323 TYnsfunc : "std func", 324 TYptr : "*", 325 TYmfunc : "member func", 326 TYjfunc : "D func", 327 TYhfunc : "C func", 328 TYnref : "__near &", 329 330 TYsptr : "__ss *", 331 TYcptr : "__cs *", 332 TYf16ptr : "__far16 *", 333 TYfptr : "__far *", 334 TYhptr : "__huge *", 335 TYvptr : "__handle *", 336 TYimmutPtr : "__immutable *", 337 TYsharePtr : "__shared *", 338 TYrestrictPtr : "__restrict *", 339 TYfgPtr : "__fg *", 340 TYffunc : "far C func", 341 TYfpfunc : "far Pascal func", 342 TYfsfunc : "far std func", 343 TYf16func : "_far16 Pascal func", 344 TYnsysfunc : "sys func", 345 TYfsysfunc : "far sys func", 346 TYfref : "__far &", 347 348 TYifunc : "interrupt func", 349 TYmemptr : "memptr", 350 TYident : "ident", 351 TYtemplate : "template", 352 TYvtshape : "vtshape", 353 ]; 354 355 version(SCPP) 356 { 357 ret[TYschar] = "signed char"; 358 ret[TYuchar] = "unsigned char"; 359 ret[TYwchar_t] = "wchar_t"; 360 361 ret[TYnullptr] = "nullptr_t"; 362 363 ret[TYushort] = "unsigned short"; 364 ret[TYuint] = "unsigned int"; 365 ret[TYulong] = "unsigned long"; 366 367 ret[TYldouble] = "long double"; 368 369 ret[TYifloat] = "imaginary float"; 370 ret[TYidouble] = "imaginary double"; 371 ret[TYildouble] = "imaginary long double"; 372 373 ret[TYcfloat] = "complex float"; 374 ret[TYcdouble] = "complex double"; 375 ret[TYcldouble] = "complex long double"; 376 377 ret[TYllong] = "long long"; 378 ret[TYullong] = "unsigned long long"; 379 380 ret[TYschar16] = "signed char[16]"; 381 ret[TYuchar16] = "unsigned char[16]"; 382 ret[TYushort8] = "unsigned short[8]"; 383 ret[TYulong4] = "unsigned long[4]"; 384 ret[TYllong2] = "long long[2]"; 385 ret[TYullong2] = "unsigned long long[2]"; 386 387 ret[TYschar32] = "signed char[32]"; 388 ret[TYuchar32] = "unsigned char[32]"; 389 ret[TYushort16] = "unsigned short[16]"; 390 ret[TYulong8] = "unsigned long[8]"; 391 ret[TYllong4] = "long long[4]"; 392 ret[TYullong4] = "unsigned long long[4]"; 393 394 ret[TYschar64] = "signed char[64]"; 395 ret[TYuchar64] = "unsigned char[64]"; 396 ret[TYushort32] = "unsigned short[32]"; 397 ret[TYulong16] = "unsigned long[16]"; 398 ret[TYllong8] = "long long[8]"; 399 ret[TYullong8] = "unsigned long long[8]"; 400 } else version(MARS) 401 { 402 ret[TYschar] = "byte"; 403 ret[TYuchar] = "ubyte"; 404 ret[TYwchar_t] = "wchar"; 405 406 ret[TYnullptr] = "typeof(null)"; 407 408 ret[TYushort] = "ushort"; 409 ret[TYuint] = "uint"; 410 ret[TYulong] = "ulong"; 411 412 ret[TYldouble] = "real"; 413 414 ret[TYifloat] = "ifloat"; 415 ret[TYidouble] = "idouble"; 416 ret[TYildouble] = "ireal"; 417 418 ret[TYcfloat] = "cfloat"; 419 ret[TYcdouble] = "cdouble"; 420 ret[TYcldouble] = "creal"; 421 422 ret[TYullong] = ret[TYulong]; // c_ulong 423 ret[TYllong] = ret[TYlong]; // c_long 424 425 ret[TYschar16] = "byte[16]"; 426 ret[TYuchar16] = "ubyte[16]"; 427 ret[TYushort8] = "ushort[8]"; 428 ret[TYulong4] = "ulong[4]"; // c_ulong 429 ret[TYllong2] = "long[2]"; 430 ret[TYullong2] = "ulong[2]"; 431 432 ret[TYschar32] = "byte[32]"; 433 ret[TYuchar32] = "ubyte[32]"; 434 ret[TYushort16] = "ushort[16]"; 435 ret[TYulong8] = "ulong[8]"; // c_ulong 436 ret[TYllong4] = "long[4]"; 437 ret[TYullong4] = "ulong[4]"; 438 439 ret[TYschar64] = "byte[64]"; 440 ret[TYuchar64] = "ubyte[64]"; 441 ret[TYushort32] = "ushort[32]"; 442 ret[TYulong16] = "ulong[16]"; // c_ulong 443 ret[TYllong8] = "long[8]"; 444 ret[TYullong8] = "ulong[8]"; 445 } else 446 static assert(0, "Unsupported compiler backend!"); 447 448 return ret; 449 } (); 450 451 /// Map to unsigned version of type 452 __gshared tym_t[256] tytouns = tytouns_init; 453 extern (D) private enum tytouns_init = 454 () { 455 tym_t[256] tab; 456 foreach (ty; 0 .. TYMAX) 457 { 458 tym_t tym; 459 switch (ty) 460 { 461 case TYchar: tym = TYuchar; break; 462 case TYschar: tym = TYuchar; break; 463 case TYshort: tym = TYushort; break; 464 case TYushort: tym = TYushort; break; 465 466 case TYenum: tym = TYuint; break; 467 case TYint: tym = TYuint; break; 468 469 case TYlong: tym = TYulong; break; 470 case TYllong: tym = TYullong; break; 471 case TYcent: tym = TYucent; break; 472 473 case TYschar16: tym = TYuchar16; break; 474 case TYshort8: tym = TYushort8; break; 475 case TYlong4: tym = TYulong4; break; 476 case TYllong2: tym = TYullong2; break; 477 478 case TYschar32: tym = TYuchar32; break; 479 case TYshort16: tym = TYushort16; break; 480 case TYlong8: tym = TYulong8; break; 481 case TYllong4: tym = TYullong4; break; 482 483 case TYschar64: tym = TYuchar64; break; 484 case TYshort32: tym = TYushort32; break; 485 case TYlong16: tym = TYulong16; break; 486 case TYllong8: tym = TYullong8; break; 487 488 default: tym = ty; break; 489 } 490 tab[ty] = tym; 491 } 492 return tab; 493 } (); 494 495 /// Map to relaxed version of type 496 __gshared ubyte[TYMAX] _tyrelax = _tyrelax_init; 497 extern(D) private enum _tyrelax_init = (){ 498 ubyte[TYMAX] tab; 499 foreach (ty; 0 .. TYMAX) 500 { 501 tym_t tym; 502 switch (ty) 503 { 504 case TYbool: tym = TYchar; break; 505 case TYschar: tym = TYchar; break; 506 case TYuchar: tym = TYchar; break; 507 case TYchar8: tym = TYchar; break; 508 case TYchar16: tym = TYint; break; 509 510 case TYshort: tym = TYint; break; 511 case TYushort: tym = TYint; break; 512 case TYwchar_t: tym = TYint; break; 513 514 case TYenum: tym = TYint; break; 515 case TYuint: tym = TYint; break; 516 517 case TYulong: tym = TYlong; break; 518 case TYdchar: tym = TYlong; break; 519 case TYullong: tym = TYllong; break; 520 case TYucent: tym = TYcent; break; 521 522 case TYnullptr: tym = TYptr; break; 523 524 default: tym = ty; break; 525 } 526 tab[ty] = cast(ubyte)tym; 527 } 528 return tab; 529 } (); 530 531 /// Map to equivalent version of type 532 __gshared ubyte[TYMAX] tyequiv = tyequiv_init; 533 extern (D) private enum tyequiv_init = 534 () { 535 ubyte[TYMAX] tab; 536 foreach (ty; 0 .. TYMAX) 537 { 538 tym_t tym; 539 switch (ty) 540 { 541 case TYchar: tym = TYschar; break; // chars are signed by default 542 case TYint: tym = TYshort; break; // adjusted in util_set32() 543 case TYuint: tym = TYushort; break; // adjusted in util_set32() 544 545 default: tym = ty; break; 546 } 547 tab[ty] = cast(ubyte)tym; 548 } 549 return tab; 550 } (); 551 552 /// Map to Codeview 1 type in debugger record 553 __gshared ubyte[TYMAX] dttab = 554 [ 555 TYbool : 0x80, 556 TYchar : 0x80, 557 TYschar : 0x80, 558 TYuchar : 0x84, 559 TYchar8 : 0x84, 560 TYchar16 : 0x85, 561 TYshort : 0x81, 562 TYwchar_t : 0x85, 563 TYushort : 0x85, 564 565 TYenum : 0x81, 566 TYint : 0x85, 567 TYuint : 0x85, 568 569 TYlong : 0x82, 570 TYulong : 0x86, 571 TYdchar : 0x86, 572 TYllong : 0x82, 573 TYullong : 0x86, 574 TYcent : 0x82, 575 TYucent : 0x86, 576 TYfloat : 0x88, 577 TYdouble : 0x89, 578 TYdouble_alias : 0x89, 579 TYldouble : 0x89, 580 581 TYifloat : 0x88, 582 TYidouble : 0x89, 583 TYildouble : 0x89, 584 585 TYcfloat : 0x88, 586 TYcdouble : 0x89, 587 TYcldouble : 0x89, 588 589 TYfloat4 : 0x00, 590 TYdouble2 : 0x00, 591 TYschar16 : 0x00, 592 TYuchar16 : 0x00, 593 TYshort8 : 0x00, 594 TYushort8 : 0x00, 595 TYlong4 : 0x00, 596 TYulong4 : 0x00, 597 TYllong2 : 0x00, 598 TYullong2 : 0x00, 599 600 TYfloat8 : 0x00, 601 TYdouble4 : 0x00, 602 TYschar32 : 0x00, 603 TYuchar32 : 0x00, 604 TYshort16 : 0x00, 605 TYushort16 : 0x00, 606 TYlong8 : 0x00, 607 TYulong8 : 0x00, 608 TYllong4 : 0x00, 609 TYullong4 : 0x00, 610 611 TYfloat16 : 0x00, 612 TYdouble8 : 0x00, 613 TYschar64 : 0x00, 614 TYuchar64 : 0x00, 615 TYshort32 : 0x00, 616 TYushort32 : 0x00, 617 TYlong16 : 0x00, 618 TYulong16 : 0x00, 619 TYllong8 : 0x00, 620 TYullong8 : 0x00, 621 622 TYnullptr : 0x20, 623 TYnptr : 0x20, 624 TYref : 0x00, 625 TYvoid : 0x85, 626 TYnoreturn : 0x85, // same as TYvoid 627 TYstruct : 0x00, 628 TYarray : 0x78, 629 TYnfunc : 0x63, 630 TYnpfunc : 0x74, 631 TYnsfunc : 0x63, 632 TYptr : 0x20, 633 TYmfunc : 0x64, 634 TYjfunc : 0x74, 635 TYhfunc : 0x00, 636 TYnref : 0x00, 637 638 TYsptr : 0x20, 639 TYcptr : 0x20, 640 TYf16ptr : 0x40, 641 TYfptr : 0x40, 642 TYhptr : 0x40, 643 TYvptr : 0x40, 644 TYimmutPtr : 0x20, 645 TYsharePtr : 0x20, 646 TYrestrictPtr : 0x20, 647 TYfgPtr : 0x20, 648 TYffunc : 0x64, 649 TYfpfunc : 0x73, 650 TYfsfunc : 0x64, 651 TYf16func : 0x63, 652 TYnsysfunc : 0x63, 653 TYfsysfunc : 0x64, 654 TYfref : 0x00, 655 656 TYifunc : 0x64, 657 TYmemptr : 0x00, 658 TYident : 0x00, 659 TYtemplate : 0x00, 660 TYvtshape : 0x00, 661 ]; 662 663 /// Map to Codeview 4 type in debugger record 664 __gshared ushort[TYMAX] dttab4 = 665 [ 666 TYbool : 0x30, 667 TYchar : 0x70, 668 TYschar : 0x10, 669 TYuchar : 0x20, 670 TYchar8 : 0x20, 671 TYchar16 : 0x21, 672 TYshort : 0x11, 673 TYwchar_t : 0x71, 674 TYushort : 0x21, 675 676 TYenum : 0x72, 677 TYint : 0x72, 678 TYuint : 0x73, 679 680 TYlong : 0x12, 681 TYulong : 0x22, 682 TYdchar : 0x7b, // UTF32 683 TYllong : 0x13, 684 TYullong : 0x23, 685 TYcent : 0x603, 686 TYucent : 0x603, 687 TYfloat : 0x40, 688 TYdouble : 0x41, 689 TYdouble_alias : 0x41, 690 TYldouble : 0x42, 691 692 TYifloat : 0x40, 693 TYidouble : 0x41, 694 TYildouble : 0x42, 695 696 TYcfloat : 0x50, 697 TYcdouble : 0x51, 698 TYcldouble : 0x52, 699 700 TYfloat4 : 0x00, 701 TYdouble2 : 0x00, 702 TYschar16 : 0x00, 703 TYuchar16 : 0x00, 704 TYshort8 : 0x00, 705 TYushort8 : 0x00, 706 TYlong4 : 0x00, 707 TYulong4 : 0x00, 708 TYllong2 : 0x00, 709 TYullong2 : 0x00, 710 711 TYfloat8 : 0x00, 712 TYdouble4 : 0x00, 713 TYschar32 : 0x00, 714 TYuchar32 : 0x00, 715 TYshort16 : 0x00, 716 TYushort16 : 0x00, 717 TYlong8 : 0x00, 718 TYulong8 : 0x00, 719 TYllong4 : 0x00, 720 TYullong4 : 0x00, 721 722 TYfloat16 : 0x00, 723 TYdouble8 : 0x00, 724 TYschar64 : 0x00, 725 TYuchar64 : 0x00, 726 TYshort32 : 0x00, 727 TYushort32 : 0x00, 728 TYlong16 : 0x00, 729 TYulong16 : 0x00, 730 TYllong8 : 0x00, 731 TYullong8 : 0x00, 732 733 TYnullptr : 0x100, 734 TYnptr : 0x100, 735 TYref : 0x00, 736 TYvoid : 0x03, 737 TYnoreturn : 0x03, // same as TYvoid 738 TYstruct : 0x00, 739 TYarray : 0x00, 740 TYnfunc : 0x00, 741 TYnpfunc : 0x00, 742 TYnsfunc : 0x00, 743 TYptr : 0x100, 744 TYmfunc : 0x00, 745 TYjfunc : 0x00, 746 TYhfunc : 0x00, 747 TYnref : 0x00, 748 749 TYsptr : 0x100, 750 TYcptr : 0x100, 751 TYf16ptr : 0x200, 752 TYfptr : 0x200, 753 TYhptr : 0x300, 754 TYvptr : 0x200, 755 TYimmutPtr : 0x100, 756 TYsharePtr : 0x100, 757 TYrestrictPtr : 0x100, 758 TYfgPtr : 0x100, 759 TYffunc : 0x00, 760 TYfpfunc : 0x00, 761 TYfsfunc : 0x00, 762 TYf16func : 0x00, 763 TYnsysfunc : 0x00, 764 TYfsysfunc : 0x00, 765 TYfref : 0x00, 766 767 TYifunc : 0x00, 768 TYmemptr : 0x00, 769 TYident : 0x00, 770 TYtemplate : 0x00, 771 TYvtshape : 0x00, 772 ]; 773 774 /// Size of a type 775 __gshared byte[256] _tysize = 776 [ 777 TYbool : 1, 778 TYchar : 1, 779 TYschar : 1, 780 TYuchar : 1, 781 TYchar8 : 1, 782 TYchar16 : 2, 783 TYshort : SHORTSIZE, 784 TYwchar_t : 2, 785 TYushort : SHORTSIZE, 786 787 TYenum : -1, 788 TYint : 2, 789 TYuint : 2, 790 791 TYlong : LONGSIZE, 792 TYulong : LONGSIZE, 793 TYdchar : 4, 794 TYllong : LLONGSIZE, 795 TYullong : LLONGSIZE, 796 TYcent : 16, 797 TYucent : 16, 798 TYfloat : FLOATSIZE, 799 TYdouble : DOUBLESIZE, 800 TYdouble_alias : 8, 801 TYldouble : -1, 802 803 TYifloat : FLOATSIZE, 804 TYidouble : DOUBLESIZE, 805 TYildouble : -1, 806 807 TYcfloat : 2*FLOATSIZE, 808 TYcdouble : 2*DOUBLESIZE, 809 TYcldouble : -1, 810 811 TYfloat4 : 16, 812 TYdouble2 : 16, 813 TYschar16 : 16, 814 TYuchar16 : 16, 815 TYshort8 : 16, 816 TYushort8 : 16, 817 TYlong4 : 16, 818 TYulong4 : 16, 819 TYllong2 : 16, 820 TYullong2 : 16, 821 822 TYfloat8 : 32, 823 TYdouble4 : 32, 824 TYschar32 : 32, 825 TYuchar32 : 32, 826 TYshort16 : 32, 827 TYushort16 : 32, 828 TYlong8 : 32, 829 TYulong8 : 32, 830 TYllong4 : 32, 831 TYullong4 : 32, 832 833 TYfloat16 : 64, 834 TYdouble8 : 64, 835 TYschar64 : 64, 836 TYuchar64 : 64, 837 TYshort32 : 64, 838 TYushort32 : 64, 839 TYlong16 : 64, 840 TYulong16 : 64, 841 TYllong8 : 64, 842 TYullong8 : 64, 843 844 TYnullptr : 2, 845 TYnptr : 2, 846 TYref : -1, 847 TYvoid : -1, 848 TYnoreturn : 0, 849 TYstruct : -1, 850 TYarray : -1, 851 TYnfunc : -1, 852 TYnpfunc : -1, 853 TYnsfunc : -1, 854 TYptr : 2, 855 TYmfunc : -1, 856 TYjfunc : -1, 857 TYhfunc : -1, 858 TYnref : 2, 859 860 TYsptr : 2, 861 TYcptr : 2, 862 TYf16ptr : 4, 863 TYfptr : 4, 864 TYhptr : 4, 865 TYvptr : 4, 866 TYimmutPtr : 2, 867 TYsharePtr : 2, 868 TYrestrictPtr : 2, 869 TYfgPtr : 2, 870 TYffunc : -1, 871 TYfpfunc : -1, 872 TYfsfunc : -1, 873 TYf16func : -1, 874 TYnsysfunc : -1, 875 TYfsysfunc : -1, 876 TYfref : 4, 877 878 TYifunc : -1, 879 TYmemptr : -1, 880 TYident : -1, 881 TYtemplate : -1, 882 TYvtshape : -1, 883 ]; 884 885 // set alignment after we know the target 886 enum SET_ALIGN = -1; 887 888 /// Size of a type to use for alignment 889 __gshared byte[256] _tyalignsize = 890 [ 891 TYbool : 1, 892 TYchar : 1, 893 TYschar : 1, 894 TYuchar : 1, 895 TYchar8 : 1, 896 TYchar16 : 2, 897 TYshort : SHORTSIZE, 898 TYwchar_t : 2, 899 TYushort : SHORTSIZE, 900 901 TYenum : -1, 902 TYint : 2, 903 TYuint : 2, 904 905 TYlong : LONGSIZE, 906 TYulong : LONGSIZE, 907 TYdchar : 4, 908 TYllong : LLONGSIZE, 909 TYullong : LLONGSIZE, 910 TYcent : 8, 911 TYucent : 8, 912 TYfloat : FLOATSIZE, 913 TYdouble : DOUBLESIZE, 914 TYdouble_alias : 8, 915 TYldouble : SET_ALIGN, 916 917 TYifloat : FLOATSIZE, 918 TYidouble : DOUBLESIZE, 919 TYildouble : SET_ALIGN, 920 921 TYcfloat : 2*FLOATSIZE, 922 TYcdouble : DOUBLESIZE, 923 TYcldouble : SET_ALIGN, 924 925 TYfloat4 : 16, 926 TYdouble2 : 16, 927 TYschar16 : 16, 928 TYuchar16 : 16, 929 TYshort8 : 16, 930 TYushort8 : 16, 931 TYlong4 : 16, 932 TYulong4 : 16, 933 TYllong2 : 16, 934 TYullong2 : 16, 935 936 TYfloat8 : 32, 937 TYdouble4 : 32, 938 TYschar32 : 32, 939 TYuchar32 : 32, 940 TYshort16 : 32, 941 TYushort16 : 32, 942 TYlong8 : 32, 943 TYulong8 : 32, 944 TYllong4 : 32, 945 TYullong4 : 32, 946 947 TYfloat16 : 64, 948 TYdouble8 : 64, 949 TYschar64 : 64, 950 TYuchar64 : 64, 951 TYshort32 : 64, 952 TYushort32 : 64, 953 TYlong16 : 64, 954 TYulong16 : 64, 955 TYllong8 : 64, 956 TYullong8 : 64, 957 958 TYnullptr : 2, 959 TYnptr : 2, 960 TYref : -1, 961 TYvoid : -1, 962 TYnoreturn : 0, 963 TYstruct : -1, 964 TYarray : -1, 965 TYnfunc : -1, 966 TYnpfunc : -1, 967 TYnsfunc : -1, 968 TYptr : 2, 969 TYmfunc : -1, 970 TYjfunc : -1, 971 TYhfunc : -1, 972 TYnref : 2, 973 974 TYsptr : 2, 975 TYcptr : 2, 976 TYf16ptr : 4, 977 TYfptr : 4, 978 TYhptr : 4, 979 TYvptr : 4, 980 TYimmutPtr : 2, 981 TYsharePtr : 2, 982 TYrestrictPtr : 2, 983 TYfgPtr : 2, 984 TYffunc : -1, 985 TYfpfunc : -1, 986 TYfsfunc : -1, 987 TYf16func : -1, 988 TYnsysfunc : -1, 989 TYfsysfunc : -1, 990 TYfref : 4, 991 992 TYifunc : -1, 993 TYmemptr : -1, 994 TYident : -1, 995 TYtemplate : -1, 996 TYvtshape : -1, 997 ]; 998 999 1000 private: 1001 extern(D): 1002 1003 static immutable TXptr = [ TYnptr ]; 1004 static immutable TXptr_nflat = [ TYsptr,TYcptr,TYf16ptr,TYfptr,TYhptr,TYvptr,TYimmutPtr,TYsharePtr,TYrestrictPtr,TYfgPtr ]; 1005 static immutable TXreal = [ TYfloat,TYdouble,TYdouble_alias,TYldouble, 1006 TYfloat4,TYdouble2, 1007 TYfloat8,TYdouble4, 1008 TYfloat16,TYdouble8, 1009 ]; 1010 static immutable TXimaginary = [ TYifloat,TYidouble,TYildouble, ]; 1011 static immutable TXcomplex = [ TYcfloat,TYcdouble,TYcldouble, ]; 1012 static immutable TXintegral = [ TYbool,TYchar,TYschar,TYuchar,TYshort, 1013 TYwchar_t,TYushort,TYenum,TYint,TYuint, 1014 TYlong,TYulong,TYllong,TYullong,TYdchar, 1015 TYschar16,TYuchar16,TYshort8,TYushort8, 1016 TYlong4,TYulong4,TYllong2,TYullong2, 1017 TYschar32,TYuchar32,TYshort16,TYushort16, 1018 TYlong8,TYulong8,TYllong4,TYullong4, 1019 TYschar64,TYuchar64,TYshort32,TYushort32, 1020 TYlong16,TYulong16,TYllong8,TYullong8, 1021 TYchar16,TYcent,TYucent, 1022 ]; 1023 static immutable TXref = [ TYnref,TYref ]; 1024 static immutable TXfunc = [ TYnfunc,TYnpfunc,TYnsfunc,TYifunc,TYmfunc,TYjfunc,TYhfunc ]; 1025 static immutable TXref_nflat = [ TYfref ]; 1026 static immutable TXfunc_nflat = [ TYffunc,TYfpfunc,TYf16func,TYfsfunc,TYnsysfunc,TYfsysfunc, ]; 1027 static immutable TXuns = [ TYuchar,TYushort,TYuint,TYulong, 1028 TYwchar_t, 1029 TYuchar16,TYushort8,TYulong4,TYullong2, 1030 TYdchar,TYullong,TYucent,TYchar16 ]; 1031 static immutable TXmptr = [ TYmemptr ]; 1032 static immutable TXnullptr = [ TYnullptr ]; 1033 static immutable TXfv = [ TYfptr, TYvptr ]; 1034 static immutable TXfarfunc = [ TYffunc,TYfpfunc,TYfsfunc,TYfsysfunc ]; 1035 static immutable TXpasfunc = [ TYnpfunc,TYnsfunc,TYmfunc,TYjfunc ]; 1036 static immutable TXpasfunc_nf = [ TYfpfunc,TYf16func,TYfsfunc, ]; 1037 static immutable TXrevfunc = [ TYnpfunc,TYjfunc ]; 1038 static immutable TXrevfunc_nf = [ TYfpfunc,TYf16func, ]; 1039 static immutable TXshort = [ TYbool,TYchar,TYschar,TYuchar,TYshort, 1040 TYwchar_t,TYushort,TYchar16 ]; 1041 static immutable TXaggregate = [ TYstruct,TYarray ]; 1042 static immutable TXxmmreg = [ 1043 TYfloat,TYdouble,TYifloat,TYidouble, 1044 //TYcfloat,TYcdouble, 1045 TYfloat4,TYdouble2, 1046 TYschar16,TYuchar16,TYshort8,TYushort8, 1047 TYlong4,TYulong4,TYllong2,TYullong2, 1048 TYfloat8,TYdouble4, 1049 TYschar32,TYuchar32,TYshort16,TYushort16, 1050 TYlong8,TYulong8,TYllong4,TYullong4, 1051 TYschar64,TYuchar64,TYshort32,TYushort32, 1052 TYlong16,TYulong16,TYllong8,TYullong8, 1053 TYfloat16,TYdouble8, 1054 ]; 1055 static immutable TXsimd = [ 1056 TYfloat4,TYdouble2, 1057 TYschar16,TYuchar16,TYshort8,TYushort8, 1058 TYlong4,TYulong4,TYllong2,TYullong2, 1059 TYfloat8,TYdouble4, 1060 TYschar32,TYuchar32,TYshort16,TYushort16, 1061 TYlong8,TYulong8,TYllong4,TYullong4, 1062 TYschar64,TYuchar64,TYshort32,TYushort32, 1063 TYlong16,TYulong16,TYllong8,TYullong8, 1064 TYfloat16,TYdouble8, 1065 ];