protected override IPhpStatement[] VisitForEachStatement(ForEachStatement src)
        {
            var g                 = src.VarName;
            var collection        = TransValue(src.Collection);
            var statement         = TranslateStatementOne(src.Statement);
            PhpForEachStatement a = null;

            if (src.ItemType.DotnetType.IsGenericType)
            {
                var gtd = src.ItemType.DotnetType.GetGenericTypeDefinition();
                if (gtd == typeof(KeyValuePair <,>))
                {
                    a = new PhpForEachStatement(src.VarName, collection, statement);
                    // $i@Key
                    a.KeyVarname   = src.VarName + "@Key";
                    a.ValueVarname = src.VarName + "@Value";
                }
            }

            if (a == null)
            {
                a = new PhpForEachStatement(src.VarName, collection, statement);
            }
            return(MkArray(a));
        }
Exemple #2
0
 protected virtual T VisitPhpForEachStatement(PhpForEachStatement node)
 {
     if (ThrowNotImplementedException)
     {
         throw new NotImplementedException(string.Format("Method {0} is not supported in class {1}", "VisitPhpForEachStatement", this.GetType().FullName));
     }
     return(default(T));
 }
 protected override IPhpStatement VisitPhpForEachStatement(PhpForEachStatement node)
 {
     return(node.Simplify(this));
 }