private void CheckReturnStatement(ASTReturnStatementNode retNode) { if (retNode.Expression != null) { CheckExpression(retNode.Expression); } }
/// <summary> /// Builds return statement /// </summary> /// <param name="retNode">Return statement node</param> private void BuildReturnStatement(ASTReturnStatementNode retNode) { if (retNode.Expression != null) { BuildExpression(retNode.Expression); } //TODO: because all user's subroutines returns System.Object on call side //and doesn't box _emitter.Box(); _emitter.Jump(_context.MethodEnd); }
private void VisitReturnStatement(ASTReturnStatementNode retNode) { //first ret statement if (_hasRet == null) { if (retNode.Expression != null) { _hasRet = true; _currentSubroutine.Return = true; } else { _hasRet = false; } } else //after first { //already return value if ((bool)_hasRet) { if (retNode.Expression == null) { Messages.Add(new MessageRecord( MsgCode.AmbiguousReturn, retNode.SourcePath, retNode.StartLine, retNode.StartPos, "value", "void" )); } } else //no value return { if (retNode.Expression != null) { Messages.Add(new MessageRecord( MsgCode.AmbiguousReturn, retNode.SourcePath, retNode.StartLine, retNode.StartPos, "void", "value" )); } } } }