Mercurial > projects > dang
comparison gen/CodeGen.d @ 175:c8e26556c24d
Codegen functions in structs
author | Anders Halager <halager@gmail.com> |
---|---|
date | Thu, 24 Jul 2008 21:12:12 +0200 |
parents | 20ff3c31f600 |
children | 59cd211a1bd3 |
comparison
equal
deleted
inserted
replaced
174:20ff3c31f600 | 175:c8e26556c24d |
---|---|
218 auto id = varDecl.identifier; | 218 auto id = varDecl.identifier; |
219 Type t = llvm(id.type); | 219 Type t = llvm(id.type); |
220 GlobalVariable g = m.addGlobal(t, id.get); | 220 GlobalVariable g = m.addGlobal(t, id.get); |
221 g.initializer = ConstantInt.GetS(t, 0); | 221 g.initializer = ConstantInt.GetS(t, 0); |
222 table[varDecl.identifier.get] = g; | 222 table[varDecl.identifier.get] = g; |
223 break; | |
224 | |
225 case DeclType.StructDecl: | |
226 auto sdecl = cast(StructDecl)decl; | |
227 foreach (d; sdecl.decls) | |
228 { | |
229 auto func = cast(FuncDecl)d; | |
230 if (func is null) | |
231 continue; | |
232 genRootDecl(func); | |
233 } | |
223 break; | 234 break; |
224 | 235 |
225 case DeclType.ClassDecl: | 236 case DeclType.ClassDecl: |
226 auto cdecl = cast(ClassDecl)decl; | 237 auto cdecl = cast(ClassDecl)decl; |
227 SmallArray!(Constant) functions; | 238 SmallArray!(Constant) functions; |
366 foreach (i, arg; callExp.args) | 377 foreach (i, arg; callExp.args) |
367 args[i] = genExpression(arg).value; | 378 args[i] = genExpression(arg).value; |
368 DFunction ftype = type.asFunction(); | 379 DFunction ftype = type.asFunction(); |
369 Type llvm_ftype = llvm(ftype); | 380 Type llvm_ftype = llvm(ftype); |
370 Value f = null; | 381 Value f = null; |
371 Stdout(callExp.callSym).newline; | |
372 if (callExp.callSym is null) | 382 if (callExp.callSym is null) |
373 { | 383 { |
374 // Do a virtual function call | 384 // Do a virtual function call |
375 f = genLValue(callExp.exp).getAddress(); | 385 f = genLValue(callExp.exp).getAddress(); |
376 f = b.buildLoad(f, "func_pointer"); | 386 f = b.buildLoad(f, "func_pointer"); |