Not sure what you mean, for this following code:
function factory(a) {
return {
read_something: function(i) { if (i < 0) this.die(); return a; }
};
};
factory(2).read_something(-1);
I get:
test2.js:3: TypeError: Object #<Object> has no method 'die'
read_something: function(i) { if (i < 0) this.die(); return a; }
^
TypeError: Object #<Object> has no method 'die'
at Object.read_something (test2.js:3:53)
at test2.js:8:12
which seems perfectly fine to me.
Yang
On Thursday, November 29, 2012 4:18:48 PM UTC+1, Paul Harris wrote:
>
> Hi,
>
> I have a small bit of code that looks something like this:
> (function (a, b, c) {
> return {
> read_something: function(i) { if (i < 0) this.die(); return a; }
> };
> });
>
> I then do something like this:
> comp = Script::Compile(code);
> wrapper = comp->Run();
> binder = wrapper->Call( global, 3, args );
> global->Set( ident, binder );
>
> which compiles, runs (to get the factory-function), then calls the
> factory-function with arguments,
> resulting in the {} object with read_something function inside.
> I then bind this to the global object.
> I use this to give me access to data, but at the same time ensure the data
> is read-only.
>
> This works well. If I call binder.read_something(-1) within javascript,
> it correctly dies when trying to call this.die().
>
> However, the callstack that is printed out only shows the details for the
> code within the wrapper,
> it does not print out the callstack up to the calling code (which is
> compiled and run later).
>
> Any ideas why this might be? I am hoping to (eg) find the place where the
> calling script calls with a -1 parameter.
>
> thanks,
> Paul
>
>
--
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users