void ImageBitmapFactories::ImageBitmapLoader::rejectPromise()
{
    m_resolver->reject(ScriptValue(m_resolver->scriptState(), v8::Null(m_resolver->scriptState()->isolate())));
    m_factory->didFinishLoading(this);
}
// CustomElementDefinition
ScriptValue ScriptCustomElementDefinition::getConstructorForScript() {
  return ScriptValue(m_scriptState.get(), constructor());
}
Ejemplo n.º 3
0
ScriptValue InjectedScriptHost::InspectableObject::get(JSC::ExecState*)
{
    return ScriptValue();
};
Ejemplo n.º 4
0
ScriptValue WebGLAny(ScriptState* scriptState, float value) {
  return ScriptValue(scriptState,
                     v8::Number::New(scriptState->isolate(), value));
}
Ejemplo n.º 5
0
ScriptValue WebGLAny(ScriptState* scriptState, WebGLObject* value) {
  return ScriptValue(scriptState, toV8(value, scriptState->context()->Global(),
                                       scriptState->isolate()));
}
Ejemplo n.º 6
0
ScriptValue WebGLAny(ScriptState* scriptState, bool value) {
  return ScriptValue(scriptState, v8Boolean(value, scriptState->isolate()));
}
Ejemplo n.º 7
0
ScriptValue WebGLAny(ScriptState* scriptState, unsigned value) {
  return ScriptValue(
      scriptState, v8::Integer::NewFromUnsigned(scriptState->isolate(),
                                                static_cast<unsigned>(value)));
}
Ejemplo n.º 8
0
 void disconnect()
 {
     m_devtoolsApiObject = ScriptValue();
     m_devtoolsHost = nullptr;
 }
ScriptValue V0CustomElementConstructorBuilder::bindingsReturnValue() const
{
    return ScriptValue(m_scriptState.get(), m_constructor);
}
Ejemplo n.º 10
0
ScriptValue WebGLAny(ScriptState* scriptState, PassRefPtr<DOMUint32Array> value)
{
    return ScriptValue(scriptState, toV8(value, scriptState->context()->Global(), scriptState->isolate()));
}
void MainThreadDebugger::xpathSelectorCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    if (info.Length() < 1)
        return;
    String selector = toCoreStringWithUndefinedOrNullCheck(info[0]);
    if (selector.isEmpty())
        return;
    Node* node = secondArgumentAsNode(info);
    if (!node || !node->isContainerNode())
        return;

    ExceptionState exceptionState(ExceptionState::ExecutionContext, "$x", "CommandLineAPI", info.Holder(), info.GetIsolate());
    XPathResult* result = XPathEvaluator::create()->evaluate(selector, node, nullptr, XPathResult::ANY_TYPE, ScriptValue(), exceptionState);
    if (exceptionState.throwIfNeeded() || !result)
        return;
    if (result->resultType() == XPathResult::NUMBER_TYPE) {
        info.GetReturnValue().Set(toV8(result->numberValue(exceptionState), info.Holder(), info.GetIsolate()));
    } else if (result->resultType() == XPathResult::STRING_TYPE) {
        info.GetReturnValue().Set(toV8(result->stringValue(exceptionState), info.Holder(), info.GetIsolate()));
    } else if (result->resultType() == XPathResult::BOOLEAN_TYPE) {
        info.GetReturnValue().Set(toV8(result->booleanValue(exceptionState), info.Holder(), info.GetIsolate()));
    } else {
        v8::Isolate* isolate = info.GetIsolate();
        v8::Local<v8::Context> context = isolate->GetCurrentContext();
        v8::Local<v8::Array> nodes = v8::Array::New(isolate);
        size_t index = 0;
        while (Node* node = result->iterateNext(exceptionState)) {
            if (exceptionState.throwIfNeeded())
                return;
            if (!createDataPropertyInArray(context, nodes, index++, toV8(node, info.Holder(), info.GetIsolate())).FromMaybe(false))
                return;
        }
        info.GetReturnValue().Set(nodes);
    }
    exceptionState.throwIfNeeded();
}
Ejemplo n.º 12
0
ScriptValue WebGLAny(ScriptState* scriptState, PassRefPtrWillBeRawPtr<WebGLObject> value)
{
    return ScriptValue(scriptState, toV8(value, scriptState->context()->Global(), scriptState->isolate()));
}
Ejemplo n.º 13
0
ScriptValue ScriptValue::deserialize(ScriptState* scriptState, SerializedScriptValue* value)
{
    return ScriptValue(value->deserialize(scriptState, scriptState->lexicalGlobalObject()));
}
Ejemplo n.º 14
0
	// set return value for current opcode
	void setReturn(DWORD value, SfallDataType type) {
		_ret = ScriptValue(type, value);
	}
