Mercurial > projects > ldc
annotate gen/elem.c @ 15:37a4fdab33fc trunk
[svn r19] * Added support for reassigning 'this' inside class constructors.
* Added preliminary support for UnrolledLoopStatement. That is foreach on a tuple.
author | lindquist |
---|---|
date | Wed, 03 Oct 2007 04:56:32 +0200 |
parents | d3ee9efe20e2 |
children | 4648206ca213 |
rev | line source |
---|---|
1 | 1 #include <iostream> |
2 | |
3 #include "llvm/Instructions.h" | |
4 | |
4
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
1
diff
changeset
|
5 #include "gen/elem.h" |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
1
diff
changeset
|
6 #include "gen/irstate.h" |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
1
diff
changeset
|
7 #include "gen/logger.h" |
1 | 8 |
9 ////////////////////////////////////////////////////////////////////////////////////////// | |
10 | |
11 elem::elem() | |
12 { | |
13 mem = 0; | |
14 val = 0; | |
15 arg = 0; | |
16 | |
17 type = NONE; | |
18 inplace = false; | |
19 field = false; | |
11
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
4
diff
changeset
|
20 callconv = (unsigned)-1; |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
11
diff
changeset
|
21 isthis = false; |
1 | 22 |
23 vardecl = 0; | |
24 funcdecl = 0; | |
25 } | |
26 | |
27 llvm::Value* elem::getValue() | |
28 { | |
29 assert(val || mem); | |
30 switch(type) | |
31 { | |
32 case NONE: | |
33 assert(0 && "type == NONE"); | |
34 break; | |
35 | |
36 case VAR: | |
37 case REF: { | |
38 if (val) { | |
39 return val; | |
40 } | |
41 else { | |
42 if (!llvm::isa<llvm::PointerType>(mem->getType())) | |
43 { | |
44 Logger::cout() << "unexpected type: " << *mem->getType() << '\n'; | |
45 assert(0); | |
46 } | |
47 const llvm::PointerType* pt = llvm::cast<llvm::PointerType>(mem->getType()); | |
48 if (!pt->getElementType()->isFirstClassType()) { | |
49 return mem; | |
50 } | |
51 else { | |
52 return new llvm::LoadInst(mem, "tmp", gIR->scopebb()); | |
53 } | |
54 } | |
55 } | |
56 | |
57 case VAL: | |
58 case NUL: | |
59 case FUNC: | |
60 case CONST: | |
61 case SLICE: | |
62 return val ? val : mem; | |
63 } | |
64 assert(0 && "type == invalid value"); | |
65 return 0; | |
66 } |