Ejemplo n.º 1
0
 public override dynamic ValueEval(Dictionary<string, dynamic> local, ScriptRunner runner)
 {
     dynamic d;
     if (local.TryGetValue(name, out d))
         return d;
     if (runner.Global.TryGetValue(name, out d))
         return d;
     throw new InnerException(data.ExceptionMessage(string.Format("value name '{0}' is not defined.", name)));
 }
Ejemplo n.º 2
0
 public override dynamic Run(Dictionary<string, dynamic> local, ScriptRunner runner)
 {
     foreach(var s in sentences)
     {
         var r = s.Run(local, runner);
         if (r != null)
             return r;
     }
     return null;
 }
Ejemplo n.º 3
0
 public override IEnumerable<dynamic> CoRoutineRun(Dictionary<string, dynamic> local, ScriptRunner runner)
 {
     dynamic v = null;
     foreach(var s in sentences)
     {
         foreach(var r in s.CoRoutineRun(local, runner))
         {
             v = r;
             if (YieldReturn.IsYieldValue(r))
             {
                 yield return r;
             }
             else if(r!=null)
             {
                 goto end;
             }
         }
     }
     v = null;
     end:
     yield return v;
 }
Ejemplo n.º 4
0
 public override IEnumerable<dynamic> CoRoutineRun(Dictionary<string, dynamic> local, ScriptRunner runner)
 {
     dynamic v = null;
     foreach (var t in sentences)
     {
         bool c;
         try
         {
             c = t.Item1.ValueEval(local, runner);
         }
         catch (Exception)
         {
             throw new InnerException(data.ExceptionMessage("dynamic type error."));
         }
         if (c)
         {
             foreach(var r in t.Item2.CoRoutineRun(local, runner))
             {
                 if (YieldReturn.IsYieldValue(r))
                 {
                     yield return r;
                 }
                 else if (r != null)
                 {
                     v = r;
                     goto end;
                 }
             }
         }
     }
     if (else_sentence != null)
     {
         foreach (var r in else_sentence.CoRoutineRun(local,runner))
         {
             if (YieldReturn.IsYieldValue(r))
             {
                 yield return r.Value;
             }
             else if (r != null)
             {
                 v = r;
                 goto end;
             }
         }
     }
     v = null;
     end:
     yield return v;
 }
Ejemplo n.º 5
0
 public override dynamic Run(Dictionary<string, dynamic> local, ScriptRunner runner)
 {
     foreach(var t in sentences)
     {
         bool c;
         try
         {
             c = t.Item1.ValueEval(local, runner);
         }
         catch(Exception)
         {
             throw new InnerException(data.ExceptionMessage("dynamic type error."));
         }
         if (c)
             return t.Item2.Run(local, runner);
     }
     if (else_sentence != null)
         return else_sentence.Run(local, runner);
     return null;
 }
Ejemplo n.º 6
0
 public override dynamic StaticEval(ScriptRunner runner)
 {
     return value;
 }
Ejemplo n.º 7
0
 public override IEnumerable<dynamic> CoRoutineRun(Dictionary<string, dynamic> local, ScriptRunner runner)
 {
     dynamic v = null;
     if (local.ContainsKey(name))
         throw new InnerException(data.ExceptionMessage(string.Format("counter value name '{0}' have been be defined.", name)));
     foreach (var r in expr.ValueEval(local, runner))
     {
         local[name] = r;
         foreach(var u in sentence.CoRoutineRun(local, runner))
         {
             if (YieldReturn.IsYieldValue(u))
             {
                 yield return u;
             }
             else if (u != null)
             {
                 v = u;
                 goto end;
             }
         }
         
     }
     v = null;
     end:
     local.Remove(name);
     yield return v;
 }
Ejemplo n.º 8
0
 public override dynamic Run(Dictionary<string, dynamic> local, ScriptRunner runner)
 {
     throw new InnerException(data.ExceptionMessage("yield_return in normal calling is not allowed"));
 }
Ejemplo n.º 9
0
 public override dynamic Run(Dictionary<string, dynamic> local, ScriptRunner runner)
 {
     return expr.ValueEval(local, runner);
 }
Ejemplo n.º 10
0
 public override dynamic Run(Dictionary<string, dynamic> local, ScriptRunner runner)
 {
     runner.Global[name] = expr.ValueEval(local, runner);
     return null;
 }
Ejemplo n.º 11
0
 public abstract dynamic Run(Dictionary<string, dynamic> local, ScriptRunner runner);
Ejemplo n.º 12
0
 public override dynamic StaticEval(ScriptRunner runner)
 {
     var d = (from e in exprs select e.StaticEval(runner)).ToArray();
     return d.Contains(null) ? null : func.StaticCall(d, data);
 }
Ejemplo n.º 13
0
 public override dynamic ValueEval(Dictionary<string, dynamic> local, ScriptRunner runner)
 {
     return func.Call((from e in exprs select e.ValueEval(local, runner)).ToArray(), data);
 }
Ejemplo n.º 14
0
 public override dynamic StaticEval(ScriptRunner runner)
 {
     dynamic d;
     return runner.ConstantValue.TryGetValue(name, out d) ? d : null;
 }
Ejemplo n.º 15
0
 public abstract dynamic StaticEval(ScriptRunner runner);
