///////////////////////////////////////////////////////////////////////////////// private static bool IsIncrementOrDecrementActionOnLocal(DynamicMetaObjectBinder action) { CSharpUnaryOperationBinder operatorPayload = action as CSharpUnaryOperationBinder; return(operatorPayload != null && (operatorPayload.Operation == ExpressionType.Increment || operatorPayload.Operation == ExpressionType.Decrement)); }
///////////////////////////////////////////////////////////////////////////////// private EXPR BindUnaryOperation( CSharpUnaryOperationBinder payload, ArgumentObject[] arguments, Dictionary<int, LocalVariableSymbol> dictionary) { if (arguments.Length != 1) { throw Error.BindUnaryOperatorRequireOneArgument(); } OperatorKind op = GetOperatorKind(payload.Operation); EXPR arg1 = CreateArgumentEXPR(arguments[0], dictionary[0]); arg1.errorString = Operators.GetDisplayName(GetOperatorKind(payload.Operation)); if (op == OperatorKind.OP_TRUE || op == OperatorKind.OP_FALSE) { // For true and false, we try to convert to bool first. If that // doesn't work, then we look for user defined operators. EXPR result = _binder.tryConvert(arg1, SymbolLoader.GetReqPredefType(PredefinedType.PT_BOOL)); if (result != null && op == OperatorKind.OP_FALSE) { // If we can convert to bool, we need to negate the thing if we're looking for false. result = _binder.BindStandardUnaryOperator(OperatorKind.OP_LOGNOT, result); } if (result == null) { result = _binder.bindUDUnop(op == OperatorKind.OP_TRUE ? ExpressionKind.EK_TRUE : ExpressionKind.EK_FALSE, arg1); } // If the result is STILL null, then that means theres no implicit conversion to bool, // and no user-defined operators for true and false. Just do a must convert to report // the error. if (result == null) { result = _binder.mustConvert(arg1, SymbolLoader.GetReqPredefType(PredefinedType.PT_BOOL)); } return result; } return _binder.BindStandardUnaryOperator(op, arg1); }