Пример #1
0
Файл: nteh.c Проект: spott/dmd
void nteh_declarvars(Blockx *bx)
{   symbol *s;

#if MARS
    if (!(bx->funcsym->Sfunc->Fflags3 & Fnteh)) // if haven't already done it
    {   bx->funcsym->Sfunc->Fflags3 |= Fnteh;
        s = symbol_name(s_name_context,SCbprel,tsint);
        s->Soffset = -5 * 4;            // -6 * 4 for C __try, __except, __finally
        s->Sflags |= SFLfree | SFLnodebug;
        type_setty(&s->Stype,mTYvolatile | TYint);
        symbol_add(s);
        bx->context = s;
    }
#else
    if (!(funcsym_p->Sfunc->Fflags3 & Fnteh))   // if haven't already done it
    {   funcsym_p->Sfunc->Fflags3 |= Fnteh;
        if (!s_context)
            s_context = scope_search(s_name_context_tag,CPP ? SCTglobal : SCTglobaltag);
        symbol_debug(s_context);

        s = symbol_name(s_name_context,SCbprel,s_context->Stype);
        s->Soffset = -6 * 4;            // -5 * 4 for C++
        s->Sflags |= SFLfree;
        symbol_add(s);
        type_setty(&s->Stype,mTYvolatile | TYstruct);

        s = symbol_name(s_name_ecode,SCauto,type_alloc(mTYvolatile | TYint));
        s->Sflags |= SFLfree;
        symbol_add(s);
    }
#endif
}
Пример #2
0
main()
{
	int choice;
	char buffer[32];

	scope_t *top_scope = NULL;
	node_t *tmp = NULL;
	
	fprintf(stderr, "0.search 1.search_all 2.insert 3.new_scope 4.del_scope \n");
	while (1) {
		scanf("%d", &choice);
		switch(choice) {
		case 0:
			scanf("%s", buffer);
			tmp = scope_search(top_scope, buffer);
			if (tmp != NULL) {
				fprintf(stderr, "Found[%s]\n", tmp->name);
			}
			else {
				fprintf(stderr, "Not found[%s]\n", buffer);
			}
			break;

		case 1:
			scanf("%s", buffer);
			tmp = scope_search_all(top_scope, buffer);
			if (tmp != NULL) {
				fprintf(stderr, "Found[%s]\n", tmp->name);
			}
			else {
				fprintf(stderr, "Not found[%s]\n", buffer);
			}
			break;

		case 2:
			scanf("%s", buffer);
			tmp = scope_insert(top_scope, buffer);
			if (tmp != NULL) {
				fprintf(stderr, "Insert[%s]\n", tmp->name);
			}
			else {
				fprintf(stderr, "Cannot Insert[%s]\n", buffer);
			}
			break;

		case 3:
			top_scope = scope_push(top_scope);
			break;

		case 4:
			top_scope = scope_pop(top_scope);
			break;
		}
	}
}