| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 | 187 |
| 188 private: | 188 private: |
| 189 friend class AstValueFactory; | 189 friend class AstValueFactory; |
| 190 | 190 |
| 191 enum Type { | 191 enum Type { |
| 192 STRING, | 192 STRING, |
| 193 SYMBOL, | 193 SYMBOL, |
| 194 NUMBER, | 194 NUMBER, |
| 195 SMI, | 195 SMI, |
| 196 BOOLEAN, | 196 BOOLEAN, |
| 197 STRING_ARRAY, | |
| 198 NULL_TYPE, | 197 NULL_TYPE, |
| 199 UNDEFINED, | 198 UNDEFINED, |
| 200 THE_HOLE | 199 THE_HOLE |
| 201 }; | 200 }; |
| 202 | 201 |
| 203 explicit AstValue(const AstRawString* s) : type_(STRING) { string_ = s; } | 202 explicit AstValue(const AstRawString* s) : type_(STRING) { string_ = s; } |
| 204 | 203 |
| 205 explicit AstValue(const char* name) : type_(SYMBOL) { symbol_name_ = name; } | 204 explicit AstValue(const char* name) : type_(SYMBOL) { symbol_name_ = name; } |
| 206 | 205 |
| 207 explicit AstValue(double n) : type_(NUMBER) { number_ = n; } | 206 explicit AstValue(double n) : type_(NUMBER) { number_ = n; } |
| 208 | 207 |
| 209 AstValue(Type t, int i) : type_(t) { | 208 AstValue(Type t, int i) : type_(t) { |
| 210 DCHECK(type_ == SMI); | 209 DCHECK(type_ == SMI); |
| 211 smi_ = i; | 210 smi_ = i; |
| 212 } | 211 } |
| 213 | 212 |
| 214 explicit AstValue(bool b) : type_(BOOLEAN) { bool_ = b; } | 213 explicit AstValue(bool b) : type_(BOOLEAN) { bool_ = b; } |
| 215 | 214 |
| 216 explicit AstValue(ZoneList<const AstRawString*>* s) : type_(STRING_ARRAY) { | |
| 217 strings_ = s; | |
| 218 } | |
| 219 | |
| 220 explicit AstValue(Type t) : type_(t) { | 215 explicit AstValue(Type t) : type_(t) { |
| 221 DCHECK(t == NULL_TYPE || t == UNDEFINED || t == THE_HOLE); | 216 DCHECK(t == NULL_TYPE || t == UNDEFINED || t == THE_HOLE); |
| 222 } | 217 } |
| 223 | 218 |
| 224 Type type_; | 219 Type type_; |
| 225 | 220 |
| 226 // Uninternalized value. | 221 // Uninternalized value. |
| 227 union { | 222 union { |
| 228 const AstRawString* string_; | 223 const AstRawString* string_; |
| 229 double number_; | 224 double number_; |
| 230 int smi_; | 225 int smi_; |
| 231 bool bool_; | 226 bool bool_; |
| 232 ZoneList<const AstRawString*>* strings_; | 227 ZoneList<const AstRawString*>* strings_; |
| 233 const char* symbol_name_; | 228 const char* symbol_name_; |
| 234 }; | 229 }; |
| 235 | 230 |
| 236 // Internalized value (empty before internalized). | 231 // Internalized value (empty before internalized). |
| 237 Handle<Object> value_; | 232 Handle<Object> value_; |
| 238 }; | 233 }; |
| 239 | 234 |
| 240 | 235 |
| 241 // For generating constants. | 236 // For generating constants. |
| 242 #define STRING_CONSTANTS(F) \ | 237 #define STRING_CONSTANTS(F) \ |
| 243 F(anonymous_function, "(anonymous function)") \ | 238 F(anonymous_function, "(anonymous function)") \ |
| 244 F(arguments, "arguments") \ | 239 F(arguments, "arguments") \ |
| 245 F(constructor, "constructor") \ | 240 F(constructor, "constructor") \ |
| 246 F(done, "done") \ | 241 F(done, "done") \ |
| 247 F(dot, ".") \ | 242 F(dot, ".") \ |
| 248 F(dot_for, ".for") \ | 243 F(dot_for, ".for") \ |
| 249 F(dot_generator, ".generator") \ | 244 F(dot_generator, ".generator") \ |
| 250 F(dot_generator_object, ".generator_object") \ | 245 F(dot_generator_object, ".generator_object") \ |
| 251 F(dot_iterator, ".iterator") \ | 246 F(dot_iterator, ".iterator") \ |
| 252 F(dot_module, ".module") \ | 247 F(dot_module, ".module") \ |
| 253 F(dot_result, ".result") \ | 248 F(dot_result, ".result") \ |
| 254 F(empty, "") \ | 249 F(empty, "") \ |
| 255 F(eval, "eval") \ | 250 F(eval, "eval") \ |
| 256 F(initialize_const_global, "initializeConstGlobal") \ | 251 F(initialize_const_global, "initializeConstGlobal") \ |
| 257 F(initialize_var_global, "initializeVarGlobal") \ | 252 F(initialize_var_global, "initializeVarGlobal") \ |
| 258 F(make_reference_error, "MakeReferenceError") \ | 253 F(make_reference_error, "MakeReferenceErrorEmbedded") \ |
| 259 F(make_syntax_error, "MakeSyntaxError") \ | 254 F(make_syntax_error, "MakeSyntaxErrorEmbedded") \ |
| 260 F(make_type_error, "MakeTypeError") \ | 255 F(make_type_error, "MakeTypeErrorEmbedded") \ |
| 261 F(module, "module") \ | 256 F(module, "module") \ |
| 262 F(native, "native") \ | 257 F(native, "native") \ |
| 263 F(next, "next") \ | 258 F(next, "next") \ |
| 264 F(proto, "__proto__") \ | 259 F(proto, "__proto__") \ |
| 265 F(prototype, "prototype") \ | 260 F(prototype, "prototype") \ |
| 266 F(this, "this") \ | 261 F(this, "this") \ |
| 267 F(use_asm, "use asm") \ | 262 F(use_asm, "use asm") \ |
| 268 F(use_strict, "use strict") \ | 263 F(use_strict, "use strict") \ |
| 269 F(value, "value") | 264 F(value, "value") |
| 270 | 265 |
| 271 #define OTHER_CONSTANTS(F) \ | 266 #define OTHER_CONSTANTS(F) \ |
| 272 F(true_value) \ | 267 F(true_value) \ |
| 273 F(false_value) \ | 268 F(false_value) \ |
| 274 F(null_value) \ | 269 F(null_value) \ |
| 275 F(undefined_value) \ | 270 F(undefined_value) \ |
| 276 F(the_hole_value) | 271 F(the_hole_value) |
| 277 | 272 |
| 278 class AstValueFactory { | 273 class AstValueFactory { |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 | 353 |
| 359 bool AstRawString::IsArguments(AstValueFactory* ast_value_factory) const { | 354 bool AstRawString::IsArguments(AstValueFactory* ast_value_factory) const { |
| 360 return ast_value_factory->arguments_string() == this; | 355 return ast_value_factory->arguments_string() == this; |
| 361 } | 356 } |
| 362 } } // namespace v8::internal | 357 } } // namespace v8::internal |
| 363 | 358 |
| 364 #undef STRING_CONSTANTS | 359 #undef STRING_CONSTANTS |
| 365 #undef OTHER_CONSTANTS | 360 #undef OTHER_CONSTANTS |
| 366 | 361 |
| 367 #endif // V8_AST_VALUE_FACTORY_H_ | 362 #endif // V8_AST_VALUE_FACTORY_H_ |
| OLD | NEW |