Index: src/accessors.cc |
=================================================================== |
--- src/accessors.cc (revision 2090) |
+++ src/accessors.cc (working copy) |
@@ -289,6 +289,24 @@ |
// |
+// Accessors::ScriptCompilationType |
+// |
+ |
+ |
+Object* Accessors::ScriptGetCompilationType(Object* object, void*) { |
+ Object* script = JSValue::cast(object)->value(); |
+ return Script::cast(script)->compilation_type(); |
+} |
+ |
+ |
+const AccessorDescriptor Accessors::ScriptCompilationType = { |
+ ScriptGetCompilationType, |
+ IllegalSetter, |
+ 0 |
+}; |
+ |
+ |
+// |
// Accessors::ScriptGetLineEnds |
// |
@@ -314,9 +332,8 @@ |
Object* Accessors::ScriptGetContextData(Object* object, void*) { |
- HandleScope scope; |
- Handle<Script> script(Script::cast(JSValue::cast(object)->value())); |
- return script->context_data(); |
+ Object* script = JSValue::cast(object)->value(); |
+ return Script::cast(script)->context_data(); |
} |
@@ -328,6 +345,54 @@ |
// |
+// Accessors::ScriptGetEvalFromFunction |
+// |
+ |
+ |
+Object* Accessors::ScriptGetEvalFromFunction(Object* object, void*) { |
+ Object* script = JSValue::cast(object)->value(); |
+ return Script::cast(script)->eval_from_function(); |
+} |
+ |
+ |
+const AccessorDescriptor Accessors::ScriptEvalFromFunction = { |
+ ScriptGetEvalFromFunction, |
+ IllegalSetter, |
+ 0 |
+}; |
+ |
+ |
+// |
+// Accessors::ScriptGetEvalFromPosition |
+// |
+ |
+ |
+Object* Accessors::ScriptGetEvalFromPosition(Object* object, void*) { |
+ HandleScope scope; |
+ Handle<Script> script(Script::cast(JSValue::cast(object)->value())); |
+ |
+ // If this is not a script compiled through eval there is no eval position. |
+ int compilation_type = Smi::cast(script->compilation_type())->value(); |
+ if (compilation_type != Script::COMPILATION_TYPE_EVAL) { |
+ return Heap::undefined_value(); |
+ } |
+ |
+ // Get the function from where eval was called and find the source position |
+ // from the instruction offset. |
+ Handle<Code> code(JSFunction::cast(script->eval_from_function())->code()); |
+ return Smi::FromInt(code->SourcePosition(code->instruction_start() + |
+ script->eval_from_instructions_offset()->value())); |
+} |
+ |
+ |
+const AccessorDescriptor Accessors::ScriptEvalFromPosition = { |
+ ScriptGetEvalFromPosition, |
+ IllegalSetter, |
+ 0 |
+}; |
+ |
+ |
+// |
// Accessors::FunctionPrototype |
// |