public IOperator RegisterUnaryCastOperator(OperandType operandType, int precedence, DoubleOperandFunctionMatrix matrix) { var text = operandType.ToString(); var castToOperand = new Operand(operandType); var op = new Operator( OperatorType.UnaryCastOperator, precedence, ShortCircuitMode.None, (operandStack, vSet, parserPosition) => { var result = OperatorActions.DoUnaryCastOperation(matrix, operandStack, vSet, castToOperand); if (result != null) { throw new ExpressionEvaluatorException(parserPosition, ExpressionEvaluatorException.ExceptionCause.BadUnaryOperand, "Cast to (" + text + ") cannot be applied to operand of type " + result.Item1); } }, text ); Operators.Add(text, op); OperatorMatrices.Add(op, matrix); return(op); }
/// <summary> /// Returns a string representation of the operand. /// </summary> /// <returns>String representation of the operand.</returns> public override string ToString() { switch (m_operandType) { case OperandType.Literal: return(ToString(m_objectValue)); case OperandType.Variable: return(m_objectValue.ToString()); case OperandType.LiteralIndexedVariable: return(m_objectValue + "[" + ToString(m_objectIndex) + "]"); case OperandType.VariableIndexedVariable: return(m_objectValue + "[" + m_objectIndex + "]"); case OperandType.InstructionRef: return("[" + ((ScriptInstruction)m_objectValue).Address.ToString("00000000") + "]"); case OperandType.ScriptFunctionRef: { ScriptFunction scriptFunction = (ScriptFunction)m_objectValue; return("[" + scriptFunction.EntryPoint.Address.ToString("00000000") + "] : " + scriptFunction.Name + "(...)"); } case OperandType.HostFunctionRef: return(m_objectValue.ToString()); default: return(m_operandType.ToString()); } }
public override string ToString() { return(string.Format("[SelectionCriteria] - Type: {0}, OperandType: {1}, Property: {2}, Comparison: {3}, Value: {4}", (Type != null) ? Type.ToString() : "null", OperandType.ToString(), (Property != null) ? Property.Name : "null", ComparisonMethod.ToString(), (Value != null) ? Value.ToString() : "null")); }
public static object ReadArg(IBinaryReader binaryReader, Context.IOperandReaderContext context, OperandType operandType) { IOperandReader reader; if (argumentReadersCache.TryGetValue(operandType, out reader)) { return(reader.Read(binaryReader, context)); } throw new System.NotSupportedException(operandType.ToString()); }
private static string GetRegisterName(OperandType operandType) { switch (operandType) { case OperandType.Temp: case OperandType.Input: case OperandType.Output: case OperandType.IndexableTemp: case OperandType.ConstantBuffer: return(operandType.ToString() + "s"); default: throw new ArgumentOutOfRangeException("operandType"); } }
public override string ToString() { switch (m_operandType) { case OperandType.Literal: { // \todo improve if (m_objectValue.GetType().ToString() == "System.String") { return(ToLiteral((string)m_objectValue)); } else if (m_objectValue.GetType().ToString() == "System.Char") { return(ToLiteral("" + (char)m_objectValue)); } else { return(ToString(m_objectValue)); } } case OperandType.Variable: return(m_objectValue.ToString()); case OperandType.Member: return(m_objectValue + "[" + ToString(m_objectIndex) + "]"); case OperandType.Pointer: return(m_objectValue + "[" + m_objectIndex + "]"); case OperandType.InstructionPointer: return("[" + ((Instruction)m_objectValue).Address.ToString("X8") + "]"); case OperandType.FunctionPointer: { Function scriptFunction = (Function)m_objectValue; return("<" + scriptFunction.Name + "@" + scriptFunction.EntryPoint.Address.ToString("X8") + ">"); } case OperandType.RoutinePointer: return(m_objectValue.ToString()); default: return(ToLiteral(m_operandType.ToString())); } }
public decimal ParseOperand(string Operand, OperandType ExpectedType) { switch (ExpectedType) { case OperandType.Register: return(ParseRegister(Operand)); case OperandType.Number16bit: return(ParseNumber16Bit(Operand)); case OperandType.Number26bit: return(ParseNumber26Bit(Operand)); case OperandType.Offset: return(ParseOffset(Operand)); } throw new ArgumentException($"Expected type {ExpectedType.ToString()} got \"{Operand}\" instead."); }
public MultiplicationException(OperandType lhs, OperandType rhs) : base("<" + lhs.ToString() + ">" + " * " + "<" + rhs.ToString() + ">" + "is not a valid multiplication.") { }
private static string GetRegisterName(OperandType operandType) { switch (operandType) { case OperandType.Temp: case OperandType.Input: case OperandType.Output: case OperandType.IndexableTemp: case OperandType.ConstantBuffer: return operandType.ToString() + "s"; default: throw new ArgumentOutOfRangeException("operandType"); } }
public AdditionException(OperandType lhs, OperandType rhs) : base("<" + lhs.ToString() + ">" + " + " + "<" + rhs.ToString() + ">" + "is not a valid additon.") { }
public SubtractionException(OperandType lhs, OperandType rhs) : base("<" +lhs.ToString() + ">" + " - " + "<" + rhs.ToString() + ">" + "is not a valid subtraction.") { }
public EqualException(OperandType lhs, OperandType rhs) : base("<" + lhs.ToString() + ">" + " == " + "<" + rhs.ToString() + ">" + "is not a valid equality.") { }
private static char ToChar(OperandType t) => t == OperandType.AddressOfAddress ? 'p' : t.ToString().ToLower()[0];
public DivisionException(OperandType lhs, OperandType rhs) : base("<" + lhs.ToString() + ">" + " / " + "<" + rhs.ToString() + ">" + "is not a valid division.") { }