Ejemplo n.º 15
0
ScriptPromise ReadableStreamReader::cancel(ScriptState* scriptState)
{
    return cancel(scriptState, ScriptValue(scriptState, v8::Undefined(scriptState->isolate())));
}
Ejemplo n.º 16
0
ScriptValue ScriptValue::createNull(ScriptState* scriptState)
{
    return ScriptValue(scriptState, v8::Null(scriptState->isolate()));
}
Ejemplo n.º 17
0
ScriptValue WebCLKernel::getWorkGroupInfo(ScriptState* scriptState, WebCLDevice* device, int paramName, ExceptionState& es)
{
    v8::Handle<v8::Object> creationContext = scriptState->context()->Global();
    v8::Isolate* isolate = scriptState->isolate();

    if (isReleased()) {
        es.throwWebCLException(WebCLException::INVALID_KERNEL, WebCLException::invalidKernelMessage);
        return ScriptValue(scriptState, v8::Null(isolate));
    }

    cl_device_id clDevice = nullptr;
    Vector<RefPtr<WebCLDevice>> deviceList = context()->getDevices();
    if (device) {
        clDevice = device->getDeviceId();
        if (!clDevice) {
            es.throwWebCLException(WebCLException::INVALID_DEVICE, WebCLException::invalidDeviceMessage);
            return ScriptValue(scriptState, v8::Null(isolate));
        }

        size_t i;
        for (i = 0; i < deviceList.size(); i ++) {
            if (clDevice == deviceList[i]->getDeviceId())
                break;
        }

        if (i == deviceList.size()) {
            es.throwWebCLException(WebCLException::INVALID_DEVICE, WebCLException::invalidDeviceMessage);
            return ScriptValue(scriptState, v8::Null(isolate));
        }
    }

    if (!device && deviceList.size() != 1) {
        es.throwWebCLException(WebCLException::INVALID_DEVICE, WebCLException::invalidDeviceMessage);
        return ScriptValue(scriptState, v8::Null(isolate));
    }

    cl_int err = CL_SUCCESS;
    size_t sizetUnits = 0;
    size_t workGroupSize[3] = {0};
    cl_ulong ulongUnits = 0;
    switch (paramName) {
    case CL_KERNEL_WORK_GROUP_SIZE:
        err = clGetKernelWorkGroupInfo(m_clKernel, clDevice, CL_KERNEL_WORK_GROUP_SIZE, sizeof(size_t), &sizetUnits, nullptr);
        if (err == CL_SUCCESS)
            return ScriptValue(scriptState, v8::Integer::NewFromUnsigned(isolate, static_cast<unsigned>(sizetUnits)));
        break;
    case CL_KERNEL_PRIVATE_MEM_SIZE:
        err = clGetKernelWorkGroupInfo(m_clKernel, clDevice, CL_KERNEL_PRIVATE_MEM_SIZE, sizeof(cl_ulong), &ulongUnits, nullptr);
        if (err == CL_SUCCESS)
            return ScriptValue(scriptState, v8::Integer::NewFromUnsigned(isolate, static_cast<unsigned long long>(ulongUnits)));
        break;
    case CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE:
        err = clGetKernelWorkGroupInfo(m_clKernel, clDevice, CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE, sizeof(size_t), &sizetUnits, nullptr);
        if (err == CL_SUCCESS)
            return ScriptValue(scriptState, v8::Integer::NewFromUnsigned(isolate, static_cast<unsigned>(sizetUnits)));
        break;
    case CL_KERNEL_COMPILE_WORK_GROUP_SIZE:
        err = clGetKernelWorkGroupInfo(m_clKernel, clDevice, CL_KERNEL_COMPILE_WORK_GROUP_SIZE, sizeof(workGroupSize), &workGroupSize, nullptr);
        if (err == CL_SUCCESS) {
            Vector<unsigned> values;
            for (unsigned i = 0; i < 3; ++i)
                values.append((unsigned)workGroupSize[i]);
            return ScriptValue(scriptState, toV8(values, creationContext, isolate));
        }
        break;
    case CL_KERNEL_LOCAL_MEM_SIZE:
        err = clGetKernelWorkGroupInfo(m_clKernel, clDevice, CL_KERNEL_LOCAL_MEM_SIZE, sizeof(cl_ulong), &ulongUnits, nullptr);
        if (err == CL_SUCCESS)
            return ScriptValue(scriptState, v8::Integer::NewFromUnsigned(isolate, static_cast<unsigned long long>(ulongUnits)));
        break;
    default:
        es.throwWebCLException(WebCLException::INVALID_VALUE, WebCLException::invalidValueMessage);
        return ScriptValue(scriptState, v8::Null(isolate));
    }

    WebCLException::throwException(err, es);
    return ScriptValue(scriptState, v8::Null(isolate));
}
Ejemplo n.º 18
0
ScriptValue InjectedScriptHost::nodeAsScriptValue(ScriptState* state, Node* node)
{
    JSLockHolder lock(state);
    return ScriptValue(state->globalData(), toJS(state, deprecatedGlobalObjectForPrototype(state), node));
}
Ejemplo n.º 19
0
ScriptValue WebGLAny(ScriptState* scriptState, int value) {
  return ScriptValue(scriptState,
                     v8::Integer::New(scriptState->isolate(), value));
}
Ejemplo n.º 20
0
ScriptValue ScriptValue::deserialize(ScriptState* scriptState, SerializedScriptValue* value)
{
    ScriptScope scope(scriptState);
    return ScriptValue(value->deserialize());
}
Ejemplo n.º 21
0
ScriptValue WebGLAny(ScriptState* scriptState, uint64_t value) {
  return ScriptValue(scriptState, v8::Number::New(scriptState->isolate(),
                                                  static_cast<double>(value)));
}
static void methodMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    if (UNLIKELY(info.Length() < 1)) {
        throwTypeError(ExceptionMessages::failedToExecute("method", "TestMediaQueryListListener", ExceptionMessages::notEnoughArguments(1, info.Length())), info.GetIsolate());
        return;
    }
    TestMediaQueryListListener* imp = V8TestMediaQueryListListener::toNative(info.Holder());
    V8TRYCATCH_VOID(RefPtr<MediaQueryListListener>, listener, MediaQueryListListener::create(ScriptValue(info[0], info.GetIsolate())));
    imp->method(listener);
}
Ejemplo n.º 23
0
ScriptValue WebGLAny(ScriptState* scriptState, String value) {
  return ScriptValue(scriptState, v8String(scriptState->isolate(), value));
}
Ejemplo n.º 24
0
ScriptValue ScriptValue::deserialize(ScriptState* scriptState, SerializedScriptValue* value, SerializationErrorMode throwExceptions)
{
    return ScriptValue(scriptState->vm(), value->deserialize(scriptState, scriptState->lexicalGlobalObject(), 0, throwExceptions));
}
Ejemplo n.º 25
0
ScriptValue WebGLAny(ScriptState* scriptState, DOMFloat32Array* value) {
  return ScriptValue(scriptState, toV8(value, scriptState->context()->Global(),
                                       scriptState->isolate()));
}
Ejemplo n.º 26
0
bool ScriptInterpreter::execOpcode(byte opcode) {

	debugCN(kDebugScript, "opcode = %d (%s)\n", opcode, opcodeNames[opcode]);

	ScriptValue value1, value2, value3;
	uint32 temp;

	/* TODO: Put all opcodes into separate functions and into an array
			 (but only after all needed opcodes are known and frozen)
	*/

	switch (opcode) {

	case opRet:
		return false;

	case opPush:
		loadValue(value1);
		derefValue(value1);
		push(value1);
		return true;

	case opPush0:
		push(ScriptValue(0));
		return true;

	case opPush1:
		push(ScriptValue(1));
		return true;

	case opPushNeg1:
		push(ScriptValue(-1));
		return true;

	case opPop:
		loadValue(value1);
		pop(value2);
		copyValue(value1, value2);
		return true;

	case opMov:
		loadValue(value1);
		loadValue(value2);
		derefValue(value2);
		copyValue(value1, value2);
		return true;

	// Possibly join all jump variants into one opcode

	case opJmp:
		temp = _runningFunction->readUint32();
		debugCN(kDebugScript, "-> ofs = %08X\n", temp);
		_runningFunction->jumpAbsolute(temp);
		return true;

	case opJl:
		temp = _runningFunction->readUint32();
		if (_cmpFlags < 0) {
			debugCN(kDebugScript, "-> ofs = %08X\n", temp);
			_runningFunction->jumpAbsolute(temp);
		}
		return true;

	case opJle:
		temp = _runningFunction->readUint32();
		if (_cmpFlags <= 0) {
			debugCN(kDebugScript, "-> ofs = %08X\n", temp);
			_runningFunction->jumpAbsolute(temp);
		}
		return true;

	case opJg:
		temp = _runningFunction->readUint32();
		if (_cmpFlags > 0) {
			debugCN(kDebugScript, "-> ofs = %08X\n", temp);
			_runningFunction->jumpAbsolute(temp);
		}
		return true;

	case opJge:
		temp = _runningFunction->readUint32();
		if (_cmpFlags >= 0) {
			debugCN(kDebugScript, "-> ofs = %08X\n", temp);
			_runningFunction->jumpAbsolute(temp);
		}
		return true;

	case opJz:
		temp = _runningFunction->readUint32();
		if (_cmpFlags == 0) {
			debugCN(kDebugScript, "-> ofs = %08X\n", temp);
			_runningFunction->jumpAbsolute(temp);
		}
		return true;

	case opJnz:
		temp = _runningFunction->readUint32();
		if (_cmpFlags != 0) {
			debugCN(kDebugScript, "-> ofs = %08X\n", temp);
			_runningFunction->jumpAbsolute(temp);
		}
		return true;

	case opJmpByTable:
		temp = _runningFunction->readUint32();
		debugCN(kDebugScript, "-> index = %d\n", _registers[0].value);
		_runningFunction->jumpRelative(_registers[0].value * 4);
		temp = _runningFunction->readUint32();
		debugCN(kDebugScript, "-> ofs = %08X\n", temp);
		_runningFunction->jumpAbsolute(temp);
		return true;

	case opCmp:
		loadValue(value1);
		loadValue(value2);
		derefValue(value1);
		derefValue(value2);
		if (value1.type != kInteger || value2.type != kInteger)
			warning("ScriptInterpreter::execOpcode() Trying to compare non-integer values (%d, %d, line %d)", value1.type, value2.type, _lineNum);
		_cmpFlags = value1.value - value2.value;
		debugCN(kDebugScript, "-> cmp %d, %d\n", value1.value, value2.value);
		debugCN(kDebugScript, "-> _cmpFlags  = %d\n", _cmpFlags);
		return true;

	case opCall:
		temp = _runningFunction->readUint32();
		callFunction(temp);
		return true;

	case opCallKernel:
		temp = _runningFunction->readUint32();
		callKernelFunction(temp);
		return true;

	case opInc:
		loadValue(value1);
		value2 = value1;
		derefValue(value2);
		value2.value++;
		copyValue(value1, value2);
		return true;

	case opDec:
		loadValue(value1);
		value2 = value1;
		derefValue(value2);
		value2.value--;
		copyValue(value1, value2);
		return true;

	case opAdd:
		loadValue(value1);
		value3 = value1;
		loadValue(value2);
		derefValue(value3);
		derefValue(value2);
		value3.value += value2.value;
		copyValue(value1, value3);
		return true;

	case opSub:
		loadValue(value1);
		value3 = value1;
		loadValue(value2);
		derefValue(value3);
		derefValue(value2);
		value3.value -= value2.value;
		copyValue(value1, value3);
		return true;

	case opDebug:
		_lineNum = (int)_runningFunction->readUint32();
		return true;

	default:
		debugCN(kDebugScript, "Invalid opcode %d!\n", opcode);
		return false;

	}

}
Ejemplo n.º 27
0
void ConsoleMessage::addToFrontend(InspectorFrontend::Console* frontend, InjectedScriptManager* injectedScriptManager, bool generatePreview)
{
    RefPtr<TypeBuilder::Console::ConsoleMessage> jsonObj = TypeBuilder::Console::ConsoleMessage::create()
        .setSource(messageSourceValue(m_source))
        .setLevel(messageLevelValue(m_level))
        .setText(m_message)
        .setTimestamp(m_timestamp);
    // FIXME: only send out type for ConsoleAPI source messages.
    jsonObj->setType(messageTypeValue(m_type));
    jsonObj->setLine(static_cast<int>(m_line));
    jsonObj->setColumn(static_cast<int>(m_column));
    jsonObj->setUrl(m_url);
    jsonObj->setRepeatCount(static_cast<int>(m_repeatCount));
    if (m_source == NetworkMessageSource && !m_requestId.isEmpty())
        jsonObj->setNetworkRequestId(m_requestId);
    if (m_arguments && m_arguments->argumentCount()) {
        InjectedScript injectedScript = injectedScriptManager->injectedScriptFor(m_arguments->globalState());
        if (!injectedScript.hasNoValue()) {
            RefPtr<TypeBuilder::Array<TypeBuilder::Runtime::RemoteObject> > jsonArgs = TypeBuilder::Array<TypeBuilder::Runtime::RemoteObject>::create();
            if (m_type == TableMessageType && generatePreview && m_arguments->argumentCount()) {
                ScriptValue table = m_arguments->argumentAt(0);
                ScriptValue columns = m_arguments->argumentCount() > 1 ? m_arguments->argumentAt(1) : ScriptValue();
                RefPtr<TypeBuilder::Runtime::RemoteObject> inspectorValue = injectedScript.wrapTable(table, columns);
                if (!inspectorValue) {
                    ASSERT_NOT_REACHED();
                    return;
                }
                jsonArgs->addItem(inspectorValue);
            } else {
                for (unsigned i = 0; i < m_arguments->argumentCount(); ++i) {
                    RefPtr<TypeBuilder::Runtime::RemoteObject> inspectorValue = injectedScript.wrapObject(m_arguments->argumentAt(i), "console", generatePreview);
                    if (!inspectorValue) {
                        ASSERT_NOT_REACHED();
                        return;
                    }
                    jsonArgs->addItem(inspectorValue);
                }
            }
            jsonObj->setParameters(jsonArgs);
        }
    }
    if (m_callStack)
        jsonObj->setStackTrace(m_callStack->buildInspectorArray());
    frontend->messageAdded(jsonObj);
}
Ejemplo n.º 28
0
// Set a |promise|'s state and result that correspond to the state.
// |promise| must be a Promise instance.
void setStateForPromise(v8::Handle<v8::Object> promise, V8PromiseCustom::PromiseState state, v8::Handle<v8::Value> value, v8::Isolate* isolate)
{
    ASSERT(!value.IsEmpty());
    ASSERT(state == V8PromiseCustom::Pending || state == V8PromiseCustom::Fulfilled || state == V8PromiseCustom::Rejected || state == V8PromiseCustom::Following);
    v8::Local<v8::Object> internal = V8PromiseCustom::getInternal(promise);
    internal->SetInternalField(V8PromiseCustom::InternalStateIndex, v8::Integer::New(isolate, state));
    internal->SetInternalField(V8PromiseCustom::InternalResultIndex, value);
    ExecutionContext* context = currentExecutionContext(isolate);
    if (InspectorInstrumentation::isPromiseTrackerEnabled(context))
        InspectorInstrumentation::didUpdatePromiseState(context, ScriptObject(ScriptState::forContext(isolate->GetCurrentContext()), promise), state, ScriptValue(value, isolate));
}
Ejemplo n.º 29
0
ScriptValue ScriptController::callFunctionEvenIfScriptDisabled(v8::Handle<v8::Function> function, v8::Handle<v8::Object> receiver, int argc, v8::Handle<v8::Value> argv[])
{
    // FIXME: This should probably perform the same isPaused check that happens in ScriptController::executeScript.
    return ScriptValue(callFunction(function, receiver, argc, argv));
}
Ejemplo n.º 30
0
void JSDictionary::convertValue(ExecState* exec, JSValue value, ScriptValue& result)
{
    result = ScriptValue(exec->globalData(), value);
}