public override void CaseAVoidReturnStm(AVoidReturnStm node) { if (!neededWhile) { node.Parent().RemoveChild(node); return; } /* * return; * -> * hasMethodReturnedVar = true; * break; */ ALocalLvalue lvalue = new ALocalLvalue(new TIdentifier(hasMethodReturnedVar.GetName().Text)); data.LvalueTypes[lvalue] = hasMethodReturnedVar.GetType(); data.LocalLinks[lvalue] = hasMethodReturnedVar; PExp exp = new ABooleanConstExp(new ATrueBool()); data.ExpTypes[exp] = new ANamedType(new TIdentifier("bool"), null); exp = new AAssignmentExp(new TAssign("="), lvalue, exp); data.ExpTypes[exp] = hasMethodReturnedVar.GetType(); PStm stm = new AExpStm(new TSemicolon(";"), exp); AABlock block = new AABlock(); block.GetStatements().Add(stm); block.GetStatements().Add(new ABreakStm(new TBreak("break"))); node.ReplaceBy(new ABlockStm(new TLBrace("{"), block)); }
public override void CaseAVoidReturnStm(AVoidReturnStm node) { ABooleanConstExp trueBool = new ABooleanConstExp(new ATrueBool()); AValueReturnStm replacer = new AValueReturnStm(node.GetToken(), trueBool); node.ReplaceBy(replacer); data.ExpTypes[trueBool] = new ANamedType(new TIdentifier("bool"), null); }
public override void CaseAVoidReturnStm(AVoidReturnStm node) { ALocalLvalue paramRef = new ALocalLvalue(new TIdentifier("paramRef")); ALvalueExp paramRefExp = new ALvalueExp(paramRef); node.ReplaceBy(new AValueReturnStm(node.GetToken(), paramRefExp)); data.LocalLinks[paramRef] = param; data.LvalueTypes[paramRef] = data.ExpTypes[paramRefExp] = param.GetType(); }
public override void CaseAVoidReturnStm(AVoidReturnStm node) { AMethodDecl baseDeconstructor = data.DeconstructorMap[data.StructDeconstructor[baseStruct]]; ALocalLvalue structFormalRef = new ALocalLvalue(new TIdentifier("currentStruct")); ALvalueExp structFormalRefExp = new ALvalueExp(structFormalRef); ASimpleInvokeExp invoke = new ASimpleInvokeExp(new TIdentifier("baseDeconstructor"), new ArrayList() { structFormalRefExp }); AABlock block = (AABlock)node.Parent(); block.GetStatements().Insert(block.GetStatements().IndexOf(node), new AExpStm(new TSemicolon(";"), invoke)); data.LocalLinks[structFormalRef] = structFormal; data.SimpleMethodLinks[invoke] = baseDeconstructor; data.LvalueTypes[structFormalRef] = data.ExpTypes[structFormalRefExp] = structFormal.GetType(); data.ExpTypes[invoke] = baseDeconstructor.GetReturnType(); }
public override void CaseAVoidReturnStm(AVoidReturnStm node) { GetNode(node); }
public override void CaseAVoidReturnStm(AVoidReturnStm node) { Write("return;\n"); }