Chromium Code Reviews| Index: frog/value.dart |
| diff --git a/frog/value.dart b/frog/value.dart |
| index 2c06880c282163a7e61e13cc0f445dedad9804f6..b8583c4e3fe69623aa8a8eb350c4b1a0f251acec 100644 |
| --- a/frog/value.dart |
| +++ b/frog/value.dart |
| @@ -243,9 +243,11 @@ class Value { |
| if (myCall == null || myCall.parameters.length != arity) { |
| final stub = world.functionType.getCallStub(new Arguments.bare(arity)); |
| var val = new Value(toType, 'to\$${stub.name}($code)', node.span); |
| + // TODO(sigmund): try to remove, see below |
| return _isDomCallback(toType) && !_isDomCallback(type) ? |
| val._wrapDomCallback(toType, arity) : val; |
| } else if (_isDomCallback(toType) && !_isDomCallback(type)) { |
| + // TODO(sigmund): try to remove, see below |
| return _wrapDomCallback(toType, arity); |
| } |
| } |
| @@ -283,12 +285,30 @@ class Value { |
| } |
| } |
| + /** |
| + * Checks whether [toType] is a callback function, and it is defined in the |
| + * dom library. |
| + */ |
| bool _isDomCallback(toType) { |
| return (toType.definition is FunctionTypeDefinition |
| && toType.library == world.dom); |
| } |
| + /** |
| + * Wraps a callback attached to the dom (e.g. event listeners, setTimeout) so |
| + * we can restore it's isolate context information. This is needed so that |
| + * callbacks are executed withing the context of the isolate that created them |
|
jimhug
2011/11/16 18:00:45
Nit: within
Siggi Cherem (dart-lang)
2011/11/17 16:50:11
Done.
|
| + * in the first place. |
| + */ |
| + // TODO(sigmund): try to remove this specialized logic about isolates |
| + // and the dom from the compiler, move into the actual dom library if |
| + // possible. |
|
Jennifer Messerly
2011/11/17 02:28:11
I still don't think this is special logic. :)
All
Siggi Cherem (dart-lang)
2011/11/17 16:50:11
totally agree. Although I would be quite happy if
|
| Value _wrapDomCallback(Type toType, int arity) { |
| + if (arity == 0) { |
| + world.gen.corejs.useWrap0 = true; |
|
Jennifer Messerly
2011/11/17 02:28:11
should this also set useIsolates to true? Or you c
Siggi Cherem (dart-lang)
2011/11/17 16:50:11
In this case no, we don't want to mark useIsolates
Jennifer Messerly
2011/11/17 19:18:03
My bad. I didn't read corejs.dart carefully enough
|
| + } else { |
| + world.gen.corejs.useWrap1 = true; |
| + } |
| return new Value(toType, '\$wrap_call\$$arity($code)', span); |
| } |