コード例 #1
0
ファイル: Exception.cs プロジェクト: retahc/old-code
        static internal object exc_new(RBasic r, params object[] args)
        {
            RException ex = new RException(r.ruby, (RMetaObject)r);

            r.ruby.CallInit(ex, args);
            return(ex);
        }
コード例 #2
0
ファイル: Exception.cs プロジェクト: retahc/old-code
        internal eTagJump(RException e)
        {
            state = Tag.TAG.RAISE;
            rex   = e;
            NetRuby rb = e.ruby;
            RThread th = rb.GetCurrentContext();

            if (th.file != null)
            {
                RArray at = e.Backtrace;
                if (at == null)
                {
                    at          = rb.Backtrace(-1);
                    e.Backtrace = at;
                }
            }
            th.errInfo = e;
            if (rb.debug && e.IsKindOf(rb.eSystemExit) == false)
            {
                Console.Error.WriteLine("Exception `{0}' at {1}:{2} - {3}",
                                        rb.ClassOf(e).Name, th.file, th.line,
                                        e.ToString());
            }

            /*
             * // trace
             * if (th.protTag.Count <= 1)
             * {
             *  rb.errorPrint(th);
             * }
             */
        }
コード例 #3
0
 internal void ErrorAppend(string s)
 {
     if (inEval > 0)
     {
         if (errInfo != null)
         {
             StringBuilder sb = new StringBuilder(errInfo.ToString());
             sb.AppendFormat("\n{0}", s);
             s = sb.ToString();
         }
         errInfo = new RException(ruby, s, ruby.eSyntaxError);
     }
     else
     {
         System.Console.Error.WriteLine("Compile error after line " + line.ToString() + ": " + s);
     }
 }
コード例 #4
0
ファイル: Exception.cs プロジェクト: retahc/old-code
        static internal object exc_exception(RBasic r, params object[] args)
        {
            if (args.Length == 0)
            {
                return(r);
            }
            if (args.Length == 1 && args[0] == r)
            {
                return(r);
            }
            NetRuby     rb    = r.ruby;
            RMetaObject etype = rb.ClassOf(r);

            while (etype is RSingletonClass)
            {
                etype = etype.super;
            }
            RException ex = new RException(rb, etype);

            r.ruby.CallInit(ex, args);
            return(ex);
        }
コード例 #5
0
ファイル: Thread.cs プロジェクト: emtees/old-code
 internal void ErrorAppend(string s)
 {
     if (inEval > 0)
     {
         if (errInfo != null)
         {
             StringBuilder sb = new StringBuilder(errInfo.ToString());
             sb.AppendFormat("\n{0}", s);
             s = sb.ToString();
         }
         errInfo = new RException(ruby, s, ruby.eSyntaxError);
     }
     else
     {
         System.Console.Error.WriteLine("Compile error after line " + line.ToString() + ": " + s);
     }
 }
コード例 #6
0
ファイル: Exception.cs プロジェクト: retahc/old-code
 internal NetRubyException(RException ex)
 {
     errInfo = ex;
 }
コード例 #7
0
ファイル: Exception.cs プロジェクト: emtees/old-code
 static internal object exc_exception(RBasic r, params object[] args)
 {
     if (args.Length == 0) return r;
     if (args.Length == 1 && args[0] == r) return r;
     NetRuby rb = r.ruby;
     RMetaObject etype = rb.ClassOf(r);
     while (etype is RSingletonClass)
     {
         etype = etype.super;
     }
     RException ex = new RException(rb, etype);
     r.ruby.CallInit(ex, args);
     return ex;
 }
コード例 #8
0
ファイル: Exception.cs プロジェクト: emtees/old-code
 static internal object exc_new(RBasic r, params object[] args)
 {
     RException ex = new RException(r.ruby, (RMetaObject)r);
     r.ruby.CallInit(ex, args);
     return ex;
 }
コード例 #9
0
ファイル: Exception.cs プロジェクト: emtees/old-code
 internal eTagJump(RException e)
 {
     state = Tag.TAG.RAISE;
     rex = e;
     NetRuby rb = e.ruby;
     RThread th = rb.GetCurrentContext();
     if (th.file != null)
     {
         RArray at = e.Backtrace;
         if (at == null)
         {
             at = rb.Backtrace(-1);
             e.Backtrace = at;
         }
     }
     th.errInfo = e;
     if (rb.debug && e.IsKindOf(rb.eSystemExit) == false)
     {
         Console.Error.WriteLine("Exception `{0}' at {1}:{2} - {3}",
                                 rb.ClassOf(e).Name, th.file, th.line,
                                 e.ToString());
     }
     /*
     // trace
     if (th.protTag.Count <= 1)
     {
         rb.errorPrint(th);
     }
     */
 }
