Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various preparations #3617

Merged
merged 18 commits into from
Jan 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
247a05b
misc/review: add a command to show differences in Tmain
masatake Jan 2, 2023
c972f79
main: allow parsers to use getLanguageKindForName and getLanguageRole…
masatake Jan 2, 2023
95c744e
main: hide getLanguageKindForLetter() from parsers
masatake Jan 2, 2023
cc6d77c
Asm: add missing "break;" in a default block in a switch statement
masatake Jan 2, 2023
52e649c
Units: delete an empty line at the EOF
masatake Jan 2, 2023
f2cbdbb
Asm,refactor: rename a local variable and a parameter related to scope
masatake Jan 2, 2023
184bc0b
main: add a new funciton, markCorkEntryPlaceholder()
masatake Nov 20, 2022
4d2f4a4
main,refactor: rename functions for marking a tag as a placeholder
masatake Nov 21, 2022
0b1b915
main,refactor: use markTagAsPlaceholder in markAsPlaceholderRecursively
masatake Nov 21, 2022
60a048d
main: add a new macro clearRole
masatake Dec 2, 2022
77ffe43
Cxx: add cxxTagRoleEnabled()
masatake Dec 3, 2022
99bc13c
Cxx,refactor: convert a bool field to a bit field
masatake Nov 30, 2022
0775dc5
build-sys,refactor: sort PARSER_SRCS
masatake Jan 3, 2023
1334099
main: add a API function for unassigning a role from a tagEntry
masatake Mar 1, 2022
4940d49
operator: add operators for assigning/unasigning a role to/from a tag
masatake Mar 1, 2022
b8f4d43
main: show the information about input when failed in evaluation
masatake Dec 27, 2022
b823933
Pod,comment: add description about depthForCork procedure
masatake Dec 27, 2022
8be2171
optlib2c: fix wrongly generated code for --_paramdef
masatake Dec 29, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Units/parser-asm.r/gas-section.d/args.ctags
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
--sort=no
--extras=+r
--fields=+r

22 changes: 17 additions & 5 deletions main/entry.c
Original file line number Diff line number Diff line change
Expand Up @@ -1738,17 +1738,24 @@ extern size_t countEntryInCorkQueue (void)
return ptrArrayCount (TagFile.corkQueue);
}

extern void markTagPlaceholder (tagEntryInfo *e, bool placeholder)
extern void markTagAsPlaceholder (tagEntryInfo *e, bool placeholder)
{
e->placeholder = placeholder;
}

extern void markCorkEntryAsPlaceholder (int index, bool placeholder)
{
tagEntryInfo *e = getEntryInCorkQueue(index);
if (e)
markTagAsPlaceholder(e, placeholder);
}

