Skip to content

Commit b13b0a3

Browse files
committed
Supoort debugger stmt
1 parent 6372264 commit b13b0a3

File tree

5 files changed

+21
-1
lines changed

5 files changed

+21
-1
lines changed

ratel-codegen/src/statement.rs

+9
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ impl<'ast, G: Generator> ToCode<G> for Statement<'ast> {
1111

1212
match *self {
1313
Empty => {},
14+
Debugger => {
15+
gen.write_bytes(b"debugger");
16+
},
1417
Expression(ref expression) => {
1518
if expression.is_allowed_as_bare_statement() {
1619
gen.write(expression);
@@ -313,6 +316,12 @@ impl<'ast, G: Generator> ToCode<G> for SwitchCase<'ast> {
313316
mod test {
314317
use assert_min;
315318

319+
#[test]
320+
fn debugger_statement() {
321+
assert_min("debugger", "debugger");
322+
assert_min("debugger;", "debugger");
323+
}
324+
316325
#[test]
317326
fn block_statement() {
318327
assert_min("{}", "{}");

ratel-visitor/src/statement.rs

+3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ impl<'ast> Visitable<'ast> for StatementNode<'ast> {
1919
// EmptyStatement doesn't have children, we return early to avoid calling pop_parent
2020
return;
2121
},
22+
Debugger => {
23+
return;
24+
},
2225
Expression(ref expression) => {
2326
visitor.on_expression_statement(expression, self);
2427
visitor.push_parent(ParentNode::from(self));

ratel/src/ast/statement.rs

+1
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ pub type ClassStatement<'ast> = Class<'ast, MandatoryName<'ast>>;
120120
#[derive(Debug, PartialEq, Clone, Copy)]
121121
pub enum Statement<'ast> {
122122
Empty,
123+
Debugger,
123124
Expression(ExpressionNode<'ast>),
124125
Declaration(DeclarationStatement<'ast>),
125126
Return(ReturnStatement<'ast>),

ratel/src/astgen/statement.rs

+1
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ impl<'ast> SerializeInLoc for Statement<'ast> {
212212

213213
match *self {
214214
Empty => self.in_loc(serializer, "EmptyStatement", 0, |_| Ok(())),
215+
Debugger => self.in_loc(serializer, "DebuggerStatement", 0, |_| Ok(())),
215216
Expression(ref expression) => {
216217
self.in_loc(serializer, "ExpressionStatement", 1, |state| {
217218
state.serialize_field("expression", expression)

ratel/src/parser/statement.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ static STMT_HANDLERS: [StatementHandler; 108] = [
3333
CONS, BRK, DO, ____, ____, ____, ____, CLAS, ____, RET, WHL, ____,
3434
// CONST BREAK DO CASE ELSE CATCH EXPRT CLASS EXTND RET WHILE FINLY
3535

36-
____, ____, CONT, FOR, SWCH, ____, ____, FUNC, THIS, ____, IF, THRW,
36+
____, ____, CONT, FOR, SWCH, ____, DBGGR, FUNC, THIS, ____, IF, THRW,
3737
// SUPER WITH CONT FOR SWTCH YIELD DBGGR FUNCT THIS DEFLT IF THROW
3838

3939
____, TRY, ____, TRUE, FALS, NULL, UNDE, STR, NUM, BIN, ____, ____,
@@ -72,6 +72,12 @@ create_handlers! {
7272

7373
stmt
7474
};
75+
const DBGGR = |par| {
76+
let stmt = par.alloc_in_loc(Statement::Debugger);
77+
par.lexer.consume();
78+
79+
stmt
80+
};
7581
const BLCK = |par| par.block_statement();
7682
const VAR = |par| par.variable_declaration_statement(DeclarationKind::Var);
7783
const LET = |par| par.variable_declaration_statement(DeclarationKind::Let);

0 commit comments

Comments
 (0)