Esempio n. 1
0
 void QObjectHolder::takeOwner(QObject* obj){
     lock();
     Present* p=getFromMap(objects,obj);
     if (p!=NULL){
         p->p=false;
         p->thread=QThread::currentThread();
         notifyAll();
         p=getFromMap(objects,obj);
         while (p!=NULL){
             wait();
             p=getFromMap(objects,obj);
         }
     }
     unlock();
 }
Esempio n. 2
0
 JObjectInformation* JObjectInformations::getObjectInformation(JObject* object){
     JObjectInformation* oi;
     lock();
     oi=getFromMap(objectMap,object);
     unlock();
     return oi;
 }
Esempio n. 3
0
 JObjectInformation* JObjectInformations::getObjectInformation(JString* id){
     JObjectInformation* oi;
     lock();
     oi=getFromMap(idMap,id);
     unlock();
     return oi;
 }
Esempio n. 4
0
 JObject* JHashMap::get(JObject* key){
     if (key==NULL){
         key=NULL_KEY;
     }
     JObject* value=getFromMap(table,key);
     return value;
 }
Esempio n. 5
0
 JObjectInformation* JObjectInformations::unexport(JObject* object){
     JObjectInformation* objInfo;
     lock();
     objInfo = getFromMap(objectMap,object);
     unlock();
     if (objInfo != NULL) {
         return unexport(objInfo->getId());
     }
     return NULL;
 }
Esempio n. 6
0
void JTransportRouter::addRoute(JString localSite,JString remoteSite, JRoute* route) {
    lock();
    map<JString,JRoute*>* internalMap=getFromMap(routes,localSite);
    if (internalMap==NULL) {
        internalMap=new map<JString,JRoute*>();
        routes->insert(pair<JString,map<JString,JRoute*>*>(localSite,internalMap));
    }
    internalMap->insert(pair<JString,JRoute*>(remoteSite,route));
    unlock();
}
Esempio n. 7
0
        void JObject::link(JObject* o){
            if (o!=NULL){
                memoryMutex->lock();
                JINT* i=getFromMap(toObject,o);
                if (i==NULL){
                    i=new JINT(0);
                    toObject->insert(pair<JObject*,JINT*>(o,i));
                }
                i->increment();

                JINT* j=getFromMap(o->fromObject,this);
                if (j==NULL){
                    j=new JINT(0);
                    o->fromObject->insert(pair<JObject*,JINT*>(this,j));
                }
                j->increment();
                memoryMutex->unlock();
            }
        }
Esempio n. 8
0
 void JObjectInformations::doExport(JString* id, JObject* object, vector<JClass*>* interfaces){
     JObjectInformation* objInfo;
     lock();
     objInfo=getFromMap(idMap,id);
     if (objInfo != NULL) {
         throw new JConnectionException("Object[" + object->toString() + "] with ID[" + id->toString() + "] already exists in ObjectInformations idMap");
     }
     objInfo=getFromMap(objectMap,object);
     if ( objInfo!= NULL) {
         throw new JConnectionException("Object[" + object->toString() + "] with ID[" + id->toString() + "] already exists in ObjectInformations objectMap");
     }
     objInfo = new JObjectInformation(id, object, interfaces, this, lifecycle, gc);
     idMap->insert(pair<JString*,JObjectInformation*>(id, objInfo));
     objectMap->insert(pair<JObject*,JObjectInformation*>(object, objInfo));
     if (idMap->size() == 1) {
         transport->startExport();
     }
     unlock();
     objInfo->exported();
 }
Esempio n. 9
0
 JConnections* JTransport::getConnections(JEndPoint* remoteEndPoint){
     JConnections* connections=NULL;
     lock();
     connections=getFromMap(remoteConnectionsMap,remoteEndPoint);
     if (connections==NULL){
         connections=new JConnections(remoteEndPoint,this);
         remoteConnectionsMap->insert(pair<JEndPoint*,JConnections*>(remoteEndPoint,connections));
     }
     unlock();
     return connections;
 }
