示例#1
0
文件: Kernel.cs 项目: emtees/old-code
 public object ruby_float(RBasic r, params object[] o)
 {
     if (o[0] == null || o[0] == ruby.oNil) return new RFloat(ruby, 0.0);
 
     RBasic x = ruby.InstanceOf(o[0]);
     return (RFloat)ruby.ConvertType(x, typeof(RFloat), "Float", "to_f");
 }
示例#2
0
文件: Object.cs 项目: emtees/old-code
        internal RBasic(RBasic o)
        {
            ruby = o.ruby;
            if (o.klass is RSingletonClass)
            {
                RMetaObject org = o.klass;
                RMetaObject meta = (RMetaObject)org.Clone();
                if (meta.m_tbl == null) meta.m_tbl = new st_table();
                else meta.m_tbl.Clear();
/*
                foreach (DictionaryEntry ent in org.m_tbl)
                {
                    RNMethod m = (RNMethod)ent.Value;
                    meta.m_tbl.Add(ent.Key, new RNMethod(m));
                }
*/
                klass = meta;
            }
            else
            {
                klass = o.klass;
            }
            flags = o.flags;
/*            
            if (o.Test(FL.EXIVAR))
            {
                ruby.CloneGenericIVar(this, o);
            }
*/            
            GetHashCode();        // define ID
        }
示例#3
0
文件: IO.cs 项目: emtees/old-code
 public object ruby_p(RBasic r, params object[] o)
 {
     foreach (object x in o)
     {
         System.Console.Out.Write(RString.AsString(ruby, ruby.Inspect(x)) + ruby.defaultRecSep);
     }
     // check defout and if file, then flush
     return null;
 }
示例#4
0
文件: Enum.cs 项目: emtees/old-code
        private static object find_all(RBasic r, params object[] args)
        {
/*        
            NetRuby ruby = r.ruby;
            RArray ary = new RArray(ruby, true);
            ruby.Iterate(new NetRuby.IterationProc(Each), r,
                         new NetRuby.BlockProc(find_all_i), ary);
            return ary;
*/
            return null; //PH
        }
示例#5
0
文件: Enum.cs 项目: emtees/old-code
        private static object collect(RBasic r, params object[] args)
        {
/*        
            NetRuby ruby = r.ruby;
            RArray ary = new RArray(ruby, true);
            ruby.Iterate(new NetRuby.IterationProc(Each), r,
                         (ruby.IsBlockGiven) ? new NetRuby.BlockProc(collect_i) :
                                               new NetRuby.BlockProc(enum_all), ary);
            return ary;
*/
            return null; //PH
        }
示例#6
0
文件: Kernel.cs 项目: emtees/old-code
 public object ruby_array(RBasic r, params object[] o)
 {
     RBasic x = ruby.InstanceOf(o[0]);
     object val;
     uint to_ary = ruby.intern("to_ary");
     if (x.RespondTo(to_ary, false))
         val = ruby.Funcall(x, to_ary, null);
     else
         val = ruby.Funcall(x, ruby.intern("to_a"), null);
     if (val is RArray == false)
         throw new eTypeError("`to_a' did not return Array");
     return (RArray)val;
 }
示例#7
0
文件: Kernel.cs 项目: emtees/old-code
 public object IsKindOf(RBasic obj, params object[] o)
 {
     RMetaObject cl = ruby.ClassOf(obj);
     object c = o[0];
     if (c is RMetaObject == false)
     {
         throw new eTypeError("class or module required");
     }
     while (cl != null)
     {
         if (cl == c || cl.m_tbl == ((RMetaObject)c).m_tbl)
             return true;
         cl = cl.super;
     }
     return false;
 }
示例#8
0
文件: Kernel.cs 项目: emtees/old-code
 public object IsInstanceOf(RBasic r, params object[] args)
 {
     object o = args[0];
     if (o == null)
     {
         return (r == ruby.oNil) ? true : false;
     }
     else if (o is bool)
     {
         return ((bool)o) ? r == ruby.oTrue : r == ruby.oFalse;
     }
     else if (o is RMetaObject == false)
     {
         throw new eTypeError("class or module required");
     }
     return r.Class == o;
 }
示例#9
0
文件: IO.cs 项目: emtees/old-code
 public object ruby_print(RBasic r, params object[] o)
 {
     string s = String.Empty;
     if (o.Length == 0)
     {
         s = obj_to_s(NetRuby.lastLineGetter(0, null, ruby));
     }
     else
     {
         foreach (object x in o)
         {
             s += obj_to_s(x);
         }
     }
     System.Console.Out.Write(s);
     return null;
 }
示例#10
0
 // A block argument to blocks is allowed in newer versions of Ruby
 public abstract RBasic Call(RThread thread, RBasic[] args, RCBlock block);
示例#11
0
文件: Array.cs 项目: emtees/old-code
 private object inspect_join(RBasic ary, object[] args)
 {
     RString rs = ((RArray)args[0]).Join(args[1]);
     return rs;
 }
