示例#1
0
        public FillbPragma(IZ80AsmVisitorContext visitorContext, IParseTree context)
        {
            if (context.ChildCount > 1)
            {
                Count = visitorContext.GetExpression(context.GetChild(1));
            }

            if (context.ChildCount > 3)
            {
                Expression = visitorContext.GetExpression(context.GetChild(3));
            }
        }
示例#2
0
        public DefsPragma(IZ80AsmVisitorContext visitorContext, Z80AsmParser.DefsPragmaContext context)
        {
            if (context.ChildCount > 1)
            {
                Count = visitorContext.GetExpression(context.GetChild(1));
            }

            if (context.ChildCount > 3)
            {
                Value = visitorContext.GetExpression(context.GetChild(3));
            }
        }
示例#3
0
 public ConditionalExpressionNode(IZ80AsmVisitorContext visitorContext,
                                  Z80AsmParser.ExprContext context,
                                  string sourceText,
                                  ExpressionNode condition)
 {
     SourceText = sourceText;
     Condition  = condition;
     if (context.expr().Length > 0)
     {
         TrueExpression = visitorContext.GetExpression(context.expr()[0]);
     }
     if (context.expr().Length > 1)
     {
         FalseExpression = visitorContext.GetExpression(context.expr()[1]);
     }
 }
示例#4
0
 public DefhPragma(IZ80AsmVisitorContext visitorContext, Z80AsmParser.DefhPragmaContext context)
 {
     if (context.expr() != null)
     {
         ByteVector = visitorContext.GetExpression(context.expr());
     }
 }
 protected ExpressionPragmaBase(IZ80AsmVisitorContext visitorContext, IParseTree context)
 {
     if (context.ChildCount > 1)
     {
         Expression = visitorContext.GetExpression(context.GetChild(1));
     }
 }
示例#6
0
 public BankPragma(IZ80AsmVisitorContext visitorContext, IParseTree context)
     : base(visitorContext, context)
 {
     if (context.ChildCount > 3)
     {
         StartOffset = visitorContext.GetExpression(context.GetChild(3));
     }
 }
示例#7
0
 public SkipPragma(IZ80AsmVisitorContext visitorContext, IParseTree context)
     : base(visitorContext, context)
 {
     if (context.ChildCount > 3)
     {
         Fill = visitorContext.GetExpression(context.GetChild(3));
     }
 }
示例#8
0
 public DefwPragma(IZ80AsmVisitorContext visitorContext, IParseTree context)
 {
     Exprs = new List <ExpressionNode>();
     for (var i = 1; i < context.ChildCount; i += 2)
     {
         Exprs.Add(visitorContext.GetExpression(context.GetChild(i)));
     }
 }
示例#9
0
 public DefmnPragma(IZ80AsmVisitorContext visitorContext, IParseTree context,
                    bool nullTerminator, bool bit7Terminator)
 {
     if (context.ChildCount > 1)
     {
         Message = visitorContext.GetExpression(context.GetChild(1));
     }
     NullTerminator = nullTerminator;
     Bit7Terminator = bit7Terminator;
 }
示例#10
0
 public Directive(IZ80AsmVisitorContext visitorContext, IParseTree context) : base(context)
 {
     if (context.ChildCount > 1)
     {
         Identifier = context.GetChild(1).NormalizeToken();
     }
     if (context.GetChild(1) is Z80AsmParser.ExprContext)
     {
         Expr = visitorContext.GetExpression(context.GetChild(1));
     }
 }
示例#11
0
        public IncludeBinPragma(IZ80AsmVisitorContext visitorContext, Z80AsmParser.IncBinPragmaContext context)
        {
            if (context.expr() == null)
            {
                return;
            }

            if (context.expr().Length > 0)
            {
                FileExpr = visitorContext.GetExpression(context.expr()[0]);
            }
            if (context.expr().Length > 1)
            {
                OffsetExpr = visitorContext.GetExpression(context.expr()[1]);
            }
            if (context.expr().Length > 2)
            {
                LengthExpr = visitorContext.GetExpression(context.expr()[2]);
            }
        }
示例#12
0
        public IfStatement(IZ80AsmVisitorContext visitorContext, Z80AsmParser.IfStatementContext context)
        {
            if (context.IFSTMT() != null)
            {
                Expr = visitorContext.GetExpression(context.expr());
                Type = IfStatementType.If;
                return;
            }

            Type   = context.IFUSED() != null ? IfStatementType.IfUsed : IfStatementType.IfNotUsed;
            Symbol = visitorContext.GetSymbol(context.symbolExpr());
        }
示例#13
0
        public ForStatement(IZ80AsmVisitorContext visitorContext, Z80AsmParser.ForStatementContext context)
        {
            if (context.IDENTIFIER() != null)
            {
                visitorContext.AddIdentifier(context.IDENTIFIER());
                ForVariable = context.IDENTIFIER()?.NormalizeToken();
            }
            if (context.TO() != null)
            {
                visitorContext.AddStatement(context.TO());
            }

            if (context.STEP() != null)
            {
                visitorContext.AddStatement(context.STEP());
            }

            From = context.expr().Length > 0 ? visitorContext.GetExpression(context.expr()[0]) : null;
            To   = context.expr().Length > 1 ? visitorContext.GetExpression(context.expr()[1]) : null;
            Step = context.expr().Length > 2 ? visitorContext.GetExpression(context.expr()[2]) : null;
        }
示例#14
0
        public LineDirective(IZ80AsmVisitorContext visitorContext, Z80AsmParser.DirectiveContext context) :
            base(context)
        {
            if (context.expr() != null)
            {
                Expr = visitorContext.GetExpression(context.expr());
            }

            if (context.STRING() != null)
            {
                visitorContext.AddString(context.STRING());
            }
            Filename = context.STRING().NormalizeString();
        }
