public override void InALocalDeclStm(ALocalDeclStm node) { if (node.GetLocalDecl() == null) { node = node; } }
public override void CaseALocalDeclStm(ALocalDeclStm node) { AMethodDecl pMethod = Util.GetAncestor <AMethodDecl>(node); AALocalDecl decl = (AALocalDecl)node.GetLocalDecl(); if (decl.GetInit() == null) { ALocalLvalue lvalue = new ALocalLvalue(new TIdentifier(decl.GetName().Text)); data.LocalLinks[lvalue] = decl; data.LvalueTypes[lvalue] = decl.GetType(); List <PStm> statements = AssignDefault(lvalue); AABlock pBlock = (AABlock)node.Parent(); foreach (PStm statement in statements) { pBlock.GetStatements().Insert(pBlock.GetStatements().IndexOf(node), statement); } pBlock.RemoveChild(node); } else { //Make an assignment expression before moving ALocalLvalue lvalue = new ALocalLvalue(new TIdentifier(decl.GetName().Text)); data.LvalueTypes[lvalue] = decl.GetType(); AAssignmentExp exp = new AAssignmentExp(new TAssign("="), lvalue, decl.GetInit()); AExpStm expStm = new AExpStm(new TSemicolon(";"), exp); node.ReplaceBy(expStm); data.LvalueTypes[lvalue] = decl.GetType(); data.ExpTypes[exp] = decl.GetType(); data.LocalLinks[lvalue] = decl; } AABlock block = (AABlock)pMethod.GetBlock(); block.GetStatements().Insert(0, node); }
public override void CaseALocalDeclStm(ALocalDeclStm node) { node.GetLocalDecl().Apply(this); Write(";\n"); }