Esempio n. 10
0
JRoute* JTransportRouter::findRoute(JString localSite, JEndPoint* remoteEndpoint) {
    JRoute* route=NULL;
    lock();
    if (remoteEndpoint!=NULL) {
        if (localSite==remoteEndpoint->getSite()) {
            route=new JRoute();
            route->addAddress(new JAddress(remoteEndpoint->getAddress()));
        } else {
            map<JString,JRoute*>* internalMap=getFromMap(routes,localSite);
            if (internalMap!=NULL) {
                route=getFromMap(internalMap,remoteEndpoint->getSite());
                if (route!=NULL) {
                    route=route->clone();
                    route->addAddress(new JAddress(remoteEndpoint->getAddress()));
                }
            }
        }
    }
    unlock();
    return route;
}
Esempio n. 11
0
 JClass* JPrimitiveArray::getClazz(JClass* componentType){
     getLockObject()->lock();
     if (jPrimitiveArrayClasses==NULL){
         jPrimitiveArrayClasses=new map<JString,JPrimitiveArrayClass*>();
     }
     JPrimitiveArrayClass* jPrimitiveArrayClass=getFromMap(jPrimitiveArrayClasses,componentType->getName());
     if (jPrimitiveArrayClass==NULL){
         jPrimitiveArrayClass=new JPrimitiveArrayClass(componentType);
         jPrimitiveArrayClasses->insert(pair<JString,JPrimitiveArrayClass*>(componentType->getName(),jPrimitiveArrayClass));
     }
     getLockObject()->unlock();
     return jPrimitiveArrayClass;
 }
Esempio n. 12
0
 JObjectInformation* JObjectInformations::remove(JString* id){
     JObjectInformation* objInfo;
     lock();
     objInfo = getFromMap(idMap,id);
     if (objInfo != NULL) {
         idMap->erase(id);
         objectMap->erase(objInfo->getObject());
         if (idMap->size() == 0) {
             transport->stopExport();
         }
     }
     unlock();
     return objInfo;
 }
Esempio n. 13
0
 void JGCClient::add(map<JObjectPointer*, JObject*,JObjectPointer::POINTER_COMPARATOR>* objectPointers){
     lock();
     map<JObjectPointer*,JObject*,JObjectPointer::POINTER_COMPARATOR>::iterator it=objectPointers->begin();
     for (;it!=objectPointers->end();it++){
         JEndPoint* remoteEndPoint = (*it).first->getEndPoint();
         JGCClientEndPointInfo* endPointInfo = getFromMap(endPointInfos,remoteEndPoint);
         if (endPointInfo == NULL) {
             endPointInfo = new JGCClientEndPointInfo(this,localServer,remoteEndPoint);
             endPointInfos->insert(pair<JEndPoint*,JGCClientEndPointInfo*>(remoteEndPoint, endPointInfo));
         }
         endPointInfo->doExport((*it).first->getId(), (*it).second);
     }
     unlock();
 }
Esempio n. 14
0
        void JObject::unlink(JObject* o){
            if (o!=NULL){
                memoryMutex->lock();
                JINT* i=getFromMap(toObject,o);
                if (i!=NULL){
                    i->decrement();
                    if (i->getValue()==0){
                        toObject->erase(o);
                        delete i;
                    }
                }

                JINT* j=getFromMap(o->fromObject,this);
                if (j!=NULL){
                    j->decrement();
                    if (j->getValue()==0){
                        o->fromObject->erase(this);
                        delete j;
                        o->finalize();
                    }
                }
                memoryMutex->unlock();
            }
        }
Esempio n. 15
0
 ConstCacheObjectPtr get( const CacheId& cacheId ) const
 {
     return getFromMap( cacheId );
 }
