Exemplo n.º 1
0
 protected virtual T VisitPyUsingStatement(PyUsingStatement node)
 {
     if (ThrowNotImplementedException)
     {
         throw new NotImplementedException(string.Format("Method {0} is not supported in class {1}", "VisitPyUsingStatement", this.GetType().FullName));
     }
     return(default(T));
 }
Exemplo n.º 2
0
        protected override IPyStatement[] VisitWithStatement(CsharpWithStatement src)
        {
            if (src.Variables.Length == 0)
            {
                throw new NotSupportedException("with statement with no variables");
            }
            PyUsingStatement owner  = null;
            PyUsingStatement result = null;

            for (var index = 0; index < src.Variables.Length; index++)
            {
                var ii        = src.Variables[index];
                var nextLevel = new PyUsingStatement
                {
                    Variable = new PyUsingStatementVariable
                    {
                        Name  = ii.Name,
                        Value = TransValue(ii.Value)
                    }
                };
                if (owner == null)
                {
                    result = nextLevel;
                }
                else
                {
                    owner.Statements.Add(nextLevel);
                }

                owner = nextLevel;
            }

            if (result == null)
            {
                throw new Exception("Internal exception");
            }
            var stats = this.TranslateStatements(src.Statements);

            result.Statements.AddRange(stats);

            /*
             * foreach (var i in src.Statements)
             * {
             *  var ii = CastOrThrow<CSharpBase>(i);
             *  var b  = Visit(ii);
             *  var bb = CastOrThrow<PyStatementBase>(b);
             *  result.Statements.Add(bb);
             * }
             */

            return(new[] { result });
        }
Exemplo n.º 3
0
 protected override IPyStatement VisitPyUsingStatement(PyUsingStatement node)
 {
     // todo: Simlifications
     return(node);
 }