public override void CaseADeconstructorDecl(ADeconstructorDecl node) { InADeconstructorDecl(node); if (node.GetBlock() != null) { node.GetBlock().Apply(this); } { Object[] temp = new Object[node.GetFormals().Count]; node.GetFormals().CopyTo(temp, 0); for (int i = temp.Length - 1; i >= 0; i--) { ((PLocalDecl)temp[i]).Apply(this); } } if (node.GetName() != null) { node.GetName().Apply(this); } if (node.GetVisibilityModifier() != null) { node.GetVisibilityModifier().Apply(this); } OutADeconstructorDecl(node); }
public MethodDescription(ADeconstructorDecl method) { Parser parser = new Parser(method); Start = parser.Start; End = parser.End; ReturnType = "void"; Name = parser.Name; Formals = parser.Formals; Locals = parser.Locals; if (method.Parent() != null) method.Parent().RemoveChild(method); while (method.GetFormals().Count > 0) Decl.GetFormals().Add(method.GetFormals()[0]); Visibility = method.GetVisibilityModifier(); Position = TextPoint.FromCompilerCoords(method.GetName()); }
public override void OutADeconstructorDecl(ADeconstructorDecl node) { //If void return is missing, insert it. AABlock block = (AABlock)node.GetBlock(); bool insertReturn = false; while (true) { if (block.GetStatements().Count == 0) { insertReturn = true; break; } PStm lastStm = (PStm)block.GetStatements()[block.GetStatements().Count - 1]; if (lastStm is AVoidReturnStm) break; if (lastStm is ABlockStm) { block = (AABlock)((ABlockStm)block.GetStatements()[block.GetStatements().Count - 1]).GetBlock(); continue; } insertReturn = true; break; } if (insertReturn) { block.GetStatements().Add(new AVoidReturnStm(new TReturn("return", block.GetToken().Line, block.GetToken().Pos))); } //Must be no parameters if (node.GetFormals().Count > 0) { errors.Add(new ErrorCollection.Error(node.GetName(), LocRM.GetString("ErrorText193"))); } if (node.GetVisibilityModifier() is AProtectedVisibilityModifier && Util.HasAncestor<AEnrichmentDecl>(node)) { errors.Add(new ErrorCollection.Error(node.GetName(), LocRM.GetString("ErrorText194"))); } base.OutADeconstructorDecl(node); }