Наследование: IronPython.Compiler.Ast.SequenceExpression
Пример #1
0
 private void WalkTuple(TupleExpression tuple) {
     foreach (Expression innerNode in tuple.Items) {
         NameExpression name = innerNode as NameExpression;
         if (name != null) {
             _binder.DefineName(name.Name);
             name.Reference = _binder.Reference(name.Name);
         } else {
             WalkTuple((TupleExpression)innerNode);
         }
     }
 }
Пример #2
0
        public override void PostWalk(TupleExpression node)
        {
            var tmp = tree.Pop();
            var parent = tree.Peek() as AssignmentStatement;
            tree.Push(tmp);

            if (parent == null || !parent.Left.Contains(node))
            {
                List<string> statements = new List<string>();
                for (int i = 0; i < node.Items.Count; i++)
                {
                    statements.Add(Content());
                }
                statements.Reverse();

                Content("[{0}]", String.Join(", ", statements));
            }

            CommonPostWalk(node);
        }
 // TupleExpression
 public bool Walk(TupleExpression node)
 {
     return Process(node);
 }
 public void PostWalk(TupleExpression node)
 {
     PostProcess(node);
 }
Пример #5
0
 public override bool Walk(TupleExpression node)
 {
     node.Parent = _binder._currentScope;
     return(true);
 }
Пример #6
0
            internal Tuple(TupleExpression list, expr_context ctx)
                : this() {
                _elts = PythonOps.MakeEmptyList(list.Items.Count);
                foreach (Compiler.Ast.Expression expr in list.Items)
                    _elts.Add(Convert(expr, ctx));

                _ctx = ctx;
            }
Пример #7
0
 public override bool Walk(TupleExpression node)
 {
     node.Parent = _currentScope;
     return base.Walk(node);
 }
Пример #8
0
        private static SymbolId EncodeTupleParamName(TupleExpression param)
        {
            // we encode a tuple parameter so we can extract the compound
            // members back out of it's name.
            StringBuilder sb = new StringBuilder(tupleArgHeader);
            AppendTupleParamNames(sb, param);

            return SymbolTable.StringToId(sb.ToString());
        }
 public virtual void PostWalk(TupleExpression node)
 {
 }
 // TupleExpression
 public virtual bool Walk(TupleExpression node)
 {
     return true;
 }
Пример #11
0
        private static Expression MakeTupleOrExpr(List<Expression> l, bool trailingComma, bool expandable)
        {
            if (l.Count == 1 && !trailingComma) return l[0];

            Expression[] exprs = l.ToArray();
            TupleExpression te = new TupleExpression(expandable && !trailingComma, exprs);
            if (exprs.Length > 0) {
                te.SetLoc(exprs[0].ExternalInfo, exprs[0].Start, exprs[exprs.Length - 1].End);
            }
            return te;
        }
Пример #12
0
 public string Visit(PyAst.TupleExpression node) => $"({VisitExpressionsList(node.Items)})";
Пример #13
0
 public override bool Walk(TupleExpression node)
 {
     return(true);
 }
Пример #14
0
 // TupleExpression
 public override bool Walk(TupleExpression node)
 {
     node.Parent = _currentScope;
     return(base.Walk(node));
 }
Пример #15
0
 public override bool Walk(TupleExpression node)
 {
     CommonWalk(node);
     return true;
 }
Пример #16
0
 private static void AppendTupleParamNames(StringBuilder sb, TupleExpression param)
 {
     for (int i = 0; i < param.Items.Count; i++) {
         NameExpression ne = param.Items[i] as NameExpression;
         if (ne != null) {
             sb.Append('!');
             sb.Append(ne.Name.GetString());
         } else {
             // nested tuple
             AppendTupleParamNames(sb, param.Items[i] as TupleExpression);
         }
     }
 }
Пример #17
0
 public SublistParameter(int position, TupleExpression tuple)
     : base("." + position, ParameterKind.Normal) {
     _tuple = tuple;
 }
Пример #18
0
 public override bool Walk(TupleExpression node)
 {
     node.Parent = _binder._currentScope;
     return true;
 }
Пример #19
0
 public SublistParameter(int position, TupleExpression tuple)
     : base(SymbolTable.StringToId("." + position * 2), ParameterKind.Normal) {
     _tuple = tuple;
 }
Пример #20
0
 public override bool Walk(TupleExpression node)
 {
     return true;
 }
Пример #21
0
 internal override AstExpression Revert()
 {
     AstExpression index = null;
     if (slice is Index)
         index = expr.Revert(((Index)slice).value);
     else if (slice is Slice) {
         Slice concreteSlice = (Slice)slice;
         AstExpression start = null;
         if (concreteSlice.lower != null)
             start = expr.Revert(concreteSlice.lower);
         AstExpression stop = null;
         if (concreteSlice.upper != null)
             stop = expr.Revert(concreteSlice.upper);
         AstExpression step = null;
         bool stepProvided = false;
         if (concreteSlice.step != null) {
             stepProvided = true;
             if (concreteSlice.step is Name && ((Name)concreteSlice.step).id == "None") {
                 // pass
             } else {
                 step = expr.Revert(concreteSlice.step);
             }
         }
         index = new SliceExpression(start, stop, step, stepProvided);
     } else if (slice is Ellipsis) {
         index = new ConstantExpression(PythonOps.Ellipsis);
     } else if (slice is ExtSlice) {
         index = new TupleExpression(true, ((ExtSlice)slice).Revert());
     } else {
         Debug.Assert(false, "Unexpected type when converting Subscript: " + slice.GetType());
     }
     return new IndexExpression(expr.Revert(value), index);
 }
Пример #22
0
        private Expression MakeTupleOrExpr(List<Expression> l, bool trailingComma, bool expandable) {
            if (l.Count == 1 && !trailingComma) return l[0];

            Expression[] exprs = l.ToArray();
            TupleExpression te = new TupleExpression(expandable && !trailingComma, exprs);
            if (exprs.Length > 0) {
                te.SetLoc(_globalParent, exprs[0].StartIndex, exprs[exprs.Length - 1].EndIndex);
            }
            return te;
        }
Пример #23
0
 public override bool Walk(TupleExpression node) => WalkItems(node.Items);