Beispiel #1
0
f8_status alloc_blk_reg_list(IBlk * b, HREG_LIST *h)
{
	CRegRequirementList * req;
	f8_status code;

	req = new CRegRequirementList;
	if(!req){
		return F8_LOW_MEMORY;
	}
	
	_traverse(b, _alloc_var_proc, (__uint)req);
	if(F8_FAILED(req->m_errcode)){
		*h = 0;
		code = req->m_errcode;
		delete req;
		return code;
	}

	_traverse(b, _alloc_reg_proc, (__uint)req);
	if(F8_FAILED(req->m_errcode)){
		*h = 0;
		code = req->m_errcode;
		delete req;
		return code;
	}
	
	*h = (HREG_LIST)req;

	return F8_SUCCESS;
}
    TreeNode* _traverse(TreeNode* node, TreeNode* head) {
        if (node == NULL) return head;

        head = _traverse(node->right, head);
        head = _traverse(node->left, head);
        node->right = head;
        node->left = NULL;
        head = node;
        return head;
    }
Beispiel #3
0
/*	=================== _traverse =================== 
	Inorder tree traversal. To process a node, we use 
	the function passed when traversal was called.
	   Pre   Tree has been created (may be null) 
	   Post  All nodes processed 
*/
static void _traverse (BSTNODE* root, void (*process) (PACKAGE* package)) 
{
    if (root)
	{
		_traverse (root->left, process);
		process ( root->ptrPackage );
        _traverse (root->right, process); 
    }
    return;
}// _traverse
Beispiel #4
0
void _traverse(Tobj *pTernary, Tptr p) {
  
  char** foo;

  if (!p) return;
  _traverse(pTernary, p->lokid);
  if (p->splitchar)
    _traverse(pTernary, p->eqkid);
  else {
    foo = pTernary->searchchar;
    foo[pTernary->searchn] = (char *) p->eqkid;
    pTernary->searchn++;
  }
  _traverse(pTernary, p->hikid);
}
Beispiel #5
0
/* allocate a DirEntry in the directory `dirEntry'
 * its address in filesystem is returned in addr
 */
int allocateDirEntry(DirEntry *dirEntry,ULONG * value_addr) {
    int result = _traverse(dirEntry,traverse_availableDirEntry,value_addr);
    /* result == 1 means all clusters of dirEntry were searched
     * which means we can not found a available entry
     * allocate a new cluster to get one
     */
    if( result == 1 ) {
#ifdef DEBUG
        printf("No available Dir Entry in current cluster !\n");
#endif
        /* search the last cluster in the FAT chain
         * allocate a new cluster and append it to the last cluster
         */
        ULONG startCluster = getDirClusterNum(dirEntry);
        ULONG last = getLastCluster(startCluster);
        ULONG newCluster = allocateCluster();
        if( newCluster == 0 )
            report_exit("Not enough space!\n");

        FAT[last] = newCluster;
        FAT[newCluster] = EOD;
        updateAllFat();
        /* allocate the first dir entry in the cluster */
        *value_addr = (cluster2sector( newCluster ) * bps);
    }
#ifdef DEBUG
    printf("Allocated dirEntry address: 0x%08x\n",(int)*value_addr);
#endif
    return 1;
}
Beispiel #6
0
void Selector::operator=(const char *s) const {
    _traverse();
    auto push = [this, s]() {
        detail::_push(_state._l, std::string{s});
    };
    _put(push);
    lua_settop(_state._l, 0);
}
Beispiel #7
0
Selector::operator std::string() const {
    _traverse();
    _get();
    if (_functor != nullptr) {
        (*_functor)(1);
        _functor.reset();
    }
    auto ret =  detail::_pop(detail::_id<std::string>{}, _state._l);
    lua_settop(_state._l, 0);
    return ret;
}
Beispiel #8
0
/*
	find an existing block's register usage.
*/
f8_status gather_blk_reg_list(IBlk *b, HREG_LIST *h)
{
	CRegRequirementList * req;
	req = new CRegRequirementList;
	if(!req){
		return F8_LOW_MEMORY;
	}
	req->m_bGatherForDelete = true;
	_traverse(b, _gather_reg_usage, (__uint)req);
	*h = (HREG_LIST)req;
	return F8_SUCCESS;
}
Beispiel #9
0
void Selector::_check_create_table() {
    _traverse();
    _get();
    if (lua_istable(_state._l, -1) == 0 ) { // not table
        lua_pop(_state._l, 1); // flush the stack
        auto put = [this]() {
            lua_newtable(_state._l);
        };
        _put(put);
    } else {
        lua_pop(_state._l, 1);
    }
}
Beispiel #10
0
Selector::operator int() const {
    _traverse();
    //std::cout << _name << " " << _state << std::endl;
    _get();
    if (_functor != nullptr) {
        //std::cout << _name << " " << _state << std::endl;
        (*_functor)(1);
        _functor.reset();
    }
    auto ret = detail::_pop(detail::_id<int>{}, _state._l);
    lua_settop(_state._l, 0);
    return ret;
}
Beispiel #11
0
/*
	reconstruct register usage map.
	called upon opening project and uploading project
*/
__bool build_reg_map()
{
	CRegRequirementList req;

	req.m_bGatherForDelete = false;
	_traverse(sections, _gather_reg_usage, (__uint)&req);
	if(F8_FAILED(req.m_errcode)){
		utils_error("Warning : _gather_reg_usage failed %d(%s).\n", req.m_errcode, _errmsg(req.m_errcode));
	}
	req.Commit(__true);
	
	return __true;
}
Beispiel #12
0
Selector Selector::operator[](const char *name) {
    _name += std::string(".") + name;
    _check_create_table();
    Fun traverse = [this]() {
        _traverse();
        _get();
    };
    Fun get = [this, name]() {
        lua_getfield(_state._l, -1, name);
    };
    PFun put = [this, name](Fun fun) {
        fun();
        lua_setfield(_state._l, -2, name);
        lua_pop(_state._l, 1);
    };
    return Selector{_state, traverse, get, put};
}
Beispiel #13
0
/* a wrapper function for _traverse
 * locate the DirEntry of `filename'
 */
