예제 #1
0
 public override void Eval(Executor exec)
 {
     Function f = exec.TypedPop<Function>();
     Executor e2 = new Executor();
     f.Eval(e2);
     CatList list = e2.GetStackAsList();
     exec.Push(list);
 }
예제 #2
0
 public override void Eval(Executor exec)
 {
     Type t = exec.TypedPop<Type>();
     Type u = exec.TypedPop<Type>();
     exec.PushBool(t.Equals(u) || u.Equals(t));
 }
예제 #3
0
 public override void Eval(Executor exec) { TimeSpan x = exec.TypedPop<TimeSpan>(); DateTime y = exec.TypedPop<DateTime>(); exec.Push(y + x); }
예제 #4
0
 public override void Eval(Executor exec)
 {
     int n = exec.PopInt();
     Function f = exec.TypedPop<Function>();
     Function g = exec.TypedPeek<Function>();
     if (g is JumpTable)
     {
         JumpTable jt = g as JumpTable;
         jt.AddCase(n, f);                    
     }
     else
     {
         exec.Pop(); 
         JumpTable jt = new JumpTable(g);
         exec.Push(jt);                        
     }
 }
예제 #5
0
            public override void Eval(Executor exec)
            {
                Function onfalse = exec.TypedPop<Function>();
                Function ontrue = exec.TypedPop<Function>();

                if ((bool)exec.Pop()) {
                    ontrue.Eval(exec);
                }
                else {
                    onfalse.Eval(exec);
                }
            }
예제 #6
0
 public override void Eval(Executor exec)
 {
     QuotedFunction right = exec.TypedPop<QuotedFunction>();
     QuotedFunction left = exec.TypedPop<QuotedFunction>();
     QuotedFunction f = new QuotedFunction(left, right);
     exec.PushFxn(f);
 }
예제 #7
0
 public override void Eval(Executor exec)
 {
     QuotedFunction f = exec.TypedPop<QuotedFunction>();
     exec.Push(FxnsToList(f.GetSubFxns()));
 }
예제 #8
0
 public override void Eval(Executor exec)
 {
     string s = exec.TypedPop<string>();
     CatList f = exec.TypedPop<CatList>();
     Object[] args = f.ToArray();
     GraphicCommand c = new GraphicCommand(s, args);
     WindowGDI.Render(c);
 }
예제 #9
0
 public override void Eval(Executor exec)
 {
     Object self = exec.Pop();
     string s = exec.TypedPop<string>();
     CatList a = exec.TypedPop<CatList>();
     MethodInfo m = self.GetType().GetMethod(s, a.GetTypeArray());
     if (m == null)
         throw new Exception("could not find method " + s + " on object of type " + self.GetType().ToString() + " with matching types");
     Object o = m.Invoke(self, a.ToArray());
     exec.Push(o);
     exec.Push(self);
 }
예제 #10
0
 public override void Eval(Executor exec)
 {
     exec.Push(exec.TypedPop<double>());
 }
예제 #11
0
 public override void Eval(Executor exec)
 {
     WindowGDI.SaveToFile(exec.TypedPop<string>());
 }
예제 #12
0
 public override void Eval(Executor exec)
 {
     exec.Push(exec.TypedPop<CatList>());
 }
예제 #13
0
 public override void Eval(Executor exec)
 {
     CatList second = exec.TypedPop<CatList>();
     CatList first = exec.TypedPeek<CatList>();
     first.AddRange(second);
 }
예제 #14
0
            public override void Eval(Executor exec)
            {
                Function f = exec.TypedPop<Function>();
                CatList list = exec.TypedPeek<CatList>();

                int n = exec.Count();
                for (int i = 0; i < list.Count; ++i)
                {
                    exec.Push(list[i]);
                    f.Eval(exec);
                    if (exec.Count() != n + 1)
                        throw new Exception("dynamic type-checking error in map function");
                    list[i] = exec.Pop();
                }
            }
예제 #15
0
 public override void Eval(Executor exec)
 {
     Function f = exec.TypedPop<Function>();
     f.Eval(exec);
 }