示例#15
0
 public UntilStatement(IZ80AsmVisitorContext visitorContext, Z80AsmParser.UntilStatementContext context)
 {
     Expression = visitorContext.GetExpression(context.expr());
 }
示例#16
0
 public LoopStatement(IZ80AsmVisitorContext visitorContext, Z80AsmParser.ExprContext context)
 {
     Expression = visitorContext.GetExpression(context);
 }
示例#17
0
        public Operand(IZ80AsmVisitorContext visitorContext, Z80AsmParser.OperandContext context)
        {
            // --- The context has exactly one child
            ParserRuleContext regContext = null;

            if (context.reg8() != null)
            {
                Type       = OperandType.Reg8;
                Register   = context.reg8().NormalizeToken();
                regContext = context.reg8();
            }
            else if (context.reg8Idx() != null)
            {
                Type       = OperandType.Reg8Idx;
                Register   = context.reg8Idx().NormalizeToken();
                regContext = context.reg8Idx();
            }
            else if (context.reg8Spec() != null)
            {
                Type       = OperandType.Reg8Spec;
                Register   = context.reg8Spec().NormalizeToken();
                regContext = context.reg8Spec();
            }
            else if (context.reg16() != null)
            {
                Type       = OperandType.Reg16;
                Register   = context.reg16().NormalizeToken();
                regContext = context.reg16();
            }
            else if (context.reg16Idx() != null)
            {
                Type       = OperandType.Reg16Idx;
                Register   = context.reg16Idx().NormalizeToken();
                regContext = context.reg16Idx();
            }
            else if (context.reg16Spec() != null)
            {
                Type       = OperandType.Reg16Spec;
                Register   = context.reg16Spec().NormalizeToken();
                regContext = context.reg16Spec();
            }
            else if (context.memIndirect() != null)
            {
                var miContext  = context.memIndirect();
                var expContext = miContext.expr();
                Type       = OperandType.MemIndirect;
                Expression = visitorContext.GetExpression(expContext);
                if (miContext.LPAR() != null)
                {
                    visitorContext.AddOperand(miContext.LPAR());
                }
                if (miContext.RPAR() != null)
                {
                    visitorContext.AddOperand(miContext.RPAR());
                }
            }
            else if (context.regIndirect() != null)
            {
                Type       = OperandType.RegIndirect;
                Register   = context.regIndirect().NormalizeToken();
                regContext = context.regIndirect();
            }
            else if (context.cPort() != null)
            {
                Type       = OperandType.CPort;
                regContext = context.cPort();
            }
            else if (context.indexedAddr() != null)
            {
                Type = OperandType.IndexedAddress;
                var idContext = context.indexedAddr();
                regContext = idContext.reg16Idx();
                if (idContext.ChildCount > 3)
                {
                    Expression = visitorContext.GetExpression(idContext.expr());
                }
                Register = idContext.reg16Idx().NormalizeToken();
                Sign     = idContext.ChildCount > 3
                    ? idContext.GetChild(2).NormalizeToken()
                    : null;
                if (idContext.LPAR() != null)
                {
                    visitorContext.AddOperand(idContext.LPAR());
                }
                if (idContext.RPAR() != null)
                {
                    visitorContext.AddOperand(idContext.RPAR());
                }
            }
            else if (context.expr() != null)
            {
                Type       = OperandType.Expr;
                Expression = visitorContext.GetExpression(context.expr());
            }
            else if (context.condition() != null)
            {
                Type       = OperandType.Condition;
                Condition  = context.condition().NormalizeToken();
                regContext = context.condition();
            }
            else if (context.macroParam() != null)
            {
                // --- LREG or HREG with macro parameter
                visitorContext.AddFunction(context);
                visitorContext.AddMacroParam(context.macroParam());
                if (context.macroParam().IDENTIFIER() != null)
                {
                    visitorContext.AddMacroParamName(context.macroParam().IDENTIFIER().GetText());
                }
            }
            else if (context.reg16Std() != null)
            {
                // --- LREG or HREG with 16-bit register
                visitorContext.AddFunction(context);
                Type     = OperandType.Reg8;
                Register = string.Empty;

                if (context.HREG() != null)
                {
                    regContext = context.reg16Std();
                    switch (context.reg16Std().NormalizeToken())
                    {
                    case "BC":
                        Register = "B";
                        break;

                    case "DE":
                        Register = "D";
                        break;

                    case "HL":
                        Register = "H";
                        break;

                    case "IX":
                        Register = "IXH";
                        Type     = OperandType.Reg8Idx;
                        break;

                    case "IY":
                        Register = "IYH";
                        Type     = OperandType.Reg8Idx;
                        break;

                    default:
                        regContext = null;
                        break;
                    }
                }
                else
                {
                    regContext = context.reg16Std();
                    switch (context.reg16Std().NormalizeToken())
                    {
                    case "BC":
                        Register = "C";
                        break;

                    case "DE":
                        Register = "E";
                        break;

                    case "HL":
                        Register = "L";
                        break;

                    case "IX":
                        Register = "IXL";
                        Type     = OperandType.Reg8Idx;
                        break;

                    case "IY":
                        Register = "IYL";
                        Type     = OperandType.Reg8Idx;
                        break;

                    default:
                        regContext = null;
                        break;
                    }
                }
            }
            else if (context.NONEARG() != null)
            {
                // --- This can happen only as the result of a macro substitution
                Type = OperandType.None;
            }

            if (regContext != null)
            {
                visitorContext.AddOperand(regContext);
            }
        }
示例#18
0
 public WhileStatement(IZ80AsmVisitorContext visitorContext, Z80AsmParser.WhileStatementContext context)
 {
     Expr = visitorContext.GetExpression(context.expr());
 }