/// <summary> /// Checks if the operand is used as a macro parameter node /// </summary> /// <param name="context"></param> private void CheckForMacroParamNode(Z80AsmParser.BuiltinFunctionInvocationContext context) { if (context.operand() == null) { return; } var op = (Operand)VisitOperand(context.operand()); if (!MacroParsingPhase && (op.Type != OperandType.Expr || !(op.Expression is MacroParamNode))) { // --- Built in function can use only macro parameters during the collection phase IssueToEmit = Errors.Z0421; } }
/// <summary> /// Visit a parse tree produced by <see cref="Z80AsmParser.builtinFunctionInvocation"/>. /// <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 override object VisitBuiltinFunctionInvocation(Z80AsmParser.BuiltinFunctionInvocationContext context) { AddFunction(context); string token = null; if (context.TEXTOF() != null || context.LTEXTOF() != null) { if (context.macroParam() != null) { AddFunction(context); AddMacroParam(context.macroParam()); if (context.macroParam().IDENTIFIER() != null) { AddMacroParamName(context.macroParam().IDENTIFIER().NormalizeToken()); } } if (context.mnemonic() != null) { AddMnemonics(context.mnemonic()); token = context.mnemonic().NormalizeToken(); } else if (context.regsAndConds() != null) { AddOperand(context.regsAndConds()); token = context.regsAndConds().NormalizeToken(); } if (context.LTEXTOF() != null) { token = token?.ToLower(); } return(new LiteralNode(token)); } if (context.DEF() != null) { CheckForMacroParamNode(context); return(new LiteralNode(context.operand() != null && context.operand().NONEARG() == null)); } if (context.ISREG8() != null) { CheckForMacroParamNode(context); return(new LiteralNode( (context.operand()?.reg8() != null || context.operand()?.reg8Spec() != null || context.operand()?.reg8Idx() != null) && context.operand().NONEARG() == null)); } if (context.ISREG8STD() != null) { CheckForMacroParamNode(context); return(new LiteralNode(context.operand()?.reg8() != null && context.operand().NONEARG() == null)); } if (context.ISREG8SPEC() != null) { CheckForMacroParamNode(context); return(new LiteralNode(context.operand()?.reg8Spec() != null && context.operand().NONEARG() == null)); } if (context.ISREG8IDX() != null) { CheckForMacroParamNode(context); return(new LiteralNode(context.operand()?.reg8Idx() != null && context.operand().NONEARG() == null)); } if (context.ISREG16() != null) { CheckForMacroParamNode(context); return(new LiteralNode( (context.operand()?.reg16() != null || context.operand()?.reg16Idx() != null || context.operand()?.reg16Spec() != null) && context.operand().NONEARG() == null)); } if (context.ISREG16IDX() != null) { CheckForMacroParamNode(context); return(new LiteralNode(context.operand()?.reg16Idx() != null && context.operand().NONEARG() == null)); } if (context.ISREG16STD() != null) { CheckForMacroParamNode(context); return(new LiteralNode(context.operand()?.reg16() != null && context.operand().NONEARG() == null)); } if (context.ISREGINDIRECT() != null) { CheckForMacroParamNode(context); return(new LiteralNode(context.operand()?.regIndirect() != null && context.operand().NONEARG() == null)); } if (context.ISCPORT() != null) { CheckForMacroParamNode(context); return(new LiteralNode(context.operand()?.cPort() != null && context.operand().NONEARG() == null)); } if (context.ISINDEXEDADDR() != null) { CheckForMacroParamNode(context); return(new LiteralNode(context.operand()?.indexedAddr() != null && context.operand().NONEARG() == null)); } if (context.ISCONDITION() != null) { CheckForMacroParamNode(context); return(new LiteralNode( (context.operand()?.condition() != null || context.operand().reg8()?.GetText()?.ToLower() == "c") && context.operand().NONEARG() == null)); } if (context.ISEXPR() != null) { CheckForMacroParamNode(context); return(new LiteralNode(context.operand()?.expr() != null && context.operand().NONEARG() == null)); } return(null); }