Skip to content

Commit 3933244

Browse files
gkzmeta-codesync[bot]
authored andcommitted
Add option to gate parsing of Flow records
Summary: Add option to gate parsing of Flow records Reviewed By: avp Differential Revision: D88059450 fbshipit-source-id: c468b3c6062f0b1e562274c36d5e0c5836d5f04b
1 parent ac5f6e1 commit 3933244

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

include/hermes/AST/Context.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,10 @@ class Context {
255255
/// also using Flow syntax.
256256
bool parseFlowMatch_{false};
257257

258+
/// If true, allow parsing Flow record declarations and expressions
259+
/// when also using Flow syntax.
260+
bool parseFlowRecords_{false};
261+
258262
/// Whether to parse Flow type syntax.
259263
ParseFlowSetting parseFlow_{ParseFlowSetting::NONE};
260264

@@ -452,6 +456,13 @@ class Context {
452456
return parseFlowMatch_;
453457
}
454458

459+
void setParseFlowRecords(bool parseFlowRecords) {
460+
parseFlowRecords_ = parseFlowRecords;
461+
}
462+
bool getParseFlowRecords() const {
463+
return parseFlowRecords_;
464+
}
465+
455466
void setParseTS(bool parseTS) {
456467
parseTS_ = parseTS;
457468
}

lib/CompilerDriver/CompilerDriver.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,13 @@ static opt<bool> ParseFlowMatch(
515515
init(false),
516516
Hidden,
517517
cat(CompilerCategory));
518+
519+
static opt<bool> ParseFlowRecords(
520+
"Xparse-flow-records",
521+
desc("Parse Flow record declarations and expressions"),
522+
init(false),
523+
Hidden,
524+
cat(CompilerCategory));
518525
#endif
519526

520527
#if HERMES_PARSE_TS
@@ -1216,6 +1223,7 @@ std::shared_ptr<Context> createContext(
12161223
}
12171224
context->setParseFlowComponentSyntax(cl::ParseFlowComponentSyntax);
12181225
context->setParseFlowMatch(cl::ParseFlowMatch);
1226+
context->setParseFlowRecords(cl::ParseFlowRecords);
12191227
#endif
12201228

12211229
#if HERMES_PARSE_TS

0 commit comments

Comments
 (0)