public override void Evaluate(ComputationContext ctx) { if (this.Evaluation == null) { FunctionDefinition func = this.EnclosingScope <FunctionDefinition>(); if (func == null) { ctx.ErrorManager.AddError(ErrorCode.ReturnOutsideFunction, this); } else { if (func.IsResultTypeNameInfered) { if (this.Expr == null) { func.AddResultTypeCandidate(ctx.Env.UnitType.InstanceOf); } else { func.AddResultTypeCandidate(this.Expr.Evaluation.Components); } } else { IEntityInstance func_result = func.ResultParameter.TypeName.Evaluation.Components; if (this.Expr == null) { if (!ctx.Env.IsUnitType(func_result)) { ctx.ErrorManager.AddError(ErrorCode.EmptyReturn, this); } } else { this.DataTransfer(ctx, ref this.expr, func_result); } } } // https://stackoverflow.com/questions/7563981/why-isnt-g-tail-call-optimizing-while-gcc-is // http://www.drdobbs.com/tackling-c-tail-calls/184401756 if (this.Expr is FunctionCall call && call.IsRecall() && !func.Parameters.Any(it => ctx.Env.IsReferenceOfType(it.TypeName.Evaluation.Components))) { this.TailCallOptimization = call; } this.Evaluation = ctx.Env.UnitEvaluation; } }