protected override void EmitPartialFunctionExpression(PartialFunctionExpression expression, bool isStatement = false) { var id = NextVarId(); Append("(lambda {0}:", id); Emit(expression.Call.FunctionExpression); Append("("); EmitTuple(expression.Call.Args); Append(", {0}))", id); }
public AphidObject InterpretPartialFunctionExpression(PartialFunctionExpression expression) { var obj = (AphidObject)InterpretExpression(expression.Call.FunctionExpression); var func = (AphidFunction)obj.Value; var partialArgCount = func.Args.Length - expression.Call.Args.Count(); var partialArgs = func.Args.Skip(partialArgCount).ToArray(); var partialFunc = new AphidFunction() { Args = partialArgs, Body = new List <Expression> { new UnaryOperatorExpression(AphidTokenType.retKeyword, new CallExpression( expression.Call.FunctionExpression, expression.Call.Args.Concat(partialArgs.Select(x => new IdentifierExpression(x))).ToArray())), }, ParentScope = _currentScope, }; return(new AphidObject(partialFunc)); }
protected override void EmitPartialFunctionExpression(PartialFunctionExpression expression, bool isStatement = false) { var arg = NextId(); Append("(function(${0}) ", arg); EmitUsed( new List <AphidExpression>(), expression.GetChildren().ToList()); Append("{ return "); var callArgs = expression.Call.Args .Concat(new[] { new IdentifierExpression(arg) }) .ToList(); Emit(new CallExpression( expression.Call.FunctionExpression, callArgs.ToList())); Append("; })"); }
[DebuggerStepThrough] protected virtual void EmitPartialFunctionExpression(PartialFunctionExpression expression, bool isStatement = false) { throw new NotImplementedException(); }