protected override bool Walk(ReturnStatement node) { Variable var; var mce = Unwrap(node.Expression) as MethodCallExpression; if (mce != null && IsTCE(mce, out var)) { if (!(Current.Body is LabeledStatement)) { Current.Body = Ast.Labeled(Current.Body); } var ee = new List<Expression>(); int i = 0; var temps = new List<Variable>(); foreach (var par in Current.Parameters) { var v = Current.CreateLocalVariable((SymbolId)Builtins.GenSym(par.Name), par.Type); ee.Add(Ast.Assign(v, mce.Arguments[i++])); temps.Add(v); } i = 0; foreach (var par in Current.Parameters) { ee.Add(Ast.Assign(par, Ast.Read(temps[i++]))); } ee.Add(Ast.Void(Ast.Continue(mce.Span))); node.Expression = Ast.Comma(ee); if (var != null) { var.Lift = false; fixups.Add(var.Block); } Current.Bind(); } return base.Walk(node); }
protected override void PostWalk(ReturnStatement node) { base.PostWalk(node); if (node.Expression is UnaryExpression && node.Expression.NodeType == AstNodeType.Convert) { var ue = (UnaryExpression)node.Expression; if (ue.Operand is MethodCallExpression) { var mce = (MethodCallExpression)ue.Operand; if (ue.Type == mce.Type || mce.Type == Current.ReturnType) { node.Expression = mce; if (mce.Type == Current.ReturnType) { mce.TailCall = true; } } } } }
protected internal override bool Walk(ReturnStatement node) { return DisallowControlFlowInVoidExpression(); }
protected override void PostWalk(ReturnStatement node) { base.PostWalk(node); List<ReturnStatement> retlist; if (!Returns.TryGetValue(Current, out retlist)) { Returns[Current] = retlist = new List<ReturnStatement>(); } retlist.Add(node); }
// ReturnStatement private void DefaultWalk(ReturnStatement node) { if (Walk(node)) { WalkNode(node.Expression); } PostWalk(node); }
protected internal override bool Walk(ReturnStatement node) { _result.Return = true; return true; }
protected override bool Walk(ReturnStatement node) { Variable var; var mce = Unwrap(node.Expression) as MethodCallExpression; if (mce != null && IsGood(mce, out var)) { if (!callsites.ContainsKey(var)) { callsites[var] = 1; } else { callsites[var]++; } } return base.Walk(node); }
protected override bool Walk(ReturnStatement node) { CodeBlockExpression cbe; Variable var; var mce = Unwrap(node.Expression) as MethodCallExpression; if (mce != null && IsHoistable(mce, out cbe, out var)) { var inlinedexpr = InlineCall(Current, cbe, mce.Arguments.ToArray()); node.Expression = inlinedexpr; var b = var.Block; var.Block = null; fixups.Add(b); } return base.Walk(node); }
protected internal override bool Walk(ReturnStatement node) { return(DisallowControlFlowInVoidExpression()); }
// ReturnStatement private void Dump(ReturnStatement node) { Out(".return", Flow.Space); WalkNode(node.Expression); Out(";", Flow.NewLine); }