コード例 #1
0
        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);
        }
コード例 #2
0
        /// <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());
            }
        }
コード例 #3
0
ファイル: SelectionCriterion.cs プロジェクト: Oshchenkov/moss
 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"));
 }
コード例 #4
0
ファイル: OperandReader.cs プロジェクト: dadhi/ILReader
        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());
        }
コード例 #5
0
        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");
            }
        }
コード例 #6
0
        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()));
            }
        }
コード例 #7
0
        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.");
        }
コード例 #8
0
 public MultiplicationException(OperandType lhs, OperandType rhs)
     : base("<" + lhs.ToString() + ">" + " * " + "<" + rhs.ToString() + ">" + "is not a valid multiplication.")
 {
 }
コード例 #9
0
 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");
     }
 }
コード例 #10
0
 public AdditionException(OperandType lhs, OperandType rhs)
     : base("<" + lhs.ToString() + ">" + " + " + "<" + rhs.ToString() + ">" + "is not a valid additon.")
 {
 }
コード例 #11
0
        public SubtractionException(OperandType lhs, OperandType rhs)
            : base("<" +lhs.ToString() + ">" + " - " + "<" + rhs.ToString() + ">" + "is not a valid subtraction.")
        {

        }
コード例 #12
0
 public EqualException(OperandType lhs, OperandType rhs)
     : base("<" + lhs.ToString() + ">" + " == " + "<" + rhs.ToString() + ">" + "is not a valid equality.")
 {
 }
コード例 #13
0
 private static char ToChar(OperandType t) => t == OperandType.AddressOfAddress ? 'p' : t.ToString().ToLower()[0];
コード例 #14
0
 public DivisionException(OperandType lhs, OperandType rhs)
     : base("<" + lhs.ToString() + ">" + " / " + "<" + rhs.ToString() + ">" + "is not a valid division.")
 {
 }