Esempio n. 1
0
 protected override PExpr DoVisit()
 {
     for ( ; ;)
     {
         if (!Expr.DoWhile)
         {
             if (IsPendingOrSignal(ref _condition, Expr.Condition))
             {
                 return(PendingOrSignal(_condition));
             }
             if (!_condition.Result.ToBoolean())
             {
                 break;
             }
         }
         if (IsPendingOrSignal(ref _code, Expr.Code))
         {
             if (_code.IsSignal)
             {
                 RuntimeFlowBreaking b = _code.Result as RuntimeFlowBreaking;
                 if (b != null)
                 {
                     if (b.Expr.Type == FlowBreakingExpr.BreakingType.Continue)
                     {
                         _condition = _code = new PExpr();
                         continue;
                     }
                     if (b.Expr.Type == FlowBreakingExpr.BreakingType.Break)
                     {
                         return(SetResult(RuntimeObj.Undefined));
                     }
                 }
             }
             return(PendingOrSignal(_code));
         }
         if (Expr.DoWhile)
         {
             if (IsPendingOrSignal(ref _condition, Expr.Condition))
             {
                 return(PendingOrSignal(_condition));
             }
             if (!_condition.Result.ToBoolean())
             {
                 break;
             }
         }
         _condition = _code = new PExpr();
     }
     return(SetResult(RuntimeObj.Undefined));
 }
            protected override PExpr DoVisit()
            {
                if (!_arguments.IsArgumentsResolved)
                {
                    PExpr args = _arguments.VisitArguments();
                    if (args.IsPendingOrSignal)
                    {
                        return(PendingOrSignal(args));
                    }

                    // Registering parameters.
                    Debug.Assert(_arguments.IsArgumentsResolved);
                    int iParam = 0;
                    foreach (var parameter in Expr.Parameters)
                    {
                        var r = Visitor.ScopeManager.Register(parameter);
                        if (iParam < _arguments.ResolvedParameters.Count)
                        {
#if DEBUG
                            Debug.Assert(r.SetValue(parameter, _arguments.ResolvedParameters[iParam]).ToValue() == _arguments.ResolvedParameters[iParam].ToValue(),
                                         "There can be no error while setting parameter value.");
#else
                            r.SetValue(parameter, _arguments.ResolvedParameters[iParam]);
#endif
                        }
                        ++iParam;
                    }
                }

                if (IsPendingOrSignal(ref _body, Expr.Body))
                {
                    if (_body.IsSignal)
                    {
                        RuntimeFlowBreaking r = _body.Result as RuntimeFlowBreaking;
                        if (r != null && r.Expr.Type == FlowBreakingExpr.BreakingType.Return)
                        {
                            return(SetResult(r.Value));
                        }
                    }
                    return(PendingOrSignal(_body));
                }
                return(SetResult(RuntimeObj.Undefined));
            }