示例#1
0
        /// <inheritdoc/>
        protected override void HandleForEach(CodeForEachStatement obj, Context ctx)
        {
            ctx.Writer.Write("foreach (");
            WriteTypeOrVar(obj.ItemType, ctx);
            ctx.Writer.Write($" {obj.ItemName.AsCsId()} in ");
            ctx.HandlerProvider.ExpressionHandler.Handle(obj.ObjectToIterate, ctx);
            ctx.Writer.Write(")");

            CSharpUtils.HandleStatementCollection(obj.Statements, ctx, true, false);
        }
        public CodeObject Compile(AstNode syntaxNode, CodeProgram prog)
        {
            var syntax = (ScriptForEachStatement)syntaxNode;

            var code = new CodeForEachStatement(
                new CodeVariableReference(syntax.Id),
                AstDomCompiler.Compile <CodeExpression>(syntax.Container, prog),
                AstDomCompiler.Compile <CodeStatement>(syntax.Statement, prog));

            return(code);
        }
    public CodeObject Compile(AstNode syntaxNode, CodeProgram prog)
    {
      var syntax = (ScriptForEachStatement)syntaxNode;

      var code = new CodeForEachStatement(
         new CodeVariableReference(syntax.Id),
         AstDomCompiler.Compile<CodeExpression>(syntax.Container, prog),
         AstDomCompiler.Compile<CodeStatement>(syntax.Statement, prog));

      return code;
    }
示例#4
0
 /// <inheritdoc />
 protected override void HandleForEach(CodeForEachStatement obj, Context ctx)
 {
     VisualBasicUtils.BeginBlock(BlockType.For, ctx, false);
     ctx.Writer.Write($"For Each {obj.ItemName.AsVbId()}");
     if (!GeneralUtils.IsNullOrVoidType(obj.ItemType))
     {
         ctx.Writer.Write(" As ");
         ctx.HandlerProvider.TypeReferenceHandler.Handle(obj.ItemType, ctx);
     }
     ctx.Writer.Write(" In ");
     ctx.HandlerProvider.ExpressionHandler.Handle(obj.ObjectToIterate, ctx);
     ctx.Writer.NewLine();
     ctx.Indent();
     VisualBasicUtils.HandleStatementCollection(obj.Statements, ctx);
     ctx.Unindent();
     ctx.Writer.IndentAndWrite("Next", ctx);
     VisualBasicUtils.EndBlock(ctx, false, false);
 }
 private bool HandleDynamic(CodeForEachStatement obj, Context ctx)
 {
     return(HandleIfTrue(() => { HandleForEach(obj, ctx); }, obj, ctx, CanHandleForEach, false));
 }
 /// <inheritdoc cref="ICodeObjectHandler{T}.Handle"/>
 protected abstract void HandleForEach(CodeForEachStatement obj, Context ctx);