Esempio n. 16
0
void Semantic::traverse(Exp * cur) {
  if (cur->v == Exp::ICONST_T || cur->v == Exp::STRLIT_T ||
      cur->v == Exp::CHRLIT_T || cur->v == Exp::BOLLIT_T ||
      cur->v == Exp::NULL_T) {
    //we're dealing with a constant here, ensure int constant in 0 2^31
    if (cur->v == Exp::ICONST_T)
      if (cur->id.length() == std::string("2147483647").length() && cur->id > "2147483647")
	error("integer literal constants must be < 2^31");
  }
  else if (cur->v == Exp::ID_T) {
    //variable
    getSym(cur->id);
  }
  else if (cur->v == Exp::UNOP_T) {
    //ensure subexp type is char or int
    Type l = expType(cur->l);
    if (!(sameType(l, Type(Type::INT_T)) || sameType(l, Type(Type::CHAR_T)) || sameType(l, Type(Type::BOOL_T))))
      error("unop must be applied to expression of type int or char");
    traverse(cur->l);
  }
  else if (cur->v == Exp::BINOP_T) {
    //if <=, <, >, >= ensure int or char
    //if != or == ensure int bool char t[] or t*
    Type l = expType(cur->l), r = expType(cur->r);
    if (cur->id == "==" || cur->id == "!=");
      
    if (!(sameType(l, Type(Type::INT_T)) || sameType(l, Type(Type::CHAR_T)) || sameType(l, Type(Type::BOOL_T))))
      error("binop must be applied to expression of type int or char or bool");
    else if (!(sameType(r, Type(Type::INT_T)) || sameType(r, Type(Type::CHAR_T)) || sameType(r, Type(Type::BOOL_T))))
      error("binop must be applied to expression of type int or char or bool");
    traverse(cur->l);
    traverse(cur->r);
  }
  else if (cur->v == Exp::IFLINE_T) {
    Type l = expType(cur->l);
    if (!(sameType(l, Type(Type::INT_T)) || sameType(l, Type(Type::CHAR_T)) || sameType(l, Type(Type::BOOL_T))))
      error("Condition must be of type bool");
    traverse(cur->l);
    traverse(cur->m);
    traverse(cur->r);
  }
  else if (cur->v == Exp::FCALL_T) {
    if (cur->id == "print" || cur->id == "read_int") return;
    
    Symbol func = getSym(cur->id);
    if (func.decl == NULL && func.defn == NULL) {
      error("call to undeclared function " + cur->id);
      return;
    }
    ArgItem * ptr = (func.decl != NULL) ? func.decl->list : func.defn->args;
    ExpItem * old = cur->args;
    while (ptr != NULL) {
      if (old == NULL) {
	error("bad argument passed to function " + cur->id);
	break;
      }

      if (!sameType(*(ptr->arg->type), expType(old->exp))) {
	error("bad argument passed to function " + cur->id);
	break;
      }
      traverse(old->exp);
      ptr = ptr->next;
      old = old->next;
    }
    if (old != NULL)
      error("bad argument passed to function " + cur->id);
  }
  else if (cur->v == Exp::DOT_T) {
    //see if type has that field
    Type t = expType(cur->l);
    if (t.v != Type::STRUCT_T)
      error("accessing field in a non-struct type");
    Symbol s = getFromMap(sid, t.str);
    bool hasField = false;
    ArgItem * ptr = s.defn->args;
    while (ptr != NULL) {
      if (ptr->arg->ID == cur->id) {
	hasField = true;
	break;
      }
      ptr = ptr->next;
    }
    if (!hasField)
      error("accessing non existing struct field " + cur->id);
  }
  else if (cur->v == Exp::ACC_T) {
    //see if type has that field
    Type t = expType(cur->l);
    if (t.v != Type::POINTER_T || t.type->v != Type::STRUCT_T)
      error("referencing field in a pointer to struct type");
    Symbol s = getFromMap(sid, t.type->str);
    bool hasField = false;
    ArgItem * ptr = s.defn->args;
    while (ptr != NULL) {
      if (ptr->arg->ID == cur->id) {
	hasField = true;
	break;
      }
      ptr = ptr->next;
    }
    if (!hasField)
      error("referencing non existing struct field " + cur->id);
  }
  else if (cur->v == Exp::SUBSC_T) {
    //see if subst is char or int and other type is vector
    Type l = expType(cur->l);
    Type r = expType(cur->r);
    if (l.v != Type::VECTOR_T)
      error("accessing index in non-vector type");
    if (!(sameType(r, Type(Type::INT_T)) || sameType(r, Type(Type::CHAR_T)) || sameType(r, Type(Type::BOOL_T))))
      error("index type must be int or char");
    traverse(cur->l);
    traverse(cur->r);
  }
  else if (cur->v == Exp::ALLOC_T) {
    //return the little thing allocated in memory (heap?)
    if (cur->t->v != Type::STRUCT_T)
      error("cannot alloc non-struct type");
  }
  else if (cur->v == Exp::ALLOCARRAY_T) {
    //return the little thing[] allocated in memory (heap?)
    Type r = expType(cur->l);
    if (!(sameType(r, Type(Type::INT_T)) || sameType(r, Type(Type::CHAR_T)) || sameType(r, Type(Type::BOOL_T))))
      error("alloc_array size must be type int");
    traverse(cur->l);
  }
}