public override void OutAValueReturnStm(AValueReturnStm node)
        {
            AMethodDecl method = Util.GetAncestor<AMethodDecl>(node);
            AConstructorDecl constructor = Util.GetAncestor<AConstructorDecl>(node);
            APropertyDecl property = Util.GetAncestor<APropertyDecl>(node);
            AABlock lastBlock = Util.GetLastAncestor<AABlock>(node);

            //WTF is this? constructors can only return void
            if (constructor == null)
            {
                PType from = data.ExpTypes[node.GetExp()];
                PType to;

                if (property != null)
                {
                    if (lastBlock == property.GetSetter())
                    {
                        errors.Add(new ErrorCollection.Error(node.GetToken(), currentSourceFile,
                                                             LocRM.GetString("ErrorText151") + Util.TypeToString(from) +
                                                             LocRM.GetString("ErrorText159")));
                        return;
                    }
                }

                if (method != null)
                    to = method.GetReturnType();
                else
                    to = property.GetType();
                if (!Assignable(from, to))
                {
                    if (ImplicitAssignable(from, to))
                    {
                        ANamedType namedTo = (ANamedType) to;
                        ACastExp cast = new ACastExp(new TLParen("("),
                                                     new ANamedType(new TIdentifier(((AAName)namedTo.GetName()).AsString()), null),
                                                     node.GetExp());
                        node.SetExp(cast);
                        OutACastExp(cast);
                    }
                    else
                        errors.Add(new ErrorCollection.Error(node.GetToken(), currentSourceFile,
                                                             LocRM.GetString("ErrorText151") + Util.TypeToString(from) +
                                                             LocRM.GetString("ErrorText152") + Util.TypeToString(to)));
                }
            }
            if (property == null)
                CheckAssignedOutParameters(
                    method != null ? method.GetFormals().Cast<AALocalDecl>() : constructor.GetFormals().Cast<AALocalDecl>(),
                    node.GetToken());
            base.OutAValueReturnStm(node);

            /*if (property != null)
            {
                AABlock lastBlock = Util.GetLastAncestor<AABlock>(node);
                if (lastBlock == property.GetGetter())
                    errors.Add(new ErrorCollection.Error(node.GetToken(), currentSourceFile,
                                                         "The getter must return something of type " +
                                                         Util.TypeToString(property.GetType())));
            }
            else*/
        }
 public override void CaseAValueReturnStm(AValueReturnStm node)
 {
     InAValueReturnStm(node);
     if (node.GetExp() != null)
     {
         node.GetExp().Apply(this);
     }
     if (node.GetToken() != null)
     {
         node.GetToken().Apply(this);
     }
     OutAValueReturnStm(node);
 }
            public override void CaseAValueReturnStm(AValueReturnStm node)
            {
                /*
                 * return <exp>;
                 * ->
                 * methodReturnerVar = <exp>;
                 * hasMethodReturnedVar = true;
                 * break;
                 */
                ALocalLvalue lvalue = new ALocalLvalue(new TIdentifier(methodReturnerVar.GetName().Text));
                data.LvalueTypes[lvalue] = methodReturnerVar.GetType();
                data.LocalLinks[lvalue] = methodReturnerVar;
                AAssignmentExp exp = new AAssignmentExp(new TAssign("="), lvalue, node.GetExp());
                data.ExpTypes[exp] = methodReturnerVar.GetType();
                PStm stm = new AExpStm(new TSemicolon(";"), exp);
                AABlock block = new AABlock();
                block.GetStatements().Add(stm);

                block.GetStatements().Add(new AVoidReturnStm(node.GetToken()));

                node.ReplaceBy(new ABlockStm(new TLBrace("{"), block));
                block.Apply(this);
            }