Example #1
0
 public Scope(NetRuby r) :
     base(r, null)
 {
     flag = 0;
     local_tbl = null;
     local_vars = null;
 }
Example #2
0
 public Parser(NetRuby rb, RThread th, bool in_eval)
 {
     evalTree = null;
     ruby = rb;
     thread = th;
     compile_for_eval = in_eval;
 }
Example #3
0
 public Parser(NetRuby rb)
 {
     evalTree = null;
     ruby = rb;
     thread = rb.GetCurrentContext();
     compile_for_eval = false;
 }
Example #4
0
        private void CreateBlock(NetRuby rb)
        {
/*        
            RThread th = rb.GetCurrentContext();
            block = th.block.Clone();
            block.origThread = th;
            block.wrapper = th.wrapper;
            block.iter = (block.prev != null) ?  ITER.PRE : ITER.NOT;
            block.frame = block.frame.Dup();
            if (th.frame.prev != null)
            {
                block.frame.lastFunc = th.frame.prev.lastFunc;
                block.frame.lastClass = th.frame.prev.lastClass;
            }
            if (block.iter != 0)
            {
                block.DupPrev();
            }
            else
            {
                block.prev = null;
            }
            block.scope.Dup();
            safeLevel = th.safeLevel;
*/            
        }
Example #5
0
        private Loader(NetRuby rb)
        {
            ruby = rb;
            loadPath = new RArray(rb, true);
            features = new RArray(rb, true);

            string baseDir = AppDomain.CurrentDomain.BaseDirectory;
            loadPath.Add(baseDir);
            loadPath.Add(Path.Combine(baseDir, "lib"));
            loadPath.Add(AppDomain.CurrentDomain.BaseDirectory);
            string lp = Environment.GetEnvironmentVariable("RUBYLIB");
            if (lp != null)
            {
                string[] sp = lp.Split(new char[] { Path.PathSeparator });
                for (int i = 0; i < sp.Length; i++)
                {
                    loadPath.Add(Environment.ExpandEnvironmentVariables(sp[i]));
                }
            }
            /*
            if (rb.SafeLevel == 0)
            {
            */
                loadPath.Add(".");
            /*
            }
            */
        }
Example #6
0
 public RString(NetRuby rb, string s, bool taint) :
     base(rb, rb.cString)
 {
     ptr = s;
     if (taint)
         flags |= FL.TAINT;
 }
Example #7
0
 internal RBignum(NetRuby rb, uint u, bool sgn)
     : base(rb, rb.cBignum)
 {
     sign = sgn;
     len = 1;
     digits = new uint[1];
     digits[0] = u;
 }
Example #8
0
 internal RBignum(NetRuby rb, int ln, bool sgn)
     : base(rb, rb.cBignum)
 {
     sign = sgn;
     len = ln;
     digits = new uint[ln];
     for (int i = 0; i < ln; i++) digits[i] = 0;
 }
Example #9
0
 internal RBignum(NetRuby rb, long l)
     : base(rb, rb.cBignum)
 {
     sign = (l < 0) ? false : true;
     len = 2;
     digits = new uint[2];
     digits[0] = BIGLO(l);
     digits[1] = (uint)BIGDN(l);
 }
Example #10
0
 static internal void Init(NetRuby rb)
 {
     RClass sym = rb.DefineClass("Symbol", rb.cObject);
     rb.cSymbol = sym;
     rb.oSymbol = new Symbol(rb);
     sym.DefineMethod("to_i", new RMethod(to_i), 0);
     sym.DefineMethod("to_int", new RMethod(to_i), 0);
     sym.DefineMethod("inspect", new RMethod(inspect), 0);
     sym.DefineMethod("to_s", new RMethod(to_s), 0);
     sym.DefineMethod("id2name", new RMethod(to_s), 0);
 }
Example #11
0
 internal RMetaObject(NetRuby rb, string name, RMetaObject sp, RMetaObject meta)
     : base(rb, meta)
 {
     super = sp;
     m_tbl = new st_table();
     if (name != null)
     {
         uint id = rb.intern(name);
         IVarSet("__classid__", Symbol.ID2SYM(id));
     }
 }
Example #12
0
        internal static void Init(NetRuby rb)
        {
            REnumerable en = new REnumerable(rb);
            rb.mEnumerable = en;

            en.DefineMethod("find_all", new RMethod(find_all), 0);
            en.DefineMethod("select", new RMethod(find_all), 0);
        
            en.DefineMethod("collect", new RMethod(collect), 0);
            en.DefineMethod("map", new RMethod(collect), 0);
        }
Example #13
0
        internal RBignum(NetRuby rb, uint[] us, bool sgn)
            : base(rb, rb.cBignum)
        {
            sign = sgn;

            len = us.Length;
            digits = us;
            // normalize
            int i = len;
            while (i-- != 0 && digits[i] == 0);
            len = ++i;
        }
