Mercurial > projects > dang
diff gen/CodeGen.d @ 93:621cedba53ea new_gen
Removed the Symbol from semantics - it was not needed anymore. From now on you set the type by doing a setType on an Identifier.
author | Anders Johnsen <skabet@gmail.com> |
---|---|
date | Mon, 05 May 2008 20:53:13 +0200 |
parents | 771ac63898e2 |
children | 48bb2287c035 |
line wrap: on
line diff
--- a/gen/CodeGen.d Mon May 05 18:44:20 2008 +0200 +++ b/gen/CodeGen.d Mon May 05 20:53:13 2008 +0200 @@ -197,9 +197,9 @@ case DeclType.VarDecl: auto varDecl = cast(VarDecl)decl; - auto sym = varDecl.env.find(varDecl.identifier); - Type t = llvm(sym.type); - GlobalVariable g = m.addGlobal(t, sym.id.get); + auto id = varDecl.env.find(varDecl.identifier); + Type t = llvm(id.type); + GlobalVariable g = m.addGlobal(t, id.get); g.initializer = ConstantInt.GetS(t, 0); table[varDecl.identifier.get] = g; break; @@ -296,7 +296,7 @@ return b.buildLoad(getPointer(exp), "."); case ExpType.CallExp: auto callExp = cast(CallExp)exp; - auto func_sym = exp.env.find(cast(Identifier)callExp.exp); + auto id = exp.env.find(cast(Identifier)callExp.exp); Value[] args; foreach (arg; callExp.args) { @@ -306,8 +306,8 @@ } // BUG: doesn't do implicit type-conversion if(callExp.sret) - return b.buildCall(m.getNamedFunction(func_sym.id.get), args, ""); - return b.buildCall(m.getNamedFunction(func_sym.id.get), args, ".call"); + return b.buildCall(m.getNamedFunction(id.get), args, ""); + return b.buildCall(m.getNamedFunction(id.get), args, ".call"); case ExpType.CastExp: auto castExp = cast(CastExp)exp; auto value = genExpression(castExp.exp); @@ -325,11 +325,11 @@ case ExpType.Identifier: auto identifier = cast(Identifier)exp; - auto sym = exp.env.find(identifier); - if(sym.type.isStruct || sym.type.isArray) - return table.find(sym.id.get); + auto id = exp.env.find(identifier); + if(id.type.isStruct || id.type.isArray) + return table.find(id.get); else - return b.buildLoad(table.find(sym.id.get), sym.id.get); + return b.buildLoad(table.find(id.get), id.get); case ExpType.MemberReference: auto v = getPointer(exp); // return v; @@ -505,8 +505,8 @@ { case ExpType.Identifier: auto identifier = cast(Identifier)exp; - auto sym = exp.env.find(identifier); - return table.find(sym.id.get); + auto id = exp.env.find(identifier); + return table.find(id.get); case ExpType.Deref: auto derefExp = cast(DerefExp)exp; auto target = getPointer(derefExp.exp); @@ -536,10 +536,9 @@ case ExpType.Identifier: auto identifier = cast(Identifier)mem.target; auto child = mem.child; - auto sym = exp.env.find(identifier); - auto symChild = child.env.find(child); - Value v = table.find(sym.id.get); - DType t = sym.type; + auto id = exp.env.find(identifier); + Value v = table.find(id.get); + DType t = id.type; auto st = t.asStruct; int i = st.indexOf(child.get); @@ -548,7 +547,7 @@ vals ~= ConstantInt.Get(IntegerType.Int32, 0, false); vals ~= ConstantInt.Get(IntegerType.Int32, i, false); - Value val = b.buildGEP(v, vals, sym.id.get~"."~child.get); + Value val = b.buildGEP(v, vals, id.get~"."~child.get); return val; case ExpType.MemberReference: