public override object VisitLambda([NotNull] LambdaContext context) { var r = new Result { data = "var" }; // 异步 if (context.t.Type == FlowRight) { r.text += "async "; } r.text += "("; if (context.lambdaIn() != null) { r.text += Visit(context.lambdaIn()); } r.text += ")"; r.text += "=>"; if (context.expressionList() != null) { r.text += ((Result)Visit(context.expressionList())).text; } else { r.text += "{" + ProcessFunctionSupport(context.functionSupportStatement()) + "}"; } return(r); }
public override object VisitLambda(LambdaContext context) { this.add_current_set(); this.add_func_stack(); var r = (new Result() { data = "var" }); r.text += "("; if (context.lambdaIn() != null) { r.text += Visit(context.lambdaIn()); } r.text += ")"; r.text += "=>"; if (context.tupleExpression() != null) { r.text += ((Result)(Visit(context.tupleExpression()))).text; } else { r.text += (new System.Text.StringBuilder().Append("{").Append(ProcessFunctionSupport(context.functionSupportStatement())).Append("}")).to_str(); } this.delete_current_set(); if (get_func_async() || context.t.Type == Right_Flow) { r.text = " async " + r.text; } this.delete_func_stack(); return(r); }
static List <Action> CreateActions() { List <Action> actions = new List <Action>(); for (int i = 0; i < 5; i++) { LambdaContext context = new LambdaContext(); context.text = string.Format("message {0}", i); actions.Add(context.Method); } return(actions); }
public Action <string> CreateAction(string methodParameter) { LambdaContext context = new LambdaContext(); context.originalThis = this; context.methodParameter = methodParameter; context.methodLocal = "method local"; string uncaptured = "uncaptured local"; Action <string> action = context.Method; context.methodLocal = "modified method local"; return(action); }
/// <summary> /// Starts creating of a lambda. /// </summary> public void LambdaStart() { var context = new LambdaContext(lambdaCount); lambdaCount++; contextsStack.Push(context); OpenBracket(); // add jump to the end of the code block Label(context.EndLabel); AddRpn(new RpnGoto(labels)); AddRpn(new RpnNop()); lambdas.Add(context.LambdaName, program.Last); }
public void RemainingTimeIsPositive() { var deadline = DateTimeOffset.UtcNow.AddHours(1); var deadlineMs = deadline.ToUnixTimeMilliseconds().ToString(CultureInfo.InvariantCulture); var headers = new Dictionary <string, IEnumerable <string> > { ["Lambda-Runtime-Aws-Request-Id"] = new[] { Guid.NewGuid().ToString() }, ["Lambda-Runtime-Deadline-Ms"] = new[] { deadlineMs }, ["Lambda-Runtime-Invoked-Function-Arn"] = new[] { "my-function-arn" } }; var runtimeApiHeaders = new RuntimeApiHeaders(headers); var lambdaEnvironment = new LambdaEnvironment(_environmentVariables); var context = new LambdaContext(runtimeApiHeaders, lambdaEnvironment); Assert.True(context.RemainingTime >= TimeSpan.Zero, $"Remaining time is not a positive value: {context.RemainingTime}"); }
public void Constructor_SetsPropertiesUsingEnvironmentVariables() { // arrange var initialEnvironmentVariables = new Dictionary <string, string> { { "AWS_LAMBDA_FUNCTION_MEMORY_SIZE", "1" }, { "AWS_LAMBDA_FUNCTION_NAME", "2" }, { "AWS_LAMBDA_FUNCTION_VERSION", "3" }, { "AWS_LAMBDA_LOG_GROUP_NAME", "4" }, { "AWS_LAMBDA_LOG_STREAM_NAME", "5" } }; // act var context = new LambdaContext(initialEnvironmentVariables); // assert context.MemoryLimitInMB.ShouldBe(1); context.FunctionName.ShouldBe("2"); context.FunctionVersion.ShouldBe("3"); context.LogGroupName.ShouldBe("4"); context.LogStreamName.ShouldBe("5"); }
public override object VisitLambda(LambdaContext context) { Add_current_set(); var r = (new Result("var")); r.text += "("; if (context.lambdaIn() != null) { r.text += Visit(context.lambdaIn()); } r.text += ")"; r.text += "=>"; if (context.tupleExpression() != null) { r.text += ((Result)Visit(context.tupleExpression())).text; } else { r.text += (new System.Text.StringBuilder().Append("{").Append(ProcessFunctionSupport(context.functionSupportStatement())).Append("}")).To_Str(); } Delete_current_set(); return(r); }
public Expression <TDelegate> Build(Func <LambdaContext, Expression> body) { using (var context = new LambdaContext(this)) AddStatement(body(context)); return(Build()); }
public Expression <TDelegate> Build(Action <LambdaContext, ParameterExpression> scope) { using (var context = new LambdaContext(this)) scope(context, Result ?? throw new InvalidOperationException(ExceptionMessages.VoidLambda)); return(Build()); }
public Expression <TDelegate> Build(Action <LambdaContext> scope) { using (var context = new LambdaContext(this)) scope(context); return(Build()); }
public Expression <D> Build(Action <LambdaContext, ParameterExpression> scope) { using (var context = new LambdaContext(this)) scope(context, Result); return(Build()); }