Esempio n. 1
0
        public void generate_code_with_output_variables()
        {
            var @call = new MethodCall(typeof(MethodCallTarget), nameof(MethodCallTarget.ReturnAndOuts));

            @call.Arguments[0] = new Variable(typeof(string), "input");
            @call.IsLocal      = true;

            var writer = new SourceWriter();

            @call.GenerateCode(new GeneratedMethod("Go", typeof(void)), writer);

            writer.Code().Trim().ShouldBe("var result_of_ReturnAndOuts = ReturnAndOuts(input, out var string, out var int32);");
        }
Esempio n. 2
0
        protected string[] WriteMethod(string methodName, Action <MethodCall> configure = null)
        {
            var @call = new MethodCall(typeof(MethodTarget), methodName);

            @call.Target = Variable.For <MethodTarget>("target");
            configure?.Invoke(@call);

            var writer = new SourceWriter();

            @call.GenerateCode(theMethod, writer);

            return(writer.Code().ReadLines().ToArray());
        }
Esempio n. 3
0
        public void write_comment_text_if_exists()
        {
            var @call = new MethodCall(typeof(MethodCallTarget), nameof(MethodCallTarget.ReturnAndOuts));

            @call.Arguments[0] = new Variable(typeof(string), "input");
            @call.IsLocal      = true;

            @call.CommentText = "Hey.";

            var writer = new SourceWriter();

            @call.GenerateCode(new GeneratedMethod("Go", typeof(void)), writer);

            writer.Code().Trim().ShouldStartWith("// Hey.");
        }
        public override void GenerateCode(GeneratedMethod method, ISourceWriter writer)
        {
            writer.WriteLine($"{_aggregateType.FullNameInCode()} {Aggregate.Usage} = default({_aggregateType.FullNameInCode()});");
            writer.Write($"BLOCK:if ({_slice.Usage}.{nameof(StreamAction.ActionType)} == {Constant.ForEnum(StreamActionType.Start).Usage})");

            _create.Action = CreateAggregateAction.Assign;
            _create.GenerateCode(method, writer);

            writer.FinishBlock();

            writer.Write("BLOCK:else");
            _loadMethod.GenerateCode(method, writer);
            _create.Action = CreateAggregateAction.NullCoalesce;
            _create.GenerateCode(method, writer);
            writer.FinishBlock();

            Next?.GenerateCode(method, writer);
        }