extern int makePlaceholder (const char *const name)
{
tagEntryInfo e;

initTagEntry (&e, name, KIND_GHOST_INDEX);
markTagPlaceholder(&e, true);
markTagAsPlaceholder(&e, true);

/*
* makePlaceholder may be called even before reading any bytes
Expand Down Expand Up @@ -2078,6 +2085,11 @@ extern void assignRole(tagEntryInfo *const e, int roleIndex)
assignRoleFull(e, roleIndex, true);
}

extern void unassignRole(tagEntryInfo *const e, int roleIndex)
{
assignRoleFull(e, roleIndex, false);
}

extern bool isRoleAssigned(const tagEntryInfo *const e, int roleIndex)
{
if (roleIndex == ROLE_DEFINITION_INDEX)
Expand Down Expand Up @@ -2151,14 +2163,14 @@ extern const char* getTagFileDirectory (void)
return TagFile.directory;
}

static bool markAsPlaceholder (int index, tagEntryInfo *e, void *data CTAGS_ATTR_UNUSED)
static bool markAsPlaceholderRecursively (int index, tagEntryInfo *e, void *data CTAGS_ATTR_UNUSED)
{
e->placeholder = 1;
markTagAsPlaceholder (e, true);
markAllEntriesInScopeAsPlaceholder (index);
return true;
}

extern void markAllEntriesInScopeAsPlaceholder (int index)
{
foreachEntriesInScope (index, NULL, markAsPlaceholder, NULL);
foreachEntriesInScope (index, NULL, markAsPlaceholderRecursively, NULL);
}
5 changes: 4 additions & 1 deletion main/entry.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ extern void initForeignRefTagEntry (tagEntryInfo *const e, const char *const nam
langType type,
int kindIndex, int roleIndex);
extern void assignRole(tagEntryInfo *const e, int roleIndex);
#define clearRoles(E) assignRole((E), ROLE_DEFINITION_INDEX)
extern void unassignRole(tagEntryInfo *const e, int roleIndex);
extern bool isRoleAssigned(const tagEntryInfo *const e, int roleIndex);

extern int makeQualifiedTagEntry (const tagEntryInfo *const e);
Expand Down Expand Up @@ -286,7 +288,8 @@ extern void attachParserFieldToCorkEntry (int index, fieldType ftype, const char
extern const char* getParserFieldValueForType (tagEntryInfo *const tag, fieldType ftype);

extern int makePlaceholder (const char *const name);
extern void markTagPlaceholder (tagEntryInfo *e, bool placeholder);
extern void markTagAsPlaceholder (tagEntryInfo *e, bool placeholder);
extern void markCorkEntryAsPlaceholder (int index, bool placeholder);

/* Marking all tag entries entries under the scope specified
* with index recursively.
Expand Down
73 changes: 69 additions & 4 deletions main/lregex.c
Original file line number Diff line number Diff line change
Expand Up @@ -1733,7 +1733,9 @@ static void matchTagPattern (struct lregexControlBlock *lcb,
scriptSetup (optvm, lcb, n, window);
EsObject *e = scriptEval (optvm, patbuf->optscript);
if (es_error_p (e))
error (WARNING, "error when evaluating: %s", patbuf->optscript_src);
error (WARNING, "error when evaluating: %s %% input: %s, line:%lu", patbuf->optscript_src,
getInputFileName (),
getInputLineNumberInRegPType(patbuf->regptype, offset));
es_object_unref (e);
scriptTeardown (optvm, lcb);
}
Expand Down Expand Up @@ -1886,7 +1888,8 @@ static bool matchRegexPattern (struct lregexControlBlock *lcb,
scriptSetup (optvm, lcb, CORK_NIL, &window);
EsObject *e = scriptEval (optvm, patbuf->optscript);
if (es_error_p (e))
error (WARNING, "error when evaluating: %s", patbuf->optscript_src);
error (WARNING, "error when evaluating: %s %% input: %s", patbuf->optscript_src,
getInputFileName ());
es_object_unref (e);
scriptTeardown (optvm, lcb);
}
Expand Down Expand Up @@ -1978,7 +1981,8 @@ static bool matchMultilineRegexPattern (struct lregexControlBlock *lcb,
scriptSetup (optvm, lcb, CORK_NIL, &window);
EsObject *e = scriptEval (optvm, patbuf->optscript);
if (es_error_p (e))
error (WARNING, "error when evaluating: %s", patbuf->optscript_src);
error (WARNING, "error when evaluating: %s %% input: %s", patbuf->optscript_src,
getInputFileName ());
es_object_unref (e);
scriptTeardown (optvm, lcb);
}
Expand Down Expand Up @@ -3333,6 +3337,55 @@ static EsObject* lrop_make_reftag (OptVM *vm, EsObject *name)
return es_false;
}

static EsObject* lrop_assign_role_common (OptVM *vm, EsObject *name, bool assign)
{
EsObject *tag = opt_vm_ostack_peek (vm, 1);
tagEntryInfo *e;
if (es_integer_p (tag))
{
int n = es_integer_get (tag);
if (! (CORK_NIL < n && n < countEntryInCorkQueue()))
return OPT_ERR_RANGECHECK;
e = getEntryInCorkQueue (n);
}
else if (es_object_get_type (tag) == OPT_TYPE_TAG)
e = es_pointer_get (tag);
else
return OPT_ERR_TYPECHECK;

if (e == NULL)
return OPTSCRIPT_ERR_NOTAGENTRY;

langType lang = e->langType;
int kind_index = e->kindIndex;
EsObject *role = opt_vm_ostack_top (vm);
if (es_object_get_type (role) != OPT_TYPE_NAME)
return OPT_ERR_TYPECHECK;
EsObject *role_sym = es_pointer_get (role);
const char *role_str = es_symbol_get (role_sym);
roleDefinition* role_def = getLanguageRoleForName (lang, kind_index, role_str);
if (!role_def)
return OPTSCRIPT_ERR_UNKNOWNROLE;
int role_index = role_def->id;

(assign? assignRole: unassignRole) (e, role_index);

opt_vm_ostack_pop (vm);
opt_vm_ostack_pop (vm);

return es_false;
}

static EsObject* lrop_assign_role (OptVM *vm, EsObject *name)
{
return lrop_assign_role_common (vm, name, true);
}

static EsObject* lrop_unassign_role (OptVM *vm, EsObject *name)
{
return lrop_assign_role_common (vm, name, false);
}

/* tag COMMIT int */
static EsObject* lrop_commit_tag (OptVM *vm, EsObject *name)
{
Expand Down Expand Up @@ -3947,7 +4000,7 @@ static EsObject *lrop_markplaceholder (OptVM *vm, EsObject *name)
if (e == NULL)
return OPTSCRIPT_ERR_NOTAGENTRY;

markTagPlaceholder (e, true);
markTagAsPlaceholder (e, true);

opt_vm_ostack_pop (vm);
return es_false;
Expand Down Expand Up @@ -4211,6 +4264,18 @@ static struct optscriptOperatorRegistration lropOperators [] = {
.help_str = "param:name _PARAM value:string true%"
"param:name _PARAM false",
},
{
.name = "_assignrole",
.fn = lrop_assign_role,
.arity = 2,
.help_str = "tag:int|tag:tag role:name _ASSIGNROLE -",
},
{
.name = "_unassignrole",
.fn = lrop_unassign_role,
.arity = 2,
.help_str = "tag:int|tag:tag role:name _UNASSIGNROLE -",
},
};

extern void initRegexOptscript (void)
Expand Down
4 changes: 3 additions & 1 deletion main/parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@ extern bool isLanguageEnabled (const langType language);
extern bool isLanguageKindEnabled (const langType language, int kindIndex);
extern bool isLanguageRoleEnabled (const langType language, int kindIndex, int roleIndex);

extern kindDefinition* getLanguageKindForLetter (const langType language, char kindLetter);
extern kindDefinition* getLanguageKindForName (const langType language, const char *kindName);
extern roleDefinition* getLanguageRoleForName (const langType language, int kindIndex,
const char *roleName);

extern void initializeParser (langType language);
extern unsigned int getLanguageCorkUsage (langType language);
Expand Down
4 changes: 1 addition & 3 deletions main/parse_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,8 @@ extern bool doesLanguageRequestAutomaticFQTag (const langType language);
extern langType getNamedLanguageFull (const char *const name, size_t len, bool noPretending, bool include_aliases);

extern kindDefinition* getLanguageKind(const langType language, int kindIndex);
extern kindDefinition* getLanguageKindForName (const langType language, const char *kindName);
extern kindDefinition* getLanguageKindForLetter (const langType language, char kindLetter);
extern roleDefinition* getLanguageRole(const langType language, int kindIndex, int roleIndex);
extern roleDefinition* getLanguageRoleForName (const langType language, int kindIndex,
const char *roleName);
extern unsigned int getLanguageVersionCurrent (const langType language);
extern unsigned int getLanguageVersionAge (const langType language);

Expand Down
7 changes: 6 additions & 1 deletion misc/optlib2c
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,11 @@ EOF
if (defined $opts->{'selector'}) {
print <<EOF;
#include "selectors.h"
EOF
}
if ((scalar @{$opts->{'paramdefs'}}) > 0) {
print <<EOF;
#include "param.h"
EOF
}
print <<EOF;
Expand Down Expand Up @@ -968,7 +973,7 @@ EOF
print <<EOF;
{
.name = "$_->{'name'}",
.description = "$desc",
.desc = "$desc",
.handleParam = NULL,
},
EOF
Expand Down
28 changes: 27 additions & 1 deletion misc/review
Original file line number Diff line number Diff line change
Expand Up @@ -276,17 +276,43 @@ function tmain_inspect_run
make tmain UNITS=$(basename $t .d)
}


