Mercurial > projects > ddmd
comparison dmd/ReturnStatement.d @ 67:f708f0452e81
some of the backend/codegen stuff implemented
author | korDen |
---|---|
date | Mon, 23 Aug 2010 21:21:05 +0400 |
parents | cab4c37afb89 |
children | ee3a9f34dc48 |
comparison
equal
deleted
inserted
replaced
66:efb1e5bdf63c | 67:f708f0452e81 |
---|---|
32 import dmd.WANT; | 32 import dmd.WANT; |
33 import dmd.VarExp; | 33 import dmd.VarExp; |
34 import dmd.VarDeclaration; | 34 import dmd.VarDeclaration; |
35 import dmd.GlobalExpressions; | 35 import dmd.GlobalExpressions; |
36 import dmd.BE; | 36 import dmd.BE; |
37 | |
37 import dmd.codegen.Util; | 38 import dmd.codegen.Util; |
38 | 39 |
39 import dmd.backend.Blockx; | 40 import dmd.backend.Blockx; |
40 import dmd.backend.elem; | 41 import dmd.backend.elem; |
41 import dmd.backend.TYM; | 42 import dmd.backend.TYM; |
42 import dmd.backend.Util; | 43 import dmd.backend.Util; |
43 import dmd.backend.OPER; | 44 import dmd.backend.OPER; |
44 import dmd.backend.mTY; | 45 import dmd.backend.mTY; |
45 import dmd.backend.BC; | 46 import dmd.backend.BC; |
47 | |
48 import core.stdc.string; | |
46 | 49 |
47 class ReturnStatement : Statement | 50 class ReturnStatement : Statement |
48 { | 51 { |
49 Expression exp; | 52 Expression exp; |
50 | 53 |
415 /* If returning struct literal, write result | 418 /* If returning struct literal, write result |
416 * directly into return value | 419 * directly into return value |
417 */ | 420 */ |
418 if (exp.op == TOK.TOKstructliteral) | 421 if (exp.op == TOK.TOKstructliteral) |
419 { | 422 { |
420 assert(false); | 423 scope StructLiteralExp se = cast(StructLiteralExp)exp; |
421 /* | 424 enum objectSize = __traits(classInstanceSize, StructLiteralExp); |
422 StructLiteralExp se = cast(StructLiteralExp)exp; | 425 ubyte save[objectSize]; |
423 char save[(StructLiteralExp).sizeof]; | 426 memcpy(save.ptr, cast(void*)se, objectSize); |
424 memcpy(save, se, sizeof(StructLiteralExp)); | |
425 se.sym = irs.shidden; | 427 se.sym = irs.shidden; |
426 se.soffset = 0; | 428 se.soffset = 0; |
427 se.fillHoles = 1; | 429 se.fillHoles = 1; |
428 e = exp.toElem(irs); | 430 e = exp.toElem(irs); |
429 memcpy(se, save, sizeof(StructLiteralExp)); | 431 memcpy(cast(void*)se, save.ptr, objectSize); |
430 */ | |
431 } | 432 } |
432 else | 433 else |
433 e = exp.toElem(irs); | 434 e = exp.toElem(irs); |
434 | 435 |
435 assert(e); | 436 assert(e); |