InitImplementation() public method

public InitImplementation ( object implementation ) : void
implementation object
return void
Example #1
0
		private static NativeContinuation CaptureContinuation(Context cx, Interpreter.CallFrame frame, bool requireContinuationsTopFrame)
		{
			NativeContinuation c = new NativeContinuation();
			ScriptRuntime.SetObjectProtoAndParent(c, ScriptRuntime.GetTopCallScope(cx));
			// Make sure that all frames are frozen
			Interpreter.CallFrame x = frame;
			Interpreter.CallFrame outermost = frame;
			while (x != null && !x.frozen)
			{
				x.frozen = true;
				// Allow to GC unused stack space
				for (int i = x.savedStackTop + 1; i != x.stack.Length; ++i)
				{
					// Allow to GC unused stack space
					x.stack[i] = null;
					x.stackAttributes[i] = ScriptableObject.EMPTY;
				}
				if (x.savedCallOp == Token.CALL)
				{
					// the call will always overwrite the stack top with the result
					x.stack[x.savedStackTop] = null;
				}
				else
				{
					if (x.savedCallOp != Token.NEW)
					{
						Kit.CodeBug();
					}
				}
				// the new operator uses stack top to store the constructed
				// object so it shall not be cleared: see comments in
				// setCallResult
				outermost = x;
				x = x.parentFrame;
			}
			if (requireContinuationsTopFrame)
			{
				while (outermost.parentFrame != null)
				{
					outermost = outermost.parentFrame;
				}
				if (!outermost.isContinuationsTopFrame)
				{
					throw new InvalidOperationException("Cannot capture continuation " + "from JavaScript code not called directly by " + "executeScriptWithContinuations or " + "callFunctionWithContinuations");
				}
			}
			c.InitImplementation(frame);
			return c;
		}