コード例 #1
0
    // A for statement will also define a variable temporarily
    public override bool Walk(ForStatement node)
    {
        if (node.Left is NameExpression nameExpression)
        {
            var expressionConverter = _expressionConverter.Clone();
            expressionConverter.AddVariables(NewVariables);

            var newVar     = nameExpression.Name;
            var newVarType = expressionConverter.GetListElementType(expressionConverter.GetExpressionType(node.List));
            NewVariables[newVar] = newVarType;

            node.Body?.Walk(this);
            node.Else?.Walk(this);

            NewVariables.Remove(newVar);
            return(false);
        }

        return(base.Walk(node));
    }