| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 | 233 |
| 234 int code_; | 234 int code_; |
| 235 }; | 235 }; |
| 236 | 236 |
| 237 class Statement { | 237 class Statement { |
| 238 public: | 238 public: |
| 239 static Statement Default() { | 239 static Statement Default() { |
| 240 return Statement(kUnknownStatement); | 240 return Statement(kUnknownStatement); |
| 241 } | 241 } |
| 242 | 242 |
| 243 static Statement FunctionDeclaration() { |
| 244 return Statement(kFunctionDeclaration); |
| 245 } |
| 246 |
| 243 // Creates expression statement from expression. | 247 // Creates expression statement from expression. |
| 244 // Preserves being an unparenthesized string literal, possibly | 248 // Preserves being an unparenthesized string literal, possibly |
| 245 // "use strict". | 249 // "use strict". |
| 246 static Statement ExpressionStatement(Expression expression) { | 250 static Statement ExpressionStatement(Expression expression) { |
| 247 if (!expression.IsParenthesized()) { | 251 if (!expression.IsParenthesized()) { |
| 248 if (expression.IsUseStrictLiteral()) { | 252 if (expression.IsUseStrictLiteral()) { |
| 249 return Statement(kUseStrictExpressionStatement); | 253 return Statement(kUseStrictExpressionStatement); |
| 250 } | 254 } |
| 251 if (expression.IsStringLiteral()) { | 255 if (expression.IsStringLiteral()) { |
| 252 return Statement(kStringLiteralExpressionStatement); | 256 return Statement(kStringLiteralExpressionStatement); |
| 253 } | 257 } |
| 254 } | 258 } |
| 255 return Default(); | 259 return Default(); |
| 256 } | 260 } |
| 257 | 261 |
| 258 bool IsStringLiteral() { | 262 bool IsStringLiteral() { |
| 259 return code_ != kUnknownStatement; | 263 return code_ != kUnknownStatement; |
| 260 } | 264 } |
| 261 | 265 |
| 262 bool IsUseStrictLiteral() { | 266 bool IsUseStrictLiteral() { |
| 263 return code_ == kUseStrictExpressionStatement; | 267 return code_ == kUseStrictExpressionStatement; |
| 264 } | 268 } |
| 265 | 269 |
| 270 bool IsFunctionDeclaration() { |
| 271 return code_ == kFunctionDeclaration; |
| 272 } |
| 273 |
| 266 private: | 274 private: |
| 267 enum Type { | 275 enum Type { |
| 268 kUnknownStatement, | 276 kUnknownStatement, |
| 269 kStringLiteralExpressionStatement, | 277 kStringLiteralExpressionStatement, |
| 270 kUseStrictExpressionStatement | 278 kUseStrictExpressionStatement, |
| 279 kFunctionDeclaration |
| 271 }; | 280 }; |
| 272 | 281 |
| 273 explicit Statement(Type code) : code_(code) {} | 282 explicit Statement(Type code) : code_(code) {} |
| 274 Type code_; | 283 Type code_; |
| 275 }; | 284 }; |
| 276 | 285 |
| 277 enum SourceElements { | 286 enum SourceElements { |
| 278 kUnknownSourceElements | 287 kUnknownSourceElements |
| 279 }; | 288 }; |
| 280 | 289 |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 uintptr_t stack_limit_; | 484 uintptr_t stack_limit_; |
| 476 i::Scanner::Location strict_mode_violation_location_; | 485 i::Scanner::Location strict_mode_violation_location_; |
| 477 const char* strict_mode_violation_type_; | 486 const char* strict_mode_violation_type_; |
| 478 bool stack_overflow_; | 487 bool stack_overflow_; |
| 479 bool allow_lazy_; | 488 bool allow_lazy_; |
| 480 bool parenthesized_function_; | 489 bool parenthesized_function_; |
| 481 }; | 490 }; |
| 482 } } // v8::preparser | 491 } } // v8::preparser |
| 483 | 492 |
| 484 #endif // V8_PREPARSER_H | 493 #endif // V8_PREPARSER_H |
| OLD | NEW |