Beispiel #1
0
Value* interpereteFloatOperator(Token *t, Value *v2, Value *v3){
	switch ((int)t->extra){
		case ADDITION:
			*((float*)v2->extra) += *((float*)v3->extra);
			break;
		case SUBTRACTION:
			*((float*)v2->extra) -= *((float*)v3->extra);
			break;
		case MULTIPLICATION:
			*((float*)v2->extra) *= *((float*)v3->extra);
			break;
		case DIVISION:
			*((float*)v2->extra) /= *((float*)v3->extra);
			break;
		case EQUALITY:
		case INEQUALITY:
		case GREATER_THAN:
		case GREATER_OR_EQUAL:
		case LESS_THAN:
		case LESS_OR_EQUAL:
			v2->type = INTEGER;
			*((int*)v2->extra) = comparef((int)t->extra, *((float*)v2->extra), *((float*)v3->extra));
			break;
		case PRE_INC:
		case PRE_DEC:
		case POST_INC:
		case POST_DEC:
		{
			v2 = v3;
			float old_val = *((float*)v2->extra);
			float new_val;
			if ((int)t->extra == POST_INC || (int)t->extra == PRE_INC){
				new_val = old_val + 1.0f;
			}
			else{
				new_val = old_val - 1.0f;
			}
			interpreteAssignment(getVarName((int)t->firstChild->extra), FLOAT, &new_val);

			if ((int)t->extra == PRE_INC || (int)t->extra == PRE_DEC){
				*((float*)v2->extra) = new_val;
			}
		}
		break;
		case NEGATE:
			v2 = v3;
			*((float*)v2->extra) = -*((float*)v2->extra);
			break;
		case PLUS:
			v2 = v3;
			break;
		default:
			PERROR("");
		break;
	}
	return v2;
}
Beispiel #2
0
void registerpair(file_t **matchlist, file_t *newmatch, 
		  int (*comparef)(file_t *f1, file_t *f2))
{
  file_t *traverse;
  file_t *back;

  (*matchlist)->hasdupes = 1;

  back = 0;
  traverse = *matchlist;
  while (traverse)
  {
    if (comparef(newmatch, traverse) <= 0)
    {
      newmatch->duplicates = traverse;
      
      if (back == 0)
      {
	*matchlist = newmatch; /* update pointer to head of list */

	newmatch->hasdupes = 1;
	traverse->hasdupes = 0; /* flag is only for first file in dupe chain */
      }
      else
	back->duplicates = newmatch;

      break;
    }
    else
    {
      if (traverse->duplicates == 0)
      {
	traverse->duplicates = newmatch;
	
	if (back == 0)
	  traverse->hasdupes = 1;
	
	break;
      }
    }
    
    back = traverse;
    traverse = traverse->duplicates;
  }
}
Beispiel #3
0
static void
comparecf (_Complex float a, float r, float i)
{
  comparef (__real__ a, r);
  comparef (__imag__ a, i);
}