OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project 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 // Features shared by parsing and pre-parsing scanners. | 5 // Features shared by parsing and pre-parsing scanners. |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "src/v8.h" | 9 #include "src/v8.h" |
10 | 10 |
(...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
895 Advance(); | 895 Advance(); |
896 uc32 result = ScanHexNumber(4); | 896 uc32 result = ScanHexNumber(4); |
897 if (result < 0) PushBack('u'); | 897 if (result < 0) PushBack('u'); |
898 return result; | 898 return result; |
899 } | 899 } |
900 | 900 |
901 | 901 |
902 // ---------------------------------------------------------------------------- | 902 // ---------------------------------------------------------------------------- |
903 // Keyword Matcher | 903 // Keyword Matcher |
904 | 904 |
905 #define KEYWORDS(KEYWORD_GROUP, KEYWORD) \ | 905 #define KEYWORDS(KEYWORD_GROUP, KEYWORD) \ |
906 KEYWORD_GROUP('b') \ | 906 KEYWORD_GROUP('b') \ |
907 KEYWORD("break", Token::BREAK) \ | 907 KEYWORD("break", Token::BREAK) \ |
908 KEYWORD_GROUP('c') \ | 908 KEYWORD_GROUP('c') \ |
909 KEYWORD("case", Token::CASE) \ | 909 KEYWORD("case", Token::CASE) \ |
910 KEYWORD("catch", Token::CATCH) \ | 910 KEYWORD("catch", Token::CATCH) \ |
911 KEYWORD("class", Token::FUTURE_RESERVED_WORD) \ | 911 KEYWORD("class", \ |
912 KEYWORD("const", Token::CONST) \ | 912 harmony_classes ? Token::CLASS : Token::FUTURE_RESERVED_WORD) \ |
913 KEYWORD("continue", Token::CONTINUE) \ | 913 KEYWORD("const", Token::CONST) \ |
914 KEYWORD_GROUP('d') \ | 914 KEYWORD("continue", Token::CONTINUE) \ |
915 KEYWORD("debugger", Token::DEBUGGER) \ | 915 KEYWORD_GROUP('d') \ |
916 KEYWORD("default", Token::DEFAULT) \ | 916 KEYWORD("debugger", Token::DEBUGGER) \ |
917 KEYWORD("delete", Token::DELETE) \ | 917 KEYWORD("default", Token::DEFAULT) \ |
918 KEYWORD("do", Token::DO) \ | 918 KEYWORD("delete", Token::DELETE) \ |
919 KEYWORD_GROUP('e') \ | 919 KEYWORD("do", Token::DO) \ |
920 KEYWORD("else", Token::ELSE) \ | 920 KEYWORD_GROUP('e') \ |
921 KEYWORD("enum", Token::FUTURE_RESERVED_WORD) \ | 921 KEYWORD("else", Token::ELSE) \ |
922 KEYWORD("export", \ | 922 KEYWORD("enum", Token::FUTURE_RESERVED_WORD) \ |
923 harmony_modules ? Token::EXPORT : Token::FUTURE_RESERVED_WORD) \ | 923 KEYWORD("export", \ |
924 KEYWORD("extends", Token::FUTURE_RESERVED_WORD) \ | 924 harmony_modules ? Token::EXPORT : Token::FUTURE_RESERVED_WORD) \ |
925 KEYWORD_GROUP('f') \ | 925 KEYWORD("extends", \ |
926 KEYWORD("false", Token::FALSE_LITERAL) \ | 926 harmony_classes ? Token::EXTENDS : Token::FUTURE_RESERVED_WORD) \ |
927 KEYWORD("finally", Token::FINALLY) \ | 927 KEYWORD_GROUP('f') \ |
928 KEYWORD("for", Token::FOR) \ | 928 KEYWORD("false", Token::FALSE_LITERAL) \ |
929 KEYWORD("function", Token::FUNCTION) \ | 929 KEYWORD("finally", Token::FINALLY) \ |
930 KEYWORD_GROUP('i') \ | 930 KEYWORD("for", Token::FOR) \ |
931 KEYWORD("if", Token::IF) \ | 931 KEYWORD("function", Token::FUNCTION) \ |
932 KEYWORD("implements", Token::FUTURE_STRICT_RESERVED_WORD) \ | 932 KEYWORD_GROUP('i') \ |
933 KEYWORD("import", \ | 933 KEYWORD("if", Token::IF) \ |
934 harmony_modules ? Token::IMPORT : Token::FUTURE_RESERVED_WORD) \ | 934 KEYWORD("implements", Token::FUTURE_STRICT_RESERVED_WORD) \ |
935 KEYWORD("in", Token::IN) \ | 935 KEYWORD("import", \ |
936 KEYWORD("instanceof", Token::INSTANCEOF) \ | 936 harmony_modules ? Token::IMPORT : Token::FUTURE_RESERVED_WORD) \ |
937 KEYWORD("interface", Token::FUTURE_STRICT_RESERVED_WORD) \ | 937 KEYWORD("in", Token::IN) \ |
938 KEYWORD_GROUP('l') \ | 938 KEYWORD("instanceof", Token::INSTANCEOF) \ |
939 KEYWORD("let", \ | 939 KEYWORD("interface", Token::FUTURE_STRICT_RESERVED_WORD) \ |
940 harmony_scoping ? Token::LET : Token::FUTURE_STRICT_RESERVED_WORD) \ | 940 KEYWORD_GROUP('l') \ |
941 KEYWORD_GROUP('n') \ | 941 KEYWORD("let", \ |
942 KEYWORD("new", Token::NEW) \ | 942 harmony_scoping ? Token::LET : Token::FUTURE_STRICT_RESERVED_WORD) \ |
943 KEYWORD("null", Token::NULL_LITERAL) \ | 943 KEYWORD_GROUP('n') \ |
944 KEYWORD_GROUP('p') \ | 944 KEYWORD("new", Token::NEW) \ |
945 KEYWORD("package", Token::FUTURE_STRICT_RESERVED_WORD) \ | 945 KEYWORD("null", Token::NULL_LITERAL) \ |
946 KEYWORD("private", Token::FUTURE_STRICT_RESERVED_WORD) \ | 946 KEYWORD_GROUP('p') \ |
947 KEYWORD("protected", Token::FUTURE_STRICT_RESERVED_WORD) \ | 947 KEYWORD("package", Token::FUTURE_STRICT_RESERVED_WORD) \ |
948 KEYWORD("public", Token::FUTURE_STRICT_RESERVED_WORD) \ | 948 KEYWORD("private", Token::FUTURE_STRICT_RESERVED_WORD) \ |
949 KEYWORD_GROUP('r') \ | 949 KEYWORD("protected", Token::FUTURE_STRICT_RESERVED_WORD) \ |
950 KEYWORD("return", Token::RETURN) \ | 950 KEYWORD("public", Token::FUTURE_STRICT_RESERVED_WORD) \ |
951 KEYWORD_GROUP('s') \ | 951 KEYWORD_GROUP('r') \ |
952 KEYWORD("static", Token::FUTURE_STRICT_RESERVED_WORD) \ | 952 KEYWORD("return", Token::RETURN) \ |
953 KEYWORD("super", \ | 953 KEYWORD_GROUP('s') \ |
954 harmony_classes ? Token::SUPER : Token::FUTURE_RESERVED_WORD) \ | 954 KEYWORD("static", harmony_classes ? Token::STATIC \ |
955 KEYWORD("switch", Token::SWITCH) \ | 955 : Token::FUTURE_STRICT_RESERVED_WORD) \ |
956 KEYWORD_GROUP('t') \ | 956 KEYWORD("super", \ |
957 KEYWORD("this", Token::THIS) \ | 957 harmony_classes ? Token::SUPER : Token::FUTURE_RESERVED_WORD) \ |
958 KEYWORD("throw", Token::THROW) \ | 958 KEYWORD("switch", Token::SWITCH) \ |
959 KEYWORD("true", Token::TRUE_LITERAL) \ | 959 KEYWORD_GROUP('t') \ |
960 KEYWORD("try", Token::TRY) \ | 960 KEYWORD("this", Token::THIS) \ |
961 KEYWORD("typeof", Token::TYPEOF) \ | 961 KEYWORD("throw", Token::THROW) \ |
962 KEYWORD_GROUP('v') \ | 962 KEYWORD("true", Token::TRUE_LITERAL) \ |
963 KEYWORD("var", Token::VAR) \ | 963 KEYWORD("try", Token::TRY) \ |
964 KEYWORD("void", Token::VOID) \ | 964 KEYWORD("typeof", Token::TYPEOF) \ |
965 KEYWORD_GROUP('w') \ | 965 KEYWORD_GROUP('v') \ |
966 KEYWORD("while", Token::WHILE) \ | 966 KEYWORD("var", Token::VAR) \ |
967 KEYWORD("with", Token::WITH) \ | 967 KEYWORD("void", Token::VOID) \ |
968 KEYWORD_GROUP('y') \ | 968 KEYWORD_GROUP('w') \ |
| 969 KEYWORD("while", Token::WHILE) \ |
| 970 KEYWORD("with", Token::WITH) \ |
| 971 KEYWORD_GROUP('y') \ |
969 KEYWORD("yield", Token::YIELD) | 972 KEYWORD("yield", Token::YIELD) |
970 | 973 |
971 | 974 |
972 static Token::Value KeywordOrIdentifierToken(const uint8_t* input, | 975 static Token::Value KeywordOrIdentifierToken(const uint8_t* input, |
973 int input_length, | 976 int input_length, |
974 bool harmony_scoping, | 977 bool harmony_scoping, |
975 bool harmony_modules, | 978 bool harmony_modules, |
976 bool harmony_classes) { | 979 bool harmony_classes) { |
977 DCHECK(input_length >= 1); | 980 DCHECK(input_length >= 1); |
978 const int kMinLength = 2; | 981 const int kMinLength = 2; |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1360 } | 1363 } |
1361 backing_store_.Add(static_cast<uint8_t>((one_byte_length >> 7) | 0x80u)); | 1364 backing_store_.Add(static_cast<uint8_t>((one_byte_length >> 7) | 0x80u)); |
1362 } | 1365 } |
1363 backing_store_.Add(static_cast<uint8_t>(one_byte_length & 0x7f)); | 1366 backing_store_.Add(static_cast<uint8_t>(one_byte_length & 0x7f)); |
1364 | 1367 |
1365 backing_store_.AddBlock(bytes); | 1368 backing_store_.AddBlock(bytes); |
1366 return backing_store_.EndSequence().start(); | 1369 return backing_store_.EndSequence().start(); |
1367 } | 1370 } |
1368 | 1371 |
1369 } } // namespace v8::internal | 1372 } } // namespace v8::internal |
OLD | NEW |