summaryrefslogtreecommitdiff
path: root/xfa/fxfa/fm2js/cxfa_fmparser.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2018-02-22 20:01:15 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-02-22 20:01:15 +0000
commit26fc813975170de5040e9abe79a80b7034719944 (patch)
tree3ba21bf39f87fb4b47df8da5ecd31c41f5bb4c9a /xfa/fxfa/fm2js/cxfa_fmparser.cpp
parentcc48741d63e216b3030fc2e452b6cf07481596ea (diff)
downloadpdfium-26fc813975170de5040e9abe79a80b7034719944.tar.xz
[formcalc] Cleanup function handling
This CL creates a CXFA_FMAST root for the AST tree instead of overloading the CXFA_FMFunctionDefinition. This Removes the m_global from FunctionDefinition and simpifies the code. Change-Id: I9347769a291ef1753539701f334cc8dd69b7187e Reviewed-on: https://pdfium-review.googlesource.com/27590 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'xfa/fxfa/fm2js/cxfa_fmparser.cpp')
-rw-r--r--xfa/fxfa/fm2js/cxfa_fmparser.cpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/xfa/fxfa/fm2js/cxfa_fmparser.cpp b/xfa/fxfa/fm2js/cxfa_fmparser.cpp
index 9beda2c564..30746a39c4 100644
--- a/xfa/fxfa/fm2js/cxfa_fmparser.cpp
+++ b/xfa/fxfa/fm2js/cxfa_fmparser.cpp
@@ -28,14 +28,12 @@ CXFA_FMParser::CXFA_FMParser(const WideStringView& wsFormcalc)
CXFA_FMParser::~CXFA_FMParser() {}
-std::unique_ptr<CXFA_FMFunctionDefinition> CXFA_FMParser::Parse() {
+std::unique_ptr<CXFA_FMAST> CXFA_FMParser::Parse() {
auto expressions = ParseExpressionList();
if (HasError())
return nullptr;
- std::vector<WideStringView> arguments;
- return pdfium::MakeUnique<CXFA_FMFunctionDefinition>(
- true, L"", std::move(arguments), std::move(expressions));
+ return pdfium::MakeUnique<CXFA_FMAST>(std::move(expressions));
}
bool CXFA_FMParser::NextToken() {
@@ -101,14 +99,15 @@ std::unique_ptr<CXFA_FMExpression> CXFA_FMParser::ParseFunction() {
std::vector<std::unique_ptr<CXFA_FMExpression>> expressions;
if (!CheckThenNext(TOKfunc))
return nullptr;
+
if (m_token.m_type != TOKidentifier) {
m_error = true;
return nullptr;
- } else {
- ident = m_token.m_string;
- if (!NextToken())
- return nullptr;
}
+
+ ident = m_token.m_string;
+ if (!NextToken())
+ return nullptr;
if (!CheckThenNext(TOKlparen))
return nullptr;
@@ -149,7 +148,7 @@ std::unique_ptr<CXFA_FMExpression> CXFA_FMParser::ParseFunction() {
}
return pdfium::MakeUnique<CXFA_FMFunctionDefinition>(
- false, ident, std::move(arguments), std::move(expressions));
+ ident, std::move(arguments), std::move(expressions));
}
// Expression := IfExpression | WhileExpression | ForExpression |