Esempio n. 1
0
        private void doResolve(exec fn)
        {
            bool done = false;
            var  res  = tryCallTwo
                        (
                fn,
                value =>
            {
                if (done)
                {
                    return;
                }
                done = true;
                resolve(value);
            },
                reason =>
            {
                if (done)
                {
                    return;
                }
                done = true;
                reject(reason);
            });

            if (!done && res == IS_ERROR)
            {
                done = true;
                reject(LAST_ERROR);
            }
        }
Esempio n. 2
0
            public multi(string line)
            {
                //先分割成多個 basic
                string[] parts = line.Split(';');
                basics = new IRunnable[parts.Length];

                //然後就每一個 basic 進行分類
                for (int i = 0; i < parts.Length; i++)
                {
                    if (IsComment(parts[i]))
                    {
                        basics[i] = new empty();
                    }
                    else if (IsTerm(parts[i]))
                    {
                        basics[i] = new term(parts[i].Trim());
                    }
                    else if (IsExec(parts[i]))
                    {
                        basics[i] = new exec(parts[i].Trim());
                    }
                    else
                    {
                        basics[i] = new decla(parts[i].Trim());
                    }
                }
            }
Esempio n. 3
0
    public static void Main()
    {
        int  s  = 0;
        exec e1 = new exec();

        s = e1.execute((x => 2 * x), 3);
        Contract.Assert(s == 5);
    }
Esempio n. 4
0
 Mecanismo
 (
     exec ex
 )
 {
     this.ex
         =
             ex;
 }
Esempio n. 5
0
 public Promise(exec fn)
 {
     this._state    = State._0_pending;
     this._value    = null;
     this._handlers = null;
     if (fn == noop)
     {
         return;
     }
     doResolve(fn);
 }
Esempio n. 6
0
 private object tryCallTwo(exec fn, CB a, CB b)
 {
     try
     {
         fn(a, b);
         return(null);
     }
     catch (Exception ex)
     {
         LAST_ERROR = ex;
         return(IS_ERROR);
     }
 }
Esempio n. 7
0
 Mecanismo(exec ex)
 {
     this.ex = ex;
 }
Esempio n. 8
0
            public multi(string line)
            {
                //先分割成多個 basic
                string[] parts = line.Split(';');
                basics = new IRunnable[parts.Length];

                //然後就每一個 basic 進行分類
                for (int i = 0; i < parts.Length; i++)
                {
                    if (IsComment(parts[i]))
                    {
                        basics[i] = new empty();
                    }
                    else if (IsTerm(parts[i]))
                    {
                        basics[i] = new term(parts[i].Trim());
                    }
                    else if (IsExec(parts[i]))
                    {
                        basics[i] = new exec(parts[i].Trim());
                    }
                    else
                    {
                        basics[i] = new decla(parts[i].Trim());
                    }
                }
            }