void nameFunction(t_tree node)
{
	if (node == NULL)
		return;

	if (nameCurrentPrimitive != NULL)
	{
		if (strcmp(node->Node.Function.Name, "main") == 0)
		{
			replaceString(&node->Node.Function.Name, nameCurrentPrimitive->Node.Primitive.Name);
			node->Node.Function.Variables = nameCurrentPrimitive->Node.Primitive.Variables;
			nameCurrentPrimitive->Node.Primitive.Variables = NULL;
			namePrimitiveVariables(node->Node.Function.Variables);
		}
		else
			joinStrings(&node->Node.Function.Name, nameCurrentPrimitive->Node.Primitive.Name, node->Node.Function.Name);			
	}
	
	checkIdExists(node->Node.Function.Name, node->LineNr, node->Node.Function.Type, NAME_TABLE_FUNCTION);
	scope = FindId(node->Node.Function.Name, scope);
		
	nameVariable(node->Node.Function.Variables);

	nameStmnt(node->Node.Function.Stmnts);

	scope = scope->parent;
	namePrimitive(node->Node.Function.Next);
}
Example #2
0
void offsetLocal(t_tree node, int * curoffset)
{
	t_symtable * var_table;
	var_table = FindId(node->Node.Variable.Name, scope);
	(*curoffset) -= offsetSizeOf(node->Node.Variable.Type);
	var_table->offset = (*curoffset);
}
Example #3
0
void EditorInfo::UnregisterName (const char* name) {
    UMapElem* elem = FindId((void*) name);

    if (elem != nil) {
         UMap::Unregister(elem);
         delete elem;
     }
}
Example #4
0
//______________________________________________________________________________
void ROMENetFolderServer::UnRegister(TSocket* socket)
{
   Int_t id = FindId(socket);
   if(id != -1) {
      fAcceptedSockets[id] = 0;
      fSocketClientRead[id] = kFALSE;
   }
}
Example #5
0
//main method
int main(int argc, char **argv) {
   LinearSim ls;
   int count, status, *arr, *reparr;
   int less = 0;
   int more = 0;
   int run = 0;
   int run2 = 0;
   int ret = EXIT_SUCCESS;

   Init(&ls, argv);
   pipe(ls.rep);
   arr = calloc(sizeof(int), ls.cellNum);
   reparr = calloc(sizeof(int), ls.cellNum);
   
   MainLoop(ls, arr);
   close(ls.rep[1]);
   
   while (read(IN_FD, &(ls.report), sizeof(Report))) {
      printf("Result from %d, step %d: %.3lf\n",
       ls.report.id, ls.report.step, ls.report.value);
      reparr[ls.report.id] += 1;
   }
   
   //checks if too many or too few reports ran
   for (count = ls.cellNum - 1; count >= 0; count--) {
      if (reparr[count] > ls.steps + 1)
         more++;
      if (reparr[count] < ls.steps + 1)
         less++;
   }
   
   if (less) {
      fprintf(stderr, "Error: %d cells reported too few reports\n",
       less);
      ret = EXIT_FAILURE;
   }
   if (more) {
      fprintf(stderr, "Error: %d cells reported too many reports\n",
       more);
      ret = EXIT_FAILURE;
   }
   while (ls.cellNum--) {
      run = FindId(arr, wait(&status));
      run2 = status;
      if (run2) {
         fprintf(stderr, "Error: Child %d exited ", run);
         fprintf(stderr, "with %d\n", run2);
         ret = EXIT_FAILURE;
      }
   }
   
   close(ls.rep[0]);
   free(arr);
   free(reparr);
   
   return ret;
}
Example #6
0
Ctrl *Ctrl::GetTopCtrlFromId(int id)
{
	int q = FindId(id);
	if(q >= 0) {
		Ctrl *p = wins[q].ctrl;
		if(p && p->top)
			return p;
	}
	return NULL;
}
GuiObject * ToolGuiObjectManager::UnregisterGuiObject (GuiObject *guiObject)
{
    ToolGuiObject *toolGuiObject = dynamic_cast< ToolGuiObject * >(guiObject);
    if (toolGuiObject != NULL) {

        int id = FindId (toolGuiObject);
        m_toolList[toolGuiObject]->RemoveTool (id);
	    m_toolList.erase (toolGuiObject);
    }

    return GuiObjectManager::UnregisterGuiObject (guiObject);
}
void ToolGuiObjectManager::UpdateGuiEnableStatus (GuiObject *guiObject,
        const bool enable)
{
    GuiObjectManager::UpdateGuiEnableStatus (guiObject, enable);

    ToolGuiObject *toolGuiObject = dynamic_cast< ToolGuiObject * >(guiObject);
    if (toolGuiObject != NULL) {

        int id = FindId (toolGuiObject);
        m_toolList[toolGuiObject]->EnableTool (id, enable);
    }
}
void ToolGuiObjectManager::UpdateStatus (GuiObject *guiObject)
{
    GuiObjectManager::UpdateStatus (guiObject);

    ToolGuiObject *toolGuiObject = dynamic_cast< ToolGuiObject * >(guiObject);
    if (toolGuiObject != NULL) {

	    bool enabled = toolGuiObject->IsEnabled ();
	    int id = FindId (toolGuiObject);

        m_toolList[toolGuiObject]->ToggleTool (id, enabled);
    }
}
Example #10
0
HRESULT CWebBrowserUI::InvokeMethod( IDispatch *pObj, LPOLESTR pMehtod, VARIANT *pVarResult, VARIANT *ps, int cArgs )
{
    DISPID dispid = FindId(pObj, pMehtod);
    if(dispid == -1) return E_FAIL;

    DISPPARAMS dispparams;
    dispparams.cArgs = cArgs;
    dispparams.rgvarg = ps;
    dispparams.cNamedArgs = 0;
    dispparams.rgdispidNamedArgs = NULL;

    return pObj->Invoke(dispid, IID_NULL, LOCALE_SYSTEM_DEFAULT, DISPATCH_METHOD, &dispparams, pVarResult, NULL, NULL);
}
Example #11
0
HRESULT CWebBrowserUI::SetProperty( IDispatch *pObj, LPOLESTR pName, VARIANT *pValue )
{
    DISPID dispid = FindId(pObj, pName);
    if(dispid == -1) return E_FAIL;

    DISPPARAMS ps;
    ps.cArgs = 1;
    ps.rgvarg = pValue;
    ps.cNamedArgs = 0;
    ps.rgdispidNamedArgs = NULL;

    return pObj->Invoke(dispid, IID_NULL, LOCALE_SYSTEM_DEFAULT, DISPATCH_PROPERTYPUT, &ps, NULL, NULL, NULL);
}
void checkIdUndefinedInPrimitive(char ** name, int lineNr)
{
	t_symtable * table_iter = scope;
	t_symtable * tableFound = NULL;
	char * new_name;

	if (nameErrorType > 0)
		return;

	while (table_iter != NULL)
	{
		tableFound = FindId(*name, table_iter);
		if (tableFound != NULL)
			return;
		table_iter = table_iter->parent;
	}

	new_name = (char *)malloc(sizeof(char) * (strlen(*name) + strlen(nameCurrentPrimitive->Node.Primitive.Name) + 1));
	strcpy(new_name, nameCurrentPrimitive->Node.Primitive.Name);
	strcat(new_name, *name);
	new_name[strlen(*name) + strlen(nameCurrentPrimitive->Node.Primitive.Name)] = 0;
	
	table_iter = scope;
	while (table_iter != NULL)
	{
		tableFound = FindId(new_name, table_iter);
		if (tableFound != NULL)
		{
			free(*name);
			(*name) = new_name;
			return;
		}
		table_iter = table_iter->parent;
	}
	free(new_name);
	nameErrorType = NAME_ERROR_TYPE_NOT_DEFINED;
	nameErrorLineNr = lineNr;
	nameErrorId = *name;		
}
Example #13
0
void offsetFunction(t_tree node)
{
	if (node == NULL)
		return;

	scope = FindId(node->Node.Function.Name, scope);
	
	// go through var list and calc offsets..
	// formals start at offset 2 and locals start at offset 0
	offsetVariable(node->Node.Function.Variables, 2, 0);

	scope = scope->parent;

	offsetFunction(node->Node.Function.Next);
}
Example #14
0
void nameFunction(t_tree node)
{
	if (node == NULL)
		return;
	
	checkIdExists(node->Node.Function.Name, node->LineNr, node->Node.Function.Type, NAME_TABLE_FUNCTION);
	scope = FindId(node->Node.Function.Name, scope);
		
	nameVariable(node->Node.Function.Variables);

	nameStmnt(node->Node.Function.Stmnts);

	scope = scope->parent;
	nameFunction(node->Node.Function.Next);
}
Example #15
0
void checkIdUndefined(const char * name, int lineNr)
{
	t_symtable * table_iter = scope;
	t_symtable * tableFound = NULL;
	if (nameErrorType > 0)
		return;
	while (table_iter != NULL)
	{
		tableFound = FindId(name, table_iter);
		if (tableFound != NULL)
			return;
		table_iter = table_iter->parent;
	}
	nameErrorType = NAME_ERROR_TYPE_NOT_DEFINED;
	nameErrorLineNr = lineNr;
	nameErrorId = name;
}
Example #16
0
void nameFormal(t_tree node)
{
	int offset = 0;
	t_symtable *thisVar;
	t_symtable *var_iter;

	checkIdExists(node->Node.Variable.Name, node->LineNr, node->Node.Variable.Type, NAME_TABLE_VARIABLE);
	thisVar = FindId(node->Node.Variable.Name,scope);
	var_iter = thisVar->parent->child;

	// this sets the order of the formal vars so we know which Actual 
	// to match up with the right Formal when performing type control.
	while (var_iter != NULL)
	{
		if (var_iter->offset > offset)
			offset = var_iter->offset;
		var_iter = var_iter->next;
	}
	thisVar->offset = offset + 1;
}
Example #17
0
void checkIdExists(const char * name, int lineNr, int type, int funcorvar)
{
	t_symtable * table_iter = scope;
	t_symtable * tableFound = NULL;
	while (table_iter != NULL)
	{
		tableFound = FindId(name, table_iter);
		if (tableFound != NULL && nameErrorType <= 0)
		{
			nameErrorType = NAME_ERROR_TYPE_ALREADY_DEFINED;
			nameErrorLineNr = lineNr;
			nameErrorId = name;
			return;
		}
		table_iter = table_iter->parent;
	}
	// om det inte finns, lägg till det
	if (funcorvar == 0)
		createFunctionTable(name,type);
	else
		createVariableTable(name,type);
}
Example #18
0
int
pr_IDListExpandedMembers(afs_int32 aid, namelist * lnames)
{
    afs_int32 code;
    afs_int32 gid;
    idlist lids;
    prlist alist;
    afs_int32 over;
    struct idhash *members = NULL;
    afs_int32 *stack = NULL;
    afs_int32 maxstack = ID_STACK_SIZE;
    int n = 0;			/* number of ids stacked */
    int i;
    int firstpass = 1;

    code = AllocateIdHash(&members);
    if (code) {
	return code;
    }
    stack = (afs_int32 *) malloc(sizeof(afs_int32) * maxstack);
    if (!stack) {
	code = ENOMEM;
	goto done;
    }

    stack[n++] = aid;
    while (n) {
	gid = stack[--n];	/* pop next group id */
	alist.prlist_len = 0;
	alist.prlist_val = NULL;
	if (firstpass || aid < 0) {
	    firstpass = 0;
	    code = ubik_PR_ListElements(pruclient, 0, gid, &alist, &over);
	} else {
	    code = ubik_PR_ListSuperGroups(pruclient, 0, gid, &alist, &over);
	    if (code == RXGEN_OPCODE) {
	        alist.prlist_len = 0;
		alist.prlist_val = NULL;
		code = 0; /* server does not support supergroups. */
	    }
	}
	if (code)
	    goto done;
	if (over) {
	    fprintf(stderr,
		    "membership list for id %d exceeds display limit\n", gid);
	}
	for (i = 0; i < alist.prlist_len; i++) {
	    afs_int32 found;
	    afs_int32 id;

	    id = alist.prlist_val[i];
	    found = FindId(members, id);
	    if (found < 0) {
		code = found;
		xdr_free((xdrproc_t) xdr_prlist, &alist);
		goto done;
	    }
	    if (found == 0 && id < 0) {
		if (n == maxstack) {	/* need more stack space */
		    afs_int32 *tmp;
		    maxstack += n;
		    tmp =
			(afs_int32 *) realloc(stack,
					      maxstack * sizeof(afs_int32));
		    if (!tmp) {
			code = ENOMEM;
			xdr_free((xdrproc_t) xdr_prlist, &alist);
			goto done;
		    }
		    stack = tmp;
		}
		stack[n++] = id;	/* push group id */
	    }
	}
	xdr_free((xdrproc_t) xdr_prlist, &alist);
    }

    code = CreateIdList(members, &lids, (aid < 0 ? PRUSERS : PRGROUPS));
    if (code) {
	goto done;
    }
    code = pr_IdToName(&lids, lnames);
    if (lids.idlist_len)
	free(lids.idlist_val);

  done:
    if (stack)
	free(stack);
    if (members)
	FreeIdHash(members);
    return code;
}
Example #19
0
const char* EditorInfo::GetInfo (const char* name) {
    UMapElem* elem = FindId((void*) name);
    return (elem == nil) ? nil : (char*) elem->tag();
}
Example #20
0
bool EditorInfo::Registered (const char* name) {
    return FindId((void*) name) != nil;
}
Example #21
0
int User(UserNodePtr User,HashTablePtr H){
	int choice;
    int id;
    char name[NameSize];
    LinkNodePtr MFriend,TFriend;
    printf("***********************************\n"
           "*      Enter your choice          *\n"
           "*      1 to view yourself         *\n"
           "*      2 to add a friend          *\n"
           "*      3 to delete a friend       *\n"
           "*      4 to follow somebody       *\n"
           "*      5 to cancel follow         *\n"
           "*      6 to find mutual friend    *\n"
           "*      7 to find twice friend     *\n"
           "*      8 to view somebody         *\n"
           "*      9 to end                   *\n"
           "***********************************\n");
    printf("your choice:\n");
    if(!scanf("%d",&choice)){
        printf("input error!!!\n");
        exit(1);
    }

    while(choice != 9){
        switch(choice){
            case 1:
                printUser(User,H);
                break;
            case 2:
                printf("***********************************\n"
                       "*      Enter your choice          *\n"
                       "*      1 by id                    *\n"
                       "*      2 by name                  *\n"
                       "***********************************\n");
                printf("your choice:\n");
                if(!scanf("%d",&choice)){
                    printf("input error!!!\n");
                    choice = 0;
                }
                switch(choice){
                    case 1:
                        printf("input your friend's id:\n");
                        scanf("%d",&id);
                        if(FindId(id,H) != NULL) {
                            InsertFriends(User->Name, FindId(id, H)->Name, NameSize, H);
                        }else{
                            printf("Can't find!!!\n");
                        }
                        Write(H);
                        break;
                    case 2:
                        printf("input your firend's name:\n");
                        getchar();
                        scanf("%[^\n]",name);
                        if(Find(name,NameSize,H) != NULL) {
                            InsertFriends(User->Name, name, NameSize, H);
                        }else{
                            printf("Can't find!!!\n");
                        }
                        Write(H);
                        break;
                    default:
                        printf("Invalid choice!!!\n");
                        break;
                }
                break;
            case 3:
                printf("***********************************\n"
                       "*      Enter your choice          *\n"
                       "*      1 by id                    *\n"
                       "*      2 by name                  *\n"
                       "***********************************\n");
                printf("your choice:\n");
                if(!scanf("%d",&choice)){
                    printf("input error!!!\n");
                    choice = 0;
                }
                switch(choice){
                    case 1:
                        printf("input your friend's id:\n");
                        scanf("%d",&id);
                        if(FindId(id,H) != NULL) {
                            DeleteFriends(User->Name, FindId(id, H)->Name, NameSize, H);
                        }else{
                            printf("Can't find!!!\n");
                        }
                        Write(H);
                        break;
                    case 2:
                        printf("input your firend's name:\n");
                        getchar();
                        scanf("%[^\n]",name);
                        if(Find(name,NameSize,H) != NULL) {
                            DeleteFriends(User->Name, name, NameSize, H);
                        }else{
                            printf("Can't find!!!\n");
                        }
                        Write(H);
                        break;
                    default:
                        printf("Invalid choice!!!\n");
                        break;
                }
                break;
            case 4:
                printf("***********************************\n"
                       "*      Enter your choice          *\n"
                       "*      1 by id                    *\n"
                       "*      2 by name                  *\n"
                       "***********************************\n");
                printf("your choice:\n");
                if(!scanf("%d",&choice)){
                    printf("input error!!!\n");
                    choice = 0;
                }
                switch(choice){
                    case 1:
                        printf("input your follow's id:\n");
                        scanf("%d",&id);
                        if(FindId(id,H) != NULL) {
                            InsertFollows(User->Name, FindId(id, H)->Name, NameSize, H);
                        }else{
                            printf("Can't find!!!\n");
                        }
                        Write(H);
                        break;
                    case 2:
                        printf("input your follow's name:\n");
                        getchar();
                        scanf("%[^\n]",name);
                        if(Find(name,NameSize,H) != NULL) {
                            InsertFollows(User->Name, name, NameSize, H);
                        }else{
                            printf("Can't find!!!\n");
                        }
                        Write(H);
                        break;
                    default:
                        printf("Invalid choice!!!\n");
                        break;
                }
                break;
            case 5:
                printf("***********************************\n"
                       "*      Enter your choice          *\n"
                       "*      1 by id                    *\n"
                       "*      2 by name                  *\n"
                       "***********************************\n");
                printf("your choice:\n");
                if(!scanf("%d",&choice)){
                    printf("input error!!!\n");
                    choice = 0;
                }
                switch(choice){
                    case 1:
                        printf("input your follow's id:\n");
                        scanf("%d",&id);
                        if(FindId(id,H) != NULL) {
                            DeleteFollows(User->Name, FindId(id, H)->Name, NameSize, H);
                        }else{
                            printf("Can't find!!!\n");
                        }
                        Write(H);
                        break;
                    case 2:
                        printf("input your follow's name:\n");
                        getchar();
                        scanf("%[^\n]",name);
                        if(Find(name,NameSize,H) != NULL) {
                            DeleteFollows(User->Name, name, NameSize, H);
                        }else{
                            printf("Can't find!!!\n");
                        }
                        Write(H);
                        break;
                    default:
                        printf("Invalid choice!!!\n");
                        break;
                }
                break;
            case 6:
                printf("input a name:\n");
                getchar();
                scanf("%[^\n]",name);
                if(Find(name,NameSize,H) != NULL){
                    MFriend = Intersection(User->Name,name,NameSize,H);
                    printList(MFriend,H);
                }else{
                    printf("Can't find!!!\n");
                }
                break;
            case 7:
                printf("input a name:\n");
                getchar();
                scanf("%[^\n]",name);
                if(Find(name,NameSize,H) != NULL){
                    TFriend = Twice(User->Name,name,NameSize,H);
                    printList(TFriend,H);
                }else{
                    printf("Can't find!!!\n");
                }
                break;
            case 8:
                printf("***********************************\n"
                       "*    Please input your choice     *\n"
                       "*          1  friends             *\n"
                       "*          2  follows             *\n"
                       "*          3  fans                *\n"
                       "***********************************\n");
                printf("your choice:\n");
                scanf("%d",&choice);
                switch (choice){
                    case 1:
                        printFriend(User,H);
                        break;
                    case 2:
                        printFollow(User,H);
                        break;
                    case 3:
                        printFan(User,H);
                        break;
                }
                break;
            default:
                printf("Invalid choice!!!\n");
                break;
        }
        printf("***********************************\n"
               "*      Enter your choice          *\n"
               "*      1 to view yourself         *\n"
               "*      2 to add a friend          *\n"
               "*      3 to delete a friend       *\n"
               "*      4 to follow somebody       *\n"
               "*      5 to cancel follow         *\n"
               "*      6 to find mutual           *\n"
               "*      7 to find twice            *\n"
               "*      8 to view somebody         *\n"
               "*      9 to end                   *\n"
               "***********************************\n");
        printf("your choice:\n");
        if(!scanf("%d",&choice)){
            printf("input error!!!\n");
            exit(1);
        }
    }
}