Changeset 17372 in webkit for trunk/JavaScriptCore/kjs/lexer.cpp
- Timestamp:
- Oct 27, 2006, 9:48:28 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/lexer.cpp
r17354 r17372 3 3 * This file is part of the KDE libraries 4 4 * Copyright (C) 1999-2000 Harri Porten ([email protected]) 5 * Copyright (C) 2006 Apple Computer, Inc. 5 6 * 6 7 * This library is free software; you can redistribute it and/or … … 31 32 #include <wtf/unicode/Unicode.h> 32 33 33 static bool isDecimalDigit( unsigned short c);34 static bool isDecimalDigit(int); 34 35 35 36 // we can't specify the namespace in yacc's C output, so do it here … … 208 209 } else if (current == '"' || current == '\'') { 209 210 state = InString; 210 stringType = current;211 stringType = static_cast<unsigned short>(current); 211 212 } else if (isIdentStart(current)) { 212 213 record16(current); … … 282 283 state = InString; 283 284 } else { 284 record16(singleEscape( current));285 record16(singleEscape(static_cast<unsigned short>(current))); 285 286 state = InString; 286 287 } … … 581 582 } 582 583 583 bool Lexer::isIdentStart( unsigned short c)584 bool Lexer::isIdentStart(int c) 584 585 { 585 586 return (WTF::Unicode::category(c) & (WTF::Unicode::Letter_Uppercase … … 591 592 } 592 593 593 bool Lexer::isIdentPart( unsigned short c)594 bool Lexer::isIdentPart(int c) 594 595 { 595 596 return (WTF::Unicode::category(c) & (WTF::Unicode::Letter_Uppercase … … 605 606 } 606 607 607 static bool isDecimalDigit( unsigned short c)608 static bool isDecimalDigit(int c) 608 609 { 609 610 return (c >= '0' && c <= '9'); 610 611 } 611 612 612 bool Lexer::isHexDigit( unsigned short c)613 bool Lexer::isHexDigit(int c) 613 614 { 614 615 return (c >= '0' && c <= '9' || … … 617 618 } 618 619 619 bool Lexer::isOctalDigit( unsigned short c) const620 bool Lexer::isOctalDigit(int c) 620 621 { 621 622 return (c >= '0' && c <= '7'); 622 623 } 623 624 624 int Lexer::matchPunctuator(unsigned short c1, unsigned short c2, 625 unsigned short c3, unsigned short c4) 625 int Lexer::matchPunctuator(int c1, int c2, int c3, int c4) 626 626 { 627 627 if (c1 == '>' && c2 == '>' && c3 == '>' && c4 == '=') { … … 737 737 } 738 738 739 unsigned short Lexer::singleEscape(unsigned short c) const739 unsigned short Lexer::singleEscape(unsigned short c) 740 740 { 741 741 switch(c) { … … 763 763 } 764 764 765 unsigned short Lexer::convertOctal(unsigned short c1, unsigned short c2, 766 unsigned short c3) const 767 { 768 return ((c1 - '0') * 64 + (c2 - '0') * 8 + c3 - '0'); 769 } 770 771 unsigned char Lexer::convertHex(unsigned short c) 765 unsigned short Lexer::convertOctal(int c1, int c2, int c3) 766 { 767 return static_cast<unsigned short>((c1 - '0') * 64 + (c2 - '0') * 8 + c3 - '0'); 768 } 769 770 unsigned char Lexer::convertHex(int c) 772 771 { 773 772 if (c >= '0' && c <= '9') 774 return (c - '0'); 775 else if (c >= 'a' && c <= 'f') 776 return (c - 'a' + 10); 777 else 778 return (c - 'A' + 10); 779 } 780 781 unsigned char Lexer::convertHex(unsigned short c1, unsigned short c2) 773 return static_cast<unsigned char>(c - '0'); 774 if (c >= 'a' && c <= 'f') 775 return static_cast<unsigned char>(c - 'a' + 10); 776 return static_cast<unsigned char>(c - 'A' + 10); 777 } 778 779 unsigned char Lexer::convertHex(int c1, int c2) 782 780 { 783 781 return ((convertHex(c1) << 4) + convertHex(c2)); 784 782 } 785 783 786 KJS::UChar Lexer::convertUnicode(unsigned short c1, unsigned short c2, 787 unsigned short c3, unsigned short c4) 784 KJS::UChar Lexer::convertUnicode(int c1, int c2, int c3, int c4) 788 785 { 789 786 return KJS::UChar((convertHex(c1) << 4) + convertHex(c2), … … 791 788 } 792 789 793 void Lexer::record8(unsigned short c) 794 { 795 assert(c <= 0xff); 790 void Lexer::record8(int c) 791 { 792 ASSERT(c >= 0); 793 ASSERT(c <= 0xff); 796 794 797 795 // enlarge buffer if full
Note:
See TracChangeset
for help on using the changeset viewer.