int traverse(char * filename,int (*func)(unsigned char *,int,ULONG *),
             ULONG * value_addr) {
#ifdef DEBUG
    printf("** traverse starts **\n");
#endif
    int result=0;
    DirEntry de;
    /* can not find the DirEntry */
    if( locateFileInFS(filename,&de) == 0 ) {
        printf("%s: No such file or directory.\n",filename);
        return result;
    }
    result = _traverse(&de,func,value_addr);
#ifdef DEBUG
    printf("** traverse ends **\n");
#endif
    return result;
}
Beispiel #14
0
Selector Selector::operator[](const int index) {
    _name += std::string(".") + std::to_string(index);
    _check_create_table();
    Fun traverse = [this]() {
        _traverse();
        _get();
    };
    Fun get = [this, index]() {
        lua_pushinteger(_state._l, index);
        lua_gettable(_state._l, -2);
    };
    PFun put = [this, index](Fun fun) {
        lua_pushinteger(_state._l, index);
        fun();
        lua_settable(_state._l, -3);
        lua_pop(_state._l, 1);
    };
    return Selector{_state, traverse, get, put};
}
Beispiel #15
0
void CErrorDetector::detect()
{
	m_addrConflicts.clear();
	m_invalidAddress.clear();
	_traverse(sections, _traverse_fixup_pins, (__uint)this);
}
 void flatten(TreeNode* root) {
     _traverse(root, NULL);
 }
Beispiel #17
0
void t_traverse(Tobj *pTernary) {
  _malloc(pTernary);
  pTernary->searchn = 0;
  _traverse(pTernary, pTernary->root);
  /* now look at pTernary->searchn and pTernary->searchchar */
}
Beispiel #18
0
/*	=================== BST_Traverse =================== 
	Process tree using inorder traversal. 
	   Pre   Tree has been created (may be null) 
	         process visited package during traversal 
	   Post  Pacakge processed in LNR (inorder) sequence 
*/
void BST_Traverse (HEADER* listHeader, void (*process) (PACKAGE* package) ) 
{
	if(listHeader->treeRoot)
		_traverse (listHeader->treeRoot, process);
	return;
} // end BST_Traverse