Exemplo n.º 1
0
string Temp_look(Temp_map m, Temp_temp t) {
  string s;
  assert(m && m->tab);
  s = TAB_look(m->tab, t);
  if (s) return s;
  else if (m->under) return Temp_look(m->under, t);
  else return NULL;
}
Exemplo n.º 2
0
//-----------------------------------------------------------------------------
// name: Temp_look( )
// desc: ...
//-----------------------------------------------------------------------------
c_str Temp_look( Temp_Map m, Temp_Temp t )
{
    c_str s;
    assert( m && m->tab );
    s = (c_str)TAB_look( m->tab, t );
    if ( s ) return s;
    else if ( m->under ) return Temp_look( m->under, t );
    else return NULL;
}
Exemplo n.º 3
0
/* first param is string created by this function by reading 'assem' string
 * and replacing `d `s and `j stuff.
 * Last param is function to use to determine what to do with each temp.
 */
static void format(char *result, string assem, Temp_tempList dst, Temp_tempList src, AS_targets jumps, Temp_map m)
{  
	char *p;
	int i = 0; /* offset to result string */

	for (p = assem; p && *p != '\0'; p++) {
		if (*p == '`') {
			switch(*(++p)) {
				case 's':
				{
				int n = *(++p) - '0';
				string s = Temp_look(m, nthTemp(src,n));
				strcpy(result+i, s);
				i += strlen(s);
				}
				break;
				case 'd': 
				{
				int n = *(++p) - '0';
				string s = Temp_look(m, nthTemp(dst,n));
				strcpy(result+i, s);
				i += strlen(s);
				}
				break;
				case 'j': assert(jumps); 
				{
				int n = *(++p) - '0';
				string s = Temp_labelstring(nthLabel(jumps->labels,n));
				strcpy(result+i, s);
				i += strlen(s);
				}
				break;
				default: assert(0);
			} 
		} else {
			result[i] = *p; 
			i++; 
		}
	}
	result[i] = '\0';
}
Exemplo n.º 4
0
/* first param is string created by this function by reading 'assem' string
 * and replacing `d `s and `j stuff.
 * Last param is function to use to determine what to do with each temp.
 */
void AS_format(char *result, string assem, 
		   Temp_tempList dst, Temp_tempList src,
		   AS_targets jumps, Temp_map m)
{
  char *p;
  int i = 0; /* offset to result string */
  for(p = assem; p && *p != '\0'; p++)
    if (*p == '`')
      switch(*(++p)) {
      case 's': {int n = atoi(++p);
//printf("mark start\n");
//printf("n = %d\n", n);
//if(nthTemp(src,n)==NULL){printf("But it is NULL!\n");}fflush(stdout);
		 string s = Temp_look(m, nthTemp(src,n));
//printf("mark end\n");fflush(stdout);
		 strcpy(result+i, s);
		 i += strlen(s);
	       }
	break;
      case 'd': {int n = atoi(++p);
		 string s = Temp_look(m, nthTemp(dst,n));
		 strcpy(result+i, s);
		 i += strlen(s);
	       }
	break;
      case 'j': assert(jumps); 
	       {int n = atoi(++p);
		 string s = Temp_labelstring(nthLabel(jumps->labels,n));
		 strcpy(result+i, s);
		 i += strlen(s);
	       }
	break;
      case '`': result[i] = '`'; i++; 
	break;
      default: assert(0);
      }
    else {result[i] = *p; i++; }
  result[i] = '\0';
}
Exemplo n.º 5
0
T_exp T_Temp(Temp_temp temp)
{
	T_exp p = (T_exp) checked_malloc(sizeof *p);

	p->kind=T_TEMP;

	p->PrintMyNodeSerialNumber = serial_node_number++;

	sprintf(p->PrintTheKindOfTreeIAm,"TEMP %s",Temp_look(Temp_name(),temp));
	
	p->u.TEMP=temp;
	
	return p;
}
Exemplo n.º 6
0
T_exp T_JumpRegister(Temp_temp temp)
{
	T_exp p = (T_exp) checked_malloc(sizeof *p);
 
	p->kind=T_JUMP;
 
	p->PrintMyNodeSerialNumber = serial_node_number++;

	sprintf(p->PrintTheKindOfTreeIAm,"JUMP %s",Temp_look(Temp_name(),temp));

	p->u.JUMP.type = T_JUMP_REGISTER;
	p->u.JUMP.u.temp=temp;
 
	return p;
}