Example #14
0
        internal static void Init(NetRuby rb)
        {
            RIOClass io = new RIOClass(rb);
            io.DefineClass("IO", rb.cObject);
            rb.cIO = io;
        
            rb.DefineGlobalFunction("printf", new RMethod(io.ruby_printf), -1);
            rb.DefineGlobalFunction("print", new RMethod(io.ruby_print), -1);
        
            rb.DefineGlobalFunction("p", new RMethod(io.ruby_p), -1);

        }
Example #15
0
 /*
 internal RBasic(NetRuby rb)
 {
 }
 */
 internal RBasic(NetRuby rb, RMetaObject meta)
 {
     klass = meta;
     ruby = rb;
     /*
     if (rb.SafeLevel >= 3)
     {
         flags |= FL.TAINT;
     }
     */
     GetHashCode();        // define ID
 }
Example #16
0
 public RArray(NetRuby rb, ArrayList a, bool clone) :
     base(rb, rb.cArray)
 {
     if (clone)
     {
         // but it creates only a shallow copy.
         ptr = (ArrayList)a.Clone();
     }
     else
     {
         ptr = a;
     }
 }
Example #17
0
 public RArray(NetRuby rb, bool newobj) :
     base(rb, rb.cArray)
 {
     ptr = (newobj) ? new ArrayList() : null;
 }
Example #18
0
 internal static RArray Create(NetRuby rb, object[] args)
 {
     RArray a = new RArray(rb, args);
     return a;
 }
Example #19
0
 public RArray(NetRuby rb, ICollection col) :
     base(rb, rb.cArray)
 {
     ptr = new ArrayList(col);
 }
Example #20
0
 static public RArray AssocNew(NetRuby ruby, object car, object cdr)
 {
     ArrayList ar = new ArrayList();
     ar.Add(car);
     ar.Add(cdr);
     return new RArray(ruby, ar);
 }
Example #21
0
 public RArray(NetRuby rb, ArrayList a) :
     base(rb, rb.cArray)
 {
     ptr = a;
 }
Example #22
0
        internal RThread(NetRuby rb, RThread th) :
            base(rb, rb.cThread)
        {
            result = null;
            ////safeLevel = th.safeLevel;
            gid = th.gid;
            abortOnException = rb.cThread.abortOnException;
            threadId = AppDomain.GetCurrentThreadId();
            thread = Thread.CurrentThread;
            vMode = Scope.ScopeMode.Private;
        
            ////frame = (Frame)rb.topFrame.Dup();
            ////frame.self = rb.topSelf;
            ////frame.cBase = rb.topCRef;
            scopes = new Stack();
            scope = new Scope(rb);
            dyna_vars = null;
            ////iter = new Stack();
            ////iter.Push(ITER.NOT);
            ////protTag = new Stack();
            ////    protTag.Push(null);

            ////block = null;
            lvtbl = null;

            rClass = rb.cObject;
            wrapper = null;
            ////cRef = rb.topCRef;

            file = "ruby";
            line = 0;
            inEval = 0;
            tracing = false;
            errInfo = null;
            lastCallStat = CALLSTAT.PUBLIC;

            locals = null;
        }
Example #23
0
        internal RThread(NetRuby rb) :
            base(rb, rb.cThread)
        {
            result = null;
            ////safeLevel = 0;
            threadId = AppDomain.GetCurrentThreadId();
            thread = Thread.CurrentThread;
            ////vMode = Scope.ScopeMode.Private;
        
            ////frame = new Frame();
            ////rb.topFrame = frame;
            scopes = new Stack();
            scope = new Scope(rb);
            dyna_vars = null;
            ////iter = new Stack();
            ////iter.Push(ITER.NOT);
            ////protTag = new Stack();
            ////    protTag.Push(null);

            ////block = null;
            lvtbl = null;

            rClass = null;
            wrapper = null;
            ////cRef = null;

            file = "ruby";
            line = 0;
            inEval = 0;
            tracing = false;
            errInfo = null;
            lastCallStat = CALLSTAT.PUBLIC;

            locals = null;
            gid = 0;
        }
Example #24
0
 public RArray(NetRuby rb, bool newobj, RMetaObject spr) :
     base(rb, spr)
 {
     ptr = (newobj) ? new ArrayList() : null;
 }
Example #25
0
 internal static void Init(NetRuby rb)
 {
     RThreadGroupClass t = new RThreadGroupClass(rb);
     t.DefineClass("ThreadGroup", rb.cObject);
     rb.cThreadGroup = t;
     t.DefineSingletonMethod("new", new RMethod(tg_new), -1);
     t.DefineMethod("list", new RMethod(list), 0);
     t.DefineMethod("add", new RMethod(add), 1);
     RThreadGroup rg = (RThreadGroup)tg_new(t);
     t.ConstSet(rb.intern("Default"), rg);
     rg.Add(rb.GetCurrentContext());
 }
