Skip to content

Commit

Permalink
[modules] Move generateInternalLabelReference() to semact
Browse files Browse the repository at this point in the history
since labelReference() is there and it is mostly used by semantic actions.
  • Loading branch information
thoni56 committed Sep 6, 2023
1 parent 147da7d commit 3a73718
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ $(eval $(call UNITTEST,progress,protocol log))
$(eval $(call UNITTEST,refactorings,log))
$(eval $(call UNITTEST,refactory,protocol usage position log memory session))
$(eval $(call UNITTEST,reftab,log memory hash))
$(eval $(call UNITTEST,semact,memory log protocol usage hash position storage type))
$(eval $(call UNITTEST,semact,memory log protocol usage hash position storage type id))
$(eval $(call UNITTEST,server,memory log session position))
$(eval $(call UNITTEST,symbol,memory log))
$(eval $(call UNITTEST,symboltable,hash log memory))
Expand Down
2 changes: 1 addition & 1 deletion src/counters_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include "counters.h"

#include "extract.mock"
#include "semact.mock"


Describe(Counters);
Expand Down
20 changes: 0 additions & 20 deletions src/extract.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,26 +87,6 @@ void dumpProgram(ProgramGraphNode *program) {
printf("[ProgramDump end]\n");
}

void generateInternalLabelReference(int counter, int usage) {
char labelName[TMP_STRING_SIZE];
Id labelId;
Position position;

if (options.serverOperation != OLO_EXTRACT)
return;

snprintf(labelName, TMP_STRING_SIZE, "%%L%d", counter);

position = (Position){.file = currentFile.characterBuffer.fileNumber, .line = 0, .col = 0};
fillId(&labelId, labelName, NULL, position);

if (usage != UsageDefined)
labelId.position.line++;
// line == 0 or 1 , (hack to get definition first)
labelReference(&labelId, usage);
}


Symbol *addContinueBreakLabelSymbol(int labn, char *name) {
Symbol *s;

Expand Down
1 change: 0 additions & 1 deletion src/extract.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ typedef struct referencesItemList {
extern Symbol *addContinueBreakLabelSymbol(int labn, char *name);
extern void actionsBeforeAfterExternalDefinition(void);
extern void extractActionOnBlockMarker(void);
extern void generateInternalLabelReference(int counter, int usage);
extern void deleteContinueBreakLabelSymbol(char *name);
extern void generateContinueBreakReference(char *name);
extern void generateSwitchCaseFork(bool isLast);
Expand Down
4 changes: 0 additions & 4 deletions src/extract.mock
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ void extractActionOnBlockMarker(void) {
mock();
}

void generateInternalLabelReference(int counter, int usage) {
mock(counter, usage);
}

void deleteContinueBreakLabelSymbol(char *name) {
mock(name);
}
Expand Down
20 changes: 20 additions & 0 deletions src/semact.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "commons.h"
#include "counters.h"
#include "globals.h"
#include "filedescriptor.h"
#include "options.h"
#include "parsers.h"
#include "misc.h"
Expand Down Expand Up @@ -495,6 +496,25 @@ void labelReference(Id *id, UsageKind usage) {
addTrivialCxReference(tempString, TypeLabel,StorageDefault, id->position, usage);
}

void generateInternalLabelReference(int counter, int usage) {
char labelName[TMP_STRING_SIZE];
Id labelId;
Position position;

if (options.serverOperation != OLO_EXTRACT)
return;

snprintf(labelName, TMP_STRING_SIZE, "%%L%d", counter);

position = (Position){.file = currentFile.characterBuffer.fileNumber, .line = 0, .col = 0};
fillId(&labelId, labelName, NULL, position);

if (usage != UsageDefined)
labelId.position.line++;
// line == 0 or 1 , (hack to get definition first)
labelReference(&labelId, usage);
}

void setLocalVariableLinkName(struct symbol *p) {
char ttt[TMP_STRING_SIZE];
char nnn[TMP_STRING_SIZE];
Expand Down
1 change: 1 addition & 0 deletions src/semact.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ extern void javaHandleDeclaratorParamPositions(Position *sym, Position *lpar,
PositionList *commas, Position *rpar);
extern void setLocalVariableLinkName(struct symbol *p);
extern void labelReference(Id *id, UsageKind usage);
extern void generateInternalLabelReference(int counter, int usage);
extern void setDirectStructureCompletionType(TypeModifier *xxx);
extern void setIndirectStructureCompletionType(TypeModifier *xxx);

Expand Down
4 changes: 4 additions & 0 deletions src/semact.mock
Original file line number Diff line number Diff line change
Expand Up @@ -209,3 +209,7 @@ void setLocalVariableLinkName(struct symbol *p) {
void labelReference(Id *id, UsageKind usage) {
mock(id, usage);
}

void generateInternalLabelReference(int counter, int usage) {
mock(counter, usage);
}
1 change: 1 addition & 0 deletions src/semact_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "cxref.mock"
#include "editor.mock"
#include "filetable.mock"
#include "filedescriptor.mock"
#include "globals.mock"
#include "jsemact.mock"
#include "jslsemact.mock"
Expand Down

0 comments on commit 3a73718

Please sign in to comment.