tmain_inspect_cmd_show_diff_generic()
{
local prefix=$1
local t=$2
local c=$3
cat $prefix/$t/$c-diff.txt | diff_post_processor
}

tmain_inspect_cmd_show_diff_all()
{
local prefix=$1
local t=$2
local c

for c in stdout stderr exit; do
if [[ -e "$prefix/$t/$c-diff.txt" ]]; then
echo '### ' "$c"
tmain_inspect_cmd_show_diff_generic "$prefix" "$t" "$c"
fi
done
}

do_tmain_inspect()
{
local next=0
local r
local t=$1

select r in '<n>ext' '<S>hell' '<R>un' '<q>uit'; do
select r in '<n>ext' '<d>iff' '<S>hell' '<R>un' '<q>uit'; do
case $r-$REPLY in
("<n>ext"-*|-n)
next=1
;;
("<d>iff"-*|-d)
tmain_inspect_cmd_show_diff_all Tmain "$t"
;;
("<S>hell"-*|-S)
inspect_cmd_shell Tmain "$t"
;;
Expand Down
1 change: 1 addition & 0 deletions optlib/pod.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ static void initializePodParser (const langType language CTAGS_ATTR_UNUSED)
" 0 get ?1 sub\n"
" } def\n"
"\n"
" % cork:int DEPTHFORCORK depth:int\n"
" /depthForCork {\n"
" :kind kindTable exch _aindex pop\n"
" } def\n"
Expand Down
1 change: 1 addition & 0 deletions optlib/pod.ctags
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
0 get ?1 sub
} def