Ejemplo n.º 16
0
 public override IEnumerable<dynamic> CoRoutineRun(Dictionary<string, dynamic> local, ScriptRunner runner)
 {
     local[name] = expr.ValueEval(local, runner);
     yield return null;
 }
Ejemplo n.º 17
0
 public abstract IEnumerable<dynamic> CoRoutineRun(Dictionary<string, dynamic> local, ScriptRunner runner);
Ejemplo n.º 18
0
 public override IEnumerable<dynamic> CoRoutineRun(Dictionary<string, dynamic> local, ScriptRunner runner)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 19
0
        public override IEnumerable<dynamic> CoRoutineRun(Dictionary<string, dynamic> local, ScriptRunner runner)
        {
            if (local.ContainsKey(name))
                throw new InnerException(data.ExceptionMessage(string.Format("counter value name '{0}' have been be defined.", name)));
            var las = last.ValueEval(local, runner);
            var ste = step.ValueEval(local, runner);
            bool c;
            dynamic v = null;

            local[name] = first.ValueEval(local, runner);
            try
            {
                c = (local[name] != las);
            }
            catch (Exception)
            {
                throw new InnerException(data.ExceptionMessage("dynamic type error."));
            }
            while (c)
            {
                foreach (var r in source.CoRoutineRun(local, runner))
                {
                    if (YieldReturn.IsYieldValue(r))
                    {
                        yield return r;
                    }
                    else if (r != null)
                    {
                        v = r;
                        goto end;
                    }
                }
                try
                {
                    local[name] = local[name] + ste;
                    c = (local[name] != las);
                }
                catch (Exception)
                {
                    throw new InnerException(data.ExceptionMessage("dynamic type error."));
                }
            }
            foreach(var r in source.CoRoutineRun(local, runner))
            {
                if (YieldReturn.IsYieldValue(r))
                    yield return r;
                else if (r != null)
                {
                    v = r;
                    goto end;
                }
            }
            v = null;
            end:
            local.Remove(name);
            yield return v;
        }
Ejemplo n.º 20
0
 public override IEnumerable<dynamic> CoRoutineRun(Dictionary<string, dynamic> local, ScriptRunner runner)
 {
     yield return new YieldValue(expr.ValueEval(local, runner));
 }
Ejemplo n.º 21
0
 public override dynamic Run(Dictionary<string, dynamic> local, ScriptRunner runner)
 {
     bool c;
     try
     {
         c = cond.ValueEval(local, runner);
     }
     catch(Exception)
     {
         throw new InnerException(data.ExceptionMessage("dynamic type error."));
     }
     while (c)
     {
         var r = source.Run(local, runner);
         if (r != null)
             return r;
         try
         {
             c = cond.ValueEval(local, runner);
         }
         catch (Exception)
         {
             throw new InnerException(data.ExceptionMessage("dynamic type error."));
         }
     }
     return null;
 }
Ejemplo n.º 22
0
 public override dynamic Run(Dictionary<string, dynamic> local, ScriptRunner runner)
 {
     if (local.ContainsKey(name))
         throw new InnerException(data.ExceptionMessage(string.Format("counter value name '{0}' have been be defined.", name)));
     foreach (var r in expr.ValueEval(local, runner))
     {
         local[name] = YieldReturn.RemoveYield(r);
         var v = sentence.Run(local, runner);
         if (v != null)
             return v;
     }
     local.Remove(name);
     return null;
 }
Ejemplo n.º 23
0
 public override IEnumerable<dynamic> CoRoutineRun(Dictionary<string, dynamic> local, ScriptRunner runner)
 {
     bool c;
     dynamic v = null;
     try
     {
         c = cond.ValueEval(local, runner);
     }
     catch (Exception)
     {
         throw new InnerException(data.ExceptionMessage("dynamic type error."));
     }
     while (c)
     {
         foreach (var r in source.CoRoutineRun(local, runner))
         {
             if(YieldReturn.IsYieldValue(r))
             {
                 yield return r;
             }
             else if (r != null)
             {
                 v = r;
                 goto end;
             }
             try
             {
                 c = cond.ValueEval(local, runner);
             }
             catch (Exception)
             {
                 throw new InnerException(data.ExceptionMessage("dynamic type error."));
             }
         }
     }
     v = null;
     end:
     yield return v;
 }
Ejemplo n.º 24
0
        public override dynamic Run(Dictionary<string, dynamic> local, ScriptRunner runner)
        {
            if (local.ContainsKey(name))
                throw new InnerException(data.ExceptionMessage(string.Format("counter value name '{0}' have been be defined.", name)));
            var las = last.ValueEval(local, runner);
            var ste = step.ValueEval(local, runner);
            bool c;

            local[name] = first.ValueEval(local, runner);
            try
            {
                c = (local[name] != las);
            }
            catch (Exception)
            {
                throw new InnerException(data.ExceptionMessage("dynamic type error."));
            }
            while (c)
            {
                var r = source.Run(local, runner);
                if (r != null)
                    return r;
                try
                {
                    local[name] = local[name] + ste;
                    c = (local[name] != las);
                }
                catch (Exception)
                {
                    throw new InnerException(data.ExceptionMessage("dynamic type error."));
                }
            }
            source.Run(local, runner);
            local.Remove(name);
            return null;
        }
Ejemplo n.º 25
0
 public override dynamic ValueEval(Dictionary<string, dynamic> local, ScriptRunner runner)
 {
     return value;
 }