예제 #16
0
 public override void Eval(Executor exec)
 {
     Object self = exec.Pop();
     string s = exec.TypedPop<string>();
     FieldInfo fi = self.GetType().GetField(s);
     if (fi == null)
         throw new Exception("could not find field " + s + " on object of type " + self.GetType().ToString());
     exec.Push(fi.GetValue(self));
     exec.Push(self);
 }
예제 #17
0
 public override void Eval(Executor exec)
 {
     Function f = exec.TypedPop<Function>();
     Object o = exec.Pop();
     f.Eval(exec);
     exec.Push(o);
 }
예제 #18
0
 public override void Eval(Executor exec)
 {
     string s = exec.TypedPop<string>();
     CatList a = exec.TypedPop<CatList>();
     Type t = Type.GetType(s);
     if (t == null)
         throw new Exception("could not find type " + s);
     ConstructorInfo c = t.GetConstructor(a.GetTypeArray());
     if (c == null)
         throw new Exception("could not find constructor for object of type " + t.ToString() + " with matching types");
     Object o = c.Invoke(a.ToArray());
     if (o == null)
         throw new Exception(s + " object could not be constructed");
     exec.Push(o);
 }
예제 #19
0
 public override void Eval(Executor exec)
 {
     CatList fs = exec.TypedPop<CatList>();
     Object o = exec.Peek();
     for (int i = 0; i < fs.Count / 2; ++i)
     {
         Type t = fs[i * 2 + 1] as Type;
         Function f = fs[i * 2] as Function;
         if (t.IsInstanceOfType(o))
         {
             f.Eval(exec);
             return;
         }
     }
     throw new Exception("could not dispatch function");
 }
예제 #20
0
 public override void Eval(Executor exec)
 {
     IEnumerable e = exec.TypedPop<IEnumerable>();
     exec.Push(new CatList(e));
 }
예제 #21
0
 public override void Eval(Executor exec)
 {
     QuotedFunction f = exec.TypedPop<QuotedFunction>();
     f.GetSubFxns().Insert(0, new Pop());
     JumpTable jt = new JumpTable(f);
     exec.Push(jt);
 }
예제 #22
0
 public override void Eval(Executor exec)
 {   
     exec.Push(new Regex(exec.TypedPop<string>()));
 }
예제 #23
0
            public override void Eval(Executor exec)
            {
                Function cond = exec.TypedPop<Function>();
                Function body = exec.TypedPop<Function>();

                cond.Eval(exec);
                while ((bool)exec.Pop())
                {
                    body.Eval(exec);
                    cond.Eval(exec);
                }
            }
예제 #24
0
 public override void Eval(Executor exec)
 {
     Regex re = exec.TypedPop<Regex>();
     string s = exec.TypedPop<string>();
     List<string> list = new List<string>();
     foreach (Match m in re.Matches(s))
         list.Add(m.Value);
     CatList f = new CatList(list);
     exec.Push(f);
 }
예제 #25
0
            public override void Eval(Executor exec)
            {
                Function c = exec.TypedPop<Function>();
                Function t = exec.TypedPop<Function>();
                int n = exec.Count();
                try
                {
                    t.Eval(exec);
                }
                catch (CatException e)
                {
                    exec.ClearTo(n);
                    Output.WriteLine("exception caught");

                    exec.Push(e.GetObject());
                    c.Eval(exec);
                }
            }
예제 #26
0
 public override void Eval(Executor exec)
 {
     Regex re = exec.TypedPop<Regex>();
     string s = exec.TypedPeek<string>();
     Match m = re.Match(s);
     if (m == null)
         exec.Push(-1);
     else
         exec.Push(m.Index);
 }
예제 #27
0
 public override void Eval(Executor exec) { DateTime x = exec.TypedPop<DateTime>(); DateTime y = exec.TypedPop<DateTime>(); exec.Push(y - x); }
예제 #28
0
 public override void Eval(Executor exec)
 {
     exec.Push(exec.TypedPop<Ref>().GetVal());
 }
예제 #29
0
 public override void Eval(Executor exec) { exec.Push(exec.TypedPop<TimeSpan>().TotalMilliseconds); }
예제 #30
0
 public override void Eval(Executor exec)
 {
     HashList hash = exec.TypedPop<HashList>();
     exec.Push(hash.ToArray());
 }