예제 #1
0
 public void EvalIsolate(RCRunner runner, RCClosure closure, RCBlock right)
 {
     DoIsolate(runner, closure, new string[] { }, right);
 }
예제 #2
0
 public void EvalPop(RCRunner runner, RCClosure closure, RCByte right)
 {
     runner.Yield(closure, new RCByte(DoPop <byte> (right.Data)));
 }
예제 #3
0
 public void EvalGet(RCRunner runner, RCClosure closure, RCSymbol left, RCBlock right)
 {
     EvalGet(runner, closure, right, left);
 }
예제 #4
0
 public void EvalPop(RCRunner runner, RCClosure closure, RCString right)
 {
     runner.Yield(closure, new RCString(DoPop <string> (right.Data)));
 }
예제 #5
0
 public void EvalPop(RCRunner runner, RCClosure closure, RCSymbol right)
 {
     runner.Yield(closure, new RCSymbol(DoPop <RCSymbolScalar> (right.Data)));
 }
예제 #6
0
 public void EvalLast(RCRunner runner, RCClosure closure, RCByte right)
 {
     runner.Yield(closure, new RCByte(right[right.Count - 1]));
 }
예제 #7
0
 public void EvalPop(RCRunner runner, RCClosure closure, RCDouble right)
 {
     runner.Yield(closure, new RCDouble(DoPop <double> (right.Data)));
 }
예제 #8
0
 public void EvalRepeat(RCRunner runner, RCClosure closure, RCLong left, RCDecimal right)
 {
     runner.Yield(closure, new RCDecimal(DoRepeat <decimal> (left, right)));
 }
예제 #9
0
 public void EvalRepeat(RCRunner runner, RCClosure closure, RCLong left, RCBoolean right)
 {
     runner.Yield(closure, new RCBoolean(DoRepeat <bool> (left, right)));
 }
예제 #10
0
 public void EvalCount(RCRunner runner, RCClosure closure, RCOperator right)
 {
     runner.Yield(closure, new RCLong(right.Count));
 }
예제 #11
0
 public void EvalRepeat(RCRunner runner, RCClosure closure, RCLong left, RCDouble right)
 {
     runner.Yield(closure, new RCDouble(DoRepeat <double> (left, right)));
 }
예제 #12
0
 public void EvalCount(RCRunner runner, RCClosure closure, RCTemplate right)
 {
     runner.Yield(closure, new RCLong(right.Count));
 }
예제 #13
0
        protected void DoIsolate(RCRunner runner, RCClosure closure, string[] argv, RCValue code)
        {
            Thread thread = new Thread(delegate()
            {
                Queue <string> argQueue = new Queue <string> (argv);
                string result           = null;
                AppDomain appDomain     = null;
                Program program;
                Exception isolateEx = null;
                try
                {
                    AppDomainSetup setupInfo = new AppDomainSetup();
                    string build             = "dev";
                    if (argQueue.Count > 0)
                    {
                        string first   = argv[0];
                        string rclHome = Environment.GetEnvironmentVariable("RCL_HOME");
                        if (rclHome == null)
                        {
                            throw new Exception(
                                "RCL_HOME was not set. It is needed in order to locate the specified binary: " +
                                first);
                        }
                        if (first == "dev")
                        {
                            build = first;
                            // It should use the dev build in this case. The current build is not the
                            // dev build.
                            setupInfo = AppDomain.CurrentDomain.SetupInformation;
                            setupInfo.ApplicationBase = rclHome + "/dev/rcl/dbg";
                            argQueue.Dequeue();
                        }
                        else if (first == "last")
                        {
                            argQueue.Dequeue();
                            throw new NotImplementedException(
                                "last option is not yet implemented. Please specify a build number");
                        }
                        else
                        {
                            int number;
                            if (int.TryParse(first, out number))
                            {
                                build = number.ToString();
                                setupInfo.ApplicationBase = rclHome + "/bin/rcl_bin/" + number + "/lib";
                                argQueue.Dequeue();
                            }
                            else
                            {
                                setupInfo = AppDomain.CurrentDomain.SetupInformation;
                            }
                        }
                    }
                    string appDomainName = "Isolated build:" + build + " id:" + Guid.NewGuid();
                    appDomain            = AppDomain.CreateDomain(appDomainName, null, setupInfo);
                    Type type            = typeof(Program);
                    program = (Program)appDomain.CreateInstanceAndUnwrap(type.Assembly.FullName,
                                                                         type.FullName);
                    string appDomainVersionString = setupInfo.ApplicationBase;
                    // RCSystem.CrossDomainTraceHelper.StartListening (appDomain);
                    program.IsolateCode = code.ToString();
                    program.InstanceMain(argQueue.ToArray(), appDomainVersionString);
                    result    = (string)appDomain.GetData("IsolateResult");
                    isolateEx = (Exception)appDomain.GetData("IsolateException");
                }
                catch (Exception ex)
                {
                    runner.Finish(closure, ex, 1);
                }
                finally
                {
                    if (appDomain != null)
                    {
                        AppDomain.Unload(appDomain);
                        appDomain = null;
                    }
                }
                if (result == null)
                {
                    if (isolateEx == null)
                    {
                        isolateEx = new Exception("Missing IsolateResult for program");
                    }
                    runner.Finish(closure, isolateEx, 1);
                }
                else
                {
                    runner.Yield(closure, RCSystem.Parse(result));
                }
            });

            thread.IsBackground = true;
            thread.Start();
        }
