summaryrefslogtreecommitdiff
path: root/xfa/fxfa
diff options
context:
space:
mode:
authorRyan Harrison <rharrison@chromium.org>2017-07-27 11:41:07 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-07-27 18:03:49 +0000
commit495d89ff20806b6acdf564f3865b1fb974ccf44a (patch)
tree1b4d867bfef50f6870c217506e781bd372b2b3ca /xfa/fxfa
parent2b70ec2d6df96bdf6f72cfac7a8cbbcdd1293d8c (diff)
downloadpdfium-495d89ff20806b6acdf564f3865b1fb974ccf44a.tar.xz
Add conversion from FMTokens to strings
This is to aid with debugging, since the getting things like the type is a pain due to it being a enum. Bug: Change-Id: I89bae7103b476d7fd09ba78699367a1a413ee700 Reviewed-on: https://pdfium-review.googlesource.com/9190 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'xfa/fxfa')
-rw-r--r--xfa/fxfa/fm2js/cxfa_fmlexer.cpp30
-rw-r--r--xfa/fxfa/fm2js/cxfa_fmlexer.h2
2 files changed, 32 insertions, 0 deletions
diff --git a/xfa/fxfa/fm2js/cxfa_fmlexer.cpp b/xfa/fxfa/fm2js/cxfa_fmlexer.cpp
index dc86c23b06..5ae8a6f40b 100644
--- a/xfa/fxfa/fm2js/cxfa_fmlexer.cpp
+++ b/xfa/fxfa/fm2js/cxfa_fmlexer.cpp
@@ -95,6 +95,26 @@ const XFA_FMKeyword keyWords[] = {
const XFA_FM_TOKEN KEYWORD_START = TOKdo;
const XFA_FM_TOKEN KEYWORD_END = TOKendif;
+const wchar_t* tokenStrings[] = {
+ L"TOKand", L"TOKlparen", L"TOKrparen", L"TOKmul",
+ L"TOKplus", L"TOKcomma", L"TOKminus", L"TOKdot",
+ L"TOKdiv", L"TOKlt", L"TOKassign", L"TOKgt",
+ L"TOKlbracket", L"TOKrbracket", L"TOKor", L"TOKdotscream",
+ L"TOKdotstar", L"TOKdotdot", L"TOKle", L"TOKne",
+ L"TOKeq", L"TOKge", L"TOKdo", L"TOKkseq",
+ L"TOKksge", L"TOKksgt", L"TOKif", L"TOKin",
+ L"TOKksle", L"TOKkslt", L"TOKksne", L"TOKksor",
+ L"TOKnull", L"TOKbreak", L"TOKksand", L"TOKend",
+ L"TOKeof", L"TOKfor", L"TOKnan", L"TOKksnot",
+ L"TOKvar", L"TOKthen", L"TOKelse", L"TOKexit",
+ L"TOKdownto", L"TOKreturn", L"TOKinfinity", L"TOKendwhile",
+ L"TOKforeach", L"TOKendfunc", L"TOKelseif", L"TOKwhile",
+ L"TOKendfor", L"TOKthrow", L"TOKstep", L"TOKupto",
+ L"TOKcontinue", L"TOKfunc", L"TOKendif", L"TOKstar",
+ L"TOKidentifier", L"TOKunderscore", L"TOKdollar", L"TOKexclamation",
+ L"TOKcall", L"TOKstring", L"TOKnumber", L"TOKreserver",
+};
+
XFA_FM_TOKEN TokenizeIdentifier(const CFX_WideStringC& str) {
uint32_t key = FX_HashCode_GetW(str, true);
@@ -118,6 +138,16 @@ CXFA_FMToken::CXFA_FMToken(uint32_t line_num)
CXFA_FMToken::~CXFA_FMToken() {}
+CFX_WideString CXFA_FMToken::ToDebugString() const {
+ CFX_WideString str(L"type = ");
+ str += tokenStrings[m_type];
+ str += L", string = ";
+ str += m_string;
+ str += L", line_num = ";
+ str += std::to_wstring(m_line_num).c_str();
+ return str;
+}
+
CXFA_FMLexer::CXFA_FMLexer(const CFX_WideStringC& wsFormCalc)
: m_cursor(wsFormCalc.unterminated_c_str()),
m_end(m_cursor + wsFormCalc.GetLength() - 1),
diff --git a/xfa/fxfa/fm2js/cxfa_fmlexer.h b/xfa/fxfa/fm2js/cxfa_fmlexer.h
index b3f13dae7a..858dc5d988 100644
--- a/xfa/fxfa/fm2js/cxfa_fmlexer.h
+++ b/xfa/fxfa/fm2js/cxfa_fmlexer.h
@@ -95,6 +95,8 @@ class CXFA_FMToken {
explicit CXFA_FMToken(uint32_t line_num);
~CXFA_FMToken();
+ CFX_WideString ToDebugString() const;
+
CFX_WideStringC m_string;
XFA_FM_TOKEN m_type;
uint32_t m_line_num;