Exemple #1
0
        protected override Value Evaluate(ValueContainer scopes)
        {
            InitExpression.Process(scopes);

            Value lastVal = null;

            while (CondExpression.Process(scopes).IsTrue)
            {
                lastVal = OnExecute.Process(scopes);

                if (lastVal?.IsReturning ?? false)
                {
                    return(lastVal);
                }

                IncrementExpression.Process(scopes);
            }

            return(lastVal);
        }
Exemple #2
0
        /// <inheritdoc />
        public override string ToString()
        {
            var builder = new StringBuilder();

            if (Visibility != CppVisibility.Default)
            {
                builder.Append(Visibility.ToString().ToLowerInvariant());
                builder.Append(" ");
            }

            if (StorageQualifier != CppStorageQualifier.None)
            {
                builder.Append(StorageQualifier.ToString().ToLowerInvariant());
                builder.Append(" ");
            }

            builder.Append(Type.GetDisplayName());
            builder.Append(" ");
            builder.Append(Name);

            if (InitExpression != null)
            {
                builder.Append(" = ");
                var initExpressionStr = InitExpression.ToString();
                if (string.IsNullOrEmpty(initExpressionStr))
                {
                    builder.Append(InitValue);
                }
                else
                {
                    builder.Append(initExpressionStr);
                }
            }
            else if (InitValue != null)
            {
                builder.Append(" = ");
                builder.Append(InitValue);
            }

            return(builder.ToString());
        }
        protected override void GenerateInner(CodeGenerator generator, CodeStatementEmitOptions emitOptions)
        {
            if (!generator.JustWroteOpeningBrace && !generator.JustWroteVariableDeclaration && (emitOptions & CodeStatementEmitOptions.OmitSemiColon) == 0)
            {
                generator.WriteLine();
            }
            generator.WriteBlankLineIfJustExitedBlock();

            Type.Generate(generator);
            generator.Write(TokenType.Space, ' ');
            generator.OutputIdentifier(TokenType.Identifier, Name);
            if (InitExpression != null)
            {
                generator.Write(TokenType.Space, ' ');
                generator.Write(TokenType.Punctuation, '=');
                generator.Write(TokenType.Space, ' ');
                InitExpression.Generate(generator);
            }
            generator.WriteStatementEnd(emitOptions);
            generator.JustWroteVariableDeclaration = true;
        }
Exemple #4
0
        /// <summary>
        /// Write Soruce
        /// </summary>
        /// <param name="writer"></param>
        /// <param name="options"></param>
        /// <param name="info"></param>
        internal override void WriteSource(System.IO.StreamWriter writer, TsGeneratorOptions options, TsWriteInformation info)
        {
            //type variableName = initexpression
            //add line indent string
            var source = options.GetPreLineIndentString(info.Depth);

            //add type and variable name
            source += InitKeyReference.TsTypeName + TsDomConstants.ATTRIBUTE_SEPEARATOR + Name;
            //if type is set we will add type
            if (Type != null)
            {
                source = string.Format(TsDomConstants.TS_ELEMENT_TYPE_FORMAT, source, Type.TsTypeName);
            }
            //if there is an init expression add init expression
            if (InitExpression != null)
            {
                source = string.Format(TsDomConstants.ASSIGN_FORMAT, source, InitExpression.GetSource(options, info));
            }
            source += TsDomConstants.EXPRESSION_END;
            //write source
            writer.WriteLine(source);
        }