示例#1
0
JSStringIterator* JSStringIterator::clone(ExecState* exec)
{
    VM& vm = exec->vm();
    JSValue iteratedString = getDirect(vm, vm.propertyNames->builtinNames().iteratedStringPrivateName());
    JSValue nextIndex = getDirect(vm, vm.propertyNames->builtinNames().stringIteratorNextIndexPrivateName());

    auto clone = JSStringIterator::create(exec, exec->callee()->globalObject()->stringIteratorStructure(), asString(iteratedString));
    clone->putDirect(vm, vm.propertyNames->builtinNames().stringIteratorNextIndexPrivateName(), nextIndex);
    return clone;
}
示例#2
0
void JSGlobalObject::putWithAttributes(ExecState* exec, const Identifier& propertyName, JSValue* value, unsigned attributes)
{
    ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(this));

    if (symbolTablePutWithAttributes(propertyName, value, attributes))
        return;

    JSValue* valueBefore = getDirect(propertyName);
    PutPropertySlot slot;
    JSVariableObject::put(exec, propertyName, value, slot);
    if (!valueBefore) {
        if (JSValue* valueAfter = getDirect(propertyName))
            putDirect(propertyName, valueAfter, attributes);
    }
}
示例#3
0
void JSObject::defineSetter(ExecState* exec, const Identifier& propertyName, JSObject* setterFunction, unsigned attributes)
{
    JSValue object = getDirect(propertyName);
    if (object && object.isGetterSetter()) {
        ASSERT(m_structure->hasGetterSetterProperties());
        asGetterSetter(object)->setSetter(setterFunction);
        return;
    }

    PutPropertySlot slot;
    GetterSetter* getterSetter = new (exec) GetterSetter(exec);
    putDirectInternal(exec->globalData(), propertyName, getterSetter, attributes | Setter, true, slot);

    // putDirect will change our Structure if we add a new property. For
    // getters and setters, though, we also need to change our Structure
    // if we override an existing non-getter or non-setter.
    if (slot.type() != PutPropertySlot::NewProperty) {
        if (!m_structure->isDictionary()) {
            RefPtr<Structure> structure = Structure::getterSetterTransition(m_structure);
            setStructure(structure.release());
        }
    }

    m_structure->setHasGetterSetterProperties(true);
    getterSetter->setSetter(setterFunction);
}
void JSObject::defineSetter(ExecState* exec, const Identifier& propertyName, JSObject* setterFunction)
{
    JSValue* object = getDirect(propertyName);
    if (object && object->isGetterSetter()) {
        ASSERT(m_structureID->hasGetterSetterProperties());
        asGetterSetter(object)->setSetter(setterFunction);
        return;
    }

    PutPropertySlot slot;
    GetterSetter* getterSetter = new (exec) GetterSetter;
    putDirect(propertyName, getterSetter, None, true, slot);

    // putDirect will change our StructureID if we add a new property. For
    // getters and setters, though, we also need to change our StructureID
    // if we override an existing non-getter or non-setter.
    if (slot.type() != PutPropertySlot::NewProperty) {
        if (!m_structureID->isDictionary()) {
            RefPtr<StructureID> structureID = StructureID::getterSetterTransition(m_structureID);
            setStructureID(structureID.release());
        }
    }

    m_structureID->setHasGetterSetterProperties(true);
    getterSetter->setSetter(setterFunction);
}
示例#5
0
void PathFinder::runActionFight(float dt) {
	TEActionState actionState = _fightAnimations->runDirect(this, getDirect(), dt);
	if(actionState == eActionStateEnd) {
		PathFinder* enemy = this->getTargetSprite();
		enemy->setHealth(enemy->getHealth() - this->getAttack());
	}
}
示例#6
0
const UString InternalFunction::displayName(JSGlobalData* globalData)
{
    JSValue displayName = getDirect(globalData->propertyNames->displayName);
    
    if (displayName && isJSString(globalData, displayName))
        return asString(displayName)->value();
    
    return UString::null();
}
示例#7
0
const String InternalFunction::displayName(ExecState* exec)
{
    JSValue displayName = getDirect(exec->vm(), exec->vm().propertyNames->displayName);
    
    if (displayName && isJSString(displayName))
        return asString(displayName)->tryGetValue();
    
    return String();
}
示例#8
0
const UString InternalFunction::displayName(TiExcState* exec)
{
    TiValue displayName = getDirect(exec->globalData().propertyNames->displayName);
    
    if (displayName && isTiString(&exec->globalData(), displayName))
        return asString(displayName)->tryGetValue();
    
    return UString::null();
}
示例#9
0
const UString InternalFunction::displayName(ExecState* exec)
{
    JSValue displayName = getDirect(exec->globalData().propertyNames->displayName);
    
    if (displayName && isJSString(&exec->globalData(), displayName))
        return asString(displayName)->value(exec);
    
    return UString::null();
}
示例#10
0
String JSFunction::displayName(ExecState* exec)
{
    JSValue displayName = getDirect(exec->globalData(), exec->globalData().propertyNames->displayName);
    
    if (displayName && isJSString(displayName))
        return asString(displayName)->tryGetValue();
    
    return String();
}
示例#11
0
void JSDOMWindowBase::clear()
{
    JSLock lock(false);

    if (d()->returnValueSlot && !*d()->returnValueSlot)
        *d()->returnValueSlot = getDirect(Identifier(globalExec(), "returnValue"));

    clearHelperObjectProperties();
}
示例#12
0
void JSObject::defineSetter(ExecState*, const Identifier& propertyName, JSObject* setterFunc)
{
    JSValue *o = getDirect(propertyName);
    GetterSetterImp *gs;

    if (o && o->type() == GetterSetterType) {
        gs = static_cast<GetterSetterImp *>(o);
    } else {
        gs = new GetterSetterImp;
        putDirect(propertyName, gs, GetterSetter);
    }

    _prop.setHasGetterSetterProperties(true);
    gs->setSetter(setterFunc);
}
示例#13
0
TETraceResult PathFinder::naviByPath(double dt) {
	// 如果目标点无效,则不走
	if(getTarget().equals(INVALID_POINT)) {
		//stopAllActions();
		setTarget(INVALID_POINT);
		return eTraceResultFailure;
	}
	// 如果下一个路径点在地图外或是墙,则不走(应该不会出现这种情况)
	CCPoint targetTilePos = _map->realPosToTilePos(getTarget());
	if(int(targetTilePos.x + targetTilePos.y) == -2 || _map->getTileType(targetTilePos) == emWall) {
		//stopAllActions();
		setTarget(INVALID_POINT);
		return eTraceResultFailure;
	}
	// 如果已经到达目标点,则寻找下一个目标点
	if(getPosition().getDistanceSq(getTarget()) < 1) {
		//CCLog("reach half way pos");
		//stopAllActions();
		if(_currPathNode == _shortestPath.size() - 1) { // 如果目标点是最后一个,则寻路结束
			//stopAllActions();
			setTarget(INVALID_POINT);
			return eTraceResultSuccess;
		}
		else { // 如果目标点后面还有,则继续
			//CCLog("go to next pos");
			++_currPathNode;
			_target = _map->getNaviGraph().getNode(_shortestPath[_currPathNode]).getCenterPos();
			CCPoint toTarget = getTarget() - getPosition();
			setDirect(_map->getClosestDirect(toTarget.normalize()));
		}
	}
	// 根据不同的方向,执行不同的动作
	TEActionState actionState = _walkAnimations->runDirect(this, getDirect(), dt);
	// 走向目标点
	CCPoint tilePos = _map->realPosToTilePos(getPosition());
	int tileZorder = tilePos.x + tilePos.y;
	setZOrder(tileZorder);
	CCPoint toTarget = getTarget() - getPosition();
	toTarget = toTarget.normalize();
	setPosition(getPosition() + toTarget * _speed * dt);
	return eTraceResultHalfway;
}
示例#14
0
void JSDOMGlobalObject::addBuiltinGlobals(VM& vm)
{
    m_builtinInternalFunctions.initialize(*this);

#if ENABLE(READABLE_STREAM_API)
    JSObject* privateReadableStreamDefaultControllerConstructor = createReadableStreamDefaultControllerPrivateConstructor(vm, *this);
#if ENABLE(READABLE_BYTE_STREAM_API)
    JSObject* privateReadableByteStreamControllerConstructor = createReadableByteStreamControllerPrivateConstructor(vm, *this);
#endif
    JSObject* privateReadableStreamDefaultReaderConstructor = createReadableStreamDefaultReaderPrivateConstructor(vm, *this);

    ASSERT(!constructors(NoLockingNecessary).get(privateReadableStreamDefaultControllerConstructor->info()).get());
#if ENABLE(READABLE_BYTE_STREAM_API)
    ASSERT(!constructors(NoLockingNecessary).get(privateReadableByteStreamControllerConstructor->info()).get());
#endif
    ASSERT(!constructors(NoLockingNecessary).get(privateReadableStreamDefaultReaderConstructor->info()).get());
    JSC::WriteBarrier<JSC::JSObject> temp;
    {
        auto locker = lockDuringMarking(vm.heap, m_gcLock);
        constructors(locker).add(privateReadableStreamDefaultControllerConstructor->info(), temp).iterator->value.set(vm, this, privateReadableStreamDefaultControllerConstructor);
#if ENABLE(READABLE_BYTE_STREAM_API)
        constructors(locker).add(privateReadableByteStreamControllerConstructor->info(), temp).iterator->value.set(vm, this, privateReadableByteStreamControllerConstructor);
#endif
        constructors(locker).add(privateReadableStreamDefaultReaderConstructor->info(), temp).iterator->value.set(vm, this, privateReadableStreamDefaultReaderConstructor);
    }
#endif
    JSVMClientData& clientData = *static_cast<JSVMClientData*>(vm.clientData);
    JSDOMGlobalObject::GlobalPropertyInfo staticGlobals[] = {
        JSDOMGlobalObject::GlobalPropertyInfo(clientData.builtinNames().makeThisTypeErrorPrivateName(),
            JSFunction::create(vm, this, 2, String(), makeThisTypeErrorForBuiltins), DontDelete | ReadOnly),
        JSDOMGlobalObject::GlobalPropertyInfo(clientData.builtinNames().makeGetterTypeErrorPrivateName(),
            JSFunction::create(vm, this, 2, String(), makeGetterTypeErrorForBuiltins), DontDelete | ReadOnly),
        JSDOMGlobalObject::GlobalPropertyInfo(clientData.builtinNames().structuredCloneArrayBufferPrivateName(),
            JSFunction::create(vm, this, 1, String(), structuredCloneArrayBuffer), DontDelete | ReadOnly),
        JSDOMGlobalObject::GlobalPropertyInfo(clientData.builtinNames().structuredCloneArrayBufferViewPrivateName(),
            JSFunction::create(vm, this, 1, String(), structuredCloneArrayBufferView), DontDelete | ReadOnly),
        JSDOMGlobalObject::GlobalPropertyInfo(vm.propertyNames->builtinNames().ArrayBufferPrivateName(), getDirect(vm, vm.propertyNames->ArrayBuffer), DontDelete | ReadOnly),
#if ENABLE(READABLE_STREAM_API) || ENABLE(WRITABLE_STREAM_API)
        JSDOMGlobalObject::GlobalPropertyInfo(clientData.builtinNames().streamClosedPrivateName(), jsNumber(1), DontDelete | ReadOnly),
        JSDOMGlobalObject::GlobalPropertyInfo(clientData.builtinNames().streamClosingPrivateName(), jsNumber(2), DontDelete | ReadOnly),
        JSDOMGlobalObject::GlobalPropertyInfo(clientData.builtinNames().streamErroredPrivateName(), jsNumber(3), DontDelete | ReadOnly),
        JSDOMGlobalObject::GlobalPropertyInfo(clientData.builtinNames().streamReadablePrivateName(), jsNumber(4), DontDelete | ReadOnly),
        JSDOMGlobalObject::GlobalPropertyInfo(clientData.builtinNames().streamWaitingPrivateName(), jsNumber(5), DontDelete | ReadOnly),
        JSDOMGlobalObject::GlobalPropertyInfo(clientData.builtinNames().streamWritablePrivateName(), jsNumber(6), DontDelete | ReadOnly),
#endif
#if ENABLE(READABLE_STREAM_API)
        JSDOMGlobalObject::GlobalPropertyInfo(clientData.builtinNames().ReadableStreamDefaultControllerPrivateName(), privateReadableStreamDefaultControllerConstructor, DontDelete | ReadOnly),
#if ENABLE(READABLE_BYTE_STREAM_API)
        JSDOMGlobalObject::GlobalPropertyInfo(clientData.builtinNames().ReadableByteStreamControllerPrivateName(), privateReadableByteStreamControllerConstructor, DontDelete | ReadOnly),
#endif
        JSDOMGlobalObject::GlobalPropertyInfo(clientData.builtinNames().ReadableStreamDefaultReaderPrivateName(), privateReadableStreamDefaultReaderConstructor, DontDelete | ReadOnly),
#endif
    };
    addStaticGlobals(staticGlobals, WTF_ARRAY_LENGTH(staticGlobals));
}
示例#15
0
void PathFinder::runActionLaydown(float dt) {
	_laydownAnimations->runDirect(this, getDirect(), dt);
}
示例#16
0
bool JSObject::defineOwnProperty(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor, bool throwException)
{
    // If we have a new property we can just put it on normally
    PropertyDescriptor current;
    if (!getOwnPropertyDescriptor(exec, propertyName, current))
        return putDescriptor(exec, this, propertyName, descriptor, descriptor.attributes(), jsUndefined());

    if (descriptor.isEmpty())
        return true;

    if (current.equalTo(descriptor))
        return true;

    // Filter out invalid changes
    if (!current.configurable()) {
        if (descriptor.configurable()) {
            if (throwException)
                throwError(exec, TypeError, "Attempting to configurable attribute of unconfigurable property.");
            return false;
        }
        if (descriptor.enumerablePresent() && descriptor.enumerable() != current.enumerable()) {
            if (throwException)
                throwError(exec, TypeError, "Attempting to change enumerable attribute of unconfigurable property.");
            return false;
        }
    }

    // A generic descriptor is simply changing the attributes of an existing property
    if (descriptor.isGenericDescriptor()) {
        if (!current.attributesEqual(descriptor)) {
            deleteProperty(exec, propertyName);
            putDescriptor(exec, this, propertyName, descriptor, current.attributesWithOverride(descriptor), current.value());
        }
        return true;
    }

    // Changing between a normal property or an accessor property
    if (descriptor.isDataDescriptor() != current.isDataDescriptor()) {
        if (!current.configurable()) {
            if (throwException)
                throwError(exec, TypeError, "Attempting to change access mechanism for an unconfigurable property.");
            return false;
        }
        deleteProperty(exec, propertyName);
        return putDescriptor(exec, this, propertyName, descriptor, current.attributesWithOverride(descriptor), current.value() ? current.value() : jsUndefined());
    }

    // Changing the value and attributes of an existing property
    if (descriptor.isDataDescriptor()) {
        if (!current.configurable()) {
            if (!current.writable() && descriptor.writable()) {
                if (throwException)
                    throwError(exec, TypeError, "Attempting to change writable attribute of unconfigurable property.");
                return false;
            }
            if (!current.writable()) {
                if (descriptor.value() || !JSValue::strictEqual(current.value(), descriptor.value())) {
                    if (throwException)
                        throwError(exec, TypeError, "Attempting to change value of a readonly property.");
                    return false;
                }
            }
        } else if (current.attributesEqual(descriptor)) {
            if (!descriptor.value())
                return true;
            PutPropertySlot slot;
            put(exec, propertyName, descriptor.value(), slot);
            if (exec->hadException())
                return false;
            return true;
        }
        deleteProperty(exec, propertyName);
        return putDescriptor(exec, this, propertyName, descriptor, current.attributesWithOverride(descriptor), current.value());
    }

    // Changing the accessor functions of an existing accessor property
    ASSERT(descriptor.isAccessorDescriptor());
    if (!current.configurable()) {
        if (descriptor.setterPresent() && !(current.setter() && JSValue::strictEqual(current.setter(), descriptor.setter()))) {
            if (throwException)
                throwError(exec, TypeError, "Attempting to change the setter of an unconfigurable property.");
            return false;
        }
        if (descriptor.getterPresent() && !(current.getter() && JSValue::strictEqual(current.getter(), descriptor.getter()))) {
            if (throwException)
                throwError(exec, TypeError, "Attempting to change the getter of an unconfigurable property.");
            return false;
        }
    }
    JSValue accessor = getDirect(propertyName);
    if (!accessor)
        return false;
    GetterSetter* getterSetter = asGetterSetter(accessor);
    if (current.attributesEqual(descriptor)) {
        if (descriptor.setter())
            getterSetter->setSetter(asObject(descriptor.setter()));
        if (descriptor.getter())
            getterSetter->setGetter(asObject(descriptor.getter()));
        return true;
    }
    deleteProperty(exec, propertyName);
    unsigned attrs = current.attributesWithOverride(descriptor);
    if (descriptor.setter())
        attrs |= Setter;
    if (descriptor.getter())
        attrs |= Getter;
    putDirect(propertyName, getterSetter, attrs);
    return true;
}
示例#17
0
const UString& InternalFunction::name(ExecState* exec)
{
    return asString(getDirect(exec->globalData().propertyNames->name))->tryGetValue();
}
	float get(const Point3D &pt) const{return getDirect(pt.x, pt.y, pt.z);}