Example #26
0
        static internal void Init(NetRuby rb)
        {
            BindingFlags bf = BindingFlags.InvokeMethod
                | BindingFlags.Static | BindingFlags.Public
                | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy
                | BindingFlags.Instance;
            RClass ary = rb.DefineClass("Array", rb.cObject);
            RMetaObject.IncludeModule(ary, rb.mEnumerable);
            rb.cArray = ary;
            Type obj = typeof(RArray);
            ary.DefineSingletonMethod("new", new RMethod(s_new), -1);
            ary.DefineSingletonMethod("[]", obj.GetMethod("Create", bf));
        
            ary.DefineMethod("initialize", obj.GetMethod("Initialize", bf));

            ary.DefineMethod("to_ary", obj.GetMethod("ToArray", bf));
            ary.DefineMethod("==", obj.GetMethod("ArrayEqual", bf));
            ary.DefineMethod("eql?", obj.GetMethod("ArrayEql", bf));

            ary.DefineMethod("[]", obj.GetMethod("ARef", bf));
            ary.DefineMethod("[]=", obj.GetMethod("ASet", bf));
            ary.DefineMethod("at", obj.GetMethod("At", bf));
            ary.DefineMethod("first", obj.GetMethod("get_First", bf));
            ary.DefineMethod("last", obj.GetMethod("get_Last", bf));
            ary.DefineMethod("concat", obj.GetMethod("Concat", bf));
            ary.DefineMethod("<<", obj.GetMethod("Push", bf));
            ary.DefineMethod("push", obj.GetMethod("Push", bf));
            ary.DefineMethod("pop", obj.GetMethod("Pop", bf));
            ary.DefineMethod("shift", obj.GetMethod("Shift", bf));
            ary.DefineMethod("unshift", obj.GetMethod("Unshift", bf));
            ary.DefineMethod("each", obj.GetMethod("Each", bf));
            ary.DefineMethod("each_index", obj.GetMethod("EachIndex", bf));
            ary.DefineMethod("reverse_each", obj.GetMethod("ReverseEach", bf));
            ary.DefineMethod("length", obj.GetMethod("get_Count", bf));
            ary.DefineAlias("size", "length");
            ary.DefineMethod("empty?", obj.GetMethod("get_IsEmpty", bf));
            ary.DefineMethod("index", obj.GetMethod("Index", bf));
            ary.DefineMethod("rindex", obj.GetMethod("RIndex", bf));
        
            ary.DefineMethod("clone", obj.GetMethod("Clone", bf));
            ary.DefineMethod("join", obj.GetMethod("JoinMethod", bf));

            ary.DefineMethod("reverse", obj.GetMethod("Reverse", bf));
            ary.DefineMethod("reverse!", obj.GetMethod("ReverseAt", bf));
            ary.DefineMethod("sort", obj.GetMethod("Sort", bf));
            ary.DefineMethod("sort!", obj.GetMethod("SortAt", bf));
            ary.DefineMethod("collect", obj.GetMethod("Collect", bf));
            ary.DefineMethod("collect!", obj.GetMethod("CollectAt", bf));

            ary.DefineMethod("delete", obj.GetMethod("Delete", bf));
            ary.DefineMethod("delete_at", obj.GetMethod("DeleteAt", bf));
        
            ary.DefineMethod("clear", obj.GetMethod("Clear2", bf));
            ary.DefineMethod("fill", obj.GetMethod("Fill", bf));
            ary.DefineMethod("include", obj.GetMethod("Contains", bf));
        }
Example #27
0
 public RArray(NetRuby rb, int capa) :
     base(rb, rb.cArray)
 {
     ptr = new ArrayList(capa);
 }
Example #28
0
 internal RThreadGroup(NetRuby rb, RMetaObject meta) :
     base(rb, meta)
 {
     gid = GetHashCode();
 }
Example #29
0
 public EmitContext(NetRuby r, string name, string fn)
 {
     filename = fn;
     save = filename != null;
     
     ruby = r;
     
     AppDomain domain = AppDomain.CurrentDomain;
     
     AssemblyName assembly_name = new AssemblyName();
     assembly_name.Name = name;
     
     assembly_builder = domain.DefineDynamicAssembly(assembly_name, 
                 save ? AssemblyBuilderAccess.RunAndSave : AssemblyBuilderAccess.Run);
     
     string module_name = name + "Module";
     
     if(save) {
         module_builder = assembly_builder.DefineDynamicModule(module_name, filename);
     } else {
         module_builder = assembly_builder.DefineDynamicModule(module_name);
     }
 }
Example #30
0
 private RThreadGroupClass(NetRuby rb) :
     base(rb, "ThreadGroup", rb.cObject)
 {
 }