Exemplo n.º 1
0
        /// <summary>
        /// Retrieves the value of the expression
        /// </summary>
        /// <param name="evalContext">Evaluation context</param>
        /// <param name="checkOnly"></param>
        /// <returns>Evaluated expression value</returns>
        public override ExpressionValue Evaluate(IExpressionEvaluationContext evalContext, bool checkOnly = false)
        {
            // --- Test for operand errors
            var addrValue = StartAddress.Evaluate(evalContext);

            if (addrValue.Type == ExpressionValueType.Error)
            {
                EvaluationError = StartAddress.EvaluationError;
                return(ExpressionValue.Error);
            }
            var endValue = EndAddress == null ? new ExpressionValue(1) : EndAddress.Evaluate(evalContext);

            if (endValue.Type == ExpressionValueType.Error)
            {
                EvaluationError = EndAddress?.EvaluationError;
                return(ExpressionValue.Error);
            }

            if (checkOnly)
            {
                return(ExpressionValue.NonEvaluated);
            }

            if (addrValue.Type == ExpressionValueType.ByteArray || endValue.Type == ExpressionValueType.ByteArray)
            {
                EvaluationError = "Memory address operator cannot be applied on a byte array";
                return(ExpressionValue.Error);
            }

            return(new ExpressionValue(evalContext.GetMachineContext().GetMemorySection(addrValue.AsWord(),
                                                                                        endValue.AsWord())));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Retrieves the value of the expression
        /// </summary>
        /// <param name="evalContext">Evaluation context</param>
        /// <param name="checkOnly"></param>
        /// <returns>Evaluated expression value</returns>
        public override ExpressionValue Evaluate(IExpressionEvaluationContext evalContext, bool checkOnly = false)
        {
            if (checkOnly)
            {
                return(ExpressionValue.NonEvaluated);
            }

            var regValue = evalContext.GetMachineContext().GetRegisterValue(RegisterName);

            return(new ExpressionValue(regValue));
        }
Exemplo n.º 3
0
 /// <summary>
 /// Evaluates a memory touch expression
 /// </summary>
 /// <param name="evalContext">Evaluation context</param>
 /// <param name="start">Start address (inclusive)</param>
 /// <param name="end">End address (inclusive)</param>
 /// <returns>True, if all bytes within the section has been touched</returns>
 public override byte[] EvalTouch(IExpressionEvaluationContext evalContext, ushort start, ushort end)
 => evalContext.GetMachineContext().GetMemoryWriteSection(start, end);
Exemplo n.º 4
0
 /// <summary>
 /// This property signs if an expression is ready to be evaluated,
 /// namely, all subexpression values are known
 /// </summary>
 /// <param name="evalContext">Evaluation context</param>
 /// <returns>True, if the expression is ready; otherwise, false</returns>
 public override bool ReadyToEvaluate(IExpressionEvaluationContext evalContext)
 => evalContext.GetMachineContext() != null;
Exemplo n.º 5
0
 /// <summary>
 /// This property signs if an expression is ready to be evaluated,
 /// namely, all subexpression values are known
 /// </summary>
 /// <param name="evalContext">Evaluation context</param>
 /// <returns>True, if the expression is ready; otherwise, false</returns>
 public override bool ReadyToEvaluate(IExpressionEvaluationContext evalContext) =>
 StartAddress.ReadyToEvaluate(evalContext) &&
 (EndAddress == null || EndAddress.ReadyToEvaluate(evalContext)) &&
 evalContext.GetMachineContext() != null;