OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1071 ASSERT(var_ != NULL); // Variable must be resolved. | 1071 ASSERT(var_ != NULL); // Variable must be resolved. |
1072 return var()->is_global() || var()->rewrite()->IsLeaf(); | 1072 return var()->is_global() || var()->rewrite()->IsLeaf(); |
1073 } | 1073 } |
1074 | 1074 |
1075 // Reading from a mutable variable is a side effect, but 'this' is | 1075 // Reading from a mutable variable is a side effect, but 'this' is |
1076 // immutable. | 1076 // immutable. |
1077 virtual bool IsTrivial() { return is_trivial_; } | 1077 virtual bool IsTrivial() { return is_trivial_; } |
1078 | 1078 |
1079 virtual bool IsPrimitive(); | 1079 virtual bool IsPrimitive(); |
1080 | 1080 |
| 1081 void SetIsPrimitive(bool value) { is_primitive_ = value; } |
| 1082 |
1081 bool IsVariable(Handle<String> n) { | 1083 bool IsVariable(Handle<String> n) { |
1082 return !is_this() && name().is_identical_to(n); | 1084 return !is_this() && name().is_identical_to(n); |
1083 } | 1085 } |
1084 | 1086 |
1085 bool IsArguments() { | 1087 bool IsArguments() { |
1086 Variable* variable = AsVariable(); | 1088 Variable* variable = AsVariable(); |
1087 return (variable == NULL) ? false : variable->is_arguments(); | 1089 return (variable == NULL) ? false : variable->is_arguments(); |
1088 } | 1090 } |
1089 | 1091 |
1090 Handle<String> name() const { return name_; } | 1092 Handle<String> name() const { return name_; } |
1091 Variable* var() const { return var_; } | 1093 Variable* var() const { return var_; } |
1092 bool is_this() const { return is_this_; } | 1094 bool is_this() const { return is_this_; } |
1093 bool inside_with() const { return inside_with_; } | 1095 bool inside_with() const { return inside_with_; } |
1094 bool is_trivial() { return is_trivial_; } | 1096 bool is_trivial() { return is_trivial_; } |
1095 void set_is_trivial(bool b) { is_trivial_ = b; } | 1097 void set_is_trivial(bool b) { is_trivial_ = b; } |
1096 | 1098 |
1097 BitVector* reaching_definitions() { return reaching_definitions_; } | 1099 BitVector* reaching_definitions() { return reaching_definitions_; } |
1098 void set_reaching_definitions(BitVector* rd) { reaching_definitions_ = rd; } | 1100 void set_reaching_definitions(BitVector* rd) { reaching_definitions_ = rd; } |
1099 | 1101 |
1100 // Bind this proxy to the variable var. | 1102 // Bind this proxy to the variable var. |
1101 void BindTo(Variable* var); | 1103 void BindTo(Variable* var); |
1102 | 1104 |
1103 protected: | 1105 protected: |
1104 Handle<String> name_; | 1106 Handle<String> name_; |
1105 Variable* var_; // resolved variable, or NULL | 1107 Variable* var_; // resolved variable, or NULL |
1106 bool is_this_; | 1108 bool is_this_; |
1107 bool inside_with_; | 1109 bool inside_with_; |
1108 bool is_trivial_; | 1110 bool is_trivial_; |
1109 BitVector* reaching_definitions_; | 1111 BitVector* reaching_definitions_; |
| 1112 bool is_primitive_; |
1110 | 1113 |
1111 VariableProxy(Handle<String> name, bool is_this, bool inside_with); | 1114 VariableProxy(Handle<String> name, bool is_this, bool inside_with); |
1112 explicit VariableProxy(bool is_this); | 1115 explicit VariableProxy(bool is_this); |
1113 | 1116 |
1114 friend class Scope; | 1117 friend class Scope; |
1115 }; | 1118 }; |
1116 | 1119 |
1117 | 1120 |
1118 class VariableProxySentinel: public VariableProxy { | 1121 class VariableProxySentinel: public VariableProxy { |
1119 public: | 1122 public: |
(...skipping 963 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2083 | 2086 |
2084 // Holds the result of copying an expression. | 2087 // Holds the result of copying an expression. |
2085 Expression* expr_; | 2088 Expression* expr_; |
2086 // Holds the result of copying a statement. | 2089 // Holds the result of copying a statement. |
2087 Statement* stmt_; | 2090 Statement* stmt_; |
2088 }; | 2091 }; |
2089 | 2092 |
2090 } } // namespace v8::internal | 2093 } } // namespace v8::internal |
2091 | 2094 |
2092 #endif // V8_AST_H_ | 2095 #endif // V8_AST_H_ |
OLD | NEW |