/// <summary> /// Attributes named [[reko::reg(<tokens>)]] expect a single register /// in <tokens>. Remaining tokens are ignored /// </summary> /// <param name="attrs"></param> /// <returns></returns> public SerializedKind GetArgumentKindFromAttributes(string paramType, List <CAttribute> attrs) { if (attrs == null) { return(null); } SerializedKind kind = null; foreach (var attr in attrs) { if (attr.Name.Components == null || attr.Name.Components.Length != 2 || attr.Name.Components[0] != "reko" || attr.Name.Components[1] != paramType) { continue; } if (attr.Tokens[0].Type != CTokenType.Register || attr.Tokens[1].Type != CTokenType.Comma) { continue; } // We have a reko::arg(register, prefix; get the register. if (attr.Tokens.Count < 1 || attr.Tokens[2].Type != CTokenType.StringLiteral) { throw new FormatException("[[reko::arg(register,<name>)]] attribute expects a register name."); } kind = new Register_v1 { Name = (string)attr.Tokens[2].Value }; } return(kind); }
/// <summary> /// Attributes named [[reko::reg(<tokens>)]] expect a single register /// in <tokens>. Remaining tokens are ignored /// </summary> /// <param name="attrs"></param> /// <returns></returns> public SerializedKind GetArgumentKindFromAttributes(string paramType, List<CAttribute> attrs) { if (attrs == null) return null; SerializedKind kind = null; foreach (var attr in attrs) { if (attr.Name.Components == null || attr.Name.Components.Length != 2 || attr.Name.Components[0] != "reko" || attr.Name.Components[1] != paramType) continue; if (attr.Tokens[0].Type == CTokenType.Register && attr.Tokens[1].Type == CTokenType.Comma) { // We have a reko::arg(register, prefix; get the register. if (attr.Tokens.Count < 1 || attr.Tokens[2].Type != CTokenType.StringLiteral) throw new FormatException("[[reko::arg(register,<name>)]] attribute expects a register name."); kind = new Register_v1 { Name = (string)attr.Tokens[2].Value }; } else if (attr.Tokens[0].Type == CTokenType.Id && (string)attr.Tokens[0].Value == "fpu") { // We have a reko::fpu prefix; mark as FPU kind = new FpuStackVariable_v1(); } } return kind; }