コード例 #10
0
ファイル: Exception.cs プロジェクト: emtees/old-code
 internal NetRubyException(RException ex)
 {
     errInfo = ex;
 }
コード例 #11
0
ファイル: NETRuby.cs プロジェクト: emtees/old-code
/*
        internal object SpecificEval(RMetaObject klass, RBasic self, object[] argv)
        {
            RThread th = GetCurrentContext();
            if (th.IsBlockGiven)
            {
                if (argv.Length > 0)
                {
                    throw new eArgError(String.Format("wrong # of arguments ({0} for 0)",
                                                      argv.Length));
                }
                return Yield(th, klass, self);
            }
            else
            {
                string file = "(eval)";
                int line = 1;
                int argc = argv.Length;
                if (argc == 0)
                    throw new eArgError("block not supplied");
                CheckSafeString(th, argv[0]);
                if (argc > 3)
                    throw new eArgError(String.Format("wrong # of arguments : {0}(src) or {1}(..)",
                                                      id2name(th.frame.lastFunc),
                                                      id2name(th.frame.lastFunc)));
                if (argc > 1) file = argv[1].ToString();
                if (argc > 2) line = RInteger.ToInt(this, argv[2]);

                return Eval(th, klass, self, argv[0], file, line);
            }
        }
        private object EvalNode(object self, RNode node, RThread th)
        {
            RNode beg = th.evalTreeBegin;
            th.evalTreeBegin = null;
            if (beg != null)
            {
                Eval(self, beg);
            }
            if (node == null) return null;

            return Eval(self, node);
        }

        internal object ruby_eval(RBasic r, params object[] args)
        {
            string file = "(eval)";
            string src = String.Empty;
            int line = 1;
            object[] argv = new object[4];
            ScanArgs(args, "13", argv);
            if (args.Length >= 3)
            {
                if (argv[2] is string)
                {
                    file = (string)argv[2];
                }
                else
                {
                    CheckType(argv[2], typeof(RString));
                    file = ((RString)argv[2]).ToString();
                }
            }
            if (args.Length >= 4)
            {
                line = RInteger.ToInt(this, argv[3]);
            }
            Scope scope = null;
            if (argv[1] != null)
            {
                CheckType(argv[1], typeof(Scope));
                scope = (Scope)argv[1];
            }
            RThread th = GetCurrentContext();
            if (argv[0] is string)
            {
                src = (string)argv[0];
            }
            else
            {
                if (th.safeLevel >= 4)
                {
                    CheckType(argv[0], typeof(RString));
                    if (scope != null && scope.IsTainted == false)
                        throw new SecurityException("Insecure: can't modify trusted binding");
                }
                else
                {
                    CheckSafeString(th, argv[0]);
                }
                src = argv[0].ToString();
            }
            if (scope == null && th.frame.prev != null)
            {
                lock (th)
                {
                    Frame pv = th.frame;
                    Frame fm = th.PushFrame(true);
                    fm.prev = pv;
                }
                object val = Eval(r, src, scope, file, line);
                th.PopFrame();
                return val;
            }
            return Eval(r, src, scope, file, line);
        }
*/
/*        
        internal object ruby_block_given_p(RBasic r, params object[] args)
        {
            RThread th = GetCurrentContext();
            return th.IsPriorBlockGiven;
        }
        internal object ruby_loop(RBasic r, params object[] args)
        {
            for (;;)
            {
                Yield(null, null, null, false);
            }
        }
*/        
        internal object ruby_raise(RBasic r, params object[] args)
        {
            RBasic msg = null;
            switch (args.Length)
            {
            case 0:
                break;
            case 1:
                if (args[0] == null) break;
                if (args[0] is string || args[0] is RString)
                {
                    msg = new RException(this, args[0].ToString(), eRuntimeError);
                    break;
                }
                msg = (RBasic)Funcall(args[0], "exception");
                break;
            case 2:
            case 3:
                msg = (RBasic)Funcall(args[0], "exception", args[1]);
                break;
            default:
                throw new eArgError("wrong # of arguments");
            }
            if (args.Length > 0)
            {
                if (msg.IsKindOf(eException) == false)
                    throw new eTypeError("exception object expected");
                RException.exc_set_backtrace(msg, (args.Length > 2) ? args[2] : null);
            }
            /*
            RThread th = GetCurrentContext();
            if (th.frame != topFrame)
            {
                th.PushFrame(true);
            }
            */
            throw new eTagJump((RException)msg);
        }