Example #1
0
        public static IApiMethodBuilderResult CreateTestExpression(ApiBaseFunction func, ExpressionBuilderParams p,
                                                                   FunctionCallStatement functionCallStatement, TestExpressionCreator createTestExpression)
        {
            func.AssertParameters(p, functionCallStatement.Parameters);

            var result = createTestExpression(p, functionCallStatement);

            if (p.UsageContext is IfElseStatement)
            {
                return(new ApiMethodBuilderRawResult(new ExpressionResult(
                                                         func.TypeDescriptor,
                                                         result.Expression,
                                                         result.Template
                                                         )));
            }

            p.NonInlinePartWriter.WriteLine(result.Expression);

            var varName = BashVariableDefinitionStatementTranspiler.WriteLastStatusCodeStoreVariableDefinition(
                p.Context, p.Scope,
                p.NonInlinePartWriter, $"{functionCallStatement.Fqn}_Result");

            return(new ApiMethodBuilderRawResult(new ExpressionResult(
                                                     func.TypeDescriptor,
                                                     $"${varName}",
                                                     new VariableAccessStatement(varName, functionCallStatement.Info),
                                                     ExpressionBuilderBase.PinRequiredNotice
                                                     )));
        }