stage4/generate_cc/generate_cc_il.cc
changeset 41 8998c8b24b60
parent 35 9f3d6c089533
child 62 7955adc445b8
equal deleted inserted replaced
40:873a5b60a7ea 41:8998c8b24b60
   400       symbol_c *backup = this->default_variable_name.current_type;
   400       symbol_c *backup = this->default_variable_name.current_type;
   401       this->default_variable_name.current_type = &(this->bool_type);
   401       this->default_variable_name.current_type = &(this->bool_type);
   402       this->default_variable_name.accept(*this);
   402       this->default_variable_name.accept(*this);
   403       this->default_variable_name.current_type = backup;
   403       this->default_variable_name.current_type = backup;
   404 
   404 
   405       if (search_expression_type->is_time_type(this->default_variable_name.current_type) &&
   405       s4o.print(" = ");
   406           search_expression_type->is_time_type(this->current_operand_type)) {
   406       s4o.print(operation);
   407         s4o.print(" = __compare_timespec(");
   407       this->default_variable_name.current_type->accept(*this);
   408         s4o.print(operation);
   408       s4o.print("(2, ");
   409         s4o.print(", ");
   409       this->default_variable_name.accept(*this);
   410         this->default_variable_name.accept(*this);
   410       s4o.print(", ");
   411         s4o.print(", ");
   411       o->accept(*this);
   412         o->accept(*this);
   412       s4o.print(")");
   413         s4o.print(")");
   413 
   414       }
       
   415       else {
       
   416         s4o.print(" = (");
       
   417         this->default_variable_name.accept(*this);
       
   418         s4o.print(operation);
       
   419         o->accept(*this);
       
   420         s4o.print(")");
       
   421       }
       
   422       /* the data type resulting from this operation... */
   414       /* the data type resulting from this operation... */
   423       this->default_variable_name.current_type = &(this->bool_type);
   415       this->default_variable_name.current_type = &(this->bool_type);
   424       return NULL;
   416       return NULL;
   425     }
   417     }
   426 
   418 
  1213 }
  1205 }
  1214 
  1206 
  1215 void *visit(ADD_operator_c *symbol)	{
  1207 void *visit(ADD_operator_c *symbol)	{
  1216   if (search_expression_type->is_time_type(this->default_variable_name.current_type) &&
  1208   if (search_expression_type->is_time_type(this->default_variable_name.current_type) &&
  1217       search_expression_type->is_time_type(this->current_operand_type)) {
  1209       search_expression_type->is_time_type(this->current_operand_type)) {
  1218     XXX_function("__add_timespec", &(this->default_variable_name), this->current_operand);
  1210     XXX_function("__time_add", &(this->default_variable_name), this->current_operand);
  1219     /* the data type resulting from this operation... */
  1211     /* the data type resulting from this operation... */
  1220     this->default_variable_name.current_type = this->current_operand_type;
  1212     this->default_variable_name.current_type = this->current_operand_type;
  1221     return NULL;
  1213     return NULL;
  1222   }
  1214   }
  1223   if (search_expression_type->is_num_type(this->default_variable_name.current_type) &&
  1215   if (search_expression_type->is_num_type(this->default_variable_name.current_type) &&
  1232 }
  1224 }
  1233 
  1225 
  1234 void *visit(SUB_operator_c *symbol)	{
  1226 void *visit(SUB_operator_c *symbol)	{
  1235   if (search_expression_type->is_time_type(this->default_variable_name.current_type) &&
  1227   if (search_expression_type->is_time_type(this->default_variable_name.current_type) &&
  1236       search_expression_type->is_time_type(this->current_operand_type)) {
  1228       search_expression_type->is_time_type(this->current_operand_type)) {
  1237     XXX_function("__sub_timespec", &(this->default_variable_name), this->current_operand);
  1229     XXX_function("__time_sub", &(this->default_variable_name), this->current_operand);
  1238     /* the data type resulting from this operation... */
  1230     /* the data type resulting from this operation... */
  1239     this->default_variable_name.current_type = this->current_operand_type;
  1231     this->default_variable_name.current_type = this->current_operand_type;
  1240     return NULL;
  1232     return NULL;
  1241   }
  1233   }
  1242   if (search_expression_type->is_num_type(this->default_variable_name.current_type) &&
  1234   if (search_expression_type->is_num_type(this->default_variable_name.current_type) &&
  1251 }
  1243 }
  1252 
  1244 
  1253 void *visit(MUL_operator_c *symbol)	{
  1245 void *visit(MUL_operator_c *symbol)	{
  1254   if (search_expression_type->is_time_type(this->default_variable_name.current_type) &&
  1246   if (search_expression_type->is_time_type(this->default_variable_name.current_type) &&
  1255       search_expression_type->is_integer_type(this->current_operand_type)) {
  1247       search_expression_type->is_integer_type(this->current_operand_type)) {
  1256     XXX_function("__mul_timespec", &(this->default_variable_name), this->current_operand);
  1248     XXX_function("__time_mul", &(this->default_variable_name), this->current_operand);
  1257     /* the data type resulting from this operation... */
  1249     /* the data type resulting from this operation... */
  1258     this->default_variable_name.current_type = this->current_operand_type;
  1250     this->default_variable_name.current_type = this->current_operand_type;
  1259     return NULL;
  1251     return NULL;
  1260   }
  1252   }
  1261   if (search_expression_type->is_num_type(this->default_variable_name.current_type) &&
  1253   if (search_expression_type->is_num_type(this->default_variable_name.current_type) &&
  1290   else {ERROR;}
  1282   else {ERROR;}
  1291   return NULL;
  1283   return NULL;
  1292 }
  1284 }
  1293 
  1285 
  1294 void *visit(GT_operator_c *symbol)	{
  1286 void *visit(GT_operator_c *symbol)	{
  1295   return CMP_operator(this->current_operand, " > ");
  1287   return CMP_operator(this->current_operand, "__gt_");
  1296 }
  1288 }
  1297 
  1289 
  1298 void *visit(GE_operator_c *symbol)	{
  1290 void *visit(GE_operator_c *symbol)	{
  1299   return CMP_operator(this->current_operand, " >= ");
  1291   return CMP_operator(this->current_operand, "__ge_");
  1300 }
  1292 }
  1301 
  1293 
  1302 void *visit(EQ_operator_c *symbol)	{
  1294 void *visit(EQ_operator_c *symbol)	{
  1303   return CMP_operator(this->current_operand, " == ");
  1295   return CMP_operator(this->current_operand, "__eq_");
  1304 }
  1296 }
  1305 
  1297 
  1306 void *visit(LT_operator_c *symbol)	{
  1298 void *visit(LT_operator_c *symbol)	{
  1307   return CMP_operator(this->current_operand, " < ");
  1299   return CMP_operator(this->current_operand, "__lt_");
  1308 }
  1300 }
  1309 
  1301 
  1310 void *visit(LE_operator_c *symbol)	{
  1302 void *visit(LE_operator_c *symbol)	{
  1311   return CMP_operator(this->current_operand, " <= ");
  1303   return CMP_operator(this->current_operand, "__le_");
  1312 }
  1304 }
  1313 
  1305 
  1314 void *visit(NE_operator_c *symbol)	{
  1306 void *visit(NE_operator_c *symbol)	{
  1315   return CMP_operator(this->current_operand, " != ");
  1307   return CMP_operator(this->current_operand, "__ne_");
  1316 }
  1308 }
  1317 
  1309 
  1318 
  1310 
  1319 //SYM_REF0(CAL_operator_c)
  1311 //SYM_REF0(CAL_operator_c)
  1320 // This method will be called from within the il_fb_call_c visitor method
  1312 // This method will be called from within the il_fb_call_c visitor method