Mercurial > projects > dang
comparison ast/Decl.d @ 82:06dda301ea61 new_gen
Can declare outside functions and call c-functions
author | Anders Johnsen <skabet@gmail.com> |
---|---|
date | Fri, 02 May 2008 19:51:58 +0200 |
parents | 91f10c34cd7b |
children | 29f486ccc203 |
comparison
equal
deleted
inserted
replaced
81:110c7e1c4ca2 | 82:06dda301ea61 |
---|---|
50 { | 50 { |
51 } | 51 } |
52 | 52 |
53 override DType type() | 53 override DType type() |
54 { | 54 { |
55 return env.find(identifier).type; | 55 if(identifier) |
56 return env.find(identifier).type; | |
57 else | |
58 return env.findType(varType); | |
56 } | 59 } |
57 | 60 |
58 Identifier varType, identifier; | 61 Identifier varType, identifier; |
59 Exp init; | 62 Exp init; |
60 } | 63 } |
66 super(DeclType.FuncDecl); | 69 super(DeclType.FuncDecl); |
67 this.returnType = type; | 70 this.returnType = type; |
68 this.identifier = identifier; | 71 this.identifier = identifier; |
69 } | 72 } |
70 | 73 |
71 void addParam(Identifier type, Identifier name) | 74 void addParam(Identifier type, Identifier name = null) |
72 { | 75 { |
73 funcArgs ~= new VarDecl(type, name, null); | 76 funcArgs ~= new VarDecl(type, name, null); |
74 } | 77 } |
75 | 78 |
76 void setBody(CompoundStatement stmts) | 79 void setBody(CompoundStatement stmts) |
77 { | 80 { |
78 statements = stmts.statements; | 81 statements = stmts.statements; |
82 emptyFunction = false; | |
79 } | 83 } |
80 | 84 |
81 void simplify() | 85 void simplify() |
82 { | 86 { |
83 if(auto t = cast(DFunction)env.find(identifier).type) | 87 if(auto t = cast(DFunction)env.find(identifier).type) |
127 | 131 |
128 Identifier returnType, identifier; | 132 Identifier returnType, identifier; |
129 VarDecl[] funcArgs; | 133 VarDecl[] funcArgs; |
130 Stmt[] statements; | 134 Stmt[] statements; |
131 bool sret = false; | 135 bool sret = false; |
136 bool emptyFunction = true; | |
132 private DFunction myType; | 137 private DFunction myType; |
133 } | 138 } |
134 | 139 |
135 class StructDecl : Decl | 140 class StructDecl : Decl |
136 { | 141 { |