예제 #14
0
 public void EvalIsolate(RCRunner runner, RCClosure closure, RCString left, RCBlock right)
 {
     DoIsolate(runner, closure, left.ToArray(), right);
 }
예제 #15
0
 public void EvalRest(RCRunner runner, RCClosure closure, RCIncr right)
 {
     runner.Yield(closure, new RCIncr(DoRest <RCIncrScalar> (right.Data)));
 }
예제 #16
0
 public void EvalRepeat(RCRunner runner, RCClosure closure, RCLong left, RCString right)
 {
     runner.Yield(closure, new RCString(DoRepeat <string> (left, right)));
 }
예제 #17
0
 public void EvalFirst(RCRunner runner, RCClosure closure, RCBlock right)
 {
     runner.Yield(closure, right.Get(0));
 }
예제 #18
0
 public void EvalRepeat(RCRunner runner, RCClosure closure, RCLong left, RCIncr right)
 {
     runner.Yield(closure, new RCIncr(DoRepeat <RCIncrScalar> (left, right)));
 }
예제 #19
0
 public void EvalPop(RCRunner runner, RCClosure closure, RCBlock right)
 {
     runner.Yield(closure, right.Previous);
 }
예제 #20
0
 public void EvalOperator(RCRunner runner, RCClosure closure, RCBoolean left, RCBoolean right)
 {
     runner.Yield(closure, DoFind <bool> (left, right));
 }
예제 #21
0
 public void EvalPop(RCRunner runner, RCClosure closure, RCDecimal right)
 {
     runner.Yield(closure, new RCDecimal(DoPop <decimal> (right.Data)));
 }
예제 #22
0
 public void EvalOperator(RCRunner runner, RCClosure closure, RCDouble left, RCDouble right)
 {
     runner.Yield(closure, DoFind <double> (left, right));
 }
예제 #23
0
 public void EvalPop(RCRunner runner, RCClosure closure, RCBoolean right)
 {
     runner.Yield(closure, new RCBoolean(DoPop <bool> (right.Data)));
 }
예제 #24
0
 public void EvalOperator(RCRunner runner, RCClosure closure, RCDecimal left, RCDecimal right)
 {
     runner.Yield(closure, DoFind <decimal> (left, right));
 }
예제 #25
0
 public void EvalPop(RCRunner runner, RCClosure closure, RCTime right)
 {
     runner.Yield(closure, new RCTime(DoPop <RCTimeScalar> (right.Data)));
 }
예제 #26
0
 public void EvalOperator(RCRunner runner, RCClosure closure, RCString left, RCString right)
 {
     runner.Yield(closure, DoFind <string> (left, right));
 }
예제 #27
0
 public void EvalFirst(RCRunner runner, RCClosure closure, RCDecimal right)
 {
     runner.Yield(closure, new RCDecimal(right[0]));
 }
예제 #28
0
 public void EvalOperator(RCRunner runner, RCClosure closure, RCTime left, RCTime right)
 {
     runner.Yield(closure, DoFind <RCTimeScalar> (left, right));
 }
예제 #29
0
 public void EvalFirst(RCRunner runner, RCClosure closure, RCString right)
 {
     runner.Yield(closure, new RCString(right[0]));
 }
예제 #30
0
 public override void Close(RCRunner runner, RCClosure closure)
 {
     _client.Dispose();
     runner.Yield(closure, new RCLong(_handle));
 }