Ejemplo n.º 1
0
        // Without this constructor, deserialization will fail
        protected RCException(SerializationInfo info, StreamingContext context)
            : base(info, context)
        {
            string  closureString = info.GetString("Closure");
            bool    fragment;
            RCBlock closureBlock = (RCBlock)RCSystem.Parse(closureString, out fragment);

            Closure = RCClosure.Deserialize(closureBlock);
            Error   = (RCErrors)info.GetValue("Error", typeof(RCErrors));
            string[] outputStrings = (string[])info.GetValue("Output", typeof(string[]));
            if (outputStrings != null)
            {
                Output = new RCString(outputStrings);
            }
        }
Ejemplo n.º 2
0
        public RCValue Rep(string code, bool restoreStateOnError)
        {
            bool    fragment = false;
            RCValue peek     = RCSystem.Parse(code, out fragment);

            if (peek == null)
            {
                return(null);
            }
            RCBlock variable = peek as RCBlock;

            if (variable != null && fragment)
            {
                if (variable.Count == 0)
                {
                    return(null);
                }
                if (variable.Value.ArgumentEval)
                {
                    RCBlock   program = new RCBlock(_state, "", "<-", variable.Value);
                    RCClosure parent  = new RCClosure(_bots[0].Id,
                                                      0,
                                                      null,
                                                      null,
                                                      program,
                                                      null,
                                                      _state,
                                                      _state.Count,
                                                      null,
                                                      null,
                                                      noClimb: false,
                                                      noResolve: false);
                    RCClosure child = new RCClosure(parent,
                                                    _bots[0].Id,
                                                    variable.Value,
                                                    null,
                                                    RCBlock.Empty,
                                                    0,
                                                    null,
                                                    null);
                    RCValue result = Run(child, restoreStateOnError);
                    _state = new RCBlock(_state, variable.Name, ":", result);
                }
                else
                {
                    // What about fragments with multiple parts.
                    _state = new RCBlock(_state, variable.Name, ":", variable.Value);
                }
                return(null);
            }
            else
            {
                RCBlock   program = new RCBlock(_state, "", "<-", peek);
                RCClosure parent  = new RCClosure(_bots[0].Id,
                                                  0,
                                                  null,
                                                  null,
                                                  program,
                                                  null,
                                                  _state,
                                                  _state.Count,
                                                  null,
                                                  null,
                                                  noClimb: false,
                                                  noResolve: false);
                RCClosure child  = new RCClosure(parent, _bots[0].Id, peek, null, RCBlock.Empty, 0);
                RCValue   result = Run(child, restoreStateOnError);
                return(result);
            }
        }
Ejemplo n.º 3
0
 public static RCRunner TestRunner()
 {
     RCSystem.Reconfigure(new RCLArgv("--output=test", "--show=print"));
     return(new RCRunner(workers: 1));
 }