OLD | NEW |
---|---|
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
491 min_match_ += node->min_match(); | 491 min_match_ += node->min_match(); |
492 int node_max_match = node->max_match(); | 492 int node_max_match = node->max_match(); |
493 if (kInfinity - max_match_ < node_max_match) { | 493 if (kInfinity - max_match_ < node_max_match) { |
494 max_match_ = kInfinity; | 494 max_match_ = kInfinity; |
495 } else { | 495 } else { |
496 max_match_ += node->max_match(); | 496 max_match_ += node->max_match(); |
497 } | 497 } |
498 } | 498 } |
499 } | 499 } |
500 | 500 |
501 // IsPrimitive implementation. IsPrimitive is true if the value of an | |
502 // expression is known at compile-time to be any JS type other than Object | |
503 // (e.g, it is Undefined, Null, Boolean, String, or Number). | |
504 | |
505 // The following expression types are never primitive because they express | |
506 // Object values. | |
507 bool FunctionLiteral::IsPrimitive() { return false; } | |
508 bool FunctionBoilerplateLiteral::IsPrimitive() { return false; } | |
509 bool RegExpLiteral::IsPrimitive() { return false; } | |
510 bool ObjectLiteral::IsPrimitive() { return false; } | |
511 bool ArrayLiteral::IsPrimitive() { return false; } | |
512 bool CatchExtensionObject::IsPrimitive() { return false; } | |
513 bool CallNew::IsPrimitive() { return false; } | |
514 bool ThisFunction::IsPrimitive() { return false; } | |
515 | |
516 | |
517 // The following expression types are not always primitive because we do not | |
518 // have enough information to conclude that they are. | |
519 bool VariableProxy::IsPrimitive() { return false; } | |
520 bool Property::IsPrimitive() { return false; } | |
521 bool Call::IsPrimitive() { return false; } | |
522 bool CallRuntime::IsPrimitive() { return false; } | |
523 | |
524 | |
525 // The value of a conditional is the value of one of the alternatives. It's | |
526 // always primitive if both alternatives are always primitive. | |
527 bool Conditional::IsPrimitive() { | |
528 return then_expression()->IsPrimitive() && else_expression()->IsPrimitive(); | |
529 } | |
530 | |
531 | |
532 // A literal is primitive when it is not a JSObject. | |
533 bool Literal::IsPrimitive() { return !handle()->IsJSObject(); } | |
534 | |
535 | |
536 // The value of an assignment is the value of its right-hand side. | |
537 bool Assignment::IsPrimitive() { | |
538 switch (op()) { | |
539 case Token::INIT_VAR: | |
540 case Token::INIT_CONST: | |
541 case Token::ASSIGN: | |
542 return value()->IsPrimitive(); | |
543 | |
544 default: | |
545 // {|=, ^=, &=, <<=, >>=, >>>=, +=, -=, *=, /=, %=} | |
546 // Arithmetic operations are always primitive. They express Numbers | |
547 // with the exception of +, which expresses a Number or a String. | |
548 return true; | |
549 } | |
550 } | |
551 | |
501 | 552 |
553 // Throw does not express a value, so it's trivially always primitive. | |
554 bool Throw::IsPrimitive() { return true; } | |
555 | |
556 | |
557 // Unary operations always express primitive values. delete and ! express | |
558 // Booleans, void Undefined, typeof String (but host objects are | |
Mads Ager (chromium)
2010/03/12 12:19:29
Let's remove the comment about host objects being
| |
559 // implementation-dependent), +, -, and ~ Numbers. | |
560 bool UnaryOperation::IsPrimitive() { return true; } | |
561 | |
562 | |
563 // Count operations (pre- and post-fix increment and decrement) always | |
564 // express primitive values (Numbers). See ECMA-262-3, 11.3.1, 11.3.2, | |
565 // 11.4.4, ane 11.4.5. | |
566 bool CountOperation::IsPrimitive() { return true; } | |
567 | |
568 | |
569 // Binary operations depend on the operator. | |
570 bool BinaryOperation::IsPrimitive() { | |
571 switch (op()) { | |
572 case Token::COMMA: | |
573 // Value is the value of the right subexpression. | |
574 return right()->IsPrimitive(); | |
575 | |
576 case Token::OR: | |
577 case Token::AND: | |
578 // Value is the value one of the subexpressions. | |
579 return left()->IsPrimitive() && right()->IsPrimitive(); | |
580 | |
581 default: | |
582 // {|, ^, &, <<, >>, >>>, +, -, *, /, %} | |
583 // Arithmetic operations are always primitive. They express Numbers | |
584 // with the exception of +, which expresses a Number or a String. | |
585 return true; | |
586 } | |
587 } | |
588 | |
589 | |
590 // Compare operations always express Boolean values. | |
591 bool CompareOperation::IsPrimitive() { return true; } | |
592 | |
593 | |
502 } } // namespace v8::internal | 594 } } // namespace v8::internal |
OLD | NEW |