public override void Visit(ReturnSyntax pNode) { if (_returnValues != null && pNode.Values.Count != _returnValues.Count) { if (_returnValues.Count == 0) { Compiler.ReportError(CompilerErrorType.NoReturnValues, pNode); } else { Compiler.ReportError(CompilerErrorType.IncorrectReturnCount, pNode, _returnValues.Count.ToString()); } } else { for (int i = 0; i < pNode.Values.Count; i++) { if (!_returnValues[i].Type.IsAssignableFrom(pNode.Values[i].Type)) { Compiler.ReportError(CompilerErrorType.TypeMismatch, pNode, _returnValues[i].Type.ToString(), pNode.Values[i].Type.ToString()); } } } base.Visit(pNode); }
protected virtual void VisitReturnSyntax(ReturnSyntax pNode) { foreach (var v in pNode.Values) { Visit(v); } }
private void OutputReturn(ReturnSyntax node, string prefix) { builder.AddFragment(new OutputFragment(prefix, DefaultColour)); builder.AddFragment(new OutputFragment("return ", StatementColour)); if (node.Expression != null) { Output(node.Expression, string.Empty); } }
protected virtual SyntaxNode VisitReturnSyntax(ReturnSyntax pNode) { List <SyntaxNode> values = new List <SyntaxNode>(pNode.Values.Count); foreach (var v in pNode.Values) { values.Add(Visit(v)); } return(SyntaxFactory.Return(values)); }
protected override void VisitReturnSyntax(ReturnSyntax pNode) { for (int i = 0; i < Math.Min(pNode.Values.Count, _methodReturns.Length); i++) { ForceCastLiteral(_methodReturns[i], pNode.Values[i]); //Try to cast each individual value to the corresponding return value TrySetImplicitCastType(pNode.Values[i], _methodReturns[i]); } base.VisitReturnSyntax(pNode); }
protected override void VisitReturnSyntax(ReturnSyntax pNode) { for (int i = 0; i < Math.Min(_methodReturns.Length, pNode.Values.Count); i++) { if (!CanCast(pNode.Values[i].Type, _methodReturns[i])) { CompilerErrors.TypeCastError(pNode.Values[i].Type, _methodReturns[i], pNode.Values[i].Span); } } base.VisitReturnSyntax(pNode); }
protected override void VisitReturnSyntax(ReturnSyntax pNode) { Store.SetValue("ReturnFound", pNode.Values.Count > 0); var count = Store.GetValue <int>("ReturnValueCount"); //If we have 0 return values it will be caught when we return to the method for checking return statements if (count > 0 && pNode.Values.Count != count) { CompilerErrors.MethodReturnCount(count, pNode.Span); } //Return statements can't be deferred otherwise we would defer forever! if (pNode.Deferred) { CompilerErrors.InvalidDefer(pNode.Span); } base.VisitReturnSyntax(pNode); }
public ReturnEvalutor(ReturnSyntax syntax) { Syntax = syntax; }
public Return(ReturnSyntax syntax, Package containingPackage, Expression expression) : base(syntax, containingPackage) { Expression = expression; }
public override void Visit(ReturnSyntax pNode) { SetValue("Returns", true); base.Visit(pNode); }