示例#1
0
        public CompoundOperation(IZ80AsmVisitorContext visitorContext, Z80AsmParser.CompoundOperationContext context) : base(context)
        {
            var operands = context.operand();

            if (operands == null)
            {
                return;
            }
            for (var i = 0; i < operands.Length; i++)
            {
                // --- Collect operands
                var operandCtx = operands[i];
                switch (i)
                {
                case 0:
                    Operand = visitorContext.GetOperand(operandCtx);
                    break;

                case 1:
                    Operand2 = visitorContext.GetOperand(operandCtx);
                    break;

                default:
                    Operand3 = visitorContext.GetOperand(operandCtx);
                    break;
                }
            }
        }
示例#2
0
        /// <summary>
        /// Visit a parse tree produced by <see cref="Generated.Z80AsmParser.compoundOperation"/>.
        /// </summary>
        /// <param name="context">The parse tree.</param>
        /// <return>The visitor result.</return>
        public override object VisitCompoundOperation(Z80AsmParser.CompoundOperationContext context)
        {
            if (IsInvalidContext(context))
            {
                return(null);
            }

            var op = new CompoundOperation
            {
                Mnemonic = context.GetChild(0).NormalizeToken()
            };

            var operandFound = false;

            foreach (var child in context.children)
            {
                // --- Collect operands
                if (child is Z80AsmParser.OperandContext operandChild)
                {
                    if (!operandFound)
                    {
                        op.Operand = (Operand)VisitOperand(operandChild);
                    }
                    else
                    {
                        op.Operand2 = (Operand)VisitOperand(operandChild);
                    }
                    operandFound = true;
                    continue;
                }

                // --- Collect optional condition
                if (child is Z80AsmParser.ConditionContext condChild)
                {
                    op.Condition = condChild.GetText().NormalizeToken();
                    continue;
                }

                // --- Collect optional bit index
                if (child is Z80AsmParser.ExprContext exprChild)
                {
                    op.BitIndex = (ExpressionNode)VisitExpr(exprChild);
                }
            }
            return(AddLine(op, context));
        }
示例#3
0
 public override object VisitCompoundOperation(Z80AsmParser.CompoundOperationContext context)
 => new CompoundOperation(this, context);
 /// <summary>
 /// Visit a parse tree produced by <see cref="Z80AsmParser.compoundOperation"/>.
 /// <para>
 /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
 /// on <paramref name="context"/>.
 /// </para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 /// <return>The visitor result.</return>
 public virtual Result VisitCompoundOperation([NotNull] Z80AsmParser.CompoundOperationContext context)
 {
     return(VisitChildren(context));
 }
示例#5
0
 /// <summary>
 /// Exit a parse tree produced by <see cref="Z80AsmParser.compoundOperation"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitCompoundOperation([NotNull] Z80AsmParser.CompoundOperationContext context)
 {
 }