bool InspectorInstrumentationObject::isEnabled(VM& vm) const
{
    return getDirect(vm, vm.propertyNames->isEnabled).asBoolean();
}
示例#20
0
JSValue JSPromise::result(VM& vm) const
{
    return getDirect(vm, vm.propertyNames->builtinNames().promiseResultPrivateName());
}
示例#21
0
JSValue JSStringIterator::iteratedValue(ExecState* exec) const
{
    return getDirect(exec->vm(), exec->vm().propertyNames->builtinNames().iteratedStringPrivateName());
}
示例#22
0
void ws_maker(){
	//printf("%d\n",getMax());
	char *s = dictionary[getMax()];
	int len = strlen(s);
	input(MID-len/2,MID,s,DOWN);
	printf("0 %s\n",s);

	for(int i=0; i<dictSize-1-4;i++){
		int judge=0;
		s = dictionary[getMax()];

		getMaxAndMin_X_Y();
		int max=-1,x=0,y=0,d=0,sizeX = 1000, sizeY = 1000;
		for(int j=1;j<1000 ;j++){
			getWhere(j);
			int xxx,kongtime=0;      //xxx isbetter 返回
			int bd = getDirect(a[0],a[1]);
			for(int k=0; k<8; k++){

				xxx = isbetter(a[0],a[1],s,(bd+k-1)%8);

				if(xxx == -2){
					kongtime++;
					xxx = 0;
				}
				if(xxx == -1)
					continue;

				if(max_x - min_x > max_y - min_y){
					if(max_x_new <= max_x && min_x_new >= min_x){
						if(max_y_new - min_y_new < sizeY){
							x = a[0];
							y = a[1];
							d = (bd+k-1)%8;
							max = xxx;
							sizeY = max_y_new - min_y_new;
						}
						else if( max_y_new - min_y_new == sizeY ){
							if(max < xxx){
								x = a[0];
								y = a[1];
								d = (bd+k-1)%8;
								max = xxx;
							}
						}
					}

				}
				else{
					if(max_y_new <= max_y && min_y_new >= min_y){
						if(max_x_new - min_x_new < sizeX){
							x = a[0];
							y = a[1];
							d = (bd+k-1)%8;
							max = xxx;
							sizeX = max_x_new - min_x_new;
						}
						else if( max_x_new - min_x_new == sizeX ){
							if(max < xxx){
								x = a[0];
								y = a[1];
								d = (bd+k-1)%8;
								max = xxx;
							}
						}
					}
				}


				
			}
			if(kongtime == 8)
				break;
		}
		// if(debug){
		// 	printf("%d %d %d %s %d\n",i+1,x,y,s,d);
		// }
		input(x,y,s,d);
	}
}
示例#23
0
const UString& InternalFunction::name(JSGlobalData* globalData)
{
    return asString(getDirect(globalData->propertyNames->name))->value();
}
示例#24
0
void PathFinder::runActionStand(float dt) {
	_standAnimations->runDirect(this, getDirect(), dt);
}