% cork:int DEPTHFORCORK depth:int
/depthForCork {
:kind kindTable exch _aindex pop
} def
Expand Down
15 changes: 8 additions & 7 deletions parsers/asm.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ static int makeAsmTag (
const bool labelCandidate,
const bool nameFollows,
const bool directive,
int *scope)
int *macroScope)
{
int r = CORK_NIL;

Expand Down Expand Up @@ -258,17 +258,17 @@ static int makeAsmTag (
macro_tag = getEntryInCorkQueue (r);
if (macro_tag)
{
macro_tag->extensionFields.scopeIndex = *scope;
macro_tag->extensionFields.scopeIndex = *macroScope;
registerEntry (r);
*scope = r;
*macroScope = r;
}
break;
case K_PSUEDO_MACRO_END:
macro_tag = getEntryInCorkQueue (*scope);
macro_tag = getEntryInCorkQueue (*macroScope);
if (macro_tag)
{
macro_tag->extensionFields.endLine = getInputLineNumber ();
*scope = macro_tag->extensionFields.scopeIndex;
*macroScope = macro_tag->extensionFields.scopeIndex;
}
break;
case K_SECTION:
Expand All @@ -278,6 +278,7 @@ static int makeAsmTag (
break;
default:
r = makeSimpleTag (operator, kind_for_directive);
break;
}
}
}
Expand Down Expand Up @@ -655,7 +656,7 @@ static void findAsmTagsCommon (bool useCpp)
KIND_GHOST_INDEX, 0, 0, KIND_GHOST_INDEX, KIND_GHOST_INDEX, 0, 0,
FIELD_UNKNOWN);

int scope = CORK_NIL;
int macroScope = CORK_NIL;

while ((line = asmReadLineFromInputFile (commentCharsInMOL, useCpp)) != NULL)
{
Expand Down Expand Up @@ -719,7 +720,7 @@ static void findAsmTagsCommon (bool useCpp)
cp = readSymbol (cp, name);
nameFollows = true;
}
int r = makeAsmTag (name, operator, labelCandidate, nameFollows, directive, &scope);
int r = makeAsmTag (name, operator, labelCandidate, nameFollows, directive, &macroScope);
tagEntryInfo *e = getEntryInCorkQueue (r);
if (e && e->kindIndex == K_MACRO && isRoleAssigned(e, ROLE_DEFINITION_INDEX))
readMacroParameters (r, e, cp);
Expand Down
15 changes: 15 additions & 0 deletions parsers/cxx/cxx_tag.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,21 @@ bool cxxTagKindEnabled(unsigned int uKind)
return g_cxx.pKindDefinitions[uKind].enabled;
}

bool cxxTagRoleEnabled(unsigned int uKind, int iRole)
{
if(!cxxTagKindEnabled(uKind))
return true;
if(iRole == ROLE_DEFINITION_INDEX)
return true;

CXX_DEBUG_ASSERT(
(ROLE_DEFINITION_INDEX < iRole
&& iRole < g_cxx.pKindDefinitions[uKind].nRoles),
"The role must be associated to the kind (%u)", uKind
);
return g_cxx.pKindDefinitions[uKind].roles[iRole].enabled;
}

fieldDefinition * cxxTagGetCPPFieldDefinitionifiers(void)
{
return g_aCXXCPPFields;
Expand Down
3 changes: 3 additions & 0 deletions parsers/cxx/cxx_tag.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ int cxxTagGetCPPKindDefinitionCount(void);
// Returns true if the specified tag kind is enabled in the current language
bool cxxTagKindEnabled(unsigned int uTagKind);

// Returns true if the specified tag role is enabled in the current language
bool cxxTagRoleEnabled(unsigned int uTagKind, int iTagRole);

// Begin composing a tag. The tag kind must correspond to the current language.
// Returns NULL if the tag should *not* be included in the output
// or the tag entry info that can be filled up with extension fields.
Expand Down
2 changes: 1 addition & 1 deletion parsers/cxx/cxx_token.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ typedef struct _CXXToken
vString * pszWord;
CXXKeyword eKeyword;
CXXTokenChain * pChain; // this is NOT the parent chain!
bool bFollowedBySpace;
unsigned int bFollowedBySpace: 1;

int iLineNumber;
MIOPos oFilePosition;
Expand Down
Loading