Skip to content

Commit

Permalink
kernel: remove InterpreterStartLine from GAPState
Browse files Browse the repository at this point in the history
... and instead put it into `struct IntrState`, where it arguably belongs.

This further decouples the scanner/reader/interpreter from the IO code.
  • Loading branch information
fingolfin authored and ChrisJefferson committed Mar 20, 2020
1 parent a55149e commit 05347eb
Show file tree
Hide file tree
Showing 6 changed files with 157 additions and 153 deletions.
4 changes: 0 additions & 4 deletions src/gapstate.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ typedef struct GAPState {
UInt NrError;
UInt NrErrLine;

// Used for recording the first line of the fragment of code currently
// begin interpreted, so the current line is outputted when profiling
UInt InterpreterStartLine;

const char * Prompt;

char * In;
Expand Down
4 changes: 2 additions & 2 deletions src/intrprtr.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@
static void INTERPRETER_PROFILE_HOOK(IntrState * intr, int ignoreLevel)
{
if (!intr->coding) {
InterpreterHook(GetInputFilenameID(), STATE(InterpreterStartLine),
InterpreterHook(GetInputFilenameID(), intr->startLine,
intr->returning || (intr->ignoring > ignoreLevel));
}
STATE(InterpreterStartLine) = 0;
intr->startLine = 0;
}


Expand Down
5 changes: 5 additions & 0 deletions src/intrprtr.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ struct IntrState {
// are ignored.
ExecStatus returning;

// Record the first line of the fragment of code currently being
// interpreted in 'startLine', so we can mark interpreted code lines when
// profiling
UInt startLine;

// 'StackObj' is the stack of values.
Obj StackObj;

Expand Down
9 changes: 0 additions & 9 deletions src/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,6 @@ typedef struct {
// character
char * ptr;

// the number of the line where the fragment of code currently being
// interpreted started; used for profiling
Int interpreterStartLine;

// the number of the current line; used in error messages
Int number;

Expand Down Expand Up @@ -510,7 +506,6 @@ UInt OpenInput (
if (IO()->InputStackPointer > 0) {
GAP_ASSERT(IS_CHAR_PUSHBACK_EMPTY());
IO()->Input->ptr = STATE(In);
IO()->Input->interpreterStartLine = STATE(InterpreterStartLine);
}

/* enter the file identifier and the file name */
Expand All @@ -531,7 +526,6 @@ UInt OpenInput (
// start with an empty line
STATE(In) = IO()->Input->line;
STATE(In)[0] = STATE(In)[1] = '\0';
STATE(InterpreterStartLine) = 0;
IO()->Input->number = 1;

/* indicate success */
Expand All @@ -555,7 +549,6 @@ UInt OpenInputStream(Obj stream, UInt echo)
if (IO()->InputStackPointer > 0) {
GAP_ASSERT(IS_CHAR_PUSHBACK_EMPTY());
IO()->Input->ptr = STATE(In);
IO()->Input->interpreterStartLine = STATE(InterpreterStartLine);
}

/* enter the file identifier and the file name */
Expand All @@ -579,7 +572,6 @@ UInt OpenInputStream(Obj stream, UInt echo)
// start with an empty line
STATE(In) = IO()->Input->line;
STATE(In)[0] = STATE(In)[1] = '\0';
STATE(InterpreterStartLine) = 0;
IO()->Input->number = 1;

/* indicate success */
Expand Down Expand Up @@ -634,7 +626,6 @@ UInt CloseInput ( void )
#endif
IO()->Input = IO()->InputStack[sp - 1];
STATE(In) = IO()->Input->ptr;
STATE(InterpreterStartLine) = IO()->Input->interpreterStartLine;

/* indicate success */
return 1;
Expand Down
Loading

0 comments on commit 05347eb

Please sign in to comment.