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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 case STRING: | 152 case STRING: |
153 DCHECK(string_ != NULL); | 153 DCHECK(string_ != NULL); |
154 return !string_->IsEmpty(); | 154 return !string_->IsEmpty(); |
155 case SYMBOL: | 155 case SYMBOL: |
156 UNREACHABLE(); | 156 UNREACHABLE(); |
157 break; | 157 break; |
158 case NUMBER: | 158 case NUMBER: |
159 return DoubleToBoolean(number_); | 159 return DoubleToBoolean(number_); |
160 case SMI: | 160 case SMI: |
161 return smi_ != 0; | 161 return smi_ != 0; |
162 case STRING_ARRAY: | |
163 UNREACHABLE(); | |
164 break; | |
165 case BOOLEAN: | 162 case BOOLEAN: |
166 return bool_; | 163 return bool_; |
167 case NULL_TYPE: | 164 case NULL_TYPE: |
168 return false; | 165 return false; |
169 case THE_HOLE: | 166 case THE_HOLE: |
170 UNREACHABLE(); | 167 UNREACHABLE(); |
171 break; | 168 break; |
172 case UNDEFINED: | 169 case UNDEFINED: |
173 return false; | 170 return false; |
174 } | 171 } |
(...skipping 20 matching lines...) Expand all Loading... |
195 case SMI: | 192 case SMI: |
196 value_ = handle(Smi::FromInt(smi_), isolate); | 193 value_ = handle(Smi::FromInt(smi_), isolate); |
197 break; | 194 break; |
198 case BOOLEAN: | 195 case BOOLEAN: |
199 if (bool_) { | 196 if (bool_) { |
200 value_ = isolate->factory()->true_value(); | 197 value_ = isolate->factory()->true_value(); |
201 } else { | 198 } else { |
202 value_ = isolate->factory()->false_value(); | 199 value_ = isolate->factory()->false_value(); |
203 } | 200 } |
204 break; | 201 break; |
205 case STRING_ARRAY: { | |
206 DCHECK(strings_ != NULL); | |
207 Factory* factory = isolate->factory(); | |
208 int len = strings_->length(); | |
209 Handle<FixedArray> elements = factory->NewFixedArray(len, TENURED); | |
210 for (int i = 0; i < len; i++) { | |
211 const AstRawString* string = (*strings_)[i]; | |
212 Handle<Object> element = string->string(); | |
213 // Strings are already internalized. | |
214 DCHECK(!element.is_null()); | |
215 elements->set(i, *element); | |
216 } | |
217 value_ = | |
218 factory->NewJSArrayWithElements(elements, FAST_ELEMENTS, TENURED); | |
219 break; | |
220 } | |
221 case NULL_TYPE: | 202 case NULL_TYPE: |
222 value_ = isolate->factory()->null_value(); | 203 value_ = isolate->factory()->null_value(); |
223 break; | 204 break; |
224 case THE_HOLE: | 205 case THE_HOLE: |
225 value_ = isolate->factory()->the_hole_value(); | 206 value_ = isolate->factory()->the_hole_value(); |
226 break; | 207 break; |
227 case UNDEFINED: | 208 case UNDEFINED: |
228 value_ = isolate->factory()->undefined_value(); | 209 value_ = isolate->factory()->undefined_value(); |
229 break; | 210 break; |
230 } | 211 } |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 | 324 |
344 const AstValue* AstValueFactory::NewBoolean(bool b) { | 325 const AstValue* AstValueFactory::NewBoolean(bool b) { |
345 if (b) { | 326 if (b) { |
346 GENERATE_VALUE_GETTER(true_value_, true); | 327 GENERATE_VALUE_GETTER(true_value_, true); |
347 } else { | 328 } else { |
348 GENERATE_VALUE_GETTER(false_value_, false); | 329 GENERATE_VALUE_GETTER(false_value_, false); |
349 } | 330 } |
350 } | 331 } |
351 | 332 |
352 | 333 |
353 const AstValue* AstValueFactory::NewStringList( | |
354 ZoneList<const AstRawString*>* strings) { | |
355 AstValue* value = new (zone_) AstValue(strings); | |
356 if (isolate_) { | |
357 value->Internalize(isolate_); | |
358 } | |
359 values_.Add(value); | |
360 return value; | |
361 } | |
362 | |
363 | |
364 const AstValue* AstValueFactory::NewNull() { | 334 const AstValue* AstValueFactory::NewNull() { |
365 GENERATE_VALUE_GETTER(null_value_, AstValue::NULL_TYPE); | 335 GENERATE_VALUE_GETTER(null_value_, AstValue::NULL_TYPE); |
366 } | 336 } |
367 | 337 |
368 | 338 |
369 const AstValue* AstValueFactory::NewUndefined() { | 339 const AstValue* AstValueFactory::NewUndefined() { |
370 GENERATE_VALUE_GETTER(undefined_value_, AstValue::UNDEFINED); | 340 GENERATE_VALUE_GETTER(undefined_value_, AstValue::UNDEFINED); |
371 } | 341 } |
372 | 342 |
373 | 343 |
(...skipping 24 matching lines...) Expand all Loading... |
398 if (isolate_) { | 368 if (isolate_) { |
399 new_string->Internalize(isolate_); | 369 new_string->Internalize(isolate_); |
400 } | 370 } |
401 entry->value = reinterpret_cast<void*>(1); | 371 entry->value = reinterpret_cast<void*>(1); |
402 } | 372 } |
403 return reinterpret_cast<AstRawString*>(entry->key); | 373 return reinterpret_cast<AstRawString*>(entry->key); |
404 } | 374 } |
405 | 375 |
406 | 376 |
407 } } // namespace v8::internal | 377 } } // namespace v8::internal |
OLD | NEW |