Example #1
0
void TerrainDemo::keyboardCallback(unsigned char key, int x, int y) {

	if (',' == key) {
		// increment model
		m_model = (eFractal == m_model) ? eRadial : eFractal;
		this->resetPhysics();
	}
	if ('/' == key) {
		// increment type
		m_type = nextType(m_type);
		this->resetPhysics();
	}
	if ('\\' == key) {
		// increment axis
		m_upAxis++;
		if (m_upAxis > 2) {
			m_upAxis = 0;
		}
		this->resetPhysics();
	}
	if ('[' == key) {
		// toggle dynamics
		m_isDynamic = !m_isDynamic;
	}

	// let demo base class handle!
	DemoApplication::keyboardCallback(key, x, y);
}
Example #2
0
int doEntry()
{
    func_t *F;
    symentry_t *sym;
    sym = EiC_lookup(stand_tab,"main");

    if(!sym) {
	if(!ScriptMode) 
	    EiC_messageDisplay("Error: Missing `main'\n");
	return 0;
    }
    if(sym) {
	if(EiC_gettype(sym->type) != t_func) {
	    EiC_messageDisplay("Error: `main' NOT DECLARED as a function\n");
	    return 0;
	}
	/* check return type of main */
	if(EiC_gettype(nextType(sym->type)) != t_int) {
	    EiC_messageDisplay("Error: function `main' MUST return an `int' type\n");
	    return 0;
	}
    
	/* get number of arguments */
	F = EiC_getInf(sym->type);
	if(getFNp(F) <= 1)  /* allow for void argument */
	    EiC_prolineString(FORMAT1);
	else if(getFNp(F) <= 2)
	    EiC_prolineString(FORMAT2);
	else
	    EiC_messageDisplay("Error: too many arguments being "
			       "passed  to `main'\n");
           /*EiC_prolineString(FORMAT3);*/
    }
    return 1;
}
Example #3
0
static void genCall(type_expr *t, char *fname, FILE *fp)
{
    static int level = 0;
    func_t *F;
    int i;

    F = (func_t *) EiC_getInf(t);
    level++;

    fputs("\n", fp);

    if(Ncalls) {
	int k;
	for(k=0;k<Ncalls;++k) 
	    fprintf(fp,"\t%s%d = arg(%d,getargs(),ptr_t).p;\n",
		    callName,callNo[k],callpos[k]);
    }

    if(nextType(t)) {
	t = nextType(t);
	genAffect(t,0,fp);
	if(t)
	    while(nextType(t))
		t = nextType(t);
    }
    
    fputs(fname,fp);
    fputs("(", fp);
    if (F && getFNp(F)) {
	for (i = 0; i < getFNp(F); i++) {
	    genArg(getFPty(F,i), i, fp);
	    if(i < getFNp(F)-1) {
		fputs(",\n", fp);
		fputs("\t\t", fp);
	    }
	}
	fputs(");\n", fp);
    }
    else
	fputs(");\n", fp);

    level--;
}
Example #4
0
MWWorld::ContainerStoreIterator::ContainerStoreIterator (int mask, ContainerStore *container)
: mType (0), mMask (mask), mContainer (container)
{
    nextType();

    if (mType==-1 || (**this).getRefData().getCount())
        return;

    ++*this;
}
Example #5
0
static void checktype(type_expr * type)
{
    int t;
    while (type) {
	if ((t = EiC_gettype(type)) == t_struct || t == t_union)
	    if (!type->alias)
		if (setnextinf(EiC_getInf(type)))
		    type->alias = 1;
	type = nextType(type);
    }
}
Example #6
0
MWWorld::ContainerStoreIterator& MWWorld::ContainerStoreIterator::operator++()
{
    do
    {
        if (incIterator())
            nextType();
    }
    while (mType!=-1 && !(**this).getRefData().getCount());

    return *this;
}
Example #7
0
static void showFunc(type_expr **t, FILE *fp)
{
    static int level = 0;
    func_t *F;
    int i,k;
    fputs("Func (", fp);
    F = (func_t *) EiC_getInf(*t);
    level++;

    if (F && getFNp(F)) {
	for (i = 0; i < getFNp(F); i++) {
	    fputc('\n',fp);
	    for(k=0;k<level;k++)
		fputc('\t',fp);
	    if(getFPname(F,i))
		printf("%s: ",getFPname(F,i));
	    EiC_showdectype(getFPty(F,i), 0,fp);
	    if(i < getFNp(F)-1)
		fputs(",", fp);
	}

    }
    fputc('\n',fp);
    for(k=0;k<level;k++)
	fputc('\t',fp);
    fputs(") returning ", fp);
    if(nextType(*t)) {
	*t = nextType(*t);
	EiC_showdectype(*t,0,fp);
	if(*t)
	    while(nextType(*t))
		*t = nextType(*t);
    }
    
    if(F && getFComm(F)) 
	fprintf(fp,"\n\n    /* %s/\n", getFComm(F));  /**/
    level--;
    
}    
Example #8
0
static int setnextinf(void *info)
{
    int i, t;
    symentry_t *sym;
    type_expr *type;
    for (i = 0; i < HSIZE; i++)
	for (sym = EiC_HTAB[i]; sym; sym = sym->next)
	    if ((t = EiC_gettype(sym->type)) == t_union || t == t_struct)
		for (type = sym->type; type; type = nextType(type))
		    if (type->alias && EiC_getInf(type) == info) {
			type->alias = 0;
			return 1;
		    }
    return 0;
}
Example #9
0
static struct pluginitem *selectPlugin(struct pluginitem **list, char *type){
	char *ptr;
	int len;
	int i;
	if(type==NULL || *type==0)return NULL;
	len=strlen(type);

