Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Side by Side Diff: xfa/fxfa/fm2js/xfa_fmparse.cpp

Issue 1979723003: Make CFX_WideString(const CFX_WideString&) explicit. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Override Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fxfa/fm2js/xfa_fm2jscontext.cpp ('k') | xfa/fxfa/fm2js/xfa_simpleexpression.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "xfa/fxfa/fm2js/xfa_fmparse.h" 7 #include "xfa/fxfa/fm2js/xfa_fmparse.h"
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 11 matching lines...) Expand all
22 while (m_pToken->m_type == TOKreserver) { 22 while (m_pToken->m_type == TOKreserver) {
23 if (m_lexer->HasError()) { 23 if (m_lexer->HasError()) {
24 break; 24 break;
25 } 25 }
26 m_pToken = m_lexer->NextToken(); 26 m_pToken = m_lexer->NextToken();
27 } 27 }
28 } 28 }
29 29
30 void CXFA_FMParse::Check(XFA_FM_TOKEN op) { 30 void CXFA_FMParse::Check(XFA_FM_TOKEN op) {
31 if (m_pToken->m_type != op) { 31 if (m_pToken->m_type != op) {
32 CFX_WideString ws_TempString = m_pToken->m_wstring; 32 CFX_WideString ws_TempString(m_pToken->m_wstring);
33 Error(m_pToken->m_uLinenum, kFMErrExpectedToken, XFA_FM_KeywordToString(op), 33 Error(m_pToken->m_uLinenum, kFMErrExpectedToken, XFA_FM_KeywordToString(op),
34 ws_TempString.c_str()); 34 ws_TempString.c_str());
35 } 35 }
36 NextToken(); 36 NextToken();
37 } 37 }
38 38
39 void CXFA_FMParse::Error(uint32_t lineNum, const FX_WCHAR* msg, ...) { 39 void CXFA_FMParse::Error(uint32_t lineNum, const FX_WCHAR* msg, ...) {
40 m_pErrorInfo->linenum = lineNum; 40 m_pErrorInfo->linenum = lineNum;
41 va_list ap; 41 va_list ap;
42 va_start(ap, msg); 42 va_start(ap, msg);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 } 75 }
76 76
77 CXFA_FMExpression* CXFA_FMParse::ParseFunction() { 77 CXFA_FMExpression* CXFA_FMParse::ParseFunction() {
78 std::unique_ptr<CXFA_FMExpression> e; 78 std::unique_ptr<CXFA_FMExpression> e;
79 CFX_WideStringC ident; 79 CFX_WideStringC ident;
80 std::unique_ptr<CFX_WideStringCArray> pArguments; 80 std::unique_ptr<CFX_WideStringCArray> pArguments;
81 std::unique_ptr<CFX_ArrayTemplate<CXFA_FMExpression*>> pExpressions; 81 std::unique_ptr<CFX_ArrayTemplate<CXFA_FMExpression*>> pExpressions;
82 uint32_t line = m_pToken->m_uLinenum; 82 uint32_t line = m_pToken->m_uLinenum;
83 NextToken(); 83 NextToken();
84 if (m_pToken->m_type != TOKidentifier) { 84 if (m_pToken->m_type != TOKidentifier) {
85 CFX_WideString ws_TempString = m_pToken->m_wstring; 85 CFX_WideString ws_TempString(m_pToken->m_wstring);
86 Error(m_pToken->m_uLinenum, kFMErrExpectedIdentifier, 86 Error(m_pToken->m_uLinenum, kFMErrExpectedIdentifier,
87 ws_TempString.c_str()); 87 ws_TempString.c_str());
88 } else { 88 } else {
89 ident = m_pToken->m_wstring; 89 ident = m_pToken->m_wstring;
90 NextToken(); 90 NextToken();
91 } 91 }
92 Check(TOKlparen); 92 Check(TOKlparen);
93 if (m_pToken->m_type == TOKrparen) { 93 if (m_pToken->m_type == TOKrparen) {
94 NextToken(); 94 NextToken();
95 } else { 95 } else {
96 pArguments.reset(new CFX_WideStringCArray()); 96 pArguments.reset(new CFX_WideStringCArray());
97 CFX_WideStringC p; 97 CFX_WideStringC p;
98 while (1) { 98 while (1) {
99 if (m_pToken->m_type == TOKidentifier) { 99 if (m_pToken->m_type == TOKidentifier) {
100 p = m_pToken->m_wstring; 100 p = m_pToken->m_wstring;
101 pArguments->Add(p); 101 pArguments->Add(p);
102 NextToken(); 102 NextToken();
103 if (m_pToken->m_type == TOKcomma) { 103 if (m_pToken->m_type == TOKcomma) {
104 NextToken(); 104 NextToken();
105 continue; 105 continue;
106 } else if (m_pToken->m_type == TOKrparen) { 106 } else if (m_pToken->m_type == TOKrparen) {
107 NextToken(); 107 NextToken();
108 break; 108 break;
109 } else { 109 } else {
110 Check(TOKrparen); 110 Check(TOKrparen);
111 break; 111 break;
112 } 112 }
113 } else { 113 } else {
114 CFX_WideString ws_TempString = m_pToken->m_wstring; 114 CFX_WideString ws_TempString(m_pToken->m_wstring);
115 Error(m_pToken->m_uLinenum, kFMErrExpectedIdentifier, 115 Error(m_pToken->m_uLinenum, kFMErrExpectedIdentifier,
116 ws_TempString.c_str()); 116 ws_TempString.c_str());
117 NextToken(); 117 NextToken();
118 break; 118 break;
119 } 119 }
120 } 120 }
121 } 121 }
122 Check(TOKdo); 122 Check(TOKdo);
123 if (m_pToken->m_type == TOKendfunc) { 123 if (m_pToken->m_type == TOKendfunc) {
124 NextToken(); 124 NextToken();
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 break; 174 break;
175 case TOKbreak: 175 case TOKbreak:
176 e.reset(new CXFA_FMBreakExpression(line)); 176 e.reset(new CXFA_FMBreakExpression(line));
177 NextToken(); 177 NextToken();
178 break; 178 break;
179 case TOKcontinue: 179 case TOKcontinue:
180 e.reset(new CXFA_FMContinueExpression(line)); 180 e.reset(new CXFA_FMContinueExpression(line));
181 NextToken(); 181 NextToken();
182 break; 182 break;
183 default: 183 default:
184 CFX_WideString ws_TempString = m_pToken->m_wstring; 184 CFX_WideString ws_TempString(m_pToken->m_wstring);
185 Error(m_pToken->m_uLinenum, kFMErrUnexpectedExpression, 185 Error(m_pToken->m_uLinenum, kFMErrUnexpectedExpression,
186 ws_TempString.c_str()); 186 ws_TempString.c_str());
187 NextToken(); 187 NextToken();
188 break; 188 break;
189 } 189 }
190 return e.release(); 190 return e.release();
191 } 191 }
192 192
193 CXFA_FMExpression* CXFA_FMParse::ParseVarExpression() { 193 CXFA_FMExpression* CXFA_FMParse::ParseVarExpression() {
194 std::unique_ptr<CXFA_FMExpression> e; 194 std::unique_ptr<CXFA_FMExpression> e;
195 CFX_WideStringC ident; 195 CFX_WideStringC ident;
196 uint32_t line = m_pToken->m_uLinenum; 196 uint32_t line = m_pToken->m_uLinenum;
197 NextToken(); 197 NextToken();
198 if (m_pToken->m_type != TOKidentifier) { 198 if (m_pToken->m_type != TOKidentifier) {
199 CFX_WideString ws_TempString = m_pToken->m_wstring; 199 CFX_WideString ws_TempString(m_pToken->m_wstring);
200 Error(m_pToken->m_uLinenum, kFMErrExpectedIdentifier, 200 Error(m_pToken->m_uLinenum, kFMErrExpectedIdentifier,
201 ws_TempString.c_str()); 201 ws_TempString.c_str());
202 } else { 202 } else {
203 ident = m_pToken->m_wstring; 203 ident = m_pToken->m_wstring;
204 NextToken(); 204 NextToken();
205 } 205 }
206 if (m_pToken->m_type == TOKassign) { 206 if (m_pToken->m_type == TOKassign) {
207 NextToken(); 207 NextToken();
208 e.reset(ParseExpExpression()); 208 e.reset(ParseExpExpression());
209 } 209 }
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 NextToken(); 525 NextToken();
526 break; 526 break;
527 case TOKnull: 527 case TOKnull:
528 e.reset(new CXFA_FMNullExpression(line)); 528 e.reset(new CXFA_FMNullExpression(line));
529 NextToken(); 529 NextToken();
530 break; 530 break;
531 case TOKlparen: 531 case TOKlparen:
532 e.reset(ParseParenExpression()); 532 e.reset(ParseParenExpression());
533 break; 533 break;
534 default: 534 default:
535 CFX_WideString ws_TempString = m_pToken->m_wstring; 535 CFX_WideString ws_TempString(m_pToken->m_wstring);
536 Error(m_pToken->m_uLinenum, kFMErrUnexpectedExpression, 536 Error(m_pToken->m_uLinenum, kFMErrUnexpectedExpression,
537 ws_TempString.c_str()); 537 ws_TempString.c_str());
538 NextToken(); 538 NextToken();
539 break; 539 break;
540 } 540 }
541 e.reset(ParsePostExpression(e.release())); 541 e.reset(ParsePostExpression(e.release()));
542 if (!(m_pErrorInfo->message.IsEmpty())) 542 if (!(m_pErrorInfo->message.IsEmpty()))
543 e.reset(); 543 e.reset();
544 return e.release(); 544 return e.release();
545 } 545 }
(...skipping 14 matching lines...) Expand all
560 pArray->Add(e); 560 pArray->Add(e);
561 } 561 }
562 if (m_pToken->m_type == TOKcomma) { 562 if (m_pToken->m_type == TOKcomma) {
563 NextToken(); 563 NextToken();
564 } else if (m_pToken->m_type == TOKeof || 564 } else if (m_pToken->m_type == TOKeof ||
565 m_pToken->m_type == TOKreserver) { 565 m_pToken->m_type == TOKreserver) {
566 break; 566 break;
567 } 567 }
568 } 568 }
569 if (m_pToken->m_type != TOKrparen) { 569 if (m_pToken->m_type != TOKrparen) {
570 CFX_WideString ws_TempString = m_pToken->m_wstring; 570 CFX_WideString ws_TempString(m_pToken->m_wstring);
571 Error(m_pToken->m_uLinenum, kFMErrExpectedToken, 571 Error(m_pToken->m_uLinenum, kFMErrExpectedToken,
572 XFA_FM_KeywordToString(TOKrparen), ws_TempString.c_str()); 572 XFA_FM_KeywordToString(TOKrparen), ws_TempString.c_str());
573 } 573 }
574 } 574 }
575 if (m_pErrorInfo->message.IsEmpty()) { 575 if (m_pErrorInfo->message.IsEmpty()) {
576 e = new CXFA_FMCallExpression(line, e, pArray.release(), FALSE); 576 e = new CXFA_FMCallExpression(line, e, pArray.release(), FALSE);
577 NextToken(); 577 NextToken();
578 if (m_pToken->m_type != TOKlbracket) { 578 if (m_pToken->m_type != TOKlbracket) {
579 continue; 579 continue;
580 } 580 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 CXFA_FMSimpleExpression* exp = ParseSimpleExpression(); 613 CXFA_FMSimpleExpression* exp = ParseSimpleExpression();
614 pArray->Add(exp); 614 pArray->Add(exp);
615 if (m_pToken->m_type == TOKcomma) { 615 if (m_pToken->m_type == TOKcomma) {
616 NextToken(); 616 NextToken();
617 } else if (m_pToken->m_type == TOKeof || 617 } else if (m_pToken->m_type == TOKeof ||
618 m_pToken->m_type == TOKreserver) { 618 m_pToken->m_type == TOKreserver) {
619 break; 619 break;
620 } 620 }
621 } 621 }
622 if (m_pToken->m_type != TOKrparen) { 622 if (m_pToken->m_type != TOKrparen) {
623 CFX_WideString ws_TempString = m_pToken->m_wstring; 623 CFX_WideString ws_TempString(m_pToken->m_wstring);
624 Error(m_pToken->m_uLinenum, kFMErrExpectedToken, 624 Error(m_pToken->m_uLinenum, kFMErrExpectedToken,
625 XFA_FM_KeywordToString(TOKrparen), ws_TempString.c_str()); 625 XFA_FM_KeywordToString(TOKrparen), ws_TempString.c_str());
626 } 626 }
627 } 627 }
628 if (m_pErrorInfo->message.IsEmpty()) { 628 if (m_pErrorInfo->message.IsEmpty()) {
629 CXFA_FMSimpleExpression* pIdentifier = 629 CXFA_FMSimpleExpression* pIdentifier =
630 new CXFA_FMIdentifierExpressionn(tempLine, tempStr); 630 new CXFA_FMIdentifierExpressionn(tempLine, tempStr);
631 pExpCall = new CXFA_FMCallExpression(line, pIdentifier, 631 pExpCall = new CXFA_FMCallExpression(line, pIdentifier,
632 pArray.release(), TRUE); 632 pArray.release(), TRUE);
633 e = new CXFA_FMMethodCallExpression(line, pExpAccessor, pExpCall); 633 e = new CXFA_FMMethodCallExpression(line, pExpAccessor, pExpCall);
(...skipping 25 matching lines...) Expand all
659 } 659 }
660 e = new CXFA_FMDotAccessorExpression(tempLine, e, TOKdot, tempStr, 660 e = new CXFA_FMDotAccessorExpression(tempLine, e, TOKdot, tempStr,
661 s.release()); 661 s.release());
662 } else { 662 } else {
663 CXFA_FMSimpleExpression* s = new CXFA_FMIndexExpression( 663 CXFA_FMSimpleExpression* s = new CXFA_FMIndexExpression(
664 tempLine, ACCESSOR_NO_INDEX, NULL, FALSE); 664 tempLine, ACCESSOR_NO_INDEX, NULL, FALSE);
665 e = new CXFA_FMDotAccessorExpression(line, e, TOKdot, tempStr, s); 665 e = new CXFA_FMDotAccessorExpression(line, e, TOKdot, tempStr, s);
666 continue; 666 continue;
667 } 667 }
668 } else { 668 } else {
669 CFX_WideString ws_TempString = m_pToken->m_wstring; 669 CFX_WideString ws_TempString(m_pToken->m_wstring);
670 Error(m_pToken->m_uLinenum, kFMErrExpectedIdentifier, 670 Error(m_pToken->m_uLinenum, kFMErrExpectedIdentifier,
671 ws_TempString.c_str()); 671 ws_TempString.c_str());
672 return e; 672 return e;
673 } 673 }
674 break; 674 break;
675 case TOKdotdot: 675 case TOKdotdot:
676 NextToken(); 676 NextToken();
677 if (m_pToken->m_type == TOKidentifier) { 677 if (m_pToken->m_type == TOKidentifier) {
678 CFX_WideStringC tempStr = m_pToken->m_wstring; 678 CFX_WideStringC tempStr = m_pToken->m_wstring;
679 uint32_t tempLine = m_pToken->m_uLinenum; 679 uint32_t tempLine = m_pToken->m_uLinenum;
680 NextToken(); 680 NextToken();
681 if (m_pToken->m_type == TOKlbracket) { 681 if (m_pToken->m_type == TOKlbracket) {
682 std::unique_ptr<CXFA_FMSimpleExpression> s(ParseIndexExpression()); 682 std::unique_ptr<CXFA_FMSimpleExpression> s(ParseIndexExpression());
683 if (!(m_pErrorInfo->message.IsEmpty())) { 683 if (!(m_pErrorInfo->message.IsEmpty())) {
684 delete e; 684 delete e;
685 return nullptr; 685 return nullptr;
686 } 686 }
687 e = new CXFA_FMDotDotAccessorExpression(tempLine, e, TOKdotdot, 687 e = new CXFA_FMDotDotAccessorExpression(tempLine, e, TOKdotdot,
688 tempStr, s.release()); 688 tempStr, s.release());
689 } else { 689 } else {
690 CXFA_FMSimpleExpression* s = new CXFA_FMIndexExpression( 690 CXFA_FMSimpleExpression* s = new CXFA_FMIndexExpression(
691 tempLine, ACCESSOR_NO_INDEX, NULL, FALSE); 691 tempLine, ACCESSOR_NO_INDEX, NULL, FALSE);
692 e = new CXFA_FMDotDotAccessorExpression(line, e, TOKdotdot, tempStr, 692 e = new CXFA_FMDotDotAccessorExpression(line, e, TOKdotdot, tempStr,
693 s); 693 s);
694 continue; 694 continue;
695 } 695 }
696 } else { 696 } else {
697 CFX_WideString ws_TempString = m_pToken->m_wstring; 697 CFX_WideString ws_TempString(m_pToken->m_wstring);
698 Error(m_pToken->m_uLinenum, kFMErrExpectedIdentifier, 698 Error(m_pToken->m_uLinenum, kFMErrExpectedIdentifier,
699 ws_TempString.c_str()); 699 ws_TempString.c_str());
700 return e; 700 return e;
701 } 701 }
702 break; 702 break;
703 case TOKdotscream: 703 case TOKdotscream:
704 NextToken(); 704 NextToken();
705 if (m_pToken->m_type == TOKidentifier) { 705 if (m_pToken->m_type == TOKidentifier) {
706 CFX_WideStringC tempStr = m_pToken->m_wstring; 706 CFX_WideStringC tempStr = m_pToken->m_wstring;
707 uint32_t tempLine = m_pToken->m_uLinenum; 707 uint32_t tempLine = m_pToken->m_uLinenum;
708 NextToken(); 708 NextToken();
709 if (m_pToken->m_type == TOKlbracket) { 709 if (m_pToken->m_type == TOKlbracket) {
710 std::unique_ptr<CXFA_FMSimpleExpression> s(ParseIndexExpression()); 710 std::unique_ptr<CXFA_FMSimpleExpression> s(ParseIndexExpression());
711 if (!(m_pErrorInfo->message.IsEmpty())) { 711 if (!(m_pErrorInfo->message.IsEmpty())) {
712 delete e; 712 delete e;
713 return nullptr; 713 return nullptr;
714 } 714 }
715 e = new CXFA_FMDotAccessorExpression(tempLine, e, TOKdotscream, 715 e = new CXFA_FMDotAccessorExpression(tempLine, e, TOKdotscream,
716 tempStr, s.release()); 716 tempStr, s.release());
717 } else { 717 } else {
718 CXFA_FMSimpleExpression* s = new CXFA_FMIndexExpression( 718 CXFA_FMSimpleExpression* s = new CXFA_FMIndexExpression(
719 tempLine, ACCESSOR_NO_INDEX, NULL, FALSE); 719 tempLine, ACCESSOR_NO_INDEX, NULL, FALSE);
720 e = new CXFA_FMDotAccessorExpression(line, e, TOKdotscream, tempStr, 720 e = new CXFA_FMDotAccessorExpression(line, e, TOKdotscream, tempStr,
721 s); 721 s);
722 continue; 722 continue;
723 } 723 }
724 } else { 724 } else {
725 CFX_WideString ws_TempString = m_pToken->m_wstring; 725 CFX_WideString ws_TempString(m_pToken->m_wstring);
726 Error(m_pToken->m_uLinenum, kFMErrExpectedIdentifier, 726 Error(m_pToken->m_uLinenum, kFMErrExpectedIdentifier,
727 ws_TempString.c_str()); 727 ws_TempString.c_str());
728 return e; 728 return e;
729 } 729 }
730 break; 730 break;
731 case TOKdotstar: { 731 case TOKdotstar: {
732 CXFA_FMSimpleExpression* s = 732 CXFA_FMSimpleExpression* s =
733 new CXFA_FMIndexExpression(line, ACCESSOR_NO_INDEX, NULL, FALSE); 733 new CXFA_FMIndexExpression(line, ACCESSOR_NO_INDEX, NULL, FALSE);
734 e = new CXFA_FMDotAccessorExpression(line, e, TOKdotstar, 734 e = new CXFA_FMDotAccessorExpression(line, e, TOKdotstar,
735 FX_WSTRC(L"*"), s); 735 FX_WSTRC(L"*"), s);
(...skipping 10 matching lines...) Expand all
746 std::unique_ptr<CXFA_FMSimpleExpression> pExp; 746 std::unique_ptr<CXFA_FMSimpleExpression> pExp;
747 uint32_t line = m_pToken->m_uLinenum; 747 uint32_t line = m_pToken->m_uLinenum;
748 NextToken(); 748 NextToken();
749 std::unique_ptr<CXFA_FMSimpleExpression> s; 749 std::unique_ptr<CXFA_FMSimpleExpression> s;
750 XFA_FM_AccessorIndex accessorIndex = ACCESSOR_NO_RELATIVEINDEX; 750 XFA_FM_AccessorIndex accessorIndex = ACCESSOR_NO_RELATIVEINDEX;
751 if (m_pToken->m_type == TOKmul) { 751 if (m_pToken->m_type == TOKmul) {
752 pExp.reset( 752 pExp.reset(
753 new CXFA_FMIndexExpression(line, accessorIndex, s.release(), TRUE)); 753 new CXFA_FMIndexExpression(line, accessorIndex, s.release(), TRUE));
754 NextToken(); 754 NextToken();
755 if (m_pToken->m_type != TOKrbracket) { 755 if (m_pToken->m_type != TOKrbracket) {
756 CFX_WideString ws_TempString = m_pToken->m_wstring; 756 CFX_WideString ws_TempString(m_pToken->m_wstring);
757 Error(m_pToken->m_uLinenum, kFMErrExpectedToken, 757 Error(m_pToken->m_uLinenum, kFMErrExpectedToken,
758 XFA_FM_KeywordToString(TOKrparen), ws_TempString.c_str()); 758 XFA_FM_KeywordToString(TOKrparen), ws_TempString.c_str());
759 pExp.reset(); 759 pExp.reset();
760 } 760 }
761 return pExp.release(); 761 return pExp.release();
762 } 762 }
763 if (m_pToken->m_type == TOKplus) { 763 if (m_pToken->m_type == TOKplus) {
764 accessorIndex = ACCESSOR_POSITIVE_INDEX; 764 accessorIndex = ACCESSOR_POSITIVE_INDEX;
765 NextToken(); 765 NextToken();
766 } else if (m_pToken->m_type == TOKminus) { 766 } else if (m_pToken->m_type == TOKminus) {
767 accessorIndex = ACCESSOR_NEGATIVE_INDEX; 767 accessorIndex = ACCESSOR_NEGATIVE_INDEX;
768 NextToken(); 768 NextToken();
769 } 769 }
770 s.reset(ParseSimpleExpression()); 770 s.reset(ParseSimpleExpression());
771 if (m_pToken->m_type != TOKrbracket) { 771 if (m_pToken->m_type != TOKrbracket) {
772 CFX_WideString ws_TempString = m_pToken->m_wstring; 772 CFX_WideString ws_TempString(m_pToken->m_wstring);
773 Error(m_pToken->m_uLinenum, kFMErrExpectedToken, 773 Error(m_pToken->m_uLinenum, kFMErrExpectedToken,
774 XFA_FM_KeywordToString(TOKrparen), ws_TempString.c_str()); 774 XFA_FM_KeywordToString(TOKrparen), ws_TempString.c_str());
775 } else { 775 } else {
776 pExp.reset( 776 pExp.reset(
777 new CXFA_FMIndexExpression(line, accessorIndex, s.release(), FALSE)); 777 new CXFA_FMIndexExpression(line, accessorIndex, s.release(), FALSE));
778 } 778 }
779 return pExp.release(); 779 return pExp.release();
780 } 780 }
781 781
782 CXFA_FMSimpleExpression* CXFA_FMParse::ParseParenExpression() { 782 CXFA_FMSimpleExpression* CXFA_FMParse::ParseParenExpression() {
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 break; 884 break;
885 case TOKelseif: 885 case TOKelseif:
886 pElseExpression.reset(ParseIfExpression()); 886 pElseExpression.reset(ParseIfExpression());
887 break; 887 break;
888 case TOKelse: 888 case TOKelse:
889 NextToken(); 889 NextToken();
890 pElseExpression.reset(ParseBlockExpression()); 890 pElseExpression.reset(ParseBlockExpression());
891 Check(TOKendif); 891 Check(TOKendif);
892 break; 892 break;
893 default: 893 default:
894 CFX_WideString ws_TempString = m_pToken->m_wstring; 894 CFX_WideString ws_TempString(m_pToken->m_wstring);
895 Error(m_pToken->m_uLinenum, kFMErrExpectedEndIf, ws_TempString.c_str()); 895 Error(m_pToken->m_uLinenum, kFMErrExpectedEndIf, ws_TempString.c_str());
896 NextToken(); 896 NextToken();
897 break; 897 break;
898 } 898 }
899 std::unique_ptr<CXFA_FMIfExpression> pExp; 899 std::unique_ptr<CXFA_FMIfExpression> pExp;
900 if (m_pErrorInfo->message.IsEmpty()) { 900 if (m_pErrorInfo->message.IsEmpty()) {
901 pExp.reset(new CXFA_FMIfExpression(line, pExpression.release(), 901 pExp.reset(new CXFA_FMIfExpression(line, pExpression.release(),
902 pIfExpression.release(), 902 pIfExpression.release(),
903 pElseExpression.release())); 903 pElseExpression.release()));
904 } 904 }
(...skipping 15 matching lines...) Expand all
920 return e.release(); 920 return e.release();
921 } 921 }
922 922
923 CXFA_FMSimpleExpression* CXFA_FMParse::ParseSubassignmentInForExpression() { 923 CXFA_FMSimpleExpression* CXFA_FMParse::ParseSubassignmentInForExpression() {
924 std::unique_ptr<CXFA_FMSimpleExpression> e; 924 std::unique_ptr<CXFA_FMSimpleExpression> e;
925 switch (m_pToken->m_type) { 925 switch (m_pToken->m_type) {
926 case TOKidentifier: 926 case TOKidentifier:
927 e.reset(ParseSimpleExpression()); 927 e.reset(ParseSimpleExpression());
928 break; 928 break;
929 default: 929 default:
930 CFX_WideString ws_TempString = m_pToken->m_wstring; 930 CFX_WideString ws_TempString(m_pToken->m_wstring);
931 Error(m_pToken->m_uLinenum, kFMErrUnexpectedExpression, 931 Error(m_pToken->m_uLinenum, kFMErrUnexpectedExpression,
932 ws_TempString.c_str()); 932 ws_TempString.c_str());
933 NextToken(); 933 NextToken();
934 break; 934 break;
935 } 935 }
936 return e.release(); 936 return e.release();
937 } 937 }
938 938
939 CXFA_FMExpression* CXFA_FMParse::ParseForExpression() { 939 CXFA_FMExpression* CXFA_FMParse::ParseForExpression() {
940 CFX_WideStringC wsVariant; 940 CFX_WideStringC wsVariant;
941 uint32_t line = m_pToken->m_uLinenum; 941 uint32_t line = m_pToken->m_uLinenum;
942 NextToken(); 942 NextToken();
943 if (m_pToken->m_type != TOKidentifier) { 943 if (m_pToken->m_type != TOKidentifier) {
944 CFX_WideString ws_TempString = m_pToken->m_wstring; 944 CFX_WideString ws_TempString(m_pToken->m_wstring);
945 Error(m_pToken->m_uLinenum, kFMErrExpectedToken, 945 Error(m_pToken->m_uLinenum, kFMErrExpectedToken,
946 XFA_FM_KeywordToString(m_pToken->m_type), ws_TempString.c_str()); 946 XFA_FM_KeywordToString(m_pToken->m_type), ws_TempString.c_str());
947 } 947 }
948 wsVariant = m_pToken->m_wstring; 948 wsVariant = m_pToken->m_wstring;
949 NextToken(); 949 NextToken();
950 std::unique_ptr<CXFA_FMSimpleExpression> pAssignment; 950 std::unique_ptr<CXFA_FMSimpleExpression> pAssignment;
951 if (m_pToken->m_type == TOKassign) { 951 if (m_pToken->m_type == TOKassign) {
952 NextToken(); 952 NextToken();
953 pAssignment.reset(ParseSimpleExpression()); 953 pAssignment.reset(ParseSimpleExpression());
954 } else { 954 } else {
955 CFX_WideString ws_TempString = m_pToken->m_wstring; 955 CFX_WideString ws_TempString(m_pToken->m_wstring);
956 Error(m_pToken->m_uLinenum, kFMErrExpectedToken, 956 Error(m_pToken->m_uLinenum, kFMErrExpectedToken,
957 XFA_FM_KeywordToString(m_pToken->m_type), ws_TempString.c_str()); 957 XFA_FM_KeywordToString(m_pToken->m_type), ws_TempString.c_str());
958 } 958 }
959 int32_t iDirection = 0; 959 int32_t iDirection = 0;
960 if (m_pToken->m_type == TOKupto) { 960 if (m_pToken->m_type == TOKupto) {
961 iDirection = 1; 961 iDirection = 1;
962 } else if (m_pToken->m_type == TOKdownto) { 962 } else if (m_pToken->m_type == TOKdownto) {
963 iDirection = -1; 963 iDirection = -1;
964 } else { 964 } else {
965 CFX_WideString ws_TempString = m_pToken->m_wstring; 965 CFX_WideString ws_TempString(m_pToken->m_wstring);
966 Error(m_pToken->m_uLinenum, kFMErrExpectedToken, L"upto or downto", 966 Error(m_pToken->m_uLinenum, kFMErrExpectedToken, L"upto or downto",
967 ws_TempString.c_str()); 967 ws_TempString.c_str());
968 } 968 }
969 NextToken(); 969 NextToken();
970 std::unique_ptr<CXFA_FMSimpleExpression> pAccessor(ParseSimpleExpression()); 970 std::unique_ptr<CXFA_FMSimpleExpression> pAccessor(ParseSimpleExpression());
971 std::unique_ptr<CXFA_FMSimpleExpression> pStep; 971 std::unique_ptr<CXFA_FMSimpleExpression> pStep;
972 if (m_pToken->m_type == TOKstep) { 972 if (m_pToken->m_type == TOKstep) {
973 NextToken(); 973 NextToken();
974 pStep.reset(ParseSimpleExpression()); 974 pStep.reset(ParseSimpleExpression());
975 } 975 }
(...skipping 10 matching lines...) Expand all
986 } 986 }
987 987
988 CXFA_FMExpression* CXFA_FMParse::ParseForeachExpression() { 988 CXFA_FMExpression* CXFA_FMParse::ParseForeachExpression() {
989 std::unique_ptr<CXFA_FMExpression> e; 989 std::unique_ptr<CXFA_FMExpression> e;
990 CFX_WideStringC wsIdentifier; 990 CFX_WideStringC wsIdentifier;
991 std::unique_ptr<CFX_ArrayTemplate<CXFA_FMSimpleExpression*>> pAccessors; 991 std::unique_ptr<CFX_ArrayTemplate<CXFA_FMSimpleExpression*>> pAccessors;
992 std::unique_ptr<CXFA_FMExpression> pList; 992 std::unique_ptr<CXFA_FMExpression> pList;
993 uint32_t line = m_pToken->m_uLinenum; 993 uint32_t line = m_pToken->m_uLinenum;
994 NextToken(); 994 NextToken();
995 if (m_pToken->m_type != TOKidentifier) { 995 if (m_pToken->m_type != TOKidentifier) {
996 CFX_WideString ws_TempString = m_pToken->m_wstring; 996 CFX_WideString ws_TempString(m_pToken->m_wstring);
997 Error(m_pToken->m_uLinenum, kFMErrExpectedToken, 997 Error(m_pToken->m_uLinenum, kFMErrExpectedToken,
998 XFA_FM_KeywordToString(m_pToken->m_type), ws_TempString.c_str()); 998 XFA_FM_KeywordToString(m_pToken->m_type), ws_TempString.c_str());
999 } 999 }
1000 wsIdentifier = m_pToken->m_wstring; 1000 wsIdentifier = m_pToken->m_wstring;
1001 NextToken(); 1001 NextToken();
1002 Check(TOKin); 1002 Check(TOKin);
1003 Check(TOKlparen); 1003 Check(TOKlparen);
1004 if (m_pToken->m_type == TOKrparen) { 1004 if (m_pToken->m_type == TOKrparen) {
1005 CFX_WideString ws_TempString = m_pToken->m_wstring; 1005 CFX_WideString ws_TempString(m_pToken->m_wstring);
1006 Error(m_pToken->m_uLinenum, kFMErrUnexpectedExpression, 1006 Error(m_pToken->m_uLinenum, kFMErrUnexpectedExpression,
1007 ws_TempString.c_str()); 1007 ws_TempString.c_str());
1008 NextToken(); 1008 NextToken();
1009 } else { 1009 } else {
1010 pAccessors.reset(new CFX_ArrayTemplate<CXFA_FMSimpleExpression*>()); 1010 pAccessors.reset(new CFX_ArrayTemplate<CXFA_FMSimpleExpression*>());
1011 while (m_pToken->m_type != TOKrparen) { 1011 while (m_pToken->m_type != TOKrparen) {
1012 CXFA_FMSimpleExpression* s = ParseSimpleExpression(); 1012 CXFA_FMSimpleExpression* s = ParseSimpleExpression();
1013 if (s) { 1013 if (s) {
1014 pAccessors->Add(s); 1014 pAccessors->Add(s);
1015 } 1015 }
(...skipping 26 matching lines...) Expand all
1042 NextToken(); 1042 NextToken();
1043 e.reset(ParseBlockExpression()); 1043 e.reset(ParseBlockExpression());
1044 Check(TOKend); 1044 Check(TOKend);
1045 if (m_pErrorInfo->message.IsEmpty()) { 1045 if (m_pErrorInfo->message.IsEmpty()) {
1046 e.reset(new CXFA_FMDoExpression(line, e.release())); 1046 e.reset(new CXFA_FMDoExpression(line, e.release()));
1047 } else { 1047 } else {
1048 e.reset(); 1048 e.reset();
1049 } 1049 }
1050 return e.release(); 1050 return e.release();
1051 } 1051 }
OLDNEW
« no previous file with comments | « xfa/fxfa/fm2js/xfa_fm2jscontext.cpp ('k') | xfa/fxfa/fm2js/xfa_simpleexpression.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698