private IOperand GetErrorOperand(IOperand op) { IOperand errorOp = op.Convert(OperandType.Error); if (errorOp != null) { return(errorOp); } return(new ErrorValueOperand(ErrorValueType.Value)); }
private IOperand ComputeValueInternal(IOperand op) { OperandType knownType = GetKnownArgumentType(); IOperand convertedOp = op.Convert(knownType); if (convertedOp == null) { return(GetConvertError(op)); } return(ComputeValue(convertedOp)); }
internal override ArgumentMarshalResult MarshalArgument(int position, IOperand op) { // Get the operand type we expect OperandType opType = _argumentTypes[position]; // Try to convert IOperand result = op.Convert(opType); bool success = result != null; if (result == null) { // Conversion failed; get the error result = GetErrorOperand(op); } // Return the result of marshaling return(new ArgumentMarshalResult(success, result)); }
protected IOperand GetErrorOperand(IOperand lhs, IOperand rhs) { IOperand errorOp = lhs.Convert(OperandType.Error); if (errorOp != null) { return(errorOp); } errorOp = rhs.Convert(OperandType.Error); if (errorOp != null) { return(errorOp); } return(null); }
private CompareResult Compare(IOperand lhs, IOperand rhs) { OperandType[] convertTypes = { OperandType.Integer, OperandType.Double, OperandType.String, OperandType.Boolean, OperandType.DateTime }; int commonTypeIndex = IndexOfCommonType((PrimitiveOperand)lhs, (PrimitiveOperand)rhs, convertTypes); if (commonTypeIndex == -1) { return(CompareDifferentTypes((PrimitiveOperand)lhs, (PrimitiveOperand)rhs)); } OperandType commonType = convertTypes[commonTypeIndex]; var lhsPrim = (PrimitiveOperand)lhs.Convert(commonType); var rhsPrim = (PrimitiveOperand)rhs.Convert(commonType); int result = lhsPrim.Compare(rhsPrim); return(Compare2CompareResult(result)); }
/// <summary> /// Get the operand based on our result type /// </summary> private IOperand GetResultOperand(IOperand op) { op = op.Convert(ResultType) ?? new ErrorValueOperand(ErrorValueType.Value); return(op); }
private bool IsInvalidReference(IOperand op) { var @ref = (Reference)op.Convert(OperandType.Reference); return(@ref != null && @ref.Valid == false); }
/// <summary> /// Determines if this argument can be converted to a particular type /// </summary> /// <param name="opType">The operand type you wish to test</param> /// <returns>True if the argument can be converted to opType; False otherwise</returns> /// <remarks>This method is a more generic version of the IsXXX properties</remarks> public bool IsType(OperandType opType) { return(MyOperand.Convert(opType) != null); }