	for(i=0;i<PLUGIN_NULL;i++){
		ptr=list[i]->contenttype;
		while(ptr){
			if(strncmp(ptr,type,len)==0)
				return list[i];
			ptr=nextType(ptr);
		}
	}
	return NULL;
}
Example #10
0
static int DoCallBackNames(func_t *F, FILE *fp)
{
    int x = 0;
    if (F) {
	int i;
	callpos = realloc(callpos,sizeof(int)*getFNp(F));
	for (i = 0; i < getFNp(F); i++) {
	    type_expr *t = getFPty(F,i);
	    if(EiC_gettype(t) == t_pointer && 
	       EiC_IsFunc(EiC_gettype(nextType(t)))) {
		callNo = realloc(callNo, sizeof(*callNo) * (x+1));
		callpos[x] = i;
		callNo[x] = callBack++;
		fprintf(fp,"static void * %s%d = NULL;\n",callName,callNo[x]);
		x++;
	    }
	}
    }
    return (Ncalls = x);
}
Example #11
0
static void genArg(type_expr * t, int idx, FILE *fp)
{
    int ob;
   if ((ob = EiC_gettype(t)) == t_void) {
      return;
   }

   if(ob == t_pointer) {
       int k = EiC_gettype((nextType(t)));
       if(EiC_IsFunc(k)) {
	   k = 0;
	   while(k<Ncalls && callpos[k] != idx) k++;
	   fprintf(fp,"%s%d",middleName,callNo[k]+adjustNum);
	   return ;
       }
   }
       
    fputs("arg(",fp);
    fprintf(fp,"%d",idx);
    fputs(",getargs(),",fp);

	switch (ob) {
	  case t_char:  fputs("char)", fp); break;
	  case t_uchar: fputs("char)", fp); break;
	  case t_short: fputs("short)", fp); break;
	  case t_ushort:fputs("short)", fp); break;
	  case t_int:   fputs("int)", fp); break;
	  case t_uint:  fputs("unsigned)", fp); break;
	  case t_long:  fputs("long) ", fp); break;
	  case t_ulong: fputs("unsigned long)", fp); break;
	  case t_float: fputs("float)", fp); break;
	  case t_double:fputs("double)", fp); break;
	  case t_pointer:
	      fputs("ptr_t).p",fp);
	      break; 
	  default: fputs("Uknown identifier", fp); return;
	}
}
Example #12
0
void EiC_showvalue(AR_t * arg)
{
    int t;

    if(!EiC_interActive || !arg->type)
	return ;

    fputc('\t', stdout);

    t = EiC_gettype(arg->type);

    if(isconst(arg->type) && t != t_pointer) {
	outputval(t, &arg->v);
	fputc('\n', stdout);
	return;
    }
    	
    switch ((t = EiC_gettype(arg->type))) {
      case t_union:  fputs("(Union)",stdout); break;
      case t_struct: showstruct(arg); break;
      case t_char:   case t_uchar:  case t_short:  
      case t_ushort: outputval(t_int, &arg->v.ival); break;
      case t_float:  outputval(t_double, &arg->v.ival); break;
      case t_array:
      case t_pointer:
	if (EiC_gettype(nextType(arg->type)) == t_char)
	    t = STR;
	else
	    t = t_pointer;
      default:
	outputval(t, &arg->v);
	break;
    }
    fputc('\n', stdout);

}
Example #13
0
int main (int argc, char**argv)
{
	int32_t first_Error = 0;
	ResetProperties();
	UpdateNumberOfRawAndColomn();
	// check error
	if (argc < 2) {
		printf("You set more than 3 argument at the commande line\n");
		usage();
		return -1;
	}
	bool directCheckFiles = false;
	int basicIDParsing = 1;
	if (0==strcmp("-d",argv[1])) {
		basicIDParsing++;
		directCheckFiles = true;
	}
	// one file
	if (basicIDParsing+1 <= argc) {
		strcpy(fileProp[0].name, argv[basicIDParsing]);
		fileProp[0].availlable = true;
	}
	// a second file
	if (basicIDParsing+2 <= argc) {
		strcpy(fileProp[1].name, argv[basicIDParsing+1]);
		fileProp[1].availlable = true;
	}
	// open the files
	OpenFiles();
	
	// user requested to have the direct error ID of the file...
	if (directCheckFiles==true) {
		
		float dividor = 1;
		int32_t maxSlot = (fileProp[0].slotSize>fileProp[1].slotSize)?fileProp[0].slotSize:fileProp[1].slotSize;
		if (0!=maxSlot) {
			dividor = maxSlot;
		}
		
		int32_t idError = findFirstDiff();
		int minSizeFile = ((fileProp[0].size<fileProp[1].size)?fileProp[0].size:fileProp[1].size) - abs(getPaddingOffsetFile());
		if (minSizeFile<=idError) {
			printf(" --- slot=%3d nb frame=%d", (int32_t)dividor, (int32_t)(idError/dividor));
			CloseFiles();
			// 0 : no error
			return 0;
		} else {
			int32_t sizeElement = 1;
			showTypeSize_te tmpType = getTypeSize();
			switch(tmpType)
			{
				default:
				case SHOW_TYPE_SIZE_8:
					sizeElement = 1;
					break;
				case SHOW_TYPE_SIZE_16:
					sizeElement = 2;
					break;
				case SHOW_TYPE_SIZE_FLOAT:
				case SHOW_TYPE_SIZE_32:
					sizeElement = 4;
					break;
				case SHOW_TYPE_SIZE_DOUBLE:
				case SHOW_TYPE_SIZE_64:
					sizeElement = 8;
					break;
			}
			int32_t elementIDError = idError/sizeElement;
			float frameRatio = (float)elementIDError/dividor;
			int32_t idFrame = frameRatio;
			int32_t idFrameElement = (frameRatio-idFrame)*dividor;
			printf("%9d / frame=%9.2f ==> frame=%5d element=%5d slot=%3d", elementIDError, frameRatio, idFrame, idFrameElement, (int32_t)dividor);
			CloseFiles();
			return idError;
		}
	}
	// rendre la lecture des données non canonique
	system("stty -icanon");
	// supression de l'écho des caractères
	system("stty -echo");
	// enable mouse event ...
	printf(MOUSE_REPORTING_ENABLE);
	// hide cursor ...
	printf(CURSOR_DISPLAY_DISABLE);
	system("clear");
	CleanDisplay();


	int ret = 0;
	pthread_t HangleThreadDisplay;

	ret = pthread_create ( & HangleThreadDisplay, NULL, threadDisplay, NULL );
	if (! ret)
	{
		while (1)
		{
			int32_t inputValue;
			inputValue = getc(stdin);
			switch(inputValue)
			{
				case 'q':
				case 'Q':
					goto exit_programme;
					break;
				//case 0x1B:
				case '\e':
					inputValue = getc (stdin);
					//printf("\n get data : 0x%08x ..... : \n", (unsigned int)inputValue);
					// [ == 0x5B
					if (inputValue == '[')
					{
						inputValue = getc (stdin);
						char charValue = inputValue;
						// printf("\n get data : 0x%08x ..... : \\e[%c\n", (unsigned int)inputValue, charValue);
						if (    charValue == 'A' //0x41 ==> UP
						     || charValue == 'B' //0x42 ==> DOWN
						     || charValue == 'C' //0x43 ==> RIGHT
						     || charValue == 'D' //0x44 ==> LEFT
						   )
						{
							//printf("\n get data :\\e[%c ==> MoveKey \n", charValue);
							if (charValue == 'A') {
								upDownOfsetFile(-5);
							} else if ( charValue == 'B') {
								upDownOfsetFile(5);
							} else if ( charValue == 'C') {
								upDownOfsetFile((GetNumberOfRaw()-NB_HEARDER_RAW));
							} else if ( charValue == 'D') {
								upDownOfsetFile(-(GetNumberOfRaw()-NB_HEARDER_RAW));
							}
						} else if (charValue == 'M' ) { //0x4d ==> mouse
							//printf("\n get data :\\e[%c ==> Mouse \n", charValue);
							int32_t button = getc(stdin);
							int32_t xPos = getc(stdin);
							xPos -= 0x20;
							int32_t yPos = getc(stdin);
							yPos -= 0x20;
							
							int32_t bt=0;
							switch (button) {
								case 97:
									bt = 4;
									break;
								case 96:
									bt = 5;
									break;
								case 32:
									bt = 1;
									break;
								case 33:
									bt = 3;
									break;
							}
							//printf("     bt=%#x=%d \n", button, bt);
							//printf("     x=%d y=%d\n", xPos, yPos);
							if (bt == 4) {
								upDownOfsetFile(5);
							} else if (bt == 5) {
								upDownOfsetFile(-5);
							}
						}
					}
					
					break;
				// change the type of interpretation the file
				case 't':
				case 'T':
					nextType();
					break;
				// change the size of showing the file
				case 's':
				case 'S':
					nextTypeSize();
					break;
				// find the first ERROR
				case 'f':
				case 'F':
					// try to find the first error...
					first_Error = findFirstDiff();
					setOfsetFile((first_Error/16)*16 - 128);
					needRedraw();
					break;
				// find the first ERROR
				case 'a':
				case 'A':
					setOfsetFile(0);
					break;
				// go to the end of the file (File 1 and next File 2)
				case 'z':
				case 'Z':
					{
						UpdateFilesSize();
						static bool whichElement = false;
						if (whichElement == false) {
							whichElement = true;
							setOfsetFile((fileProp[0].size/16)*16 - 256);
						} else {
							whichElement = false;
							setOfsetFile((fileProp[1].size/16)*16 - 256);
						}
					}
					break;
				// Reload the 2 files
				case 'r':
				case 'R':
					CloseFiles();
					UpdateNumberOfRawAndColomn();
					CleanDisplay();
					OpenFiles();
					needRedraw();
					break;
				// Display Slot mode :
				case 'j':
				case 'J':
					setSlotDisplayMode((getSlotDisplayMode()==true)?false:true);
					needRedraw();
					break;
				case 'U':
					setSlotSize(getSlotSize()-9);
				case 'u':
					setSlotSize(getSlotSize()-1);
					needRedraw();
					break;
				case 'I':
					setSlotSize(getSlotSize()+9);
				case 'i':
					setSlotSize(getSlotSize()+1);
					needRedraw();
					break;
				case 'k':
				case 'K':
					setSlotSize(0);
					setSlotDisplayMode(false);
					needRedraw();
					break;
				// Add padding offset between left an right file
				case 'o':
					displayPaddingOffset(-1);
					break;
				case 'O':
					displayPaddingOffset(-16);
					break;
				case 'p':
					displayPaddingOffset(1);
					break;
				case 'P':
					displayPaddingOffset(16);
					break;
				// Clear the padding
				case 'm':
				case 'M':
					displayPaddingOffsetClear();
					break;
				case 'c':
				case 'C':
					AutoSetPadding();
					break;
				case 'h':
				case 'H':
					setHelpDisplay((getHelpDisplay()==true)?false:true);
					needRedraw();
					break;
			}
		}
	} else {
// Pre: disambig_fp has been initialized and disambig_writing is True
void generateDisambigFile() {
  FuncIterator* funcIt;
  TypeIterator* typeIt;

  // Write entries for global variables:
  fputs(ENTRY_DELIMETER, disambig_fp);
  fputs("\n", disambig_fp);
  fputs(GLOBAL_STRING, disambig_fp);
  fputs("\n", disambig_fp);

  visitVariableGroup(GLOBAL_VAR,
                     0,
                     0,
                     0,
		     0,
                     &printDisambigAction);

  fputs("\n", disambig_fp);

  // Write entries for function parameters and return values:
  funcIt = newFuncIterator();

  while (hasNextFunc(funcIt)) {
    FunctionEntry* cur_entry = nextFunc(funcIt);

    tl_assert(cur_entry);

    // Only write .disambig entries for program points that are listed
    // in prog-pts-file, if we are using the --prog-pts-file option:
    if (!fjalar_trace_prog_pts_filename ||
        // If fjalar_trace_prog_pts_filename is on (we are reading in
        // a ppt list file), then DO NOT OUTPUT entries for program
        // points that we are not interested in.
        prog_pts_tree_entry_found(cur_entry)) {
      fputs(ENTRY_DELIMETER, disambig_fp);
      fputs("\n", disambig_fp);
      fputs(FUNCTION_PREFIX, disambig_fp);
      fputs(cur_entry->fjalar_name, disambig_fp);
      fputs("\n", disambig_fp);

      // Print out all function parameter return value variable names:
      visitVariableGroup(FUNCTION_FORMAL_PARAM,
                         cur_entry,
                         0,
                         0,
			 0,
                         &printDisambigAction);

      visitVariableGroup(FUNCTION_RETURN_VAR,
                         cur_entry,
                         0,
                         0,
			 0,
                         &printDisambigAction);

      fputs("\n", disambig_fp);
    }
  }
  deleteFuncIterator(funcIt);

  // Write entries for every struct/class in TypesTable, with the
  // type's name prefixed by 'usertype.':
  typeIt = newTypeIterator();

  while (hasNextType(typeIt)) {
    TypeEntry* cur_entry = nextType(typeIt);

    tl_assert(cur_entry && cur_entry->typeName);

    fputs(ENTRY_DELIMETER, disambig_fp);
    fputs("\n", disambig_fp);
    fputs(USERTYPE_PREFIX, disambig_fp);
    fputs(cur_entry->typeName, disambig_fp);
    fputs("\n", disambig_fp);

    visitClassMembersNoValues(cur_entry,
                              &printDisambigAction);

    fputs("\n", disambig_fp);
  }

  deleteTypeIterator(typeIt);
}
Example #15
0
static void genMultiCall(type_expr *t, char *fname, FILE *fp)
{
    static int level = 0;
    func_t *F;
    int i,n;
    type_expr *T;

    F = (func_t *) EiC_getInf(t);
    level++;

    fputs("\tstatic int nb = 0;\n\n",fp);

    fprintf(fp,"\tswitch(nb)\n");
    fprintf(fp,"\t{\n");
    for (n = 0;n < MULTIPLEX;++n)
    {
	adjustNum = n+1-MULTIPLEX;
	fprintf(fp,"\tcase %d :\n",n);

	if(Ncalls) {
	    int k;
	    for(k=0;k<Ncalls;++k) 
		fprintf(fp,"\t%s%d = arg(%d,getargs(),ptr_t).p;\n",
			callName,callNo[k]+adjustNum,callpos[k]);
	}

	if (n == 0)
	{
	    T = t;
	}
	else
	{
	    t = T;
	}

	if(nextType(t)) {
	    t = nextType(t);
	    genAffect(t,0,fp);
	    if(t)
		while(nextType(t))
		    t = nextType(t);
	}

	fputs(fname,fp);
	fputs("(", fp);
	if (F && getFNp(F)) {
	    for (i = 0; i < getFNp(F); i++) {
		genArg(getFPty(F,i), i, fp);
		if(i < getFNp(F)-1) {
		    fputs(",\n", fp);
		    fputs("\t\t", fp);
		}
	    }
	    fputs(");\n", fp);
	}
	else
	    fputs(");\n", fp);

	level--;
	fprintf(fp,"\tbreak;\n");
    }
    fprintf(fp,"\t}\n");
    fprintf(fp,"\t++nb;\n");
    fprintf(fp,"\tnb %%= %d;\n",MULTIPLEX);
    adjustNum = 0;
}
Example #16
0
static void genCallBackFunc(type_expr *ty, 
			    int p, 
			    FILE *fp)
{
    char buff[10];
    func_t *F, *F2;
    int i,v, var=0;
    type_expr *t;

    F = EiC_getInf(ty);
    t = getFPty(F,callpos[p]);
    t = nextType(t);
    F2 = EiC_getInf(t);

    fprintf(fp,"static ");
    EiC_showdectype(nextType(t),0,fp);

    fprintf(fp," %s%d(",middleName,callNo[p]);

    /* check 4 varadic function calls */
    for(i=0;i<getFNp(F2);i++) 
	if(EiC_gettype(getFPty(F2,i)) == t_var) {
	    var = 1;
	    break;
	}

    if(!var) {
	for(i=0;i<getFNp(F2)-1;i++) {
	    if((v=EiC_gettype(getFPty(F2,i))) == t_void)
		continue;
	    sprintf(buff,"x%d, ",i);
	    EiC__generateType(getFPty(F2,i),buff,fp,1);

	}
	if((v=EiC_gettype(getFPty(F2,i))) != t_void)  {
	    sprintf(buff,"x%d ",i);
	    EiC__generateType(getFPty(F2,i),buff,fp,1);
	}
	fprintf(fp,")\n{\n");

	for (i = 0; i < getFNp(F2); i++) {
	    if(EiC_gettype(getFPty(F2,i)) == t_void)
		continue;
	    fprintf(fp,"    setArg(%d, %s%d, ",i,callName,callNo[p]);

	    EiC__generateType(getFPty(F2,i),"",fp,1);

	    fprintf(fp,",x%d);\n",i);
	}

    } else {
    	fprintf(fp," va_alist )  va_dcl\n{\n");
	fprintf(fp,"    void Auto_EiC_CallBack(code_t *callback, va_list ap);\n");
	fprintf(fp,"    va_list ap; va_start(ap);\n");
	fprintf(fp,"    Auto_EiC_CallBack(%s%d,ap);\n",callName,callNo[p]);
    } 
	
    fprintf(fp,"\n    EiC_callBack(%s%d);\n",callName,callNo[p]);

    if(EiC_gettype(nextType(t)) != t_void) {
	fputs("    return EiC_ReturnValue( ",fp);
	/*EiC_showdectype(nextType(t),0,fp);*/
	EiC__generateType(nextType(t),"",fp,1);
	fputs(");\n",fp);
    }
    if(var)
	fputs("    va_end(ap);\n",fp);
    
    fputs("}\n\n",fp);

}
Example #17
0
static void EiC__generateType(type_expr *t, char *id,FILE *fp, int level)
{

    struct_t *S;

    char tmp[100];
    char out[100];

    strcpy(out,id);

    do {
        switch(EiC_gettype(t)) {
            case t_pointer: /* pointer */
                sprintf(tmp,"*%s",out);
                strcpy(out,tmp);
                break;

	    case t_char:    sprintf(tmp,"%s %s", "char", out); strcpy(out,tmp); break;
	    case t_uchar:   sprintf(tmp,"%s %s", "unsigned char",out);strcpy(out,tmp); break;
	    case t_short:   sprintf(tmp,"%s %s",  "short",out);strcpy(out,tmp);break;
	    case t_ushort:  sprintf(tmp,"%s %s",  "unsigned short",out);strcpy(out,tmp);break;
	    case t_int:     sprintf(tmp,"%s %s",  "int",out);strcpy(out,tmp);break;
	    case t_uint:    sprintf(tmp,"%s %s",  "unsigned",out);strcpy(out,tmp);break;
	    case t_long:    sprintf(tmp,"%s %s",  "long",out);strcpy(out,tmp);break;
	    case t_ulong:   sprintf(tmp,"%s %s",  "unsigned long",out);strcpy(out,tmp);break;
	    case t_float:   sprintf(tmp,"%s %s",  "float",out);strcpy(out,tmp);break;
	    case t_double:  sprintf(tmp,"%s %s",  "double",out);strcpy(out,tmp);break;
	    case t_void:  sprintf(tmp,"%s %s",  "void",out);strcpy(out,tmp);break;

	    case t_struct:
	    case t_union:
		if(EiC_gettype(t) == t_union) 
		    fputs("union {",fp);
		else
		    fputs("struct {",fp);

		S = EiC_getInf(t);
		if(!S) {
		    fputs("Incomplete", fp);
		    break;
		}
		level++;
		if (level <= 2) {
		    int i;
		    for (i = 0; i < S->n; i++) {
			EiC__generateType(S->type[i], S->id[i], fp,level);
			fputs(";",fp);
		    }
		}
		sprintf(tmp,"} %s ",out);
		strcpy(out,tmp);
		level--;
		break;

            case t_array: /* array */ 
                if(out[0] ==  '*') {
                    sprintf(tmp,"(%s)%s",out,"[]");
                    strcpy(out,tmp);
                } else {
		    sprintf(tmp,"[%d]",(int)EiC_getInf(t));
                    strcat(out, tmp);
		}
		break;

		
	}

    } while ( (t=nextType(t)));

    fprintf(fp,"%s",out);
}
Example #18
0
	std::unique_ptr<const CPPModel::Type>			TypeTree::type( const CPPModel::ASTDictionary&		dictionary ) const
	{
		CPPModel::TypeSpecifier						currentTypeSpec = typeSpecifier();
		std::unique_ptr<const CPPModel::Type>		returnValue( new CPPModel::UnrecognizedType());

		//	TODO add other enumerations

		switch( CPPModel::CPPTypes[(int)currentTypeSpec].classification )
		{
			case CPPModel::TypeInfo::Classification::FUNDAMENTAL :
			{
				returnValue.reset( new CPPModel::FundamentalType( currentTypeSpec ));
			}
			break;

			case CPPModel::TypeInfo::Classification::CLASS :
			{
				const CPPModel::UID typeUID = uid();

//				const FullyQualifiedNamespace	fqName = fullyQualifiedNamespace() + identifier();

				const CPPModel::ASTDictionary::UIDIndexConstIterator		entry = dictionary.UIDIdx().find( typeUID );

				if( entry != dictionary.UIDIdx().end() )
				{
					if( ((CPPModel::ASTDictionary::DictionaryEntryPtr)(*entry))->entryKind() == CPPModel::DictionaryEntry::EntryKind::CLASS )
					{
						const CPPModel::DictionaryClassEntry*	classEntry = dynamic_cast<const CPPModel::DictionaryClassEntry*>(&(*(*entry)));

						if( classEntry != NULL )
						{
							CPPModel::ConstListPtr<CPPModel::Attribute>	attributes( CPPModel::Attributes::deepCopy( classEntry->attributes() ));

							returnValue.reset( new CPPModel::ClassOrStructType( classEntry->typeSpec(),
																			    classEntry->name(),
																			    typeUID,
																			    classEntry->enclosingNamespace(),
																			    classEntry->sourceLocation(),
																			    attributes ));
						}
					}
					else
					{
						std::cerr << "TypeInfo Classification does not match dictionary entry kind\n" << std::endl;
					}
				}
				else
				{
					//	TODO get attributes

					CPPModel::ConstListPtr<CPPModel::Attribute>		attributes( new boost::ptr_list<CPPModel::Attribute>() );

					const CPPModel::Namespace*		namespaceScope;

					std::string			scope = fullyQualifiedNamespace().asString();

					dictionary.GetNamespace( fullyQualifiedNamespace().asString(), namespaceScope );

					if( namespaceScope == NULL )
					{
						std::cerr << "Null Scope" << std::endl;
					}

					returnValue.reset( new CPPModel::ClassOrStructType( currentTypeSpec,
																	    convert( TYPE_NAME( m_tree ))->identifier(),
																	    uid(),
																	    *namespaceScope,
																	    CPPModel::SourceLocation( "", 1, 1, 1 ),
																	    attributes ));
				}
			}
			break;

			case CPPModel::TypeInfo::Classification::DERIVED :
			{
				//	TODO get attributes

				CPPModel::ConstListPtr<CPPModel::Attribute>		attributes( new boost::ptr_list<CPPModel::Attribute>() );

				TypeTree		nextType( TREE_TYPE( m_tree ));

				returnValue.reset( new CPPModel::DerivedType( currentTypeSpec, attributes, nextType.type( dictionary ) ));
			}
			break;

			case CPPModel::TypeInfo::Classification::UNION :
			{
				const CPPModel::UID typeUID = uid();

				const CPPModel::ASTDictionary::UIDIndexConstIterator	entry = dictionary.UIDIdx().find( typeUID );

				if( entry != dictionary.UIDIdx().end() )
				{
					//	TODO handle if failure mode
					if( ((CPPModel::ASTDictionary::DictionaryEntryPtr)(*entry))->entryKind() == CPPModel::DictionaryEntry::EntryKind::UNION )
					{
						const CPPModel::DictionaryUnionEntry*	unionEntry = dynamic_cast<const CPPModel::DictionaryUnionEntry*>(&(*(*entry)));

						if( unionEntry != NULL )
						{
							CPPModel::ConstListPtr<CPPModel::Attribute>	attributes( CPPModel::Attributes::deepCopy( unionEntry->attributes() ));

							returnValue.reset( new CPPModel::UnionType( unionEntry->typeSpec(),unionEntry->name().c_str(), typeUID, unionEntry->enclosingNamespace(), unionEntry->sourceLocation(), attributes ));
						}
					}
				}
				else
				{
					//	TODO get attributes

					CPPModel::ConstListPtr<CPPModel::Attribute>		attributes( new boost::ptr_list<CPPModel::Attribute>() );

					const CPPModel::Namespace*		namespaceScope;

					dictionary.GetNamespace( fullyQualifiedNamespace().asString(), namespaceScope );

					returnValue.reset( new CPPModel::UnionType( currentTypeSpec,
																convert( TYPE_NAME( m_tree ))->identifier(),
																uid(),
																*namespaceScope,
																CPPModel::SourceLocation( "", 1, 1, 1 ),
																attributes ) );
				}
			}

			break;
		}

		//	TODO Finish the implementation

		return( returnValue );
	}
Example #19
0
static void EiC_showdectype(type_expr * t, int expand, FILE *fp)
{

    struct_t *S;
    int i;
    static int level = 0;

    while (t) {
	if(isconst(t) || isconstp(t))
	    fputs("const ",fp);
	
	switch (EiC_gettype(t)) {
	  case t_var:   fputs("...", fp); break;
	  case t_enum:  fputs("enum ", fp); break;
	  case t_char:  fputs("char ", fp); break;
	  case t_uchar: fputs("unsigned char ", fp); break;
	  case t_short: fputs("short ", fp); break;
	  case t_ushort:fputs("unsigned short ", fp); break;
	  case t_int:   fputs("int ", fp); break;
	  case t_uint:  fputs("unsigned ", fp); break;
	  case t_long:  fputs("long int ", fp); break;
	  case t_ulong: fputs("unsigned long int ", fp); break;
	  case t_llong: fputs("long long ",fp); break;
	  case t_float: fputs("float ", fp); break;
	  case t_double:fputs("double ", fp); break;
	  case t_pointer: 

	    if(isunsafe(t)) 
	      fputs("unsafe ", fp);
	    /*else if(issafe(t)) 
	      fputs("safe ", fp);*/

	    fputs("* ", fp); 
	    break;

	  case t_void:  fputs("void ", fp); break;
	  case t_hidden: fputs("hidden ",fp); break;
	    
	  case t_funcdec: fputs("dec_", fp); showFunc(&t,fp); break;
	  case t_func:   showFunc(&t,fp); break;
	  case t_builtin: fputs("Builtin ",fp); showFunc(&t,fp); break; 

	  case t_array:
	    fprintf(fp,"ARY[%d]",(int) EiC_getInf(t));
	    break;
	  case t_union:
	  case t_struct:
	    S = EiC_getInf(t);
	    if(!S) {
		fputs("Incomplete", fp);
		break;
	    }
	    if (EiC_gettype(t) == t_struct)
		fprintf(fp,"struct: size  %u bytes",S->tsize);
	    else
		fprintf(fp,"union: size  %u bytes",S->tsize);
	    if (expand) {
		level++;
		fputc('\n', fp);
		if (level <= 2) {
		    int j;
		    for (i = 0; i < S->n; i++) {
			for (j = 0; j < level; j++)
			    fputc('\t', fp);
			fputs(S->id[i], fp);
			fputs(" -> ", fp);
			EiC_showdectype(S->type[i], expand,fp);
			fputc('\n', fp);
		    }
		}
		level--;
	    }
	    break;
	  case t_ref: fputs("Reference ",fp);break;
	  case ID: fputs("Identifier ", fp); break;
	  default: fputs("Uknown identifier", fp); return;
	}
	t = nextType(t);
    }
}