示例#12
0
文件: Array.cs 项目: emtees/old-code
 static public RArray AssocNew(NetRuby ruby, RBasic car, RBasic cdr)
 {
     ArrayList ar = new ArrayList();
     ar.Add(car);
     ar.Add(cdr);
     return new RArray(ruby, ar);
 }
示例#13
0
文件: Thread.cs 项目: emtees/old-code
 static internal object add(RBasic r, params object[] args)
 {
     return ((RThreadGroup)r).Add(args[0]);
 }
示例#14
0
文件: Thread.cs 项目: emtees/old-code
 static internal object tg_new(RBasic r, params object[] args)
 {
     return NewThreadGroup(args, (RMetaObject)r);
 }
示例#15
0
文件: Thread.cs 项目: emtees/old-code
 static internal object thread_aset(RBasic r, params object[] args)
 {
     return ((RThread)r).SetTLS(args[0], args[1]);
 }
示例#16
0
文件: Thread.cs 项目: emtees/old-code
 static internal object thread_priority_set(RBasic r, params object[] args)
 {
     NetRuby rb = r.ruby;
     long l = rb.InstanceOf(args[0]).ToInteger().ToLong();
     if (Array.IndexOf(threadPtyVal, (int)l) < 0)
     {
         throw new ArgumentException("invalid thread priority value");
     }
     ((RThread)r).Priority = (int)l;
     return null;
 }
示例#17
0
文件: Thread.cs 项目: emtees/old-code
/*        
        static internal object thread_safe_level(RBasic r, params object[] args)
        {
            return ((RThread)r).safeLevel;
        }
*/        
        static internal object thread_aref(RBasic r, params object[] args)
        {
            return ((RThread)r).GetTLS(args[0]);
        }
示例#18
0
文件: Thread.cs 项目: emtees/old-code
 static internal object thread_raise(RBasic r, params object[] args)
 {
     return ((RThread)r).Raise(args);
 }
示例#19
0
文件: Thread.cs 项目: emtees/old-code
 static internal object thread_keyp(RBasic r, params object[] args)
 {
     return ((RThread)r).IsKey(args[0]);
 }
示例#20
0
文件: Thread.cs 项目: emtees/old-code
 static internal object critical_getset(RBasic r, params object[] args)
 {
     throw new NotSupportedException("NETRuby can't handle Thread#critical");
 }
示例#21
0
文件: Thread.cs 项目: emtees/old-code
 static internal object list(RBasic r, params object[] args)
 {
     return ((RThreadGroup)r).List;
 }
示例#22
0
文件: Thread.cs 项目: emtees/old-code
 static internal object thread_s_abort_exc(RBasic r, params object[] args)
 {
     NetRuby rb = r.ruby;
     return rb.cThread.AbortOnException;
 }
示例#23
0
文件: Thread.cs 项目: emtees/old-code
 public void GlobalSet(string name, RBasic val)
 {
     GlobalEntry ent = ruby.global_entry(ruby.global_id(name));
     ruby.GVarSet(ent, val);
 }
示例#24
0
文件: Thread.cs 项目: emtees/old-code
 static internal object thread_s_abort_set(RBasic r, params object[] args)
 {
     NetRuby rb = r.ruby;
     bool b = RBasic.RTest(args[0]);
     rb.cThread.AbortOnException = b;
     return b;
 }
示例#25
0
文件: Array.cs 项目: emtees/old-code
 private object inspect_ary(RBasic ary, object[] args)
 {
     bool taint = false;
     StringBuilder result = new StringBuilder("[");
     for (int i = 0; i < ptr.Count; i++)
     {
         object o = ruby.Inspect(ptr[i]);
         if (o is RBasic && ((RBasic)o).IsTainted) taint = true;
         if (i > 0)
             result.AppendFormat(", {0}", (o == null) ? "nil" : o.ToString());
         else
             result.Append(o.ToString());
     }
     result.Append("]");
     if (IsTainted || taint)
         return new RString(ruby, result.ToString(), true);
     else
         return result.ToString();
 }
示例#26
0
文件: Thread.cs 项目: emtees/old-code
 static internal object thread_abort_exc(RBasic r, params object[] args)
 {
     return ((RThread)r).AbortOnException;
 }
示例#27
0
文件: Array.cs 项目: emtees/old-code
 internal static object s_new(RBasic r, params object[] args)
 {
     NetRuby rb = r.ruby;
     RArray a = new RArray(rb, false, (RMetaObject)r);
     rb.CallInit(a, args);
     if (a.ptr == null) a.ptr = new ArrayList();
     return a;
 }
示例#28
0
文件: Thread.cs 项目: emtees/old-code
 static internal object thread_abort_set(RBasic r, params object[] args)
 {
     bool b = RBasic.RTest(args[0]);
     ((RThread)r).AbortOnException = b;
     return b;
 }
示例#29
0
 public RCBlock(RBasic self, RBasic[] locals) 
 {
     this.self = self;
     this.locals = locals;
 }
示例#30
0
文件: Thread.cs 项目: emtees/old-code
 static internal object thread_priority(RBasic r, params object[] args)
 {
     return ((RThread)r).Priority;
 }