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 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 | 342 |
343 | 343 |
344 const AccessorDescriptor Accessors::ScriptContextData = { | 344 const AccessorDescriptor Accessors::ScriptContextData = { |
345 ScriptGetContextData, | 345 ScriptGetContextData, |
346 IllegalSetter, | 346 IllegalSetter, |
347 0 | 347 0 |
348 }; | 348 }; |
349 | 349 |
350 | 350 |
351 // | 351 // |
352 // Accessors::ScriptGetEvalFromFunction | 352 // Accessors::ScriptGetEvalFromScript |
353 // | 353 // |
354 | 354 |
355 | 355 |
356 Object* Accessors::ScriptGetEvalFromFunction(Object* object, void*) { | 356 Object* Accessors::ScriptGetEvalFromScript(Object* object, void*) { |
357 Object* script = JSValue::cast(object)->value(); | 357 Object* script = JSValue::cast(object)->value(); |
358 return Script::cast(script)->eval_from_function(); | 358 if (!Script::cast(script)->eval_from_shared()->IsUndefined()) { |
| 359 Handle<SharedFunctionInfo> eval_from_shared( |
| 360 SharedFunctionInfo::cast(Script::cast(script)->eval_from_shared())); |
| 361 |
| 362 if (eval_from_shared->script()->IsScript()) { |
| 363 Handle<Script> eval_from_script(Script::cast(eval_from_shared->script())); |
| 364 return *GetScriptWrapper(eval_from_script); |
| 365 } |
| 366 } |
| 367 return Heap::undefined_value(); |
359 } | 368 } |
360 | 369 |
361 | 370 |
362 const AccessorDescriptor Accessors::ScriptEvalFromFunction = { | 371 const AccessorDescriptor Accessors::ScriptEvalFromScript = { |
363 ScriptGetEvalFromFunction, | 372 ScriptGetEvalFromScript, |
364 IllegalSetter, | 373 IllegalSetter, |
365 0 | 374 0 |
366 }; | 375 }; |
367 | 376 |
368 | 377 |
369 // | 378 // |
370 // Accessors::ScriptGetEvalFromPosition | 379 // Accessors::ScriptGetEvalFromScriptPosition |
371 // | 380 // |
372 | 381 |
373 | 382 |
374 Object* Accessors::ScriptGetEvalFromPosition(Object* object, void*) { | 383 Object* Accessors::ScriptGetEvalFromScriptPosition(Object* object, void*) { |
375 HandleScope scope; | 384 HandleScope scope; |
376 Handle<Script> script(Script::cast(JSValue::cast(object)->value())); | 385 Handle<Script> script(Script::cast(JSValue::cast(object)->value())); |
377 | 386 |
378 // If this is not a script compiled through eval there is no eval position. | 387 // If this is not a script compiled through eval there is no eval position. |
379 int compilation_type = Smi::cast(script->compilation_type())->value(); | 388 int compilation_type = Smi::cast(script->compilation_type())->value(); |
380 if (compilation_type != Script::COMPILATION_TYPE_EVAL) { | 389 if (compilation_type != Script::COMPILATION_TYPE_EVAL) { |
381 return Heap::undefined_value(); | 390 return Heap::undefined_value(); |
382 } | 391 } |
383 | 392 |
384 // Get the function from where eval was called and find the source position | 393 // Get the function from where eval was called and find the source position |
385 // from the instruction offset. | 394 // from the instruction offset. |
386 Handle<Code> code(JSFunction::cast(script->eval_from_function())->code()); | 395 Handle<Code> code(SharedFunctionInfo::cast( |
| 396 script->eval_from_shared())->code()); |
387 return Smi::FromInt(code->SourcePosition(code->instruction_start() + | 397 return Smi::FromInt(code->SourcePosition(code->instruction_start() + |
388 script->eval_from_instructions_offset()->value())); | 398 script->eval_from_instructions_offset()->value())); |
389 } | 399 } |
390 | 400 |
391 | 401 |
392 const AccessorDescriptor Accessors::ScriptEvalFromPosition = { | 402 const AccessorDescriptor Accessors::ScriptEvalFromScriptPosition = { |
393 ScriptGetEvalFromPosition, | 403 ScriptGetEvalFromScriptPosition, |
| 404 IllegalSetter, |
| 405 0 |
| 406 }; |
| 407 |
| 408 |
| 409 // |
| 410 // Accessors::ScriptGetEvalFromFunctionName |
| 411 // |
| 412 |
| 413 |
| 414 Object* Accessors::ScriptGetEvalFromFunctionName(Object* object, void*) { |
| 415 Object* script = JSValue::cast(object)->value(); |
| 416 Handle<SharedFunctionInfo> shared(SharedFunctionInfo::cast( |
| 417 Script::cast(script)->eval_from_shared())); |
| 418 |
| 419 |
| 420 // Find the name of the function calling eval. |
| 421 if (!shared->name()->IsUndefined()) { |
| 422 return shared->name(); |
| 423 } else { |
| 424 return shared->inferred_name(); |
| 425 } |
| 426 } |
| 427 |
| 428 |
| 429 const AccessorDescriptor Accessors::ScriptEvalFromFunctionName = { |
| 430 ScriptGetEvalFromFunctionName, |
394 IllegalSetter, | 431 IllegalSetter, |
395 0 | 432 0 |
396 }; | 433 }; |
397 | 434 |
398 | 435 |
399 // | 436 // |
400 // Accessors::FunctionPrototype | 437 // Accessors::FunctionPrototype |
401 // | 438 // |
402 | 439 |
403 | 440 |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
649 } | 686 } |
650 | 687 |
651 | 688 |
652 const AccessorDescriptor Accessors::ObjectPrototype = { | 689 const AccessorDescriptor Accessors::ObjectPrototype = { |
653 ObjectGetPrototype, | 690 ObjectGetPrototype, |
654 ObjectSetPrototype, | 691 ObjectSetPrototype, |
655 0 | 692 0 |
656 }; | 693 }; |
657 | 694 |
658 } } // namespace v8::internal | 695 } } // namespace v8::internal |
OLD | NEW |