Mercurial > projects > dang
diff ast/Decl.d @ 56:4ae365eff712 new_gen
Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
author | Anders Johnsen <skabet@gmail.com> |
---|---|
date | Mon, 28 Apr 2008 21:40:00 +0200 |
parents | da551f90e03f |
children | 2451f0904bf6 |
line wrap: on
line diff
--- a/ast/Decl.d Sat Apr 26 23:11:13 2008 +0200 +++ b/ast/Decl.d Mon Apr 28 21:40:00 2008 +0200 @@ -5,6 +5,8 @@ import lexer.Token; +import tango.io.Stdout; + import sema.SymbolTable; enum DeclType @@ -21,6 +23,10 @@ this.declType = declType; } + void simplify() + { + } + DeclType declType; Scope env; } @@ -36,6 +42,10 @@ this.init = e; } + void simplify() + { + } + Identifier type, identifier; Exp init; } @@ -59,9 +69,34 @@ statements = stmts.statements; } + void simplify() + { + if(auto t = cast(DStruct)env.find(identifier).type) + { + VarDecl[] funcArgs; + auto i = new Identifier("ret.val"); + i.env = env; + i.env.add(i); + i.env.find(i).type = i.env.find(identifier).type; + auto var = new VarDecl(type, i); + var.env = env; + funcArgs ~= var; + funcArgs ~= this.funcArgs; + this.funcArgs = funcArgs; + env.find(this.identifier).type = DType.Void; + sret = true; + } + + foreach ( funcArg ; funcArgs ) + funcArg.simplify(); + foreach ( stmt ; statements ) + stmt.simplify(); + } + Identifier type, identifier; VarDecl[] funcArgs; Stmt[] statements; + bool sret = false; } class StructDecl : Decl @@ -78,6 +113,10 @@ vars ~= new VarDecl(type, name, exp); } + void simplify() + { + } + Identifier identifier; VarDecl[] vars; }