Exemple #1
0
 /// <summary>
 /// Provides a way for the binder to provide a custom error message when lookup fails.  Just
 /// doing this for the time being until we get a more robust error return mechanism.
 /// </summary>
 public virtual Expression MakeReadOnlyMemberError(RuleBuilder rule, Type type, string name)
 {
     return(rule.MakeError(
                Expression.New(
                    typeof(MissingMemberException).GetConstructor(new Type[] { typeof(string) }),
                    Expression.Constant(name)
                    )
                ));
 }
 private void SetErrorTarget(OperatorInfo info)
 {
     _rule.Target =
         _rule.MakeError(
             AstUtils.ComplexCallHelper(
                 typeof(BinderOps).GetMethod("BadArgumentsForOperation"),
                 ArrayUtils.Insert((Expression)Ast.Constant(info.Operator), _rule.Parameters)
                 )
             );
 }
Exemple #3
0
 protected virtual void MakeCannotCallRule(Type type)
 {
     _rule.Target =
         _rule.MakeError(
             Ast.New(
                 typeof(ArgumentTypeException).GetConstructor(new Type[] { typeof(string) }),
                 Ast.Constant(type.Name + " is not callable")
                 )
             );
 }
Exemple #4
0
        /// <summary>
        /// Internal helper to produce the actual expression used for the error when emitting
        /// the error into a rule.
        /// </summary>
        public Expression MakeErrorForRule(RuleBuilder rule, ActionBinder binder)
        {
            switch (_kind)
            {
            case ErrorInfoKind.Error:
                rule.IsError = true;
                return(rule.MakeReturn(binder, _value));

            case ErrorInfoKind.Success:
                return(rule.MakeReturn(binder, _value));

            case ErrorInfoKind.Exception:
                return(rule.MakeError(_value));

            default: throw new InvalidOperationException();
            }
        }
Exemple #5
0
 /// <summary>
 /// Provides a way for the binder to provide a custom error message when lookup fails.  Just
 /// doing this for the time being until we get a more robust error return mechanism.
 /// </summary>
 public virtual Expression MakeReadOnlyMemberError(RuleBuilder rule, Type type, string name) {
     return rule.MakeError(
         Expression.New(
             typeof(MissingMemberException).GetConstructor(new Type[] { typeof(string) }),
             AstUtils.Constant(name)
         )
     );
 }
Exemple #6
0
 /// <summary>
 /// Internal helper to produce the actual expression used for the error when emitting
 /// the error into a rule.
 /// </summary>
 public Expression MakeErrorForRule(RuleBuilder rule, ActionBinder binder) {
     switch (_kind) {
         case ErrorInfoKind.Error:
             rule.IsError = true;
             return rule.MakeReturn(binder, _value);
         case ErrorInfoKind.Success:
             return rule.MakeReturn(binder, _value);
         case ErrorInfoKind.Exception:
             return rule.MakeError(_value);
         default: throw new InvalidOperationException();
     }
 }