Created
October 27, 2010 22:04
-
-
Save sinfu/650117 to your computer and use it in GitHub Desktop.
余計なRTTIを生成することなく,シーケンスを単一型にパックする
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
true | |
tuple((double),"value",5) | |
tuple((double),"value",5) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() | |
{ | |
enum val = 5.0; | |
alias pack!(double, "value", 5.0) p; | |
alias pack!(double, "value", val) q; | |
pragma(msg, is(p == q)); | |
pragma(msg, unpack!p); | |
pragma(msg, unpack!q); | |
} | |
template pack(seq...) | |
{ | |
alias Tagger!(Packer!seq) pack; | |
} | |
template unpack(P) | |
{ | |
static if (is(P _ : Tagger!packer, alias packer)) | |
{ | |
alias packer.expand unpack; | |
} | |
else static assert(0); | |
} | |
private | |
{ | |
template Packer(seq...) | |
{ | |
alias seq expand; | |
} | |
struct Tagger(alias a); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FLAT group | |
;File = test.d | |
extrn _main | |
public _deh_beg | |
public _deh_end | |
public _tlsstart | |
public _tlsend | |
public _Dmain | |
public _D4test12__ModuleInfoZ | |
extrn _Dmodule_ref | |
public _D4test7__arrayZ | |
public _D4test8__assertFiZv | |
extrn _d_assertm | |
extrn _d_array_bounds | |
.text segment | |
assume CS:.text | |
: | |
ret | |
pushad | |
mov EAX,offset FLAT:_D4test12__ModuleInfoZ[013h]@SYM32 | |
mov ECX,offset FLAT:_Dmodule_ref@SYM32 | |
mov EDX,[ECX] | |
mov [EAX],EDX | |
mov [ECX],EAX | |
popad | |
ret | |
.text ends | |
.data segment | |
_D4test12__ModuleInfoZ: | |
db 004h,000h,000h,0ffffff80h,000h,000h,000h,000h ;........ | |
db 074h,065h,073h,074h,000h,000h,000h,000h ;test.... | |
db 000h,000h,000h,000h ;.... | |
dd offset FLAT:_D4test12__ModuleInfoZ@SYM32 | |
db 000h,000h,000h,000h ;.... | |
.data ends | |
.bss segment | |
.bss ends | |
.rodata segment | |
.rodata ends | |
.tdata segment | |
_tlsstart: | |
db 000h,000h,000h,000h ;.... | |
.tdata ends | |
.tdata. segment | |
.tdata. ends | |
.text._Dmain segment | |
assume CS:.text._Dmain | |
_Dmain: | |
push EBP | |
mov EBP,ESP | |
xor EAX,EAX | |
pop EBP | |
ret | |
nop | |
.text._Dmain ends | |
.ctors segment | |
dd offset FLAT:[1]@SYM32 | |
.ctors ends | |
.text._D4test7__arrayZ segment | |
assume CS:.text._D4test7__arrayZ | |
_D4test7__arrayZ: | |
push EBP | |
mov EBP,ESP | |
sub ESP,4 | |
push EAX | |
mov ECX,offset FLAT:_D4test12__ModuleInfoZ@SYM32 | |
push ECX | |
call _d_array_bounds@PC32 | |
leave | |
ret | |
.text._D4test7__arrayZ ends | |
.text._D4test8__assertFiZv segment | |
assume CS:.text._D4test8__assertFiZv | |
_D4test8__assertFiZv: | |
push EBP | |
mov EBP,ESP | |
sub ESP,4 | |
push EAX | |
mov ECX,offset FLAT:_D4test12__ModuleInfoZ@SYM32 | |
push ECX | |
call _d_assertm@PC32 | |
leave | |
ret | |
.text._D4test8__assertFiZv ends | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment