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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move EscapeSequenceParser to core #2168

Merged
merged 3 commits into from Jun 1, 2019
Merged

Conversation

Tyriar
Copy link
Member

@Tyriar Tyriar commented Jun 1, 2019

Part of #1507

@jerch can you check out the EscapeSequenceParser.ts diff? I needed to tweak a bunch of stuff and want to make sure it's right 馃檪

@Tyriar Tyriar added this to the 4.0.0 milestone Jun 1, 2019
@Tyriar Tyriar requested a review from jerch June 1, 2019 05:37
@Tyriar Tyriar self-assigned this Jun 1, 2019
add(code: number, state: number, action: number | null, next: number | null): void {
this.table[state << 8 | code] = ((action | 0) << 4) | ((next === undefined) ? state : next);
add(code: number, state: number, action: number | null, next: number | undefined): void {
this.table[state << 8 | code] = ((action || 0) << 4) | ((next === undefined) ? state : next);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed action | 0 to action || 0, was this right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm the old JS version relied on | 0 (anything cast to a number), but I think its not needed anymore (I think all add calls now have the full args list). Lemme check.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed arg types to ParserAction and ParserState and removed the undefined and null types.

@@ -279,21 +279,10 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP
}

public dispose(): void {
this._printHandlerFb = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we cannot (yet) remove these as they might hold a reference from the input handler with a terminal object?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think in that case it will still get disposed correctly and release the reference to input handler and terminal when the consumers reference to terminal is removed

@@ -453,7 +442,9 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP
this._printHandler(data, print, i);
print = -1;
} else if (~dcs) {
dcsHandler.put(data, dcs, i);
if (dcsHandler) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was there an error regarding this? In theory dcsHandler should never be null here (if so the parser has a serious logic flaw). I am abit unhappy about dcsHandler being null in between, guess this needs some refactoring (to reduce branching).
Well its good for now with this addtional check.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dcsHandler could be null according to the type system, if we're certain and want to avoid the if we could compel the type system with !, that's unsafe though.

@jerch
Copy link
Member

jerch commented Jun 1, 2019

@Tyriar Added the need to rework the dcsHandler logic in #1823 (my parser TODO ticket). Guess I should this get this done rather soon.

@Tyriar Tyriar merged commit 67db588 into xtermjs:master Jun 1, 2019
@Tyriar Tyriar deleted the parser_core branch June 1, 2019 17:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants