public virtual void OutAValueReturnStm(AValueReturnStm node) { DefaultOut(node); }
public override void CaseAValueReturnStm(AValueReturnStm node) { GetNode(node); }
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 virtual void InAValueReturnStm(AValueReturnStm node) { DefaultIn(node); }
public override void CaseAValueReturnStm(AValueReturnStm node) { Returned = true; }
public virtual void CaseAValueReturnStm(AValueReturnStm node) { DefaultCase(node); }
public override void CaseAValueReturnStm(AValueReturnStm node) { Write("return "); node.GetExp().Apply(this); Write(";\n"); }
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*/ }
ArrayList New302() { ArrayList nodeList = new ArrayList(); ArrayList nodeArrayList3 = (ArrayList) Pop(); ArrayList nodeArrayList2 = (ArrayList) Pop(); ArrayList nodeArrayList1 = (ArrayList) Pop(); TReturn treturnNode2 = (TReturn)nodeArrayList1[0]; PExp pexpNode3 = (PExp)nodeArrayList2[0]; AValueReturnStm pstmNode1 = new AValueReturnStm ( treturnNode2, pexpNode3 ); nodeList.Add(pstmNode1); return nodeList; }
public override void CaseAValueReturnStm(AValueReturnStm node) { PType type = data.ExpTypes[node.GetExp()]; AMethodDecl pMethod = Util.GetAncestor<AMethodDecl>(node); if (Util.IsBulkCopy(type)) { TurnDynamic(node.GetExp(), null, oldReturnTypes.ContainsKey(pMethod) ? oldReturnTypes[pMethod] : pMethod.GetReturnType(), true, false, false); } if (pMethod != null && oldReturnTypes.ContainsKey(pMethod)) { PType oldType = oldReturnTypes[pMethod]; if (node.GetExp() is ANullExp && oldType is APointerType && Util.IsIntPointer(node, ((APointerType)oldType).GetType(), data)) { AIntConstExp replacer = new AIntConstExp(new TIntegerLiteral("0")); data.ExpTypes[replacer] = new ANamedType(new TIdentifier("int"), null); node.GetExp().ReplaceBy(replacer); } } base.CaseAValueReturnStm(node); }
public override void CaseAValueReturnStm(AValueReturnStm node) { AMethodDecl pMethod = Util.GetAncestor<AMethodDecl>(node); if (pMethod != null) { PType type = pMethod.GetReturnType(); if (node.GetExp() is ANullExp) { if (type is APointerType) { bool add = true; foreach (PType pType in TypesWithIdentifierArray) { if (Util.TypesEqual(((APointerType)type).GetType(), pType, data)) { add = false; break; } } if (add) TypesWithIdentifierArray.Add(((APointerType)type).GetType()); } } } base.CaseAValueReturnStm(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); }
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); }