public override void Assign(object val, NameEnv env)
        {
            // Disallow "[] = l", "[], a = l, l", "[[]] = [l]", etc
            if (items.Length == 0)
            {
                throw Ops.SyntaxError("can't assign to " + EmptySequenceString, "<unknown>",
                                      start.line, start.column, null, 0, IronPython.Hosting.Severity.Error);
            }

            IEnumerator ie = Ops.GetEnumerator(val);

            int leftCount = items.Length;

            object[] values = new object[leftCount];

            int rightCount = Ops.GetEnumeratorValues(ie, ref values);

            if (leftCount != rightCount)
            {
                throw Ops.ValueErrorForUnpackMismatch(leftCount, rightCount);
            }

            for (int i = 0; i < leftCount; i++)
            {
                items[i].Assign(values[i], env);
            }
        }
        public override object Evaluate(NameEnv env)
        {
            object t = target.Evaluate(env);
            object i = index.Evaluate(env);

            return(Ops.GetIndex(t, i));
        }
        public override void Assign(object val, NameEnv env)
        {
            object t = target.Evaluate(env);
            object i = index.Evaluate(env);

            Ops.SetIndex(t, i, val);
        }
        public override object Evaluate(NameEnv env)
        {
            object e1 = slStart.Evaluate(env);
            object e2 = slStop.Evaluate(env);
            object e3 = slStep.Evaluate(env);

            return(Ops.MakeSlice(e1, e2, e3));
        }
        public override object Evaluate(NameEnv env)
        {
            //!!! not right for compare
            object l = left.Evaluate(env);
            object r = right.Evaluate(env);

            return(op.Evaluate(l, r));
        }
 public static object[] Evaluate(Expr[] items, NameEnv env)
 {
     object[] ret = new object[items.Length];
     for (int i = 0; i < items.Length; i++)
     {
         ret[i] = items[i].Evaluate(env);
     }
     return(ret);
 }
        public override object Evaluate(NameEnv env)
        {
            IDictionary <object, object> dict = Ops.MakeDict(items.Length);

            foreach (SliceExpr s in items)
            {
                dict[s.slStart.Evaluate(env)] = s.slStop.Evaluate(env);
            }
            return(dict);
        }
Beispiel #8
0
        public override object Execute(NameEnv env)
        {
            object v = rhs.Evaluate(env);

            foreach (Expr e in lhs)
            {
                e.Assign(v, env);
            }
            return(NextStmt);
        }
        public override object Evaluate(NameEnv env)
        {
            object ret = left.Evaluate(env);

            if (!Ops.IsTrue(ret))
            {
                return(right.Evaluate(env));
            }
            else
            {
                return(ret);
            }
        }
Beispiel #10
0
        public override object Execute(NameEnv env)
        {
            object ret = Stmt.NextStmt;

            foreach (Stmt stmt in stmts)
            {
                ret = stmt.Execute(env);
                if (ret != Stmt.NextStmt)
                {
                    break;
                }
            }
            return(ret);
        }
Beispiel #11
0
        public override object Execute(NameEnv env)
        {
            Console.Out.Write("print> ");
            foreach (Expr e in exprs)
            {
                object val = e.Evaluate(env);
                Ops.PrintComma(env.globals.SystemState, val);
            }
            if (!trailingComma)
            {
                Ops.PrintNewline(env.globals.SystemState);
            }

            return(NextStmt);
        }
Beispiel #12
0
 public override object Execute(NameEnv env)
 {
     foreach (IfStmtTest t in tests)
     {
         object val = t.test.Evaluate(env);
         if (Ops.IsTrue(val))
         {
             return(t.body.Execute(env));
         }
     }
     if (elseStmt != null)
     {
         return(elseStmt.Execute(env));
     }
     return(NextStmt);
 }
Beispiel #13
0
        public override object Execute(NameEnv env)
        {
            object ret = NextStmt;

            while (Ops.IsTrue(test.Evaluate(env)))
            {
                ret = body.Execute(env);
                if (ret != NextStmt)
                {
                    break;
                }
            }
            return(ret);
            //			if (else_ != null) {
            //				else_.exec(env);
            //			}
        }
Beispiel #14
0
        public override object Execute(NameEnv env)
        {
            object ret = Stmt.NextStmt;

            IEnumerator i = Ops.GetEnumerator(list.Evaluate(env));

            while (i.MoveNext())
            {
                lhs.Assign(i.Current, env);
                ret = body.Execute(env);
                if (ret != NextStmt)
                {
                    return(ret);
                }
            }

            return(ret);
            //			if (else_ != null) {
            //				else_.exec(env);
            //			}
        }
Beispiel #15
0
        public override object Evaluate(NameEnv env)
        {
            object callee = target.Evaluate(env);

            object[] cargs = new object[args.Length];
            int      index = 0;

            foreach (Arg arg in args)
            {
                if (arg.name != null)
                {
                    throw new NotImplementedException("keywords");
                }
                cargs[index++] = arg.expr.Evaluate(env);
            }

            switch (cargs.Length)
            {
            case 0: return(Ops.Call(callee));

            default: return(Ops.Call(callee, cargs));
            }
        }
Beispiel #16
0
 public override object Evaluate(NameEnv env)
 {
     return(Ops.Repr(expr.Evaluate(env)));
 }
Beispiel #17
0
 public override object Execute(NameEnv env)
 {
     return(NextStmt);
 }
Beispiel #18
0
 public override object Execute(NameEnv env)
 {
     return(expr.Evaluate(env));
 }
Beispiel #19
0
        public override object Evaluate(NameEnv env)
        {
            object t = target.Evaluate(env);

            return(Ops.GetAttr(env.globals, t, SymbolTable.StringToId(name.GetString())));
        }
Beispiel #20
0
        public override object Execute(NameEnv env)
        {
            Ops.ImportFrom(env.globals, root.MakeString(), Name.ToStrings(names));

            return(NextStmt);
        }
Beispiel #21
0
        public override void Assign(object val, NameEnv env)
        {
            object t = target.Evaluate(env);

            Ops.SetAttr(env.globals, t, SymbolTable.StringToId(name.GetString()), val);
        }
Beispiel #22
0
 public virtual void Assign(object val, NameEnv env)
 {
     throw new NotImplementedException("Assign: " + this);
 }
Beispiel #23
0
 public override void Assign(object val, NameEnv env)
 {
     env.Set(name.GetString(), val);
 }
Beispiel #24
0
 public override object Evaluate(NameEnv env)
 {
     return(Ops.MakeList(Evaluate(items, env)));
 }
Beispiel #25
0
 public virtual object Execute(NameEnv env)
 {
     throw new NotImplementedException("execute: " + this);
 }
Beispiel #26
0
 public override void Assign(object val, NameEnv env)
 {
     expr.Assign(val, env);
 }
Beispiel #27
0
 public override object Execute(NameEnv env)
 {
     expr.Evaluate(env);
     //!!! print it if in the right env
     return(NextStmt);
 }
Beispiel #28
0
 public override object Evaluate(NameEnv env)
 {
     return(value);
 }
Beispiel #29
0
 public override object Evaluate(NameEnv env)
 {
     return(env.Get(name.GetString()));
 }
Beispiel #30
0
 public override object Evaluate(NameEnv env)
 {
     return(func.MakeFunction(env));
 }