| Index: src/ast.h
|
| diff --git a/src/ast.h b/src/ast.h
|
| index 205560f586106c8bc1e8c54576b14a64fb9558fa..01d06dd0afd6e51f2b3a851fc6c79341ad71c3e2 100644
|
| --- a/src/ast.h
|
| +++ b/src/ast.h
|
| @@ -220,6 +220,10 @@ class Expression: public AstNode {
|
| // evaluate out of order.
|
| virtual bool IsTrivial() { return false; }
|
|
|
| + // True if the expression always has one of the non-Object JS types
|
| + // (Undefined, Null, Boolean, String, or Number).
|
| + virtual bool IsPrimitive() = 0;
|
| +
|
| // Mark the expression as being compiled as an expression
|
| // statement. This is used to transform postfix increments to
|
| // (faster) prefix increments.
|
| @@ -280,6 +284,9 @@ class ValidLeftHandSideSentinel: public Expression {
|
| virtual bool IsValidLeftHandSide() { return true; }
|
| virtual void Accept(AstVisitor* v) { UNREACHABLE(); }
|
| static ValidLeftHandSideSentinel* instance() { return &instance_; }
|
| +
|
| + virtual bool IsPrimitive() { UNREACHABLE(); return false; }
|
| +
|
| private:
|
| static ValidLeftHandSideSentinel instance_;
|
| };
|
| @@ -798,6 +805,7 @@ class Literal: public Expression {
|
|
|
| virtual bool IsLeaf() { return true; }
|
| virtual bool IsTrivial() { return true; }
|
| + virtual bool IsPrimitive();
|
|
|
| // Identity testers.
|
| bool IsNull() const { return handle_.is_identical_to(Factory::null_value()); }
|
| @@ -885,6 +893,8 @@ class ObjectLiteral: public MaterializedLiteral {
|
|
|
| virtual bool IsLeaf() { return properties()->is_empty(); }
|
|
|
| + virtual bool IsPrimitive();
|
| +
|
| Handle<FixedArray> constant_properties() const {
|
| return constant_properties_;
|
| }
|
| @@ -913,6 +923,8 @@ class RegExpLiteral: public MaterializedLiteral {
|
|
|
| virtual bool IsLeaf() { return true; }
|
|
|
| + virtual bool IsPrimitive();
|
| +
|
| Handle<String> pattern() const { return pattern_; }
|
| Handle<String> flags() const { return flags_; }
|
|
|
| @@ -939,6 +951,8 @@ class ArrayLiteral: public MaterializedLiteral {
|
|
|
| virtual bool IsLeaf() { return values()->is_empty(); }
|
|
|
| + virtual bool IsPrimitive();
|
| +
|
| Handle<FixedArray> constant_elements() const { return constant_elements_; }
|
| ZoneList<Expression*>* values() const { return values_; }
|
|
|
| @@ -959,6 +973,8 @@ class CatchExtensionObject: public Expression {
|
|
|
| virtual void Accept(AstVisitor* v);
|
|
|
| + virtual bool IsPrimitive();
|
| +
|
| Literal* key() const { return key_; }
|
| VariableProxy* value() const { return value_; }
|
|
|
| @@ -995,6 +1011,8 @@ class VariableProxy: public Expression {
|
| // immutable.
|
| virtual bool IsTrivial() { return is_trivial_; }
|
|
|
| + virtual bool IsPrimitive();
|
| +
|
| bool IsVariable(Handle<String> n) {
|
| return !is_this() && name().is_identical_to(n);
|
| }
|
| @@ -1036,6 +1054,8 @@ class VariableProxySentinel: public VariableProxy {
|
| return &identifier_proxy_;
|
| }
|
|
|
| + virtual bool IsPrimitive() { UNREACHABLE(); return false; }
|
| +
|
| private:
|
| explicit VariableProxySentinel(bool is_this) : VariableProxy(is_this) { }
|
| static VariableProxySentinel this_proxy_;
|
| @@ -1079,6 +1099,8 @@ class Slot: public Expression {
|
|
|
| virtual bool IsLeaf() { return true; }
|
|
|
| + virtual bool IsPrimitive() { UNREACHABLE(); return false; }
|
| +
|
| bool IsStackAllocated() { return type_ == PARAMETER || type_ == LOCAL; }
|
|
|
| // Accessors
|
| @@ -1111,6 +1133,8 @@ class Property: public Expression {
|
|
|
| virtual bool IsValidLeftHandSide() { return true; }
|
|
|
| + virtual bool IsPrimitive();
|
| +
|
| Expression* obj() const { return obj_; }
|
| Expression* key() const { return key_; }
|
| int position() const { return pos_; }
|
| @@ -1141,6 +1165,8 @@ class Call: public Expression {
|
| // Type testing and conversion.
|
| virtual Call* AsCall() { return this; }
|
|
|
| + virtual bool IsPrimitive();
|
| +
|
| Expression* expression() const { return expression_; }
|
| ZoneList<Expression*>* arguments() const { return arguments_; }
|
| int position() { return pos_; }
|
| @@ -1163,6 +1189,8 @@ class CallNew: public Expression {
|
|
|
| virtual void Accept(AstVisitor* v);
|
|
|
| + virtual bool IsPrimitive();
|
| +
|
| Expression* expression() const { return expression_; }
|
| ZoneList<Expression*>* arguments() const { return arguments_; }
|
| int position() { return pos_; }
|
| @@ -1187,6 +1215,8 @@ class CallRuntime: public Expression {
|
|
|
| virtual void Accept(AstVisitor* v);
|
|
|
| + virtual bool IsPrimitive();
|
| +
|
| Handle<String> name() const { return name_; }
|
| Runtime::Function* function() const { return function_; }
|
| ZoneList<Expression*>* arguments() const { return arguments_; }
|
| @@ -1211,6 +1241,8 @@ class UnaryOperation: public Expression {
|
| // Type testing & conversion
|
| virtual UnaryOperation* AsUnaryOperation() { return this; }
|
|
|
| + virtual bool IsPrimitive();
|
| +
|
| Token::Value op() const { return op_; }
|
| Expression* expression() const { return expression_; }
|
|
|
| @@ -1232,6 +1264,8 @@ class BinaryOperation: public Expression {
|
| // Type testing & conversion
|
| virtual BinaryOperation* AsBinaryOperation() { return this; }
|
|
|
| + virtual bool IsPrimitive();
|
| +
|
| // True iff the result can be safely overwritten (to avoid allocation).
|
| // False for operations that can return one of their operands.
|
| bool ResultOverwriteAllowed() {
|
| @@ -1284,6 +1318,8 @@ class CountOperation: public Expression {
|
| return expression()->AsVariableProxy()->AsVariable();
|
| }
|
|
|
| + virtual bool IsPrimitive();
|
| +
|
| bool is_prefix() const { return is_prefix_; }
|
| bool is_postfix() const { return !is_prefix_; }
|
| Token::Value op() const { return op_; }
|
| @@ -1310,6 +1346,8 @@ class CompareOperation: public Expression {
|
|
|
| virtual void Accept(AstVisitor* v);
|
|
|
| + virtual bool IsPrimitive();
|
| +
|
| Token::Value op() const { return op_; }
|
| Expression* left() const { return left_; }
|
| Expression* right() const { return right_; }
|
| @@ -1340,6 +1378,8 @@ class Conditional: public Expression {
|
|
|
| virtual void Accept(AstVisitor* v);
|
|
|
| + virtual bool IsPrimitive();
|
| +
|
| Expression* condition() const { return condition_; }
|
| Expression* then_expression() const { return then_expression_; }
|
| Expression* else_expression() const { return else_expression_; }
|
| @@ -1362,6 +1402,8 @@ class Assignment: public Expression {
|
| virtual void Accept(AstVisitor* v);
|
| virtual Assignment* AsAssignment() { return this; }
|
|
|
| + virtual bool IsPrimitive();
|
| +
|
| Assignment* AsSimpleAssignment() { return !is_compound() ? this : NULL; }
|
|
|
| virtual Variable* AssignedVar() {
|
| @@ -1402,6 +1444,9 @@ class Throw: public Expression {
|
| : exception_(exception), pos_(pos) {}
|
|
|
| virtual void Accept(AstVisitor* v);
|
| +
|
| + virtual bool IsPrimitive();
|
| +
|
| Expression* exception() const { return exception_; }
|
| int position() const { return pos_; }
|
|
|
| @@ -1451,6 +1496,8 @@ class FunctionLiteral: public Expression {
|
|
|
| virtual bool IsLeaf() { return true; }
|
|
|
| + virtual bool IsPrimitive();
|
| +
|
| Handle<String> name() const { return name_; }
|
| Scope* scope() const { return scope_; }
|
| ZoneList<Statement*>* body() const { return body_; }
|
| @@ -1521,6 +1568,8 @@ class FunctionBoilerplateLiteral: public Expression {
|
|
|
| virtual void Accept(AstVisitor* v);
|
|
|
| + virtual bool IsPrimitive();
|
| +
|
| private:
|
| Handle<JSFunction> boilerplate_;
|
| };
|
| @@ -1530,6 +1579,7 @@ class ThisFunction: public Expression {
|
| public:
|
| virtual void Accept(AstVisitor* v);
|
| virtual bool IsLeaf() { return true; }
|
| + virtual bool IsPrimitive();
|
| };
|
|
|
|
|
|
|