protected virtual void CheckReturnValue(ReturnStatement ret) { if (ret.Value == null) { if (!currentRoutine.ReturnType.IsNull) { report.Error(ret.Location, "return value should be provided"); return; } } else { if (currentRoutine.ReturnType.IsNull) { report.Error(ret.Location, "return value should not be provided"); return; } ret.Value.Accept(this); if (ret.Value is VoidExpression) { ret.Value.NodeType = currentRoutine.ReturnType.NodeType; } else { TypeData expectedType = currentRoutine.ReturnType.NodeType; if (!ret.Value.NodeType.IsSubtypeOf(expectedType)) { report.Error(ret.Location, "the type of the destination: {0} is " + "not a supertype of {1}", expectedType.FullName, ret.Value.NodeType.FullName); return; } } } }
public override void VisitReturn(ReturnStatement ret) { if (ret.Value != null) { ret.Value.Accept(this); BoxIfNecessary(ret.Value.RawType, currentRoutine.ReturnType.RawType); } if (exceptionLevel > 0) { ilGenerator.Emit(OpCodes.Leave, returnLabel); } else { ilGenerator.Emit(OpCodes.Br, returnLabel); } }
public override void VisitReturn(ReturnStatement ret) { if (currentIter != null) { report.Error(ret.Location, "`return' statements may not appear in iters."); return; } CheckReturnValue(ret); }
public virtual void VisitReturn(ReturnStatement ret) { }